Skip to content

Add replacement span for string literal#37490

Merged
DanielRosenwasser merged 6 commits intomicrosoft:masterfrom
Kingwl:string_literal_replacement
Apr 2, 2020
Merged

Add replacement span for string literal#37490
DanielRosenwasser merged 6 commits intomicrosoft:masterfrom
Kingwl:string_literal_replacement

Conversation

@Kingwl
Copy link
Copy Markdown
Contributor

@Kingwl Kingwl commented Mar 20, 2020

Fixes #29270

@Kingwl
Copy link
Copy Markdown
Contributor Author

Kingwl commented Mar 20, 2020

@typescript-bot pack this.

@typescript-bot
Copy link
Copy Markdown
Collaborator

typescript-bot commented Mar 20, 2020

Heya @Kingwl, I've started to run the tarball bundle task on this PR at 2fb19fb. You can monitor the build here.

@typescript-bot
Copy link
Copy Markdown
Collaborator

typescript-bot commented Mar 20, 2020

Hey @Kingwl, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/68827/artifacts?artifactName=tgz&fileId=F70BAC5E061C90607777E118131671AB6516CEA1765784A391DB763283CBB12802&fileName=/typescript-3.9.0-insiders.20200320.tgz"
    }
}

and then running npm install.


There is also a playground for this build.

Comment thread src/compiler/types.ts Outdated
readonly importModuleSpecifierEnding?: "auto" | "minimal" | "index" | "js";
readonly allowTextChangesInNewFiles?: boolean;
readonly providePrefixAndSuffixTextForRename?: boolean;
readonly stringLiteralReplacementMode?: boolean;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amcasey @uniqueiniquity @mjbvz do we really need this preference for compatibility given that the replacementSpan is existing property.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope - if there's a replacementSpan, we'll handle it.

Copy link
Copy Markdown
Contributor Author

@Kingwl Kingwl Mar 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not my opinion, but I don't want to break anything

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to wait on @mjbvz to confirm if this is needed for vscode.. Otherwise this flag is not needed and shouldnt be added.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the flag is added for the user who wants to keep the classic behavior, IMO...
I‘m not 100% sure everyone like the replacement.🤔

Comment thread src/services/stringCompletions.ts Outdated
if (!contextToken || !isStringLiteralLike(contextToken)) return undefined;
const entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host);
return convertStringLiteralCompletions(entries, sourceFile, checker, log, preferences);
const completeInfo = convertStringLiteralCompletions(entries, sourceFile, checker, log, preferences);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather you do this inside the switch case of StringLiteralCompletionKind.Properties and StringLiteralCompletionKind.Types to ensure we aren't alternating any returned entries.

Comment thread src/compiler/types.ts Outdated
readonly importModuleSpecifierEnding?: "auto" | "minimal" | "index" | "js";
readonly allowTextChangesInNewFiles?: boolean;
readonly providePrefixAndSuffixTextForRename?: boolean;
readonly stringLiteralReplacementMode?: boolean;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also if this is really needed it shouldn't say node.. instead may be provideStringLiteralReplacementSpan

@Kingwl Kingwl force-pushed the string_literal_replacement branch 3 times, most recently from ae18871 to 36e65a5 Compare March 23, 2020 16:49
@Kingwl Kingwl force-pushed the string_literal_replacement branch from 36e65a5 to 1f9d8a7 Compare March 24, 2020 02:18
@sandersn sandersn added the For Backlog Bug PRs that fix a backlog bug label Apr 1, 2020
@sandersn
Copy link
Copy Markdown
Member

sandersn commented Apr 1, 2020

This sounds safe to put in the 3.9 RC. What do you think @DanielRosenwasser ?

@DanielRosenwasser
Copy link
Copy Markdown
Member

@typescript-bot pack this

@typescript-bot
Copy link
Copy Markdown
Collaborator

typescript-bot commented Apr 2, 2020

Heya @DanielRosenwasser, I've started to run the tarball bundle task on this PR at b1a6127. You can monitor the build here.

@typescript-bot
Copy link
Copy Markdown
Collaborator

Hey @DanielRosenwasser, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/70102/artifacts?artifactName=tgz&fileId=AA23AEE1D79256F09697DB6D3604C70CAA2577A9B515C66A2B7B0F1203A95FAB02&fileName=/typescript-3.9.0-insiders.20200402.tgz"
    }
}

and then running npm install.

@DanielRosenwasser
Copy link
Copy Markdown
Member

Looks like it's working!

@DanielRosenwasser DanielRosenwasser merged commit 5596ed8 into microsoft:master Apr 2, 2020
@Kingwl Kingwl deleted the string_literal_replacement branch April 2, 2020 11:38
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Add replacementSpan for string completions

6 participants