From 63151eaa766f67ef1474e8bf14d9082f3d29d578 Mon Sep 17 00:00:00 2001 From: Noah Santschi-Cooney Date: Sun, 3 Jun 2018 15:24:36 +0100 Subject: [PATCH] Added config to server --- .vscode/launch.json | 3 - client/server/package-lock.json | 41 ---------- client/server/package.json | 27 ------- client/server/server.js | 113 --------------------------- client/server/server.js.map | 1 - package-lock.json | 132 ++++++++++++++++++++++++++++++++ package.json | 12 +-- server/src/config.ts | 13 ++++ server/src/server.ts | 120 +++++++++++------------------ 9 files changed, 196 insertions(+), 266 deletions(-) delete mode 100644 client/server/package-lock.json delete mode 100644 client/server/package.json delete mode 100644 client/server/server.js delete mode 100644 client/server/server.js.map create mode 100644 package-lock.json create mode 100644 server/src/config.ts diff --git a/.vscode/launch.json b/.vscode/launch.json index 846d7c2..e944143 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,6 +1,5 @@ { "version": "0.2.0", - // List of configurations. Add new configurations or edit existing ones. "configurations": [ { "name": "Launch Client", @@ -10,8 +9,6 @@ "args": [ "--extensionDevelopmentPath=${workspaceRoot}/client" ], - "stopOnEntry": false, - "sourceMaps": true, "outFiles": [ "${workspaceRoot}/client/out/**/*.js" ], diff --git a/client/server/package-lock.json b/client/server/package-lock.json deleted file mode 100644 index 2ba2eb0..0000000 --- a/client/server/package-lock.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "vscode-mc-shader-server", - "version": "0.0.1", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "vscode-jsonrpc": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-3.5.0.tgz", - "integrity": "sha1-hyOdnhZrLXNSJFuKgTWXgEwdY6o=" - }, - "vscode-languageserver": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-3.5.1.tgz", - "integrity": "sha512-RYUKn0DgHTFcS8kS4VaNCjNMaQXYqiXdN9bKrFjXzu5RPKfjIYcoh47oVWwZj4L3R/DPB0Se7HPaDatvYY2XgQ==", - "requires": { - "vscode-languageserver-protocol": "3.5.1", - "vscode-uri": "^1.0.1" - } - }, - "vscode-languageserver-protocol": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.5.1.tgz", - "integrity": "sha512-1fPDIwsAv1difCV+8daOrJEGunClNJWqnUHq/ncWrjhitKWXgGmRCjlwZ3gDUTt54yRcvXz1PXJDaRNvNH6pYA==", - "requires": { - "vscode-jsonrpc": "3.5.0", - "vscode-languageserver-types": "3.5.0" - } - }, - "vscode-languageserver-types": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.5.0.tgz", - "integrity": "sha1-5I15li8LjgLelV4/UkkI4rGcA3Q=" - }, - "vscode-uri": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-1.0.3.tgz", - "integrity": "sha1-Yxvb9xbcyrDmUpGo3CXCMjIIWlI=" - } - } -} diff --git a/client/server/package.json b/client/server/package.json deleted file mode 100644 index 6785c02..0000000 --- a/client/server/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "vscode-mc-shader-server", - "description": "A Visual Studio Code extension for linting/etc Minecraft GLSL Shaders", - "version": "0.0.1", - "author": "Noah Santschi-Cooney (Strum355)", - "license": "MIT", - "engines": { - "node": "*" - }, - "repository": { - "type": "git", - "url": "https://dl.continuum.graphics/nova-group/bedrock-verifier.git" - }, - "devDependencies": { - "@types/node": "^7.0.43", - "tslint": "^5.8.0", - "typescript": "^2.6.1" - }, - "dependencies": { - "vscode-languageserver": "^3.4.2" - }, - "scripts": { - "installServer": "installServerIntoExtension ../client ./package.json ./tsconfig.json", - "compile": "installServerIntoExtension ../client ./package.json ./tsconfig.json && tsc -p .", - "watch": "installServerIntoExtension ../client ./package.json ./tsconfig.json && tsc -w -p ." - } -} diff --git a/client/server/server.js b/client/server/server.js deleted file mode 100644 index 360428b..0000000 --- a/client/server/server.js +++ /dev/null @@ -1,113 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const vscode_languageserver_1 = require("vscode-languageserver"); -// Create a connection for the server. The connection uses Node's IPC as a transport -const connection = vscode_languageserver_1.createConnection(new vscode_languageserver_1.IPCMessageReader(process), new vscode_languageserver_1.IPCMessageWriter(process)); -// Create a simple text document manager. The text document manager -// supports full document sync only -const documents = new vscode_languageserver_1.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 initialize request. The server receives -// in the passed params, the rootPath of the workspace plus the client capabilities. -connection.onInitialize((params) => { - return { - capabilities: { - // Tell the client that the server works in FULL text document sync mode - textDocumentSync: documents.syncKind, - // Tell the client that the server supports code completion - completionProvider: { - resolveProvider: true - } - } - }; -}); -// The content of a text document has changed. This event is emitted -// when the text document is first opened or when its content has changed. -documents.onDidChangeContent((change) => { - validateTextDocument(change.document); -}); -// The settings have changed. It is sent on server activation -// as well. -connection.onDidChangeConfiguration((change) => { - documents.all().forEach(validateTextDocument); -}); -function validateTextDocument(textDocument) { - const diagnostics = []; - const lines = textDocument.getText().split(/\r?\n/g); - for (let i = 0; i < lines.length; i++) { - const line = lines[i]; - const index = line.indexOf('typescript'); - if (index >= 0) { - diagnostics.push({ - severity: vscode_languageserver_1.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 VS Code. - connection.sendDiagnostics({ uri: textDocument.uri, diagnostics }); -} -connection.onDidChangeWatchedFiles((change) => { - // Monitored files have changed in VS Code - connection.console.log('We received a file change event'); -}); -// This handler provides the initial list of the completion items. -connection.onCompletion((textDocumentPosition) => { - // The passed parameter contains the position in the text document in - // which code completion was requested. For this example, we ignore this - // information and always provide the same completion items. - return [ - { - label: 'TypeScript', - kind: vscode_languageserver_1.CompletionItemKind.Text, - data: 1 - }, - { - label: 'JavaScript', - kind: vscode_languageserver_1.CompletionItemKind.Text, - data: 2 - } - ]; -}); -// This handler resolves additional information for the item selected in -// the completion list. -connection.onCompletionResolve((item) => { - 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 was opened in VS Code. - // params.uri uniquely identifies the document. For documents stored 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 has changed in VS Code. - // 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 was closed in VS Code. - // params.uri uniquely identifies the document. - connection.console.log(`${params.textDocument.uri} closed.`); -}); -*/ -// Listen on the connection -connection.listen(); -//# sourceMappingURL=server.js.map \ No newline at end of file diff --git a/client/server/server.js.map b/client/server/server.js.map deleted file mode 100644 index 3ade12a..0000000 --- a/client/server/server.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"server.js","sourceRoot":"","sources":["../../server/src/server.ts"],"names":[],"mappings":";;AAAA,iEAE+B;AAE/B,oFAAoF;AACpF,MAAM,UAAU,GAAgB,wCAAgB,CAAC,IAAI,wCAAgB,CAAC,OAAO,CAAC,EAAE,IAAI,wCAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;AAE/G,mEAAmE;AACnE,mCAAmC;AACnC,MAAM,SAAS,GAAkB,IAAI,qCAAa,EAAE,CAAC;AACrD,0DAA0D;AAC1D,kDAAkD;AAClD,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AAE7B,4FAA4F;AAC5F,oFAAoF;AACpF,UAAU,CAAC,YAAY,CAAC,CAA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AAC"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..19b7095 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,132 @@ +{ + "name": "vscode-mc-shader", + "version": "0.0.1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "ansi-regex": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz", + "integrity": "sha1-DY6UaWej2BQ/k+JOKYUl/BsiNfk=", + "dev": true + }, + "ansi-styles": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-1.1.0.tgz", + "integrity": "sha1-6uy/Zs1waIJ2Cy9GkVgrj1XXp94=", + "dev": true + }, + "chalk": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz", + "integrity": "sha1-Zjs6ZItotV0EaQ1JFnqoN4WPIXQ=", + "dev": true, + "requires": { + "ansi-styles": "^1.1.0", + "escape-string-regexp": "^1.0.0", + "has-ansi": "^0.1.0", + "strip-ansi": "^0.3.0", + "supports-color": "^0.2.0" + }, + "dependencies": { + "supports-color": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-0.2.0.tgz", + "integrity": "sha1-2S3iaU6z9nMjlz1649i1W0wiGQo=", + "dev": true + } + } + }, + "commander": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.6.0.tgz", + "integrity": "sha1-nfflL7Kgyw+4kFjugMMQQiXzfh0=", + "dev": true + }, + "concurrently": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-3.5.1.tgz", + "integrity": "sha512-689HrwGw8Rbk1xtV9C4dY6TPJAvIYZbRbnKSAtfJ7tHqICFGoZ0PCWYjxfmerRyxBG0o3sbG3pe7N8vqPwIHuQ==", + "dev": true, + "requires": { + "chalk": "0.5.1", + "commander": "2.6.0", + "date-fns": "^1.23.0", + "lodash": "^4.5.1", + "rx": "2.3.24", + "spawn-command": "^0.0.2-1", + "supports-color": "^3.2.3", + "tree-kill": "^1.1.0" + } + }, + "date-fns": { + "version": "1.29.0", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-1.29.0.tgz", + "integrity": "sha512-lbTXWZ6M20cWH8N9S6afb0SBm6tMk+uUg6z3MqHPKE9atmsY3kJkTm8vKe93izJ2B2+q5MV990sM2CHgtAZaOw==", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "has-ansi": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-0.1.0.tgz", + "integrity": "sha1-hPJlqujA5qiKEtcCKJS3VoiUxi4=", + "dev": true, + "requires": { + "ansi-regex": "^0.2.0" + } + }, + "has-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", + "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", + "dev": true + }, + "lodash": { + "version": "4.17.10", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", + "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", + "dev": true + }, + "rx": { + "version": "2.3.24", + "resolved": "https://registry.npmjs.org/rx/-/rx-2.3.24.tgz", + "integrity": "sha1-FPlQpCF9fjXapxu8vljv9o6ksrc=", + "dev": true + }, + "spawn-command": { + "version": "0.0.2-1", + "resolved": "https://registry.npmjs.org/spawn-command/-/spawn-command-0.0.2-1.tgz", + "integrity": "sha1-YvXpRmmBwbeW3Fkpk34RycaSG9A=", + "dev": true + }, + "strip-ansi": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.3.0.tgz", + "integrity": "sha1-JfSOoiynkYfzF0pNuHWTR7sSYiA=", + "dev": true, + "requires": { + "ansi-regex": "^0.2.1" + } + }, + "supports-color": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", + "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", + "dev": true, + "requires": { + "has-flag": "^1.0.0" + } + }, + "tree-kill": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.0.tgz", + "integrity": "sha512-DlX6dR0lOIRDFxI0mjL9IYg6OTncLm/Zt+JiBhE5OlFcAR8yc9S7FFXU9so0oda47frdM/JFsk7UjNt9vscKcg==", + "dev": true + } + } +} diff --git a/package.json b/package.json index 65bf366..0808cdb 100644 --- a/package.json +++ b/package.json @@ -10,17 +10,19 @@ "url": "https://github.com/Strum355/vscode-mc-shader" }, "scripts": { - "postinstall": "cd server && npm install && cd ../client && npm install && cd ..", - "compile": "tsc -p client/tsconfig.json && cd server && npm run installServer && cd .. && tsc -p server/tsconfig.json", - "compile:client": "tsc -p client/tsconfig.json", - "watch:client": "tsc -w -p client/tsconfig.json", - "compile:server": "cd server && npm run installServer && cd .. && tsc -p server/tsconfig.json", + "postinstall": "cd server && npm install && cd ../client && npm install && cd ..", + "compile": "tsc -p client/tsconfig.json && cd server && npm run installServer && cd .. && tsc -p server/tsconfig.json", + "run": "concurrently \"npm run watch:client\" \"npm run watch:server\"", + "compile:client": "tsc -p client/tsconfig.json", + "watch:client": "tsc -w -p client/tsconfig.json", + "compile:server": "cd server && npm run installServer && cd .. && tsc -p server/tsconfig.json", "watch:server": "cd server && npm run installServer && cd .. && tsc -w -p server/tsconfig.json", "lint": "cd server && npm run lint && cd ../client && npm run lint" }, "devDependencies": { "@types/mocha": "^2.2.42", "@types/node": "^7.0.43", + "concurrently": "^3.5.1", "tslint": "^5.8.0", "typescript": "^2.6.1" } diff --git a/server/src/config.ts b/server/src/config.ts new file mode 100644 index 0000000..95aac18 --- /dev/null +++ b/server/src/config.ts @@ -0,0 +1,13 @@ +export class Config { + public readonly minecraftPath: string + public readonly glslangPath: string + + constructor(mcPath: string, glslangPath: string) { + this.minecraftPath = mcPath + this.glslangPath = glslangPath + } + + public onChange(c: Config) { + Object.assign(this, c) + } +} \ No newline at end of file diff --git a/server/src/server.ts b/server/src/server.ts index 7a0b5c7..9d1fbcc 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -1,59 +1,61 @@ -import { IPCMessageReader, IPCMessageWriter, createConnection, IConnection, - TextDocuments, TextDocument, Diagnostic, DiagnosticSeverity, InitializeResult, TextDocumentPositionParams, CompletionItem, CompletionItemKind -} from 'vscode-languageserver'; +import * as vsclang from 'vscode-languageserver' +import { Config } from './config' -// Create a connection for the server. The connection uses Node's IPC as a transport -const connection: IConnection = createConnection(new IPCMessageReader(process), new IPCMessageWriter(process)); +const connection = vsclang.createConnection(new vsclang.IPCMessageReader(process), new vsclang.IPCMessageWriter(process)); + +const documents = new vsclang.TextDocuments(); -// Create a simple text document manager. The text document manager -// supports full document sync only -const 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 initialize request. The server receives -// in the passed params, the rootPath of the workspace plus the client capabilities. -connection.onInitialize((params): InitializeResult => { +const conf = new Config('', '') + +connection.onInitialize((params): vsclang.InitializeResult => { return { capabilities: { - // Tell the client that the server works in FULL text document sync mode - textDocumentSync: documents.syncKind, - // Tell the client that the server supports code completion + textDocumentSync: vsclang.TextDocumentSyncKind.Incremental, completionProvider: { resolveProvider: true - } + }, } }; }); -// The content of a text document has changed. This event is emitted -// when the text document is first opened or when its content has changed. documents.onDidChangeContent((change) => { validateTextDocument(change.document); }); -// The settings have changed. It is sent on server activation -// as well. connection.onDidChangeConfiguration((change) => { + conf.onChange(change.settings as Config) documents.all().forEach(validateTextDocument); }); -function validateTextDocument(textDocument: TextDocument): void { - const diagnostics: Diagnostic[] = []; +connection.onDidChangeTextDocument((param) => { + console.log(param.contentChanges) +}) + +connection.onDidOpenTextDocument((param) => { + console.log(param) +}) + +connection.onDidCloseTextDocument((param) => { + console.log(param) +}) + +function validateTextDocument(textDocument: vsclang.TextDocument) { + const diagnostics: vsclang.Diagnostic[] = []; const lines = textDocument.getText().split(/\r?\n/g); for (let i = 0; i < lines.length; i++) { const line = lines[i]; const index = line.indexOf('typescript'); if (index >= 0) { diagnostics.push({ - severity: DiagnosticSeverity.Warning, + severity: vsclang.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' + message: `blah blah Todd Howard`, + source: 'mcglsl' }); } } @@ -61,62 +63,28 @@ function validateTextDocument(textDocument: TextDocument): void { connection.sendDiagnostics({ uri: textDocument.uri, diagnostics }); } -connection.onDidChangeWatchedFiles((change) => { - // Monitored files have changed in VS Code - connection.console.log('We received a file change event'); -}); - -// This handler provides the initial list of the completion items. -connection.onCompletion((textDocumentPosition: TextDocumentPositionParams): CompletionItem[] => { - // The passed parameter contains the position in the text document in - // which code completion was requested. For this example, we ignore this - // information and always provide the same completion items. +connection.onCompletion((textDocumentPosition: vsclang.TextDocumentPositionParams): vsclang.CompletionItem[] => { return [ { - label: 'TypeScript', - kind: CompletionItemKind.Text, + label: 'heldItemId', + kind: vsclang.CompletionItemKind.Variable, + data: 0, + },{ + label: 'hot', + kind: vsclang.CompletionItemKind.Property, data: 1 - }, - { - label: 'JavaScript', - kind: CompletionItemKind.Text, - data: 2 - } - ]; + }]; }); -// This handler resolves 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' +connection.onCompletionResolve((item: vsclang.CompletionItem): vsclang.CompletionItem => { + if (item.data === 0) { + item.documentation = 'blyat man' + item.detail = 'Held item ID (main hand)' + } else if (item.data === 1) { + item.documentation = 'random' + item.detail = 'something' } - return item; + return item }); -/* -connection.onDidOpenTextDocument((params) => { - // A text document was opened in VS Code. - // params.uri uniquely identifies the document. For documents stored 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 has changed in VS Code. - // 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 was closed in VS Code. - // params.uri uniquely identifies the document. - connection.console.log(`${params.textDocument.uri} closed.`); -}); -*/ - -// Listen on the connection connection.listen(); \ No newline at end of file