Skip to content

TS Server Plugin rename supoort transform user input #61702

Closed as not planned
Closed as not planned
@mantou132

Description

@mantou132

πŸ” Search Terms

rename, ts server, plugin

βœ… Viability Checklist

⭐ Suggestion

Current ls interface:

interface LanguageService {
  ...
  findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, preferences: UserPreferences): readonly RenameLocation[] | undefined;
  ...
}

Add textStyle property to RenameLocation

interface RenameLocation extends DocumentSpan {
    readonly prefixText?: string;
    readonly suffixText?: string;
    readonly textStyle?: 'origin' | 'kebab' | 'camel'
}

As far as I know, this does not require changing the LSP

πŸ“ƒ Motivating Example

When renaming, some templates need to perform symbol conversion

Image

πŸ’» Use Cases

my case:

@customElements('e-my')
class MyElement extends GemElement {
  @emitter sayHi
}

html`<e-my @say-hi=${console.log}></e-my>`

When I rename an emitter name(camelCase), I want the event name(kebabCase) in the html template to transform

@customElements('e-my')
class MyElement extends GemElement {
  @emitter goodBye
}

html`<e-my @good-bye=${console.log}></e-my>`

example: https://github.com/mantou132/gem/blob/main/packages/ts-gem-plugin/src/decorate-ts.ts#L159

vscode issue: microsoft/vscode#248912

Metadata

Metadata

Assignees

No one assigned

    Labels

    DeclinedThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions