aboutsummaryrefslogtreecommitdiff
path: root/server/out/server.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/out/server.js')
-rw-r--r--server/out/server.js122
1 files changed, 122 insertions, 0 deletions
diff --git a/server/out/server.js b/server/out/server.js
new file mode 100644
index 0000000..c7db522
--- /dev/null
+++ b/server/out/server.js
@@ -0,0 +1,122 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+/* --------------------------------------------------------------------------------------------
+ * Copyright (c) Microsoft Corporation. All rights reserved.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ * ------------------------------------------------------------------------------------------ */
+const node_1 = require("vscode-languageserver/node");
+const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
+const diagnostics_1 = require("./diagnostics");
+const completion_1 = require("./completion");
+// Create a connection for the server, using Node's IPC as a transport.
+// Also include all preview / proposed LSP features.
+const connection = (0, node_1.createConnection)(node_1.ProposedFeatures.all);
+// Create a simple text document manager.
+const documents = new node_1.TextDocuments(vscode_languageserver_textdocument_1.TextDocument);
+let hasConfigurationCapability = false;
+let hasWorkspaceFolderCapability = false;
+let hasDiagnosticRelatedInformationCapability = false;
+connection.onInitialize((params) => {
+ const capabilities = params.capabilities;
+ // Does the client support the `workspace/configuration` request?
+ // If not, we fall back using global settings.
+ hasConfigurationCapability = !!(capabilities.workspace && !!capabilities.workspace.configuration);
+ hasWorkspaceFolderCapability = !!(capabilities.workspace && !!capabilities.workspace.workspaceFolders);
+ hasDiagnosticRelatedInformationCapability = !!(capabilities.textDocument);
+ const result = {
+ capabilities: {
+ textDocumentSync: node_1.TextDocumentSyncKind.Incremental,
+ // Tell the client that this server supports code completion.
+ completionProvider: {
+ resolveProvider: true
+ }
+ }
+ };
+ if (hasWorkspaceFolderCapability) {
+ result.capabilities.workspace = {
+ workspaceFolders: {
+ supported: true
+ }
+ };
+ }
+ return result;
+});
+connection.onInitialized(() => {
+ if (hasConfigurationCapability) {
+ // Register for all configuration changes.
+ connection.client.register(node_1.DidChangeConfigurationNotification.type, undefined);
+ }
+ if (hasWorkspaceFolderCapability) {
+ connection.workspace.onDidChangeWorkspaceFolders(_event => {
+ connection.console.log('Workspace folder change event received.');
+ });
+ }
+});
+// The global settings, used when the `workspace/configuration` request is not supported by the client.
+// Please note that this is not the case when using this server with the client provided in this example
+// but could happen with other clients.
+const defaultSettings = { maxNumberOfProblems: 1000 };
+let globalSettings = defaultSettings;
+// Cache the settings of all open documents
+const documentSettings = new Map();
+connection.onDidChangeConfiguration(change => {
+ if (hasConfigurationCapability) {
+ // Reset all cached document settings
+ documentSettings.clear();
+ }
+ else {
+ globalSettings = ((change.settings.languageServerExample || defaultSettings));
+ }
+ // Revalidate all open text documents
+ documents.all().forEach(validateTextDocument);
+});
+function getDocumentSettings(resource) {
+ if (!hasConfigurationCapability) {
+ return Promise.resolve(globalSettings);
+ }
+ let result = documentSettings.get(resource);
+ if (!result) {
+ result = connection.workspace.getConfiguration({
+ scopeUri: resource,
+ section: 'wingStudio'
+ });
+ documentSettings.set(resource, result);
+ }
+ return result;
+}
+// Only keep settings for open documents
+documents.onDidClose(e => {
+ documentSettings.delete(e.document.uri);
+});
+// 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);
+});
+let currentDocument;
+async function validateTextDocument(textDocument) {
+ currentDocument = textDocument;
+ // In this simple example we get the settings for every validate run.
+ const settings = await getDocumentSettings(textDocument.uri);
+ // The validator creates diagnostics for all uppercase words length 2 and more
+ const diagnostics = diagnostics_1.default.run(textDocument);
+ // 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 received an file change event');
+});
+// This handler provides the initial list of the completion items.
+connection.onCompletion((_textDocumentPosition) => {
+ return completion_1.default.run(_textDocumentPosition, currentDocument);
+});
+// This handler resolves additional information for the item selected in
+// the completion list.
+connection.onCompletionResolve(completion_1.default.detail);
+// Make the text document manager listen on the connection
+// for open, change and close text document events
+documents.listen(connection);
+// Listen on the connection
+connection.listen();
+//# sourceMappingURL=server.js.map \ No newline at end of file