Skip to content

Commit

Permalink
Revert "feat: Add option to disable code actions (#1849)" (#1856)
Browse files Browse the repository at this point in the history
This reverts commit 3453361.

This feature was only added as a potential mitigation for performance
issues in the v15 release. These performance issues have been
unreproducable by the team and disabling quick fixes using this feature
has not been confirmed to resolve the problem from developers
expeiencing the issue.
  • Loading branch information
atscott committed Feb 2, 2023
1 parent 86292ea commit 2e6e8c9
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 24 deletions.
4 changes: 0 additions & 4 deletions client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,6 @@ function constructArgs(
if (disableAutomaticNgcc) {
args.push('--disableAutomaticNgcc');
}
const disableCodeActions = config.get<boolean>('angular.disableCodeActions');
if (disableCodeActions) {
args.push('--disableCodeActions');
}

const forceStrictTemplates = config.get<boolean>('angular.forceStrictTemplates');
if (forceStrictTemplates) {
Expand Down
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,6 @@
"default": false,
"markdownDescription": "Disable the step to automatically run ngcc. [ngcc](https://github.com/angular/angular/blob/main/packages/compiler/design/architecture.md#high-level-proposal) is required to run and gather metadata from libraries not published with Ivy instructions. This can be run outside of VSCode instead (for example, as part of the build/rebuild in the CLI). Note that ngcc needs to run not only at startup, but also whenever the dependencies change. Failing to run ngcc when required can result in incomplete information and spurious errors reported by the language service."
},
"angular.disableCodeActions": {
"type": "boolean",
"default": false,
"markdownDescription": "Disable code actions in Angular contexts, including quick fixes in template files which add missing imports. Some code actions require global project analysis, so it may be desirable to disable them for performance reasons."
},
"angular.forceStrictTemplates": {
"type": "boolean",
"default": false,
Expand Down
2 changes: 0 additions & 2 deletions server/src/cmdline_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ interface CommandLineOptions {
* If true, skips the running ngcc when using Ivy LS.
*/
disableAutomaticNgcc: boolean;
disableCodeActions: boolean;
logFile?: string;
logVerbosity?: string;
logToConsole: boolean;
Expand All @@ -53,7 +52,6 @@ export function parseCommandLine(argv: string[]): CommandLineOptions {
help: hasArgument(argv, '--help'),
ivy: !hasArgument(argv, '--viewEngine'),
disableAutomaticNgcc: hasArgument(argv, '--disableAutomaticNgcc'),
disableCodeActions: hasArgument(argv, '--disableCodeActions'),
logFile: findArgument(argv, '--logFile'),
logVerbosity: findArgument(argv, '--logVerbosity'),
logToConsole: hasArgument(argv, '--logToConsole'),
Expand Down
1 change: 0 additions & 1 deletion server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ function main() {
resolvedNgLsPath: ng.resolvedPath,
ivy: isG3 ? true : options.ivy,
disableAutomaticNgcc: options.disableAutomaticNgcc || options.untrustedWorkspace,
disableCodeActions: options.disableCodeActions,
logToConsole: options.logToConsole,
includeAutomaticOptionalChainCompletions: options.includeAutomaticOptionalChainCompletions,
includeCompletionsWithSnippetText: options.includeCompletionsWithSnippetText,
Expand Down
20 changes: 8 additions & 12 deletions server/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export interface SessionOptions {
resolvedNgLsPath: string;
ivy: boolean;
disableAutomaticNgcc: boolean;
disableCodeActions: boolean;
logToConsole: boolean;
includeAutomaticOptionalChainCompletions: boolean;
includeCompletionsWithSnippetText: boolean;
Expand Down Expand Up @@ -116,7 +115,7 @@ export class Session {
}
});

this.addProtocolHandlers(this.connection, options);
this.addProtocolHandlers(this.connection);
this.projectService = this.createProjectService(options);
}

Expand Down Expand Up @@ -184,8 +183,8 @@ export class Session {
return projSvc;
}

private addProtocolHandlers(conn: lsp.Connection, options: SessionOptions) {
conn.onInitialize(p => this.onInitialize(p, options));
private addProtocolHandlers(conn: lsp.Connection) {
conn.onInitialize(p => this.onInitialize(p));
conn.onDidOpenTextDocument(p => this.onDidOpenTextDocument(p));
conn.onDidCloseTextDocument(p => this.onDidCloseTextDocument(p));
conn.onDidChangeTextDocument(p => this.onDidChangeTextDocument(p));
Expand All @@ -207,10 +206,8 @@ export class Session {
conn.onCodeLens(p => this.onCodeLens(p));
conn.onCodeLensResolve(p => this.onCodeLensResolve(p));
conn.onSignatureHelp(p => this.onSignatureHelp(p));
if (!options.disableCodeActions) {
conn.onCodeAction(p => this.onCodeAction(p));
conn.onCodeActionResolve(p => this.onCodeActionResolve(p));
}
conn.onCodeAction(p => this.onCodeAction(p));
conn.onCodeActionResolve(p => this.onCodeActionResolve(p));
}

private onCodeAction(params: lsp.CodeActionParams): lsp.CodeAction[]|null {
Expand Down Expand Up @@ -710,8 +707,7 @@ export class Session {
return project;
}

private onInitialize(params: lsp.InitializeParams, options: SessionOptions):
lsp.InitializeResult {
private onInitialize(params: lsp.InitializeParams): lsp.InitializeResult {
this.snippetSupport =
params.capabilities.textDocument?.completion?.completionItem?.snippetSupport;
const serverOptions: ServerOptions = {
Expand Down Expand Up @@ -745,7 +741,7 @@ export class Session {
workspace: {
workspaceFolders: {supported: true},
},
codeActionProvider: (this.ivy && !options.disableCodeActions) ? {
codeActionProvider: this.ivy ? {
resolveProvider: true,
// Now the Angular code action provider only supports `QuickFix`. If leave the
// `codeActionKinds` empty, all action requests will be sent to the Angular language
Expand All @@ -756,7 +752,7 @@ export class Session {
// [here](https://github.com/angular/vscode-ng-language-service/issues/1828)
codeActionKinds: [lsp.CodeActionKind.QuickFix],
} :
undefined,
undefined,
},
serverOptions,
};
Expand Down

0 comments on commit 2e6e8c9

Please sign in to comment.