org.eclipse.lsp4j.DiagnosticSeverity Java Examples
The following examples show how to use
org.eclipse.lsp4j.DiagnosticSeverity.
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: WorkspaceDiagnosticsHandlerTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
private void testDiagnostic(List<PublishDiagnosticsParams> allCalls) { List<Diagnostic> projectDiags = new ArrayList<>(); List<Diagnostic> pomDiags = new ArrayList<>(); for (PublishDiagnosticsParams diag : allCalls) { if (diag.getUri().endsWith("maven/salut")) { projectDiags.addAll(diag.getDiagnostics()); } else if (diag.getUri().endsWith("pom.xml")) { pomDiags.addAll(diag.getDiagnostics()); } } assertTrue("No maven/salut errors were found", projectDiags.size() > 0); Optional<Diagnostic> projectDiag = projectDiags.stream().filter(p -> p.getMessage().contains("references non existing library")).findFirst(); assertTrue("No 'references non existing library' diagnostic", projectDiag.isPresent()); assertEquals(projectDiag.get().getSeverity(), DiagnosticSeverity.Error); assertTrue("No pom.xml errors were found", pomDiags.size() > 0); Optional<Diagnostic> pomDiag = pomDiags.stream().filter(p -> p.getMessage().startsWith("Missing artifact")).findFirst(); assertTrue("No 'missing artifact' diagnostic", pomDiag.isPresent()); assertTrue(pomDiag.get().getMessage().startsWith("Missing artifact")); assertEquals(pomDiag.get().getRange().getStart().getLine(), 19); assertEquals(pomDiag.get().getRange().getStart().getCharacter(), 3); assertEquals(pomDiag.get().getRange().getEnd().getLine(), 19); assertEquals(pomDiag.get().getRange().getEnd().getCharacter(), 14); assertEquals(pomDiag.get().getSeverity(), DiagnosticSeverity.Error); }
Example #2
Source File: XMLValidationSettings.java From lemminx with Eclipse Public License 2.0 | 6 votes |
/** * Returns the <code>noGrammar</code> severity according the given settings and * {@link DiagnosticSeverity#Hint} otherwise. * * @param settings the settings * @return the <code>noGrammar</code> severity according the given settings and * {@link DiagnosticSeverity#Hint} otherwise. */ public static DiagnosticSeverity getNoGrammarSeverity(ContentModelSettings settings) { DiagnosticSeverity defaultSeverity = DiagnosticSeverity.Hint; if (settings == null || settings.getValidation() == null) { return defaultSeverity; } XMLValidationSettings problems = settings.getValidation(); String noGrammar = problems.getNoGrammar(); if ("ignore".equalsIgnoreCase(noGrammar)) { // Ignore "noGrammar", return null. return null; } else if ("info".equalsIgnoreCase(noGrammar)) { return DiagnosticSeverity.Information; } else if ("warning".equalsIgnoreCase(noGrammar)) { return DiagnosticSeverity.Warning; } else if ("error".equalsIgnoreCase(noGrammar)) { return DiagnosticSeverity.Error; } return defaultSeverity; }
Example #3
Source File: ConfigurationPropertiesDiagnosticService.java From camel-language-server with Apache License 2.0 | 6 votes |
public Collection<Diagnostic> converToLSPDiagnostics(Map<String, ConfigurationPropertiesValidationResult> configurationPropertiesErrors) { List<Diagnostic> lspDiagnostics = new ArrayList<>(); for (Map.Entry<String, ConfigurationPropertiesValidationResult> errorEntry : configurationPropertiesErrors.entrySet()) { ConfigurationPropertiesValidationResult validationResult = errorEntry.getValue(); String lineContentInError = errorEntry.getKey(); List<Diagnostic> unknownParameterDiagnostics = computeUnknowParameters(validationResult, lineContentInError); lspDiagnostics.addAll(unknownParameterDiagnostics); List<Diagnostic> invalidEnumDiagnostics = computeInvalidEnumsDiagnostic(validationResult, lineContentInError); lspDiagnostics.addAll(invalidEnumDiagnostics); if (invalidEnumDiagnostics.size() + unknownParameterDiagnostics.size() < validationResult.getNumberOfErrors()) { lspDiagnostics.add(new Diagnostic( computeRange(validationResult, lineContentInError, lineContentInError), computeErrorMessage(validationResult), DiagnosticSeverity.Error, APACHE_CAMEL_VALIDATION, null)); } } return lspDiagnostics; }
Example #4
Source File: WorkspaceDiagnosticsHandlerTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@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 = WorkspaceDiagnosticsHandler.toDiagnosticsArray(d, new IMarker[] { m1, null }, true); 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()); }
Example #5
Source File: ConfigurationPropertiesDiagnosticService.java From camel-language-server with Apache License 2.0 | 6 votes |
private List<Diagnostic> computeUnknowParameters(ConfigurationPropertiesValidationResult validationResult, String lineContentInError) { List<Diagnostic> lspDiagnostics = new ArrayList<>(); Set<String> unknownParameters = validationResult.getUnknown(); if (unknownParameters != null) { for (String unknownParameter : unknownParameters) { int lastIndexOf = unknownParameter.lastIndexOf('.'); String realValueOfUnknowparameter; if(lastIndexOf != -1) { realValueOfUnknowparameter = unknownParameter.substring(lastIndexOf + 1); } else { realValueOfUnknowparameter = unknownParameter; } lspDiagnostics.add(new Diagnostic( computeRange(validationResult, lineContentInError, realValueOfUnknowparameter), new UnknownErrorMsg().getErrorMessage(unknownParameter), DiagnosticSeverity.Error, APACHE_CAMEL_VALIDATION, ERROR_CODE_UNKNOWN_PROPERTIES)); } } return lspDiagnostics; }
Example #6
Source File: EndpointDiagnosticService.java From camel-language-server with Apache License 2.0 | 6 votes |
public List<Diagnostic> converToLSPDiagnostics(String fullCamelText, Map<CamelEndpointDetails, EndpointValidationResult> endpointErrors, TextDocumentItem textDocumentItem) { List<Diagnostic> lspDiagnostics = new ArrayList<>(); for (Map.Entry<CamelEndpointDetails, EndpointValidationResult> endpointError : endpointErrors.entrySet()) { EndpointValidationResult validationResult = endpointError.getValue(); CamelEndpointDetails camelEndpointDetails = endpointError.getKey(); List<Diagnostic> unknownParameterDiagnostics = computeUnknowParameters(fullCamelText, textDocumentItem, validationResult, camelEndpointDetails); lspDiagnostics.addAll(unknownParameterDiagnostics); List<Diagnostic> invalidEnumDiagnostics = computeInvalidEnumsDiagnostic(fullCamelText, textDocumentItem, validationResult, camelEndpointDetails); lspDiagnostics.addAll(invalidEnumDiagnostics); if (invalidEnumDiagnostics.size() + unknownParameterDiagnostics.size() < validationResult.getNumberOfErrors()) { lspDiagnostics.add(new Diagnostic( computeRange(fullCamelText, textDocumentItem, camelEndpointDetails), computeErrorMessage(validationResult), DiagnosticSeverity.Error, APACHE_CAMEL_VALIDATION, null)); } } return lspDiagnostics; }
Example #7
Source File: RdfLintLanguageServer.java From rdflint with MIT License | 5 votes |
private DiagnosticSeverity convertLintProblemLevel2DiagnosticSeverity(ErrorLevel lv) { DiagnosticSeverity severity; switch (lv) { case ERROR: severity = DiagnosticSeverity.Error; break; case WARN: severity = DiagnosticSeverity.Warning; break; default: severity = DiagnosticSeverity.Information; } return severity; }
Example #8
Source File: XMLSchemaPublishDiagnosticsTest.java From lemminx with Eclipse Public License 2.0 | 5 votes |
@Test public void schemaWithUrlWithCache() throws Exception { // Here we test the following context: // - XML which have xsi:noNamespaceSchemaLocation="http://invoice.xsd" // - XMLCacheResolverExtension which is enabled // Result of test is to have 2 published diagnostics (resource downloading as // info and error downloading). Consumer<XMLLanguageService> configuration = ls -> { ContentModelManager contentModelManager = ls.getComponent(ContentModelManager.class); // Use cache on file system contentModelManager.setUseCache(true); }; String fileURI = "test.xml"; String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" + // "<invoice xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n" + // " xsi:noNamespaceSchemaLocation=\"http://invoice.xsd\">\r\n" + // "</invoice> \r\n" + // ""; String expectedLocation = TEST_WORK_DIRECTORY.resolve("cache/http/invoice.xsd").toString(); XMLAssert.testPublishDiagnosticsFor(xml, fileURI, configuration, pd(fileURI, new Diagnostic(r(1, 1, 1, 8), "The resource 'http://invoice.xsd' is downloading.", DiagnosticSeverity.Information, "XML")), pd(fileURI, new Diagnostic(r(1, 1, 1, 8), "Error while downloading 'http://invoice.xsd' to "+expectedLocation+".", DiagnosticSeverity.Error, "XML"))); }
Example #9
Source File: WorkspaceDiagnosticsHandlerTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Test public void testProjectConfigurationIsNotUpToDate() throws Exception { //import project importProjects("maven/salut"); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("salut"); IFile pom = project.getFile("/pom.xml"); assertTrue(pom.exists()); ResourceUtils.setContent(pom, ResourceUtils.getContent(pom).replaceAll("1.7", "1.8")); ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, monitor); assertNoErrors(project); List<IMarker> warnings = ResourceUtils.getWarningMarkers(project); Optional<IMarker> outOfDateWarning = warnings.stream().filter(w -> Messages.ProjectConfigurationUpdateRequired.equals(ResourceUtils.getMessage(w))).findFirst(); assertTrue("No out-of-date warning found", outOfDateWarning.isPresent()); ArgumentCaptor<PublishDiagnosticsParams> captor = ArgumentCaptor.forClass(PublishDiagnosticsParams.class); verify(connection, atLeastOnce()).publishDiagnostics(captor.capture()); List<PublishDiagnosticsParams> allCalls = captor.getAllValues(); Collections.reverse(allCalls); projectsManager.setConnection(client); Optional<PublishDiagnosticsParams> projectDiags = allCalls.stream().filter(p -> p.getUri().endsWith("maven/salut")).findFirst(); assertTrue("No maven/salut errors were found", projectDiags.isPresent()); List<Diagnostic> diags = projectDiags.get().getDiagnostics(); assertEquals(diags.toString(), 2, diags.size()); Optional<PublishDiagnosticsParams> pomDiags = allCalls.stream().filter(p -> p.getUri().endsWith("pom.xml")).findFirst(); assertTrue("No pom.xml errors were found", pomDiags.isPresent()); diags = pomDiags.get().getDiagnostics(); assertEquals(diags.toString(), 1, diags.size()); Diagnostic diag = diags.get(0); assertTrue(diag.getMessage().equals(WorkspaceDiagnosticsHandler.PROJECT_CONFIGURATION_IS_NOT_UP_TO_DATE_WITH_POM_XML)); assertEquals(diag.getSeverity(), DiagnosticSeverity.Warning); }
Example #10
Source File: ConfigurationPropertiesDiagnosticService.java From camel-language-server with Apache License 2.0 | 5 votes |
private List<Diagnostic> computeInvalidEnumsDiagnostic(ConfigurationPropertiesValidationResult validationResult, String lineContentInError) { List<Diagnostic> lspDiagnostics = new ArrayList<>(); Map<String, String> invalidEnums = validationResult.getInvalidEnum(); if (invalidEnums != null) { for (Entry<String, String> invalidEnum : invalidEnums.entrySet()) { lspDiagnostics.add(new Diagnostic( computeRange(validationResult, lineContentInError, invalidEnum.getKey()), new EnumErrorMsg().getErrorMessage(validationResult, invalidEnum), DiagnosticSeverity.Error, APACHE_CAMEL_VALIDATION, ERROR_CODE_INVALID_ENUM)); } } return lspDiagnostics; }
Example #11
Source File: EndpointDiagnosticService.java From camel-language-server with Apache License 2.0 | 5 votes |
private List<Diagnostic> computeInvalidEnumsDiagnostic(String fullCamelText, TextDocumentItem textDocumentItem, EndpointValidationResult validationResult, CamelEndpointDetails camelEndpointDetails) { List<Diagnostic> lspDiagnostics = new ArrayList<>(); Map<String, String> invalidEnums = validationResult.getInvalidEnum(); if (invalidEnums != null) { for (Entry<String, String> invalidEnum : invalidEnums.entrySet()) { lspDiagnostics.add(new Diagnostic( computeRange(fullCamelText, textDocumentItem, camelEndpointDetails, invalidEnum), new EnumErrorMsg().getErrorMessage(validationResult, invalidEnum), DiagnosticSeverity.Error, APACHE_CAMEL_VALIDATION, ERROR_CODE_INVALID_ENUM)); } } return lspDiagnostics; }
Example #12
Source File: EndpointDiagnosticService.java From camel-language-server with Apache License 2.0 | 5 votes |
private List<Diagnostic> computeUnknowParameters(String fullCamelText, TextDocumentItem textDocumentItem, EndpointValidationResult validationResult, CamelEndpointDetails camelEndpointDetails) { List<Diagnostic> lspDiagnostics = new ArrayList<>(); Set<String> unknownParameters = validationResult.getUnknown(); if (unknownParameters != null) { for (String unknownParameter : unknownParameters) { lspDiagnostics.add(new Diagnostic( computeRange(fullCamelText, textDocumentItem, camelEndpointDetails, unknownParameter), new UnknownErrorMsg().getErrorMessage(unknownParameter), DiagnosticSeverity.Error, APACHE_CAMEL_VALIDATION, ERROR_CODE_UNKNOWN_PROPERTIES)); } } return lspDiagnostics; }
Example #13
Source File: XMLSchemaPublishDiagnosticsTest.java From lemminx with Eclipse Public License 2.0 | 5 votes |
@Test public void schemaWithUrlInvalidPathWithNamespace() throws Exception { // Here we test the following context: // - XML which have xsi:noNamespaceSchemaLocation="http://invoice.xsd" // - XMLCacheResolverExtension which is disabled // Result of test is to have one published diagnostics with several Xerces // errors (schema) Consumer<XMLLanguageService> configuration = ls -> { ContentModelManager contentModelManager = ls.getComponent(ContentModelManager.class); // Use cache on file system contentModelManager.setUseCache(false); }; String fileURI = "test.xml"; String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" + // "<invoice xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n" + // " xsi:schemaLocation=\"http://invoice.xsd\">\r\n" + // "</invoice> \r\n" + // ""; XMLAssert.testPublishDiagnosticsFor(xml, fileURI, configuration, pd(fileURI, // new Diagnostic(r(2, 20, 2, 40), "SchemaLocation: schemaLocation value = 'http://invoice.xsd' must have even number of URI's.", DiagnosticSeverity.Warning, "xml", "SchemaLocation"), // new Diagnostic(r(1, 1, 1, 8), "cvc-elt.1.a: Cannot find the declaration of element 'invoice'.", DiagnosticSeverity.Error, "xml", "cvc-elt.1.a"))); }
Example #14
Source File: N4jscIssueSerializer.java From n4js with Eclipse Public License 1.0 | 5 votes |
private String getShortSeverity(DiagnosticSeverity severity) { switch (severity) { case Error: return "ERR"; case Warning: return "WRN"; case Information: return "INF"; case Hint: return "HNT"; } return "???"; }
Example #15
Source File: DiagnosticIssueConverter.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * Convert the {@link Severity} to a lsp {@link DiagnosticSeverity}. * * Defaults to severity {@link DiagnosticSeverity#Hint}. */ protected DiagnosticSeverity toSeverity(Severity severity) { switch (severity) { case ERROR: return DiagnosticSeverity.Error; case IGNORE: return DiagnosticSeverity.Hint; case INFO: return DiagnosticSeverity.Information; case WARNING: return DiagnosticSeverity.Warning; default: return DiagnosticSeverity.Hint; } }
Example #16
Source File: DiagnosticIssueConverter.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * Convert the lsp {@link DiagnosticSeverity} to an Xtext {@link Severity}. * * Defaults to severity {@link Severity#IGNORE}. */ protected Severity toSeverity(DiagnosticSeverity severity) { switch (severity) { case Error: return Severity.ERROR; case Hint: return Severity.IGNORE; case Information: return Severity.INFO; case Warning: return Severity.WARNING; default: return Severity.IGNORE; } }
Example #17
Source File: DdlTokenAnalyzer.java From syndesis with Apache License 2.0 | 5 votes |
public void addException(Token startToken, Token endToken, String errorMessage) { Position startPosition = new Position(startToken.beginLine, startToken.beginColumn); Position endPosition = new Position(endToken.endLine, endToken.endColumn + 1); DdlAnalyzerException exception = new DdlAnalyzerException(DiagnosticSeverity.Error, errorMessage, new Range(startPosition, endPosition)); // $NON-NLS-1$); this.addException(exception); }
Example #18
Source File: DdlAnalyzerException.java From syndesis with Apache License 2.0 | 5 votes |
/** Constructor with message. */ public DdlAnalyzerException(DiagnosticSeverity severity, String message, Range range) { super(message); this.diagnostic = new Diagnostic(); this.diagnostic.setSeverity(severity); this.diagnostic.setMessage(message); this.diagnostic.setRange(range); }
Example #19
Source File: BaseDiagnosticsHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private static DiagnosticSeverity convertSeverity(IProblem problem) { if (problem.isError()) { return DiagnosticSeverity.Error; } if (problem.isWarning() && (problem.getID() != IProblem.Task)) { return DiagnosticSeverity.Warning; } return DiagnosticSeverity.Information; }
Example #20
Source File: WorkspaceDiagnosticsHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
/** * @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; }
Example #21
Source File: CodeActionHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
public static IProblemLocationCore[] getProblemLocationCores(ICompilationUnit unit, List<Diagnostic> diagnostics) { IProblemLocationCore[] locations = new IProblemLocationCore[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 ProblemLocationCore(start, end - start, problemId, new String[0], isError, IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); } return locations; }
Example #22
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 #23
Source File: MavenJavaDiagnosticsMicroProfileHealthTest.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
@Test public void testHealthAnnotationMissing() throws Exception { Module module = createMavenModule("microprofile-health-quickstart", new File("projects/maven/microprofile-health-quickstart")); MicroProfileJavaDiagnosticsParams diagnosticsParams = new MicroProfileJavaDiagnosticsParams(); VirtualFile javaFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(ModuleUtilCore.getModuleDirPath(module) + "/src/main/java/org/acme/health/ImplementHealthCheck.java"); String uri = VfsUtilCore.virtualToIoFile(javaFile).toURI().toString(); diagnosticsParams.setUris(Arrays.asList(uri)); diagnosticsParams.setDocumentFormat(DocumentFormat.Markdown); Diagnostic d = d(5, 13, 33, "The class `org.acme.health.ImplementHealthCheck` implementing the HealthCheck interface should use the @Liveness, @Readiness, or @Health annotation.", DiagnosticSeverity.Warning, MicroProfileHealthConstants.DIAGNOSTIC_SOURCE, MicroProfileHealthErrorCode.HealthAnnotationMissing); assertJavaDiagnostics(diagnosticsParams, utils, // d); /*MicroProfileJavaCodeActionParams codeActionParams = createCodeActionParams(uri, d); assertJavaCodeAction(codeActionParams, utils, // ca(uri, "Insert @Health", d, // te(2, 0, 5, 0, "import org.eclipse.microprofile.health.Health;\r\n" + // "import org.eclipse.microprofile.health.HealthCheck;\r\n" + // "import org.eclipse.microprofile.health.HealthCheckResponse;\r\n\r\n" + // "@Health\r\n")), ca(uri, "Insert @Liveness", d, // te(3, 59, 5, 0, "\r\n" + // "import org.eclipse.microprofile.health.Liveness;\r\n\r\n" + // "@Liveness\r\n")), // ca(uri, "Insert @Readiness", d, // te(3, 59, 5, 0, "\r\n" + // "import org.eclipse.microprofile.health.Readiness;\r\n\r\n" + // "@Readiness\r\n")) // );*/ }
Example #24
Source File: LSPLocalInspectionTool.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
private ProblemHighlightType getHighlighType(DiagnosticSeverity severity) { switch (severity) { case Error: return ProblemHighlightType.ERROR; case Hint: case Information: return ProblemHighlightType.INFORMATION; case Warning: return ProblemHighlightType.WARNING; } return ProblemHighlightType.INFORMATION; }
Example #25
Source File: LSPDiagnosticsToMarkers.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
private Color getColor(DiagnosticSeverity severity) { switch (severity) { case Hint: return Color.GRAY; case Error: return Color.RED; case Information: return Color.GRAY; case Warning: return Color.YELLOW; } return Color.GRAY; }
Example #26
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 #27
Source File: GradleJavaDiagnosticsMicroProfileRestClientTest.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
@Test public void testRestClientAnnotationMissingForInterface() throws Exception { ApplicationManager.getApplication().invokeAndWait(() -> { Module module = getModule("rest-client-quickstart.main"); MicroProfileJavaDiagnosticsParams params = new MicroProfileJavaDiagnosticsParams(); VirtualFile javaFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(ModuleUtilCore.getModuleDirPath(module) + "/src/main/java/org/acme/restclient/MyService.java"); String uri = VfsUtilCore.virtualToIoFile(javaFile).toURI().toString(); params.setUris(Arrays.asList(uri)); params.setDocumentFormat(DocumentFormat.Markdown); Diagnostic d = d(2, 17, 26, "The interface `MyService` does not have the @RegisterRestClient annotation. The 1 fields references will not be injected as CDI beans.", DiagnosticSeverity.Warning, MicroProfileRestClientConstants.DIAGNOSTIC_SOURCE, MicroProfileRestClientErrorCode.RegisterRestClientAnnotationMissing); assertJavaDiagnostics(params, utils, // d); /*String uri = javaFile.getLocation().toFile().toURI().toString(); MicroProfileJavaCodeActionParams codeActionParams = createCodeActionParams(uri, d); assertJavaCodeAction(codeActionParams, utils, // ca(uri, "Insert @RegisterRestClient", d, // te(0, 28, 2, 0, "\r\n\r\nimport org.eclipse.microprofile.rest.client.inject.RegisterRestClient;\r\n\r\n@RegisterRestClient\r\n")));*/ }); }
Example #28
Source File: GradleJavaDiagnosticsMicroProfileHealthTest.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
@Test public void testImplementHealthCheck() throws Exception { Module module = getModule("microprofile-health-quickstart.main"); MicroProfileJavaDiagnosticsParams diagnosticsParams = new MicroProfileJavaDiagnosticsParams(); VirtualFile javaFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(ModuleUtilCore.getModuleDirPath(module) + "/src/main/java/org/acme/health/DontImplementHealthCheck.java"); String uri = VfsUtilCore.virtualToIoFile(javaFile).toURI().toString(); diagnosticsParams.setUris(Arrays.asList(uri)); diagnosticsParams.setDocumentFormat(DocumentFormat.Markdown); Diagnostic d = d(9, 13, 37, "The class `org.acme.health.DontImplementHealthCheck` using the @Liveness, @Readiness, or @Health annotation should implement the HealthCheck interface.", DiagnosticSeverity.Warning, MicroProfileHealthConstants.DIAGNOSTIC_SOURCE, MicroProfileHealthErrorCode.ImplementHealthCheck); assertJavaDiagnostics(diagnosticsParams, utils, // d); /*String uri = javaFile.getUrl(); MicroProfileJavaCodeActionParams codeActionParams = createCodeActionParams(uri, d); assertJavaCodeAction(codeActionParams, utils, // ca(uri, "Let 'DontImplementHealthCheck' implement 'org.eclipse.microprofile.health.HealthCheck'", d, // te(2, 50, 9, 37, "\r\n\r\n" + // "import org.eclipse.microprofile.health.HealthCheck;\r\n" + // "import org.eclipse.microprofile.health.HealthCheckResponse;\r\n" + // "import org.eclipse.microprofile.health.Liveness;\r\n\r\n@Liveness\r\n" + // "@ApplicationScoped\r\n" + // "public class DontImplementHealthCheck implements HealthCheck")));*/ }
Example #29
Source File: GradleJavaDiagnosticsMicroProfileHealthTest.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
@Test public void testHealthAnnotationMissing() throws Exception { Module module = getModule("microprofile-health-quickstart.main"); MicroProfileJavaDiagnosticsParams diagnosticsParams = new MicroProfileJavaDiagnosticsParams(); VirtualFile javaFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(ModuleUtilCore.getModuleDirPath(module) + "/src/main/java/org/acme/health/ImplementHealthCheck.java"); String uri = VfsUtilCore.virtualToIoFile(javaFile).toURI().toString(); diagnosticsParams.setUris(Arrays.asList(uri)); diagnosticsParams.setDocumentFormat(DocumentFormat.Markdown); Diagnostic d = d(5, 13, 33, "The class `org.acme.health.ImplementHealthCheck` implementing the HealthCheck interface should use the @Liveness, @Readiness, or @Health annotation.", DiagnosticSeverity.Warning, MicroProfileHealthConstants.DIAGNOSTIC_SOURCE, MicroProfileHealthErrorCode.HealthAnnotationMissing); assertJavaDiagnostics(diagnosticsParams, utils, // d); /*MicroProfileJavaCodeActionParams codeActionParams = createCodeActionParams(uri, d); assertJavaCodeAction(codeActionParams, utils, // ca(uri, "Insert @Health", d, // te(2, 0, 5, 0, "import org.eclipse.microprofile.health.Health;\r\n" + // "import org.eclipse.microprofile.health.HealthCheck;\r\n" + // "import org.eclipse.microprofile.health.HealthCheckResponse;\r\n\r\n" + // "@Health\r\n")), ca(uri, "Insert @Liveness", d, // te(3, 59, 5, 0, "\r\n" + // "import org.eclipse.microprofile.health.Liveness;\r\n\r\n" + // "@Liveness\r\n")), // ca(uri, "Insert @Readiness", d, // te(3, 59, 5, 0, "\r\n" + // "import org.eclipse.microprofile.health.Readiness;\r\n\r\n" + // "@Readiness\r\n")) // );*/ }
Example #30
Source File: MavenJavaDiagnosticsMicroProfileHealthTest.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
@Test public void testImplementHealthCheck() throws Exception { Module module = createMavenModule("microprofile-health-quickstart", new File("projects/maven/microprofile-health-quickstart")); MicroProfileJavaDiagnosticsParams diagnosticsParams = new MicroProfileJavaDiagnosticsParams(); VirtualFile javaFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(ModuleUtilCore.getModuleDirPath(module) + "/src/main/java/org/acme/health/DontImplementHealthCheck.java"); String uri = VfsUtilCore.virtualToIoFile(javaFile).toURI().toString(); diagnosticsParams.setUris(Arrays.asList(uri)); diagnosticsParams.setDocumentFormat(DocumentFormat.Markdown); Diagnostic d = d(9, 13, 37, "The class `org.acme.health.DontImplementHealthCheck` using the @Liveness, @Readiness, or @Health annotation should implement the HealthCheck interface.", DiagnosticSeverity.Warning, MicroProfileHealthConstants.DIAGNOSTIC_SOURCE, MicroProfileHealthErrorCode.ImplementHealthCheck); assertJavaDiagnostics(diagnosticsParams, utils, // d); /*String uri = javaFile.getUrl(); MicroProfileJavaCodeActionParams codeActionParams = createCodeActionParams(uri, d); assertJavaCodeAction(codeActionParams, utils, // ca(uri, "Let 'DontImplementHealthCheck' implement 'org.eclipse.microprofile.health.HealthCheck'", d, // te(2, 50, 9, 37, "\r\n\r\n" + // "import org.eclipse.microprofile.health.HealthCheck;\r\n" + // "import org.eclipse.microprofile.health.HealthCheckResponse;\r\n" + // "import org.eclipse.microprofile.health.Liveness;\r\n\r\n@Liveness\r\n" + // "@ApplicationScoped\r\n" + // "public class DontImplementHealthCheck implements HealthCheck")));*/ }