@volar/language-core 2.4.0-alpha.9 → 2.4.1

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.d.ts CHANGED
@@ -5,5 +5,5 @@ export * from './lib/types';
5
5
  export * from './lib/utils';
6
6
  import type { Language, LanguagePlugin, MapperFactory, SourceScript, VirtualCode } from './lib/types';
7
7
  export declare const defaultMapperFactory: MapperFactory;
8
- export declare function createLanguage<T>(plugins: LanguagePlugin<T>[], scriptRegistry: Map<T, SourceScript<T>>, sync: (id: T) => void): Language<T>;
8
+ export declare function createLanguage<T>(plugins: LanguagePlugin<T>[], scriptRegistry: Map<T, SourceScript<T>>, sync: (id: T, includeFsFiles: boolean) => void): Language<T>;
9
9
  export declare function forEachEmbeddedCode(virtualCode: VirtualCode): Generator<VirtualCode>;
package/index.js CHANGED
@@ -38,8 +38,8 @@ function createLanguage(plugins, scriptRegistry, sync) {
38
38
  fromVirtualCode(virtualCode) {
39
39
  return virtualCodeToSourceScriptMap.get(virtualCode);
40
40
  },
41
- get(id) {
42
- sync(id);
41
+ get(id, includeFsFiles = true) {
42
+ sync(id, includeFsFiles);
43
43
  const result = scriptRegistry.get(id);
44
44
  // The sync function provider may not always call the set function due to caching, so it is necessary to explicitly check isAssociationDirty.
45
45
  if (result?.isAssociationDirty) {
@@ -211,7 +211,7 @@ function createLanguage(plugins, scriptRegistry, sync) {
211
211
  sourceScript.isAssociationDirty = false;
212
212
  return {
213
213
  getAssociatedScript(id) {
214
- sync(id);
214
+ sync(id, true);
215
215
  const relatedSourceScript = scriptRegistry.get(id);
216
216
  if (relatedSourceScript) {
217
217
  relatedSourceScript.targetIds.add(sourceScript.id);
@@ -2,8 +2,11 @@ import type { CodeInformation } from './types';
2
2
  export declare function isHoverEnabled(info: CodeInformation): boolean;
3
3
  export declare function isInlayHintsEnabled(info: CodeInformation): boolean;
4
4
  export declare function isCodeLensEnabled(info: CodeInformation): boolean;
5
+ export declare function isMonikerEnabled(info: CodeInformation): boolean;
6
+ export declare function isInlineValueEnabled(info: CodeInformation): boolean;
5
7
  export declare function isSemanticTokensEnabled(info: CodeInformation): boolean;
6
8
  export declare function isCallHierarchyEnabled(info: CodeInformation): boolean;
9
+ export declare function isTypeHierarchyEnabled(info: CodeInformation): boolean;
7
10
  export declare function isRenameEnabled(info: CodeInformation): boolean;
8
11
  export declare function isDefinitionEnabled(info: CodeInformation): boolean;
9
12
  export declare function isTypeDefinitionEnabled(info: CodeInformation): boolean;
@@ -22,6 +25,6 @@ export declare function isFormattingEnabled(info: CodeInformation): boolean;
22
25
  export declare function isCompletionEnabled(info: CodeInformation): boolean;
23
26
  export declare function isAutoInsertEnabled(info: CodeInformation): boolean;
24
27
  export declare function isSignatureHelpEnabled(info: CodeInformation): boolean;
25
- export declare function shouldReportDiagnostics(info: CodeInformation): boolean;
28
+ export declare function shouldReportDiagnostics(info: CodeInformation, source: string | undefined, code: string | number | undefined): boolean;
26
29
  export declare function resolveRenameNewName(newName: string, info: CodeInformation): string;
27
30
  export declare function resolveRenameEditText(text: string, info: CodeInformation): string;
@@ -3,8 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isHoverEnabled = isHoverEnabled;
4
4
  exports.isInlayHintsEnabled = isInlayHintsEnabled;
5
5
  exports.isCodeLensEnabled = isCodeLensEnabled;
6
+ exports.isMonikerEnabled = isMonikerEnabled;
7
+ exports.isInlineValueEnabled = isInlineValueEnabled;
6
8
  exports.isSemanticTokensEnabled = isSemanticTokensEnabled;
7
9
  exports.isCallHierarchyEnabled = isCallHierarchyEnabled;
10
+ exports.isTypeHierarchyEnabled = isTypeHierarchyEnabled;
8
11
  exports.isRenameEnabled = isRenameEnabled;
9
12
  exports.isDefinitionEnabled = isDefinitionEnabled;
10
13
  exports.isTypeDefinitionEnabled = isTypeDefinitionEnabled;
@@ -35,6 +38,12 @@ function isInlayHintsEnabled(info) {
35
38
  function isCodeLensEnabled(info) {
36
39
  return !!info.semantic;
37
40
  }
41
+ function isMonikerEnabled(info) {
42
+ return !!info.semantic;
43
+ }
44
+ function isInlineValueEnabled(info) {
45
+ return !!info.semantic;
46
+ }
38
47
  function isSemanticTokensEnabled(info) {
39
48
  return typeof info.semantic === 'object'
40
49
  ? info.semantic.shouldHighlight?.() ?? true
@@ -43,6 +52,9 @@ function isSemanticTokensEnabled(info) {
43
52
  function isCallHierarchyEnabled(info) {
44
53
  return !!info.navigation;
45
54
  }
55
+ function isTypeHierarchyEnabled(info) {
56
+ return !!info.navigation;
57
+ }
46
58
  function isRenameEnabled(info) {
47
59
  return typeof info.navigation === 'object'
48
60
  ? info.navigation.shouldRename?.() ?? true
@@ -100,9 +112,9 @@ function isSignatureHelpEnabled(info) {
100
112
  return !!info.completion;
101
113
  }
102
114
  // should...
103
- function shouldReportDiagnostics(info) {
115
+ function shouldReportDiagnostics(info, source, code) {
104
116
  return typeof info.verification === 'object'
105
- ? info.verification.shouldReport?.() ?? true
117
+ ? info.verification.shouldReport?.(source, code) ?? true
106
118
  : !!info.verification;
107
119
  }
108
120
  // resolve...
package/lib/types.d.ts CHANGED
@@ -12,7 +12,7 @@ export interface Language<T = unknown> {
12
12
  mapperFactory: MapperFactory;
13
13
  plugins: LanguagePlugin<T>[];
14
14
  scripts: {
15
- get(id: T): SourceScript<T> | undefined;
15
+ get(id: T, includeFsFiles?: boolean): SourceScript<T> | undefined;
16
16
  set(id: T, snapshot: IScriptSnapshot, languageId?: string, plugins?: LanguagePlugin<T>[]): SourceScript<T> | undefined;
17
17
  delete(id: T): void;
18
18
  fromVirtualCode(virtualCode: VirtualCode): SourceScript<T>;
@@ -52,7 +52,7 @@ export interface VirtualCode {
52
52
  export interface CodeInformation {
53
53
  /** virtual code is expected to support verification */
54
54
  verification?: boolean | {
55
- shouldReport?(): boolean;
55
+ shouldReport?(source: string | undefined, code: string | number | undefined): boolean;
56
56
  };
57
57
  /** virtual code is expected to support assisted completion */
58
58
  completion?: boolean | {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volar/language-core",
3
- "version": "2.4.0-alpha.9",
3
+ "version": "2.4.1",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -12,7 +12,7 @@
12
12
  "directory": "packages/language-core"
13
13
  },
14
14
  "dependencies": {
15
- "@volar/source-map": "2.4.0-alpha.9"
15
+ "@volar/source-map": "2.4.1"
16
16
  },
17
- "gitHead": "4a3fc1bf36eb12ccd58bc8cb25f11f1a9f7b2300"
17
+ "gitHead": "b920b6c4a3e4b2d8f46c676ea414e94c437cb5b7"
18
18
  }