diff --git a/.travis.yml b/.travis.yml index 3784589bfcc0c..63ed3c51e3c12 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,7 +52,6 @@ cache: - packages/task/node_modules - packages/terminal/node_modules - packages/typehierarchy/node_modules - - packages/typescript/node_modules - packages/userstorage/node_modules - packages/variable-resolver/node_modules - packages/workspace/node_modules diff --git a/CHANGELOG.md b/CHANGELOG.md index 514e62b9c9be9..56c80f38e65cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,8 @@ Breaking changes: - The extension will no longer be maintained by the project and remains in the Git history for anyone who would like to reference it or maintain it. - [tslint] removed the `@theia/tslint` extension [#6933](https://github.com/eclipse-theia/theia/pull/6933) - The extension will no longer be maintained by the project and remains in the Git history for anyone who would like to reference it or maintain it. +- [typescript] removed the `@theia/typescript` extension [#6933](https://github.com/eclipse-theia/theia/pull/6933) + - The extension will no longer be maintained by the project and remains in the Git history for anyone who would like to reference it or maintain it. - [task] renamed method `getStrigifiedTaskSchema()` has been renamed to `getStringifiedTaskSchema()` [#6780](https://github.com/eclipse-theia/theia/pull/6780) - [task] renamed method `reorgnizeTasks()` has been renamed to `reorganizeTasks()` [#6780](https://github.com/eclipse-theia/theia/pull/6780) - Support VS Code icon and color theming. [#6475](https://github.com/eclipse-theia/theia/pull/6475) diff --git a/packages/typescript/README.md b/packages/typescript/README.md deleted file mode 100644 index 53ff12e249458..0000000000000 --- a/packages/typescript/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Theia - Typescript Extension - -See [here](https://www.theia-ide.org/doc/index.html) for a detailed documentation. - -## License -- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/) -- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp) \ No newline at end of file diff --git a/packages/typescript/compile.tsconfig.json b/packages/typescript/compile.tsconfig.json deleted file mode 100644 index b8b72b49c8822..0000000000000 --- a/packages/typescript/compile.tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../configs/base.tsconfig", - "compilerOptions": { - "rootDir": "src", - "outDir": "lib" - }, - "include": [ - "src" - ] -} \ No newline at end of file diff --git a/packages/typescript/package.json b/packages/typescript/package.json deleted file mode 100644 index bc94a7bf706f1..0000000000000 --- a/packages/typescript/package.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "name": "@theia/typescript", - "version": "0.14.0", - "description": "Theia - Typescript Extension", - "dependencies": { - "@theia/application-package": "^0.14.0", - "@theia/callhierarchy": "^0.14.0", - "@theia/core": "^0.14.0", - "@theia/editor": "^0.14.0", - "@theia/filesystem": "^0.14.0", - "@theia/languages": "^0.14.0", - "@theia/monaco": "^0.14.0", - "@theia/workspace": "^0.14.0", - "command-exists": "^1.2.8", - "typescript-language-server": "^0.4.0" - }, - "publishConfig": { - "access": "public" - }, - "theiaExtensions": [ - { - "frontend": "lib/browser/typescript-frontend-module", - "backend": "lib/node/typescript-backend-module" - } - ], - "keywords": [ - "theia-extension" - ], - "license": "EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0", - "repository": { - "type": "git", - "url": "https://github.com/eclipse-theia/theia.git" - }, - "bugs": { - "url": "https://github.com/eclipse-theia/theia/issues" - }, - "homepage": "https://github.com/eclipse-theia/theia", - "files": [ - "lib", - "src", - "data" - ], - "scripts": { - "prepare": "yarn run clean && yarn run build", - "clean": "theiaext clean", - "build": "theiaext build", - "watch": "theiaext watch", - "test": "theiaext test" - }, - "devDependencies": { - "@theia/ext-scripts": "^0.14.0" - }, - "nyc": { - "extends": "../../configs/nyc.json" - } -} diff --git a/packages/typescript/src/browser/monaco.d.ts b/packages/typescript/src/browser/monaco.d.ts deleted file mode 100644 index ad8ef7c744a72..0000000000000 --- a/packages/typescript/src/browser/monaco.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// \ No newline at end of file diff --git a/packages/typescript/src/browser/typescript-callhierarchy-service.ts b/packages/typescript/src/browser/typescript-callhierarchy-service.ts deleted file mode 100644 index 8a082a4afb0d5..0000000000000 --- a/packages/typescript/src/browser/typescript-callhierarchy-service.ts +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2018 TypeFox and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the Eclipse - * Public License v. 2.0 are satisfied: GNU General Public License, version 2 - * with the GNU Classpath Exception which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - ********************************************************************************/ - -import { injectable } from 'inversify'; -import { AbstractDefaultCallHierarchyService, ExtendedDocumentSymbol } from '@theia/callhierarchy/lib/browser/callhierarchy-service-impl'; -import { CallHierarchyContext } from '@theia/callhierarchy/lib/browser/callhierarchy-context'; -import { TYPESCRIPT_LANGUAGE_ID } from '../common'; -import { SymbolInformation, Range, Location, DocumentSymbol } from 'vscode-languageserver-types'; -import * as utils from '@theia/callhierarchy/lib/browser/utils'; - -@injectable() -export class TypeScriptCallHierarchyService extends AbstractDefaultCallHierarchyService { - - readonly languageId: string = TYPESCRIPT_LANGUAGE_ID; - - /** - * Finds the symbol that encloses the definition range of a caller. - * - * In the case of typescript, a method's definition and all its override definitions - * are returned as a reference as well. As these are not calls they have to be filtered. - * We also just want ot see the top-most caller symbol. - */ - async getEnclosingCallerSymbol(reference: Location, context: CallHierarchyContext): Promise { - const allSymbols = await context.getAllSymbols(reference.uri); - if (allSymbols.length === 0) { - return undefined; - } - if (DocumentSymbol.is(allSymbols[0])) { - return this.getEnclosingRootSymbol(reference, context); - } - const symbols = (allSymbols as SymbolInformation[]).filter(s => this.isCallable(s)); - let bestMatch: SymbolInformation | undefined = undefined; - let bestRange: Range | undefined = undefined; - for (const candidate of symbols) { - const candidateRange = candidate.location.range; - if (utils.containsRange(candidateRange, reference.range)) { - // as opposed to default, find the topmost (earliest) symbol - if (!bestMatch || utils.startsAfter(bestRange!, candidateRange)) { - bestMatch = candidate; - bestRange = candidateRange; - } - } - } - if (bestMatch) { - // filter references that are in fact definitions - const nameLocation = await this.getSymbolNameLocation(bestMatch, context); - if (!nameLocation || utils.isSame(nameLocation, reference)) { - return undefined; - } - } - return bestMatch; - } -} diff --git a/packages/typescript/src/browser/typescript-client-contribution.ts b/packages/typescript/src/browser/typescript-client-contribution.ts deleted file mode 100644 index b7d6f82c39927..0000000000000 --- a/packages/typescript/src/browser/typescript-client-contribution.ts +++ /dev/null @@ -1,187 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2017 TypeFox and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the Eclipse - * Public License v. 2.0 are satisfied: GNU General Public License, version 2 - * with the GNU Classpath Exception which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - ********************************************************************************/ - -import { injectable, inject, postConstruct } from 'inversify'; -import URI from '@theia/core/lib/common/uri'; -import { Emitter, Event } from '@theia/core/lib/common/event'; -import { Deferred } from '@theia/core/lib/common/promise-util'; -import { PreferenceService, PreferenceScope } from '@theia/core/lib/browser/preferences'; -import { BaseLanguageClientContribution, Workspace, Languages, LanguageClientFactory, ILanguageClient, State } from '@theia/languages/lib/browser'; -import { WorkspaceService } from '@theia/workspace/lib/browser'; -import { WorkspaceVariableContribution } from '@theia/workspace/lib/browser/workspace-variable-contribution'; -import { TypeScriptInitializationOptions, TypeScriptInitializeResult } from 'typescript-language-server/lib/ts-protocol'; -import { - TYPESCRIPT_LANGUAGE_ID, TYPESCRIPT_LANGUAGE_NAME, TYPESCRIPT_REACT_LANGUAGE_ID, JAVASCRIPT_LANGUAGE_ID, JAVASCRIPT_REACT_LANGUAGE_ID, TypescriptStartParams -} from '../common'; -import { TypescriptPreferences } from './typescript-preferences'; -import { TypescriptVersion, TypescriptVersionService, TypescriptVersionOptions } from '../common/typescript-version-service'; - -@injectable() -export class TypeScriptClientContribution extends BaseLanguageClientContribution { - - readonly id = TYPESCRIPT_LANGUAGE_ID; - readonly name = TYPESCRIPT_LANGUAGE_NAME; - - @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; - - @inject(WorkspaceVariableContribution) - protected readonly workspaceVariables: WorkspaceVariableContribution; - - @inject(TypescriptPreferences) - protected readonly preferences: TypescriptPreferences; - - @inject(PreferenceService) - protected readonly preferenceService: PreferenceService; - - @inject(TypescriptVersionService) - protected readonly versionService: TypescriptVersionService; - - protected readonly onDidChangeVersionEmitter = new Emitter(); - readonly onDidChangeVersion: Event = this.onDidChangeVersionEmitter.event; - - constructor( - @inject(Workspace) protected readonly workspace: Workspace, - @inject(Languages) protected readonly languages: Languages, - @inject(LanguageClientFactory) protected readonly languageClientFactory: LanguageClientFactory - ) { - super(workspace, languages, languageClientFactory); - } - - @postConstruct() - protected init(): void { - this.preferences.onPreferenceChanged(e => { - if (e.preferenceName === 'typescript.server.log') { - this.restart(); - } - }); - this.onDidChangeVersion(() => this.restart()); - } - - protected _version: TypescriptVersion | undefined; - get version(): TypescriptVersion | undefined { - return this._version; - } - async setVersion(raw: TypescriptVersion | undefined): Promise { - const version = await this.validateVersion(raw); - if (TypescriptVersion.equals(this._version, version)) { - return; - } - this._version = version; - if (version && version.qualifier === 'Workspace') { - const tsdkPath = this.workspaceVariables.getWorkspaceRelativePath(new URI(version.uri)); - if (tsdkPath) { - this.preferenceService.set('typescript.tsdk', tsdkPath, PreferenceScope.Workspace); - } - } - this.onDidChangeVersionEmitter.fire(this._version); - } - - protected async getStartParameters(): Promise { - await this.restored.promise; - const { version } = this; - await this.setVersion(version); - return { version }; - } - - protected get documentSelector(): string[] { - return [ - TYPESCRIPT_LANGUAGE_ID, - TYPESCRIPT_REACT_LANGUAGE_ID, - JAVASCRIPT_LANGUAGE_ID, - JAVASCRIPT_REACT_LANGUAGE_ID - ]; - } - - protected get workspaceContains(): string[] { - // FIXME requires https://github.com/eclipse-theia/theia/issues/2359 - // return [ - // "**/tsconfig.json", - // "**/jsconfig.json", - // "**/tsconfig.*.json", - // "**/jsconfig.*.json" - // ]; - return [ - 'tsconfig.json', - 'jsconfig.json' - ]; - } - - protected get initializationOptions(): Partial { - const options: Partial = {}; - const logVerbosity = this.preferences['typescript.server.log']; - if (logVerbosity !== 'off') { - options.logVerbosity = logVerbosity; - } - return options; - } - - protected _logFileUri: URI | undefined; - get logFileUri(): URI | undefined { - return this._logFileUri; - } - protected onReady(languageClient: ILanguageClient): void { - if (languageClient.initializeResult) { - const initializeResult = languageClient.initializeResult as TypeScriptInitializeResult; - this._logFileUri = initializeResult.logFileUri !== undefined ? new URI(initializeResult.logFileUri) : undefined; - } - languageClient.onDidChangeState(({ newState }) => { - if (newState === State.Stopped) { - this._logFileUri = undefined; - } - }); - super.onReady(languageClient); - } - - protected async validateVersion(candidate: TypescriptVersion | undefined): Promise { - const versions = await this.getVersions(); - if (candidate && versions.some(version => TypescriptVersion.equals(candidate, version))) { - return candidate; - } - return versions.find(version => version.qualifier === 'Workspace') || versions[0]; - } - async getVersions(): Promise { - await Promise.all([this.preferences.ready, this.workspace.ready]); - return this.versionService.getVersions(this.versionOptions); - } - protected get versionOptions(): TypescriptVersionOptions { - return { - workspaceFolders: this.workspaceService.tryGetRoots().map(({ uri }) => uri), - localTsdk: this.preferences['typescript.tsdk'] - }; - } - - store(): TypescriptContributionData { - return { - version: this._version - }; - } - - protected readonly restored = new Deferred(); - async restore(data: TypescriptContributionData | undefined): Promise { - try { - if (!this._version) { - await this.setVersion(data && data.version); - } - } finally { - this.restored.resolve(); - } - } - -} -export interface TypescriptContributionData { - version?: TypescriptVersion -} diff --git a/packages/typescript/src/browser/typescript-frontend-contribution.ts b/packages/typescript/src/browser/typescript-frontend-contribution.ts deleted file mode 100644 index 7d02b1fa7ce3a..0000000000000 --- a/packages/typescript/src/browser/typescript-frontend-contribution.ts +++ /dev/null @@ -1,256 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2018 TypeFox and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the Eclipse - * Public License v. 2.0 are satisfied: GNU General Public License, version 2 - * with the GNU Classpath Exception which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - ********************************************************************************/ - -import { injectable, inject, postConstruct } from 'inversify'; -import * as tsp from 'typescript/lib/protocol'; -import { Commands } from 'typescript-language-server/lib/commands'; -import { - QuickPickService, KeybindingRegistry, KeybindingContribution, QuickPickItem, StorageService, LabelProvider, FrontendApplicationContribution, StatusBar, StatusBarAlignment -} from '@theia/core/lib/browser'; -import { ExecuteCommandRequest } from '@theia/languages/lib/browser'; -import { FileSystemWatcher, FileMoveEvent } from '@theia/filesystem/lib/browser'; -import { EditorManager, EditorWidget, EDITOR_CONTEXT_MENU, TextEditor } from '@theia/editor/lib/browser'; -import { CommandContribution, CommandRegistry, Command, MenuModelRegistry, MenuContribution, DisposableCollection } from '@theia/core/lib/common'; -import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor'; -import { TYPESCRIPT_LANGUAGE_ID, TS_JS_LANGUAGES } from '../common'; -import { TypeScriptClientContribution, TypescriptContributionData } from './typescript-client-contribution'; -import { TypeScriptKeybindingContexts } from './typescript-keybinding-contexts'; -import { TypescriptVersion } from '../common/typescript-version-service'; -import URI from '@theia/core/lib/common/uri'; - -export namespace TypeScriptCommands { - export const applyCompletionCodeAction: Command = { - id: Commands.APPLY_COMPLETION_CODE_ACTION - }; - // TODO: get rid of me when https://github.com/TypeFox/monaco-languageclient/issues/104 is resolved - export const organizeImports: Command = { - category: 'TypeScript', - label: 'Organize Imports', - id: 'typescript.edit.organizeImports' - }; - export const openServerLog: Command = { - category: 'TypeScript', - label: 'Open Server Log', - id: 'typescript.server.openLog' - }; - export const selectVersion: Command = { - category: 'TypeScript', - label: 'Select Version', - id: 'typescript.selectVersion' - }; -} - -@injectable() -export class TypeScriptFrontendContribution implements FrontendApplicationContribution, CommandContribution, MenuContribution, KeybindingContribution { - - @inject(StatusBar) - protected readonly statusBar: StatusBar; - - @inject(EditorManager) - protected readonly editorManager: EditorManager; - - @inject(QuickPickService) - protected readonly quickPickService: QuickPickService; - - @inject(TypeScriptClientContribution) - protected readonly clientContribution: TypeScriptClientContribution; - - @inject(FileSystemWatcher) - protected readonly fileSystemWatcher: FileSystemWatcher; - - @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; - - @inject(StorageService) - protected readonly storage: StorageService; - - @postConstruct() - protected init(): void { - this.fileSystemWatcher.onDidMove(event => this.renameFile(event)); - } - - onStart(): void { - this.restore(); - this.updateStatusBar(); - this.editorManager.onCurrentEditorChanged(() => this.updateStatusBar()); - this.clientContribution.onDidChangeVersion(() => this.updateStatusBar()); - } - - onStop(): void { - this.store(); - } - - registerCommands(commands: CommandRegistry): void { - commands.registerCommand(TypeScriptCommands.applyCompletionCodeAction, { - execute: async (file: string, codeActions: tsp.CodeAction[]) => { - const codeAction = await this.pickCodeAction(codeActions); - return codeAction && this.applyCodeAction(codeAction); - } - }); - commands.registerCommand(TypeScriptCommands.organizeImports, { - execute: () => this.organizeImports(), - isEnabled: () => !!this.currentEditor, - isVisible: () => !!this.currentEditor - }); - commands.registerCommand(TypeScriptCommands.openServerLog, { - execute: () => this.openServerLog(), - isEnabled: () => !!this.clientContribution.logFileUri, - isVisible: () => !!this.clientContribution.logFileUri - }); - commands.registerCommand(TypeScriptCommands.selectVersion, { - execute: () => this.selectVersion() - }); - } - - registerMenus(menus: MenuModelRegistry): void { - menus.registerMenuAction([...EDITOR_CONTEXT_MENU, '1_modification'], { - commandId: TypeScriptCommands.organizeImports.id, - label: 'Organize Imports' - }); - } - - registerKeybindings(keybindings: KeybindingRegistry): void { - keybindings.registerKeybinding({ - command: TypeScriptCommands.organizeImports.id, - context: TypeScriptKeybindingContexts.typescriptEditorTextFocus, - keybinding: 'shift+alt+o' - }); - } - - openServerLog(): void { - const logFileUri = this.clientContribution.logFileUri; - if (logFileUri) { - this.editorManager.open(logFileUri); - } - } - - organizeImports(): void { - const editor = MonacoEditor.get(this.currentEditor); - if (editor) { - // tslint:disable-next-line:no-any - const action = editor.getControl().getAction('editor.action.organizeImports') as any; - // workaround isSupported check - action._run(); - } - } - - get currentEditor(): EditorWidget | undefined { - const { currentEditor } = this.editorManager; - if (currentEditor && currentEditor.editor.document.languageId === TYPESCRIPT_LANGUAGE_ID) { - return currentEditor; - } - return undefined; - } - - protected pickCodeAction(codeActions: tsp.CodeAction[]): Promise { - return this.quickPickService.show(codeActions.map(value => ({ - label: value.description, - value - }), { - placeholder: 'Select code action to apply' - } - )); - } - - // tslint:disable-next-line:no-any - protected async applyCodeAction(codeAction: tsp.CodeAction): Promise { - const client = await this.clientContribution.languageClient; - return client.sendRequest(ExecuteCommandRequest.type, { - command: Commands.APPLY_CODE_ACTION, - arguments: [codeAction] - }); - } - - protected async renameFile({ sourceUri, targetUri }: FileMoveEvent): Promise { - const client = await this.clientContribution.languageClient; - return client.sendRequest(ExecuteCommandRequest.type, { - command: Commands.APPLY_RENAME_FILE, - arguments: [{ - sourceUri: sourceUri.toString(), - targetUri: targetUri.toString() - }] - }); - } - - protected async selectVersion(): Promise { - const items: QuickPickItem[] = []; - const currentVersion = this.clientContribution.version; - let currentItem: QuickPickItem | undefined; - for (const version of await this.clientContribution.getVersions()) { - const item: QuickPickItem = { - label: `Use ${version.qualifier} Version`, - description: version.version, - detail: this.labelProvider.getLongName(new URI(version.uri)), - value: version - }; - if (!currentItem && TypescriptVersion.equals(version, currentVersion)) { - currentItem = item; - } - items.push(item); - } - if (!currentItem) { - currentItem = items[0]; - } - if (currentItem) { - currentItem.label = '• ' + currentItem.label; - } - const selectedVersion = await this.quickPickService.show(items, { - placeholder: 'Select the TypeScript version used for JavaScript and TypeScript language features' - }); - if (selectedVersion) { - this.clientContribution.setVersion(selectedVersion); - } - } - - protected storageKey = 'typescript.contribution'; - protected async restore(): Promise { - const data = await this.storage.getData(this.storageKey); - await this.clientContribution.restore(data); - } - protected async store(): Promise { - const data = this.clientContribution.store(); - await this.storage.setData(this.storageKey, data); - } - - protected readonly toDisposeOnCurrentEditorChanged = new DisposableCollection(); - protected updateStatusBar(): void { - this.toDisposeOnCurrentEditorChanged.dispose(); - - const widget = this.editorManager.currentEditor; - const editor = widget && widget.editor; - this.updateVersionStatus(editor); - if (editor) { - this.toDisposeOnCurrentEditorChanged.push( - editor.onLanguageChanged(() => this.updateVersionStatus(editor)) - ); - } - } - protected updateVersionStatus(editor: TextEditor | undefined): void { - const version = this.clientContribution.version; - const languageId = editor && editor.document.languageId; - if (!languageId || !TS_JS_LANGUAGES.has(languageId) || !version) { - this.statusBar.removeElement('editor-ts-version'); - return; - } - this.statusBar.setElement('editor-ts-version', { - text: version.version, - alignment: StatusBarAlignment.RIGHT, - priority: 0.9, - command: TypeScriptCommands.selectVersion.id - }); - } - -} diff --git a/packages/typescript/src/browser/typescript-frontend-module.ts b/packages/typescript/src/browser/typescript-frontend-module.ts deleted file mode 100644 index cd25103cb5295..0000000000000 --- a/packages/typescript/src/browser/typescript-frontend-module.ts +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2018 TypeFox, Ericsson and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the Eclipse - * Public License v. 2.0 are satisfied: GNU General Public License, version 2 - * with the GNU Classpath Exception which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - ********************************************************************************/ - -import { ContainerModule } from 'inversify'; -import { CommandContribution, MenuContribution } from '@theia/core/lib/common'; -import { KeybindingContext, KeybindingContribution, WebSocketConnectionProvider, FrontendApplicationContribution } from '@theia/core/lib/browser'; -import { LanguageClientContribution } from '@theia/languages/lib/browser'; -import { CallHierarchyService } from '@theia/callhierarchy/lib/browser'; -import { TypeScriptClientContribution } from './typescript-client-contribution'; -import { TypeScriptCallHierarchyService } from './typescript-callhierarchy-service'; -import { TypeScriptFrontendContribution } from './typescript-frontend-contribution'; -import { TypeScriptEditorTextFocusContext } from './typescript-keybinding-contexts'; -import { bindTypescriptPreferences } from './typescript-preferences'; -import { TypescriptVersionService, typescriptVersionPath } from '../common/typescript-version-service'; - -export default new ContainerModule(bind => { - bindTypescriptPreferences(bind); - - bind(TypescriptVersionService).toDynamicValue(({ container }) => - WebSocketConnectionProvider.createProxy(container, typescriptVersionPath) - ).inSingletonScope(); - bind(TypeScriptClientContribution).toSelf().inSingletonScope(); - bind(LanguageClientContribution).toService(TypeScriptClientContribution); - - bind(TypeScriptCallHierarchyService).toSelf().inSingletonScope(); - bind(CallHierarchyService).toService(TypeScriptCallHierarchyService); - - bind(TypeScriptFrontendContribution).toSelf().inSingletonScope(); - bind(CommandContribution).toService(TypeScriptFrontendContribution); - bind(MenuContribution).toService(TypeScriptFrontendContribution); - bind(KeybindingContribution).toService(TypeScriptFrontendContribution); - bind(FrontendApplicationContribution).toService(TypeScriptFrontendContribution); - - bind(KeybindingContext).to(TypeScriptEditorTextFocusContext).inSingletonScope(); -}); diff --git a/packages/typescript/src/browser/typescript-keybinding-contexts.ts b/packages/typescript/src/browser/typescript-keybinding-contexts.ts deleted file mode 100644 index fa0787624b556..0000000000000 --- a/packages/typescript/src/browser/typescript-keybinding-contexts.ts +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2018 TypeFox and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the Eclipse - * Public License v. 2.0 are satisfied: GNU General Public License, version 2 - * with the GNU Classpath Exception which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - ********************************************************************************/ - -import { injectable } from 'inversify'; -import { EditorTextFocusContext, EditorWidget } from '@theia/editor/lib/browser'; -import { TYPESCRIPT_LANGUAGE_ID } from '../common'; - -export namespace TypeScriptKeybindingContexts { - export const typescriptEditorTextFocus = 'typescriptEditorTextFocus'; -} - -@injectable() -export class TypeScriptEditorTextFocusContext extends EditorTextFocusContext { - - readonly id: string = TypeScriptKeybindingContexts.typescriptEditorTextFocus; - - protected canHandle(widget: EditorWidget): boolean { - return super.canHandle(widget) && widget.editor.document.languageId === TYPESCRIPT_LANGUAGE_ID; - } - -} diff --git a/packages/typescript/src/browser/typescript-preferences.ts b/packages/typescript/src/browser/typescript-preferences.ts deleted file mode 100644 index 24b62f245f8c0..0000000000000 --- a/packages/typescript/src/browser/typescript-preferences.ts +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2018 TypeFox and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the Eclipse - * Public License v. 2.0 are satisfied: GNU General Public License, version 2 - * with the GNU Classpath Exception which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - ********************************************************************************/ - -import { interfaces } from 'inversify'; -import { - createPreferenceProxy, - PreferenceProxy, - PreferenceService, - PreferenceContribution, - PreferenceSchema, - PreferenceChangeEvent -} from '@theia/core/lib/browser/preferences'; - -export const typescriptPreferenceSchema: PreferenceSchema = { - 'type': 'object', - 'properties': { - 'typescript.server.log': { - 'type': 'string', - 'enum': [ - 'off', - 'terse', - 'normal', - 'verbose' - ], - 'default': 'off', - // tslint:disable-next-line:max-line-length - 'description': 'Enables logging of the TS server to a file. This log can be used to diagnose TS Server issues. The log may contain file paths, source code, and other potentially sensitive information from your project.' - }, - 'typescript.tsdk': { - 'type': [ - 'string', - 'null' - ], - // tslint:disable-next-line:no-null-keyword - 'default': null, - 'description': 'Specifies the folder path containing the tsserver and lib*.d.ts files to use.', - 'scope': 'window' - } - } -}; - -export interface TypescriptConfiguration { - 'typescript.server.log': 'off' | 'terse' | 'normal' | 'verbose' - 'typescript.tsdk'?: string -} -export type TypescriptPreferenceChange = PreferenceChangeEvent; - -export const TypescriptPreferences = Symbol('TypescriptPreferences'); -export type TypescriptPreferences = PreferenceProxy; - -export function createTypescriptPreferences(preferences: PreferenceService): TypescriptPreferences { - return createPreferenceProxy(preferences, typescriptPreferenceSchema); -} - -export function bindTypescriptPreferences(bind: interfaces.Bind): void { - bind(TypescriptPreferences).toDynamicValue(ctx => { - const preferences = ctx.container.get(PreferenceService); - return createTypescriptPreferences(preferences); - }).inSingletonScope(); - - bind(PreferenceContribution).toConstantValue({ schema: typescriptPreferenceSchema }); -} diff --git a/packages/typescript/src/common/index.ts b/packages/typescript/src/common/index.ts deleted file mode 100644 index 9318346355cf1..0000000000000 --- a/packages/typescript/src/common/index.ts +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2017 TypeFox and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the Eclipse - * Public License v. 2.0 are satisfied: GNU General Public License, version 2 - * with the GNU Classpath Exception which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - ********************************************************************************/ - -import { TypescriptVersion } from './typescript-version-service'; - -export const TYPESCRIPT_LANGUAGE_ID = 'typescript'; -export const TYPESCRIPT_LANGUAGE_NAME = 'TypeScript'; - -export const TYPESCRIPT_REACT_LANGUAGE_ID = 'typescriptreact'; -export const TYPESCRIPT_REACT_LANGUAGE_NAME = 'TypeScript React'; - -export const JAVASCRIPT_LANGUAGE_ID = 'javascript'; -export const JAVASCRIPT_LANGUAGE_NAME = 'JavaScript'; - -export const JAVASCRIPT_REACT_LANGUAGE_ID = 'javascriptreact'; -export const JAVASCRIPT_REACT_LANGUAGE_NAME = 'JavaScript React'; - -export const JSX_TAGS_LANGUAGE_ID = 'jsx-tags'; - -export const TS_JS_LANGUAGES = new Set([ - TYPESCRIPT_LANGUAGE_ID, - TYPESCRIPT_REACT_LANGUAGE_ID, - JAVASCRIPT_LANGUAGE_ID, - JAVASCRIPT_REACT_LANGUAGE_ID, - JSX_TAGS_LANGUAGE_ID -]); - -export interface TypescriptStartParams { - version?: TypescriptVersion -} diff --git a/packages/typescript/src/common/typescript-version-service.ts b/packages/typescript/src/common/typescript-version-service.ts deleted file mode 100644 index a3c950abd6371..0000000000000 --- a/packages/typescript/src/common/typescript-version-service.ts +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2018 TypeFox and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the Eclipse - * Public License v. 2.0 are satisfied: GNU General Public License, version 2 - * with the GNU Classpath Exception which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - ********************************************************************************/ - -export const typescriptVersionPath = '/services/ts-version'; - -export type TypescriptVersionQualifier = 'Bundled' | 'Workspace'; -export interface TypescriptVersion { - uri: string - version: string - qualifier: TypescriptVersionQualifier -} -export namespace TypescriptVersion { - export function equals(one: TypescriptVersion | undefined, another: TypescriptVersion | undefined): boolean { - return JSON.stringify({ version: one }) === JSON.stringify({ version: another }); - } -} - -export interface TypescriptVersionOptions { - workspaceFolders: string[] - localTsdk?: string -} - -export const TypescriptVersionService = Symbol('TypescriptVersionService'); -export interface TypescriptVersionService { - getVersions(options: TypescriptVersionOptions): Promise -} diff --git a/packages/typescript/src/node/command-exists.d.ts b/packages/typescript/src/node/command-exists.d.ts deleted file mode 100644 index 6789c65c21f36..0000000000000 --- a/packages/typescript/src/node/command-exists.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2018 TypeFox and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the Eclipse - * Public License v. 2.0 are satisfied: GNU General Public License, version 2 - * with the GNU Classpath Exception which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - ********************************************************************************/ - - declare module 'command-exists' { - function sync(command: string): boolean; -} diff --git a/packages/typescript/src/node/startserver.ts b/packages/typescript/src/node/startserver.ts deleted file mode 100644 index 91135e49ec691..0000000000000 --- a/packages/typescript/src/node/startserver.ts +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2017 TypeFox and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the Eclipse - * Public License v. 2.0 are satisfied: GNU General Public License, version 2 - * with the GNU Classpath Exception which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - ********************************************************************************/ - -// delegate to allow resolving the file in a hoisted scenario - -// uncomment to run against repo checked out next to theia -// require("./../../../../../typescript-language-server/lib/cli"); -require('typescript-language-server/lib/cli'); diff --git a/packages/typescript/src/node/typescript-backend-module.ts b/packages/typescript/src/node/typescript-backend-module.ts deleted file mode 100644 index 82b9ad8d810f4..0000000000000 --- a/packages/typescript/src/node/typescript-backend-module.ts +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2017 TypeFox and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the Eclipse - * Public License v. 2.0 are satisfied: GNU General Public License, version 2 - * with the GNU Classpath Exception which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - ********************************************************************************/ - -import { ContainerModule } from 'inversify'; -import { JsonRpcConnectionHandler, ConnectionHandler } from '@theia/core/lib/common'; -import { LanguageServerContribution } from '@theia/languages/lib/node'; -import { TypeScriptContribution } from './typescript-contribution'; -import { typescriptVersionPath, TypescriptVersionService } from '../common/typescript-version-service'; -import { TypescriptVersionServiceImpl } from './typescript-version-service-impl'; - -export default new ContainerModule(bind => { - bind(LanguageServerContribution).to(TypeScriptContribution).inSingletonScope(); - - bind(TypescriptVersionService).to(TypescriptVersionServiceImpl).inSingletonScope(); - bind(ConnectionHandler).toDynamicValue(ctx => - new JsonRpcConnectionHandler(typescriptVersionPath, () => - ctx.container.get(TypescriptVersionService) - ) - ).inSingletonScope(); -}); diff --git a/packages/typescript/src/node/typescript-contribution.ts b/packages/typescript/src/node/typescript-contribution.ts deleted file mode 100644 index 35fb82489711c..0000000000000 --- a/packages/typescript/src/node/typescript-contribution.ts +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2017 TypeFox and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the Eclipse - * Public License v. 2.0 are satisfied: GNU General Public License, version 2 - * with the GNU Classpath Exception which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - ********************************************************************************/ - -import { injectable, postConstruct, inject } from 'inversify'; -import * as path from 'path'; -import { ApplicationPackage, environment } from '@theia/application-package'; -import { BaseLanguageServerContribution, IConnection, LanguageServerStartOptions } from '@theia/languages/lib/node'; -import { TYPESCRIPT_LANGUAGE_ID, TYPESCRIPT_LANGUAGE_NAME, TypescriptStartParams } from '../common'; -import { TypeScriptPlugin, TypeScriptInitializeParams, TypeScriptInitializationOptions } from 'typescript-language-server/lib/ts-protocol'; -import { isRequestMessage, Message } from 'vscode-ws-jsonrpc'; -import { InitializeRequest } from 'vscode-languageserver-protocol'; -import { TypescriptVersionURI } from './typescript-version-service-impl'; - -export interface TypeScriptStartOptions extends LanguageServerStartOptions { - parameters?: TypescriptStartParams -} - -@injectable() -export class TypeScriptContribution extends BaseLanguageServerContribution { - - readonly id = TYPESCRIPT_LANGUAGE_ID; - readonly name = TYPESCRIPT_LANGUAGE_NAME; - - protected readonly plugins: TypeScriptPlugin[] = []; - - @inject(ApplicationPackage) - protected readonly applicationPackage: ApplicationPackage; - - @postConstruct() - protected init(): void { - for (const extension of this.applicationPackage.extensionPackages) { - const { contributes, installed } = extension.raw; - if (installed && contributes && contributes.typescriptServerPlugins && Array.isArray(contributes.typescriptServerPlugins)) { - for (const plugin of contributes.typescriptServerPlugins) { - this.plugins.push({ - name: plugin.name, - location: installed.packagePath - }); - } - } - } - } - - async start(clientConnection: IConnection, { parameters }: TypeScriptStartOptions): Promise { - // Re-use the same tool used to launch Theia. e.g. for an Electron Theia packaging, - // this will be "electron" executable that is bundled with the application. - const command = process.execPath; - const args: string[] = [ - path.join(__dirname, 'startserver.js'), - '--stdio' - ]; - const tsServerPath = TypescriptVersionURI.getTsServerPath(parameters && parameters.version); - if (tsServerPath) { - args.push(`--tsserver-path=${tsServerPath}`); - } - const serverConnection = await this.createProcessStreamConnectionAsync(command, args, { env: environment.electron.runAsNodeEnv() }); - this.forward(clientConnection, serverConnection); - } - - protected map(message: Message): Message { - if (isRequestMessage(message)) { - if (message.method === InitializeRequest.type.method) { - const initializeParams = message.params as TypeScriptInitializeParams; - if (this.plugins.length) { - const options: TypeScriptInitializationOptions = { - plugins: [], - ...initializeParams.initializationOptions - }; - options.plugins.push(...this.plugins); - initializeParams.initializationOptions = options; - } - } - } - return super.map(message); - } - -} diff --git a/packages/typescript/src/node/typescript-version-service-impl.spec.ts b/packages/typescript/src/node/typescript-version-service-impl.spec.ts deleted file mode 100644 index c99f34d6897dc..0000000000000 --- a/packages/typescript/src/node/typescript-version-service-impl.spec.ts +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2018 TypeFox and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the Eclipse - * Public License v. 2.0 are satisfied: GNU General Public License, version 2 - * with the GNU Classpath Exception which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - ********************************************************************************/ - -import * as os from 'os'; -import * as path from 'path'; -import * as assert from 'assert'; -import URI from '@theia/core/lib/common/uri'; -import { isWindows } from '@theia/core/lib/common/os'; -import { FileUri } from '@theia/core/lib/node'; -import { TypescriptVersionServiceImpl, TypescriptVersionURI } from './typescript-version-service-impl'; - -describe('TypescriptVersionServiceImpl', function (): void { - - const projectUri = FileUri.create(path.resolve(__dirname, '../../../..')); - let impl: TypescriptVersionServiceImpl; - - beforeEach(() => { - impl = new TypescriptVersionServiceImpl(); - // tslint:disable-next-line:no-any - (impl as any).applicationPackage = { - projectPath: FileUri.fsPath(projectUri) - }; - }); - afterEach(() => { - impl = undefined!; - }); - - it('resolveBundledVersionInApplicationPath', async () => { - const version = await impl['resolveBundledVersionInApplicationPath'](); - assert.equal(projectUri.relative(new URI(version!.uri)), 'node_modules/typescript/lib'); - }); - - it('resolveBundledVersionWithRequire', async () => { - const version = await impl['resolveBundledVersionWithRequire'](); - assert.equal(projectUri.relative(new URI(version!.uri)), 'node_modules/typescript/lib'); - }); - - it('resolveBundledVersionAsExecutable', async () => { - const version = await impl['resolveBundledVersionAsExecutable'](); - assert.equal(TypescriptVersionURI.getTsServerPath(version!), isWindows ? 'tsserver.cmd' : 'tsserver'); - }); - - it('getVersions', async () => { - const versions = await impl.getVersions({ - workspaceFolders: [projectUri.toString()] - }); - assert.equal( - versions.map(({ qualifier, uri }) => `${qualifier}: ${projectUri.relative(new URI(uri))}`).join(os.EOL), - [ - 'Bundled: node_modules/typescript/lib', - 'Workspace: node_modules/typescript/lib' - ].join(os.EOL) - ); - }); - -}); diff --git a/packages/typescript/src/node/typescript-version-service-impl.ts b/packages/typescript/src/node/typescript-version-service-impl.ts deleted file mode 100644 index 0039df5f70d81..0000000000000 --- a/packages/typescript/src/node/typescript-version-service-impl.ts +++ /dev/null @@ -1,161 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2018 TypeFox and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the Eclipse - * Public License v. 2.0 are satisfied: GNU General Public License, version 2 - * with the GNU Classpath Exception which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - ********************************************************************************/ - -// tslint:disable-next-line:no-implicit-dependencies -import * as fs from 'fs-extra'; -import * as cp from 'child_process'; -import * as commandExists from 'command-exists'; -import { injectable, inject } from 'inversify'; -import URI from '@theia/core/lib/common/uri'; -import { isWindows, Path } from '@theia/core/lib/common'; -import { FileUri } from '@theia/core/lib/node'; -import { TypescriptVersion, TypescriptVersionService, TypescriptVersionOptions } from '../common/typescript-version-service'; -// tslint:disable-next-line:no-implicit-dependencies -import { ApplicationPackage } from '@theia/application-package'; - -export namespace TypescriptVersionURI { - const scheme = 'tsversion'; - export function encodeCommand(command: string): URI { - return new URI().withScheme(scheme).withPath(command); - } - export function getTsServerPath(version: TypescriptVersion | undefined): string | undefined { - const uri = version && version.uri && new URI(version.uri); - if (!uri) { - return undefined; - } - if (uri.scheme === scheme) { - return uri.path.toString(); - } - return FileUri.fsPath(uri.resolve('tsserver.js')); - } -} - -@injectable() -export class TypescriptVersionServiceImpl implements TypescriptVersionService { - - @inject(ApplicationPackage) - protected readonly applicationPackage: ApplicationPackage; - - async getVersions(options: TypescriptVersionOptions): Promise { - const versions: TypescriptVersion[] = []; - const version = await this.resolveBundledVersion(); - if (version) { - versions.push(version); - } - await this.resolveWorkspaceVersions(versions, options); - return versions; - } - - protected async resolveBundledVersion(): Promise { - return await this.resolveBundledVersionInApplicationPath() || - await this.resolveBundledVersionWithRequire() || - this.resolveBundledVersionAsExecutable(); - } - - protected async resolveBundledVersionInApplicationPath(): Promise { - const uri = FileUri.create(this.applicationPackage.projectPath).resolve('node_modules/typescript/lib'); - const version = await this.readVersion(uri); - if (version) { - return { - uri: uri.toString(), - version, - qualifier: 'Bundled' - }; - } - } - - protected async resolveBundledVersionWithRequire(): Promise { - try { - const uri = FileUri.create(require.resolve('typescript')).parent; - const version = await this.readVersion(uri); - if (version) { - return { - uri: uri.toString(), - version, - qualifier: 'Bundled' - }; - } - } catch { /* no-op */ } - } - - protected async resolveBundledVersionAsExecutable(): Promise { - const command = isWindows ? 'tsserver.cmd' : 'tsserver'; - if (!commandExists.sync(command)) { - return undefined; - } - try { - const output = cp.spawnSync(isWindows ? 'tsc.cmd' : 'tsc', ['--version']).output.filter(_ => !!_).map(_ => String(_)).join(''); - const matches = output.match(/(\d+\.\d+\.\d+)/g); - const match = matches && matches[0]; - if (match) { - return { - uri: TypescriptVersionURI.encodeCommand(command).toString(), - version: match, - qualifier: 'Bundled' - }; - } - } catch { /* no-op */ } - } - - protected async resolveWorkspaceVersions(versions: TypescriptVersion[], options: TypescriptVersionOptions): Promise { - const all = new Map(); - const workspaceFolders = options.workspaceFolders.map(uri => new URI(uri)); - if (options.localTsdk) { - await this.resolveVersions(workspaceFolders, all, options.localTsdk); - } - await this.resolveVersions(workspaceFolders, all, 'node_modules/typescript/lib'); - for (const [uri, version] of all.entries()) { - if (version) { - versions.push({ - uri, - version, - qualifier: 'Workspace' - }); - } - } - } - protected async resolveVersions(roots: URI[], versions: Map, rawPath: string): Promise { - const path = new Path(rawPath); - if (path.isAbsolute) { - await this.resolveVersion(versions, new URI().withPath(path)); - } else { - await Promise.all(roots.map(root => - this.resolveVersion(versions, root.resolve(path)) - )); - } - } - protected async resolveVersion(versions: Map, uri: URI): Promise { - const key = uri.toString(); - if (versions.has(key)) { - return; - } - versions.set(key, undefined); - try { - const version = await this.readVersion(uri); - versions.set(key, version); - } catch { /*no-op*/ } - } - - protected async readVersion(uri: URI): Promise { - try { - const packagePath = FileUri.fsPath(uri.parent.resolve('package.json')); - const pck: { version?: string | Object } | undefined = await fs.readJSON(packagePath); - return pck && pck.version && typeof pck.version === 'string' ? pck.version : undefined; - } catch { /*no-op*/ } - return undefined; - } - -} diff --git a/packages/typescript/src/package.spec.ts b/packages/typescript/src/package.spec.ts deleted file mode 100644 index a2c6e1ecadb70..0000000000000 --- a/packages/typescript/src/package.spec.ts +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2017 Ericsson and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the Eclipse - * Public License v. 2.0 are satisfied: GNU General Public License, version 2 - * with the GNU Classpath Exception which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - ********************************************************************************/ - -/* note: this bogus test file is required so that - we are able to run mocha unit tests on this - package, without having any actual unit tests in it. - This way a coverage report will be generated, - showing 0% coverage, instead of no report. - This file can be removed once we have real unit - tests in place. */ - -describe('typescript package', () => { - - it('should support code coverage statistics', () => true); -}); diff --git a/yarn.lock b/yarn.lock index fc6aa1db236b8..2c488c634f868 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3700,16 +3700,6 @@ combined-stream@^1.0.6, combined-stream@~1.0.6: dependencies: delayed-stream "~1.0.0" -command-exists@1.2.6: - version "1.2.6" - resolved "https://registry.yarnpkg.com/command-exists/-/command-exists-1.2.6.tgz#577f8e5feb0cb0f159cd557a51a9be1bdd76e09e" - integrity sha512-Qst/zUUNmS/z3WziPxyqjrcz09pm+2Knbs5mAZL4VAE0sSrNY1/w8+/YxeHcoBTsO6iojA6BW7eFf27Eg2MRuw== - -command-exists@^1.2.8: - version "1.2.8" - resolved "https://registry.yarnpkg.com/command-exists/-/command-exists-1.2.8.tgz#715acefdd1223b9c9b37110a149c6392c2852291" - integrity sha512-PM54PkseWbiiD/mMsbvW351/u+dafwTJ0ye2qB60G1aGQP9j3xK2gmMDc+R34L3nDtx4qMCitXT75mkbkGJDLw== - command-join@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/command-join/-/command-join-2.0.1.tgz#0a9e58a84e94bd0d1b6c75ce1078723d8a7645cb" @@ -3722,7 +3712,7 @@ commander@2.6.0: resolved "https://registry.yarnpkg.com/commander/-/commander-2.6.0.tgz#9df7e52fb2a0cb0fb89058ee80c3104225f37e1d" integrity sha1-nfflL7Kgyw+4kFjugMMQQiXzfh0= -commander@^2.11.0, commander@^2.12.1, commander@^2.20.0, commander@~2.20.3: +commander@^2.12.1, commander@^2.20.0, commander@~2.20.3: version "2.20.3" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== @@ -4168,11 +4158,6 @@ crypto-browserify@^3.11.0: randombytes "^2.0.0" randomfill "^1.0.3" -crypto-random-string@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e" - integrity sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4= - css-color-names@0.0.4: version "0.0.4" resolved "https://registry.yarnpkg.com/css-color-names/-/css-color-names-0.0.4.tgz#808adc2e79cf84738069b646cb20ec27beb629e0" @@ -8949,11 +8934,6 @@ p-debounce@*, p-debounce@^2.1.0: resolved "https://registry.yarnpkg.com/p-debounce/-/p-debounce-2.1.0.tgz#e79f70c6e325cbb9bddbcbec0b81025084671ad3" integrity sha512-M9bMt62TTnozdZhqFgs+V7XD2MnuKCaz+7fZdlu2/T7xruI3uIE5CicQ0vx1hV7HIUYF0jF+4/R1AgfOkl74Qw== -p-debounce@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/p-debounce/-/p-debounce-1.0.0.tgz#cb7f2cbeefd87a09eba861e112b67527e621e2fd" - integrity sha1-y38svu/YegnrqGHhErZ1J+Yh4v0= - p-defer@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c" @@ -11561,14 +11541,6 @@ tempfile@^1.1.1: os-tmpdir "^1.0.0" uuid "^2.0.1" -tempy@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/tempy/-/tempy-0.2.1.tgz#9038e4dbd1c201b74472214179bc2c6f7776e54c" - integrity sha512-LB83o9bfZGrntdqPuRdanIVCPReam9SOZKW0fOy5I9X3A854GGWi0tjCqoXEk84XIEYBc/x9Hq3EFop/H5wJaw== - dependencies: - temp-dir "^1.0.0" - unique-string "^1.0.0" - terser-webpack-plugin@^1.4.3: version "1.4.3" resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-1.4.3.tgz#5ecaf2dbdc5fb99745fd06791f46fc9ddb1c9a7c" @@ -11948,19 +11920,6 @@ typedoc@^0.15.0-0: typedoc-default-themes "^0.6.3" typescript "3.7.x" -typescript-language-server@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/typescript-language-server/-/typescript-language-server-0.4.0.tgz#9b4aee8e001a69fcd152459a6cc1a08283db9193" - integrity sha512-K8jNOmDFn+QfrCh8ujby2pGDs5rpjYZQn+zvQnf42rxG4IHbfw5CHoMvbGkWPK/J5Gw8/l5K3i03kVZC2IBElg== - dependencies: - command-exists "1.2.6" - commander "^2.11.0" - fs-extra "^7.0.0" - p-debounce "^1.0.0" - tempy "^0.2.1" - vscode-languageserver "^5.3.0-next" - vscode-uri "^1.0.5" - typescript@3.7.x: version "3.7.4" resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.4.tgz#1743a5ec5fef6a1fa9f3e4708e33c81c73876c19" @@ -12073,13 +12032,6 @@ unique-slug@^2.0.0: dependencies: imurmurhash "^0.1.4" -unique-string@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/unique-string/-/unique-string-1.0.0.tgz#9e1057cca851abb93398f8b33ae187b99caec11a" - integrity sha1-nhBXzKhRq7kzmPizOuGHuZyuwRo= - dependencies: - crypto-random-string "^1.0.0" - universalify@^0.1.0: version "0.1.2" resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" @@ -12389,14 +12341,6 @@ vscode-languageserver@6.0.0-next.1, vscode-languageserver@^6.0.0-next.1: vscode-languageserver-protocol "^3.15.0-next.9" vscode-textbuffer "^1.0.0" -vscode-languageserver@^5.3.0-next: - version "5.3.0-next.10" - resolved "https://registry.yarnpkg.com/vscode-languageserver/-/vscode-languageserver-5.3.0-next.10.tgz#995fe8b57fc4eb9fea0d11762d3a803de4278995" - integrity sha512-QL7Fe1FT6PdLtVzwJeZ78pTic4eZbzLRy7yAQgPb9xalqqgZESR0+yDZPwJrM3E7PzOmwHBceYcJR54eQZ7Kng== - dependencies: - vscode-languageserver-protocol "^3.15.0-next.8" - vscode-textbuffer "^1.0.0" - vscode-nls@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.1.1.tgz#f9916b64e4947b20322defb1e676a495861f133c"