Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Diagnostics reported in CompilerLifecycleEventContext are ignored #41915

Closed
xlight05 opened this issue Dec 21, 2023 · 2 comments · Fixed by #42131
Closed

[Bug]: Diagnostics reported in CompilerLifecycleEventContext are ignored #41915

xlight05 opened this issue Dec 21, 2023 · 2 comments · Fixed by #42131

Comments

@xlight05
Copy link
Contributor

Description

$Subject.

Consider the following code.

    @Override
    public void perform(CompilerLifecycleEventContext compilerLifecycleEventContext) {
        DiagnosticInfo diagnosticInfo = new DiagnosticInfo(C2CDiagnosticCodes.DOCKER_FAILED.getCode(),
                "Test Diag", DiagnosticSeverity.WARNING);
        Diagnostic diagnostic = DiagnosticFactory.createDiagnostic(diagnosticInfo, new NullLocation());
        compilerLifecycleEventContext.reportDiagnostic(diagnostic);
        
        }

Ideally, this should show a warning to all packages which uses this compiler plugin. but in this case this diagnostic is ignored.

Steps to Reproduce

  1. Clone https://github.com/xlight05/module-ballerina-c2c/tree/lifecycle-diag
  2. Invoke ./gradlew clean build -x check -x test and copy the generated pack
  3. Create a sample ballerina project(http hello world) and invoke build --cloud=docker

Affected Version(s)

All

OS, DB, other environment details and versions

No response

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@ShammiL
Copy link
Contributor

ShammiL commented Feb 8, 2024

A fix for this has been introduced in the PR #42131 and the following changes were introduced as a result.

  • Diagnostics recorded inside the JBallerinaBackend will contain all diagnostics reported during compilation and executable generation stages. Therefore, jar resolving diagnostics and lifeCyclePlugin diagnostics will also be added to this.
  • EmitResult generated during the executable generating stage will only contain the diagnostics related to executable generation and no any other diagnostics reported in earlier stages will be included. Before this fix, all diagnostics were included in the EmitResult.
  • After the EmitResult is generated, all EmitResult diagnostics will be printed. This means any other diagnostics related to earlier stages will not be printed again.

@ShammiL ShammiL moved this from In Progress to PR Sent in Ballerina Team Main Board Feb 9, 2024
@github-project-automation github-project-automation bot moved this from PR Sent to Done in Ballerina Team Main Board Feb 15, 2024
Copy link

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.

@azinneera azinneera added this to the 2201.9.0 milestone Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants