Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Implementation of testing api for testing vscode extensions language features #597

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 2 additions & 0 deletions che-theia-init-sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ sources:
- extensions/eclipse-che-theia-about
- extensions/eclipse-che-theia-preferences-provider-extension
- extensions/eclipse-che-theia-git-provisioner
- extensions/eclipse-che-theia-testing-service-ext
- extensions/eclipse-che-theia-testing-service
plugins:
- plugins/containers-plugin
- plugins/workspace-plugin
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib
47 changes: 47 additions & 0 deletions extensions/eclipse-che-theia-testing-service-ext/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "@eclipse-che/testing-service-ext",
"version": "0.0.1",
"description": "Theia - TestService Extension",
"dependencies": {
"@theia/plugin": "^0.15.0",
"@theia/plugin-ext": "^0.15.0",
"@eclipse-che/testing-service": "^0.0.1",
"glob": "^7.1.6",
"mocha": "^3.4.2"
},
"publishConfig": {
"access": "public"
},
"theiaExtensions": [
{
"backend": "lib/node/testservice-ext-backend-module",
"frontend": "lib/browser/testservice-ext-frontend-module"
}
],
"keywords": [
"theia-extension"
],
"license": "EPL-2.0",
"files": [
"lib",
"src"
],
"scripts": {
"prepare": "yarn clean && yarn build",
"clean": "rimraf lib",
"format": "tsfmt -r --useTsfmt ../../configs/tsfmt.json",
"lint": "tslint -c ../../configs/tslint.json --project tsconfig.json",
"compile": "tsc",
"build": "concurrently -n \"format,lint,compile\" -c \"red,green,blue\" \"yarn format\" \"yarn lint\" \"yarn compile\" && yarn run compileWorker",
"compileWorker": "webpack-cli --config webpack.config.js",
"watch": "tsc -w"
},
"devDependencies": {
"clean-webpack-plugin": "^0.1.19",
"ts-loader": "^4.1.0",
"webpack": "^4.20.2",
"webpack-cli": "^3.1.1",
"typescript-formatter": "7.2.2",
"@types/js-yaml": "3.11.2"
}
}
JPinkney marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
/*********************************************************************
* Copyright (c) 2020 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/

import { PluginHandleRegistry } from './plugin-handle-registry';
import { interfaces } from 'inversify';
import { TestAPI } from '../common/test-protocol';
import {
CompletionContext,
CompletionResultDto,
SignatureHelp,
Hover,
DocumentHighlight,
Range,
TextEdit,
FormattingOptions,
Definition,
DefinitionLink,
DocumentLink,
CodeLensSymbol,
DocumentSymbol,
ReferenceContext,
Location,
SignatureHelpContext,
CodeActionContext,
CodeAction,
FoldingRange,
} from '@theia/plugin-ext/lib/common/plugin-api-rpc-model';
import { UriComponents } from '@theia/plugin-ext/lib/common/uri-components';
import { CancellationToken, FoldingContext } from '@theia/plugin';
import { SymbolInformation } from 'vscode-languageserver-types';
import {
Position,
Selection,
RawColorInfo,
WorkspaceEditDto
} from '@theia/plugin-ext/lib/common/plugin-api-rpc';

/**
* This class redirects language api requests to the correct sidecars and returns the results
*/
export class TestAPIImpl implements TestAPI {
JPinkney marked this conversation as resolved.
Show resolved Hide resolved

private readonly pluginHandleRegistry: PluginHandleRegistry;

constructor(container: interfaces.Container) {
tsmaeder marked this conversation as resolved.
Show resolved Hide resolved
this.pluginHandleRegistry = container.get(PluginHandleRegistry);
}

async $provideCompletionItems(pluginID: string, resource: UriComponents, position: Position,
context: CompletionContext, token: CancellationToken): Promise<CompletionResultDto | undefined> {
const { languagesExt, handle } = await this.pluginHandleRegistry.lookupLanguagesExtForPluginAndAction(pluginID, 'completion');
tsmaeder marked this conversation as resolved.
Show resolved Hide resolved
return languagesExt.$provideCompletionItems(handle, resource, position, context, token);
}

async $provideDefinition(pluginID: string, resource: UriComponents, position: Position, token: CancellationToken): Promise<Definition | DefinitionLink[] | undefined> {
const { languagesExt, handle } = await this.pluginHandleRegistry.lookupLanguagesExtForPluginAndAction(pluginID, 'definition');
return languagesExt.$provideDefinition(handle, resource, position, token);
}

async $provideDeclaration(pluginID: string, resource: UriComponents, position: Position, token: CancellationToken): Promise<Definition | DefinitionLink[] | undefined> {
const { languagesExt, handle } = await this.pluginHandleRegistry.lookupLanguagesExtForPluginAndAction(pluginID, 'declaration');
return languagesExt.$provideDeclaration(handle, resource, position, token);
}

async $provideSignatureHelp(pluginID: string, resource: UriComponents, position: Position, context: SignatureHelpContext, token: CancellationToken
): Promise<SignatureHelp | undefined> {
const { languagesExt, handle } = await this.pluginHandleRegistry.lookupLanguagesExtForPluginAndAction(pluginID, 'signatureHelp');
return languagesExt.$provideSignatureHelp(handle, resource, position, context, token);
}

async $provideImplementation(pluginID: string, resource: UriComponents, position: Position, token: CancellationToken): Promise<Definition | DefinitionLink[] | undefined> {
const { languagesExt, handle } = await this.pluginHandleRegistry.lookupLanguagesExtForPluginAndAction(pluginID, 'implementation');
return languagesExt.$provideImplementation(handle, resource, position, token);
}

async $provideTypeDefinition(pluginID: string, resource: UriComponents, position: Position, token: CancellationToken): Promise<Definition | DefinitionLink[] | undefined> {
const { languagesExt, handle } = await this.pluginHandleRegistry.lookupLanguagesExtForPluginAndAction(pluginID, 'typeDefinition');
return languagesExt.$provideTypeDefinition(handle, resource, position, token);
}

async $provideHover(pluginID: string, resource: UriComponents, position: Position, token: CancellationToken): Promise<Hover | undefined> {
const { languagesExt, handle } = await this.pluginHandleRegistry.lookupLanguagesExtForPluginAndAction(pluginID, 'hover');
return languagesExt.$provideHover(handle, resource, position, token);
}

async $provideDocumentHighlights(pluginID: string, resource: UriComponents, position: Position, token: CancellationToken): Promise<DocumentHighlight[] | undefined> {
const { languagesExt, handle } = await this.pluginHandleRegistry.lookupLanguagesExtForPluginAndAction(pluginID, 'documentHighlight');
return languagesExt.$provideDocumentHighlights(handle, resource, position, token);
}

$provideWorkspaceSymbols(pluginID: string, query: string, token: CancellationToken): PromiseLike<SymbolInformation[]> {
return this.pluginHandleRegistry.lookupLanguagesExtForPluginAndAction(pluginID, 'workspaceSymbols').then(({ languagesExt, handle }) =>
languagesExt.$provideWorkspaceSymbols(handle, query, token)
);
}

async $provideDocumentFormattingEdits(pluginID: string, resource: UriComponents,
options: FormattingOptions, token: CancellationToken): Promise<TextEdit[] | undefined> {
const { languagesExt, handle } = await this.pluginHandleRegistry.lookupLanguagesExtForPluginAndAction(pluginID, 'documentFormattingEdits');
return languagesExt.$provideDocumentFormattingEdits(handle, resource, options, token);
}

// tslint:disable-next-line:no-any
async $provideDocumentRangeFormattingEdits(pluginID: string, resource: UriComponents, range: Range,
options: FormattingOptions, token: CancellationToken): Promise<TextEdit[] | undefined> {
const { languagesExt, handle } = await this.pluginHandleRegistry.lookupLanguagesExtForPluginAndAction(pluginID, 'documentRangeFormattingEdits');
return languagesExt.$provideDocumentRangeFormattingEdits(handle, resource, range, options, token);
}

async $provideOnTypeFormattingEdits(pluginID: string,
resource: UriComponents,
position: Position,
ch: string,
options: FormattingOptions,
token: CancellationToken
): Promise<TextEdit[] | undefined> {
const { languagesExt, handle } = await this.pluginHandleRegistry.lookupLanguagesExtForPluginAndAction(pluginID, 'onTypeFormattingEdits');
return languagesExt.$provideOnTypeFormattingEdits(handle, resource, position, ch, options, token);
}

async $provideDocumentLinks(pluginID: string, resource: UriComponents, token: CancellationToken): Promise<DocumentLink[] | undefined> {
const { languagesExt, handle } = await this.pluginHandleRegistry.lookupLanguagesExtForPluginAndAction(pluginID, 'documentLinks');
return languagesExt.$provideDocumentLinks(handle, resource, token);
}

// tslint:disable-next-line:no-any
async $provideCodeActions(pluginID: string,
resource: UriComponents,
rangeOrSelection: Range | Selection,
context: CodeActionContext,
token: CancellationToken
): Promise<CodeAction[] | undefined> {
const { languagesExt, handle } = await this.pluginHandleRegistry.lookupLanguagesExtForPluginAndAction(pluginID, 'codeActions');
return languagesExt.$provideCodeActions(handle, resource, rangeOrSelection, context, token);
}

async $provideCodeLenses(pluginID: string, resource: UriComponents, token: CancellationToken): Promise<CodeLensSymbol[] | undefined> {
const { languagesExt, handle } = await this.pluginHandleRegistry.lookupLanguagesExtForPluginAndAction(pluginID, 'codeLenses');
return languagesExt.$provideCodeLenses(handle, resource, token);
}

async $provideReferences(pluginID: string, resource: UriComponents, position: Position, context: ReferenceContext, token: CancellationToken): Promise<Location[] | undefined> {
const { languagesExt, handle } = await this.pluginHandleRegistry.lookupLanguagesExtForPluginAndAction(pluginID, 'references');
return languagesExt.$provideReferences(handle, resource, position, context, token);
}

$provideDocumentColors(pluginID: string, resource: UriComponents, token: CancellationToken): PromiseLike<RawColorInfo[]> {
return this.pluginHandleRegistry.lookupLanguagesExtForPluginAndAction(pluginID, 'documentColors').then(({ languagesExt, handle }) =>
languagesExt.$provideDocumentColors(handle, resource, token)
);
}

$provideFoldingRange(pluginID: string,
resource: UriComponents,
context: FoldingContext,
token: CancellationToken
): PromiseLike<FoldingRange[] | undefined> {
return this.pluginHandleRegistry.lookupLanguagesExtForPluginAndAction(pluginID, 'foldingRange').then(({ languagesExt, handle }) =>
languagesExt.$provideFoldingRange(handle, resource, context, token)
);
}

$provideRenameEdits(pluginID: string, resource: UriComponents, position: Position, newName: string, token: CancellationToken): PromiseLike<WorkspaceEditDto | undefined> {
return this.pluginHandleRegistry.lookupLanguagesExtForPluginAndAction(pluginID, 'renameEdits').then(({ languagesExt, handle }) =>
languagesExt.$provideRenameEdits(handle, resource, position, newName, token)
);
}

async $provideDocumentSymbols(pluginID: string, resource: UriComponents, token: CancellationToken): Promise<DocumentSymbol[] | undefined> {
const { languagesExt, handle } = await this.pluginHandleRegistry.lookupLanguagesExtForPluginAndAction(pluginID, 'symbols');
return languagesExt.$provideDocumentSymbols(handle, resource, token);
}
}
Loading