Skip to content

refactor(language-service): drop name casing convertion and its language status item #5411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
231 changes: 0 additions & 231 deletions extensions/vscode/src/features/nameCasing.ts

This file was deleted.

2 changes: 0 additions & 2 deletions extensions/vscode/src/languageClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
} from 'reactive-vscode';
import * as vscode from 'vscode';
import { config } from './config';
import { activate as activateNameCasing } from './features/nameCasing';
import { activate as activateSplitEditors } from './features/splitEditors';
import { checkCompatible } from './hybridMode';
import { useInsidersStatusItem } from './insiders';
Expand Down Expand Up @@ -89,7 +88,6 @@ async function activateLc(
await client.start();
});

activateNameCasing(client, selectors);
activateSplitEditors(client);

lsp.activateAutoInsertion(selectors, client);
Expand Down
32 changes: 0 additions & 32 deletions extensions/vscode/src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import * as lsp from '@volar/vscode';
import { AttrNameCasing, TagNameCasing } from '@vue/language-server/lib/types';
import * as vscode from 'vscode';
import { config } from './config';
import { attrNameCasings, tagNameCasings } from './features/nameCasing';

export const middleware: lsp.Middleware = {
...lsp.middleware,
Expand All @@ -16,34 +14,4 @@ export const middleware: lsp.Middleware = {
}
return await (lsp.middleware.resolveCodeAction?.(item, token, next) ?? next(item, token));
},
workspace: {
configuration(params, token, next) {
if (params.items.some(item => item.section === 'vue.complete.casing.props' || item.section === 'vue.complete.casing.tags')) {
return params.items.map(item => {
if (item.scopeUri) {
if (item.section === 'vue.complete.casing.tags') {
const tagNameCasing = tagNameCasings.get(item.scopeUri);
if (tagNameCasing === TagNameCasing.Kebab) {
return 'kebab';
}
else if (tagNameCasing === TagNameCasing.Pascal) {
return 'pascal';
}
}
else if (item.section === 'vue.complete.casing.props') {
const attrCase = attrNameCasings.get(item.scopeUri);
if (attrCase === AttrNameCasing.Kebab) {
return 'kebab';
}
if (attrCase === AttrNameCasing.Camel) {
return 'camel';
}
}
}
return vscode.workspace.getConfiguration(item.section, item.scopeUri ? vscode.Uri.parse(item.scopeUri) : undefined);
});
}
return next(params, token);
},
},
};
38 changes: 1 addition & 37 deletions packages/language-service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export * from './lib/nameCasing';
export * from './lib/types';

import type { LanguageServiceContext, LanguageServicePlugin } from '@volar/language-service';
import { AttrNameCasing, commands, TagNameCasing } from './lib/types';
import { commands } from './lib/types';

import { create as createEmmetPlugin } from 'volar-service-emmet';
import { create as createJsonPlugin } from 'volar-service-json';
Expand Down Expand Up @@ -44,7 +44,6 @@ import { getImportPathForFile } from '@vue/typescript-plugin/lib/requests/getImp
import { getPropertiesAtLocation } from '@vue/typescript-plugin/lib/requests/getPropertiesAtLocation';
import type { RequestContext } from '@vue/typescript-plugin/lib/requests/types';
import { URI } from 'vscode-uri';
import { convertAttrName, convertTagName, detect } from './lib/nameCasing';

declare module '@volar/language-service' {
export interface ProjectContext {
Expand Down Expand Up @@ -239,40 +238,5 @@ function getCommonLanguageServicePlugins(
};
},
},
{
name: 'vue-name-casing',
capabilities: {
executeCommandProvider: {
commands: [
commands.detectNameCasing,
commands.convertTagsToKebabCase,
commands.convertTagsToPascalCase,
commands.convertPropsToKebabCase,
commands.convertPropsToCamelCase,
],
}
},
create(context) {
return {
executeCommand(command, [uri]) {
if (command === commands.detectNameCasing) {
return detect(context, URI.parse(uri));
}
else if (command === commands.convertTagsToKebabCase) {
return convertTagName(context, URI.parse(uri), TagNameCasing.Kebab, getTsPluginClient(context));
}
else if (command === commands.convertTagsToPascalCase) {
return convertTagName(context, URI.parse(uri), TagNameCasing.Pascal, getTsPluginClient(context));
}
else if (command === commands.convertPropsToKebabCase) {
return convertAttrName(context, URI.parse(uri), AttrNameCasing.Kebab, getTsPluginClient(context));
}
else if (command === commands.convertPropsToCamelCase) {
return convertAttrName(context, URI.parse(uri), AttrNameCasing.Camel, getTsPluginClient(context));
}
},
};
},
}
];
}
Loading