@volar/language-core
Advanced tools
Comparing version 2.3.0-alpha.7 to 2.3.0-alpha.8
22
index.js
@@ -37,2 +37,7 @@ "use strict"; | ||
sync(id); | ||
const result = scriptRegistry.get(id); | ||
// The sync function provider may not always call the set function due to caching, so it is necessary to explicitly check isAssociationDirty. | ||
if (result?.isAssociationDirty) { | ||
this.set(id, result.snapshot, result.languageId); | ||
} | ||
return scriptRegistry.get(id); | ||
@@ -53,9 +58,18 @@ }, | ||
} | ||
let associatedOnly = false; | ||
for (const plugin of plugins) { | ||
if (plugin.isAssociatedFileOnly?.(id, languageId)) { | ||
associatedOnly = true; | ||
break; | ||
} | ||
} | ||
if (scriptRegistry.has(id)) { | ||
const sourceScript = scriptRegistry.get(id); | ||
if (sourceScript.languageId !== languageId) { | ||
// languageId changed | ||
if (sourceScript.languageId !== languageId || sourceScript.associatedOnly !== associatedOnly) { | ||
this.delete(id); | ||
return this.set(id, snapshot, languageId); | ||
} | ||
else if (associatedOnly) { | ||
sourceScript.snapshot = snapshot; | ||
} | ||
else if (sourceScript.isAssociationDirty || sourceScript.snapshot !== snapshot) { | ||
@@ -99,4 +113,8 @@ // snapshot updated | ||
targetIds: new Set(), | ||
associatedOnly | ||
}; | ||
scriptRegistry.set(id, sourceScript); | ||
if (associatedOnly) { | ||
return sourceScript; | ||
} | ||
for (const languagePlugin of _plugins) { | ||
@@ -103,0 +121,0 @@ const virtualCode = languagePlugin.createVirtualCode?.(id, languageId, snapshot, prepareCreateVirtualCode(sourceScript)); |
@@ -37,2 +37,3 @@ import type { Mapping, SourceMap } from '@volar/source-map'; | ||
associatedIds: Set<T>; | ||
associatedOnly: boolean; | ||
isAssociationDirty?: boolean; | ||
@@ -107,2 +108,9 @@ generated?: { | ||
disposeVirtualCode?(scriptId: T, virtualCode: K): void; | ||
/** | ||
* Some file types should not be parsed or processed as TypeScript files, | ||
* as they are used only as sources for generated files. | ||
* | ||
* This functionality is required only in TS plugin mode. | ||
*/ | ||
isAssociatedFileOnly?(scriptId: T, languageId: string): boolean; | ||
typescript?: TypeScriptGenericOptions<K> & TypeScriptNonTSPluginOptions<K>; | ||
@@ -109,0 +117,0 @@ } |
{ | ||
"name": "@volar/language-core", | ||
"version": "2.3.0-alpha.7", | ||
"version": "2.3.0-alpha.8", | ||
"license": "MIT", | ||
@@ -15,5 +15,5 @@ "files": [ | ||
"dependencies": { | ||
"@volar/source-map": "2.3.0-alpha.7" | ||
"@volar/source-map": "2.3.0-alpha.8" | ||
}, | ||
"gitHead": "3cc2a62516113c5789e4f54766e25063099a13a5" | ||
"gitHead": "377a0083ac697a476509805a6777a2339391dcaf" | ||
} |
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
26765
584
+ Added@volar/source-map@2.3.0-alpha.8(transitive)
- Removed@volar/source-map@2.3.0-alpha.7(transitive)