当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript IConnection.sendDiagnostics方法代码示例

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

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

示例1: 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


示例2:

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


示例3: utf16to8

    .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


示例4: 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,代码来源:


示例5: 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


示例6: validateTextDocument

async function validateTextDocument(textDocument: TextDocument) {
	let diagnostics: Diagnostic[] = [];
	if (textDocument.languageId === 'html') {
		let modes = languageModes.getAllModesInDocument(textDocument);
		let settings = await getDocumentSettings(textDocument, () => modes.some(m => !!m.doValidation));
		modes.forEach(mode => {
			if (mode.doValidation && isValidationEnabled(mode.getId(), settings)) {
				pushAll(diagnostics, mode.doValidation(textDocument, settings));
			}
		});
	}
	connection.sendDiagnostics({ uri: textDocument.uri, diagnostics });
}
开发者ID:armanio123,项目名称:vscode,代码行数:13,代码来源:htmlServerMain.ts


示例7: validateTextDocument

function validateTextDocument(textDocument: TextDocument): void {
  let diagnostics: Diagnostic[] = [];
  let text = textDocument.getText();

  let refractOutput = undefined;

  try {
    refractOutput = parser.parse(text, currentSettings.parser);
  } catch(err) {
    refractOutput = err.result;
  } finally {

    refractDocuments.set(textDocument.uri.toString(), refractOutput);
    let 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
      );

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

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


示例8: catch

documents.onDidChangeContent((change) => {
    let diagnostics: Diagnostic[] = [];
    
    try {
        let result = pegjs.buildParser(change.document.getText());
    } catch(error)
    {
        let err : pegjs.PegjsError = error;
        diagnostics.push({
            severity: DiagnosticSeverity.Error,
            range: pegjsLoc_to_vscodeRange(err.location),
            message: error.name + ": " + error.message
        });
    }
    
    // Send the computed diagnostics to VS Code.
    connection.sendDiagnostics({ uri: change.document.uri, diagnostics });
});
开发者ID:ebugusey,项目名称:code-pegjs-language,代码行数:18,代码来源:server.ts


示例9: validateTextDocument

function validateTextDocument(textDocument: ITextDocument): void {
	let diagnostics: Diagnostic[] = [];
	let lines = textDocument.getText().split(/\r?\n/g);
	let problems = 0;
	for (var i = 0; i < lines.length && problems < maxNumberOfProblems; i++) {
		let line = lines[i];
		let index = line.indexOf('typescript');
		if (index >= 0) {
			problems++;
			diagnostics.push({
				severity: DiagnosticSeverity.Warning,
				range: {
					start: { line: i, character: index},
					end: { line: i, character: index + 10 }
				},
				message: `${line.substr(index, 10)} should be spelled TypeScript`
			});
		}
	}
	// Send the computed diagnostics to VSCode.
	connection.sendDiagnostics({ uri: textDocument.uri, diagnostics });
}
开发者ID:babakness,项目名称:vscode-pgsql,代码行数:22,代码来源:server.ts


示例10: validate

function validate(document) {
	const content = document.getText();
	const uri = document.uri;
	const url = Files.uriToFilePath(uri);

	if (Object.keys(editorSettings.config).length === 0) {
		// Update settings from a configuration file only if their updates
		if (configWatcherStatus) {
			linterSettings = configResolver.load(null, path.dirname(url));
			configWatcherStatus = false;
		}
	} else {
		linterSettings = editorSettings.config;
	}

	if (!linterSettings) {
		linterSettings = {};
	}

	// ---> Maybe there's another way?
	const extendPath = linterSettings.extends;
	if (extendPath && path.basename(extendPath) === extendPath) {
		linterSettings.extends = `./node_modules/pug-lint-config-${linterSettings.extends}/index.js`;
	}
	// <---

	linter.configure(linterSettings);

	const diagnostics = [];
	const report = linter.checkString(content, url);
	if (report.length > 0) {
		report.forEach((problem) => {
			diagnostics.push(makeDiagnostic(problem));
		});
	}

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



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