當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript vscode-languageserver.IConnection類代碼示例

本文整理匯總了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;未經允許,請勿轉載。