Skip to content

refactor(server): Remove references to Ivy and improve help message docs #1911

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 1 commit into from
Aug 11, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
.npmrc=974837034
pnpm-lock.yaml=-997189543
yarn.lock=812186388
package.json=482498770
package.json=2022241265
pnpm-workspace.yaml=1711114604
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@
"angular.suggest.includeAutomaticOptionalChainCompletions": {
"type": "boolean",
"default": true,
"markdownDescription": "Enable/disable showing completions on potentially undefined values that insert an optional chain call. Requires TS 3.7+, strict null checks to be enabled and the `legacy View Engine` option to be disabled."
"markdownDescription": "Enable/disable showing completions on potentially undefined values that insert an optional chain call. Requires TS 3.7+ and strict null checks to be enabled."
},
"angular.suggest.includeCompletionsWithSnippetText": {
"type": "boolean",
"default": true,
"markdownDescription": "Enable/disable snippet completions from Angular language server. Requires using TypeScript 4.3+ in the workspace and the `legacy View Engine` option to be disabled."
"markdownDescription": "Enable/disable snippet completions from Angular language server. Requires using TypeScript 4.3+ in the workspace."
},
"angular.forceStrictTemplates": {
"type": "boolean",
Expand Down
9 changes: 3 additions & 6 deletions server/src/cmdline_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ function hasArgument(argv: string[], argName: string): boolean {

interface CommandLineOptions {
help: boolean;
/**
* If true, use Ivy LS, otherwise use legacy View Engine LS.
*/
ivy: boolean;
logFile?: string;
logVerbosity?: string;
logToConsole: boolean;
Expand All @@ -45,7 +41,6 @@ interface CommandLineOptions {
export function parseCommandLine(argv: string[]): CommandLineOptions {
return {
help: hasArgument(argv, '--help'),
ivy: !hasArgument(argv, '--viewEngine'),
logFile: findArgument(argv, '--logFile'),
logVerbosity: findArgument(argv, '--logVerbosity'),
logToConsole: hasArgument(argv, '--logToConsole'),
Expand All @@ -65,12 +60,14 @@ export function generateHelpMessage(argv: string[]) {

Options:
--help: Prints help message.
--viewEngine: Use legacy View Engine language service. Defaults to false.
--logFile: Location to log messages. Logging to file is disabled if not provided.
--logVerbosity: terse|normal|verbose|requestTime. See ts.server.LogLevel.
--logToConsole: Enables logging to console via 'window/logMessage'. Defaults to false.
--ngProbeLocations: Path of @angular/language-service. Required.
--tsProbeLocations: Path of typescript. Required.
--includeAutomaticOptionalChainCompletions: Shows completions on potentially undefined values that insert an optional chain call. Requires TS 3.7+ and strict null checks to be enabled.
--includeCompletionsWithSnippetText: Enables snippet completions from Angular language server;
--forceStrictTemplates: Forces the language service to use strictTemplates and ignore the user settings in the 'tsconfig.json'.

Additional options supported by vscode-languageserver:
--clientProcessId=<number>: Automatically kills the server if the client process dies.
Expand Down
16 changes: 7 additions & 9 deletions server/src/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function ngCompletionKindToLspCompletionItemKind(kind: CompletionKind): lsp.Comp
*/
export function tsCompletionEntryToLspCompletionItem(
entry: ts.CompletionEntry, position: lsp.Position, scriptInfo: ts.server.ScriptInfo,
insertReplaceSupport: boolean, isIvy: boolean): lsp.CompletionItem {
insertReplaceSupport: boolean): lsp.CompletionItem {
const item = lsp.CompletionItem.create(entry.name);
// Even though `entry.kind` is typed as ts.ScriptElementKind, it's
// really Angular's CompletionKind. This is because ts.ScriptElementKind does
Expand All @@ -120,14 +120,12 @@ export function tsCompletionEntryToLspCompletionItem(
const insertText = entry.insertText || entry.name;
item.textEdit = createTextEdit(scriptInfo, entry, position, insertText, insertReplaceSupport);

if (isIvy) {
// If the user enables the config `includeAutomaticOptionalChainCompletions`, the `insertText`
// range will include the dot. the `insertText` should be assigned to the `filterText` to filter
// the completion items.
item.filterText = entry.insertText;
if (entry.isSnippet) {
item.insertTextFormat = lsp.InsertTextFormat.Snippet;
}
// If the user enables the config `includeAutomaticOptionalChainCompletions`, the `insertText`
// range will include the dot. the `insertText` should be assigned to the `filterText` to filter
// the completion items.
item.filterText = entry.insertText;
if (entry.isSnippet) {
item.insertTextFormat = lsp.InsertTextFormat.Snippet;
}

item.data = {
Expand Down
2 changes: 0 additions & 2 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

// Parse command line arguments
const options = parseCommandLine(process.argv);

if (options.help) {
console.error(generateHelpMessage(process.argv));
process.exit(0);
Expand Down Expand Up @@ -42,7 +41,6 @@ function main() {
// TypeScript allows only package names as plugin names.
ngPlugin: '@angular/language-service',
resolvedNgLsPath: ng.resolvedPath,
ivy: isG3 ? true : options.ivy,
logToConsole: options.logToConsole,
includeAutomaticOptionalChainCompletions: options.includeAutomaticOptionalChainCompletions,
includeCompletionsWithSnippetText: options.includeCompletionsWithSnippetText,
Expand Down
43 changes: 13 additions & 30 deletions server/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export interface SessionOptions {
logger: ts.server.Logger;
ngPlugin: string;
resolvedNgLsPath: string;
ivy: boolean;
logToConsole: boolean;
includeAutomaticOptionalChainCompletions: boolean;
includeCompletionsWithSnippetText: boolean;
Expand Down Expand Up @@ -57,7 +56,6 @@ export class Session {
private readonly connection: lsp.Connection;
private readonly projectService: ts.server.ProjectService;
private readonly logger: ts.server.Logger;
private readonly ivy: boolean;
private readonly logToConsole: boolean;
private readonly openFiles = new MruTracker();
private readonly includeAutomaticOptionalChainCompletions: boolean;
Expand All @@ -79,7 +77,6 @@ export class Session {
options.includeAutomaticOptionalChainCompletions;
this.includeCompletionsWithSnippetText = options.includeCompletionsWithSnippetText;
this.logger = options.logger;
this.ivy = options.ivy;
this.logToConsole = options.logToConsole;
// Create a connection for the server. The connection uses Node's IPC as a transport.
this.connection = lsp.createConnection({
Expand Down Expand Up @@ -158,9 +155,6 @@ export class Session {
if (options.forceStrictTemplates) {
pluginConfig.forceStrictTemplates = true;
}
if (options.host.isG3) {
options.ivy = true;
}
projSvc.configurePlugin({
pluginName: options.ngPlugin,
configuration: pluginConfig,
Expand Down Expand Up @@ -445,12 +439,7 @@ export class Session {
// project as dirty to force update the graph.
project.markAsDirty();
}
if (!this.ivy) {
// Immediately enable Legacy / View Engine language service
this.info(`Enabling View Engine language service for ${projectName}.`);
return;
}
this.info(`Enabling Ivy language service for ${projectName}.`);
this.info(`Enabling language service for ${projectName}.`);
this.handleCompilerOptionsDiagnostics(project);
// Send diagnostics since we skipped this step when opening the file.
// First, make sure the Angular project is complete.
Expand Down Expand Up @@ -684,31 +673,26 @@ export class Session {
return {
capabilities: {
foldingRangeProvider: true,
codeLensProvider: this.ivy ? {resolveProvider: true} : undefined,
codeLensProvider: {resolveProvider: true},
textDocumentSync: lsp.TextDocumentSyncKind.Incremental,
completionProvider: {
// Only the Ivy LS provides support for additional completion resolution.
resolveProvider: this.ivy,
triggerCharacters: ['<', '.', '*', '[', '(', '$', '|']
},
completionProvider:
{resolveProvider: true, triggerCharacters: ['<', '.', '*', '[', '(', '$', '|']},
definitionProvider: true,
typeDefinitionProvider: this.ivy,
referencesProvider: this.ivy,
renameProvider: this.ivy ? {
typeDefinitionProvider: true,
referencesProvider: true,
renameProvider: {
// Renames should be checked and tested before being executed.
prepareProvider: true,
} :
false,
},
hoverProvider: true,
signatureHelpProvider: this.ivy ? {
signatureHelpProvider: {
triggerCharacters: ['(', ','],
retriggerCharacters: [','],
} :
undefined,
},
workspace: {
workspaceFolders: {supported: true},
},
codeActionProvider: this.ivy ? {
codeActionProvider: {
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 @@ -718,8 +702,7 @@ export class Session {
// Find more info
// [here](https://github.com/angular/vscode-ng-language-service/issues/1828)
codeActionKinds: [lsp.CodeActionKind.QuickFix],
} :
undefined,
},
},
serverOptions,
};
Expand Down Expand Up @@ -1151,7 +1134,7 @@ export class Session {
false;
return completions.entries.map(
(e) => tsCompletionEntryToLspCompletionItem(
e, params.position, scriptInfo, clientSupportsInsertReplaceCompletion, this.ivy));
e, params.position, scriptInfo, clientSupportsInsertReplaceCompletion));
}

private onCompletionResolve(item: lsp.CompletionItem): lsp.CompletionItem {
Expand Down