Skip to content

Commit

Permalink
fix(extension): disable rename override to allow built in TS renaming (
Browse files Browse the repository at this point in the history
…#1687)

This is a rollback of #1589 due to breaking rename scenarios in
projects.
#1683 (comment)

Fixes #1685

(cherry picked from commit 7233c7d)
  • Loading branch information
atscott committed Jun 7, 2022
1 parent d1bd734 commit 5ec03c8
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
11 changes: 10 additions & 1 deletion client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,16 @@ export class AngularLanguageClient implements vscode.Disposable {
prepareRename: async (
document: vscode.TextDocument, position: vscode.Position,
token: vscode.CancellationToken, next: lsp.PrepareRenameSignature) => {
if (await this.isInAngularProject(document)) {
// We are able to provide renames for many types of string literals: template strings,
// pipe names, and hopefully in the future selectors and input/output aliases. Because
// TypeScript isn't able to provide renames for these, we can more or less
// guarantee that the Angular Language service will be called for the rename as the
// fallback. We specifically do not provide renames outside of string literals
// because we cannot ensure our extension is prioritized for renames in TS files (see
// https://github.com/microsoft/vscode/issues/115354) we disable renaming completely so we
// can provide consistent expectations.
if (await this.isInAngularProject(document) &&
isInsideStringLiteral(document, position)) {
return next(document, position, token);
}
},
Expand Down
2 changes: 2 additions & 0 deletions override_rename_ts_plugin/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Note: This is currently disabled. See conversations in https://github.com/angular/vscode-ng-language-service/issues/1685 and https://github.com/angular/vscode-ng-language-service/issues/1683

This package is applied to the built-in TS extension by the config [`typescriptServerPlugins`][1] and is used to disable rename provider of the built-in TS extension so VSCode asks the Angular Language Service for the answer instead.

Detail about this package is [here][2].
Expand Down
7 changes: 0 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,6 @@
"path": "./syntaxes/expression.json",
"scopeName": "expression.ng"
}
],
"typescriptServerPlugins": [
{
"name": "@angular/override-rename-ts-plugin",
"enableForWorkspaceTypeScriptVersions": true
}
]
},
"activationEvents": [
Expand All @@ -209,7 +203,6 @@
"test:syntaxes": "yarn compile:syntaxes-test && yarn build:syntaxes && jasmine dist/syntaxes/test/driver.js"
},
"dependencies": {
"@angular/override-rename-ts-plugin": "file:override_rename_ts_plugin",
"@angular/language-service": "14.0.0",
"typescript": "4.5.4",
"vscode-jsonrpc": "6.0.0",
Expand Down
1 change: 0 additions & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ cp package.json angular.png CHANGELOG.md README.md dist/npm
# Copy files to server directory
cp -r server/package.json server/README.md server/bin dist/npm/server
cp -r v12_language_service dist/npm/v12_language_service
cp -r override_rename_ts_plugin dist/npm/override_rename_ts_plugin
# Build and copy files to syntaxes directory
yarn run build:syntaxes
mkdir dist/npm/syntaxes
Expand Down
3 changes: 0 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,6 @@
resolved "https://registry.yarnpkg.com/@angular/language-service/-/language-service-14.0.0.tgz#749b52642fe0ba04f8475667d2eac0b3cf60d400"
integrity sha512-05P+3IJ+pT9WQdUcXVM4NGY1a8V1bGKRVEE6BFFPYG+ElrM2aR7e0j997zAPIwPLWT1Z8/oC1wJ3MCBBTbECVQ==

"@angular/override-rename-ts-plugin@file:override_rename_ts_plugin":
version "0.0.1"

"@assemblyscript/loader@^0.10.1":
version "0.10.1"
resolved "https://registry.yarnpkg.com/@assemblyscript/loader/-/loader-0.10.1.tgz#70e45678f06c72fa2e350e8553ec4a4d72b92e06"
Expand Down

0 comments on commit 5ec03c8

Please sign in to comment.