@vue/language-service
Advanced tools
Comparing version
@@ -26,46 +26,17 @@ "use strict"; | ||
/** | ||
* If the editing position is within the virtual code and navigation is enabled, | ||
* skip the CSS renaming feature. | ||
* If the position is within the virtual code and navigation is enabled, | ||
* skip the CSS navigation feature. | ||
*/ | ||
provideReferences(document, position) { | ||
if (isWithinNavigationVirtualCode(document, position)) { | ||
return; | ||
} | ||
return worker(document, (stylesheet, cssLs) => { | ||
return cssLs.findReferences(document, position, stylesheet); | ||
}); | ||
}, | ||
provideRenameRange(document, position) { | ||
do { | ||
const uri = vscode_uri_1.URI.parse(document.uri); | ||
const decoded = context.decodeEmbeddedDocumentUri(uri); | ||
const sourceScript = decoded && context.language.scripts.get(decoded[0]); | ||
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]); | ||
if (!sourceScript?.generated || !virtualCode?.id.startsWith('style_')) { | ||
break; | ||
} | ||
const root = sourceScript.generated.root; | ||
if (!(root instanceof language_core_1.VueVirtualCode)) { | ||
break; | ||
} | ||
const block = root.sfc.styles.find(style => style.name === decoded[1]); | ||
if (!block) { | ||
break; | ||
} | ||
let script; | ||
for (const [key, value] of sourceScript.generated.embeddedCodes) { | ||
if (key.startsWith('script_')) { | ||
script = value; | ||
break; | ||
} | ||
} | ||
if (!script) { | ||
break; | ||
} | ||
const offset = document.offsetAt(position) + block.startTagEnd; | ||
for (const { sourceOffsets, lengths, data } of script.mappings) { | ||
if (!sourceOffsets.length | ||
|| !data.navigation | ||
|| typeof data.navigation === 'object' && !data.navigation.shouldRename) { | ||
continue; | ||
} | ||
const start = sourceOffsets[0]; | ||
const end = sourceOffsets.at(-1) + lengths.at(-1); | ||
if (offset >= start && offset <= end) { | ||
return; | ||
} | ||
} | ||
} while (0); | ||
if (isWithinNavigationVirtualCode(document, position)) { | ||
return; | ||
} | ||
return worker(document, (stylesheet, cssLs) => { | ||
@@ -76,2 +47,43 @@ return cssLs.prepareRename(document, position, stylesheet); | ||
}; | ||
function isWithinNavigationVirtualCode(document, position) { | ||
const uri = vscode_uri_1.URI.parse(document.uri); | ||
const decoded = context.decodeEmbeddedDocumentUri(uri); | ||
const sourceScript = decoded && context.language.scripts.get(decoded[0]); | ||
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]); | ||
if (!sourceScript?.generated || !virtualCode?.id.startsWith('style_')) { | ||
return false; | ||
} | ||
const root = sourceScript.generated.root; | ||
if (!(root instanceof language_core_1.VueVirtualCode)) { | ||
return false; | ||
} | ||
const block = root.sfc.styles.find(style => style.name === decoded[1]); | ||
if (!block) { | ||
return false; | ||
} | ||
let script; | ||
for (const [key, value] of sourceScript.generated.embeddedCodes) { | ||
if (key.startsWith('script_')) { | ||
script = value; | ||
break; | ||
} | ||
} | ||
if (!script) { | ||
return false; | ||
} | ||
const offset = document.offsetAt(position) + block.startTagEnd; | ||
for (const { sourceOffsets, lengths, data } of script.mappings) { | ||
if (!sourceOffsets.length | ||
|| !data.navigation | ||
|| typeof data.navigation === 'object' && !data.navigation.shouldRename) { | ||
continue; | ||
} | ||
const start = sourceOffsets[0]; | ||
const end = sourceOffsets.at(-1) + lengths.at(-1); | ||
if (offset >= start && offset <= end) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
function worker(document, callback) { | ||
@@ -78,0 +90,0 @@ const cssLs = getCssLs(document); |
@@ -26,3 +26,2 @@ "use strict"; | ||
} | ||
const vueCompilerOptions = context.project.vue.compilerOptions; | ||
const enabled = await context.env.getConfiguration?.('vue.inlayHints.missingProps') ?? false; | ||
@@ -105,3 +104,3 @@ if (!enabled) { | ||
else if (attrText === 'v-model') { | ||
attrText = vueCompilerOptions.target >= 3 ? 'modelValue' : 'value'; // TODO: support for experimentalModelPropName? | ||
attrText = 'modelValue'; // TODO: support for experimentalModelPropName? | ||
} | ||
@@ -108,0 +107,0 @@ else if (attrText.startsWith('v-on:')) { |
{ | ||
"name": "@vue/language-service", | ||
"version": "3.0.0-alpha.6", | ||
"version": "3.0.0-alpha.8", | ||
"license": "MIT", | ||
@@ -24,6 +24,6 @@ "files": [ | ||
"@vue/compiler-dom": "^3.5.0", | ||
"@vue/language-core": "3.0.0-alpha.6", | ||
"@vue/language-core": "3.0.0-alpha.8", | ||
"@vue/shared": "^3.5.0", | ||
"@vue/typescript-plugin": "3.0.0-alpha.6", | ||
"alien-signals": "^1.0.3", | ||
"@vue/typescript-plugin": "3.0.0-alpha.8", | ||
"alien-signals": "^2.0.5", | ||
"path-browserify": "^1.0.1", | ||
@@ -49,3 +49,3 @@ "volar-service-css": "0.0.64", | ||
}, | ||
"gitHead": "a7b5649ab4957cd2228f4bbc9205b2008bff58a2" | ||
"gitHead": "d38cb93558fe8015c7ffe9ceacfdd3296e3692f6" | ||
} |
877305
-1.09%74
-2.63%10197
-1.96%+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated