Java Code Examples for org.eclipse.lsp4j.Diagnostic#setRange()
The following examples show how to use
org.eclipse.lsp4j.Diagnostic#setRange() .
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: BaseDiagnosticsHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
public static List<Diagnostic> toDiagnosticsArray(IOpenable openable, List<IProblem> problems, boolean isDiagnosticTagSupported) { List<Diagnostic> array = new ArrayList<>(problems.size()); for (IProblem problem : problems) { Diagnostic diag = new Diagnostic(); diag.setSource(JavaLanguageServerPlugin.SERVER_SOURCE_ID); diag.setMessage(problem.getMessage()); diag.setCode(Integer.toString(problem.getID())); diag.setSeverity(convertSeverity(problem)); diag.setRange(convertRange(openable, problem)); if (isDiagnosticTagSupported) { diag.setTags(getDiagnosticTag(problem.getID())); } array.add(diag); } return array; }
Example 2
Source File: WorkspaceDiagnosticsHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
private static Diagnostic toDiagnostic(Range range, IMarker marker, boolean isDiagnosticTagSupported) { if (marker == null || !marker.exists()) { return null; } Diagnostic d = new Diagnostic(); d.setSource(JavaLanguageServerPlugin.SERVER_SOURCE_ID); String message = marker.getAttribute(IMarker.MESSAGE, ""); if (Messages.ProjectConfigurationUpdateRequired.equals(message)) { message = PROJECT_CONFIGURATION_IS_NOT_UP_TO_DATE_WITH_POM_XML; } d.setMessage(message); d.setSeverity(convertSeverity(marker.getAttribute(IMarker.SEVERITY, -1))); int problemId = marker.getAttribute(IJavaModelMarker.ID, 0); d.setCode(String.valueOf(problemId)); if (isDiagnosticTagSupported) { d.setTags(DiagnosticsHandler.getDiagnosticTag(problemId)); } d.setRange(range); return d; }
Example 3
Source File: WorkspaceDiagnosticsHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
private static Diagnostic toDiagnostic(IDocument document, IMarker marker, boolean isDiagnosticTagSupported) { if (marker == null || !marker.exists()) { return null; } Diagnostic d = new Diagnostic(); d.setSource(JavaLanguageServerPlugin.SERVER_SOURCE_ID); d.setMessage(marker.getAttribute(IMarker.MESSAGE, "")); int problemId = marker.getAttribute(IJavaModelMarker.ID, 0); d.setCode(String.valueOf(problemId)); d.setSeverity(convertSeverity(marker.getAttribute(IMarker.SEVERITY, -1))); d.setRange(convertRange(document, marker)); if (isDiagnosticTagSupported) { d.setTags(DiagnosticsHandler.getDiagnosticTag(problemId)); } return d; }
Example 4
Source File: JavaDiagnosticsContext.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
public Diagnostic createDiagnostic(String uri, String message, Range range, String source, IJavaErrorCode code) { Diagnostic diagnostic = new Diagnostic(); diagnostic.setSource(source); diagnostic.setMessage(message); diagnostic.setSeverity(DiagnosticSeverity.Warning); diagnostic.setRange(range); if (code != null) { diagnostic.setCode(code.getCode()); } return diagnostic; }
Example 5
Source File: DiagnosticIssueConverter.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** Convert the given issue to a diagnostic. */ public Diagnostic toDiagnostic(LSPIssue issue) { Diagnostic result = new Diagnostic(); result.setCode(issue.getCode()); result.setMessage(Strings.nullToEmpty(issue.getMessage())); result.setSeverity(toSeverity(issue.getSeverity())); Position start = new Position(toZeroBasedInt(issue.getLineNumber()), toZeroBasedInt(issue.getColumn())); Position end = new Position(issue.getLineNumberEnd() - 1, issue.getColumnEnd() - 1); result.setRange(new Range(start, end)); return result; }
Example 6
Source File: CodeActionHandlerTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private Diagnostic getDiagnostic(String code, Range range){ Diagnostic $ = new Diagnostic(); $.setCode(code); $.setRange(range); $.setSeverity(DiagnosticSeverity.Error); $.setMessage("Test Diagnostic"); return $; }
Example 7
Source File: LSPUtils.java From vscode-as3mxml with Apache License 2.0 | 5 votes |
public static Diagnostic createDiagnosticWithoutRange() { Diagnostic diagnostic = new Diagnostic(); Range range = new Range(); range.setStart(new Position()); range.setEnd(new Position()); diagnostic.setRange(range); return diagnostic; }
Example 8
Source File: ActionScriptServices.java From vscode-as3mxml with Apache License 2.0 | 5 votes |
private void addCompilerProblem(ICompilerProblem problem, PublishDiagnosticsParams publish, boolean isConfigFile) { if (!compilerProblemFilter.isAllowed(problem)) { return; } Diagnostic diagnostic = LanguageServerCompilerUtils.getDiagnosticFromCompilerProblem(problem); if(isConfigFile) { //clear the range because it isn't relevant diagnostic.setRange(new Range(new Position(0, 0), new Position(0, 0))); } List<Diagnostic> diagnostics = publish.getDiagnostics(); diagnostics.add(diagnostic); }
Example 9
Source File: LanguageServerImpl.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
/** * Convert the given issue to a diagnostic. */ protected Diagnostic toDiagnostic(Issue issue) { Diagnostic result = new Diagnostic(); result.setCode(issue.getCode()); result.setMessage(issue.getMessage()); result.setSeverity(toDiagnosticSeverity(issue.getSeverity())); // line and column numbers in LSP are 0-based Position start = new Position(Math.max(0, issue.getLineNumber() - 1), Math.max(0, issue.getColumn() - 1)); Position end = new Position(Math.max(0, issue.getLineNumberEnd() - 1), Math.max(0, issue.getColumnEnd() - 1)); result.setRange(new Range(start, end)); return result; }