volar-service-typescript 0.0.51 → 0.0.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,18 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = void 0;
4
- var semantic_1 = require("./lib/plugins/semantic");
3
+ exports.create = create;
5
4
  const directiveComment_1 = require("./lib/plugins/directiveComment");
6
5
  const docCommentTemplate_1 = require("./lib/plugins/docCommentTemplate");
7
- const semantic_2 = require("./lib/plugins/semantic");
6
+ const semantic_1 = require("./lib/plugins/semantic");
8
7
  const syntactic_1 = require("./lib/plugins/syntactic");
9
8
  function create(ts, options) {
10
9
  return [
11
- (0, semantic_2.create)(ts, options),
10
+ (0, semantic_1.create)(ts, options),
12
11
  (0, syntactic_1.create)(ts, options),
13
12
  (0, docCommentTemplate_1.create)(ts),
14
13
  (0, directiveComment_1.create)(),
15
14
  ];
16
15
  }
17
- exports.create = create;
18
16
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFormatCodeSettings = void 0;
3
+ exports.getFormatCodeSettings = getFormatCodeSettings;
4
4
  const shared_1 = require("../shared");
5
5
  async function getFormatCodeSettings(ctx, document, options) {
6
6
  const config = await ctx.env.getConfiguration?.((0, shared_1.getConfigTitle)(document) + '.format') ?? {};
@@ -29,5 +29,4 @@ async function getFormatCodeSettings(ctx, document, options) {
29
29
  semicolons: config.semicolons ?? 'ignore',
30
30
  };
31
31
  }
32
- exports.getFormatCodeSettings = getFormatCodeSettings;
33
32
  //# sourceMappingURL=getFormatCodeSettings.js.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getUserPreferences = void 0;
3
+ exports.getUserPreferences = getUserPreferences;
4
4
  const path = require("path-browserify");
5
5
  const shared_1 = require("../shared");
6
6
  const vscode_uri_1 = require("vscode-uri");
@@ -49,7 +49,6 @@ async function getUserPreferences(ctx, document) {
49
49
  };
50
50
  return preferences;
51
51
  }
52
- exports.getUserPreferences = getUserPreferences;
53
52
  function getQuoteStylePreference(config) {
54
53
  switch (config.quoteStyle) {
55
54
  case 'single': return 'single';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = void 0;
3
+ exports.create = create;
4
4
  const nls = require("vscode-nls");
5
5
  const shared_1 = require("../shared");
6
6
  const localize = nls.loadMessageBundle(); // TODO: not working
@@ -66,5 +66,4 @@ function create() {
66
66
  },
67
67
  };
68
68
  }
69
- exports.create = create;
70
69
  //# sourceMappingURL=directiveComment.js.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = void 0;
3
+ exports.create = create;
4
4
  const nls = require("vscode-nls");
5
5
  const shared_1 = require("../shared");
6
6
  const lspConverters_1 = require("../utils/lspConverters");
@@ -50,7 +50,6 @@ function create(ts) {
50
50
  },
51
51
  };
52
52
  }
53
- exports.create = create;
54
53
  function createCompletionItem(document, position, insertText) {
55
54
  const item = { label: '/** */' };
56
55
  item.kind = 1;
@@ -1,4 +1,4 @@
1
- import type { ProviderResult, LanguageServiceContext, LanguageServicePlugin } from '@volar/language-service';
1
+ import type { LanguageServiceContext, LanguageServicePlugin, ProviderResult } from '@volar/language-service';
2
2
  import type * as ts from 'typescript';
3
3
  import type { TextDocument } from 'vscode-languageserver-textdocument';
4
4
  import { URI } from 'vscode-uri';
@@ -1,18 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = void 0;
3
+ exports.create = create;
4
4
  const path = require("path-browserify");
5
5
  const semver = require("semver");
6
6
  const tsWithImportCache = require("typescript-auto-import-cache");
7
+ const vscode_uri_1 = require("vscode-uri");
7
8
  const getFormatCodeSettings_1 = require("../configs/getFormatCodeSettings");
8
9
  const getUserPreferences_1 = require("../configs/getUserPreferences");
9
- const shared_1 = require("../shared");
10
- const lspConverters_1 = require("../utils/lspConverters");
11
- const snippetForFunctionCall_1 = require("../utils/snippetForFunctionCall");
12
10
  const codeActions = require("../semanticFeatures/codeAction");
13
11
  const codeActionResolve = require("../semanticFeatures/codeActionResolve");
14
12
  const semanticTokens = require("../semanticFeatures/semanticTokens");
15
- const vscode_uri_1 = require("vscode-uri");
13
+ const shared_1 = require("../shared");
14
+ const lspConverters_1 = require("../utils/lspConverters");
15
+ const snippetForFunctionCall_1 = require("../utils/snippetForFunctionCall");
16
16
  const documentRegistries = [];
17
17
  function getDocumentRegistry(ts, useCaseSensitiveFileNames, currentDirectory) {
18
18
  let documentRegistry = documentRegistries.find(item => item[0] === useCaseSensitiveFileNames && item[1] === currentDirectory)?.[2];
@@ -69,43 +69,27 @@ function create(ts, { isValidationEnabled = async (document, context) => {
69
69
  'class',
70
70
  'enum',
71
71
  'interface',
72
- 'struct',
73
72
  'typeParameter',
74
73
  'type',
75
74
  'parameter',
76
75
  'variable',
77
76
  'property',
78
77
  'enumMember',
79
- 'decorator',
80
- 'event',
81
78
  'function',
82
79
  'method',
83
- 'macro',
84
- 'label',
85
- 'comment',
86
- 'string',
87
- 'keyword',
88
- 'number',
89
- 'regexp',
90
- 'operator',
91
80
  ],
92
81
  tokenModifiers: [
93
82
  'declaration',
94
- 'definition',
95
83
  'readonly',
96
84
  'static',
97
- 'deprecated',
98
- 'abstract',
99
85
  'async',
100
- 'modification',
101
- 'documentation',
102
86
  'defaultLibrary',
87
+ 'local', // additional
103
88
  ],
104
89
  },
105
90
  },
106
91
  workspaceSymbolProvider: true,
107
92
  // fileRenameEdits: true,
108
- selectionRangeProvider: true,
109
93
  signatureHelpProvider: {
110
94
  triggerCharacters: ['(', ',', '<'],
111
95
  retriggerCharacters: [')'],
@@ -197,7 +181,9 @@ function create(ts, { isValidationEnabled = async (document, context) => {
197
181
  function updateSourceScriptFileNames() {
198
182
  sourceScriptNames.clear();
199
183
  for (const fileName of languageServiceHost.getScriptFileNames()) {
200
- const uri = ctx.fileNameToUri(fileName);
184
+ const maybeEmbeddedUri = ctx.fileNameToUri(fileName);
185
+ const decoded = context.decodeEmbeddedDocumentUri(maybeEmbeddedUri);
186
+ const uri = decoded ? decoded[0] : maybeEmbeddedUri;
201
187
  const sourceScript = context.language.scripts.get(uri);
202
188
  if (sourceScript?.generated) {
203
189
  const tsCode = sourceScript.generated.languagePlugin.typescript?.getServiceScript(sourceScript.generated.root);
@@ -633,7 +619,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
633
619
  return items
634
620
  .filter(item => item.containerName || item.kind !== 'alias')
635
621
  .map(item => (0, lspConverters_1.convertNavigateToItem)(item, ctx.getTextDocument(ctx.fileNameToUri(item.fileName))))
636
- .filter(shared_1.notEmpty);
622
+ .filter(item => !!item);
637
623
  });
638
624
  },
639
625
  provideFileRenameEdits(oldUri, newUri, token) {
@@ -652,25 +638,6 @@ function create(ts, { isValidationEnabled = async (document, context) => {
652
638
  return (0, lspConverters_1.convertFileTextChanges)(response, ctx.fileNameToUri, ctx.getTextDocument);
653
639
  });
654
640
  },
655
- provideSelectionRanges(document, positions, token) {
656
- const uri = vscode_uri_1.URI.parse(document.uri);
657
- if (!isSemanticDocument(uri, document)) {
658
- return;
659
- }
660
- return worker(token, () => {
661
- return positions
662
- .map(position => {
663
- const fileName = ctx.uriToFileName(uri);
664
- const offset = document.offsetAt(position);
665
- const range = (0, shared_1.safeCall)(() => ctx.languageService.getSmartSelectionRange(fileName, offset));
666
- if (!range) {
667
- return;
668
- }
669
- return (0, lspConverters_1.convertSelectionRange)(range, document);
670
- })
671
- .filter(shared_1.notEmpty);
672
- });
673
- },
674
641
  provideSignatureHelp(document, position, context, token) {
675
642
  const uri = vscode_uri_1.URI.parse(document.uri);
676
643
  if (!isSemanticDocument(uri, document)) {
@@ -756,7 +723,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
756
723
  const suggestionDiagnostics = (0, shared_1.safeCall)(() => ctx.languageService.getSuggestionDiagnostics(fileName)) ?? [];
757
724
  return [...syntacticDiagnostics, ...suggestionDiagnostics]
758
725
  .map(diagnostic => (0, lspConverters_1.convertDiagnostic)(diagnostic, document, ctx.fileNameToUri, ctx.getTextDocument))
759
- .filter(shared_1.notEmpty);
726
+ .filter(diagnostic => !!diagnostic);
760
727
  }
761
728
  else if (mode === 'semantic') {
762
729
  const semanticDiagnostics = (0, shared_1.safeCall)(() => program.getSemanticDiagnostics(sourceFile, token)) ?? [];
@@ -765,7 +732,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
765
732
  : [];
766
733
  return [...semanticDiagnostics, ...declarationDiagnostics]
767
734
  .map(diagnostic => (0, lspConverters_1.convertDiagnostic)(diagnostic, document, ctx.fileNameToUri, ctx.getTextDocument))
768
- .filter(shared_1.notEmpty);
735
+ .filter(diagnostic => !!diagnostic);
769
736
  }
770
737
  });
771
738
  }
@@ -822,7 +789,6 @@ function create(ts, { isValidationEnabled = async (document, context) => {
822
789
  },
823
790
  };
824
791
  }
825
- exports.create = create;
826
792
  function getBasicTriggerCharacters(tsVersion) {
827
793
  const triggerCharacters = ['.', '"', '\'', '`', '/', '<'];
828
794
  // https://github.com/microsoft/vscode/blob/8e65ae28d5fb8b3c931135da1a41edb9c80ae46f/extensions/typescript-language-features/src/languageFeatures/completions.ts#L811-L833
@@ -1,6 +1,6 @@
1
- import type { ProviderResult, LanguageServiceContext, LanguageServicePlugin } from '@volar/language-service';
2
- import type { TextDocument } from 'vscode-languageserver-textdocument';
1
+ import type { LanguageServiceContext, LanguageServicePlugin, ProviderResult } from '@volar/language-service';
3
2
  import type * as ts from 'typescript';
3
+ import type { TextDocument } from 'vscode-languageserver-textdocument';
4
4
  export declare function getLanguageServiceByDocument(ts: typeof import('typescript'), document: TextDocument): {
5
5
  languageService: ts.LanguageService;
6
6
  fileName: string;
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = exports.getLanguageServiceByDocument = void 0;
3
+ exports.getLanguageServiceByDocument = getLanguageServiceByDocument;
4
+ exports.create = create;
4
5
  const getFormatCodeSettings_1 = require("../configs/getFormatCodeSettings");
5
6
  const shared_1 = require("../shared");
6
- const lspConverters_1 = require("../utils/lspConverters");
7
7
  const syntaxOnlyService_1 = require("../syntaxOnlyService");
8
+ const lspConverters_1 = require("../utils/lspConverters");
8
9
  const snapshots = new WeakMap();
9
10
  let created;
10
11
  function getLanguageServiceByDocument(ts, document) {
@@ -29,7 +30,6 @@ function getLanguageServiceByDocument(ts, document) {
29
30
  fileName: document.uri,
30
31
  };
31
32
  }
32
- exports.getLanguageServiceByDocument = getLanguageServiceByDocument;
33
33
  function create(ts, { isFormattingEnabled = async (document, context) => {
34
34
  return await context.env.getConfiguration?.((0, shared_1.getConfigTitle)(document) + '.format.enable') ?? true;
35
35
  }, } = {}) {
@@ -41,6 +41,7 @@ function create(ts, { isFormattingEnabled = async (document, context) => {
41
41
  configurationSections: ['javascript.autoClosingTags', 'typescript.autoClosingTags'],
42
42
  },
43
43
  foldingRangeProvider: true,
44
+ selectionRangeProvider: true,
44
45
  documentSymbolProvider: true,
45
46
  documentFormattingProvider: true,
46
47
  documentOnTypeFormattingProvider: {
@@ -76,6 +77,24 @@ function create(ts, { isFormattingEnabled = async (document, context) => {
76
77
  }
77
78
  return outliningSpans.map(span => (0, lspConverters_1.convertOutliningSpan)(span, document));
78
79
  },
80
+ provideSelectionRanges(document, positions) {
81
+ if (!(0, shared_1.isTsDocument)(document)) {
82
+ return;
83
+ }
84
+ const { languageService, fileName } = getLanguageServiceByDocument(ts, document);
85
+ const ranges = positions
86
+ .map(position => {
87
+ const offset = document.offsetAt(position);
88
+ const range = (0, shared_1.safeCall)(() => languageService.getSmartSelectionRange(fileName, offset));
89
+ if (!range) {
90
+ return;
91
+ }
92
+ return (0, lspConverters_1.convertSelectionRange)(range, document);
93
+ });
94
+ if (ranges.every(range => !!range)) {
95
+ return ranges;
96
+ }
97
+ },
79
98
  provideDocumentSymbols(document) {
80
99
  if (!(0, shared_1.isTsDocument)(document)) {
81
100
  return;
@@ -133,5 +152,4 @@ function create(ts, { isFormattingEnabled = async (document, context) => {
133
152
  },
134
153
  };
135
154
  }
136
- exports.create = create;
137
155
  //# sourceMappingURL=syntactic.js.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.register = void 0;
3
+ exports.register = register;
4
4
  const getFormatCodeSettings_1 = require("../configs/getFormatCodeSettings");
5
5
  const getUserPreferences_1 = require("../configs/getUserPreferences");
6
6
  const shared_1 = require("../shared");
@@ -260,5 +260,4 @@ function register(ctx) {
260
260
  }
261
261
  };
262
262
  }
263
- exports.register = register;
264
263
  //# sourceMappingURL=codeAction.js.map
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveOrganizeImportsCodeAction = exports.resolveRefactorCodeAction = exports.resolveFixAllCodeAction = exports.register = void 0;
3
+ exports.register = register;
4
+ exports.resolveFixAllCodeAction = resolveFixAllCodeAction;
5
+ exports.resolveRefactorCodeAction = resolveRefactorCodeAction;
6
+ exports.resolveOrganizeImportsCodeAction = resolveOrganizeImportsCodeAction;
4
7
  const getFormatCodeSettings_1 = require("../configs/getFormatCodeSettings");
5
8
  const getUserPreferences_1 = require("../configs/getUserPreferences");
6
9
  const shared_1 = require("../shared");
@@ -26,13 +29,11 @@ function register(ctx) {
26
29
  return codeAction;
27
30
  };
28
31
  }
29
- exports.register = register;
30
32
  function resolveFixAllCodeAction(ctx, codeAction, data, formatOptions, preferences) {
31
33
  const fixes = data.fixIds.map(fixId => (0, shared_1.safeCall)(() => ctx.languageService.getCombinedCodeFix({ type: 'file', fileName: data.fileName }, fixId, formatOptions, preferences)));
32
34
  const changes = fixes.map(fix => fix?.changes ?? []).flat();
33
35
  codeAction.edit = (0, lspConverters_1.convertFileTextChanges)(changes, ctx.fileNameToUri, ctx.getTextDocument);
34
36
  }
35
- exports.resolveFixAllCodeAction = resolveFixAllCodeAction;
36
37
  function resolveRefactorCodeAction(ctx, codeAction, data, document, formatOptions, preferences) {
37
38
  const editInfo = (0, shared_1.safeCall)(() => ctx.languageService.getEditsForRefactor(data.fileName, formatOptions, data.range, data.refactorName, data.actionName, preferences));
38
39
  if (!editInfo) {
@@ -43,10 +44,8 @@ function resolveRefactorCodeAction(ctx, codeAction, data, document, formatOption
43
44
  codeAction.command = ctx.commands.rename.create(document.uri, document.positionAt(editInfo.renameLocation));
44
45
  }
45
46
  }
46
- exports.resolveRefactorCodeAction = resolveRefactorCodeAction;
47
47
  function resolveOrganizeImportsCodeAction(ctx, codeAction, data, formatOptions, preferences) {
48
48
  const changes = (0, shared_1.safeCall)(() => ctx.languageService.organizeImports({ type: 'file', fileName: data.fileName }, formatOptions, preferences));
49
49
  codeAction.edit = (0, lspConverters_1.convertFileTextChanges)(changes ?? [], ctx.fileNameToUri, ctx.getTextDocument);
50
50
  }
51
- exports.resolveOrganizeImportsCodeAction = resolveOrganizeImportsCodeAction;
52
51
  //# sourceMappingURL=codeActionResolve.js.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.register = void 0;
3
+ exports.register = register;
4
4
  const shared_1 = require("../shared");
5
5
  function register(ts, ctx) {
6
6
  return (uri, document, range, legend) => {
@@ -19,14 +19,18 @@ function register(ts, ctx) {
19
19
  tokenModifiersTable[0 /* TokenModifier.declaration */] = 1 << legend.tokenModifiers.indexOf('declaration');
20
20
  tokenModifiersTable[3 /* TokenModifier.readonly */] = 1 << legend.tokenModifiers.indexOf('readonly');
21
21
  tokenModifiersTable[1 /* TokenModifier.static */] = 1 << legend.tokenModifiers.indexOf('static');
22
- tokenModifiersTable[5 /* TokenModifier.local */] = 1 << legend.tokenModifiers.indexOf('local'); // missing in server tokenModifiers
22
+ tokenModifiersTable[5 /* TokenModifier.local */] = 1 << legend.tokenModifiers.indexOf('local');
23
23
  tokenModifiersTable[4 /* TokenModifier.defaultLibrary */] = 1 << legend.tokenModifiers.indexOf('defaultLibrary');
24
24
  tokenModifiersTable = tokenModifiersTable.map(mod => Math.max(mod, 0));
25
+ const end = start + length;
25
26
  const tokenSpan = response.spans;
26
27
  const tokens = [];
27
28
  let i = 0;
28
29
  while (i < tokenSpan.length) {
29
30
  const offset = tokenSpan[i++];
31
+ if (offset >= end) {
32
+ break;
33
+ }
30
34
  const length = tokenSpan[i++];
31
35
  const tsClassification = tokenSpan[i++];
32
36
  const tokenType = getTokenTypeFromClassification(tsClassification);
@@ -66,7 +70,6 @@ function register(ts, ctx) {
66
70
  }
67
71
  };
68
72
  }
69
- exports.register = register;
70
73
  function docLineLength(document, line) {
71
74
  const currentLineOffset = document.offsetAt({ line, character: 0 });
72
75
  const nextLineOffset = document.offsetAt({ line: line + 1, character: 0 });
@@ -99,7 +102,7 @@ tokenModifiers[2 /* TokenModifier.async */] = 'async';
99
102
  tokenModifiers[0 /* TokenModifier.declaration */] = 'declaration';
100
103
  tokenModifiers[3 /* TokenModifier.readonly */] = 'readonly';
101
104
  tokenModifiers[1 /* TokenModifier.static */] = 'static';
102
- tokenModifiers[5 /* TokenModifier.local */] = 'local'; // missing in server tokenModifiers
105
+ tokenModifiers[5 /* TokenModifier.local */] = 'local';
103
106
  tokenModifiers[4 /* TokenModifier.defaultLibrary */] = 'defaultLibrary';
104
107
  // mapping for the original ExperimentalProtocol.ClassificationType from TypeScript (only used when plugin is not available)
105
108
  const tokenTypeMap = [];
package/lib/shared.d.ts CHANGED
@@ -3,5 +3,4 @@ export declare function getConfigTitle(document: TextDocument): string;
3
3
  export declare function isTsDocument(document: TextDocument): boolean;
4
4
  export declare function isJsonDocument(document: TextDocument): boolean;
5
5
  export declare function safeCall<T>(cb: () => T): T | undefined;
6
- export declare function notEmpty(value: any): value is NonNullable<typeof value>;
7
6
  //# sourceMappingURL=shared.d.ts.map
package/lib/shared.js CHANGED
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.notEmpty = exports.safeCall = exports.isJsonDocument = exports.isTsDocument = exports.getConfigTitle = void 0;
3
+ exports.getConfigTitle = getConfigTitle;
4
+ exports.isTsDocument = isTsDocument;
5
+ exports.isJsonDocument = isJsonDocument;
6
+ exports.safeCall = safeCall;
4
7
  function getConfigTitle(document) {
5
8
  if (document.languageId === 'javascriptreact') {
6
9
  return 'javascript';
@@ -10,28 +13,20 @@ function getConfigTitle(document) {
10
13
  }
11
14
  return document.languageId;
12
15
  }
13
- exports.getConfigTitle = getConfigTitle;
14
16
  function isTsDocument(document) {
15
17
  return document.languageId === 'javascript' ||
16
18
  document.languageId === 'typescript' ||
17
19
  document.languageId === 'javascriptreact' ||
18
20
  document.languageId === 'typescriptreact';
19
21
  }
20
- exports.isTsDocument = isTsDocument;
21
22
  function isJsonDocument(document) {
22
23
  return document.languageId === 'json' ||
23
24
  document.languageId === 'jsonc';
24
25
  }
25
- exports.isJsonDocument = isJsonDocument;
26
26
  function safeCall(cb) {
27
27
  try {
28
28
  return cb();
29
29
  }
30
30
  catch { }
31
31
  }
32
- exports.safeCall = safeCall;
33
- function notEmpty(value) {
34
- return value !== null && value !== undefined;
35
- }
36
- exports.notEmpty = notEmpty;
37
32
  //# sourceMappingURL=shared.js.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSyntaxOnlyService = void 0;
3
+ exports.createSyntaxOnlyService = createSyntaxOnlyService;
4
4
  function createSyntaxOnlyService(ts, syntaxOnly) {
5
5
  let currentProjectVersion = -1;
6
6
  let fileNames = [];
@@ -41,5 +41,4 @@ function createSyntaxOnlyService(ts, syntaxOnly) {
41
41
  }
42
42
  }
43
43
  }
44
- exports.createSyntaxOnlyService = createSyntaxOnlyService;
45
44
  //# sourceMappingURL=syntaxOnlyService.js.map
@@ -1,10 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertTextSpan = exports.convertDocumentSpantoLocationLink = exports.convertDefinitionInfoAndBoundSpan = exports.convertDocumentSpanToLocation = exports.convertCallHierarchyItem = exports.convertCallHierarchyOutgoingCall = exports.convertCallHierarchyIncomingCall = exports.convertTextChange = exports.convertOutliningSpanKind = exports.convertOutliningSpan = exports.convertNavTree = exports.convertQuickInfo = exports.convertRenameLocations = exports.convertFileTextChanges = exports.convertSelectionRange = exports.convertHighlightSpan = exports.convertInlayHint = exports.convertNavigateToItem = exports.getLineText = exports.convertCompletionInfo = exports.applyCompletionEntryDetails = exports.convertDiagnostic = void 0;
3
+ exports.convertDiagnostic = convertDiagnostic;
4
+ exports.applyCompletionEntryDetails = applyCompletionEntryDetails;
5
+ exports.convertCompletionInfo = convertCompletionInfo;
6
+ exports.getLineText = getLineText;
7
+ exports.convertNavigateToItem = convertNavigateToItem;
8
+ exports.convertInlayHint = convertInlayHint;
9
+ exports.convertHighlightSpan = convertHighlightSpan;
10
+ exports.convertSelectionRange = convertSelectionRange;
11
+ exports.convertFileTextChanges = convertFileTextChanges;
12
+ exports.convertRenameLocations = convertRenameLocations;
13
+ exports.convertQuickInfo = convertQuickInfo;
14
+ exports.convertNavTree = convertNavTree;
15
+ exports.convertOutliningSpan = convertOutliningSpan;
16
+ exports.convertOutliningSpanKind = convertOutliningSpanKind;
17
+ exports.convertTextChange = convertTextChange;
18
+ exports.convertCallHierarchyIncomingCall = convertCallHierarchyIncomingCall;
19
+ exports.convertCallHierarchyOutgoingCall = convertCallHierarchyOutgoingCall;
20
+ exports.convertCallHierarchyItem = convertCallHierarchyItem;
21
+ exports.convertDocumentSpanToLocation = convertDocumentSpanToLocation;
22
+ exports.convertDefinitionInfoAndBoundSpan = convertDefinitionInfoAndBoundSpan;
23
+ exports.convertDocumentSpantoLocationLink = convertDocumentSpantoLocationLink;
24
+ exports.convertTextSpan = convertTextSpan;
4
25
  const path = require("path-browserify");
5
26
  const semver = require("semver");
6
27
  const PConst = require("../protocol.const");
7
- const shared_1 = require("../shared");
8
28
  const modifiers_1 = require("../utils/modifiers");
9
29
  const previewer = require("../utils/previewer");
10
30
  const typeConverters = require("../utils/typeConverters");
@@ -45,7 +65,6 @@ function convertDiagnostic(diag, document, fileNameToUri, getTextDocument) {
45
65
  }
46
66
  return diagnostic;
47
67
  }
48
- exports.convertDiagnostic = convertDiagnostic;
49
68
  function convertDiagnosticRelatedInformation(diag, fileNameToUri, getTextDocument) {
50
69
  if (diag.start === undefined) {
51
70
  return;
@@ -130,7 +149,6 @@ function applyCompletionEntryDetails(ts, item, data, document, fileNameToUri, ge
130
149
  handleKindModifiers(item, data);
131
150
  }
132
151
  }
133
- exports.applyCompletionEntryDetails = applyCompletionEntryDetails;
134
152
  // completion
135
153
  function convertCompletionInfo(ts, completionContext, document, position, createData) {
136
154
  const lt_320 = semver.lt(ts.version, '3.2.0');
@@ -330,7 +348,6 @@ function convertCompletionInfo(ts, completionContext, document, position, create
330
348
  return true;
331
349
  }
332
350
  }
333
- exports.convertCompletionInfo = convertCompletionInfo;
334
351
  function convertCompletionItemKind(kind) {
335
352
  switch (kind) {
336
353
  case PConst.Kind.primitiveType:
@@ -426,7 +443,6 @@ function getLineText(document, line) {
426
443
  });
427
444
  return text;
428
445
  }
429
- exports.getLineText = getLineText;
430
446
  // workspaceSymbol
431
447
  function convertNavigateToItem(item, document) {
432
448
  const info = {
@@ -443,7 +459,6 @@ function convertNavigateToItem(item, document) {
443
459
  }
444
460
  return info;
445
461
  }
446
- exports.convertNavigateToItem = convertNavigateToItem;
447
462
  function getLabel(item) {
448
463
  const label = item.name;
449
464
  if (item.kind === 'method' || item.kind === 'function') {
@@ -480,7 +495,6 @@ function convertInlayHint(hint, document) {
480
495
  result.paddingRight = hint.whitespaceAfter;
481
496
  return result;
482
497
  }
483
- exports.convertInlayHint = convertInlayHint;
484
498
  // documentHighlight
485
499
  function convertHighlightSpan(span, document) {
486
500
  return {
@@ -490,7 +504,6 @@ function convertHighlightSpan(span, document) {
490
504
  range: convertTextSpan(span.textSpan, document),
491
505
  };
492
506
  }
493
- exports.convertHighlightSpan = convertHighlightSpan;
494
507
  // selectionRanges
495
508
  function convertSelectionRange(range, document) {
496
509
  return {
@@ -500,7 +513,6 @@ function convertSelectionRange(range, document) {
500
513
  range: convertTextSpan(range.textSpan, document),
501
514
  };
502
515
  }
503
- exports.convertSelectionRange = convertSelectionRange;
504
516
  // rename
505
517
  function convertFileTextChanges(changes, fileNameToUri, getTextDocument) {
506
518
  const workspaceEdit = {};
@@ -538,7 +550,6 @@ function convertFileTextChanges(changes, fileNameToUri, getTextDocument) {
538
550
  }
539
551
  return workspaceEdit;
540
552
  }
541
- exports.convertFileTextChanges = convertFileTextChanges;
542
553
  // rename file
543
554
  function convertRenameLocations(newText, locations, fileNameToUri, getTextDocument) {
544
555
  const workspaceEdit = {};
@@ -565,7 +576,6 @@ function convertRenameLocations(newText, locations, fileNameToUri, getTextDocume
565
576
  }
566
577
  return workspaceEdit;
567
578
  }
568
- exports.convertRenameLocations = convertRenameLocations;
569
579
  // hover
570
580
  function convertQuickInfo(ts, info, document, fileNameToUri, getTextDocument) {
571
581
  const parts = [];
@@ -586,7 +596,6 @@ function convertQuickInfo(ts, info, document, fileNameToUri, getTextDocument) {
586
596
  range: convertTextSpan(info.textSpan, document),
587
597
  };
588
598
  }
589
- exports.convertQuickInfo = convertQuickInfo;
590
599
  // documentSymbol
591
600
  function convertNavTree(item, document) {
592
601
  if (!shouldIncludeEntry(item)) {
@@ -630,7 +639,6 @@ function convertNavTree(item, document) {
630
639
  return symbol;
631
640
  });
632
641
  }
633
- exports.convertNavTree = convertNavTree;
634
642
  const getSymbolKind = (kind) => {
635
643
  switch (kind) {
636
644
  case PConst.Kind.module: return 2;
@@ -669,7 +677,6 @@ function convertOutliningSpan(outliningSpan, document) {
669
677
  kind: convertOutliningSpanKind(outliningSpan.kind),
670
678
  };
671
679
  }
672
- exports.convertOutliningSpan = convertOutliningSpan;
673
680
  function convertOutliningSpanKind(kind) {
674
681
  switch (kind) {
675
682
  case 'comment': return 'comment';
@@ -679,7 +686,6 @@ function convertOutliningSpanKind(kind) {
679
686
  default: return undefined;
680
687
  }
681
688
  }
682
- exports.convertOutliningSpanKind = convertOutliningSpanKind;
683
689
  const foldEndPairCharacters = ['}', ']', ')', '`'];
684
690
  // https://github.com/microsoft/vscode/blob/bed61166fb604e519e82e4d1d1ed839bc45d65f8/extensions/typescript-language-features/src/languageFeatures/folding.ts#L61-L73
685
691
  function adjustFoldingEnd(start, end, document) {
@@ -703,7 +709,6 @@ function convertTextChange(edit, document) {
703
709
  newText: edit.newText,
704
710
  };
705
711
  }
706
- exports.convertTextChange = convertTextChange;
707
712
  // callHierarchy
708
713
  function convertCallHierarchyIncomingCall(item, ctx) {
709
714
  const uri = ctx.fileNameToUri(item.from.file);
@@ -712,19 +717,17 @@ function convertCallHierarchyIncomingCall(item, ctx) {
712
717
  from: convertCallHierarchyItem(item.from, ctx),
713
718
  fromRanges: item.fromSpans
714
719
  .map(span => convertTextSpan(span, document))
715
- .filter(shared_1.notEmpty),
720
+ .filter(span => !!span),
716
721
  };
717
722
  }
718
- exports.convertCallHierarchyIncomingCall = convertCallHierarchyIncomingCall;
719
723
  function convertCallHierarchyOutgoingCall(item, fromDocument, ctx) {
720
724
  return {
721
725
  to: convertCallHierarchyItem(item.to, ctx),
722
726
  fromRanges: item.fromSpans
723
727
  .map(span => convertTextSpan(span, fromDocument))
724
- .filter(shared_1.notEmpty),
728
+ .filter(span => !!span),
725
729
  };
726
730
  }
727
- exports.convertCallHierarchyOutgoingCall = convertCallHierarchyOutgoingCall;
728
731
  function convertCallHierarchyItem(item, ctx) {
729
732
  const rootPath = ctx.languageService.getProgram()?.getCompilerOptions().rootDir ?? '';
730
733
  const uri = ctx.fileNameToUri(item.file);
@@ -746,7 +749,6 @@ function convertCallHierarchyItem(item, ctx) {
746
749
  }
747
750
  return result;
748
751
  }
749
- exports.convertCallHierarchyItem = convertCallHierarchyItem;
750
752
  function isSourceFileItem(item) {
751
753
  return item.kind === PConst.Kind.script || item.kind === PConst.Kind.module && item.selectionSpan.start === 0;
752
754
  }
@@ -760,7 +762,6 @@ function convertDocumentSpanToLocation(documentSpan, ctx) {
760
762
  range,
761
763
  };
762
764
  }
763
- exports.convertDocumentSpanToLocation = convertDocumentSpanToLocation;
764
765
  function convertDefinitionInfoAndBoundSpan(info, document, ctx) {
765
766
  if (!info.definitions) {
766
767
  return [];
@@ -774,9 +775,8 @@ function convertDefinitionInfoAndBoundSpan(info, document, ctx) {
774
775
  return link;
775
776
  }
776
777
  })
777
- .filter(shared_1.notEmpty);
778
+ .filter(entry => !!entry);
778
779
  }
779
- exports.convertDefinitionInfoAndBoundSpan = convertDefinitionInfoAndBoundSpan;
780
780
  function convertDocumentSpantoLocationLink(documentSpan, ctx) {
781
781
  const targetUri = ctx.fileNameToUri(documentSpan.fileName);
782
782
  const document = ctx.getTextDocument(targetUri);
@@ -794,7 +794,6 @@ function convertDocumentSpantoLocationLink(documentSpan, ctx) {
794
794
  originSelectionRange,
795
795
  };
796
796
  }
797
- exports.convertDocumentSpantoLocationLink = convertDocumentSpantoLocationLink;
798
797
  function convertTextSpan(textSpan, document) {
799
798
  if (!document) {
800
799
  return {
@@ -807,5 +806,4 @@ function convertTextSpan(textSpan, document) {
807
806
  end: document.positionAt(textSpan.start + textSpan.length),
808
807
  };
809
808
  }
810
- exports.convertTextSpan = convertTextSpan;
811
809
  //# sourceMappingURL=lspConverters.js.map
@@ -4,9 +4,8 @@
4
4
  * Licensed under the MIT License. See License.txt in the project root for license information.
5
5
  *--------------------------------------------------------------------------------------------*/
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.parseKindModifier = void 0;
7
+ exports.parseKindModifier = parseKindModifier;
8
8
  function parseKindModifier(kindModifiers) {
9
9
  return new Set(kindModifiers.split(/,|\s+/g));
10
10
  }
11
- exports.parseKindModifier = parseKindModifier;
12
11
  //# sourceMappingURL=modifiers.js.map
@@ -4,7 +4,10 @@
4
4
  * Licensed under the MIT License. See License.txt in the project root for license information.
5
5
  *--------------------------------------------------------------------------------------------*/
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.addMarkdownDocumentation = exports.markdownDocumentation = exports.tagsMarkdownPreview = exports.plainWithLinks = void 0;
7
+ exports.plainWithLinks = plainWithLinks;
8
+ exports.tagsMarkdownPreview = tagsMarkdownPreview;
9
+ exports.markdownDocumentation = markdownDocumentation;
10
+ exports.addMarkdownDocumentation = addMarkdownDocumentation;
8
11
  function replaceLinks(text) {
9
12
  return text
10
13
  // Http(s) links
@@ -84,7 +87,6 @@ function getTagDocumentation(tag, fileNameToUri, getTextDocument) {
84
87
  function plainWithLinks(parts, fileNameToUri, getTextDocument) {
85
88
  return processInlineTags(convertLinkTags(parts, fileNameToUri, getTextDocument));
86
89
  }
87
- exports.plainWithLinks = plainWithLinks;
88
90
  /**
89
91
  * Convert `@link` inline tags to markdown links
90
92
  */
@@ -171,11 +173,9 @@ function convertLinkTags(parts, fileNameToUri, getTextDocument) {
171
173
  function tagsMarkdownPreview(tags, fileNameToUri, getTextDocument) {
172
174
  return tags.map(tag => getTagDocumentation(tag, fileNameToUri, getTextDocument)).join(' \n\n');
173
175
  }
174
- exports.tagsMarkdownPreview = tagsMarkdownPreview;
175
176
  function markdownDocumentation(documentation, tags, fileNameToUri, getTextDocument) {
176
177
  return addMarkdownDocumentation('', documentation, tags, fileNameToUri, getTextDocument);
177
178
  }
178
- exports.markdownDocumentation = markdownDocumentation;
179
179
  function addMarkdownDocumentation(out, documentation, tags, fileNameToUri, getTextDocument) {
180
180
  if (documentation) {
181
181
  out += plainWithLinks(documentation, fileNameToUri, getTextDocument);
@@ -188,5 +188,4 @@ function addMarkdownDocumentation(out, documentation, tags, fileNameToUri, getTe
188
188
  }
189
189
  return out;
190
190
  }
191
- exports.addMarkdownDocumentation = addMarkdownDocumentation;
192
191
  //# sourceMappingURL=previewer.js.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.snippetForFunctionCall = void 0;
3
+ exports.snippetForFunctionCall = snippetForFunctionCall;
4
4
  const PConst = require("../protocol.const");
5
5
  function snippetForFunctionCall(item, displayParts) {
6
6
  if (item.insertText && typeof item.insertText !== 'string') {
@@ -28,7 +28,6 @@ function snippetForFunctionCall(item, displayParts) {
28
28
  return snippet;
29
29
  }
30
30
  }
31
- exports.snippetForFunctionCall = snippetForFunctionCall;
32
31
  function getParameterListParts(displayParts) {
33
32
  const parts = [];
34
33
  let isInMethod = false;
@@ -1,5 +1,5 @@
1
1
  import type * as ts from 'typescript';
2
2
  export declare namespace SymbolKind {
3
- function fromProtocolScriptElementKind(kind: ts.ScriptElementKind): 2 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 15 | 22 | 26;
3
+ function fromProtocolScriptElementKind(kind: ts.ScriptElementKind): 2 | 5 | 10 | 22 | 11 | 6 | 7 | 13 | 12 | 9 | 26 | 15;
4
4
  }
5
5
  //# sourceMappingURL=typeConverters.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volar-service-typescript",
3
- "version": "0.0.51",
3
+ "version": "0.0.53",
4
4
  "description": "Integrate TypeScript into Volar",
5
5
  "homepage": "https://github.com/volarjs/services/tree/master/packages/typescript",
6
6
  "bugs": "https://github.com/volarjs/services/issues",
@@ -30,18 +30,18 @@
30
30
  "dependencies": {
31
31
  "path-browserify": "^1.0.1",
32
32
  "semver": "^7.5.4",
33
- "typescript-auto-import-cache": "^0.3.1",
33
+ "typescript-auto-import-cache": "^0.3.3",
34
34
  "vscode-languageserver-textdocument": "^1.0.11",
35
35
  "vscode-nls": "^5.2.0",
36
36
  "vscode-uri": "^3.0.8"
37
37
  },
38
38
  "peerDependencies": {
39
- "@volar/language-service": "~2.3.0"
39
+ "@volar/language-service": "~2.3.1"
40
40
  },
41
41
  "peerDependenciesMeta": {
42
42
  "@volar/language-service": {
43
43
  "optional": true
44
44
  }
45
45
  },
46
- "gitHead": "7af242537b552e0fb4391a38fdeb8115580085dc"
46
+ "gitHead": "8c61d6a8acc354e68c726727f72be7d318c583da"
47
47
  }