diff options
Diffstat (limited to 'build/extension/client/src')
-rw-r--r-- | build/extension/client/src/extension.ts | 65 | ||||
-rw-r--r-- | build/extension/client/src/test/completion.test.ts | 44 | ||||
-rw-r--r-- | build/extension/client/src/test/diagnostics.test.ts | 42 | ||||
-rw-r--r-- | build/extension/client/src/test/helper.ts | 48 | ||||
-rw-r--r-- | build/extension/client/src/test/index.ts | 15 |
5 files changed, 0 insertions, 214 deletions
diff --git a/build/extension/client/src/extension.ts b/build/extension/client/src/extension.ts deleted file mode 100644 index 13899f2a..00000000 --- a/build/extension/client/src/extension.ts +++ /dev/null @@ -1,65 +0,0 @@ -/* -------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - * ------------------------------------------------------------------------------------------ */ -'use strict'; - -import * as path from 'path'; -import { workspace, ExtensionContext } from 'vscode'; - -import { - LanguageClient, - LanguageClientOptions, - ServerOptions, -} from 'vscode-languageclient'; - -let client: LanguageClient; - -export function activate(context: ExtensionContext) { - // If the extension is launched in debug mode then the debug server options are used - // Otherwise the run options are used - let serverOptions: ServerOptions = { - command: context.asAbsolutePath( - path.join('server', 'bin', 'lua.exe') - ), - args: [ - '-E', - context.asAbsolutePath( - path.join('server', 'main.lua') - ) - ], - options: { - cwd: context.asAbsolutePath( - path.join('server') - ), - } - }; - - // Options to control the language client - let clientOptions: LanguageClientOptions = { - // Register the server for plain text documents - documentSelector: [{ scheme: 'file', language: 'lua' }], - synchronize: { - // Notify the server about file changes to '.clientrc files contained in the workspace - fileEvents: workspace.createFileSystemWatcher('**/.clientrc') - } - }; - - // Create the language client and start the client. - client = new LanguageClient( - 'languageServerExample', - 'Language Server Example', - serverOptions, - clientOptions - ); - - // Start the client. This will also launch the server - client.start(); -} - -export function deactivate(): Thenable<void> { - if (!client) { - return undefined; - } - return client.stop(); -} diff --git a/build/extension/client/src/test/completion.test.ts b/build/extension/client/src/test/completion.test.ts deleted file mode 100644 index 2cb65642..00000000 --- a/build/extension/client/src/test/completion.test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - * ------------------------------------------------------------------------------------------ */ -'use strict'; - -import * as vscode from 'vscode'; -import * as assert from 'assert'; -import { getDocUri, activate } from './helper'; - -describe('Should do completion', () => { - const docUri = getDocUri('completion.txt'); - - it('Completes JS/TS in txt file', async () => { - await testCompletion(docUri, new vscode.Position(0, 0), { - items: [ - { label: 'JavaScript', kind: vscode.CompletionItemKind.Text }, - { label: 'TypeScript', kind: vscode.CompletionItemKind.Text } - ] - }); - }); -}); - -async function testCompletion( - docUri: vscode.Uri, - position: vscode.Position, - expectedCompletionList: vscode.CompletionList -) { - await activate(docUri); - - // Executing the command `vscode.executeCompletionItemProvider` to simulate triggering completion - const actualCompletionList = (await vscode.commands.executeCommand( - 'vscode.executeCompletionItemProvider', - docUri, - position - )) as vscode.CompletionList; - - assert.equal(actualCompletionList.items.length, expectedCompletionList.items.length); - expectedCompletionList.items.forEach((expectedItem, i) => { - const actualItem = actualCompletionList.items[i]; - assert.equal(actualItem.label, expectedItem.label); - assert.equal(actualItem.kind, expectedItem.kind); - }); -} diff --git a/build/extension/client/src/test/diagnostics.test.ts b/build/extension/client/src/test/diagnostics.test.ts deleted file mode 100644 index 1eee4990..00000000 --- a/build/extension/client/src/test/diagnostics.test.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - * ------------------------------------------------------------------------------------------ */ -'use strict'; - -import * as vscode from 'vscode' -import * as assert from 'assert' -import { getDocUri, activate } from './helper' - -describe('Should get diagnostics', () => { - const docUri = getDocUri('diagnostics.txt') - - it('Diagnoses uppercase texts', async () => { - await testDiagnostics(docUri, [ - { message: 'ANY is all uppercase.', range: toRange(0, 0, 0, 3), severity: vscode.DiagnosticSeverity.Warning, source: 'ex' }, - { message: 'ANY is all uppercase.', range: toRange(0, 14, 0, 17), severity: vscode.DiagnosticSeverity.Warning, source: 'ex' }, - { message: 'OS is all uppercase.', range: toRange(0, 18, 0, 20), severity: vscode.DiagnosticSeverity.Warning, source: 'ex' } - ]) - }) -}) - -function toRange(sLine: number, sChar: number, eLine: number, eChar: number) { - const start = new vscode.Position(sLine, sChar) - const end = new vscode.Position(eLine, eChar) - return new vscode.Range(start, end) -} - -async function testDiagnostics(docUri: vscode.Uri, expectedDiagnostics: vscode.Diagnostic[]) { - await activate(docUri) - - const actualDiagnostics = vscode.languages.getDiagnostics(docUri); - - assert.equal(actualDiagnostics.length, expectedDiagnostics.length); - - expectedDiagnostics.forEach((expectedDiagnostic, i) => { - const actualDiagnostic = actualDiagnostics[i] - assert.equal(actualDiagnostic.message, expectedDiagnostic.message) - assert.deepEqual(actualDiagnostic.range, expectedDiagnostic.range) - assert.equal(actualDiagnostic.severity, expectedDiagnostic.severity) - }) -}
\ No newline at end of file diff --git a/build/extension/client/src/test/helper.ts b/build/extension/client/src/test/helper.ts deleted file mode 100644 index 22121c1c..00000000 --- a/build/extension/client/src/test/helper.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - * ------------------------------------------------------------------------------------------ */ -'use strict'; - -import * as vscode from 'vscode'; -import * as path from 'path'; - -export let doc: vscode.TextDocument; -export let editor: vscode.TextEditor; -export let documentEol: string; -export let platformEol: string; - -/** - * Activates the vscode.lsp-sample extension - */ -export async function activate(docUri: vscode.Uri) { - // The extensionId is `publisher.name` from package.json - const ext = vscode.extensions.getExtension('vscode.lsp-sample'); - await ext.activate(); - try { - doc = await vscode.workspace.openTextDocument(docUri); - editor = await vscode.window.showTextDocument(doc); - await sleep(2000); // Wait for server activation - } catch (e) { - console.error(e); - } -} - -async function sleep(ms: number) { - return new Promise(resolve => setTimeout(resolve, ms)); -} - -export const getDocPath = (p: string) => { - return path.resolve(__dirname, '../../testFixture', p); -}; -export const getDocUri = (p: string) => { - return vscode.Uri.file(getDocPath(p)); -}; - -export async function setTestContent(content: string): Promise<boolean> { - const all = new vscode.Range( - doc.positionAt(0), - doc.positionAt(doc.getText().length) - ); - return editor.edit(eb => eb.replace(all, content)); -} diff --git a/build/extension/client/src/test/index.ts b/build/extension/client/src/test/index.ts deleted file mode 100644 index 7fedf55f..00000000 --- a/build/extension/client/src/test/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* -------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - * ------------------------------------------------------------------------------------------ */ -'use strict'; - -import * as testRunner from 'vscode/lib/testrunner'; - -testRunner.configure({ - ui: 'bdd', - useColors: true, - timeout: 100000 -}); - -module.exports = testRunner;
\ No newline at end of file |