mirror of
https://github.com/angular/angular.git
synced 2026-11-23 07:05:14 -05:00
refactor(compiler-cli): clean up preprocessor language service and vscode extension
- Remove unused parameters (`_fileContent`, `_facade`) and unused methods (`ensureVirtualFile`, `getDocument`, `getHoverAtOffset`, `getVirtualFiles`, `incrementVersion`, `getCurrentVersion`, `updateFiles`, `expectReplacementText`, `expectContainInsertText`, `getApi`, `getLoadedProject`, `onDidClose`) across `language-service/` and `ngp-vscode-ng-language-service/`. - Fix missing `TestFileManager` and `FileUpdateType` imports, missing `await` on `env.createFile()`, and leftover Vitest 2-argument `expect(val, msg)` calls in `language-service/tests/`. - Remove obsolete `reference/typescript-go` path probes. - Clean up unused `exactExternalPlugin`, stale `ng-analyze-wasm` external entry, unused path aliases, unused `HandlerContext` fields, and broken `compile`/`watch` scripts in `ngp-vscode-ng-language-service/`. - Add missing Google license headers to `ngp-vscode-ng-language-service/` source and test files.
This commit is contained in:
committed by
Kristiyan Kostadinov
parent
8f71b21cf7
commit
61e0558516
@@ -1,23 +1,15 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
const esbuild = require('esbuild');
|
||||
const fs = require('fs/promises');
|
||||
const path = require('path');
|
||||
|
||||
const exactExternalPlugin = {
|
||||
name: 'exact-external',
|
||||
setup(build) {
|
||||
const externals = new Set([
|
||||
'@angular/compiler',
|
||||
'@angular/compiler-cli',
|
||||
'@angular/language-service/api',
|
||||
]);
|
||||
build.onResolve({filter: /^@angular\//}, (args) => {
|
||||
if (externals.has(args.path)) {
|
||||
return {path: args.path, external: true};
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
async function build() {
|
||||
// 1. Build Client
|
||||
console.log('Building client...');
|
||||
@@ -42,7 +34,6 @@ async function build() {
|
||||
outfile: path.join(__dirname, 'dist/server/server.js'),
|
||||
external: [
|
||||
path.join(__dirname, '../packages/compiler-cli/preprocessor/ng-analyze/index.js'),
|
||||
path.join(__dirname, '../packages/compiler-cli/preprocessor/ng-analyze-wasm/ng_analyze.js'),
|
||||
'typescript',
|
||||
],
|
||||
alias: {
|
||||
@@ -60,9 +51,6 @@ async function build() {
|
||||
repoRoot,
|
||||
'packages/language-service/private.ts',
|
||||
),
|
||||
'@angular/language-service/api': path.join(repoRoot, 'packages/language-service/api.ts'),
|
||||
'@angular/language-service': path.join(repoRoot, 'packages/language-service/api.ts'),
|
||||
'@angular/core': path.join(repoRoot, 'packages/core/index.ts'),
|
||||
},
|
||||
logOverride: {
|
||||
'empty-import-meta': 'silent',
|
||||
|
||||
@@ -3,10 +3,6 @@
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"main": "out/extension.js",
|
||||
"scripts": {
|
||||
"compile": "tsc -p .",
|
||||
"watch": "tsc -p . -w"
|
||||
},
|
||||
"dependencies": {
|
||||
"vscode-languageclient": "^10.1.0"
|
||||
},
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import {LanguageClient} from 'vscode-languageclient/node';
|
||||
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import {
|
||||
@@ -69,7 +77,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
|
||||
registerCommands(context, client, outputChannel);
|
||||
|
||||
const startAngularClientPromise = client.start().catch((err) => {
|
||||
client.start().catch((err) => {
|
||||
outputChannel.appendLine(`Failed to start Angular Language Service: ${err}`);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
const esbuild = require('esbuild');
|
||||
const path = require('path');
|
||||
const fs = require('fs/promises');
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
const path = require('path');
|
||||
const {runTests} = require('@vscode/test-electron');
|
||||
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as assert from 'assert';
|
||||
import * as path from 'path';
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as assert from 'assert';
|
||||
import * as path from 'path';
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as assert from 'assert';
|
||||
import * as path from 'path';
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as path from 'path';
|
||||
import * as assert from 'assert';
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as assert from 'assert';
|
||||
import * as path from 'path';
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs/promises';
|
||||
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
export interface WaitForOptions {
|
||||
timeout?: number;
|
||||
interval?: number;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import {Component, Directive, Input, signal} from '@angular/core';
|
||||
import {MyAttrDirective} from './my-attr.directive';
|
||||
import {MatListItemStub} from './mat-list-item.component';
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import {Component, signal} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import {Component} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import {Component, Input} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import {Directive} from '@angular/core';
|
||||
|
||||
@Directive({
|
||||
|
||||
@@ -3,10 +3,6 @@
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"main": "out/server.js",
|
||||
"scripts": {
|
||||
"compile": "tsc -p .",
|
||||
"watch": "tsc -p . -w"
|
||||
},
|
||||
"dependencies": {
|
||||
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
||||
"vscode-languageserver": "^10.1.0",
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import {Connection} from 'vscode-languageserver/node';
|
||||
import {URI} from 'vscode-uri';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import {CompletionParams, CompletionList, CompletionItem} from 'vscode-languageserver';
|
||||
import {HandlerContext, getDocumentContext} from './utils.js';
|
||||
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import {DefinitionParams, Definition, LocationLink} from 'vscode-languageserver';
|
||||
import {HandlerContext, getDocumentContext} from './utils.js';
|
||||
|
||||
export {HandlerContext};
|
||||
|
||||
export async function onDefinition(params: DefinitionParams, context: HandlerContext) {
|
||||
const docContext = getDocumentContext(context, params.textDocument.uri, params.position);
|
||||
if (!docContext) {
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import {HandlerContext, getDocumentContext} from './utils.js';
|
||||
import {offsetToPosition} from '../../../../packages/compiler-cli/preprocessor/src/tcb_ls_util.js';
|
||||
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import {HandlerContext} from './utils.js';
|
||||
|
||||
|
||||
@@ -6,16 +6,14 @@
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import {Position, TextDocuments, Connection} from 'vscode-languageserver';
|
||||
import {Position, TextDocuments} from 'vscode-languageserver';
|
||||
import {TextDocument} from 'vscode-languageserver-textdocument';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import {LanguageService} from '../../../../packages/compiler-cli/preprocessor/language-service/src/language_service.js';
|
||||
import {positionToOffset} from '../../../../packages/compiler-cli/preprocessor/src/tcb_ls_util.js';
|
||||
|
||||
export interface HandlerContext {
|
||||
workspaceRoot: string;
|
||||
languageService: LanguageService;
|
||||
connection: Connection;
|
||||
documents: TextDocuments<TextDocument>;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import * as fs from 'node:fs/promises';
|
||||
import {readConfiguration} from '@angular/compiler-cli';
|
||||
import {API, Snapshot} from '@typescript/native-preview/unstable/async';
|
||||
@@ -56,10 +64,6 @@ export class ProjectManager {
|
||||
this.currentSnapshot = undefined;
|
||||
}
|
||||
|
||||
getApi(): API | undefined {
|
||||
return this.api;
|
||||
}
|
||||
|
||||
getLoadedProjects(): readonly ProjectInstance[] {
|
||||
return Array.from(this.projects.values());
|
||||
}
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import {
|
||||
createConnection,
|
||||
ProposedFeatures,
|
||||
@@ -40,7 +48,6 @@ import {ProjectManager} from './project_manager';
|
||||
import {DiagnosticPublisher} from './diagnostic_publisher';
|
||||
import {canonicalizePath as normalizePath} from '../../../packages/compiler-cli/preprocessor/language-service/src/utils.js';
|
||||
|
||||
let workspaceRoot: string = '';
|
||||
let facade: TsGoFacade | null = null;
|
||||
let projectManager: ProjectManager | null = null;
|
||||
|
||||
@@ -133,11 +140,6 @@ connection.onDidChangeWatchedFiles((params: DidChangeWatchedFilesParams) => {
|
||||
|
||||
connection.onInitialize(async (params: InitializeParams) => {
|
||||
connection.console.log(`Initializing Angular Hybrid Language Server`);
|
||||
if (params.rootUri) {
|
||||
workspaceRoot = fileURLToPath(params.rootUri);
|
||||
} else if (params.rootPath) {
|
||||
workspaceRoot = params.rootPath;
|
||||
}
|
||||
|
||||
let api: API | undefined;
|
||||
if (params.initializationOptions?.tsApiPipe) {
|
||||
@@ -230,9 +232,7 @@ function withProject<P extends {textDocument: {uri: string}}, R>(
|
||||
if (!info) return null;
|
||||
await info.project.hybridCompiler.ensureReady();
|
||||
return handler(params, {
|
||||
workspaceRoot,
|
||||
languageService: info.project.languageService,
|
||||
connection,
|
||||
documents,
|
||||
});
|
||||
};
|
||||
@@ -252,9 +252,7 @@ connection.onCompletionResolve(async (item: CompletionItem) => {
|
||||
if (project) {
|
||||
await project.hybridCompiler.ensureReady();
|
||||
return onCompletionResolve(item, {
|
||||
workspaceRoot,
|
||||
languageService: project.languageService,
|
||||
connection,
|
||||
documents,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import * as rpc from 'vscode-jsonrpc/node';
|
||||
import {TestEnv, getTestWorkspacePath, startTestServer} from './test_helpers';
|
||||
import {TestFileManager} from '../../packages/compiler-cli/preprocessor/language-service/tests/test_file_manager';
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import * as rpc from 'vscode-jsonrpc/node';
|
||||
import {CompletionItemKind} from 'vscode-languageserver';
|
||||
import {TestEnv, getTestWorkspacePath, startTestServer} from './test_helpers';
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import * as rpc from 'vscode-jsonrpc/node';
|
||||
import {URI} from 'vscode-uri';
|
||||
import {TestEnv, getTestWorkspacePath, startTestServer} from './test_helpers';
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user