From 8cde03896ebda7c68d030eea77373686010c422c Mon Sep 17 00:00:00 2001 From: Dirk Baeumer Date: Mon, 4 Sep 2017 17:44:19 +0200 Subject: [PATCH] Remove old lsp example --- languageprovider-sample/.gitignore | 2 - languageprovider-sample/.vscode/launch.json | 55 ------- languageprovider-sample/.vscode/tasks.json | 12 -- languageprovider-sample/README.md | 20 --- .../client/src/clientMain.ts | 44 ----- languageprovider-sample/client/tsconfig.json | 13 -- languageprovider-sample/package.json | 56 ------- languageprovider-sample/server/package.json | 21 --- .../server/src/serverMain.ts | 153 ------------------ .../server/src/thenable.d.ts | 2 - languageprovider-sample/server/tsconfig.json | 12 -- 11 files changed, 390 deletions(-) delete mode 100644 languageprovider-sample/.gitignore delete mode 100644 languageprovider-sample/.vscode/launch.json delete mode 100644 languageprovider-sample/.vscode/tasks.json delete mode 100644 languageprovider-sample/README.md delete mode 100644 languageprovider-sample/client/src/clientMain.ts delete mode 100644 languageprovider-sample/client/tsconfig.json delete mode 100644 languageprovider-sample/package.json delete mode 100644 languageprovider-sample/server/package.json delete mode 100644 languageprovider-sample/server/src/serverMain.ts delete mode 100644 languageprovider-sample/server/src/thenable.d.ts delete mode 100644 languageprovider-sample/server/tsconfig.json diff --git a/languageprovider-sample/.gitignore b/languageprovider-sample/.gitignore deleted file mode 100644 index 8e5962ee..00000000 --- a/languageprovider-sample/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -out -node_modules \ No newline at end of file diff --git a/languageprovider-sample/.vscode/launch.json b/languageprovider-sample/.vscode/launch.json deleted file mode 100644 index 68421dbc..00000000 --- a/languageprovider-sample/.vscode/launch.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": "Launch Extension", - "type": "extensionHost", - "request": "launch", - "runtimeExecutable": "${execPath}", - "args": [ - "--extensionDevelopmentPath=${workspaceRoot}" - ], - "stopOnEntry": false, - "sourceMaps": true, - "outFiles": [ - "${workspaceRoot}/client/out/**/*.js" - ], - "preLaunchTask": "npm" - }, - { - "name": "Launch Extension Tests", - "type": "extensionHost", - "request": "launch", - "runtimeExecutable": "${execPath}", - "args": [ - "--extensionDevelopmentPath=${workspaceRoot}", - "--extensionTestsPath=${workspaceRoot}/client/out/test" - ], - "stopOnEntry": false, - "sourceMaps": true, - "outFiles": [ - "${workspaceRoot}/client/out/test/**/*.js" - ], - "preLaunchTask": "npm" - }, - { - "name": "Attach Language Server", - "type": "node", - "request": "attach", - "port": 6004, - "sourceMaps": true, - "outFiles": [ - "${workspaceRoot}/server/out/**/*.js" - ] - } - ], - "compounds": [ - { - "name": "Launch Client & Server", - "configurations": [ - "Launch Extension", - "Attach Language Server" - ] - } - ] -} \ No newline at end of file diff --git a/languageprovider-sample/.vscode/tasks.json b/languageprovider-sample/.vscode/tasks.json deleted file mode 100644 index f0b64b94..00000000 --- a/languageprovider-sample/.vscode/tasks.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "version": "0.1.0", - "command": "npm", - "isShellCommand": true, - "showOutput": "silent", - "args": [ - "run", - "watch" - ], - "isBackground": true, - "problemMatcher": "$tsc-watch" -} \ No newline at end of file diff --git a/languageprovider-sample/README.md b/languageprovider-sample/README.md deleted file mode 100644 index 37fd8c41..00000000 --- a/languageprovider-sample/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# README -## This is the README for the "languageprovider-sample" -------------------- - -This folder contains a sample VS code extension that demonstrates an extension that runs a language server - -The extension observes all 'plaintext' documents (documents from all editors not associated with a language) -and uses the server to provide validation and completion proposals. - -The code for the extension is in the 'client' folder. It uses the 'vscode-languageclient' node module to launch the language server. - -The language server is located in the 'server' folder. - - -# How to run locally -* `npm install` to initialize the extension and the server -* `npm run compile` to compile the extension and the server -* open this folder in VS Code. In the Debug viewlet, run 'Launch Client & Server' from drop-down to launch the extension and attach to both the extension and the server. -* create a file `foo.bar`, and type `typescript`. You should see a validation error. -* set breakpoints in the server or the client \ No newline at end of file diff --git a/languageprovider-sample/client/src/clientMain.ts b/languageprovider-sample/client/src/clientMain.ts deleted file mode 100644 index f692a2d6..00000000 --- a/languageprovider-sample/client/src/clientMain.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 path from 'path'; - -import { workspace, Disposable, ExtensionContext } from 'vscode'; -import { LanguageClient, LanguageClientOptions, SettingMonitor, ServerOptions, TransportKind } from 'vscode-languageclient'; - -export function activate(context: ExtensionContext) { - - // The server is implemented in node - let serverModule = context.asAbsolutePath(path.join('server', 'out', 'serverMain.js')); - // The debug options for the server - let debugOptions = { execArgv: ["--nolazy", "--debug=6004"] }; - - // If the extension is launched in debug mode then the debug server options are used - // Otherwise the run options are used - let serverOptions: ServerOptions = { - run: { module: serverModule, transport: TransportKind.ipc }, - debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions } - } - - // Options to control the language client - let clientOptions: LanguageClientOptions = { - // Register the server for plain text documents - documentSelector: ['plaintext'], - synchronize: { - // Synchronize the setting section 'languageServerExample' to the server - configurationSection: 'languageServerExample', - // Notify the server about file changes to '.clientrc files contain in the workspace - fileEvents: workspace.createFileSystemWatcher('**/.clientrc') - } - } - - // Create the language client and start the client. - let disposable = new LanguageClient('languageServerExample', 'Language Server Example', serverOptions, clientOptions).start(); - - // Push the disposable to the context's subscriptions so that the - // client can be deactivated on extension deactivation - context.subscriptions.push(disposable); -} diff --git a/languageprovider-sample/client/tsconfig.json b/languageprovider-sample/client/tsconfig.json deleted file mode 100644 index 8f8a3196..00000000 --- a/languageprovider-sample/client/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module": "commonjs", - "outDir": "./out", - "skipLibCheck": true, - "sourceMap": true, - "lib": [ - "es5", - "es2015.promise" - ] - } -} diff --git a/languageprovider-sample/package.json b/languageprovider-sample/package.json deleted file mode 100644 index 9c67010e..00000000 --- a/languageprovider-sample/package.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "name": "languageprovider-sample", - "description": "Language provider extension that launches a language server", - "author": "Microsoft Corporation", - "license": "MIT", - "version": "0.0.1", - "publisher": "vscode", - "engines": { - "vscode": "^1.4.0" - }, - "categories": [ - "Other" - ], - "activationEvents": [ - "onLanguage:plaintext" - ], - "main": "./client/out/clientMain", - "contributes": { - "configuration": { - "type": "object", - "title": "Example configuration", - "properties": { - "languageServerExample.maxNumberOfProblems": { - "type": "number", - "default": 100, - "description": "Controls the maximum number of problems produced by the server." - }, - "languageServerExample.trace.server": { - "type": "string", - "enum": [ - "off", - "messages", - "verbose" - ], - "default": "off", - "description": "Traces the communication between VSCode and the languageServerExample service." - } - } - } - }, - "scripts": { - "vscode:prepublish": "tsc -p ./", - "compile": "tsc -p ./client && cd server && npm run compile && cd ..", - "update-vscode": "node ./node_modules/vscode/bin/install", - "postinstall": "node ./node_modules/vscode/bin/install && cd server && npm install" - }, - "devDependencies": { - "@types/mocha": "^2.2.33", - "@types/node": "^6.0.52", - "typescript": "^2.1.4", - "vscode": "^1.0.3" - }, - "dependencies": { - "vscode-languageclient": "^2.6.3" - } -} \ No newline at end of file diff --git a/languageprovider-sample/server/package.json b/languageprovider-sample/server/package.json deleted file mode 100644 index b579c535..00000000 --- a/languageprovider-sample/server/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "language-server-example", - "description": "Example implementation of a language server in node.", - "version": "0.0.1", - "author": "Microsoft Corporation", - "license": "MIT", - "engines": { - "node": "*" - }, - "dependencies": { - "vscode-languageserver": "^2.6.2" - }, - "devDependencies": { - "@types/node": "^6.0.52", - "typescript": "^2.1.4" - }, - "scripts": { - "compile": "tsc -p .", - "watch": "tsc --watch -p ." - } -} diff --git a/languageprovider-sample/server/src/serverMain.ts b/languageprovider-sample/server/src/serverMain.ts deleted file mode 100644 index 35040794..00000000 --- a/languageprovider-sample/server/src/serverMain.ts +++ /dev/null @@ -1,153 +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 { - IPCMessageReader, IPCMessageWriter, - createConnection, IConnection, TextDocumentSyncKind, - TextDocuments, TextDocument, Diagnostic, DiagnosticSeverity, - InitializeParams, InitializeResult, TextDocumentPositionParams, - CompletionItem, CompletionItemKind -} from 'vscode-languageserver'; - -// Create a connection for the server. The connection uses Node's IPC as a transport -let connection: IConnection = createConnection(new IPCMessageReader(process), new IPCMessageWriter(process)); - -// Create a simple text document manager. The text document manager -// supports full document sync only -let documents: TextDocuments = new TextDocuments(); -// Make the text document manager listen on the connection -// for open, change and close text document events -documents.listen(connection); - -// After the server has started the client sends an initilize request. The server receives -// in the passed params the rootPath of the workspace plus the client capabilites. -let workspaceRoot: string; -connection.onInitialize((params): InitializeResult => { - workspaceRoot = params.rootPath; - return { - capabilities: { - // Tell the client that the server works in FULL text document sync mode - textDocumentSync: documents.syncKind, - // Tell the client that the server support code complete - completionProvider: { - resolveProvider: true - } - } - } -}); - -// The content of a text document has changed. This event is emitted -// when the text document first opened or when its content has changed. -documents.onDidChangeContent((change) => { - validateTextDocument(change.document); -}); - -// The settings interface describe the server relevant settings part -interface Settings { - languageServerExample: ExampleSettings; -} - -// These are the example settings we defined in the client's package.json -// file -interface ExampleSettings { - maxNumberOfProblems: number; -} - -// hold the maxNumberOfProblems setting -let maxNumberOfProblems: number; -// The settings have changed. Is send on server activation -// as well. -connection.onDidChangeConfiguration((change) => { - let settings = change.settings; - maxNumberOfProblems = settings.languageServerExample.maxNumberOfProblems || 100; - // Revalidate any open text documents - documents.all().forEach(validateTextDocument); -}); - -function validateTextDocument(textDocument: TextDocument): void { - let diagnostics: Diagnostic[] = []; - let lines = textDocument.getText().split(/\r?\n/g); - let problems = 0; - for (var i = 0; i < lines.length && problems < maxNumberOfProblems; i++) { - let line = lines[i]; - let index = line.indexOf('typescript'); - if (index >= 0) { - problems++; - diagnostics.push({ - severity: DiagnosticSeverity.Warning, - range: { - start: { line: i, character: index }, - end: { line: i, character: index + 10 } - }, - message: `${line.substr(index, 10)} should be spelled TypeScript`, - source: 'ex' - }); - } - } - // Send the computed diagnostics to VSCode. - connection.sendDiagnostics({ uri: textDocument.uri, diagnostics }); -} - -connection.onDidChangeWatchedFiles((change) => { - // Monitored files have change in VSCode - connection.console.log('We recevied an file change event'); -}); - - -// This handler provides the initial list of the completion items. -connection.onCompletion((textDocumentPosition: TextDocumentPositionParams): CompletionItem[] => { - // The pass parameter contains the position of the text document in - // which code complete got requested. For the example we ignore this - // info and always provide the same completion items. - return [ - { - label: 'TypeScript', - kind: CompletionItemKind.Text, - data: 1 - }, - { - label: 'JavaScript', - kind: CompletionItemKind.Text, - data: 2 - } - ] -}); - -// This handler resolve additional information for the item selected in -// the completion list. -connection.onCompletionResolve((item: CompletionItem): CompletionItem => { - if (item.data === 1) { - item.detail = 'TypeScript details', - item.documentation = 'TypeScript documentation' - } else if (item.data === 2) { - item.detail = 'JavaScript details', - item.documentation = 'JavaScript documentation' - } - return item; -}); - -/* -connection.onDidOpenTextDocument((params) => { - // A text document got opened in VSCode. - // params.uri uniquely identifies the document. For documents store on disk this is a file URI. - // params.text the initial full content of the document. - connection.console.log(`${params.textDocument.uri} opened.`); -}); -connection.onDidChangeTextDocument((params) => { - // The content of a text document did change in VSCode. - // params.uri uniquely identifies the document. - // params.contentChanges describe the content changes to the document. - connection.console.log(`${params.textDocument.uri} changed: ${JSON.stringify(params.contentChanges)}`); -}); -connection.onDidCloseTextDocument((params) => { - // A text document got closed in VSCode. - // params.uri uniquely identifies the document. - connection.console.log(`${params.textDocument.uri} closed.`); -}); -*/ - -// Listen on the connection -connection.listen(); diff --git a/languageprovider-sample/server/src/thenable.d.ts b/languageprovider-sample/server/src/thenable.d.ts deleted file mode 100644 index 997629c5..00000000 --- a/languageprovider-sample/server/src/thenable.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -// We need this until the LSP node libraries are on TS 2.x as well. -interface Thenable extends PromiseLike {} \ No newline at end of file diff --git a/languageprovider-sample/server/tsconfig.json b/languageprovider-sample/server/tsconfig.json deleted file mode 100644 index 8256b1fc..00000000 --- a/languageprovider-sample/server/tsconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module": "commonjs", - "outDir": "./out", - "sourceMap": true, - "lib": [ - "es5", - "es2015.promise" - ] - } -}