How to use the vscode-languageserver-types.DiagnosticSeverity.Warning 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 facebookarchive / flow-language-server / server / src / utils / util.js View on Github external
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,
};

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

export function hasFlowPragma(content: string) {
  const hasPragma =
    content.startsWith('/* @flow */') ||
    content.startsWith('// @flow\n') ||
    /^\s*\/\*+\s*@flow\s*\*+\//m.test(content) ||
    /^\s*\/\/\s*@flow\s*$/m.test(content);
  return hasPragma;
}

export function flowSeverityToLSPSeverity(
github eclipse-theia / theia / packages / markers / src / browser / problem / problem-tabbar-decorator.ts View on Github external
// 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 chemzqm / wxml-languageserver / src / services / wxmlDiagnostic.ts View on Github external
end: document.positionAt(offset + attr.length)
              },
              severity: DiagnosticSeverity.Error,
              message: `Unknown attribute "${attr}"`
            })
          }
          continue
        }
        if (attr === 'wx:else') {
          if (value) {
            result.push({
              range:{
                start: document.positionAt(offset),
                end: document.positionAt(offset + attr.length)
              },
              severity: DiagnosticSeverity.Warning,
              message: `Unnecessary value for "${attr}"`
            })
          }
          continue
        }
        if (value && isDynamicValue(value)) continue
        let type = allowedAttrs[attr].type
        switch (type) {
          case 'logic':
          case 'iterate':
          case 'event':
          case 'function':
            if (!value) {
              result.push({
                range:{
                  start: document.positionAt(offset),
github microsoft / BotFramework-Composer / Composer / packages / tools / language-servers / lg / server / src / lg-server.ts View on Github external
protected convertSeverity(severity: lg.DiagnosticSeverity): DiagnosticSeverity {
    switch (severity) {
      case lg.DiagnosticSeverity.Error:
        return DiagnosticSeverity.Error;
      case lg.DiagnosticSeverity.Hint:
        return DiagnosticSeverity.Hint;
      case lg.DiagnosticSeverity.Information:
        return DiagnosticSeverity.Information;
      case lg.DiagnosticSeverity.Warning:
        return DiagnosticSeverity.Warning;
    }
  }
github microsoft / BotFramework-Composer / Composer / packages / tools / language-servers / language-generation / src / utils.ts View on Github external
export function convertSeverity(severity: lg.DiagnosticSeverity): DiagnosticSeverity {
  switch (severity) {
    case lg.DiagnosticSeverity.Error:
      return DiagnosticSeverity.Error;
    case lg.DiagnosticSeverity.Hint:
      return DiagnosticSeverity.Hint;
    case lg.DiagnosticSeverity.Information:
      return DiagnosticSeverity.Information;
    case lg.DiagnosticSeverity.Warning:
      return DiagnosticSeverity.Warning;
  }
}
github sourcegraph / sourcegraph-typescript / extension / src / lsp-conversion.ts View on Github external
uri: new sourcegraph.URI(location.uri),
    range: convertRange(location.range),
})

export function convertLocations(locationOrLocations: Location | Location[] | null): sourcegraph.Location[] | null {
    if (!locationOrLocations) {
        return null
    }
    const locations = Array.isArray(locationOrLocations) ? locationOrLocations : [locationOrLocations]
    return locations.map(convertLocation)
}

const DIAGNOSTIC_COLORS: Readonly> = {
    [DiagnosticSeverity.Error]: 'var(--danger, #dc3545)',
    [DiagnosticSeverity.Information]: 'var(--info, #17a2b8)',
    [DiagnosticSeverity.Warning]: 'var(--success, #ffc107)',
    [DiagnosticSeverity.Hint]: 'var(--secondary, #6c757d)',
}
export const convertDiagnosticToDecoration = (diagnostic: Diagnostic): sourcegraph.TextDocumentDecoration => ({
    after: {
        color: DIAGNOSTIC_COLORS[diagnostic.severity || DiagnosticSeverity.Hint],
        contentText: diagnostic.message.replace(/\n/g, ' '),
    },
    range: convertRange(diagnostic.range),
})
github eclipse-theia / theia / packages / task / src / node / task-problem-collector.spec.ts View on Github external
expect(allMatches.length).to.eq(4);

        expect((allMatches[0] as ProblemMatchData).resource!.path).eq('/home/test/test-dir.js');
        expect((allMatches[0] as ProblemMatchData).marker).deep.equal({
            range: { start: { line: 13, character: 20 }, end: { line: 13, character: 20 } },
            severity: DiagnosticSeverity.Warning,
            source: 'test2',
            message: 'Missing semicolon',
            code: 'semi'
        });

        expect((allMatches[1] as ProblemMatchData).resource!.path).eq('/home/test/test-dir.js');
        expect((allMatches[1] as ProblemMatchData).marker).deep.equal({
            range: { start: { line: 14, character: 22 }, end: { line: 14, character: 22 } },
            severity: DiagnosticSeverity.Warning,
            source: 'test2',
            message: 'Missing semicolon',
            code: 'semi'
        });

        expect((allMatches[2] as ProblemMatchData).resource!.path).eq('/home/test/test-dir.js');
        expect((allMatches[2] as ProblemMatchData).marker).deep.equal({
            range: { start: { line: 102, character: 8 }, end: { line: 102, character: 8 } },
            severity: DiagnosticSeverity.Error,
            source: 'test2',
            message: 'Parsing error: Unexpected token inte'
        });

        expect((allMatches[3] as ProblemMatchData).resource!.path).eq('/home/test/more-test.js');
        expect((allMatches[3] as ProblemMatchData).marker).deep.equal({
            range: { start: { line: 12, character: 8 }, end: { line: 12, character: 8 } },
github eclipse-theia / theia / packages / markers / src / browser / problem / problem-decorator.ts View on Github external
protected filterMarker(marker: Marker): boolean {
        const { severity } = marker.data;
        return severity === DiagnosticSeverity.Error
            || severity === DiagnosticSeverity.Warning
            || severity === DiagnosticSeverity.Information;
    }
github codesandbox / codesandbox-client / standalone-packages / vscode-extensions / out / extensions / jpoissonnier.vscode-styled-components-0.0.26 / node_modules / vscode-css-languageservice / lib / esm / services / cssValidation.js View on Github external
function toDiagnostic(marker) {
            var range = Range.create(document.positionAt(marker.getOffset()), document.positionAt(marker.getOffset() + marker.getLength()));
            var source = document.languageId;
            return {
                code: marker.getRule().id,
                source: source,
                message: marker.getMessage(),
                severity: marker.getLevel() === nodes.Level.Warning ? DiagnosticSeverity.Warning : DiagnosticSeverity.Error,
                range: range
            };
        }
        return entries.filter(function (entry) { return entry.getLevel() !== nodes.Level.Ignore; }).map(toDiagnostic);
github eclipse-theia / theia / packages / task / src / node / task-problem-collector.spec.ts View on Github external
'  15:23  warning  Missing semicolon  semi',
            '  103:9  error  Parsing error: Unexpected token inte',
            '',
            '/home/test/more-test.js',
            '  13:9  error  Parsing error: Unexpected token 1000',
            '',
            '✖ 3 problems (1 error, 2 warnings)',
            '  0 errors and 2 warnings potentially fixable with the `--fix` option.'
        ]);

        expect(allMatches.length).to.eq(4);

        expect((allMatches[0] as ProblemMatchData).resource!.path).eq('/home/test/test-dir.js');
        expect((allMatches[0] as ProblemMatchData).marker).deep.equal({
            range: { start: { line: 13, character: 20 }, end: { line: 13, character: 20 } },
            severity: DiagnosticSeverity.Warning,
            source: 'test2',
            message: 'Missing semicolon',
            code: 'semi'
        });

        expect((allMatches[1] as ProblemMatchData).resource!.path).eq('/home/test/test-dir.js');
        expect((allMatches[1] as ProblemMatchData).marker).deep.equal({
            range: { start: { line: 14, character: 22 }, end: { line: 14, character: 22 } },
            severity: DiagnosticSeverity.Warning,
            source: 'test2',
            message: 'Missing semicolon',
            code: 'semi'
        });

        expect((allMatches[2] as ProblemMatchData).resource!.path).eq('/home/test/test-dir.js');
        expect((allMatches[2] as ProblemMatchData).marker).deep.equal({