• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript vscode-languageserver.createConnection函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中vscode-languageserver.createConnection函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createConnection函数的具体用法?TypeScript createConnection怎么用?TypeScript createConnection使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了createConnection函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: constructor

    /**
     * Simply construct with default values, we expect things to be properly setup when the client
     * callbacks start happening.
     */
    constructor()
    {
        this.connection = lsp.createConnection(lsp.ProposedFeatures.all),
        this.capabilities =
            {
                hasWorkspaces: false,
                hasConfiguration: false,
                hasHierarchicalDocumentSymbol: false
            };

        this.profile = new Profile(this);
    }
开发者ID:legatoproject,项目名称:legato-af,代码行数:16,代码来源:lspClient.ts


示例2: createConnection

 * Licensed under the MIT License. See License.txt in the project root for license information.
 * ------------------------------------------------------------------------------------------ */
'use strict';

import {
    IPCMessageReader, IPCMessageWriter,
	createConnection, IConnection,
	TextDocuments, TextDocument, Diagnostic, DiagnosticSeverity, 
	InitializeParams, InitializeResult
} from 'vscode-languageserver';

import * as toml from 'toml';
import {TomlSyntaxError} from 'toml';

// 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 initialize request. The server receives
// in the passed params the rootPath of the workspace plus the client capabilities. 
let workspaceRoot: string;
connection.onInitialize((params): InitializeResult => {
	workspaceRoot = params.rootPath;
	return {
		capabilities: {
开发者ID:digitaltoad,项目名称:dotfiles,代码行数:31,代码来源:tomlServerMain.ts


示例3: RequestType

import { format } from './modes/formatting';
import { pushAll } from './utils/arrays';

import * as url from 'url';
import * as path from 'path';
import uri from 'vscode-uri';

import * as nls from 'vscode-nls';
nls.config(process.env['VSCODE_NLS_CONFIG']);

namespace TagCloseRequest {
	export const type: RequestType<TextDocumentPositionParams, string, any, any> = new RequestType('html/tag');
}

// Create a connection for the server
let connection: IConnection = createConnection();

console.log = connection.console.log.bind(connection.console);
console.error = connection.console.error.bind(connection.console);

// 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);

let workspacePath: string;
var languageModes: LanguageModes;

let clientSnippetSupport = false;
开发者ID:armanio123,项目名称:vscode,代码行数:31,代码来源:htmlServerMain.ts


示例4: createConnection

/*---------------------------------------------------------
 * Copyright (C) Microsoft Corporation. All rights reserved.
 *--------------------------------------------------------*/
'use strict';

import {
	createConnection, TextDocuments, ProposedFeatures, TextDocumentSyncKind
} from 'vscode-languageserver';

// Creates the LSP connection
let connection = createConnection(ProposedFeatures.all);

// Create a manager for open text documents
let documents = new TextDocuments();

// The workspace folder this server is operating on
let workspaceFolder: string;

documents.onDidOpen((event) => {
	connection.console.log(`[Server(${process.pid}) ${workspaceFolder}] Document opened: ${event.document.uri}`);
})
documents.listen(connection);

connection.onInitialize((params) => {
	workspaceFolder = params.rootUri;
	connection.console.log(`[Server(${process.pid}) ${workspaceFolder}] Started and initialize received`);
	return {
		capabilities: {
			textDocumentSync: {
				openClose: true,
				change: TextDocumentSyncKind.None
开发者ID:voodoos,项目名称:vscode-extension-samples,代码行数:31,代码来源:server.ts


示例5: createConnection

import {
  createConnection,
  InitializeParams,
  InitializeResult,
  TextDocumentSyncKind
} from 'vscode-languageserver';
import { VLS } from './services/vls';

// Create a connection for the server
const connection =
  process.argv.length <= 2
    ? createConnection(process.stdin, process.stdout) // no arg specified
    : createConnection();

console.log = connection.console.log.bind(connection.console);
console.error = connection.console.error.bind(connection.console);

// 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
connection.onInitialize((params: InitializeParams): InitializeResult => {
  const initializationOptions = params.initializationOptions;

  const workspacePath = params.rootPath;
  if (!workspacePath) {
    console.error('No workspace path found. Vetur initialization failed');
    return {
      capabilities: { }
    };
  }

  console.log('Vetur initialized');
开发者ID:tiravata,项目名称:vetur,代码行数:31,代码来源:vueServerMain.ts


示例6: required

		},
		"socket": {
			type: "number",
			description: "Use socket",
			require: false,
		},
		"pipe": {
			type: "string",
			description: "Use pipe",
			require: false,
		}
	})
	.help()
	.argv as any as Args;

const setArgs = [argv.stdio, argv.socket, argv.nodeIpc, argv.pipe];

if (setArgs.every(a => !a)) {
	console.error("Connection type required (stdio, node-ipc, socket, pipe). Refer to --help for more details.");
	process.exit(1);
}

if (setArgs.filter(a => !!a).length !== 1) {
	console.error("You can only set exaclty one connection type (stdio, node-ipc, socket, pipe). Refer to --help for more details.");
	process.exit(1);
}

// We only use yargs for partial validation an providing help. the lsp.createConnection() handles the CLI params internally
const connection = lsp.createConnection();
runServer(connection);
开发者ID:nikeee,项目名称:dot-language-server,代码行数:30,代码来源:cli.ts


示例7: run

function run() {
    // debounce buffer
    const validationRequestStream = new Rx.ReplaySubject<TextDocument>(1);
    const validationFinishedStream = new Rx.ReplaySubject<{ uri: string; version: number }>(1);
    const triggerUpdateConfig = new Rx.ReplaySubject<void>(1);
    const triggerValidateAll = new Rx.ReplaySubject<void>(1);

    // 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));
    g_connection = connection;
    log('Start');

    // Create a simple text document manager. The text document manager
    // supports full document sync only
    const documents: TextDocuments = new TextDocuments();

    // 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.
    let workspaceRoot: string | undefined;
    connection.onInitialize((params: InitializeParams, token: CancellationToken): InitializeResult => {
        workspaceRoot = params.rootPath || undefined;
        return {
            capabilities: {
                // Tell the client that the server works in FULL text document sync mode
                textDocumentSync: documents.syncKind,
                codeActionProvider: true
            }
        };
    });

    // The settings have changed. Is sent on server activation as well.
    connection.onDidChangeConfiguration(onConfigChange);

    interface OnChangeParam { settings: Settings; }
    function onConfigChange(change: OnChangeParam) {
        log('onConfigChange');
        Object.assign(vscodeSettings, change.settings || {});
        log(`Enabled: ${vscodeSettings.cSpell && vscodeSettings.cSpell.enabled ? 'True' : 'False'}`);
        triggerUpdateConfig.next(undefined);
    }

    function updateActiveSettings() {
        log('updateActiveSettings');
        CSpell.clearCachedSettings();
        const configPaths = workspaceRoot ? [
            path.join(workspaceRoot, '.vscode', CSpell.defaultSettingsFilename.toLowerCase()),
            path.join(workspaceRoot, '.vscode', CSpell.defaultSettingsFilename),
            path.join(workspaceRoot, CSpell.defaultSettingsFilename.toLowerCase()),
            path.join(workspaceRoot, CSpell.defaultSettingsFilename),
        ] : [];
        const cSpellSettingsFile = CSpell.readSettingsFiles(configPaths);
        const { cSpell = {}, search = {} } = vscodeSettings;
        const { exclude = {} } = search;
        const importPaths = [...configsToImport.keys()].sort();
        const importSettings = CSpell.readSettingsFiles(importPaths);
        const mergedSettings = CSpell.mergeSettings(defaultSettings, importSettings, cSpellSettingsFile, cSpell);
        const { ignorePaths = []} = mergedSettings;
        const globs = defaultExclude.concat(ignorePaths, extractGlobsFromExcludeFilesGlobMap(exclude));
        fnFileExclusionTest = generateExclusionFunctionForUri(globs, workspaceRoot || '');
        Object.assign(activeSettings, mergedSettings);
        activeSettingsNeedUpdating = false;

        triggerValidateAll.next(undefined);
    }

    function getActiveSettings() {
        if (activeSettingsNeedUpdating) {
            updateActiveSettings();
        }
        return activeSettings;
    }

    function registerConfigurationFile(path: string) {
        configsToImport.add(path);
        log(`Load: ${path}`);
        triggerUpdateConfig.next(undefined);
    }

    interface TextDocumentInfo {
        uri?: string;
        languageId?: string;
    }

    // Listen for event messages from the client.
    connection.onNotification('applySettings', onConfigChange);
    connection.onNotification('registerConfigurationFile', registerConfigurationFile);

    connection.onRequest('isSpellCheckEnabled', (params: TextDocumentInfo) => {
        const { uri, languageId } = params;
        return {
            languageEnabled: languageId ? isLanguageEnabled(languageId) : undefined,
            fileEnabled: uri ? !isUriExcluded(uri) : undefined,
        };
    });

    connection.onRequest('getConfigurationForDocument', (params: TextDocumentInfo) => {
        const { uri, languageId } = params;
        const doc = uri && documents.get(uri);
        const docSettings = doc && getSettingsToUseForDocument(doc);
        const settings = activeSettings;
//.........这里部分代码省略.........
开发者ID:AlekSi,项目名称:vscode-spell-checker,代码行数:101,代码来源:server.ts


示例8: Map

import { ADTClient, createSSLConfig } from "abap-adt-api"
import { createConnection, ProposedFeatures } from "vscode-languageserver"
import { isString, isError } from "util"
import { readConfiguration } from "./clientapis"
const clients: Map<string, ADTClient> = new Map()

export const connection = createConnection(ProposedFeatures.all)
export const log = (...params: any) => {
  let msg = ""
  for (const x of params) {
    try {
      if (isError(x)) msg += `\nError ${x.name}\n${x.message}\n\n${x.stack}\n`
      else msg += isString(x) ? x : JSON.stringify(x)
    } catch (e) {
      msg += x.toString()
    }
    msg += " "
  }
  connection.console.log(msg)
}
export function clientKeyFromUrl(url: string) {
  const match = url.match(/adt:\/\/([^\/]*)/)
  return match && match[1]
}
export async function clientFromKey(key: string) {
  let client = clients.get(key)
  if (!client) {
    const conf = await readConfiguration(key)
    if (conf) {
      const sslconf = conf.url.match(/https:/i)
        ? createSSLConfig(conf.allowSelfSigned, conf.customCA)
开发者ID:valdirmendesgt,项目名称:vscode_abap_remote_fs,代码行数:31,代码来源:clientManager.ts


示例9: run

function run() {
    // debounce buffer
    const validationRequestStream = new ReplaySubject<TextDocument>(1);
    const triggerUpdateConfig = new ReplaySubject<void>(1);
    const triggerValidateAll = new ReplaySubject<void>(1);
    const validationByDoc = new Map<string, Subscription>();
    let isValidationBusy = false;

    // Create a connection for the server. The connection uses Node's IPC as a transport
    log('Create Connection');
    const connection = createConnection(vscode.ProposedFeatures.all);

    const documentSettings = new DocumentSettings(connection, defaultSettings);

    // Create a simple text document manager. The text document manager
    // supports full document sync only
    const documents: TextDocuments = new TextDocuments();

    connection.onInitialize((params: InitializeParams, token: CancellationToken): InitializeResult => {
        // Hook up the logger to the connection.
        log('onInitialize');
        setWorkspaceBase(params.rootUri ? params.rootUri : '');
        return {
            capabilities: {
                // Tell the client that the server works in FULL text document sync mode
                textDocumentSync: documents.syncKind,
                codeActionProvider: true
            }
        };
    });

    // The settings have changed. Is sent on server activation as well.
    connection.onDidChangeConfiguration(onConfigChange);

    interface OnChangeParam { settings: SettingsCspell; }
    function onConfigChange(change: OnChangeParam) {
        logInfo('Configuration Change');
        triggerUpdateConfig.next(undefined);
        updateLogLevel();
    }

    function updateActiveSettings() {
        log('updateActiveSettings');
        documentSettings.resetSettings();
        triggerValidateAll.next(undefined);
    }

    function getActiveSettings(doc: TextDocumentUri) {
        return getActiveUriSettings(doc.uri);
    }

    function getActiveUriSettings(uri?: string) {
        return documentSettings.getUriSettings(uri);
    }

    function registerConfigurationFile(path: string) {
        documentSettings.registerConfigurationFile(path);
        logInfo('Register Configuration File', path);
        triggerUpdateConfig.next(undefined);
    }

    interface TextDocumentInfo {
        uri?: string;
        languageId?: string;
        text?: string;
    }

    // Listen for event messages from the client.
    connection.onNotification(notifyMethodNames.onConfigChange, onConfigChange);
    connection.onNotification(notifyMethodNames.registerConfigurationFile, registerConfigurationFile);

    connection.onRequest(methodNames.isSpellCheckEnabled, async (params: TextDocumentInfo): Promise<Api.IsSpellCheckEnabledResult> => {
        const { uri, languageId } = params;
        const fileEnabled = uri ? !await isUriExcluded(uri) : undefined;
        const settings = await getActiveUriSettings(uri);
        return {
            languageEnabled: languageId && uri ? await isLanguageEnabled({ uri, languageId }, settings) : undefined,
            fileEnabled,
        };
    });

    connection.onRequest(methodNames.getConfigurationForDocument, async (params: TextDocumentInfo): Promise<Api.GetConfigurationForDocumentResult> => {
        const { uri, languageId } = params;
        const doc = uri && documents.get(uri);
        const docSettings = doc && await getSettingsToUseForDocument(doc) || undefined;
        const settings = await getActiveUriSettings(uri);
        return {
            languageEnabled: languageId && doc ? await isLanguageEnabled(doc, settings) : undefined,
            fileEnabled: uri ? !await isUriExcluded(uri) : undefined,
            settings,
            docSettings,
        };
    });

    function textToWords(text: string): string[] {
        const setOfWords = new Set(
            Text.extractWordsFromCode(text)
                .map(t => t.text)
                .map(t => t.toLowerCase())
            );
//.........这里部分代码省略.........
开发者ID:Jason-Rev,项目名称:vscode-spell-checker,代码行数:101,代码来源:server.ts


示例10: constructor

    constructor(input: any, output: any, strict: boolean) {

        this.connection = createConnection(input, output);

        input.removeAllListeners('end');
        input.removeAllListeners('close');
        output.removeAllListeners('end');
        output.removeAllListeners('close');

        let workspaceRoot: string;

        let documents: TextDocuments = new TextDocuments();

        let closed = false;

        function close() {
            if (!closed) {
                input.close();
                output.close();
                closed = true;
            }
        }

        let service: TypeScriptService;

        let self = this;

        let initialized: Thenable<void> = null;

        this.connection.onRequest(InitializeRequest.type, (params: InitializeParams): Promise<InitializeResult> => {
            console.error('initialize', params.rootPath);
            return new Promise<InitializeResult>(function (resolve) {
                if (params.rootPath) {
                    workspaceRoot = util.uri2path(params.rootPath);
                    service = new TypeScriptService(workspaceRoot, strict, self.connection);
                    initialized = service.host.initialize(workspaceRoot);
                    resolve({
                        capabilities: {
                            // Tell the client that the server works in FULL text document sync mode
                            textDocumentSync: documents.syncKind,
                            hoverProvider: true,
                            definitionProvider: true,
                            referencesProvider: true
                        }
                    })
                }
            });
        });

        this.connection.onNotification(ExitRequest.type, function () {
            close();
        });

        this.connection.onRequest(ShutdownRequest.type, function () {
            return [];
        });

        this.connection.onDidOpenTextDocument((params: DidOpenTextDocumentParams) => {
            let relpath = util.uri2relpath(params.textDocument.uri, workspaceRoot);
            console.error('add file', workspaceRoot, '/', relpath);
            service.addFile(relpath, params.textDocument.text);
        });

        this.connection.onDidCloseTextDocument((params: DidCloseTextDocumentParams) => {
            let relpath = util.uri2relpath(params.textDocument.uri, workspaceRoot);
            console.error('remove file', workspaceRoot, '/', relpath);
            service.removeFile(relpath);
        });

        this.connection.onRequest(WorkspaceSymbolsRequest.type, (params: WorkspaceSymbolParamsWithLimit): Promise<SymbolInformation[]> => {
            const enter = new Date().getTime();
            return new Promise<SymbolInformation[]>(function (resolve, reject) {
                initialized.then(function () {
                    let result = [];
                    const init = new Date().getTime();
                    try {
                        if (params.query == "exported") {
                            const exported = service.getExportedEnts();
                            if (exported) {
                                result = exported.map(ent => {
                                    return SymbolInformation.create(ent.name, ent.kind, ent.location.range,
                                        'file:///' + ent.location.file, util.formExternalUri(ent));
                                });
                            }
                        } else if (params.query == "externals") {
                            const externals = service.getExternalRefs();
                            if (externals) {
                                result = externals.map(external => {
                                    return SymbolInformation.create(external.name, util.formEmptyKind(), util.formEmptyRange(), util.formExternalUri(external));
                                });
                            }
                        } else if (params.query == '') {
                            const topDecls = service.getTopLevelDeclarations(params.limit);
                            if (topDecls) {
                                result = topDecls.map(decl => {
                                    return SymbolInformation.create(decl.name, decl.kind, decl.location.range,
                                        'file:///' + decl.location.file, util.formExternalUri(decl));
                                });
                            }
                        } else {
//.........这里部分代码省略.........
开发者ID:antonina-cherednichenko,项目名称:poc-jslang-server,代码行数:101,代码来源:connection.ts



注:本文中的vscode-languageserver.createConnection函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript vscode-languageserver.CompletionItem类代码示例发布时间:2022-05-25
下一篇:
TypeScript vscode.languages类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap