Java 类org.eclipse.lsp4j.DiagnosticSeverity 实例源码

项目:vscode-javac    文件:Lints.java   
static Optional<Diagnostic> convert(javax.tools.Diagnostic<? extends JavaFileObject> error) {
    if (error.getStartPosition() != javax.tools.Diagnostic.NOPOS) {
        Range range = position(error);
        Diagnostic diagnostic = new Diagnostic();
        DiagnosticSeverity severity = severity(error.getKind());

        diagnostic.setSeverity(severity);
        diagnostic.setRange(range);
        diagnostic.setCode(error.getCode());
        diagnostic.setMessage(error.getMessage(null));

        return Optional.of(diagnostic);
    } else {
        LOG.warning("Skipped " + error.getMessage(Locale.getDefault()));

        return Optional.empty();
    }
}
项目:SOMns-vscode    文件:SomLint.java   
private static void checkFileNameMatchesModule(final MixinDefinition def,
    final String fileName,
    final List<Diagnostic> diagnostics) {
  String moduleName = fileName;
  if (moduleName.contains(".")) {
    moduleName = moduleName.substring(0, moduleName.indexOf("."));
  }

  if (!moduleName.equals(def.getName().getString())) {

    diagnostics.add(new Diagnostic(
        toRange(def.getNameSourceSection()),
        "Module name '" + def.getName().getString() + "' does not match file name '"
            + fileName
            + "'.",
        DiagnosticSeverity.Information, LINT_NAME));
  }
}
项目:eclipse.jdt.ls    文件:WorkspaceDiagnosticsHandlerTest.java   
@Test
public void testMavenMarkers() throws Exception {
    String msg1 = "Some dependency is missing";
    IMarker m1 = createMavenMarker(IMarker.SEVERITY_ERROR, msg1, 2, 95, 100);

    IDocument d = mock(IDocument.class);
    when(d.getLineOffset(1)).thenReturn(90);

    List<Diagnostic> diags = handler.toDiagnosticsArray(d, new IMarker[]{m1, null});
    assertEquals(1, diags.size());

    Range r;
    Diagnostic d1 = diags.get(0);
    assertEquals(msg1, d1.getMessage());
    assertEquals(DiagnosticSeverity.Error, d1.getSeverity());
    r = d1.getRange();
    assertEquals(1, r.getStart().getLine());
    assertEquals(95, r.getStart().getCharacter());
    assertEquals(1, r.getEnd().getLine());
    assertEquals(100, r.getEnd().getCharacter());
}
项目:vscode-javac    文件:Lints.java   
private static DiagnosticSeverity severity(javax.tools.Diagnostic.Kind kind) {
    switch (kind) {
        case ERROR:
            return DiagnosticSeverity.Error;
        case WARNING:
        case MANDATORY_WARNING:
            return DiagnosticSeverity.Warning;
        case NOTE:
        case OTHER:
        default:
            return DiagnosticSeverity.Information;
    }
}
项目:SOMns-vscode    文件:SomLint.java   
public static void checkSends(final Map<String, SomStructures> structuralProbes,
    final SomStructures newProbe, final List<Diagnostic> diagnostics) {
  Collection<SomStructures> probes;
  synchronized (structuralProbes) {
    probes = new ArrayList<>(structuralProbes.values());
  }

  List<Call> calls = newProbe.getCalls();
  for (Call c : calls) {
    if (newProbe.defines(c.selector)) {
      continue;
    }

    boolean defined = false;
    for (SomStructures p : probes) {
      if (p.defines(c.selector)) {
        defined = true;
        break;
      }
    }

    if (!defined) {
      Range r = new Range(pos(c.sections[0].getStartLine(), c.sections[0].getStartColumn()),
          pos(c.sections[c.sections.length - 1].getEndLine(),
              c.sections[c.sections.length - 1].getEndColumn() + 1));
      diagnostics.add(new Diagnostic(r,
          "No " + c.selector.getString() + " defined. Might cause run time error.",
          DiagnosticSeverity.Warning, LINT_NAME));
    }
  }
}
项目:SOMns-vscode    文件:SomAdapter.java   
private List<Diagnostic> toDiagnostics(final ParseError e,
    final List<Diagnostic> diagnostics) {
  Diagnostic d = new Diagnostic();
  d.setSeverity(DiagnosticSeverity.Error);

  SourceCoordinate coord = e.getSourceCoordinate();
  d.setRange(toRangeMax(coord));
  d.setMessage(e.getMessage());
  d.setSource("Parser");

  diagnostics.add(d);
  return diagnostics;
}
项目:SOMns-vscode    文件:SomAdapter.java   
private List<Diagnostic> toDiagnostics(final SemanticDefinitionError e,
    final List<Diagnostic> diagnostics) {
  SourceSection source = e.getSourceSection();

  Diagnostic d = new Diagnostic();
  d.setSeverity(DiagnosticSeverity.Error);
  d.setRange(toRange(source));
  d.setMessage(e.getMessage());
  d.setSource("Parser");

  diagnostics.add(d);
  return diagnostics;
}
项目:SOMns-vscode    文件:SomAdapter.java   
private List<Diagnostic> toDiagnostics(final String msg,
    final List<Diagnostic> diagnostics) {
  Diagnostic d = new Diagnostic();
  d.setSeverity(DiagnosticSeverity.Error);

  d.setMessage(msg);
  d.setSource("Parser");

  diagnostics.add(d);
  return diagnostics;
}
项目:eclipse.jdt.ls    文件:DiagnosticsHandler.java   
private static DiagnosticSeverity convertSeverity(IProblem problem) {
    if(problem.isError()) {
        return DiagnosticSeverity.Error;
    }
    if(problem.isWarning()) {
        return DiagnosticSeverity.Warning;
    }
    return DiagnosticSeverity.Information;
}
项目:eclipse.jdt.ls    文件:WorkspaceDiagnosticsHandler.java   
/**
 * @param attribute
 * @return
 */
private static DiagnosticSeverity convertSeverity(int severity) {
    if (severity == IMarker.SEVERITY_ERROR) {
        return DiagnosticSeverity.Error;
    }
    if (severity == IMarker.SEVERITY_WARNING) {
        return DiagnosticSeverity.Warning;
    }
    return DiagnosticSeverity.Information;
}
项目:eclipse.jdt.ls    文件:CodeActionHandler.java   
private IProblemLocation[] getProblemLocations(ICompilationUnit unit, List<Diagnostic> diagnostics) {
    IProblemLocation[] locations = new IProblemLocation[diagnostics.size()];
    for (int i = 0; i < diagnostics.size(); i++) {
        Diagnostic diagnostic = diagnostics.get(i);
        int problemId = getProblemId(diagnostic);
        int start = DiagnosticsHelper.getStartOffset(unit, diagnostic.getRange());
        int end = DiagnosticsHelper.getEndOffset(unit, diagnostic.getRange());
        boolean isError = diagnostic.getSeverity() == DiagnosticSeverity.Error;
        locations[i] = new ProblemLocation(start, end - start, problemId, isError);
    }
    return locations;
}
项目:eclipse.jdt.ls    文件:CodeActionHandlerTest.java   
private Diagnostic getDiagnostic(String code, Range range){
    Diagnostic $ = new Diagnostic();
    $.setCode(code);
    $.setRange(range);
    $.setSeverity(DiagnosticSeverity.Error);
    $.setMessage("Test Diagnostic");
    return $;
}
项目:che    文件:DiagnosticAnnotation.java   
public DiagnosticAnnotation(Diagnostic diagnostic) {

    this.diagnostic = diagnostic;

    DiagnosticSeverity severity = diagnostic.getSeverity();
    if (severity == null) {
      layer = ERROR_LAYER;
      setType(ERROR_ANNOTATION_TYPE);
    } else {
      switch (severity) {
        case Error:
          layer = ERROR_LAYER;
          setType(ERROR_ANNOTATION_TYPE);
          break;
        case Warning:
          layer = WARNING_LAYER;
          setType(WARNING_ANNOTATION_TYPE);
          break;
        case Information:
          layer = INFO_LAYER;
          setType(INFO_ANNOTATION_TYPE);
          break;
        case Hint:
          layer = HINT_LAYER;
          setType(HINT_ANNOTATION_TYPE);
          break;
        default:
          layer = ERROR_LAYER;
          setType(ERROR_ANNOTATION_TYPE);
          break;
      }
    }
  }
项目:che    文件:PomReconciler.java   
private static Diagnostic convertProblem(Map<Integer, Position> positionMap, Problem problem) {
  Diagnostic result = new Diagnostic();
  Position start = positionMap.get(problem.getSourceStart());
  Position end = positionMap.get(problem.getSourceEnd());
  if (start == null || end == null) {
    LOG.error("Could not map problem range: " + problem);
    return null;
  }
  result.setRange(new Range(start, end));
  result.setMessage(problem.getMessage());
  result.setSeverity(problem.isError() ? DiagnosticSeverity.Error : DiagnosticSeverity.Warning);
  return result;
}
项目:SOMns-vscode    文件:Diagnostic.java   
public Diagnostic(@NonNull final Range range, @NonNull final String message, final DiagnosticSeverity severity, final String source) {
  this(range, message);
  this.severity = severity;
  this.source = source;
}
项目:SOMns-vscode    文件:Diagnostic.java   
public Diagnostic(@NonNull final Range range, @NonNull final String message, final DiagnosticSeverity severity, final String source, final String code) {
  this(range, message, severity, source);
  this.code = code;
}
项目:SOMns-vscode    文件:Diagnostic.java   
/**
 * The diagnostic's severity. Can be omitted. If omitted it is up to the client to interpret diagnostics as error,
 * warning, info or hint.
 */
@Pure
public DiagnosticSeverity getSeverity() {
  return this.severity;
}
项目:SOMns-vscode    文件:SomLint.java   
private static void checkFileEnding(final String name, final List<Diagnostic> diagnostics) {
  if (!name.endsWith(SomAdapter.FILE_ENDING)) {
    diagnostics.add(new Diagnostic(new Range(pos(1, 1), pos(1, 1)),
        "File name does not use the .ns extension.", DiagnosticSeverity.Hint, LINT_NAME));
  }
}
项目:eclipse.jdt.ls    文件:WorkspaceDiagnosticsHandlerTest.java   
@Test
public void testToDiagnosticsArray() throws Exception {
    String msg1 = "Something's wrong Jim";
    IMarker m1 = createMarker(IMarker.SEVERITY_WARNING, msg1, 2, 95, 100);

    String msg2 = "He's dead";
    IMarker m2 = createMarker(IMarker.SEVERITY_ERROR, msg2, 10, 1015, 1025);

    String msg3 = "It's probably time to panic";
    IMarker m3 = createMarker(42, msg3, 100, 10000, 10005);

    IDocument d = mock(IDocument.class);
    when(d.getLineOffset(1)).thenReturn(90);
    when(d.getLineOffset(9)).thenReturn(1000);
    when(d.getLineOffset(99)).thenReturn(10000);

    List<Diagnostic> diags = handler.toDiagnosticsArray(d, new IMarker[]{m1, m2, m3});
    assertEquals(3, diags.size());

    Range r;
    Diagnostic d1 = diags.get(0);
    assertEquals(msg1, d1.getMessage());
    assertEquals(DiagnosticSeverity.Warning, d1.getSeverity());
    r = d1.getRange();
    assertEquals(1, r.getStart().getLine());
    assertEquals(5, r.getStart().getCharacter());
    assertEquals(1, r.getEnd().getLine());
    assertEquals(10, r.getEnd().getCharacter());

    Diagnostic d2 = diags.get(1);
    assertEquals(msg2, d2.getMessage());
    assertEquals(DiagnosticSeverity.Error, d2.getSeverity());
    r = d2.getRange();
    assertEquals(9, r.getStart().getLine());
    assertEquals(15, r.getStart().getCharacter());
    assertEquals(9, r.getEnd().getLine());
    assertEquals(25, r.getEnd().getCharacter());

    Diagnostic d3 = diags.get(2);
    assertEquals(msg3, d3.getMessage());
    assertEquals(DiagnosticSeverity.Information, d3.getSeverity());
    r = d3.getRange();
    assertEquals(99, r.getStart().getLine());
    assertEquals(0, r.getStart().getCharacter());
    assertEquals(99, r.getEnd().getLine());
    assertEquals(5, r.getEnd().getCharacter());

}
项目:xtext-core    文件:LanguageServerImpl.java   
private Diagnostic toDiagnostic(final Issue issue) {
  Diagnostic _diagnostic = new Diagnostic();
  final Procedure1<Diagnostic> _function = (Diagnostic it) -> {
    it.setCode(issue.getCode());
    DiagnosticSeverity _switchResult = null;
    Severity _severity = issue.getSeverity();
    if (_severity != null) {
      switch (_severity) {
        case ERROR:
          _switchResult = DiagnosticSeverity.Error;
          break;
        case WARNING:
          _switchResult = DiagnosticSeverity.Warning;
          break;
        case INFO:
          _switchResult = DiagnosticSeverity.Information;
          break;
        default:
          _switchResult = DiagnosticSeverity.Hint;
          break;
      }
    } else {
      _switchResult = DiagnosticSeverity.Hint;
    }
    it.setSeverity(_switchResult);
    it.setMessage(issue.getMessage());
    Integer _elvis = null;
    Integer _lineNumber = issue.getLineNumber();
    if (_lineNumber != null) {
      _elvis = _lineNumber;
    } else {
      _elvis = Integer.valueOf(1);
    }
    final int lineNumber = ((_elvis).intValue() - 1);
    Integer _elvis_1 = null;
    Integer _column = issue.getColumn();
    if (_column != null) {
      _elvis_1 = _column;
    } else {
      _elvis_1 = Integer.valueOf(1);
    }
    final int column = ((_elvis_1).intValue() - 1);
    Integer _elvis_2 = null;
    Integer _length = issue.getLength();
    if (_length != null) {
      _elvis_2 = _length;
    } else {
      _elvis_2 = Integer.valueOf(0);
    }
    final Integer length = _elvis_2;
    Position _position = new Position(lineNumber, column);
    Position _position_1 = new Position(lineNumber, (column + (length).intValue()));
    Range _range = new Range(_position, _position_1);
    it.setRange(_range);
  };
  return ObjectExtensions.<Diagnostic>operator_doubleArrow(_diagnostic, _function);
}
项目:lsp4j    文件:Diagnostic.java   
public Diagnostic(@NonNull final Range range, @NonNull final String message, final DiagnosticSeverity severity, final String source) {
  this(range, message);
  this.severity = severity;
  this.source = source;
}
项目:lsp4j    文件:Diagnostic.java   
public Diagnostic(@NonNull final Range range, @NonNull final String message, final DiagnosticSeverity severity, final String source, final String code) {
  this(range, message, severity, source);
  this.code = code;
}
项目:lsp4j    文件:Diagnostic.java   
/**
 * The diagnostic's severity. Can be omitted. If omitted it is up to the client to interpret diagnostics as error,
 * warning, info or hint.
 */
@Pure
public DiagnosticSeverity getSeverity() {
  return this.severity;
}
项目:SOMns-vscode    文件:Diagnostic.java   
/**
 * The diagnostic's severity. Can be omitted. If omitted it is up to the client to interpret diagnostics as error,
 * warning, info or hint.
 */
public void setSeverity(final DiagnosticSeverity severity) {
  this.severity = severity;
}
项目:lsp4j    文件:Diagnostic.java   
/**
 * The diagnostic's severity. Can be omitted. If omitted it is up to the client to interpret diagnostics as error,
 * warning, info or hint.
 */
public void setSeverity(final DiagnosticSeverity severity) {
  this.severity = severity;
}