Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Mar 20, 2024
1 parent c1b137a commit 36d7bf6
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 22 deletions.
Expand Up @@ -84,7 +84,7 @@ export function create(
return;
}

const props = await tsPluginClient?.getPropertiesAtLocation(fileName, sourceCodeOffset) ?? [];
const props = await tsPluginClient?.getPropertiesAtLocation(file.id, fileName, sourceCodeOffset) ?? [];
if (props.some(prop => prop === 'value')) {
return '${1:.value}';
}
Expand Down
2 changes: 1 addition & 1 deletion packages/language-service/lib/plugins/vue-extract-file.ts
Expand Up @@ -82,7 +82,7 @@ export function create(
return codeAction;
}

const toExtract = await tsPluginClient?.collectExtractProps(sourceFile.generated.code.fileName, templateCodeRange) ?? [];
const toExtract = await tsPluginClient?.collectExtractProps(sourceFile.id, sourceFile.generated.code.fileName, templateCodeRange) ?? [];
if (!toExtract) {
return codeAction;
}
Expand Down
7 changes: 3 additions & 4 deletions packages/language-service/lib/plugins/vue-template.ts
Expand Up @@ -463,9 +463,9 @@ export function create(

if (!tagInfo) {
promises.push((async () => {
const attrs = await tsPluginClient?.getElementAttrs(vueCode.fileName, tag) ?? [];
const props = await tsPluginClient?.getComponentProps(vueCode.fileName, tag) ?? [];
const events = await tsPluginClient?.getComponentEvents(vueCode.fileName, tag) ?? [];
const attrs = await tsPluginClient?.getElementAttrs(sourceDocumentUri, vueCode.fileName, tag) ?? [];
const props = await tsPluginClient?.getComponentProps(sourceDocumentUri, tag) ?? [];
const events = await tsPluginClient?.getComponentEvents(sourceDocumentUri, tag) ?? [];
tagInfos.set(tag, {
attrs,
props,
Expand Down Expand Up @@ -740,7 +740,6 @@ export function create(
updateExtraCustomData([]);
}


async function initialize() {
customData = await getHtmlCustomData();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript-plugin/lib/common.ts
Expand Up @@ -32,7 +32,7 @@ export function decorateLanguageServiceForVue(
for (const ext of vueOptions.extensions) {
const suffix = capitalize(ext.substring('.'.length)); // .vue -> Vue
if (item.source.endsWith(ext) && item.name.endsWith(suffix)) {
item.name = item.name.slice(0, -suffix.length);
item.name = capitalize(item.name.slice(0, -suffix.length));
if (item.insertText) {
// #2286
item.insertText = item.insertText.replace(`${suffix}$1`, '$1');
Expand Down
Expand Up @@ -8,12 +8,13 @@ export function collectExtractProps(
files: FileRegistry;
isTsPlugin: boolean,
},
fileId: string,
fileName: string,
templateCodeRange: [number, number],
) {
const { typescript: ts, languageService, files, isTsPlugin } = this;

const volarFile = files.get(fileName);
const volarFile = files.get(fileId);
if (!(volarFile?.generated?.code instanceof VueGeneratedCode)) {
return;
}
Expand Down
19 changes: 10 additions & 9 deletions packages/typescript-plugin/lib/requests/componentInfos.ts
Expand Up @@ -9,12 +9,12 @@ export function getComponentProps(
files: vue.FileRegistry;
vueOptions: vue.VueCompilerOptions,
},
fileName: string,
fileId: string,
tag: string,
requiredOnly = false,
) {
const { typescript: ts, files, vueOptions, languageService } = this;
const volarFile = files.get(fileName);
const volarFile = files.get(fileId);
if (!(volarFile?.generated?.code instanceof vue.VueGeneratedCode)) {
return;
}
Expand Down Expand Up @@ -97,11 +97,11 @@ export function getComponentEvents(
files: vue.FileRegistry;
vueOptions: vue.VueCompilerOptions,
},
fileName: string,
fileId: string,
tag: string,
) {
const { typescript: ts, files, vueOptions, languageService } = this;
const volarFile = files.get(fileName);
const volarFile = files.get(fileId);
if (!(volarFile?.generated?.code instanceof vue.VueGeneratedCode)) {
return;
}
Expand Down Expand Up @@ -177,10 +177,10 @@ export function getTemplateContextProps(
languageService: ts.LanguageService;
files: vue.FileRegistry;
},
fileName: string,
fileId: string,
) {
const { typescript: ts, files, languageService } = this;
const volarFile = files.get(fileName);
const volarFile = files.get(fileId);
if (!(volarFile?.generated?.code instanceof vue.VueGeneratedCode)) {
return;
}
Expand All @@ -199,10 +199,10 @@ export function getComponentNames(
files: vue.FileRegistry;
vueOptions: vue.VueCompilerOptions,
},
fileName: string,
fileId: string,
) {
const { typescript: ts, files, vueOptions, languageService } = this;
const volarFile = files.get(fileName);
const volarFile = files.get(fileId);
if (!(volarFile?.generated?.code instanceof vue.VueGeneratedCode)) {
return;
}
Expand Down Expand Up @@ -238,11 +238,12 @@ export function getElementAttrs(
languageService: ts.LanguageService;
files: vue.FileRegistry;
},
fileId: string,
fileName: string,
tagName: string,
) {
const { typescript: ts, files, languageService } = this;
const volarFile = files.get(fileName);
const volarFile = files.get(fileId);
if (!(volarFile?.generated?.code instanceof vue.VueGeneratedCode)) {
return;
}
Expand Down
Expand Up @@ -8,13 +8,14 @@ export function getPropertiesAtLocation(
files: FileRegistry;
isTsPlugin: boolean,
},
fileId: string,
fileName: string,
position: number,
) {
const { languageService, files, typescript: ts, isTsPlugin } = this;

// mapping
const file = files.get(fileName);
const file = files.get(fileId);
if (file?.generated) {
const virtualScript = file.generated.languagePlugin.typescript?.getScript(file.generated.code);
if (!virtualScript) {
Expand Down
@@ -1,4 +1,4 @@
<script setup lang="ts">
import componentFor
// ^complete: componentForAutoImportVue
// ^complete: ComponentForAutoImport
</script>
@@ -1,4 +1,4 @@
<script setup lang="ts">
import componentForAutoImport from './component-for-auto-import.vue';
// ^complete: componentForAutoImportVue
// ^complete: ComponentForAutoImport
</script>
Expand Up @@ -3,5 +3,5 @@

<template>
<ComponentForA />
<!-- ^complete: componentForAutoImportVue -->
<!-- ^complete: ComponentForAutoImport -->
</template>
Expand Up @@ -5,5 +5,5 @@ import ComponentForAutoImport from './component-for-auto-import.vue';

<template>
<ComponentForAutoImport />
<!-- ^complete: componentForAutoImportVue -->
<!-- ^complete: ComponentForAutoImport -->
</template>

0 comments on commit 36d7bf6

Please sign in to comment.