From cada1b34024ca035e3d31504013afc41a9d22de1 Mon Sep 17 00:00:00 2001 From: azinneera Date: Wed, 20 Nov 2024 12:06:21 +0530 Subject: [PATCH 1/2] Fix bugs in readme change --- .../projects/internal/ManifestBuilder.java | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ManifestBuilder.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ManifestBuilder.java index 6b7ea29c3105..fbddc220782f 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ManifestBuilder.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ManifestBuilder.java @@ -128,7 +128,6 @@ public class ManifestBuilder { private static final String TARGETMODULE = "targetModule"; private static final String OPTIONS = "options"; private static final String TOOL = "tool"; - private static final String DESCRIPTION = "description"; private static final String README = "readme"; @@ -235,16 +234,25 @@ private PackageManifest parseAsPackageManifest() { description = getStringValueFromTomlTableNode(pkgNode, DESCRIPTION, ""); moduleEntries = getModuleEntries(pkgNode, customReadmeVal, packageDescriptor.name()); + if (!exported.isEmpty()) { + reportDiagnostic(pkgNode.entries().get(EXPORT), + "'export' under [package] is deprecated. " + + "Add the exports using the 'export' field under '[[package.modules]]'", + ProjectDiagnosticErrorCode.DEPRECATED_BALLERINA_TOML_ENTRY, DiagnosticSeverity.WARNING); + } if (!isOldStructure) { - if (!exported.isEmpty()) { - reportDiagnostic(pkgNode.entries().get(EXPORT), - "'export' under [package] is deprecated. " + - "Add the exports using the 'export' field under '[[package.modules]]'", - ProjectDiagnosticErrorCode.DEPRECATED_BALLERINA_TOML_ENTRY, DiagnosticSeverity.WARNING); + if (!exported.contains(packageDescriptor.name().toString())) { + exported.add(packageDescriptor.name().toString()); // default module is always exported + } + for (PackageManifest.Module moduleEntry : moduleEntries) { + if (!moduleEntry.export()) { + continue; + } + String name = moduleEntry.name(); + if (!exported.contains(name)) { + exported.add(name); + } } - exported.add(packageDescriptor.name().toString()); // default module is always exported - exported.addAll(moduleEntries.stream().filter( - PackageManifest.Module::export).map(PackageManifest.Module::name).toList()); } } } @@ -346,7 +354,8 @@ private List getModuleEntries( TomlTableArrayNode dependencyTableArray = (TomlTableArrayNode) dependencyEntries; for (TomlTableNode modulesNode : dependencyTableArray.children()) { String moduleName = getStringValueFromTomlTableNode(modulesNode, NAME, null); - if (moduleName == null) { + if (moduleName == null + || !moduleName.contains(DOT)) { // The invalid module name is already handled continue; } From 71633eadf1958f4e0f515f5be47f3d96b5f29ef3 Mon Sep 17 00:00:00 2001 From: Asma Jabir Date: Wed, 20 Nov 2024 13:05:45 +0530 Subject: [PATCH 2/2] Update compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ManifestBuilder.java Co-authored-by: Gayal Dassanayake --- .../java/io/ballerina/projects/internal/ManifestBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ManifestBuilder.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ManifestBuilder.java index fbddc220782f..39399a550de6 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ManifestBuilder.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ManifestBuilder.java @@ -250,7 +250,7 @@ private PackageManifest parseAsPackageManifest() { } String name = moduleEntry.name(); if (!exported.contains(name)) { - exported.add(name); + exported.add(name); } } }