private Diagnostic createDiagnostic(String message, DiagnosticSeverity severity, String source) { return new Diagnostic(Ranges.UNDEFINED_RANGE, message, severity, source); }
public static List<Diagnostic> toDiagnosticsArray(IOpenable openable, List<IProblem> problems) { 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)); array.add(diag); } return array; }
? "" : message.getMessage(); Diagnostic diag = new Diagnostic( Ranges.UNDEFINED_RANGE, message1, DiagnosticSeverity.Warning, GroovyConstants.GROOVY_COMPILER); diagnosticsByFile.computeIfAbsent(workspaceRoot.toUri(), (ignored) -> Lists.newArrayList()).add(diag); cause.getEndColumn()); uri = Paths.get(cause.getSourceLocator()).toUri(); diagnostic = new Diagnostic( range, cause.getMessage(), DiagnosticSeverity.Error, GroovyConstants.GROOVY_COMPILER); } else { uri = workspaceRoot.toUri(); String message1 = data.toString(); diagnostic = new Diagnostic( Ranges.UNDEFINED_RANGE, message1, DiagnosticSeverity.Error, GroovyConstants.GROOVY_COMPILER);
@Test public void testCompile_withDiagnostics() throws IOException { when(compiler.compile(any())).thenReturn(Sets.newHashSet( new PublishDiagnosticsParams("uri", ImmutableList.of( new Diagnostic(Ranges.UNDEFINED_RANGE, "name", DiagnosticSeverity.Error, "groovyc"))))); wrapper.compile(ImmutableSet.of()); // assert parser wasn't called Mockito.verify(parser, Mockito.never()).parseAllSymbols(); }
Diagnostic diagnostic = new Diagnostic(range, diag.getMessage()); diagnostic.setSeverity(DiagnosticSeverity.Error); clientDiagnostics.add(diagnostic);
@Test public void testCompile_WithJavaExtensionError() throws InterruptedException, ExecutionException, IOException { File test = addFileToFolder(root.getRoot(), "Test.java", "public class Test {" + "Foo foo;" + "}"); GroovyWorkspaceCompiler compiler = createGroovyWorkspaceCompiler(); Set<PublishDiagnosticsParams> diagnostics = compiler.compile(ImmutableSet.of()); assertEquals(Sets.newHashSet(new PublishDiagnosticsParams( test.toPath().toUri().toString(), ImmutableList.of(new Diagnostic(Ranges.createRange(0, 19, 0, 26), "unable to resolve class Foo \n @ line 1, column 20.", DiagnosticSeverity.Error, GroovyConstants.GROOVY_COMPILER)))), diagnostics); }
private static Diagnostic toDiagnostic(Range range, IMarker marker) { 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))); d.setCode(String.valueOf(marker.getAttribute(IJavaModelMarker.ID, 0))); d.setRange(range); return d; }
private static Diagnostic toDiagnostic(IDocument document, IMarker marker) { if (marker == null || !marker.exists()) { return null; } Diagnostic d = new Diagnostic(); d.setSource(JavaLanguageServerPlugin.SERVER_SOURCE_ID); d.setMessage(marker.getAttribute(IMarker.MESSAGE, "")); d.setCode(String.valueOf(marker.getAttribute(IJavaModelMarker.ID, 0))); d.setSeverity(convertSeverity(marker.getAttribute(IMarker.SEVERITY, -1))); d.setRange(convertRange(document, marker)); return d; }
private Diagnostic toDiagnostic(final Issue issue) { Diagnostic _diagnostic = new Diagnostic(); final Procedure1<Diagnostic> _function = (Diagnostic it) -> { it.setCode(issue.getCode());
new PublishDiagnosticsParams(test1.toPath().toUri().toString(), ImmutableList.of( new Diagnostic( Ranges.createRange(6, 17, 6, 72), "unable to resolve class ExceptionNew1 \n @ line 7, column 18.", new PublishDiagnosticsParams(test2.toPath().toUri().toString(), ImmutableList.of( new Diagnostic( Ranges.createRange(6, 17, 6, 74), "unable to resolve class ExceptionNew222 \n @ line 7, column 18.",
@Before public void setup() throws IOException { MockitoAnnotations.initMocks(this); Diagnostic d1 = new Diagnostic(); d1.setMessage("Some message"); d1.setSeverity(DiagnosticSeverity.Error); Diagnostic d2 = new Diagnostic(); d2.setMessage("Some other message"); d2.setSeverity(DiagnosticSeverity.Warning); expectedDiagnostics = Sets.newHashSet(new PublishDiagnosticsParams("uri", ImmutableList.of(d1, d2))); expectedReferences.add(new SymbolInformation( "MyClassName", SymbolKind.Class, new Location("uri", Ranges.createRange(1, 1, 9, 9)), "Something")); expectedReferences.add(new SymbolInformation( "MyClassName2", SymbolKind.Class, new Location("uri", Ranges.createRange(1, 1, 9, 9)), "SomethingElse")); Set<SymbolInformation> allReferencesReturned = Sets.newHashSet(expectedReferences); // The reference that will be filtered out allReferencesReturned.add(new SymbolInformation( "MyClassName3", SymbolKind.Class, new Location("uri", Ranges.UNDEFINED_RANGE), "SomethingElse")); when(compilerWrapper.getWorkspaceRoot()).thenReturn(workspace.getRoot().toPath().toUri()); when(compilerWrapper.compile(any())).thenReturn(expectedDiagnostics); when(compilerWrapper.getFilteredSymbols(any())).thenReturn(allReferencesReturned); when(state.getCompilerWrapper()).thenReturn(compilerWrapper); service = new TestWorkspaceService(state); }
Sets.newHashSet( new MyPublishDiagnosticParams(test1.toPath().toUri().toString(), Sets.newHashSet(new Diagnostic( Ranges.createRange(6, 17, 6, 72), "unable to resolve class ExceptionNew1 \n @ line 7, column 18.", GroovyConstants.GROOVY_COMPILER))), new MyPublishDiagnosticParams(test2.toPath().toUri().toString(), Sets.newHashSet(new Diagnostic( Ranges.createRange(6, 17, 6, 74), "unable to resolve class ExceptionNew222 \n @ line 7, column 18.",
Diagnostic clone(Diagnostic diagnostic) { if (diagnostic == null) { return null; } String code = diagnostic.getCode(); String message = diagnostic.getMessage(); Range range = diagnostic.getRange(); List<DiagnosticRelatedInformation> relatedInformation = diagnostic.getRelatedInformation(); DiagnosticSeverity severity = diagnostic.getSeverity(); String source = diagnostic.getSource(); Diagnostic cloned = new Diagnostic(); cloned.setCode(code); cloned.setMessage(message); cloned.setRange(clone(range)); cloned.setRelatedInformation(cloneDRI(relatedInformation)); cloned.setSeverity(severity); cloned.setSource(source); return cloned; }
ArrayList<Diagnostic> _arrayList = new ArrayList<Diagnostic>(); final Procedure1<ArrayList<Diagnostic>> _function_2 = (ArrayList<Diagnostic> it_2) -> { Diagnostic _diagnostic = new Diagnostic(); final Procedure1<Diagnostic> _function_3 = (Diagnostic it_3) -> { Range _range = new Range();
ArrayList<Diagnostic> _arrayList = new ArrayList<Diagnostic>(); final Procedure1<ArrayList<Diagnostic>> _function_2 = (ArrayList<Diagnostic> it_2) -> { Diagnostic _diagnostic = new Diagnostic(); final Procedure1<Diagnostic> _function_3 = (Diagnostic it_3) -> { Range _range = new Range();