vscode#DiagnosticRelatedInformation TypeScript Examples

The following examples show how to use vscode#DiagnosticRelatedInformation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: lexValidation.ts    From yash with MIT License 6 votes vote down vote up
export function doLEXValidation(document: TextDocument, lexDocument: LexDocument): Diagnostic[] {
    const diags: Diagnostic[] = [];
    lexDocument.problems.forEach(problem => {
        const range = new Range(document.positionAt(problem.offset), document.positionAt(problem.end));
        let severity: DiagnosticSeverity = DiagnosticSeverity.Information;
        switch (problem.type) {
            case ProblemType.Error:
                severity = DiagnosticSeverity.Error;
                break;
            case ProblemType.Information:
                severity = DiagnosticSeverity.Information;
                break;
            case ProblemType.Warning:
                severity = DiagnosticSeverity.Warning;
                break;
        }
        const diag = new Diagnostic(range, problem.message, severity);
        if (problem.related) {
            diag.relatedInformation = [new DiagnosticRelatedInformation(
                new Location(document.uri, new Range(document.positionAt(problem.related.offset), document.positionAt(problem.related.end))),
                problem.related.message
            )];
        }
        diags.push(diag);
    });
    return diags;
}
Example #2
Source File: yaccValidation.ts    From yash with MIT License 6 votes vote down vote up
export function doYACCValidation(document: TextDocument, yaccDocument: YACCDocument): Diagnostic[] {
    const diags: Diagnostic[] = [];
    yaccDocument.problems.forEach(problem => {
        const range = new Range(document.positionAt(problem.offset), document.positionAt(problem.end));
        let severity: DiagnosticSeverity = DiagnosticSeverity.Information;
        switch (problem.type) {
            case ProblemType.Error:
                severity = DiagnosticSeverity.Error;
                break;
            case ProblemType.Information:
                severity = DiagnosticSeverity.Information;
                break;
            case ProblemType.Warning:
                severity = DiagnosticSeverity.Warning;
                break;
        }
        const diag = new Diagnostic(range, problem.message, severity);
        if (problem.related) {
            diag.relatedInformation = [new DiagnosticRelatedInformation(
                new Location(document.uri, new Range(document.positionAt(problem.related.offset), document.positionAt(problem.related.end))),
                problem.related.message
            )];
        }
        diags.push(diag);
    });
    return diags;
}