Skip to content

Commit

Permalink
Merge pull request #42627 from Thevakumar-Luheerathan/fix-ballerina-l…
Browse files Browse the repository at this point in the history
…ang-iss-32985

Suppress the warnings from imports
  • Loading branch information
Thevakumar-Luheerathan authored May 3, 2024
2 parents c5036b2 + 6dd8b97 commit 769e28e
Show file tree
Hide file tree
Showing 16 changed files with 99 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ public BuildCommand() {
@CommandLine.Option(names = "--cloud", description = "Enable cloud artifact generation")
private String cloud;

@CommandLine.Option(names = "--show-dependency-diagnostics", description = "Show the diagnostics " +
"generated by the dependencies")
private Boolean showDependencyDiagnostics;

@CommandLine.Option(names = "--remote-management", description = "enable service management tools in " +
"the executable JAR file(s).")
private Boolean remoteManagement;
Expand Down Expand Up @@ -320,7 +324,8 @@ private BuildOptions constructBuildOptions() {
.setEnableCache(enableCache)
.setNativeImage(nativeImage)
.disableSyntaxTreeCaching(disableSyntaxTreeCaching)
.setGraalVMBuildOptions(graalVMBuildOptions);
.setGraalVMBuildOptions(graalVMBuildOptions)
.setShowDependencyDiagnostics(showDependencyDiagnostics);

if (targetDir != null) {
buildOptionsBuilder.targetDir(targetDir.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ public DocCommand() {
"caching for source files", defaultValue = "false")
private Boolean disableSyntaxTreeCaching;

@CommandLine.Option(names = "--show-dependency-diagnostics", description = "Show the diagnostics " +
"generated by the dependencies")
private Boolean showDependencyDiagnostics;

public void execute() {
if (this.helpFlag) {
String commandUsageInfo = BLauncherCmd.getCommandUsageInfo(DOC_COMMAND);
Expand Down Expand Up @@ -221,7 +225,8 @@ private BuildOptions constructBuildOptions() {
.setOffline(offline)
.setTestReport(false)
.setObservabilityIncluded(false)
.disableSyntaxTreeCaching(disableSyntaxTreeCaching);
.disableSyntaxTreeCaching(disableSyntaxTreeCaching)
.setShowDependencyDiagnostics(showDependencyDiagnostics);


if (targetDir != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ public class PackCommand implements BLauncherCmd {
"caching for source files", defaultValue = "false")
private Boolean disableSyntaxTreeCaching;

@CommandLine.Option(names = "--show-dependency-diagnostics", description = "Show the diagnostics " +
"generated by the dependencies")
private Boolean showDependencyDiagnostics;

public PackCommand() {
this.projectPath = Paths.get(System.getProperty(ProjectConstants.USER_DIR));
this.outStream = System.out;
Expand Down Expand Up @@ -274,7 +278,8 @@ private BuildOptions constructBuildOptions() {
.setSticky(sticky)
.setConfigSchemaGen(configSchemaGen)
.setEnableCache(enableCache)
.disableSyntaxTreeCaching(disableSyntaxTreeCaching);
.disableSyntaxTreeCaching(disableSyntaxTreeCaching)
.setShowDependencyDiagnostics(showDependencyDiagnostics);

if (targetDir != null) {
buildOptionsBuilder.targetDir(targetDir.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ public class ProfileCommand implements BLauncherCmd {
"caching for source files", defaultValue = "false")
private Boolean disableSyntaxTreeCaching;

@CommandLine.Option(names = "--show-dependency-diagnostics", description = "Show the diagnostics " +
"generated by the dependencies")
private Boolean showDependencyDiagnostics;

private static final String PROFILE_CMD = "bal profile [--debug <port>] [<ballerina-file | package-path>]\n ";

public ProfileCommand() {
Expand Down Expand Up @@ -232,7 +236,8 @@ private BuildOptions constructBuildOptions() {
.setSkipTests(true)
.setTestReport(false)
.setConfigSchemaGen(configSchemaGen)
.disableSyntaxTreeCaching(disableSyntaxTreeCaching);
.disableSyntaxTreeCaching(disableSyntaxTreeCaching)
.setShowDependencyDiagnostics(showDependencyDiagnostics);

if (targetDir != null) {
buildOptionsBuilder.targetDir(targetDir.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ public class RunCommand implements BLauncherCmd {
@CommandLine.Option(names = "--dump-build-time", description = "calculate and dump build time", hidden = true)
private Boolean dumpBuildTime;

@CommandLine.Option(names = "--show-dependency-diagnostics", description = "Show the diagnostics " +
"generated by the dependencies")
private Boolean showDependencyDiagnostics;

private static final String runCmd =
"""
bal run [--debug <port>] <executable-jar>\s
Expand Down Expand Up @@ -292,7 +296,8 @@ private BuildOptions constructBuildOptions() {
.setDumpRawGraphs(dumpRawGraphs)
.setConfigSchemaGen(configSchemaGen)
.disableSyntaxTreeCaching(disableSyntaxTreeCaching)
.setDumpBuildTime(dumpBuildTime);
.setDumpBuildTime(dumpBuildTime)
.setShowDependencyDiagnostics(showDependencyDiagnostics);

if (targetDir != null) {
buildOptionsBuilder.targetDir(targetDir.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ public TestCommand() {
"generation")
private String graalVMBuildOptions;

@CommandLine.Option(names = "--show-dependency-diagnostics", description = "Show the diagnostics " +
"generated by the dependencies")
private Boolean showDependencyDiagnostics;


private static final String testCmd = "bal test [--OPTIONS]\n" +
" [<ballerina-file> | <package-path>] [(-Ckey=value)...]";
Expand Down Expand Up @@ -392,8 +396,8 @@ private BuildOptions constructBuildOptions() {
.setNativeImage(nativeImage)
.setEnableCache(enableCache)
.disableSyntaxTreeCaching(disableSyntaxTreeCaching)
.setGraalVMBuildOptions(graalVMBuildOptions);

.setGraalVMBuildOptions(graalVMBuildOptions)
.setShowDependencyDiagnostics(showDependencyDiagnostics);

if (targetDir != null) {
buildOptionsBuilder.targetDir(targetDir.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ OPTIONS
Include the dependencies that are required to enable remote package
management service.

--show-dependency-diagnostics
Print the diagnostics that are related to the dependencies. By default, these
diagnostics are not printed to the console.


EXAMPLES
Build the current package. This will generate an 'app.jar' file in the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ OPTIONS
--target-dir <path>
Target directory path.

--show-dependency-diagnostics
Print the diagnostics that are related to the dependencies. By default, these
diagnostics are not printed to the console.


EXAMPLES
Generate API documentation for the current package.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ OPTIONS
--target-dir
Target directory path.

--show-dependency-diagnostics
Print the diagnostics that are related to the dependencies. By default, these
diagnostics are not printed to the console.


EXAMPLES
Pack the current package into .bala file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ OPTIONS
--debug <port>
Run Ballerina Profiler in the remote debugging mode.

--show-dependency-diagnostics
Print the diagnostics that are related to the dependencies. By default, these
diagnostics are not printed to the console.

EXAMPLES
Run Ballerina profiler on the 'main' function and service(s) in the 'app.bal' file.
$ bal profile app.bal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ OPTIONS
Target directory path. The directory path can be absolute or relative
to the current package.

--show-dependency-diagnostics
Print the diagnostics that are related to the dependencies. By default, these
diagnostics are not printed to the console.


ARGUMENTS
--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ OPTIONS
after-groups) of the test function should be isolated.
Parallel test execution is an experimental feature which supports only a limited set of functionality.

--show-dependency-diagnostics
Print the diagnostics that are related to the dependencies. By default, these
diagnostics are not printed to the console.


ARGUMENTS
(-Ckey=value)...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
public class BuildOptions {

private final Boolean showDependencyDiagnostics;
private Boolean testReport;
private Boolean codeCoverage;
private Boolean dumpBuildTime;
Expand All @@ -37,7 +38,8 @@ public class BuildOptions {

BuildOptions(Boolean testReport, Boolean codeCoverage, Boolean dumpBuildTime, Boolean skipTests,
CompilationOptions compilationOptions, String targetPath, Boolean enableCache,
Boolean nativeImage, Boolean exportComponentModel, String graalVMBuildOptions) {
Boolean nativeImage, Boolean exportComponentModel, String graalVMBuildOptions,
Boolean showDependencyDiagnostics) {
this.testReport = testReport;
this.codeCoverage = codeCoverage;
this.dumpBuildTime = dumpBuildTime;
Expand All @@ -48,7 +50,7 @@ public class BuildOptions {
this.nativeImage = nativeImage;
this.exportComponentModel = exportComponentModel;
this.graalVMBuildOptions = graalVMBuildOptions;

this.showDependencyDiagnostics = showDependencyDiagnostics;
}

public boolean testReport() {
Expand Down Expand Up @@ -131,6 +133,10 @@ public String graalVMBuildOptions() {
return Objects.requireNonNullElse(this.graalVMBuildOptions, "");
}

public boolean showDependencyDiagnostics() {
return toBooleanDefaultIfNull(this.showDependencyDiagnostics);
}

/**
* Merge the given build options by favoring theirs if there are conflicts.
*
Expand Down Expand Up @@ -184,6 +190,11 @@ public BuildOptions acceptTheirs(BuildOptions theirOptions) {
} else {
buildOptionsBuilder.setGraalVMBuildOptions(this.graalVMBuildOptions);
}
if (theirOptions.showDependencyDiagnostics != null) {
buildOptionsBuilder.setShowDependencyDiagnostics(theirOptions.showDependencyDiagnostics);
} else {
buildOptionsBuilder.setShowDependencyDiagnostics(this.showDependencyDiagnostics);
}

CompilationOptions compilationOptions = this.compilationOptions.acceptTheirs(theirOptions.compilationOptions());
buildOptionsBuilder.setOffline(compilationOptions.offlineBuild);
Expand Down Expand Up @@ -237,7 +248,8 @@ public enum OptionName {
TARGET_DIR("targetDir"),
NATIVE_IMAGE("graalvm"),
EXPORT_COMPONENT_MODEL("exportComponentModel"),
GRAAL_VM_BUILD_OPTIONS("graalvmBuildOptions");
GRAAL_VM_BUILD_OPTIONS("graalvmBuildOptions"),
SHOW_DEPENDENCY_DIAGNOSTICS("showDependencyDiagnostics");

private final String name;

Expand Down Expand Up @@ -268,6 +280,7 @@ public static class BuildOptionsBuilder {
private Boolean nativeImage;
private Boolean exportComponentModel;
private String graalVMBuildOptions;
private Boolean showDependencyDiagnostics;


private BuildOptionsBuilder() {
Expand Down Expand Up @@ -397,10 +410,16 @@ public BuildOptionsBuilder setRemoteManagement(Boolean value) {
return this;
}

public BuildOptionsBuilder setShowDependencyDiagnostics(Boolean value) {
showDependencyDiagnostics = value;
return this;
}

public BuildOptions build() {
CompilationOptions compilationOptions = compilationOptionsBuilder.build();
return new BuildOptions(testReport, codeCoverage, dumpBuildTime, skipTests, compilationOptions,
targetPath, enableCache, nativeImage, exportComponentModel, graalVMBuildOptions);
targetPath, enableCache, nativeImage, exportComponentModel, graalVMBuildOptions,
showDependencyDiagnostics);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,12 @@ private void performCodeGen(boolean shrink) {
moduleContext.generatePlatformSpecificCode(compilerContext, this);
}
for (Diagnostic diagnostic : moduleContext.diagnostics()) {
moduleDiagnostics.add(
new PackageDiagnostic(diagnostic, moduleContext.descriptor(), moduleContext.project()));
if (this.packageContext.project().buildOptions().showDependencyDiagnostics() ||
!ProjectKind.BALA_PROJECT.equals(moduleContext.project().kind()) ||
(diagnostic.diagnosticInfo().severity() == DiagnosticSeverity.ERROR)) {
moduleDiagnostics.add(
new PackageDiagnostic(diagnostic, moduleContext.descriptor(), moduleContext.project()));
}
}

if (shrink) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import io.ballerina.projects.internal.DefaultDiagnosticResult;
import io.ballerina.projects.internal.PackageDiagnostic;
import io.ballerina.tools.diagnostics.Diagnostic;
import io.ballerina.tools.diagnostics.DiagnosticSeverity;
import org.ballerinalang.compiler.plugins.CompilerPlugin;
import org.wso2.ballerinalang.compiler.tree.BLangPackage;
import org.wso2.ballerinalang.compiler.util.CompilerContext;
Expand Down Expand Up @@ -209,8 +210,11 @@ private void compileModulesInternal() {
for (ModuleContext moduleContext : packageResolution.topologicallySortedModuleList()) {
moduleContext.compile(compilerContext);
for (Diagnostic diagnostic : moduleContext.diagnostics()) {
diagnostics.add(new PackageDiagnostic(diagnostic, moduleContext.descriptor(),
moduleContext.project()));
if (!ProjectKind.BALA_PROJECT.equals(moduleContext.project().kind()) ||
(diagnostic.diagnosticInfo().severity() == DiagnosticSeverity.ERROR)) {
diagnostics.add(new PackageDiagnostic(diagnostic, moduleContext.descriptor(),
moduleContext.project()));
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,8 @@ private BuildOptions setBuildOptions(TomlTableNode tomlTableNode) {
BuildOptions.OptionName.GRAAL_VM_BUILD_OPTIONS.toString());
Boolean remoteManagement = getBooleanFromBuildOptionsTableNode(tableNode,
CompilerOptionName.REMOTE_MANAGEMENT.toString());
Boolean showDependencyDiagnostics = getBooleanFromBuildOptionsTableNode(tableNode,
BuildOptions.OptionName.SHOW_DEPENDENCY_DIAGNOSTICS.toString());

buildOptionsBuilder
.setOffline(offline)
Expand All @@ -707,7 +709,8 @@ private BuildOptions setBuildOptions(TomlTableNode tomlTableNode) {
.setNativeImage(nativeImage)
.setExportComponentModel(exportComponentModel)
.setGraalVMBuildOptions(graalVMBuildOptions)
.setRemoteManagement(remoteManagement);
.setRemoteManagement(remoteManagement)
.setShowDependencyDiagnostics(showDependencyDiagnostics);

if (targetDir != null) {
buildOptionsBuilder.targetDir(targetDir);
Expand Down

0 comments on commit 769e28e

Please sign in to comment.