How to use the vscode-languageserver-types.DiagnosticSeverity.Error function in vscode-languageserver-types

To help you get started, we’ve selected a few vscode-languageserver-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eclipse-theia / theia / packages / markers / src / browser / problem / problem-tabbar-decorator.ts View on Github external
if (Navigatable.is(widget)) {
            const resourceUri = widget.getResourceUri();
            if (resourceUri) {
                // Get the list of problem markers for the given resource URI.
                const markers: Marker[] = this.problemManager.findMarkers({ uri: resourceUri });
                // If no markers are available, return early.
                if (markers.length === 0) {
                    return [];
                }
                // Store the marker with the highest severity.
                let maxSeverity: Marker | undefined;
                // Iterate over available markers to determine that which has the highest severity.
                // Only display a decoration if an error or warning marker is available.
                for (const marker of markers) {
                    // Break early if an error marker is present, since it represents the highest severity.
                    if (marker.data.severity === DiagnosticSeverity.Error) {
                        maxSeverity = marker;
                        break;
                    } else if (marker.data.severity === DiagnosticSeverity.Warning) {
                        maxSeverity = marker;
                    }
                }
                // Decorate the tabbar with the highest marker severity if available.
                return maxSeverity ? [this.toDecorator(maxSeverity)] : [];
            }
        }
        return [];
    }
github facebookarchive / flow-language-server / src / utils / util.js View on Github external
import {Point} from 'simple-text-buffer';

import {DiagnosticSeverity} from 'vscode-languageserver-types';
import invariant from 'assert';
import nullthrows from 'nullthrows';
import URI from 'vscode-uri';

const FlowSeverity = {
  Error: 'Error',
  Warning: 'Warning',
};

const flowSeverityToLSPSeverityMap: {
  [string]: DiagnosticSeverityType,
} = {
  [FlowSeverity.Error]: DiagnosticSeverity.Error,
  [FlowSeverity.Warning]: DiagnosticSeverity.Warning,
};

const FILE_PROTOCOL = 'file://';

export function toURI(filePath: string): URI {
  return URI.file(filePath);
}

export function fileURIToPath(fileUri: string): string {
  if (process.platform !== 'win32') {
    return URI.parse(fileUri).fsPath;
  }

  // On Windows, vscode-uri converts drive paths to lowercase,
  // which Flow doesn't like very much.
github vuejs / vetur / server / src / modes / template / interpolationMode.ts View on Github external
return rawTemplateDiagnostics.filter(templateDiagnosticFilter).map(diag => {
      // syntactic/semantic diagnostic always has start and length
      // so we can safely cast diag to TextSpan
      return {
        range: mapBackRange(templateDoc, diag as ts.TextSpan, templateSourceMap),
        severity: DiagnosticSeverity.Error,
        message: ts.flattenDiagnosticMessageText(diag.messageText, '\n'),
        code: diag.code,
        source: 'Vetur'
      };
    });
  }
github recca0120 / vscode-phpunit / server / src / diagnostic-provider.ts View on Github external
return tests.reduce((diagnosticGroup: Map, test: Test): Map => {
            const diagnostics: Diagnostic[] = diagnosticGroup.get(test.uri) || [];

            if (test.type === Type.PASSED) {
                return diagnosticGroup.set(test.uri, diagnostics);
            }

            const fault: Fault = test.fault;
            const message: string = fault.message || '';
            const details: Detail[] = fault.details || [];

            diagnostics.push({
                severity: test.type === Type.RISKY ? DiagnosticSeverity.Warning : DiagnosticSeverity.Error,
                range: test.range,
                message: message,
                relatedInformation: this.asDiagnosticRelationInformations(details, message),
                source: 'PHPUnit',
            });

            return diagnosticGroup.set(test.uri, diagnostics);
        }, new Map());
    }
github recca0120 / vscode-phpunit / server / src / phpunit / collection.ts View on Github external
private transformToDiagonstic(test: Test): Diagnostic {
        return {
            severity: test.type === Type.RISKY ? DiagnosticSeverity.Warning : DiagnosticSeverity.Error,
            range: test.range,
            message: test.fault ? test.fault.message : '',
            relatedInformation: this.transformToRelatedInformation(test),
            source: 'PHPUnit',
        };
    }
github neoclide / coc-html / server / modes / javascriptMode.ts View on Github external
return syntaxDiagnostics.concat(semanticDiagnostics).map((diag: ts.Diagnostic): Diagnostic => {
				return {
					range: convertRange(currentTextDocument, diag),
					severity: DiagnosticSeverity.Error,
					source: 'js',
					message: ts.flattenDiagnosticMessageText(diag.messageText, '\n')
				};
			});
		},
github microsoft / BotFramework-Composer / Composer / packages / tools / language-servers / language-understanding / src / LUServer.ts View on Github external
e.diagnostics.forEach(diag => {
            const range = Range.create(0, 0, 0, 1);
            const message = diag.Message;
            const severity = DiagnosticSeverity.Error;
            errors.push(Diagnostic.create(range, message, severity));
          });
        }
github threadheap / serverless-ide-vscode / packages / language-server / src / language-service / services / validation.ts View on Github external
error.location.start +
                " " +
                error.location.end +
                " " +
                error.message;
              if (!added[signature]) {
                added[signature] = true;
                var range = {
                  start: textDocument.positionAt(error.location.start),
                  end: textDocument.positionAt(error.location.end)
                };
                diagnostics.push({
                  severity:
                    idx >= currentDoc.errors.length
                      ? DiagnosticSeverity.Warning
                      : DiagnosticSeverity.Error,
                  range: range,
                  message: error.message
                });
              }
            });
        }
github OmarTawfik / github-actions-js / src / util / diagnostics.ts View on Github external
export function severityToString(severity: DiagnosticSeverity | undefined): string {
  switch (severity) {
    case undefined:
    case DiagnosticSeverity.Error:
      return "ERROR";
    case DiagnosticSeverity.Warning:
      return "WARN";
    default:
      throw new Error(`Unexpected severity: '${severity}'.`);
  }
}
github microsoft / BotFramework-Composer / Composer / packages / tools / language-servers / language-generation / src / utils.ts View on Github external
let match: RegExpMatchArray | null;
  const wordDefinition = /[a-zA-Z0-9_/.-]+/g;
  while ((match = wordDefinition.exec(lineText))) {
    const matchIndex = match.index || 0;
    if (matchIndex > pos) {
      return undefined;
    } else if (wordDefinition.lastIndex >= pos) {
      return Range.create(line, matchIndex, line, wordDefinition.lastIndex);
    }
  }

  return undefined;
}

const severityMap = {
  [LGDiagnosticSeverity.Error]: DiagnosticSeverity.Error,
  [LGDiagnosticSeverity.Hint]: DiagnosticSeverity.Hint,
  [LGDiagnosticSeverity.Information]: DiagnosticSeverity.Information,
  [LGDiagnosticSeverity.Warning]: DiagnosticSeverity.Warning,
};

export function convertSeverity(severity: LGDiagnosticSeverity): DiagnosticSeverity {
  return severityMap[severity];
}

export function convertDiagnostics(lgDiags: LGDiagnostic[] = [], document: TextDocument, lineOffset = 0): Diagnostic[] {
  const diagnostics: Diagnostic[] = [];
  lgDiags.forEach(diag => {
    const diagnostic: Diagnostic = {
      severity: convertSeverity(diag.Severity),
      range: Range.create(
        Position.create(diag.Range.Start.Line - 1 - lineOffset, diag.Range.Start.Character),