@volar/language-core 2.4.12 → 2.4.13

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
@@ -1,5 +1,5 @@
1
1
  export { Mapping, SourceMap } from '@volar/source-map';
2
- export * from './lib/editorFeatures';
2
+ export * from './lib/editor';
3
3
  export * from './lib/linkedCodeMap';
4
4
  export * from './lib/types';
5
5
  export * from './lib/utils';
package/index.js CHANGED
@@ -19,7 +19,7 @@ exports.createLanguage = createLanguage;
19
19
  exports.forEachEmbeddedCode = forEachEmbeddedCode;
20
20
  var source_map_1 = require("@volar/source-map");
21
21
  Object.defineProperty(exports, "SourceMap", { enumerable: true, get: function () { return source_map_1.SourceMap; } });
22
- __exportStar(require("./lib/editorFeatures"), exports);
22
+ __exportStar(require("./lib/editor"), exports);
23
23
  __exportStar(require("./lib/linkedCodeMap"), exports);
24
24
  __exportStar(require("./lib/types"), exports);
25
25
  __exportStar(require("./lib/utils"), exports);
@@ -0,0 +1,34 @@
1
+ import type { CodeInformation, Mapper } from './types';
2
+ export declare function isHoverEnabled(info: CodeInformation): boolean;
3
+ export declare function isInlayHintsEnabled(info: CodeInformation): boolean;
4
+ export declare function isCodeLensEnabled(info: CodeInformation): boolean;
5
+ export declare function isMonikerEnabled(info: CodeInformation): boolean;
6
+ export declare function isInlineValueEnabled(info: CodeInformation): boolean;
7
+ export declare function isSemanticTokensEnabled(info: CodeInformation): boolean;
8
+ export declare function isCallHierarchyEnabled(info: CodeInformation): boolean;
9
+ export declare function isTypeHierarchyEnabled(info: CodeInformation): boolean;
10
+ export declare function isRenameEnabled(info: CodeInformation): boolean;
11
+ export declare function isDefinitionEnabled(info: CodeInformation): boolean;
12
+ export declare function isTypeDefinitionEnabled(info: CodeInformation): boolean;
13
+ export declare function isReferencesEnabled(info: CodeInformation): boolean;
14
+ export declare function isImplementationEnabled(info: CodeInformation): boolean;
15
+ export declare function isHighlightEnabled(info: CodeInformation): boolean;
16
+ export declare function isSymbolsEnabled(info: CodeInformation): boolean;
17
+ export declare function isFoldingRangesEnabled(info: CodeInformation): boolean;
18
+ export declare function isSelectionRangesEnabled(info: CodeInformation): boolean;
19
+ export declare function isLinkedEditingEnabled(info: CodeInformation): boolean;
20
+ export declare function isColorEnabled(info: CodeInformation): boolean;
21
+ export declare function isDocumentLinkEnabled(info: CodeInformation): boolean;
22
+ export declare function isDiagnosticsEnabled(info: CodeInformation): boolean;
23
+ export declare function isCodeActionsEnabled(info: CodeInformation): boolean;
24
+ export declare function isFormattingEnabled(info: CodeInformation): boolean;
25
+ export declare function isCompletionEnabled(info: CodeInformation): boolean;
26
+ export declare function isAutoInsertEnabled(info: CodeInformation): boolean;
27
+ export declare function isSignatureHelpEnabled(info: CodeInformation): boolean;
28
+ export declare function shouldReportDiagnostics(info: CodeInformation, source: string | undefined, code: string | number | undefined): boolean;
29
+ export declare function resolveRenameNewName(newName: string, info: CodeInformation): string;
30
+ export declare function resolveRenameEditText(text: string, info: CodeInformation): string;
31
+ export declare function findOverlapCodeRange(start: number, end: number, map: Mapper, filter: (data: CodeInformation) => boolean): {
32
+ start: number;
33
+ end: number;
34
+ } | undefined;
package/lib/editor.js ADDED
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isHoverEnabled = isHoverEnabled;
4
+ exports.isInlayHintsEnabled = isInlayHintsEnabled;
5
+ exports.isCodeLensEnabled = isCodeLensEnabled;
6
+ exports.isMonikerEnabled = isMonikerEnabled;
7
+ exports.isInlineValueEnabled = isInlineValueEnabled;
8
+ exports.isSemanticTokensEnabled = isSemanticTokensEnabled;
9
+ exports.isCallHierarchyEnabled = isCallHierarchyEnabled;
10
+ exports.isTypeHierarchyEnabled = isTypeHierarchyEnabled;
11
+ exports.isRenameEnabled = isRenameEnabled;
12
+ exports.isDefinitionEnabled = isDefinitionEnabled;
13
+ exports.isTypeDefinitionEnabled = isTypeDefinitionEnabled;
14
+ exports.isReferencesEnabled = isReferencesEnabled;
15
+ exports.isImplementationEnabled = isImplementationEnabled;
16
+ exports.isHighlightEnabled = isHighlightEnabled;
17
+ exports.isSymbolsEnabled = isSymbolsEnabled;
18
+ exports.isFoldingRangesEnabled = isFoldingRangesEnabled;
19
+ exports.isSelectionRangesEnabled = isSelectionRangesEnabled;
20
+ exports.isLinkedEditingEnabled = isLinkedEditingEnabled;
21
+ exports.isColorEnabled = isColorEnabled;
22
+ exports.isDocumentLinkEnabled = isDocumentLinkEnabled;
23
+ exports.isDiagnosticsEnabled = isDiagnosticsEnabled;
24
+ exports.isCodeActionsEnabled = isCodeActionsEnabled;
25
+ exports.isFormattingEnabled = isFormattingEnabled;
26
+ exports.isCompletionEnabled = isCompletionEnabled;
27
+ exports.isAutoInsertEnabled = isAutoInsertEnabled;
28
+ exports.isSignatureHelpEnabled = isSignatureHelpEnabled;
29
+ exports.shouldReportDiagnostics = shouldReportDiagnostics;
30
+ exports.resolveRenameNewName = resolveRenameNewName;
31
+ exports.resolveRenameEditText = resolveRenameEditText;
32
+ exports.findOverlapCodeRange = findOverlapCodeRange;
33
+ function isHoverEnabled(info) {
34
+ return !!info.semantic;
35
+ }
36
+ function isInlayHintsEnabled(info) {
37
+ return !!info.semantic;
38
+ }
39
+ function isCodeLensEnabled(info) {
40
+ return !!info.semantic;
41
+ }
42
+ function isMonikerEnabled(info) {
43
+ return !!info.semantic;
44
+ }
45
+ function isInlineValueEnabled(info) {
46
+ return !!info.semantic;
47
+ }
48
+ function isSemanticTokensEnabled(info) {
49
+ return typeof info.semantic === 'object'
50
+ ? info.semantic.shouldHighlight?.() ?? true
51
+ : !!info.semantic;
52
+ }
53
+ function isCallHierarchyEnabled(info) {
54
+ return !!info.navigation;
55
+ }
56
+ function isTypeHierarchyEnabled(info) {
57
+ return !!info.navigation;
58
+ }
59
+ function isRenameEnabled(info) {
60
+ return typeof info.navigation === 'object'
61
+ ? info.navigation.shouldRename?.() ?? true
62
+ : !!info.navigation;
63
+ }
64
+ function isDefinitionEnabled(info) {
65
+ return !!info.navigation;
66
+ }
67
+ function isTypeDefinitionEnabled(info) {
68
+ return !!info.navigation;
69
+ }
70
+ function isReferencesEnabled(info) {
71
+ return !!info.navigation;
72
+ }
73
+ function isImplementationEnabled(info) {
74
+ return !!info.navigation;
75
+ }
76
+ function isHighlightEnabled(info) {
77
+ return !!info.navigation;
78
+ }
79
+ function isSymbolsEnabled(info) {
80
+ return !!info.structure;
81
+ }
82
+ function isFoldingRangesEnabled(info) {
83
+ return !!info.structure;
84
+ }
85
+ function isSelectionRangesEnabled(info) {
86
+ return !!info.structure;
87
+ }
88
+ function isLinkedEditingEnabled(info) {
89
+ return !!info.structure;
90
+ }
91
+ function isColorEnabled(info) {
92
+ return !!info.structure;
93
+ }
94
+ function isDocumentLinkEnabled(info) {
95
+ return !!info.structure;
96
+ }
97
+ function isDiagnosticsEnabled(info) {
98
+ return !!info.verification;
99
+ }
100
+ function isCodeActionsEnabled(info) {
101
+ return !!info.verification;
102
+ }
103
+ function isFormattingEnabled(info) {
104
+ return !!info.format;
105
+ }
106
+ function isCompletionEnabled(info) {
107
+ return !!info.completion;
108
+ }
109
+ function isAutoInsertEnabled(info) {
110
+ return !!info.completion;
111
+ }
112
+ function isSignatureHelpEnabled(info) {
113
+ return !!info.completion;
114
+ }
115
+ // should...
116
+ function shouldReportDiagnostics(info, source, code) {
117
+ return typeof info.verification === 'object'
118
+ ? info.verification.shouldReport?.(source, code) ?? true
119
+ : !!info.verification;
120
+ }
121
+ // resolve...
122
+ function resolveRenameNewName(newName, info) {
123
+ return typeof info.navigation === 'object'
124
+ ? info.navigation.resolveRenameNewName?.(newName) ?? newName
125
+ : newName;
126
+ }
127
+ function resolveRenameEditText(text, info) {
128
+ return typeof info.navigation === 'object'
129
+ ? info.navigation.resolveRenameEditText?.(text) ?? text
130
+ : text;
131
+ }
132
+ function findOverlapCodeRange(start, end, map, filter) {
133
+ let mappedStart;
134
+ let mappedEnd;
135
+ for (const [mapped, mapping] of map.toGeneratedLocation(start)) {
136
+ if (filter(mapping.data)) {
137
+ mappedStart = mapped;
138
+ break;
139
+ }
140
+ }
141
+ for (const [mapped, mapping] of map.toGeneratedLocation(end)) {
142
+ if (filter(mapping.data)) {
143
+ mappedEnd = mapped;
144
+ break;
145
+ }
146
+ }
147
+ if (mappedStart === undefined || mappedEnd === undefined) {
148
+ for (const mapping of map.mappings) {
149
+ if (filter(mapping.data)) {
150
+ const mappingStart = mapping.sourceOffsets[0];
151
+ const mappingEnd = mapping.sourceOffsets[mapping.sourceOffsets.length - 1] + mapping.lengths[mapping.lengths.length - 1];
152
+ const overlap = getOverlapRange(start, end, mappingStart, mappingEnd);
153
+ if (overlap) {
154
+ const curMappedStart = (overlap.start - mappingStart) + mapping.generatedOffsets[0];
155
+ const lastGeneratedLength = (mapping.generatedLengths ?? mapping.lengths)[mapping.generatedOffsets.length - 1];
156
+ const curMappedEndOffset = Math.min(overlap.end - mapping.sourceOffsets[mapping.sourceOffsets.length - 1], lastGeneratedLength);
157
+ const curMappedEnd = mapping.generatedOffsets[mapping.generatedOffsets.length - 1] + curMappedEndOffset;
158
+ mappedStart = mappedStart === undefined ? curMappedStart : Math.min(mappedStart, curMappedStart);
159
+ mappedEnd = mappedEnd === undefined ? curMappedEnd : Math.max(mappedEnd, curMappedEnd);
160
+ }
161
+ }
162
+ }
163
+ }
164
+ if (mappedStart !== undefined && mappedEnd !== undefined) {
165
+ return {
166
+ start: mappedStart,
167
+ end: mappedEnd,
168
+ };
169
+ }
170
+ }
171
+ function getOverlapRange(range1Start, range1End, range2Start, range2End) {
172
+ const start = Math.max(range1Start, range2Start);
173
+ const end = Math.min(range1End, range2End);
174
+ if (start > end) {
175
+ return undefined;
176
+ }
177
+ return {
178
+ start,
179
+ end,
180
+ };
181
+ }
182
+ //# sourceMappingURL=editor.js.map
@@ -26,5 +26,3 @@ export declare function isCompletionEnabled(info: CodeInformation): boolean;
26
26
  export declare function isAutoInsertEnabled(info: CodeInformation): boolean;
27
27
  export declare function isSignatureHelpEnabled(info: CodeInformation): boolean;
28
28
  export declare function shouldReportDiagnostics(info: CodeInformation, source: string | undefined, code: string | number | undefined): boolean;
29
- export declare function resolveRenameNewName(newName: string, info: CodeInformation): string;
30
- export declare function resolveRenameEditText(text: string, info: CodeInformation): string;
@@ -27,8 +27,6 @@ exports.isCompletionEnabled = isCompletionEnabled;
27
27
  exports.isAutoInsertEnabled = isAutoInsertEnabled;
28
28
  exports.isSignatureHelpEnabled = isSignatureHelpEnabled;
29
29
  exports.shouldReportDiagnostics = shouldReportDiagnostics;
30
- exports.resolveRenameNewName = resolveRenameNewName;
31
- exports.resolveRenameEditText = resolveRenameEditText;
32
30
  function isHoverEnabled(info) {
33
31
  return !!info.semantic;
34
32
  }
@@ -117,15 +115,4 @@ function shouldReportDiagnostics(info, source, code) {
117
115
  ? info.verification.shouldReport?.(source, code) ?? true
118
116
  : !!info.verification;
119
117
  }
120
- // resolve...
121
- function resolveRenameNewName(newName, info) {
122
- return typeof info.navigation === 'object'
123
- ? info.navigation.resolveRenameNewName?.(newName) ?? newName
124
- : newName;
125
- }
126
- function resolveRenameEditText(text, info) {
127
- return typeof info.navigation === 'object'
128
- ? info.navigation.resolveRenameEditText?.(text) ?? text
129
- : text;
130
- }
131
118
  //# sourceMappingURL=editorFeatures.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volar/language-core",
3
- "version": "2.4.12",
3
+ "version": "2.4.13",
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.12"
15
+ "@volar/source-map": "2.4.13"
16
16
  },
17
- "gitHead": "17b9b8a1f522afd1aad1e598d2fd935680d8a8d7"
17
+ "gitHead": "c5d727b9e73d0c6a45c64b38d74ca5c52363818f"
18
18
  }