Skip to content

Commit

Permalink
Fix Compiler Plugin Diagnostics not Reporting (#1829)
Browse files Browse the repository at this point in the history
* Bump the dependency versions

* Fix compiler plugin not showing diagnostics
  • Loading branch information
ThisaruGuruge authored Apr 15, 2024
1 parent 7ec5a27 commit 9ebb287
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,6 @@ public void testMultipleInlineServiceDeclarations() {
private DiagnosticResult getDiagnosticResult(String path) {
Path projectDirPath = RESOURCE_DIRECTORY.resolve(path);
BuildProject project = BuildProject.load(getEnvironmentBuilder(), projectDirPath);
DiagnosticResult diagnosticResult = project.currentPackage().getCompilation().diagnosticResult();
Assert.assertEquals(diagnosticResult.errorCount(), 0);
return project.currentPackage().runCodeGenAndModifyPlugins();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ public void testInvalidReturnTypes() {

diagnostic = diagnosticIterator.next();
message = getErrorMessage(CompilationDiagnostic.INVALID_FUNCTION, "Interceptor", "execute");
// This error points to the types.bal in the GraphQL package since this returns the `graphql:Interceptor` type.
assertErrorMessage(diagnostic, message, 91, 5);

diagnostic = diagnosticIterator.next();
Expand Down Expand Up @@ -1454,9 +1455,6 @@ public void testInvalidServiceConfigModification() {
private DiagnosticResult getDiagnosticResult(String packagePath) {
Path projectDirPath = RESOURCE_DIRECTORY.resolve(packagePath);
BuildProject project = BuildProject.load(getEnvironmentBuilder(), projectDirPath);
DiagnosticResult diagnosticResult = project.currentPackage().getCompilation().diagnosticResult();
Assert.assertEquals(diagnosticResult.errorCount(), 0,
"Package compilation encountered errors before running compiler plugin");
return project.currentPackage().runCodeGenAndModifyPlugins();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,12 @@ public void init(CodeAnalysisContext codeAnalysisContext) {
if (this.userData == null) {
return;
}
if (this.userData.isEmpty()) {
this.analyze(codeAnalysisContext);
} else if (this.userData.containsKey(IS_ANALYSIS_COMPLETED)) {
boolean isAnalysisCompleted = (boolean) this.userData.get(IS_ANALYSIS_COMPLETED);
if (!isAnalysisCompleted) {
this.analyze(codeAnalysisContext);
if (this.userData.containsKey(IS_ANALYSIS_COMPLETED)) {
if ((boolean) this.userData.get(IS_ANALYSIS_COMPLETED)) {
return;
}
}
this.analyze(codeAnalysisContext);
}

private void analyze(CodeAnalysisContext codeAnalysisContext) {
Expand Down

0 comments on commit 9ebb287

Please sign in to comment.