@volar/language-core
Advanced tools
Comparing version 2.3.0 to 2.3.1
@@ -1,2 +0,2 @@ | ||
export * from '@volar/source-map'; | ||
export { Mapping } from '@volar/source-map'; | ||
export * from './lib/editorFeatures'; | ||
@@ -6,4 +6,5 @@ export * from './lib/linkedCodeMap'; | ||
export * from './lib/utils'; | ||
import type { Language, LanguagePlugin, SourceScript, VirtualCode } from './lib/types'; | ||
import type { Language, LanguagePlugin, MapperFactory, SourceScript, VirtualCode } from './lib/types'; | ||
export declare const defaultMapperFactory: MapperFactory; | ||
export declare function createLanguage<T>(plugins: LanguagePlugin<T>[], scriptRegistry: Map<T, SourceScript<T>>, sync: (id: T) => void): Language<T>; | ||
export declare function forEachEmbeddedCode(virtualCode: VirtualCode): Generator<VirtualCode>; |
21
index.js
@@ -17,4 +17,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.forEachEmbeddedCode = exports.createLanguage = void 0; | ||
__exportStar(require("@volar/source-map"), exports); | ||
exports.defaultMapperFactory = void 0; | ||
exports.createLanguage = createLanguage; | ||
exports.forEachEmbeddedCode = forEachEmbeddedCode; | ||
__exportStar(require("./lib/editorFeatures"), exports); | ||
@@ -26,2 +27,4 @@ __exportStar(require("./lib/linkedCodeMap"), exports); | ||
const linkedCodeMap_1 = require("./lib/linkedCodeMap"); | ||
const defaultMapperFactory = mappings => new source_map_1.SourceMap(mappings); | ||
exports.defaultMapperFactory = defaultMapperFactory; | ||
function createLanguage(plugins, scriptRegistry, sync) { | ||
@@ -31,3 +34,4 @@ const virtualCodeToSourceScriptMap = new WeakMap(); | ||
const virtualCodeToLinkedCodeMap = new WeakMap(); | ||
return { | ||
const language = { | ||
mapperFactory: exports.defaultMapperFactory, | ||
plugins, | ||
@@ -155,3 +159,3 @@ scripts: { | ||
const mappings = virtualCode.associatedScriptMappings?.get(sourceScript.id) ?? virtualCode.mappings; | ||
mapCache.set(sourceScript.snapshot, new source_map_1.SourceMap(mappings)); | ||
mapCache.set(sourceScript.snapshot, language.mapperFactory(mappings)); | ||
} | ||
@@ -163,4 +167,3 @@ return mapCache.get(sourceScript.snapshot); | ||
yield [ | ||
sourceScript.id, | ||
sourceScript.snapshot, | ||
sourceScript, | ||
this.get(virtualCode, sourceScript), | ||
@@ -173,4 +176,3 @@ ]; | ||
yield [ | ||
relatedSourceScript.id, | ||
relatedSourceScript.snapshot, | ||
relatedSourceScript, | ||
this.get(virtualCode, relatedSourceScript), | ||
@@ -199,2 +201,3 @@ ]; | ||
}; | ||
return language; | ||
function triggerTargetsDirty(sourceScript) { | ||
@@ -227,3 +230,2 @@ sourceScript.targetIds.forEach(id => { | ||
} | ||
exports.createLanguage = createLanguage; | ||
function* forEachEmbeddedCode(virtualCode) { | ||
@@ -237,3 +239,2 @@ yield virtualCode; | ||
} | ||
exports.forEachEmbeddedCode = forEachEmbeddedCode; | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.resolveRenameEditText = exports.resolveRenameNewName = exports.shouldReportDiagnostics = exports.isSignatureHelpEnabled = exports.isAutoInsertEnabled = exports.isCompletionEnabled = exports.isFormattingEnabled = exports.isCodeActionsEnabled = exports.isDiagnosticsEnabled = exports.isDocumentLinkEnabled = exports.isColorEnabled = exports.isLinkedEditingEnabled = exports.isSelectionRangesEnabled = exports.isFoldingRangesEnabled = exports.isSymbolsEnabled = exports.isHighlightEnabled = exports.isImplementationEnabled = exports.isReferencesEnabled = exports.isTypeDefinitionEnabled = exports.isDefinitionEnabled = exports.isRenameEnabled = exports.isCallHierarchyEnabled = exports.isSemanticTokensEnabled = exports.isCodeLensEnabled = exports.isInlayHintsEnabled = exports.isHoverEnabled = void 0; | ||
exports.isHoverEnabled = isHoverEnabled; | ||
exports.isInlayHintsEnabled = isInlayHintsEnabled; | ||
exports.isCodeLensEnabled = isCodeLensEnabled; | ||
exports.isSemanticTokensEnabled = isSemanticTokensEnabled; | ||
exports.isCallHierarchyEnabled = isCallHierarchyEnabled; | ||
exports.isRenameEnabled = isRenameEnabled; | ||
exports.isDefinitionEnabled = isDefinitionEnabled; | ||
exports.isTypeDefinitionEnabled = isTypeDefinitionEnabled; | ||
exports.isReferencesEnabled = isReferencesEnabled; | ||
exports.isImplementationEnabled = isImplementationEnabled; | ||
exports.isHighlightEnabled = isHighlightEnabled; | ||
exports.isSymbolsEnabled = isSymbolsEnabled; | ||
exports.isFoldingRangesEnabled = isFoldingRangesEnabled; | ||
exports.isSelectionRangesEnabled = isSelectionRangesEnabled; | ||
exports.isLinkedEditingEnabled = isLinkedEditingEnabled; | ||
exports.isColorEnabled = isColorEnabled; | ||
exports.isDocumentLinkEnabled = isDocumentLinkEnabled; | ||
exports.isDiagnosticsEnabled = isDiagnosticsEnabled; | ||
exports.isCodeActionsEnabled = isCodeActionsEnabled; | ||
exports.isFormattingEnabled = isFormattingEnabled; | ||
exports.isCompletionEnabled = isCompletionEnabled; | ||
exports.isAutoInsertEnabled = isAutoInsertEnabled; | ||
exports.isSignatureHelpEnabled = isSignatureHelpEnabled; | ||
exports.shouldReportDiagnostics = shouldReportDiagnostics; | ||
exports.resolveRenameNewName = resolveRenameNewName; | ||
exports.resolveRenameEditText = resolveRenameEditText; | ||
function isHoverEnabled(info) { | ||
return !!info.semantic; | ||
} | ||
exports.isHoverEnabled = isHoverEnabled; | ||
function isInlayHintsEnabled(info) { | ||
return !!info.semantic; | ||
} | ||
exports.isInlayHintsEnabled = isInlayHintsEnabled; | ||
function isCodeLensEnabled(info) { | ||
return !!info.semantic; | ||
} | ||
exports.isCodeLensEnabled = isCodeLensEnabled; | ||
function isSemanticTokensEnabled(info) { | ||
@@ -21,7 +43,5 @@ return typeof info.semantic === 'object' | ||
} | ||
exports.isSemanticTokensEnabled = isSemanticTokensEnabled; | ||
function isCallHierarchyEnabled(info) { | ||
return !!info.navigation; | ||
} | ||
exports.isCallHierarchyEnabled = isCallHierarchyEnabled; | ||
function isRenameEnabled(info) { | ||
@@ -32,71 +52,53 @@ return typeof info.navigation === 'object' | ||
} | ||
exports.isRenameEnabled = isRenameEnabled; | ||
function isDefinitionEnabled(info) { | ||
return !!info.navigation; | ||
} | ||
exports.isDefinitionEnabled = isDefinitionEnabled; | ||
function isTypeDefinitionEnabled(info) { | ||
return !!info.navigation; | ||
} | ||
exports.isTypeDefinitionEnabled = isTypeDefinitionEnabled; | ||
function isReferencesEnabled(info) { | ||
return !!info.navigation; | ||
} | ||
exports.isReferencesEnabled = isReferencesEnabled; | ||
function isImplementationEnabled(info) { | ||
return !!info.navigation; | ||
} | ||
exports.isImplementationEnabled = isImplementationEnabled; | ||
function isHighlightEnabled(info) { | ||
return !!info.navigation; | ||
} | ||
exports.isHighlightEnabled = isHighlightEnabled; | ||
function isSymbolsEnabled(info) { | ||
return !!info.structure; | ||
} | ||
exports.isSymbolsEnabled = isSymbolsEnabled; | ||
function isFoldingRangesEnabled(info) { | ||
return !!info.structure; | ||
} | ||
exports.isFoldingRangesEnabled = isFoldingRangesEnabled; | ||
function isSelectionRangesEnabled(info) { | ||
return !!info.structure; | ||
} | ||
exports.isSelectionRangesEnabled = isSelectionRangesEnabled; | ||
function isLinkedEditingEnabled(info) { | ||
return !!info.structure; | ||
} | ||
exports.isLinkedEditingEnabled = isLinkedEditingEnabled; | ||
function isColorEnabled(info) { | ||
return !!info.structure; | ||
} | ||
exports.isColorEnabled = isColorEnabled; | ||
function isDocumentLinkEnabled(info) { | ||
return !!info.structure; | ||
} | ||
exports.isDocumentLinkEnabled = isDocumentLinkEnabled; | ||
function isDiagnosticsEnabled(info) { | ||
return !!info.verification; | ||
} | ||
exports.isDiagnosticsEnabled = isDiagnosticsEnabled; | ||
function isCodeActionsEnabled(info) { | ||
return !!info.verification; | ||
} | ||
exports.isCodeActionsEnabled = isCodeActionsEnabled; | ||
function isFormattingEnabled(info) { | ||
return !!info.format; | ||
} | ||
exports.isFormattingEnabled = isFormattingEnabled; | ||
function isCompletionEnabled(info) { | ||
return !!info.completion; | ||
} | ||
exports.isCompletionEnabled = isCompletionEnabled; | ||
function isAutoInsertEnabled(info) { | ||
return !!info.completion; | ||
} | ||
exports.isAutoInsertEnabled = isAutoInsertEnabled; | ||
function isSignatureHelpEnabled(info) { | ||
return !!info.completion; | ||
} | ||
exports.isSignatureHelpEnabled = isSignatureHelpEnabled; | ||
// should... | ||
@@ -108,3 +110,2 @@ function shouldReportDiagnostics(info) { | ||
} | ||
exports.shouldReportDiagnostics = shouldReportDiagnostics; | ||
// resolve... | ||
@@ -116,3 +117,2 @@ function resolveRenameNewName(newName, info) { | ||
} | ||
exports.resolveRenameNewName = resolveRenameNewName; | ||
function resolveRenameEditText(text, info) { | ||
@@ -123,3 +123,2 @@ return typeof info.navigation === 'object' | ||
} | ||
exports.resolveRenameEditText = resolveRenameEditText; | ||
//# sourceMappingURL=editorFeatures.js.map |
@@ -7,6 +7,6 @@ "use strict"; | ||
*getLinkedOffsets(start) { | ||
for (const mapped of this.getGeneratedOffsets(start)) { | ||
for (const mapped of this.toGeneratedLocation(start)) { | ||
yield mapped[0]; | ||
} | ||
for (const mapped of this.getSourceOffsets(start)) { | ||
for (const mapped of this.toSourceLocation(start)) { | ||
yield mapped[0]; | ||
@@ -13,0 +13,0 @@ } |
@@ -1,5 +0,14 @@ | ||
import type { Mapping, SourceMap } from '@volar/source-map'; | ||
import type { Mapping } from '@volar/source-map'; | ||
import type * as ts from 'typescript'; | ||
import type { LinkedCodeMap } from './linkedCodeMap'; | ||
export interface Mapper { | ||
mappings: Mapping<CodeInformation>[]; | ||
toSourceRange(start: number, end: number, fallbackToAnyMatch: boolean, filter?: (data: CodeInformation) => boolean): Generator<readonly [number, number, Mapping<CodeInformation>, Mapping<CodeInformation>]>; | ||
toGeneratedRange(start: number, end: number, fallbackToAnyMatch: boolean, filter?: (data: CodeInformation) => boolean): Generator<readonly [number, number, Mapping<CodeInformation>, Mapping<CodeInformation>]>; | ||
toSourceLocation(generatedOffset: number, filter?: (data: CodeInformation) => boolean): Generator<readonly [number, Mapping<CodeInformation>]>; | ||
toGeneratedLocation(sourceOffset: number, filter?: (data: CodeInformation) => boolean): Generator<readonly [number, Mapping<CodeInformation>]>; | ||
} | ||
export type MapperFactory = (mappings: Mapping<CodeInformation>[]) => Mapper; | ||
export interface Language<T = unknown> { | ||
mapperFactory: MapperFactory; | ||
plugins: LanguagePlugin<T>[]; | ||
@@ -13,4 +22,4 @@ scripts: { | ||
maps: { | ||
get(virtualCode: VirtualCode, sourceScript: SourceScript<T>): SourceMap<CodeInformation>; | ||
forEach(virtualCode: VirtualCode): Generator<[id: T, snapshot: ts.IScriptSnapshot, map: SourceMap<CodeInformation>]>; | ||
get(virtualCode: VirtualCode, sourceScript: SourceScript<T>): Mapper; | ||
forEach(virtualCode: VirtualCode): Generator<[sourceScript: SourceScript<T>, map: Mapper]>; | ||
}; | ||
@@ -17,0 +26,0 @@ linkedCodeMaps: { |
{ | ||
"name": "@volar/language-core", | ||
"version": "2.3.0", | ||
"version": "2.3.1", | ||
"license": "MIT", | ||
@@ -15,5 +15,5 @@ "files": [ | ||
"dependencies": { | ||
"@volar/source-map": "2.3.0" | ||
"@volar/source-map": "2.3.1" | ||
}, | ||
"gitHead": "4f6488605e22e0f76ea877460848a443fd3e8762" | ||
"gitHead": "51742317a2950abd97e1a1a266b2c137bede4ad3" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26891
595
+ Added@volar/source-map@2.3.1(transitive)
- Removed@volar/source-map@2.3.0(transitive)
- Removedmuggle-string@0.4.1(transitive)
Updated@volar/source-map@2.3.1