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

TypeScript vscode-languageserver.IConnection类代码示例

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

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



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

示例1: constructor

  constructor(
      protected connection: IConnection,
      private converter: AnalyzerLSPConverter,
      private featureFinder: FeatureFinder, private analyzer: LsAnalyzer,
      private capabilities: ClientCapabilities) {
    super();

    this.clientSupportsSnippets =
        !!(this.capabilities.textDocument &&
           this.capabilities.textDocument.completion &&
           this.capabilities.textDocument.completion.completionItem &&
           this.capabilities.textDocument.completion.completionItem
               .snippetSupport);

    // Work around https://github.com/atom/atom-languageclient/issues/150
    const ourExperimentalCapabilities = this.capabilities.experimental &&
        this.capabilities.experimental['polymer-ide'];
    this.clientCannotFilter = ourExperimentalCapabilities ?
        !!ourExperimentalCapabilities.doesNotFilterCompletions :
        false;

    this.connection.onCompletion(async(request) => {
      const result = await this.handleErrors(
          this.autoComplete(request), {isIncomplete: true, items: []});
      return result;
    });
  }
开发者ID:asdfg9822,项目名称:polymer-editor-service,代码行数:27,代码来源:auto-completer.ts


示例2:

    .then((refractOutput) => {

      refractDocuments.set(textDocument.uri.toString(), refractOutput);
      const annotations = lodash.filterContent(refractOutput, { element: 'annotation' });

      const utf8Text = utf16to8(text);
      const documentLines = utf8Text.split(/\r?\n/g);

      lodash.forEach(annotations, (annotation) => {

        const lineReference = refractUtils.createLineReferenceFromSourceMap(
          annotation.attributes.sourceMap,
          text,
          documentLines,
        );

        diagnostics.push({
          code: annotation.attributes.code,
          message: annotation.content,
          range: Range.create(
            lineReference.startRow,
            lineReference.startIndex,
            lineReference.endRow,
            lineReference.endIndex,
          ),
          severity: ((lodash.head(annotation.meta.classes) === 'warning')
            ? DiagnosticSeverity.Warning : DiagnosticSeverity.Error),
          source: 'fury',
        } as Diagnostic);

      });

      connection.sendDiagnostics({ uri: textDocument.uri, diagnostics });
    });
开发者ID:XVincentX,项目名称:vscode-apielements,代码行数:34,代码来源:server.ts


示例3: validateTextDocument

function validateTextDocument(textDocument: ITextDocument): void {
	let linterBinPath = path.join(__dirname, '../../server/glualint');
	connection.console.log("lel");
	connection.console.log(linterBinPath);
	
	let stdout = childProcess.execFileSync(linterBinPath, ['stdin'], {input: textDocument.getText()});
	
	let diagnostics: Diagnostic[] = [];

	let lines = stdout.toString().split('\n');	
	for (let i = 0; i < lines.length; i++) {
		let m = errorRegex.exec(lines[i]);
		
		if (m != null) {
			var severity = DiagnosticSeverity.Error;
			if (m[1] == 'Warning') {
				severity = DiagnosticSeverity.Warning;
			}
			
			diagnostics.push({
				severity: severity,
				range: {
					start: { line: parseInt(m[2]) - 1, character: parseInt(m[3]) - 1},
					end: { line: parseInt(m[2]) - 1, character: parseInt(m[3]) - 1 + 3 }
				},
				message: m[4],
				source: 'glualint'
			});
		}
	}
	
	// Send the computed diagnostics to VSCode.
	connection.sendDiagnostics({ uri: textDocument.uri, diagnostics });
}
开发者ID:wyozi-gmod,项目名称:vscode-gluaserver,代码行数:34,代码来源:server.ts


示例4: getLanguageModes

connection.onInitialize((params: InitializeParams): InitializeResult => {
	let initializationOptions = params.initializationOptions;

	workspacePath = params.rootPath;

	languageModes = getLanguageModes(initializationOptions ? initializationOptions.embeddedLanguages : { css: true, javascript: true });
	documents.onDidClose(e => {
		languageModes.getAllModes().forEach(m => m.onDocumentRemoved(e.document));
	});
	connection.onShutdown(() => {
		languageModes.getAllModes().forEach(m => m.dispose());
	});

	return {
		capabilities: {
			// Tell the client that the server works in FULL text document sync mode
			textDocumentSync: documents.syncKind,
			completionProvider: { resolveProvider: true, triggerCharacters: ['.', ':', '<', '"', '=', '/'] },
			hoverProvider: true,
			documentHighlightProvider: true,
			documentRangeFormattingProvider: initializationOptions && initializationOptions['format.enable'],
			documentLinkProvider: true,
			definitionProvider: true,
			signatureHelpProvider: { triggerCharacters: ['('] },
			referencesProvider: true
		}
	};
});
开发者ID:,项目名称:,代码行数:28,代码来源:


示例5:

documents.onDidChangeContent((change) => {
    let diagnostics: Diagnostic[] = [];
    let input = change.document.getText();
    
    try{
        let output = toml.parse(input);
    }catch(e){
        // workaround for typescript limitation
        const ex : TomlSyntaxError = e;

        // content has invalid toml, send diagnostic to client

        // toml parser give position in one based, but languageserver used zero based
        // so we must convert it before send the position
        const startPosition = {line: ex.line - 1, character: ex.column};
        const endPosition = {line: ex.line - 1, character: ex.column + 1};

        diagnostics.push({
            severity: DiagnosticSeverity.Error,
            range: {
                start: startPosition,
                end: endPosition
            },
            message: ex.message,
            source: 'Toml Parser'
        });
    }

    // Send the computed diagnostics to VS Code.
    connection.sendDiagnostics({
        uri: change.document.uri,
        diagnostics
    });      

});
开发者ID:digitaltoad,项目名称:dotfiles,代码行数:35,代码来源:tomlServerMain.ts


示例6: getWorkspaceUri

 const server = await new Promise<LanguageServer>((resolve, reject) => {
   connection.onInitialize(async(params): Promise<InitializeResult> => {
     // Normalize across the two ways that the workspace may be
     // communicated to us.
     const workspaceUri = getWorkspaceUri(params.rootUri, params.rootPath);
     if (!workspaceUri || workspaceUri.scheme !== 'file') {
       const error = new Error(
           `Got invalid workspaceUri from client: ` +
           `${util.inspect(workspaceUri)}`);
       reject(error);
       throw error;
     }
     const {urlResolver} =
         await ProjectConfig.initializeAnalyzerFromDirectory(
             workspaceUri.fsPath);
     const newServer = new LanguageServer(
         connection,
         workspaceUri,
         params.capabilities,
         urlResolver,
         loggingOptions.logToFile);
     resolve(newServer);
     return {capabilities: newServer.capabilities(params.capabilities)};
   });
 });
开发者ID:Polymer,项目名称:tools,代码行数:25,代码来源:language-server.ts


示例7: callback

 readFile(path: string, callback: (err: Error, result? : string) => void) {
     this.connection.sendRequest(ReadFileRequest.type, path).then((content: string) => {
         return callback(null, Buffer.from(content, 'base64').toString())
     }, (err: Error) => {
         return callback(err)
     })        
 }
开发者ID:antonina-cherednichenko,项目名称:poc-jslang-server,代码行数:7,代码来源:fs.ts


示例8: validateTextDocument

function validateTextDocument(textDocument: TextDocument): void {
	let diagnostics: Diagnostic[] = [];
	languageModes.getAllModesInDocument(textDocument).forEach(mode => {
		if (mode.doValidation && validation[mode.getId()]) {
			pushAll(diagnostics, mode.doValidation(textDocument));
		}
	});
	connection.sendDiagnostics({ uri: textDocument.uri, diagnostics });
}
开发者ID:fs814,项目名称:vscode,代码行数:9,代码来源:htmlServerMain.ts


示例9: validateTextDocument

function validateTextDocument(textDocument: TextDocument): void {
	let diagnostics: Diagnostic[] = [];
	languageModes.getAllModesInDocument(textDocument).forEach(mode => {
		if (mode.doValidation) {
			diagnostics = diagnostics.concat(mode.doValidation(textDocument));
		}
	});
	connection.sendDiagnostics({ uri: textDocument.uri, diagnostics });
}
开发者ID:,项目名称:,代码行数:9,代码来源:



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript vscode-languageserver.ITextDocument类代码示例发布时间:2022-05-25
下一篇:
TypeScript vscode-languageserver.Files类代码示例发布时间: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