Code clean-up for lsp-multi-server example

This commit is contained in:
Dirk Baeumer
2018-10-26 11:23:38 +02:00
parent 5f5ae92db2
commit 8193d8a7ae
12 changed files with 358 additions and 414 deletions

View File

@ -1,36 +1,9 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "compile",
"dependsOn": [
{
"type": "npm",
"script": "compile:client"
},
{
"type": "npm",
"script": "compile:server"
}
],
"problemMatcher": []
},
{
"type": "npm",
"script": "compile:client",
"group": "build",
"presentation": {
"panel": "dedicated",
"reveal": "never"
},
"problemMatcher": [
"$tsc"
]
},
{
"type": "npm",
"script": "compile:server",
"script": "compile",
"group": "build",
"presentation": {
"panel": "dedicated",
@ -41,41 +14,13 @@
]
},
{
"label": "watch",
"dependsOn": [
{
"type": "npm",
"script": "watch:client"
},
{
"type": "npm",
"script": "watch:server"
}
],
"type": "npm",
"script": "watch",
"isBackground": true,
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"type": "npm",
"script": "watch:client",
"isBackground": true,
"group": "build",
"presentation": {
"panel": "dedicated",
"reveal": "never"
},
"problemMatcher": [
"$tsc-watch"
]
},
{
"type": "npm",
"script": "watch:server",
"isBackground": true,
"group": "build",
"presentation": {
"panel": "dedicated",
"reveal": "never"

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,7 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
import * as path from 'path';
import {
workspace as Workspace, window as Window, ExtensionContext, TextDocument, OutputChannel, WorkspaceFolder, Uri
@ -10,10 +14,10 @@ import {
let defaultClient: LanguageClient;
let clients: Map<string, LanguageClient> = new Map();
let _sortedWorkspaceFolders: string[];
let _sortedWorkspaceFolders: string[] | undefined;
function sortedWorkspaceFolders(): string[] {
if (_sortedWorkspaceFolders === void 0) {
_sortedWorkspaceFolders = Workspace.workspaceFolders.map(folder => {
_sortedWorkspaceFolders = Workspace.workspaceFolders ? Workspace.workspaceFolders.map(folder => {
let result = folder.uri.toString();
if (result.charAt(result.length - 1) !== '/') {
result = result + '/';
@ -23,7 +27,7 @@ function sortedWorkspaceFolders(): string[] {
(a, b) => {
return a.length - b.length;
}
);
) : [];
}
return _sortedWorkspaceFolders;
}
@ -37,7 +41,7 @@ function getOuterMostWorkspaceFolder(folder: WorkspaceFolder): WorkspaceFolder {
uri = uri + '/';
}
if (uri.startsWith(element)) {
return Workspace.getWorkspaceFolder(Uri.parse(element));
return Workspace.getWorkspaceFolder(Uri.parse(element))!;
}
}
return folder;

View File

@ -1,5 +1,5 @@
{
"extends": "../tsconfig.base.json",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"target": "es6",

View File

@ -17,9 +17,9 @@
"dev": true
},
"typescript": {
"version": "2.8.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-2.8.3.tgz",
"integrity": "sha512-K7g15Bb6Ra4lKf7Iq2l/I5/En+hLIHmxWZGq3D4DIRNFxMNV6j2SHSvDOqs2tGd4UvD/fJvrwopzQXjLrT7Itw==",
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.1.3.tgz",
"integrity": "sha512-+81MUSyX+BaSo+u2RbozuQk/UWx6hfG0a5gHu4ANEM4sU96XbuIyAB+rWBW1u70c6a5QuZfuYICn3s2UjuHUpA==",
"dev": true
}
}

View File

@ -53,16 +53,13 @@
},
"scripts": {
"vscode:prepublish": "cd client && npm run update-vscode && cd .. && npm run compile",
"compile:client": "tsc -p ./client/tsconfig.json",
"compile:server": "tsc -p ./server/tsconfig.json",
"watch:client": "tsc -w -p ./client/tsconfig.json",
"watch:server": "tsc -w -p ./server/tsconfig.json",
"compile": "npm run compile:client && npm run compile:server",
"compile": "tsc -b",
"watch": "tsc -b -w",
"postinstall": "cd client && npm install && cd ../server && npm install && cd .."
},
"devDependencies": {
"@types/mocha": "^5.2.0",
"@types/node": "^8.0.0",
"typescript": "2.8.3"
"typescript": "^3.1.3"
}
}

View File

@ -14,8 +14,8 @@
"resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-4.1.3.tgz",
"integrity": "sha512-D6p3q9x8QPtPLRUO5d2UKizjFYfg8zLVJqKoMpAaom8Wuhl1oKRCjeLg+Cp4mgPeCwR71wbgX2BM/jL51ni/0g==",
"requires": {
"vscode-languageserver-protocol": "^3.7.2",
"vscode-uri": "^1.0.1"
"vscode-languageserver-protocol": "3.7.2",
"vscode-uri": "1.0.3"
}
},
"vscode-languageserver-protocol": {
@ -23,8 +23,8 @@
"resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.7.2.tgz",
"integrity": "sha512-VVJwIA/FPl/FnVtrns0FPK6TLi/ET7n1Yo6tCrm6aG7+yAVwIGWdpTmKE+nbP8wEMMbHCkIabk63IJvfz2HNRg==",
"requires": {
"vscode-jsonrpc": "^3.6.2",
"vscode-languageserver-types": "^3.7.2"
"vscode-jsonrpc": "3.6.2",
"vscode-languageserver-types": "3.7.2"
}
},
"vscode-languageserver-types": {

View File

@ -1,7 +1,7 @@
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/
'use strict';
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
import {
createConnection, TextDocuments, ProposedFeatures, TextDocumentSyncKind
@ -14,7 +14,7 @@ let connection = createConnection(ProposedFeatures.all);
let documents = new TextDocuments();
// The workspace folder this server is operating on
let workspaceFolder: string;
let workspaceFolder: string | null;
documents.onDidOpen((event) => {
connection.console.log(`[Server(${process.pid}) ${workspaceFolder}] Document opened: ${event.document.uri}`);

View File

@ -1,15 +0,0 @@
{
"compilerOptions": {
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"module": "commonjs",
"moduleResolution": "node",
"target": "es6",
"lib": ["es6"],
"sourceMap": true,
"outDir": "../../client/server"
},
"exclude": ["node_modules"]
}

View File

@ -1,5 +1,5 @@
{
"extends": "../tsconfig.base.json",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"target": "es6",

View File

@ -1,8 +0,0 @@
{
"compilerOptions": {
"noImplicitAny": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true
}
}

View File

@ -0,0 +1,21 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"outDir": "out",
"rootDir": "src",
"lib": [ "es6" ],
"sourceMap": true
},
"include": [
"src"
],
"exclude": [
"node_modules"
],
"references": [
{ "path": "./client" },
{ "path": "./server" }
]
}