@volar/language-core
Advanced tools
Comparing version 2.4.11 to 2.4.12
@@ -8,3 +8,3 @@ export { Mapping, SourceMap } from '@volar/source-map'; | ||
export declare const defaultMapperFactory: MapperFactory; | ||
export declare function createLanguage<T>(plugins: LanguagePlugin<T>[], scriptRegistry: Map<T, SourceScript<T>>, sync: (id: T, includeFsFiles: boolean, shouldRegister: boolean) => void): Language<T>; | ||
export declare function createLanguage<T>(plugins: LanguagePlugin<T>[], scriptRegistry: Map<T, SourceScript<T>>, sync: (id: T, includeFsFiles: boolean, shouldRegister: boolean) => void, onAssociationDirty?: (targetId: T) => void): Language<T>; | ||
export declare function forEachEmbeddedCode(virtualCode: VirtualCode): Generator<VirtualCode>; |
16
index.js
@@ -30,3 +30,3 @@ "use strict"; | ||
exports.defaultMapperFactory = defaultMapperFactory; | ||
function createLanguage(plugins, scriptRegistry, sync) { | ||
function createLanguage(plugins, scriptRegistry, sync, onAssociationDirty) { | ||
const virtualCodeToSourceScriptMap = new WeakMap(); | ||
@@ -75,10 +75,16 @@ const virtualCodeToSourceMap = new WeakMap(); | ||
this.delete(id); | ||
triggerTargetsDirty(sourceScript); | ||
return this.set(id, snapshot, languageId); | ||
} | ||
else if (associatedOnly) { | ||
sourceScript.snapshot = snapshot; | ||
if (sourceScript.snapshot !== snapshot) { | ||
sourceScript.snapshot = snapshot; | ||
triggerTargetsDirty(sourceScript); | ||
} | ||
} | ||
else if (sourceScript.isAssociationDirty || sourceScript.snapshot !== snapshot) { | ||
// snapshot updated | ||
sourceScript.snapshot = snapshot; | ||
if (sourceScript.snapshot !== snapshot) { | ||
sourceScript.snapshot = snapshot; | ||
triggerTargetsDirty(sourceScript); | ||
} | ||
const codegenCtx = prepareCreateVirtualCode(sourceScript); | ||
@@ -104,3 +110,2 @@ if (sourceScript.generated) { | ||
} | ||
triggerTargetsDirty(sourceScript); | ||
} | ||
@@ -206,2 +211,3 @@ else { | ||
sourceScript.isAssociationDirty = true; | ||
onAssociationDirty?.(sourceScript.id); | ||
} | ||
@@ -208,0 +214,0 @@ }); |
@@ -52,5 +52,23 @@ import type { Mapping } from '@volar/source-map'; | ||
} | ||
/** | ||
* CodeInformation is a configuration object attached to each CodeMapping (between source code and generated code, | ||
* e.g. between the template code in a .vue file and the type-checkable TS code generated from it) that | ||
* determines what code/language features are expected to be available for the mapping. | ||
* | ||
* Due to the dynamic nature of code generation and the fact that, for example, things like Code Actions | ||
* and auto-complete shouldn't be triggerable on certain "in-between" regions of generated code, we need | ||
* a way to shut off certain features in certain regions, while leaving them enabled in others. | ||
*/ | ||
export interface CodeInformation { | ||
/** virtual code is expected to support verification */ | ||
/** virtual code is expected to support verification, where verification includes: | ||
* | ||
* - diagnostics (syntactic, semantic, and others, such as those generated by the TypeScript language service on generated TS code) | ||
* - code actions (refactorings, quick fixes,etc.) | ||
*/ | ||
verification?: boolean | { | ||
/** | ||
* when present, `shouldReport` callback is invoked to determine whether a diagnostic | ||
* raised in the generated code should be propagated back to the original source code. | ||
* Note that when this callback is present, diagnostic processing (e.g. typechecking) will | ||
* still be performed, but the results will not be reported back to the original source code. */ | ||
shouldReport?(source: string | undefined, code: string | number | undefined): boolean; | ||
@@ -63,3 +81,12 @@ }; | ||
}; | ||
/** virtual code is expected correctly reflect semantic of the source code */ | ||
/** virtual code is expected correctly reflect semantic of the source code. Specifically this controls the following langauge features: | ||
* | ||
* - hover | ||
* - inlay hints | ||
* - code lens | ||
* - semantic tokens | ||
* - others | ||
* | ||
* Note that semantic diagnostics (e.g. TS type-checking) are covered by the `verification` property above. | ||
*/ | ||
semantic?: boolean | { | ||
@@ -66,0 +93,0 @@ shouldHighlight?(): boolean; |
{ | ||
"name": "@volar/language-core", | ||
"version": "2.4.11", | ||
"version": "2.4.12", | ||
"license": "MIT", | ||
@@ -15,5 +15,5 @@ "files": [ | ||
"dependencies": { | ||
"@volar/source-map": "2.4.11" | ||
"@volar/source-map": "2.4.12" | ||
}, | ||
"gitHead": "42ccae005cc8516e07ad38f4d7730cab9b723340" | ||
"gitHead": "17b9b8a1f522afd1aad1e598d2fd935680d8a8d7" | ||
} |
29507
630
238
1
1
1
+ Added@volar/source-map@2.4.12(transitive)
- Removed@volar/source-map@2.4.11(transitive)
Updated@volar/source-map@2.4.12