• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DiagnosticSeverity类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.lsp4j.DiagnosticSeverity的典型用法代码示例。如果您正苦于以下问题:Java DiagnosticSeverity类的具体用法?Java DiagnosticSeverity怎么用?Java DiagnosticSeverity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DiagnosticSeverity类属于org.eclipse.lsp4j包,在下文中一共展示了DiagnosticSeverity类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: convert

import org.eclipse.lsp4j.DiagnosticSeverity; //导入依赖的package包/类
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();
    }
}
 
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:19,代码来源:Lints.java


示例2: checkFileNameMatchesModule

import org.eclipse.lsp4j.DiagnosticSeverity; //导入依赖的package包/类
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));
  }
}
 
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:19,代码来源:SomLint.java


示例3: testMavenMarkers

import org.eclipse.lsp4j.DiagnosticSeverity; //导入依赖的package包/类
@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());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:22,代码来源:WorkspaceDiagnosticsHandlerTest.java


示例4: severity

import org.eclipse.lsp4j.DiagnosticSeverity; //导入依赖的package包/类
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;
    }
}
 
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:14,代码来源:Lints.java


示例5: checkSends

import org.eclipse.lsp4j.DiagnosticSeverity; //导入依赖的package包/类
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));
    }
  }
}
 
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:32,代码来源:SomLint.java


示例6: toDiagnostics

import org.eclipse.lsp4j.DiagnosticSeverity; //导入依赖的package包/类
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;
}
 
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:14,代码来源:SomAdapter.java


示例7: convertSeverity

import org.eclipse.lsp4j.DiagnosticSeverity; //导入依赖的package包/类
private static DiagnosticSeverity convertSeverity(IProblem problem) {
	if(problem.isError()) {
		return DiagnosticSeverity.Error;
	}
	if(problem.isWarning()) {
		return DiagnosticSeverity.Warning;
	}
	return DiagnosticSeverity.Information;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:10,代码来源:DiagnosticsHandler.java


示例8: convertSeverity

import org.eclipse.lsp4j.DiagnosticSeverity; //导入依赖的package包/类
/**
 * @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;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:14,代码来源:WorkspaceDiagnosticsHandler.java


示例9: getProblemLocations

import org.eclipse.lsp4j.DiagnosticSeverity; //导入依赖的package包/类
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;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:13,代码来源:CodeActionHandler.java


示例10: getDiagnostic

import org.eclipse.lsp4j.DiagnosticSeverity; //导入依赖的package包/类
private Diagnostic getDiagnostic(String code, Range range){
	Diagnostic $ = new Diagnostic();
	$.setCode(code);
	$.setRange(range);
	$.setSeverity(DiagnosticSeverity.Error);
	$.setMessage("Test Diagnostic");
	return $;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:9,代码来源:CodeActionHandlerTest.java


示例11: DiagnosticAnnotation

import org.eclipse.lsp4j.DiagnosticSeverity; //导入依赖的package包/类
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;
      }
    }
  }
 
开发者ID:eclipse,项目名称:che,代码行数:34,代码来源:DiagnosticAnnotation.java


示例12: convertProblem

import org.eclipse.lsp4j.DiagnosticSeverity; //导入依赖的package包/类
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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:14,代码来源:PomReconciler.java


示例13: Diagnostic

import org.eclipse.lsp4j.DiagnosticSeverity; //导入依赖的package包/类
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;
}
 
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:6,代码来源:Diagnostic.java


示例14: getSeverity

import org.eclipse.lsp4j.DiagnosticSeverity; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:9,代码来源:Diagnostic.java


示例15: checkFileEnding

import org.eclipse.lsp4j.DiagnosticSeverity; //导入依赖的package包/类
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));
  }
}
 
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:7,代码来源:SomLint.java


示例16: testToDiagnosticsArray

import org.eclipse.lsp4j.DiagnosticSeverity; //导入依赖的package包/类
@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());

}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:49,代码来源:WorkspaceDiagnosticsHandlerTest.java


示例17: toDiagnostic

import org.eclipse.lsp4j.DiagnosticSeverity; //导入依赖的package包/类
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);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:58,代码来源:LanguageServerImpl.java


示例18: setSeverity

import org.eclipse.lsp4j.DiagnosticSeverity; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:8,代码来源:Diagnostic.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java UpgradeCommand类代码示例发布时间:2022-05-23
下一篇:
Java PluralRules类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap