diff --git a/ballerina-shell/modules/shell-core/src/main/java/io/ballerina/shell/invoker/classload/ClassLoadInvoker.java b/ballerina-shell/modules/shell-core/src/main/java/io/ballerina/shell/invoker/classload/ClassLoadInvoker.java index 54f5ff96fc49..4617ea0bf74d 100644 --- a/ballerina-shell/modules/shell-core/src/main/java/io/ballerina/shell/invoker/classload/ClassLoadInvoker.java +++ b/ballerina-shell/modules/shell-core/src/main/java/io/ballerina/shell/invoker/classload/ClassLoadInvoker.java @@ -558,7 +558,7 @@ private Collection globalVariableSymbols(Project project, return compilation.getSemanticModel(moduleId).moduleSymbols().stream() .filter(s -> s instanceof VariableSymbol || s instanceof FunctionSymbol) .map(GlobalVariableSymbol::fromSymbol) - .collect(Collectors.toList()); + .toList(); } /** diff --git a/ballerina-shell/modules/shell-core/src/main/java/io/ballerina/shell/invoker/classload/ImportsManager.java b/ballerina-shell/modules/shell-core/src/main/java/io/ballerina/shell/invoker/classload/ImportsManager.java index 06ac3c76bc10..829c6d9c635a 100644 --- a/ballerina-shell/modules/shell-core/src/main/java/io/ballerina/shell/invoker/classload/ImportsManager.java +++ b/ballerina-shell/modules/shell-core/src/main/java/io/ballerina/shell/invoker/classload/ImportsManager.java @@ -42,7 +42,6 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; /** * Imports that were stored to be able to search with the prefix. @@ -364,7 +363,7 @@ private static List getBallerinaKeywords() { } }) .filter(Objects::nonNull) - .collect(Collectors.toList()); + .toList(); } catch (ClassNotFoundException e) { return Collections.emptyList(); } diff --git a/ballerina-shell/modules/shell-core/src/main/java/io/ballerina/shell/snippet/types/ImportDeclarationSnippet.java b/ballerina-shell/modules/shell-core/src/main/java/io/ballerina/shell/snippet/types/ImportDeclarationSnippet.java index 988669c1784c..ec58593d5d2a 100644 --- a/ballerina-shell/modules/shell-core/src/main/java/io/ballerina/shell/snippet/types/ImportDeclarationSnippet.java +++ b/ballerina-shell/modules/shell-core/src/main/java/io/ballerina/shell/snippet/types/ImportDeclarationSnippet.java @@ -25,7 +25,6 @@ import io.ballerina.shell.utils.QuotedImport; import java.util.List; -import java.util.stream.Collectors; /** * Snippet that represent a import statement. @@ -59,7 +58,7 @@ public Identifier getPrefix() { */ public QuotedImport getImportedModule() { List moduleNames = rootNode.moduleName().stream().map(IdentifierToken::text) - .collect(Collectors.toList()); + .toList(); if (rootNode.orgName().isPresent()) { String orgName = rootNode.orgName().get().orgName().text(); return new QuotedImport(orgName, moduleNames); diff --git a/ballerina-shell/modules/shell-core/src/main/java/io/ballerina/shell/utils/ModuleImporter.java b/ballerina-shell/modules/shell-core/src/main/java/io/ballerina/shell/utils/ModuleImporter.java index 7c95fdd39cce..e7184dc9e272 100644 --- a/ballerina-shell/modules/shell-core/src/main/java/io/ballerina/shell/utils/ModuleImporter.java +++ b/ballerina-shell/modules/shell-core/src/main/java/io/ballerina/shell/utils/ModuleImporter.java @@ -39,7 +39,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; /** * Support class to add required import statements. @@ -113,7 +112,7 @@ public List undefinedModules(Collection diagnostics) { } } - return moduleErrors.stream().distinct().collect(Collectors.toList()); + return moduleErrors.stream().distinct().toList(); } /** diff --git a/ballerina-shell/modules/shell-core/src/main/java/io/ballerina/shell/utils/QuotedImport.java b/ballerina-shell/modules/shell-core/src/main/java/io/ballerina/shell/utils/QuotedImport.java index 17a0585ba711..e4aeb69475bd 100644 --- a/ballerina-shell/modules/shell-core/src/main/java/io/ballerina/shell/utils/QuotedImport.java +++ b/ballerina-shell/modules/shell-core/src/main/java/io/ballerina/shell/utils/QuotedImport.java @@ -21,7 +21,6 @@ import java.util.List; import java.util.Objects; import java.util.StringJoiner; -import java.util.stream.Collectors; /** * An import that has quoted orgname and module names. @@ -36,7 +35,7 @@ public QuotedImport(String orgName, List moduleNames) { this.orgName = orgName; this.moduleNames = moduleNames.stream() .map(Identifier::new) - .collect(Collectors.toList()); + .toList(); } public QuotedImport(List moduleNames) { diff --git a/ballerina-shell/modules/shell-core/src/test/java/io/ballerina/shell/test/unit/EvaluatorMiscTest.java b/ballerina-shell/modules/shell-core/src/test/java/io/ballerina/shell/test/unit/EvaluatorMiscTest.java index 91356a2eae12..bded26f3afd6 100644 --- a/ballerina-shell/modules/shell-core/src/test/java/io/ballerina/shell/test/unit/EvaluatorMiscTest.java +++ b/ballerina-shell/modules/shell-core/src/test/java/io/ballerina/shell/test/unit/EvaluatorMiscTest.java @@ -31,7 +31,6 @@ import java.util.List; import java.util.Optional; import java.util.Set; -import java.util.stream.Collectors; /** * Misc functionality testing of evaluator. @@ -169,6 +168,6 @@ private List filterAvailableVariables(Evaluator evaluator) { return evaluator.availableVariables().stream().filter(s -> !s.equals("Variable declarations") && !s.equals("Final variable declarations") && !s.equals("Constant Variable Declarations")) - .collect(Collectors.toList()); + .toList(); } } diff --git a/bvm/ballerina-profiler/src/main/java/io/ballerina/runtime/profiler/Profiler.java b/bvm/ballerina-profiler/src/main/java/io/ballerina/runtime/profiler/Profiler.java index 38ce6b8dc788..d27a2cdf794f 100644 --- a/bvm/ballerina-profiler/src/main/java/io/ballerina/runtime/profiler/Profiler.java +++ b/bvm/ballerina-profiler/src/main/java/io/ballerina/runtime/profiler/Profiler.java @@ -41,7 +41,6 @@ import java.util.concurrent.TimeUnit; import java.util.jar.JarFile; import java.util.regex.Pattern; -import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -236,7 +235,7 @@ private void modifyJar() throws InterruptedException, IOException { final File userDirectory = new File(System.getProperty("user.dir")); // Get the user directory listAllFiles(userDirectory); // List all files in the user directory and its subdirectories // Get a list of the directories containing instrumented files - List changedDirectories = instrumentedFiles.stream().distinct().collect(Collectors.toList()); + List changedDirectories = instrumentedFiles.stream().distinct().toList(); loadDirectories(changedDirectories); } finally { for (String instrumentedFilePath : instrumentedPaths) { diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/CommandUtil.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/CommandUtil.java index 97713deffcd8..8db23f80deec 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/CommandUtil.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/CommandUtil.java @@ -883,12 +883,12 @@ public static List getTemplates() { .map(directory -> directory.getFileName()) .filter(Objects::nonNull) .map(Path::toString) - .collect(Collectors.toList()); + .toList(); if (null != jarFs) { return templates.stream().map(t -> t .replace(jarFs.getSeparator(), "")) - .collect(Collectors.toList()); + .toList(); } else { return templates; } diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/launcher/util/BalToolsUtil.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/launcher/util/BalToolsUtil.java index 2560a8b06674..d92abf44ff4e 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/launcher/util/BalToolsUtil.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/launcher/util/BalToolsUtil.java @@ -44,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; import java.util.stream.Stream; import static io.ballerina.cli.cmd.Constants.ADD_COMMAND; @@ -189,7 +188,7 @@ private static List getToolCommandJarAndDependencyJars(String commandName) .resolve(TOOL).resolve(LIBS) .toFile())) .flatMap(List::stream) - .collect(Collectors.toList()); + .toList(); } Optional toolOpt = balToolsManifest.getActiveTool(commandName); @@ -280,7 +279,7 @@ public static void updateOldBalToolsToml() { } catch (ProjectException ignore) { return false; } - })).map(File::getName).collect(Collectors.toList()); + })).map(File::getName).toList(); Optional latestVersion = getLatestVersion(versions); versions.stream().forEach(version -> { diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunBuildToolsTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunBuildToolsTask.java index 75a5c96ff471..843b035b61d0 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunBuildToolsTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunBuildToolsTask.java @@ -368,6 +368,6 @@ private static List getToolCommandJarAndDependencyJars(List res .resolve(TOOL).resolve(LIBS) .toFile())) .flatMap(List::stream) - .collect(Collectors.toList()); + .toList(); } } diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunTestsTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunTestsTask.java index d5f7916730af..d6f54a96534d 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunTestsTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunTestsTask.java @@ -54,7 +54,6 @@ import java.util.Map; import java.util.Set; import java.util.regex.Pattern; -import java.util.stream.Collectors; import java.util.stream.Stream; import static io.ballerina.cli.launcher.LauncherUtils.createLauncherException; @@ -362,7 +361,7 @@ private List getAllSourceFilePaths(String projectRootString) throws IOExce private static List filterPathStream(Stream pathStream, String combinedPattern) { return pathStream.filter( FileSystems.getDefault().getPathMatcher("glob:" + combinedPattern)::matches) - .collect(Collectors.toList()); + .toList(); } private void getclassFromSourceFilePath(List sourcePatternList, Package currentPackage, diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java index a1ff0e62f014..2a4eae1000d1 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java @@ -61,7 +61,6 @@ import java.util.Map; import java.util.StringJoiner; import java.util.jar.JarOutputStream; -import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -603,9 +602,8 @@ public static String getClassPath(Map testSuiteMap) { dependencies.addAll(testSuiteEntry.getValue().getTestExecutionDependencies()); } - dependencies = dependencies.stream().distinct().collect(Collectors.toList()); - dependencies = dependencies.stream().map((x) -> convertWinPathToUnixFormat(addQuotationMarkToString(x))) - .collect(Collectors.toList()); + dependencies = dependencies.stream().distinct() + .map((x) -> convertWinPathToUnixFormat(addQuotationMarkToString(x))).toList(); StringJoiner classPath = new StringJoiner(File.pathSeparator); dependencies.forEach(classPath::add); diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/TestUtils.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/TestUtils.java index 065d74a00b28..a353342ada34 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/TestUtils.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/TestUtils.java @@ -62,12 +62,12 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.StringJoiner; -import java.util.stream.Collectors; import static io.ballerina.cli.launcher.LauncherUtils.createLauncherException; import static org.ballerinalang.test.runtime.util.TesterinaConstants.COVERAGE_DIR; @@ -482,11 +482,10 @@ private static String getFunctionToMockClassName(String id) { */ public static String getClassPath(JBallerinaBackend jBallerinaBackend, Package currentPackage) { JarResolver jarResolver = jBallerinaBackend.jarResolver(); + Set jars = new HashSet<>(getModuleJarPaths(jBallerinaBackend, currentPackage)); - List dependencies = getTestDependencyPaths(currentPackage, jarResolver); - - List jarList = getModuleJarPaths(jBallerinaBackend, currentPackage); - dependencies.removeAll(jarList); + List dependencies = getTestDependencyPaths(currentPackage, jarResolver) + .stream().filter(dependency -> !jars.contains(dependency)).toList(); StringJoiner classPath = joinClassPaths(dependencies); return classPath.toString(); @@ -522,7 +521,7 @@ public static List getTestDependencyPaths(Package currentPackage, JarResol } } } - return dependencies.stream().distinct().collect(Collectors.toList()); + return dependencies.stream().distinct().toList(); } /** @@ -549,7 +548,7 @@ public static List getModuleJarPaths(JBallerinaBackend jBallerinaBackend, } } - return moduleJarPaths.stream().distinct().collect(Collectors.toList()); + return moduleJarPaths.stream().distinct().toList(); } private static PlatformLibrary getCodeGeneratedTestLibrary(JBallerinaBackend jBallerinaBackend, diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/BallerinaKeywordsProvider.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/BallerinaKeywordsProvider.java index 3074c91bcf52..27bdb6383148 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/BallerinaKeywordsProvider.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/BallerinaKeywordsProvider.java @@ -20,7 +20,6 @@ import java.util.Collections; import java.util.List; import java.util.Objects; -import java.util.stream.Collectors; /** * Provides the set of Ballerina Reserved Keywords to be used at the symbol factory. @@ -55,7 +54,7 @@ private static List getBallerinaKeywords() { } }) .filter(Objects::nonNull) - .collect(Collectors.toList()); + .toList(); } catch (ClassNotFoundException e) { return Collections.emptyList(); } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/ExpectedTypeFinder.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/ExpectedTypeFinder.java index a0a16524bcf9..c19429826ce3 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/ExpectedTypeFinder.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/ExpectedTypeFinder.java @@ -132,7 +132,6 @@ import java.util.Objects; import java.util.Optional; import java.util.function.Predicate; -import java.util.stream.Collectors; import static io.ballerina.compiler.api.impl.PositionUtil.isPosWithinOpenCloseLineRanges; import static io.ballerina.compiler.api.impl.PositionUtil.isPosWithinRange; @@ -1062,7 +1061,7 @@ private List getModuleSymbols(QualifiedNameReferenceNode qNameRef, Optional module = searchModuleForAlias(alias); return module.map(moduleSymbol -> moduleSymbol.allSymbols().stream() .filter(predicate) - .collect(Collectors.toList())) + .toList()) .orElseGet(ArrayList::new); } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/ReferenceFinder.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/ReferenceFinder.java index 760d26ce9e14..902bb75932b8 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/ReferenceFinder.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/ReferenceFinder.java @@ -213,7 +213,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; import static org.ballerinalang.model.symbols.SymbolOrigin.VIRTUAL; @@ -265,10 +264,10 @@ public void visit(BLangPackage pkgNode) { find(pkgNode.typeDefinitions); find(pkgNode.classDefinitions.stream() .filter(c -> !isGeneratedClassDefForService(c)) - .collect(Collectors.toList())); + .toList()); find(pkgNode.functions.stream() .filter(f -> !f.flagSet.contains(Flag.LAMBDA)) - .collect(Collectors.toList())); + .toList()); if (!(pkgNode instanceof BLangTestablePackage)) { find(pkgNode.getTestablePkg()); diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/CompilerPluginManager.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/CompilerPluginManager.java index 6f2ba751ac43..9e4145a098f7 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/CompilerPluginManager.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/CompilerPluginManager.java @@ -26,7 +26,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; /** * Responsible for loading and maintaining engaged compiler plugins. @@ -171,7 +170,7 @@ private static CompilerPluginInfo loadCompilerPlugin(CompilerPluginDescriptor pl List jarLibraryPaths = pluginDescriptor.getCompilerPluginDependencies() .stream() .map(Paths::get) - .collect(Collectors.toList()); + .toList(); CompilerPlugin compilerPlugin; try { @@ -192,7 +191,7 @@ private static List getDirectDependencies(ResolvedPackageDependency roo return dependencyGraph.getDirectDependencies(rootPkgNode) .stream() .map(ResolvedPackageDependency::packageInstance) - .collect(Collectors.toList()); + .toList(); } private static List initializePlugins(List compilerPlugins, diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/CompletionManager.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/CompletionManager.java index 89bc515b5e41..fc84ee51c37d 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/CompletionManager.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/CompletionManager.java @@ -41,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; /** * Manages interaction with completion providers via compiler plugins. @@ -161,7 +160,7 @@ private List getModulesOfActiveListeners(CompletionContext context } return Optional.of(listenerType); }).filter(listenerType -> listenerType.isPresent() && listenerType.get().getModule().isPresent()) - .map(listenerType -> listenerType.get().getModule().get()).collect(Collectors.toList()); + .map(listenerType -> listenerType.get().getModule().get()).toList(); } private TypeSymbol getRawType(TypeSymbol typeDescriptor) { diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ConfigReader.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ConfigReader.java index 75e66cf1ecbb..fc35b719b2de 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ConfigReader.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ConfigReader.java @@ -50,7 +50,6 @@ import java.util.Map; import java.util.Optional; import java.util.Set; -import java.util.stream.Collectors; /** * Util class to read configurable variables defined in a package. @@ -303,16 +302,13 @@ private static Node getVariableNode(int position, Map synt for (Map.Entry syntaxTreeEntry : syntaxTreeMap.entrySet()) { if (syntaxTreeEntry.getValue().containsModulePart()) { ModulePartNode modulePartNode = syntaxTreeMap.get(syntaxTreeEntry.getKey()).rootNode(); - List filteredVarNodes = modulePartNode.members().stream() - .filter(node -> node.kind() == SyntaxKind.MODULE_VAR_DECL && - node instanceof ModuleVariableDeclarationNode) - .collect(Collectors.toList()); - for (Node node : filteredVarNodes) { - if (node.location().lineRange().startLine().line() <= position && - node.location().lineRange().endLine().line() >= position) { - return node; - } - } + return modulePartNode.members().stream() + .filter(node -> node.kind() == SyntaxKind.MODULE_VAR_DECL && + node instanceof ModuleVariableDeclarationNode && + node.location().lineRange().startLine().line() <= position && + node.location().lineRange().endLine().line() >= position) + .findFirst() + .orElse(null); } } return null; diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Diagnostics.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Diagnostics.java index 3d760d8ea644..0f93cd199cd3 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Diagnostics.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Diagnostics.java @@ -22,7 +22,6 @@ import java.util.Collection; import java.util.function.Predicate; -import java.util.stream.Collectors; /** * This class contains various static methods that operate on {@code Diagnostic} instances. @@ -72,7 +71,7 @@ private static Collection filterDiagnostics(Collection d Predicate predicate) { return diagnostics.stream() .filter(predicate) - .collect(Collectors.toList()); + .toList(); } private static boolean hasDiagnosticsWithSeverity(Collection diagnostics, diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBackend.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBackend.java index 4facf9078f8c..6ecd546befeb 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBackend.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBackend.java @@ -72,7 +72,6 @@ import java.util.jar.JarFile; import java.util.jar.JarInputStream; import java.util.jar.Manifest; -import java.util.stream.Collectors; import static io.ballerina.projects.util.FileUtils.getFileNameWithoutExtension; import static io.ballerina.projects.util.ProjectConstants.BIN_DIR_NAME; @@ -290,7 +289,7 @@ public Collection platformLibraryDependencies(PackageId package return getPlatformLibraries(packageId) .stream() .filter(platformLibrary -> platformLibrary.scope() == scope) - .collect(Collectors.toList()); + .toList(); } private List getPlatformLibraries(PackageId packageId) { diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleContext.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleContext.java index 12bf36df44bf..73b0754c448d 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleContext.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleContext.java @@ -45,6 +45,8 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; import java.util.Collection; import java.util.Collections; import java.util.HashSet; @@ -54,6 +56,7 @@ import java.util.Map; import java.util.Optional; import java.util.Set; +import java.util.function.Supplier; import static org.ballerinalang.model.tree.SourceKind.REGULAR_SOURCE; import static org.ballerinalang.model.tree.SourceKind.TEST_SOURCE; @@ -398,8 +401,12 @@ static void compileInternal(ModuleContext moduleContext, CompilerContext compile packageCache.putSymbol(pkgNode.packageID, pkgNode.symbol); compilerPhaseRunner.performTypeCheckPhases(pkgNode); } catch (Throwable t) { - assert false : "Compilation failed due to" + - (t.getMessage() != null ? ": " + t.getMessage() : " an unhandled exception"); + assert false : "Compilation failed due to " + ((Supplier) () -> { + StringWriter errors = new StringWriter(); + t.printStackTrace(new PrintWriter(errors)); + return errors.toString(); + }).get(); + compilerPhaseRunner.addDiagnosticForUnhandledException(pkgNode, t); } moduleContext.bLangPackage = pkgNode; @@ -417,8 +424,11 @@ static void generateCodeInternal(ModuleContext moduleContext, try { compilerPhaseRunner.performBirGenPhases(moduleContext.bLangPackage); } catch (Throwable t) { - assert false : "Compilation failed due to" + - (t.getMessage() != null ? ": " + t.getMessage() : " an unhandled exception"); + assert false : "Compilation failed due to " + ((Supplier) () -> { + StringWriter errors = new StringWriter(); + t.printStackTrace(new PrintWriter(errors)); + return errors.toString(); + }).get(); compilerPhaseRunner.addDiagnosticForUnhandledException(moduleContext.bLangPackage, t); return; } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/PackageResolution.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/PackageResolution.java index 90cb5f5f536f..c59091c276ba 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/PackageResolution.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/PackageResolution.java @@ -246,7 +246,7 @@ public Collection allDependencies() { .stream() // Remove root package from this list. .filter(resolvedPkg -> resolvedPkg.packageId() != rootPackageContext.packageId()) - .collect(Collectors.toList()); + .toList(); return dependenciesWithTransitives; } @@ -410,7 +410,7 @@ private DependencyGraph buildPackageGraph(DependencyG .filter(depNode -> !depNode.equals(rootNode) // Remove root node from the requests && !depNode.errorNode()) // Remove error nodes from the requests .map(this::createFromDepNode) - .collect(Collectors.toList()); + .toList(); Collection resolutionResponses = packageResolver.resolvePackages(resolutionRequests, resolutionOptions); @@ -447,7 +447,7 @@ private DependencyGraph buildPackageGraph(DependencyG .map(directDepNode -> resolvedPkgContainer.get( directDepNode.pkgDesc().org(), directDepNode.pkgDesc().name())) .flatMap(Optional::stream) - .collect(Collectors.toList()); + .toList(); depGraphBuilder.addDependencies(resolvedPkg, directPkgDependencies); } } @@ -552,7 +552,7 @@ private ModuleResolver createModuleResolver(PackageContext rootPackageContext, List moduleNames = rootPackageContext.moduleIds().stream() .map(rootPackageContext::moduleContext) .map(ModuleContext::moduleName) - .collect(Collectors.toList()); + .toList(); return new ModuleResolver(rootPackageContext.descriptor(), moduleNames, blendedManifest, projectEnvContext.getService(PackageResolver.class), resolutionOptions); } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/BalaFiles.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/BalaFiles.java index 69cdc6805d2d..c9f6349e9ef9 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/BalaFiles.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/BalaFiles.java @@ -205,7 +205,7 @@ private static List loadOtherModules(String pkgName, Path packagePat .filter(Files::isDirectory) .map(modulePath -> modulePath.getFileName().toString()) .map(fullModuleName -> loadModule(pkgName, fullModuleName, packagePath)) - .collect(Collectors.toList()); + .toList(); } catch (IOException e) { throw new ProjectException("Failed to read modules from directory: " + modulesDirPath, e); } @@ -654,7 +654,7 @@ private static ModuleDescriptor getModuleDescriptorFromDependencyEntry(ModuleDep private static List createModDescriptorList(List modDepEntries) { return modDepEntries.stream() .map(BalaFiles::getModuleDescriptorFromDependencyEntry) - .collect(Collectors.toList()); + .toList(); } private static DependencyGraphJson readDependencyGraphJson(Path dependencyGraphJsonPath) { diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/BlendedManifest.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/BlendedManifest.java index 7cb06b7c2dd1..f8387d892b41 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/BlendedManifest.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/BlendedManifest.java @@ -38,7 +38,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; import static io.ballerina.projects.PackageVersion.BUILTIN_PACKAGE_VERSION; @@ -187,7 +186,7 @@ private static Collection moduleNames(DependencyManifest.Package depende return dependency.modules() .stream() .map(DependencyManifest.Module::moduleName) - .collect(Collectors.toList()); + .toList(); } private static Collection moduleNames(PackageManifest.Dependency dependency, @@ -196,7 +195,7 @@ private static Collection moduleNames(PackageManifest.Dependency depende dependency.org(), dependency.name(), dependency.version()); return moduleDescriptors.stream() .map(moduleDesc -> moduleDesc.name().toString()) - .collect(Collectors.toList()); + .toList(); } public Optional lockedDependency(PackageOrg org, PackageName name) { @@ -235,7 +234,7 @@ private Optional dependency(PackageOrg org, PackageName name, Depend private Collection dependencies(DependencyOrigin origin) { return depContainer.getAll().stream() .filter(dep -> dep.origin == origin) - .collect(Collectors.toList()); + .toList(); } public DiagnosticResult diagnosticResult() { diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageConfigCreator.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageConfigCreator.java index b2e9913db2c0..b9b527f00681 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageConfigCreator.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageConfigCreator.java @@ -46,7 +46,7 @@ import java.util.Map; import java.util.Objects; import java.util.Set; -import java.util.stream.Collectors; +import java.util.stream.Stream; /** * Creates a {@code PackageConfig} instance from the given {@code PackageData} instance. @@ -146,14 +146,12 @@ private static PackageConfig createPackageConfig(PackageData packageData, PackageName packageName = packageManifest.name(); PackageId packageId = PackageId.create(packageName.value()); - List moduleConfigs = packageData.otherModules() - .stream() - .map(moduleData -> createModuleConfig(packageManifest.descriptor(), moduleData, - packageId, moduleDependencyGraph)) - .collect(Collectors.toList()); + List moduleConfigs = Stream.concat(packageData.otherModules().stream() + .map(moduleData -> createModuleConfig(packageManifest.descriptor(), moduleData, + packageId, moduleDependencyGraph)), + Stream.of(createDefaultModuleConfig(packageManifest.descriptor(), + packageData.defaultModule(), packageId, moduleDependencyGraph))).toList(); - moduleConfigs.add(createDefaultModuleConfig(packageManifest.descriptor(), - packageData.defaultModule(), packageId, moduleDependencyGraph)); DocumentConfig ballerinaToml = packageData.ballerinaToml() .map(data -> createDocumentConfig(data, null)).orElse(null); @@ -240,7 +238,7 @@ private static List getResourceConfigs(List resources, Pat // TODO: no need Remove duplicate paths before processing Set distinctResources = new HashSet<>(resources); return distinctResources.stream().map( - distinctResource -> createResourceConfig(distinctResource, packagePath)).collect(Collectors.toList()); + distinctResource -> createResourceConfig(distinctResource, packagePath)).toList(); } private static ResourceConfig createResourceConfig(Path path, Path packagePath) { @@ -253,7 +251,7 @@ private static List getDocumentConfigs(ModuleId moduleId, List createDocumentConfig(srcDoc, moduleId)) - .collect(Collectors.toList()); + .toList(); } static DocumentConfig createDocumentConfig(DocumentData documentData, ModuleId moduleId) { diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageContainer.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageContainer.java index 388e70059a10..253f4189a3ec 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageContainer.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageContainer.java @@ -25,7 +25,6 @@ import java.util.Map; import java.util.NoSuchElementException; import java.util.Optional; -import java.util.stream.Collectors; /** * A container for various package representation that provides efficient access to packages. @@ -81,6 +80,6 @@ public Collection getAll() { .stream() .map(Map::values) .flatMap(Collection::stream) - .collect(Collectors.toList()); + .toList(); } } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageDependencyGraphBuilder.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageDependencyGraphBuilder.java index ca46468fc549..5677f676cbe9 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageDependencyGraphBuilder.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageDependencyGraphBuilder.java @@ -43,7 +43,6 @@ import java.util.Objects; import java.util.Optional; import java.util.Set; -import java.util.stream.Collectors; /** * This class is responsible for creating the Package dependency graph with no version conflicts. @@ -145,7 +144,7 @@ public boolean containsNode(PackageDescriptor node) { public Collection getAllDependencies() { return vertices.values().stream() .filter(vertex -> !vertex.equals(rootDepNode)) - .collect(Collectors.toList()); + .toList(); } public DependencyGraph buildGraph() { @@ -176,7 +175,7 @@ public DependencyGraph buildGraph() { public Collection getUnresolvedNodes() { Collection unresolvedNodes = unresolvedVertices.stream() .map(vertices::get) - .collect(Collectors.toList()); + .toList(); this.unresolvedVertices = new HashSet<>(); return unresolvedNodes; } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageVersionContainer.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageVersionContainer.java index 1078e6318708..b7f26b6b79b3 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageVersionContainer.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageVersionContainer.java @@ -26,7 +26,6 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; /** * A container for various package representation that provides efficient access to packages. @@ -82,6 +81,6 @@ public Collection getAll() { .flatMap(Collection::stream) .map(Map::values) .flatMap(Collection::stream) - .collect(Collectors.toList()); + .toList(); } } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectFiles.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectFiles.java index bd139a1dc367..b76b2fdcb02d 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectFiles.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectFiles.java @@ -77,11 +77,8 @@ public static PackageData loadBuildProjectPackageData(Path packageDirPath) { ModuleData defaultModule = loadModule(packageDirPath); List otherModules = loadOtherModules(packageDirPath); List newModules = loadNewGeneratedModules(packageDirPath); - if (otherModules.isEmpty()) { - otherModules = newModules; - } else { - otherModules.addAll(newModules); - } + otherModules = Stream.concat(otherModules.stream(), newModules.stream()).toList(); + DocumentData ballerinaToml = loadDocument(packageDirPath.resolve(ProjectConstants.BALLERINA_TOML)); DocumentData dependenciesToml = loadDocument(packageDirPath.resolve(ProjectConstants.DEPENDENCIES_TOML)); DocumentData cloudToml = loadDocument(packageDirPath.resolve(ProjectConstants.CLOUD_TOML)); @@ -126,7 +123,7 @@ private static List loadNewGeneratedModules(Path packageDirPath) { return true; }) .map(ProjectFiles::loadModule) - .collect(Collectors.toList()); + .toList(); } catch (IOException e) { throw new ProjectException(e); } @@ -174,9 +171,9 @@ private static List loadOtherModules(Path packageDirPath) { private static ModuleData loadModule(Path moduleDirPath) { List srcDocs = loadDocuments(moduleDirPath); - List testSrcDocs; Path testDirPath = moduleDirPath.resolve("tests"); - testSrcDocs = Files.isDirectory(testDirPath) ? loadTestDocuments(testDirPath) : new ArrayList<>(); + List testSrcDocs = Files.isDirectory(testDirPath) ? loadTestDocuments(testDirPath) : + new ArrayList<>(); // If the module is not a newly generated module, explicitly load generated sources if (!ProjectConstants.GENERATED_MODULES_ROOT.equals(Optional.of( @@ -261,7 +258,7 @@ public static List loadResources(Path packagePath) { try (Stream pathStream = Files.walk(resourcesPath, 10)) { return pathStream .filter(Files::isRegularFile) - .collect(Collectors.toList()); + .toList(); } catch (IOException e) { throw new ProjectException(e); } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/environment/DefaultPackageResolver.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/environment/DefaultPackageResolver.java index 2087202311b1..42256bc7fc74 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/environment/DefaultPackageResolver.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/environment/DefaultPackageResolver.java @@ -165,7 +165,7 @@ public Collection resolvePackageMetadata(Collection centralLoadRequests = requests.stream() .filter(r -> !r.packageDescriptor().isBuiltInPackage()) - .collect(Collectors.toList()); + .toList(); Collection latestVersionsInCentral = centralRepo.getPackageMetadata(centralLoadRequests, options); @@ -207,7 +207,7 @@ public Collection resolvePackages(Collection resolvePackage(request, options)) - .collect(Collectors.toList()); + .toList(); } private ResolutionResponse resolvePackage(ResolutionRequest resolutionReq, ResolutionOptions options) { diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/model/BalToolDescriptor.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/model/BalToolDescriptor.java index b31bf54151d9..0fcdfa938ddf 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/model/BalToolDescriptor.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/model/BalToolDescriptor.java @@ -36,7 +36,6 @@ import java.util.Collections; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; import java.util.stream.Stream; /** @@ -201,7 +200,7 @@ private static List getDependenciesInDir(String pa return getToolJarsMatchingPattern(pattern, parentPath.get()).stream() .map(path1 -> new BalToolDescriptor.Dependency(path1.toString())) - .collect(Collectors.toList()); + .toList(); } private static List getToolJarsMatchingPattern(String pattern, Path parentPath) { diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/repositories/AbstractPackageRepository.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/repositories/AbstractPackageRepository.java index 45a6152f356b..f9c59655922a 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/repositories/AbstractPackageRepository.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/repositories/AbstractPackageRepository.java @@ -35,7 +35,6 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; @@ -149,15 +148,16 @@ private ImportModuleResponse getImportModuleLoadResponse(ImportModuleRequest imp private ImportModuleResponse getImportModuleResponse(ImportModuleRequest importModuleRequest, PackageName packageName, List packageVersions) { - Comparator comparator = (v1, v2) -> { - + packageVersions.sort((v1, v2) -> { + if (v1.equals(v2)) { + return 0; + } PackageVersion latest = getLatest(v1, v2); if (v1 == latest) { return -1; } return 1; - }; - packageVersions.sort(comparator); + }); for (PackageVersion packageVersion : packageVersions) { Collection moduleDescriptors = getModules( diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectUtils.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectUtils.java index 35d0470ea149..5a852a292f00 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectUtils.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectUtils.java @@ -93,7 +93,6 @@ import java.util.jar.Manifest; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -1251,7 +1250,7 @@ private static boolean isCorrectPatternPathMatch(Path absolutePath, Path package private static List filterPathStream(Stream pathStream, String combinedPattern) { return pathStream.filter( FileSystems.getDefault().getPathMatcher("glob:" + combinedPattern)::matches) - .collect(Collectors.toList()); + .toList(); } private static String getGlobFormatPattern(String pattern) { diff --git a/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/elements/PackageID.java b/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/elements/PackageID.java index f33bc65873cc..3c2f49be0890 100644 --- a/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/elements/PackageID.java +++ b/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/elements/PackageID.java @@ -166,7 +166,7 @@ private List createNameComps(Name name) { if (name == Names.DEFAULT_PACKAGE) { return Lists.of(Names.DEFAULT_PACKAGE); } - return Arrays.stream(name.value.split("\\.")).map(Name::new).collect(Collectors.toList()); + return Arrays.stream(name.value.split("\\.")).map(Name::new).toList(); } /** diff --git a/compiler/ballerina-lang/src/main/java/org/ballerinalang/repository/PackageSource.java b/compiler/ballerina-lang/src/main/java/org/ballerinalang/repository/PackageSource.java index 7438bfdaf9df..44a613423b53 100644 --- a/compiler/ballerina-lang/src/main/java/org/ballerinalang/repository/PackageSource.java +++ b/compiler/ballerina-lang/src/main/java/org/ballerinalang/repository/PackageSource.java @@ -49,6 +49,6 @@ public interface PackageSource extends PackageEntity { * * @return the package source entries iterator */ - List getPackageSourceEntries(); + List getPackageSourceEntries(); } diff --git a/compiler/ballerina-lang/src/main/java/org/ballerinalang/repository/fs/GeneralFSPackageRepository.java b/compiler/ballerina-lang/src/main/java/org/ballerinalang/repository/fs/GeneralFSPackageRepository.java index d3eaca1daca9..a7ddf1f68c7f 100644 --- a/compiler/ballerina-lang/src/main/java/org/ballerinalang/repository/fs/GeneralFSPackageRepository.java +++ b/compiler/ballerina-lang/src/main/java/org/ballerinalang/repository/fs/GeneralFSPackageRepository.java @@ -39,7 +39,6 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; import java.util.stream.Stream; /** @@ -258,8 +257,8 @@ public CompilerInput getPackageSourceEntry(String name) { } @Override - public List getPackageSourceEntries() { - return this.getEntryNames().stream().map(e -> new FSCompilerInput(e)).collect(Collectors.toList()); + public List getPackageSourceEntries() { + return this.getEntryNames().stream().map(e -> new FSCompilerInput(e)).toList(); } /** diff --git a/compiler/ballerina-lang/src/main/java/org/ballerinalang/toml/model/Manifest.java b/compiler/ballerina-lang/src/main/java/org/ballerinalang/toml/model/Manifest.java index fabef5d0a000..4e6174a690c7 100644 --- a/compiler/ballerina-lang/src/main/java/org/ballerinalang/toml/model/Manifest.java +++ b/compiler/ballerina-lang/src/main/java/org/ballerinalang/toml/model/Manifest.java @@ -59,7 +59,7 @@ public List getDependencies() { dependency.setMetadata(convertObjectToDependencyMetadata(entry.getValue())); return dependency; }) - .collect(Collectors.toList()); + .toList(); } private DependencyMetadata convertObjectToDependencyMetadata(Object obj) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/FileSystemProgramDirectory.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/FileSystemProgramDirectory.java index 084181d35d67..90bddfaa827a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/FileSystemProgramDirectory.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/FileSystemProgramDirectory.java @@ -44,7 +44,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import java.util.stream.Stream; import static org.wso2.ballerinalang.util.LambdaExceptionUtils.rethrow; @@ -83,7 +82,7 @@ public List getSourceFileNames() { fileNames = stream.map(ProjectDirs::getLastComp) .filter(ProjectDirs::isSourceFile) .map(Path::toString) - .collect(Collectors.toList()); + .toList(); } return fileNames; } catch (SecurityException | AccessDeniedException e) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/FileSystemProjectDirectory.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/FileSystemProjectDirectory.java index 250f664b07cf..23509921e643 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/FileSystemProjectDirectory.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/FileSystemProjectDirectory.java @@ -42,7 +42,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import java.util.stream.Stream; import static org.ballerinalang.repository.CompilerOutputEntry.Kind; @@ -94,7 +93,7 @@ public List getSourcePackageNames() { .filter(ProjectDirs::containsSourceFiles) .map(ProjectDirs::getLastComp) .map(Path::toString) - .collect(Collectors.toList()); + .toList(); } } catch (SecurityException | AccessDeniedException e) { throw new BLangCompilerException("permission denied: " + projectDirPath.toString()); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/optimizer/BIROptimizer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/optimizer/BIROptimizer.java index 216019271234..61a755adf31f 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/optimizer/BIROptimizer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/optimizer/BIROptimizer.java @@ -50,7 +50,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.stream.Collectors; /** * Optimize BIR. @@ -278,9 +277,8 @@ public void visit(BIRFunction birFunction) { birFunction.errorTable.forEach(ee -> this.optimizeNode(ee, funcOpEnv)); // Remove unused temp vars - birFunction.localVars = birFunction.localVars.stream() - .filter(l -> l.kind != VarKind.TEMP || !funcOpEnv.tempVars - .containsKey(l)).collect(Collectors.toList()); + birFunction.localVars = new ArrayList<>(birFunction.localVars.stream() + .filter(l -> l.kind != VarKind.TEMP || !funcOpEnv.tempVars.containsKey(l)).toList()); // Reuse lhs temp vars Set replaceableVarSet = new HashSet<>(); reuseTempVariables(birFunction.localVars, funcOpEnv.tempVarsList, replaceableVarSet); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ASTBuilderUtil.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ASTBuilderUtil.java index 4809b6ab33bc..d36bb7fe379e 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ASTBuilderUtil.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ASTBuilderUtil.java @@ -115,7 +115,6 @@ import java.util.ArrayList; import java.util.EnumSet; import java.util.List; -import java.util.stream.Collectors; import static org.ballerinalang.model.symbols.SymbolOrigin.VIRTUAL; @@ -904,7 +903,7 @@ public static BInvokableSymbol duplicateFunctionDeclarationSymbol(BInvokableSymb dupFuncSymbol.params = invokableSymbol.params.stream() .map(param -> duplicateParamSymbol(param, dupFuncSymbol)) - .collect(Collectors.toList()); + .toList(); if (dupFuncSymbol.restParam != null) { dupFuncSymbol.restParam = duplicateParamSymbol(invokableSymbol.restParam, dupFuncSymbol); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/AnnotationDesugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/AnnotationDesugar.java index d517961c4697..6fa8f65020e6 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/AnnotationDesugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/AnnotationDesugar.java @@ -98,7 +98,6 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import java.util.stream.Collectors; import static io.ballerina.runtime.api.constants.RuntimeConstants.UNDERSCORE; import static org.ballerinalang.model.symbols.SymbolOrigin.VIRTUAL; @@ -566,7 +565,7 @@ private void attachSchedulerPolicy(BLangFunction function) { private List getAnnotationList(AnnotatableNode node) { return node.getAnnotationAttachments().stream() .map(annotAttachment -> (BLangAnnotationAttachment) annotAttachment) - .collect(Collectors.toList()); + .toList(); } private BLangLambdaFunction defineAnnotations(List annAttachments, @@ -906,7 +905,7 @@ private BInvokableSymbol createInvokableSymbol(BLangFunction function, PackageID functionSymbol.retType = function.returnTypeNode.getBType(); functionSymbol.params = function.requiredParams.stream() .map(param -> param.symbol) - .collect(Collectors.toList()); + .toList(); functionSymbol.scope = new Scope(functionSymbol); functionSymbol.restParam = function.restParam != null ? function.restParam.symbol : null; functionSymbol.type = new BInvokableType(Collections.emptyList(), diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java index 0c6022e7ca6f..8aa47375a4d7 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java @@ -1841,7 +1841,7 @@ private void createVarDefStmts(BLangRecordVariable parentRecordVariable, BLangBl List keysToRemove = parentRecordVariable.variableList.stream() .map(var -> var.getKey().getValue()) - .collect(Collectors.toList()); + .toList(); BLangSimpleVariable filteredDetail = generateRestFilter(variableReference, pos, keysToRemove, restParamType, parentBlockStmt); @@ -1948,7 +1948,7 @@ private void createVarDefStmts(BLangErrorVariable parentErrorVariable, BLangBloc pos, detailTempVarDef.var.symbol); List keysToRemove = parentErrorVariable.detail.stream() .map(detail -> detail.key.getValue()) - .collect(Collectors.toList()); + .toList(); BLangSimpleVariable filteredDetail = generateRestFilter(detailVarRef, parentErrorVariable.pos, keysToRemove, parentErrorVariable.restDetail.getBType(), @@ -2120,7 +2120,7 @@ private BLangLambdaFunction generateEntriesToMapLambda(Location pos, BType const functionSymbol.retType = function.returnTypeNode.getBType(); functionSymbol.params = function.requiredParams.stream() .map(param -> param.symbol) - .collect(Collectors.toList()); + .toList(); functionSymbol.scope = env.scope; functionSymbol.type = new BInvokableType(Collections.singletonList(getStringAnyTupleType()), constraint, null); function.symbol = functionSymbol; @@ -2350,7 +2350,7 @@ private BLangLambdaFunction createFuncToFilterOutRestParam(BLangRecordVariable r Location location) { List fieldNamesToRemove = recordVariable.variableList.stream() .map(var -> var.getKey().getValue()) - .collect(Collectors.toList()); + .toList(); return createFuncToFilterOutRestParam(fieldNamesToRemove, location); } @@ -2406,7 +2406,7 @@ private BInvokableSymbol createReturnTrueStatement(Location pos, BLangFunction f functionSymbol.retType = function.returnTypeNode.getBType(); functionSymbol.params = function.requiredParams.stream() .map(param -> param.symbol) - .collect(Collectors.toList()); + .toList(); functionSymbol.scope = env.scope; functionSymbol.type = new BInvokableType(Collections.singletonList(getStringAnyTupleType()), getRestType(functionSymbol), symTable.booleanType, null); @@ -2900,7 +2900,7 @@ private void createVarRefAssignmentStmts(BLangRecordVarRef parentRecordVarRef, B List keysToRemove = parentRecordVarRef.recordRefFields.stream() .map(field -> field.variableName.value) - .collect(Collectors.toList()); + .toList(); BLangSimpleVariable filteredDetail = generateRestFilter(variableReference, pos, keysToRemove, restParamType, parentBlockStmt); @@ -8149,13 +8149,13 @@ public void visit(BLangArrowFunction bLangArrowFunction) { varNode.symbol.kind = SymbolKind.FUNCTION; varNode.symbol.owner = invokableEnv.scope.owner; enclScope.define(varNode.symbol.name, varNode.symbol); - }).map(varNode -> varNode.symbol).collect(Collectors.toList()); + }).map(varNode -> varNode.symbol).toList(); funcSymbol.params = paramSymbols; funcSymbol.restParam = getRestSymbol(funcNode); funcSymbol.retType = funcNode.returnTypeNode.getBType(); // Create function type. - List paramTypes = paramSymbols.stream().map(paramSym -> paramSym.type).collect(Collectors.toList()); + List paramTypes = new ArrayList<>(paramSymbols.stream().map(paramSym -> paramSym.type).toList()); funcNode.setBType(new BInvokableType(paramTypes, getRestType(funcSymbol), funcNode.returnTypeNode.getBType(), funcSymbol.type.tsymbol)); @@ -8458,7 +8458,7 @@ public void visit(BLangWorkerReceive workerReceiveNode) { @Override public void visit(BLangWorkerFlushExpr workerFlushExpr) { workerFlushExpr.workerIdentifierList = workerFlushExpr.cachedWorkerSendStmts - .stream().map(send -> send.workerIdentifier).distinct().collect(Collectors.toList()); + .stream().map(send -> send.workerIdentifier).distinct().toList(); result = workerFlushExpr; } @@ -8840,7 +8840,7 @@ List getVisibleXMLNSStmts(SymbolEnv env) { return nameBXMLNSSymbolMap.keySet().stream() .map(key -> this.stmtsToBePropagatedToQuery.get(key)) .filter(Objects::nonNull) - .collect(Collectors.toList()); + .toList(); } @Override diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ServiceDesugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ServiceDesugar.java index 1a811140783b..f5a8a18e74e0 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ServiceDesugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ServiceDesugar.java @@ -56,7 +56,6 @@ import java.util.Collections; import java.util.LinkedHashSet; import java.util.List; -import java.util.stream.Collectors; import static io.ballerina.runtime.api.constants.RuntimeConstants.UNDERSCORE; @@ -288,8 +287,7 @@ private void addMethodInvocation(Location pos, BLangSimpleVarRef varRef, BInvoka } void engageCustomServiceDesugar(BLangService service, SymbolEnv env) { - List expressionTypes = service.attachedExprs.stream().map(expression -> expression.getBType()) - .collect(Collectors.toList()); + List expressionTypes = service.attachedExprs.stream().map(expression -> expression.getBType()).toList(); service.serviceClass.functions.stream() .filter(fun -> Symbols.isResource(fun.symbol) || Symbols.isRemote(fun.symbol)) .forEach(func -> engageCustomResourceDesugar(func, env, expressionTypes)); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/packaging/repo/HomeBalaRepo.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/packaging/repo/HomeBalaRepo.java index 0adbe7affb41..33bdded07ae9 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/packaging/repo/HomeBalaRepo.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/packaging/repo/HomeBalaRepo.java @@ -37,7 +37,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; import java.util.stream.Stream; import static org.wso2.ballerinalang.compiler.packaging.Patten.path; @@ -49,14 +48,14 @@ public class HomeBalaRepo implements Repo { private Path repoLocation; private ZipConverter zipConverter; - private List supportedPlatforms = Arrays.stream(SUPPORTED_PLATFORMS).collect(Collectors.toList()); + private List supportedPlatforms = Stream.concat( + Arrays.stream(SUPPORTED_PLATFORMS), Stream.of("any")).toList(); private Map dependencyManifests; public HomeBalaRepo(Map dependencyManifests) { this.repoLocation = RepoUtils.createAndGetHomeReposPath().resolve(ProjectDirConstants.BALA_CACHE_DIR_NAME); this.dependencyManifests = dependencyManifests; this.zipConverter = new ZipConverter(this.repoLocation); - supportedPlatforms.add("any"); } @Override diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java index 7ec4a0e54bd7..4edbc78127c4 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java @@ -266,7 +266,7 @@ import java.util.Objects; import java.util.Set; import java.util.function.Predicate; -import java.util.stream.Collectors; +import java.util.stream.Stream; import static org.ballerinalang.model.tree.NodeKind.LITERAL; import static org.ballerinalang.util.BLangCompilerConstants.RETRY_MANAGER_OBJECT_SHOULD_RETRY_FUNC; @@ -1890,12 +1890,9 @@ private void checkDuplicateVarRefs(List varRefs, Set s } private List getVarRefs(BLangRecordVarRef varRef) { - List varRefs = varRef.recordRefFields.stream() - .map(e -> e.variableReference).collect(Collectors.toList()); - if (varRef.restParam != null) { - varRefs.add(varRef.restParam); - } - return varRefs; + return Stream.concat( + varRef.recordRefFields.stream().map(e -> e.variableReference), + Stream.ofNullable(varRef.restParam)).toList(); } private List getVarRefs(BLangErrorVarRef varRef) { @@ -2904,7 +2901,7 @@ public void visit(BLangWorkerFlushExpr workerFlushExpr, AnalyzerData data) { List sendsToGivenWrkr = sendStmts.stream() .filter(bLangNode -> bLangNode.workerIdentifier.equals (flushWrkIdentifier)) - .collect(Collectors.toList()); + .toList(); if (sendsToGivenWrkr.isEmpty()) { this.dlog.error(workerFlushExpr.pos, DiagnosticErrorCode.INVALID_WORKER_FLUSH_FOR_WORKER, workerFlushExpr.workerSymbol, currentWrkerAction.currentWorkerId()); @@ -2928,7 +2925,7 @@ private List getAsyncSendStmtsOfWorker(WorkerActionSys return actions.stream() .filter(CodeAnalyzer::isWorkerSend) .map(bLangNode -> (BLangWorkerAsyncSendExpr) bLangNode) - .collect(Collectors.toList()); + .toList(); } @Override public void visit(BLangTrapExpr trapExpr, AnalyzerData data) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CompilerPluginRunner.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CompilerPluginRunner.java index 2f9aa1cbc128..bcc47211e0fc 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CompilerPluginRunner.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CompilerPluginRunner.java @@ -71,7 +71,6 @@ import java.util.Set; import java.util.function.BiConsumer; import java.util.function.Consumer; -import java.util.stream.Collectors; /** * Invoke {@link CompilerPlugin} plugins. @@ -400,7 +399,7 @@ private void handleServiceTypeProcesses(CompilerPlugin plugin) { } List definitions = Arrays.stream(supportedTypes) - .map(type -> new DefinitionID(type.packageName(), type.name())).collect(Collectors.toList()); + .map(type -> new DefinitionID(type.packageName(), type.name())).toList(); resourceTypeProcessorMap.put(plugin, definitions); serviceListenerMap.put(plugin, listenerType); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java index a9ff73a9e295..4ff22f030b2f 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java @@ -1562,7 +1562,7 @@ private List createKeyArray(BLangRecordLiteral literal, List getFieldNames(BLangTableConstructorExpr constructorExpr) { @@ -1577,7 +1577,7 @@ private List getFieldNames(BLangTableConstructorExpr constructorExpr) { !constructorExpr.tableKeySpecifier.fieldNameIdentifierList.isEmpty()) { BLangTableKeySpecifier tableKeySpecifier = constructorExpr.tableKeySpecifier; return tableKeySpecifier.fieldNameIdentifierList.stream().map(identifier -> - ((BLangIdentifier) identifier).value).collect(Collectors.toList()); + ((BLangIdentifier) identifier).value).toList(); } else { return new ArrayList<>(); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/QueryTypeChecker.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/QueryTypeChecker.java index a6b105571df4..dd92270be20c 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/QueryTypeChecker.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/QueryTypeChecker.java @@ -97,7 +97,6 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; import static org.ballerinalang.model.symbols.SymbolOrigin.VIRTUAL; import static org.ballerinalang.util.diagnostic.DiagnosticErrorCode.INVALID_QUERY_CONSTRUCT_INFERRED_MAP; @@ -283,10 +282,10 @@ public BType resolveQueryType(SymbolEnv env, BLangExpression selectExp, BType ta List safeResultTypes = types.getAllTypes(targetType, true).stream() .filter(t -> !types.isAssignable(t, symTable.errorType)) .filter(t -> !types.isAssignable(t, symTable.nilType)) - .collect(Collectors.toList()); + .toList(); // resultTypes will be empty if the targetType is `error?` if (safeResultTypes.isEmpty()) { - safeResultTypes.add(symTable.noType); + safeResultTypes = List.of(symTable.noType); } BType actualType = symTable.semanticError; List selectTypes = new ArrayList<>(); @@ -497,7 +496,7 @@ private BType getQueryTableType(BLangQueryExpr queryExpr, BType constraintType, validateKeySpecifier(queryExpr.fieldNameIdentifierList, constraintType); markReadOnlyForConstraintType(constraintType); tableType.fieldNameList = queryExpr.fieldNameIdentifierList.stream() - .map(identifier -> ((BLangIdentifier) identifier).value).collect(Collectors.toList()); + .map(identifier -> ((BLangIdentifier) identifier).value).toList(); } if (Symbols.isFlagOn(resolvedType.flags, Flags.READONLY)) { return ImmutableTypeCloner.getImmutableIntersectionType(null, types, @@ -643,7 +642,7 @@ private List getCollectionTypes(List clauses) { return clauses.stream() .filter(clause -> (clause.getKind() == NodeKind.FROM || clause.getKind() == NodeKind.JOIN)) .map(clause -> ((BLangInputClause) clause).collection.getBType()) - .collect(Collectors.toList()); + .toList(); } private BType getResolvedType(BType initType, BType expType, boolean isReadonly, SymbolEnv env) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/ReachabilityAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/ReachabilityAnalyzer.java index d6a2c6255837..a169ec2ad9ff 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/ReachabilityAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/ReachabilityAnalyzer.java @@ -106,7 +106,7 @@ import java.util.ArrayList; import java.util.Deque; import java.util.List; -import java.util.stream.Collectors; +import java.util.stream.Stream; import static org.wso2.ballerinalang.compiler.util.Constants.WORKER_LAMBDA_VAR_PREFIX; @@ -962,10 +962,9 @@ private void handlePotentiallyInvalidAssignmentsToTypeNarrowedVariablesInLoop( } private List getVarRefs(BLangRecordVarRef varRef) { - List varRefs = varRef.recordRefFields.stream() - .map(e -> e.variableReference).collect(Collectors.toList()); - varRefs.add(varRef.restParam); - return varRefs; + return Stream.concat( + varRef.recordRefFields.stream().map(e -> e.variableReference), + Stream.of(varRef.restParam)).toList(); } private List getVarRefs(BLangErrorVarRef varRef) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java index 3be064dc6bc3..943baf159e6b 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java @@ -2713,7 +2713,7 @@ boolean validateRecordVariable(BLangRecordVariable recordVar, SymbolEnv env) { Set bTypes = types.expandAndGetMemberTypesRecursive(unionType); List possibleTypes = bTypes.stream() .filter(rec -> doesRecordContainKeys(rec, recordVar.variableList, recordVar.restParam != null)) - .collect(Collectors.toList()); + .toList(); if (possibleTypes.isEmpty()) { dlog.error(recordVar.pos, DiagnosticErrorCode.INVALID_RECORD_BINDING_PATTERN, recordType); @@ -2764,7 +2764,7 @@ private BRecordType populatePossibleFields(BLangRecordVariable recordVar, List mappedFields = recordVar.variableList.stream().map(varKeyValue -> varKeyValue.getKey().value) - .collect(Collectors.toList()); + .toList(); LinkedHashMap fields = populateAndGetPossibleFieldsForRecVar(recordVar.pos, possibleTypes, mappedFields, recordSymbol, env); @@ -2993,7 +2993,7 @@ private boolean defineVariableList(BLangRecordVariable recordVar, BRecordType re if (recordVar.restParam != null) { BType restType = getRestParamType(recordVarType); List varList = recordVar.variableList.stream().map(t -> t.getKey().value) - .collect(Collectors.toList()); + .toList(); BRecordType restConstraint = createRecordTypeForRestField(recordVar.restParam.getPosition(), env, recordVarType, varList, restType); defineMemberNode(recordVar.restParam, env, restConstraint); @@ -4604,9 +4604,9 @@ void defineInvokableSymbolParams(BLangInvokableNode invokableNode, BInvokableSym symResolver.validateInferTypedescParams(invokableNode.pos, invokableNode.getParameters(), retType); // Create function type - List paramTypes = paramSymbols.stream() + List paramTypes = new ArrayList<>(paramSymbols.stream() .map(paramSym -> paramSym.type) - .collect(Collectors.toList()); + .toList()); BInvokableTypeSymbol functionTypeSymbol = Symbols.createInvokableTypeSymbol(SymTag.FUNCTION_TYPE, invokableSymbol.flags, @@ -4865,7 +4865,7 @@ private BAttachedFunction createResourceFunction(BLangFunction funcNode, BInvoka p.symbol.kind = SymbolKind.PATH_PARAMETER; return p.symbol; }) - .collect(Collectors.toList()); + .toList(); BVarSymbol restPathParamSym = null; if (resourceFunction.restPathParam != null) { @@ -5155,7 +5155,7 @@ private void resolveIncludedFields(BLangStructureTypeNode structureTypeNode) { var.flagSet = field.symbol.getFlags(); return var; }); - }).collect(Collectors.toList()); + }).toList(); structureTypeNode.typeRefs.removeAll(invalidTypeRefs); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java index a1f73ea3503a..709cc373a601 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java @@ -1676,15 +1676,13 @@ private boolean validateTableConstructorExpr(BLangTableConstructorExpr tableCons switch (referredKeyTypeConstraint.tag) { case TypeTags.TUPLE: - for (BType type : ((BTupleType) referredKeyTypeConstraint).getTupleTypes()) { - memberTypes.add(type); - } + memberTypes.addAll(((BTupleType) referredKeyTypeConstraint).getTupleTypes()); break; case TypeTags.RECORD: Map fieldList = ((BRecordType) referredKeyTypeConstraint).getFields(); - memberTypes = fieldList.entrySet().stream() + memberTypes.addAll(fieldList.entrySet().stream() .filter(e -> fieldNameList.contains(e.getKey())).map(entry -> entry.getValue().type) - .collect(Collectors.toList()); + .toList()); if (memberTypes.isEmpty()) { memberTypes.add(keyTypeConstraint); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeResolver.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeResolver.java index c245f3d698c1..2e4e4d944cdb 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeResolver.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeResolver.java @@ -125,7 +125,6 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import java.util.stream.Collectors; import static org.ballerinalang.model.symbols.SymbolOrigin.BUILTIN; import static org.ballerinalang.model.symbols.SymbolOrigin.SOURCE; @@ -1936,7 +1935,7 @@ public void resolveConstant(SymbolEnv symEnv, Map modTable, B if (resolvingConstants.contains(constant)) { // To identify cycles. dlog.error(constant.pos, DiagnosticErrorCode.CONSTANT_CYCLIC_REFERENCE, (this.resolvingConstants).stream().map(constNode -> constNode.symbol) - .collect(Collectors.toList())); + .toList()); constant.setBType(symTable.semanticError); return; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/cyclefind/GlobalVariableRefAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/cyclefind/GlobalVariableRefAnalyzer.java index 185935e5bb5d..e91e441a25ae 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/cyclefind/GlobalVariableRefAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/cyclefind/GlobalVariableRefAnalyzer.java @@ -291,7 +291,7 @@ private List analyzeDependenciesStartingFrom(BSymbol symbol) { if (!dependencyOrder.isEmpty()) { List symbolsProvidersOrdered = this.dependencyOrder.stream() .map(nodeInfo -> nodeInfo.symbol) - .collect(Collectors.toList()); + .toList(); this.dependencyOrder.clear(); return symbolsProvidersOrdered; } @@ -382,7 +382,7 @@ private void projectSortToGlobalVarsList(Set sorted) { List sortedGlobalVars = sorted.stream() .filter(varMap::containsKey) .map(varMap::get) - .collect(Collectors.toList()); + .toList(); if (sortedGlobalVars.size() != this.pkgNode.globalVars.size()) { List symbolLessGlobalVars = this.pkgNode.globalVars.stream() @@ -401,7 +401,7 @@ private void sortConstants(Set sorted) { List sortedConstants = sorted.stream() .filter(varMap::containsKey) .map(varMap::get) - .collect(Collectors.toList()); + .toList(); if (sortedConstants.size() != this.pkgNode.constants.size()) { List symbolLessGlobalVars = this.pkgNode.constants.stream() @@ -487,7 +487,7 @@ private void handleCyclicReferenceError(NodeInfo node) { Collections.reverse(cycle); List symbolsOfCycle = cycle.stream() .map(n -> n.symbol) - .collect(Collectors.toList()); + .toList(); if (doesContainAGlobalVar(symbolsOfCycle)) { emitErrorMessage(symbolsOfCycle); @@ -520,7 +520,7 @@ private void emitErrorMessage(List symbolsOfCycle) { secondSubList.addAll(firstSubList); List names = secondSubList.stream() - .map(this::getNodeName).filter(Objects::nonNull).collect(Collectors.toList()); + .map(this::getNodeName).filter(Objects::nonNull).toList(); dlog.error(firstNode.get().getPosition(), DiagnosticErrorCode.GLOBAL_VARIABLE_CYCLIC_DEFINITION, names); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangImportPackage.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangImportPackage.java index c5a925aaadb1..787a20f966f6 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangImportPackage.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangImportPackage.java @@ -24,7 +24,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; /** * @since 0.94 @@ -136,7 +135,7 @@ public String getQualifiedPackageName() { String orgName = this.orgName.toString(); String pkgName = String.join(".", pkgNameComps.stream() .map(id -> id.value) - .collect(Collectors.toList())); + .toList()); String versionStr = (this.version.value != null) ? this.version.value : ""; if (!versionStr.isEmpty()) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/util/NodeUtils.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/util/NodeUtils.java index 4cd60292e32b..7d11bf155ef1 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/util/NodeUtils.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/util/NodeUtils.java @@ -21,7 +21,6 @@ import org.wso2.ballerinalang.compiler.tree.BLangIdentifier; import java.util.List; -import java.util.stream.Collectors; /** * @since 0.94 @@ -53,7 +52,7 @@ public static Name getName(String localname, String namespaceURI) { public static PackageID getPackageID(Names names, BLangIdentifier orgNameNode, List pkgNameComps, BLangIdentifier versionNode) { - List nameList = pkgNameComps.stream().map(names::fromIdNode).collect(Collectors.toList()); + List nameList = pkgNameComps.stream().map(names::fromIdNode).toList(); Name orgName = null; if (orgNameNode != null) { orgName = names.fromIdNode(orgNameNode); diff --git a/compiler/ballerina-lang/src/test/java/io/ballerina/projects/test/resolution/packages/internal/DefaultPackageRepository.java b/compiler/ballerina-lang/src/test/java/io/ballerina/projects/test/resolution/packages/internal/DefaultPackageRepository.java index 2eb83679eb66..2eaaefc03c08 100644 --- a/compiler/ballerina-lang/src/test/java/io/ballerina/projects/test/resolution/packages/internal/DefaultPackageRepository.java +++ b/compiler/ballerina-lang/src/test/java/io/ballerina/projects/test/resolution/packages/internal/DefaultPackageRepository.java @@ -89,7 +89,7 @@ public Collection getModules(PackageOrg org, PackageName name, return pkgDescWrapper.modules().stream() .map(modNameStr -> Utils.getModuleName(name, modNameStr)) .map(moduleName -> ModuleDescriptor.from(moduleName, pkgDesc)) - .collect(Collectors.toList()); + .toList(); } @Override diff --git a/compiler/ballerina-lang/src/test/java/io/ballerina/projects/test/resolution/packages/internal/GraphUtils.java b/compiler/ballerina-lang/src/test/java/io/ballerina/projects/test/resolution/packages/internal/GraphUtils.java index 923ed61309ba..815a627cdc93 100644 --- a/compiler/ballerina-lang/src/test/java/io/ballerina/projects/test/resolution/packages/internal/GraphUtils.java +++ b/compiler/ballerina-lang/src/test/java/io/ballerina/projects/test/resolution/packages/internal/GraphUtils.java @@ -25,7 +25,6 @@ import java.util.Collection; import java.util.Comparator; import java.util.List; -import java.util.stream.Collectors; /** * Contains a list of utility methods to work with Ballerina dependency graphs. @@ -84,7 +83,7 @@ public static GraphComparisonResult compareGraph(DependencyGraph } private static List getSortedCollection(Collection nodes) { - return nodes.stream().sorted(pkgDescComparator).collect(Collectors.toList()); + return nodes.stream().sorted(pkgDescComparator).toList(); } private static GraphComparisonResult reportGraphsWithDifferentNumberOfNodes( diff --git a/compiler/ballerina-lang/src/test/java/io/ballerina/projects/test/resolution/packages/internal/PackageRepositoryBuilder.java b/compiler/ballerina-lang/src/test/java/io/ballerina/projects/test/resolution/packages/internal/PackageRepositoryBuilder.java index c17b760de7ad..cad1d6aa8a1c 100644 --- a/compiler/ballerina-lang/src/test/java/io/ballerina/projects/test/resolution/packages/internal/PackageRepositoryBuilder.java +++ b/compiler/ballerina-lang/src/test/java/io/ballerina/projects/test/resolution/packages/internal/PackageRepositoryBuilder.java @@ -35,7 +35,6 @@ import java.util.Optional; import java.util.Set; import java.util.StringJoiner; -import java.util.stream.Collectors; import java.util.stream.Stream; /** @@ -90,7 +89,7 @@ private PackageRepository buildLocalRepo(Path localRepoDirPath) { } try (Stream paths = Files.list(localRepoDirPath)) { - return buildLocalRepo(paths.collect(Collectors.toList())); + return buildLocalRepo(paths.toList()); } catch (IOException e) { throw new RuntimeException(e); } @@ -211,7 +210,7 @@ List getUnmarkedNodes() { return marker.entrySet().stream() .filter(entry -> entry.getValue() == Boolean.FALSE) .map(Map.Entry::getKey) - .collect(Collectors.toList()); + .toList(); } } } diff --git a/compiler/ballerina-lang/src/test/java/io/ballerina/projects/test/resolution/packages/internal/PackageResolutionTestCaseBuilder.java b/compiler/ballerina-lang/src/test/java/io/ballerina/projects/test/resolution/packages/internal/PackageResolutionTestCaseBuilder.java index 38a11f537323..741c34aeb632 100644 --- a/compiler/ballerina-lang/src/test/java/io/ballerina/projects/test/resolution/packages/internal/PackageResolutionTestCaseBuilder.java +++ b/compiler/ballerina-lang/src/test/java/io/ballerina/projects/test/resolution/packages/internal/PackageResolutionTestCaseBuilder.java @@ -48,7 +48,6 @@ import java.util.List; import java.util.Objects; import java.util.Set; -import java.util.stream.Collectors; /** * Builds package resolution test cases. @@ -101,7 +100,7 @@ private static List getModulesInRootPackage(PackageDescWrapper rootP PackageDescriptor rootPkgDes) { return rootPkgDescWrapper.modules().stream() .map(modNameStr -> Utils.getModuleName(rootPkgDes.name(), modNameStr)) - .collect(Collectors.toList()); + .toList(); } private static DependencyGraph getPkgDescGraph(Path dotFilePath) { diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/AbstractNodeFactory.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/AbstractNodeFactory.java index fa8be955f1e1..3fe4c81fc3d0 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/AbstractNodeFactory.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/AbstractNodeFactory.java @@ -26,7 +26,6 @@ import java.util.Collection; import java.util.Collections; import java.util.Objects; -import java.util.stream.Collectors; /** * A factory for creating nodes in the syntax tree. @@ -159,7 +158,7 @@ public static MinutiaeList createMinutiaeList(Collection minutiaeNodes minutiaeNodes.stream() .map(minutiae -> Objects.requireNonNull(minutiae, "minutiae should not be null")) .map(Minutiae::internalNode) - .collect(Collectors.toList())), 0); + .toList()), 0); } public static Minutiae createCommentMinutiae(String text) { @@ -204,7 +203,7 @@ public static NodeList createNodeList(Collection nodes) { nodes.stream() .map(node -> Objects.requireNonNull(node, "node should not be null")) .map(Node::internalNode) - .collect(Collectors.toList())).createUnlinkedFacade()); + .toList()).createUnlinkedFacade()); } public static SeparatedNodeList createSeparatedNodeList(Node... nodes) { @@ -217,12 +216,12 @@ public static SeparatedNodeList createSeparatedNodeList(Node return new SeparatedNodeList<>(STNodeFactory.createNodeList(internalNodes).createUnlinkedFacade()); } - public static SeparatedNodeList createSeparatedNodeList(Collection nodes) { + public static SeparatedNodeList createSeparatedNodeList(Collection nodes) { return new SeparatedNodeList<>(STNodeFactory.createNodeList( nodes.stream() .map(node -> Objects.requireNonNull(node, "node should not be null")) .map(Node::internalNode) - .collect(Collectors.toList())).createUnlinkedFacade()); + .toList()).createUnlinkedFacade()); } protected static STNode getOptionalSTNode(Node node) { diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/MinutiaeList.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/MinutiaeList.java index 5f6282b7b093..a9ddad56e51c 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/MinutiaeList.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/MinutiaeList.java @@ -28,7 +28,6 @@ import java.util.Iterator; import java.util.List; import java.util.Objects; -import java.util.stream.Collectors; import static io.ballerina.compiler.internal.syntax.NodeListUtils.rangeCheck; import static io.ballerina.compiler.internal.syntax.NodeListUtils.rangeCheckForAdd; @@ -87,7 +86,7 @@ public MinutiaeList addAll(Collection c) { List stNodesToBeAdded = c.stream() .map(minutiae -> Objects.requireNonNull(minutiae, "minutiae should not be null")) .map(Minutiae::internalNode) - .collect(Collectors.toList()); + .toList(); return new MinutiaeList(token, internalListNode.addAll(stNodesToBeAdded), position); diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeList.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeList.java index 0ed45bc3a307..d11de17d2817 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeList.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeList.java @@ -26,7 +26,6 @@ import java.util.Iterator; import java.util.List; import java.util.Objects; -import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; @@ -85,7 +84,7 @@ public NodeList addAll(Collection c) { List stNodesToBeAdded = c.stream() .map(node -> Objects.requireNonNull(node, "node should not be null")) .map(Node::internalNode) - .collect(Collectors.toList()); + .toList(); return new NodeList<>(internalListNode.addAll(stNodesToBeAdded).createUnlinkedFacade()); } diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NonTerminalNode.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NonTerminalNode.java index 7472d0f412a3..c7006d8a0cbd 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NonTerminalNode.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NonTerminalNode.java @@ -29,7 +29,6 @@ import java.util.Collections; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; import java.util.stream.IntStream; import static io.ballerina.compiler.internal.syntax.SyntaxUtils.isSTNodePresent; @@ -71,7 +70,7 @@ public Collection childEntries() { IntStream.range(0, bucketCount()) .filter(bucket -> childInBucket(bucket) != null) .mapToObj(bucket -> new ChildNodeEntry(childNames[bucket], childInBucket(bucket))) - .collect(Collectors.toList())); + .toList()); } @Override diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/SyntaxInfo.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/SyntaxInfo.java index 7e72066764ed..17c351c6560a 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/SyntaxInfo.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/SyntaxInfo.java @@ -22,7 +22,6 @@ import java.util.Arrays; import java.util.List; -import java.util.stream.Collectors; /** * A class that provides syntax related information. @@ -34,7 +33,7 @@ public final class SyntaxInfo { private static final List BALLERINA_KEYWORDS = Arrays.stream(SyntaxKind.values()) .filter(syntaxKind -> SyntaxKind.RE_KEYWORD.compareTo(syntaxKind) > 0) .map(SyntaxKind::stringValue) - .collect(Collectors.toList()); + .toList(); private SyntaxInfo() { } diff --git a/compiler/ballerina-treegen/src/main/java/io/ballerinalang/compiler/internal/treegen/targets/node/AbstractNodeTarget.java b/compiler/ballerina-treegen/src/main/java/io/ballerinalang/compiler/internal/treegen/targets/node/AbstractNodeTarget.java index 3f4509c5721a..47839a859c20 100644 --- a/compiler/ballerina-treegen/src/main/java/io/ballerinalang/compiler/internal/treegen/targets/node/AbstractNodeTarget.java +++ b/compiler/ballerina-treegen/src/main/java/io/ballerinalang/compiler/internal/treegen/targets/node/AbstractNodeTarget.java @@ -27,7 +27,6 @@ import java.util.HashMap; import java.util.List; -import java.util.stream.Collectors; /** * The class {@code AbstractNodeTarget} represent a generic entity that converts a @@ -57,7 +56,7 @@ public List execute(SyntaxTree syntaxTree, HashMap generateNodeClass(syntaxNode, nodeMetadataMap)) .map(treeNodeClass -> getSourceText(treeNodeClass, getOutputDir(), getClassName(treeNodeClass))) - .collect(Collectors.toList()); + .toList(); } private TreeNodeClass generateNodeClass(SyntaxNode syntaxNode, HashMap generateNodeClasses(SyntaxTree syntaxTree, .stream() .map(syntaxNode -> convertToTreeNodeClass(syntaxNode, getPackageName(), new ArrayList<>(), nodeMetadataMap)) - .collect(Collectors.toList()); + .toList(); } protected abstract String getPackageName(); diff --git a/compiler/linter-plugin/src/test/java/io/ballerina/compiler/linter/codeactions/test/CodeActionUtils.java b/compiler/linter-plugin/src/test/java/io/ballerina/compiler/linter/codeactions/test/CodeActionUtils.java index 26b52f660687..ab66d1c39fa8 100644 --- a/compiler/linter-plugin/src/test/java/io/ballerina/compiler/linter/codeactions/test/CodeActionUtils.java +++ b/compiler/linter-plugin/src/test/java/io/ballerina/compiler/linter/codeactions/test/CodeActionUtils.java @@ -38,7 +38,6 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; -import java.util.stream.Collectors; /** * Helper methods for writing code action tests. @@ -85,7 +84,7 @@ public static List getCodeActions(Project project, Path filePath // Get codeactions for the diagnostic return codeActionManager.codeActions(context).getCodeActions().stream(); }) - .collect(Collectors.toList()); + .toList(); } /** @@ -108,7 +107,7 @@ public static List executeCodeAction(Project project, Path filePat Gson gson = new Gson(); List codeActionArguments = codeAction.getArguments().stream() .map(arg -> CodeActionArgument.from(gson.toJsonTree(arg))) - .collect(Collectors.toList()); + .toList(); CodeActionExecutionContext executionContext = CodeActionExecutionContextImpl.from( filePath.toUri().toString(), diff --git a/docs/bir-spec/src/test/java/org/ballerinalang/birspec/BIRTestUtils.java b/docs/bir-spec/src/test/java/org/ballerinalang/birspec/BIRTestUtils.java index a270be73148d..40b517824cb1 100644 --- a/docs/bir-spec/src/test/java/org/ballerinalang/birspec/BIRTestUtils.java +++ b/docs/bir-spec/src/test/java/org/ballerinalang/birspec/BIRTestUtils.java @@ -50,7 +50,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.stream.Collectors; import java.util.stream.Stream; /** @@ -87,7 +86,7 @@ private static List findBallerinaSourceFiles(Path testSourcesPath) throw return paths.filter(file -> Files.isRegularFile(file)) .map(file -> file.toAbsolutePath().normalize().toString()) .filter(file -> file.endsWith(".bal") && !file.contains("negative") && !file.contains("subtype")) - .collect(Collectors.toList()); + .toList(); } } diff --git a/docs/language-server/CompilerPluginCodeActions.md b/docs/language-server/CompilerPluginCodeActions.md index df3362171c3b..043d3b40f834 100644 --- a/docs/language-server/CompilerPluginCodeActions.md +++ b/docs/language-server/CompilerPluginCodeActions.md @@ -321,7 +321,7 @@ public class CodeActionUtils { // Get codeactions for the diagnostic return codeActionManager.codeActions(context).getCodeActions().stream(); }) - .collect(Collectors.toList()); + .toList(); } } ``` @@ -387,7 +387,7 @@ public class CodeActionUtils { // JsonElements to objects via deserialization. List codeActionArguments = codeAction.getArguments().stream() .map(arg -> CodeActionArgument.from(GSON.toJsonTree(arg))) - .collect(Collectors.toList()); + .toList(); CodeActionExecutionContext executionContext = CodeActionExecutionContextImpl.from( filePath.toUri().toString(), diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/BallerinaTextDocumentService.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/BallerinaTextDocumentService.java index 7b6fcc24e9a5..23ec7b07b38c 100755 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/BallerinaTextDocumentService.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/BallerinaTextDocumentService.java @@ -114,7 +114,6 @@ import java.util.concurrent.CancellationException; import java.util.concurrent.CompletableFuture; import java.util.function.Function; -import java.util.stream.Collectors; import static org.ballerinalang.formatter.core.FormatterUtils.buildFormattingOptions; @@ -345,7 +344,7 @@ public CompletableFuture>> codeAction(CodeActio cancelChecker); return LangExtensionDelegator.instance().codeActions(params, context, this.serverContext).stream() .map((Function>) Either::forRight) - .collect(Collectors.toList()); + .toList(); } catch (UserErrorException e) { this.clientLogger.notifyUser("Code Action", e); } catch (CancellationException ignore) { diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/BallerinaWorkspaceService.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/BallerinaWorkspaceService.java index 5bdf0ab3234d..168284561117 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/BallerinaWorkspaceService.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/BallerinaWorkspaceService.java @@ -41,7 +41,6 @@ import java.util.List; import java.util.Optional; import java.util.concurrent.CompletableFuture; -import java.util.stream.Collectors; /** * Workspace service implementation for Ballerina. @@ -110,7 +109,7 @@ public CompletableFuture executeCommand(ExecuteCommandParams params) { return CompletableFuture.supplyAsync(() -> { List commandArguments = params.getArguments().stream() .map(CommandArgument::from) - .collect(Collectors.toList()); + .toList(); ExecuteCommandContext context = ContextBuilder.buildExecuteCommandContext(this.workspaceManagerProxy.get(), this.serverContext, commandArguments, diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/CodeActionProvidersHolder.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/CodeActionProvidersHolder.java index 076961c93eee..ef37afac2028 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/CodeActionProvidersHolder.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/CodeActionProvidersHolder.java @@ -30,7 +30,6 @@ import java.util.Map; import java.util.Optional; import java.util.ServiceLoader; -import java.util.stream.Collectors; /** * Represents the Code Action provider factory. @@ -96,7 +95,7 @@ List getActiveRangeBasedProviders(SyntaxKind nodeT return CodeActionProvidersHolder.rangeBasedProviders.get(nodeType).stream() .filter(provider -> provider.isEnabled(ctx.languageServercontext())) .sorted(Comparator.comparingInt(LSCodeActionProvider::priority)) - .collect(Collectors.toList()); + .toList(); } return Collections.emptyList(); } @@ -110,7 +109,7 @@ List getActiveDiagnosticsBasedProviders(CodeA return CodeActionProvidersHolder.diagnosticsBasedProviders.stream() .filter(provider -> provider.isEnabled(ctx.languageServercontext())) .sorted(Comparator.comparingInt(LSCodeActionProvider::priority)) - .collect(Collectors.toList()); + .toList(); } /** diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/CodeActionUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/CodeActionUtil.java index 367fc30ec5a5..edc1c5658cb7 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/CodeActionUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/CodeActionUtil.java @@ -87,7 +87,6 @@ import java.util.Optional; import java.util.function.Function; import java.util.function.Predicate; -import java.util.stream.Collectors; import static org.ballerinalang.langserver.common.utils.CommonUtil.LINE_SEPARATOR; @@ -558,7 +557,7 @@ private static List filterErrorSubTypes(List errorTypeSy List errorTypeSymbolsClone = new ArrayList<>(errorTypeSymbols); return errorTypeSymbolsClone.stream().filter(typeSymbol -> errorTypeSymbols.stream().filter(other -> !other.signature().equals(typeSymbol.signature())) - .noneMatch(typeSymbol::subtypeOf)).collect(Collectors.toList()); + .noneMatch(typeSymbol::subtypeOf)).toList(); } private static Pair, List> getErrorAndNonErrorTypedSymbols( diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/CompilerPluginCodeActionExtension.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/CompilerPluginCodeActionExtension.java index b62c108a942e..7c9edde67fe1 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/CompilerPluginCodeActionExtension.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/CompilerPluginCodeActionExtension.java @@ -61,7 +61,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** * Compiler plugin code action extension implementation for ballerina. @@ -129,7 +128,7 @@ public List execute(CodeActionParams inputParams, return CodeActionUtil.createResolvableCodeAction(codeActionInfo.getTitle(), CodeActionKind.QuickFix, codeActionData); }) - .collect(Collectors.toList()); + .toList(); } @Override @@ -155,7 +154,7 @@ public CodeAction resolve(ResolvableCodeAction codeAction, CodeActionResolveCont List arguments = actionData.stream() .map(gson::toJsonTree) .map(CodeActionArgument::from) - .collect(Collectors.toList()); + .toList(); // Build the execution context and execute code action CodeActionExecutionContext codeActionContext = CodeActionExecutionContextImpl.from( codeActionData.getFileUri(), diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/AddCheckCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/AddCheckCodeAction.java index 078481fa9548..73ca4fbfea2c 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/AddCheckCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/AddCheckCodeAction.java @@ -46,7 +46,6 @@ import java.util.List; import java.util.Optional; import java.util.Set; -import java.util.stream.Collectors; /** * Code Action for error type handle. @@ -137,7 +136,7 @@ public List getCodeActions(Diagnostic diagnostic, DiagBasedPositionD List errorTypeSymbols = ((UnionTypeSymbol) foundType.get()).memberTypeDescriptors().stream() .filter(typeSymbol -> CommonUtil.getRawType(typeSymbol).typeKind() == TypeDescKind.ERROR) - .collect(Collectors.toList()); + .toList(); ImportsAcceptor acceptor = new ImportsAcceptor(context); List edits = new ArrayList<>(CodeActionUtil.getAddCheckTextEdits( diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java index 51100f6ffde8..d19141e3a979 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java @@ -341,7 +341,7 @@ private Optional> getVarAndParamSymbolsWithinRangeForStmts(CodeActi return Optional.of(argsSymbolsForExtractFunction.stream() // getLocation() is present for each symbol .sorted(Comparator.comparingInt(symbol -> symbol.getLocation().get().textRange().startOffset())) - .collect(Collectors.toList())); + .toList()); } /** @@ -550,7 +550,7 @@ private Optional> getVarAndParamSymbolsWithinRangeForExprs(LineRang .filter(symbol -> !PositionUtil.isWithinLineRange(symbol.getLocation().get().lineRange(), matchedLineRange)) .sorted(Comparator.comparingInt(symbol -> symbol.getLocation().get().textRange().startOffset())) - .collect(Collectors.toList())); + .toList()); } private Optional getArgLists(CodeActionContext context, List symbolsList, diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/FillRecordFieldsCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/FillRecordFieldsCodeAction.java index 367bfc59f2dd..0e9d2d595721 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/FillRecordFieldsCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/FillRecordFieldsCodeAction.java @@ -50,7 +50,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; /** * Code Action to autofill record fields. @@ -135,7 +134,7 @@ protected List getFields(MappingConstructorExpressionNode node) { .filter(field -> !field.isMissing() && field.kind() == SyntaxKind.SPECIFIC_FIELD && ((SpecificFieldNode) field).fieldName().kind() == SyntaxKind.IDENTIFIER_TOKEN) .map(field -> ((IdentifierToken) ((SpecificFieldNode) field).fieldName()).text()) - .collect(Collectors.toList()); + .toList(); } private static Optional getMappingConstructorNode(Node node) { diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ImplementAllCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ImplementAllCodeAction.java index 667fe6fc1524..c36eb3a00dcb 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ImplementAllCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ImplementAllCodeAction.java @@ -36,7 +36,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; import static org.ballerinalang.langserver.codeaction.CodeActionUtil.computePositionDetails; @@ -90,7 +89,7 @@ public List getCodeActions(CodeActionContext context, RangeBasedPosi .isRangeWithinRange(context.range(), PositionUtil.toRange(diag.location().lineRange())) ) .filter(diagnostic -> DIAGNOSTIC_CODES.contains(diagnostic.diagnosticInfo().code())) - .collect(Collectors.toList()); + .toList(); if (diags.isEmpty() || diags.size() == 1) { return Collections.emptyList(); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/createvar/CreateVariableWithTypeCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/createvar/CreateVariableWithTypeCodeAction.java index 72ceae34dadd..19f8cb37d5c1 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/createvar/CreateVariableWithTypeCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/createvar/CreateVariableWithTypeCodeAction.java @@ -225,11 +225,7 @@ private List getPossibleTypes(TypeSymbol typeSymbol, CodeActionContext c typeStream = typeStream.map(type -> type + "|" + errorTypeStr); } - List typesList = typeStream.collect(Collectors.toList()); - if (unionType != null) { - typesList.add(0, unionType); - } - return typesList; + return Stream.concat(Stream.ofNullable(unionType), typeStream).toList(); } private boolean isInRemoteMethodCallOrResourceAccess(CodeActionContext context) { diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/imports/OptimizeImportsCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/imports/OptimizeImportsCodeAction.java index ffd2ddc53914..1151476f2da9 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/imports/OptimizeImportsCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/imports/OptimizeImportsCodeAction.java @@ -180,7 +180,7 @@ protected List organizeFileImports(List o.moduleName().stream().map(Token::text).collect(Collectors.joining("."))) .thenComparing(o -> o.prefix().isPresent() ? o.prefix().get().prefix().text() : "")) - .collect(Collectors.toList()); + .toList(); } protected static void buildEditText(StringBuilder editText, ImportDeclarationNode importNode) { diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/command/executors/PullModuleExecutor.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/command/executors/PullModuleExecutor.java index 0a2b1ef6d397..939cafb945cb 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/command/executors/PullModuleExecutor.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/command/executors/PullModuleExecutor.java @@ -51,7 +51,6 @@ import java.util.Optional; import java.util.UUID; import java.util.concurrent.CompletableFuture; -import java.util.stream.Collectors; /** * Command executor for pulling a package from central. @@ -139,7 +138,7 @@ public Object execute(ExecuteCommandContext context) throws LSCommandExecutorExc .map(PullModuleCodeAction::getMissingModuleNameFromDiagnostic) .filter(Optional::isPresent) .map(Optional::get) - .collect(Collectors.toList()) + .toList() ); if (missingModules.isEmpty()) { throw new UserErrorException("Failed to pull modules!"); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/CommonUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/CommonUtil.java index d8519efd321a..ef7080b4e0b2 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/CommonUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/CommonUtil.java @@ -654,8 +654,7 @@ public static Optional getMatchingNode(Node currentNode, Predicate p */ public static List getFuncArguments(FunctionSymbol symbol, BallerinaCompletionContext ctx) { List params = CommonUtil.getFunctionParameters(symbol, ctx); - return params.stream().map(param -> getFunctionParamaterSyntax(param, ctx).orElse("")) - .collect(Collectors.toList()); + return params.stream().map(param -> getFunctionParamaterSyntax(param, ctx).orElse("")).toList(); } /** diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/NameUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/NameUtil.java index 10284d401d3e..a9f2746d24dd 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/NameUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/NameUtil.java @@ -311,7 +311,7 @@ private static String generateVariableName(int suffix, String name, Set // Remove '_' underscores while (newName.contains("_")) { String[] parts = newName.split("_"); - List restParts = Arrays.stream(parts, 1, parts.length).collect(Collectors.toList()); + List restParts = Arrays.stream(parts, 1, parts.length).toList(); newName = parts[0] + StringUtils.capitalize(String.join("", restParts)); } // If empty, revert to original name diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/RecordUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/RecordUtil.java index 564652952384..6c94a1cacb16 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/RecordUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/RecordUtil.java @@ -201,7 +201,7 @@ public static Map getRecordFields(RawTypeSymbolWrappe public static List getMandatoryRecordFields(RecordTypeSymbol recordType) { return recordType.fieldDescriptors().values().stream() .filter(field -> !field.hasDefaultValue() && !field.isOptional()) - .collect(Collectors.toList()); + .toList(); } /** @@ -239,7 +239,7 @@ public static List> getRecordTypeSymbols( .map(tSymbol -> { RecordTypeSymbol recordTypeSymbol = (RecordTypeSymbol) CommonUtil.getRawType(tSymbol); return RawTypeSymbolWrapper.from(tSymbol, recordTypeSymbol); - }).collect(Collectors.toList()); + }).toList(); } return Collections.emptyList(); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/SymbolUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/SymbolUtil.java index 77bc54e33912..d7412cb8319d 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/SymbolUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/SymbolUtil.java @@ -48,7 +48,6 @@ import java.util.Map; import java.util.Optional; import java.util.function.Predicate; -import java.util.stream.Collectors; import javax.annotation.Nonnull; @@ -452,7 +451,7 @@ public static List filterSymbolsByPrefix(List symbolList, if (!completionSearchProvider.checkModuleIndexed(moduleId)) { completionSearchProvider.indexModuleAndModuleSymbolNames(moduleId, symbolList.stream() .map(symbol -> symbol.getName().get()) - .collect(Collectors.toList()), new ArrayList<>(symbolMapWithPrefix.keySet())); + .toList(), new ArrayList<>(symbolMapWithPrefix.keySet())); } List stringList = completionSearchProvider.getSuggestions(prefix); @@ -468,6 +467,6 @@ public static List filterSymbolsByPrefix(List symbolList, private static List getFilteredList(Map symbolMap, List stringList) { return symbolMap.entrySet().stream().filter(stringSymbolEntry -> stringList.contains(stringSymbolEntry.getKey().toLowerCase())).map(Map.Entry::getValue) - .collect(Collectors.toList()); + .toList(); } } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/CompilerPluginCompletionExtension.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/CompilerPluginCompletionExtension.java index 78806a67d597..1d5c37d5705a 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/CompilerPluginCompletionExtension.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/CompilerPluginCompletionExtension.java @@ -49,7 +49,6 @@ import java.util.Collections; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** * Completion extension implementation for ballerina compiler plugins. @@ -117,10 +116,10 @@ public List execute(CompletionParams inputParams, lsp4jTextEdit.setNewText(textEdit.text()); lsp4jTextEdit.setRange(range); return lsp4jTextEdit; - }).collect(Collectors.toList())); + }).toList()); } return item; - }).collect(Collectors.toList()); + }).toList(); } @Override diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/builder/ResourcePathCompletionItemBuilder.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/builder/ResourcePathCompletionItemBuilder.java index 984ec296b5bf..4290158b1529 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/builder/ResourcePathCompletionItemBuilder.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/builder/ResourcePathCompletionItemBuilder.java @@ -35,7 +35,6 @@ import java.util.Collections; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** * This class is being used to build resource access completion item. @@ -84,7 +83,7 @@ public static List build(ResourceMethodSymbol resourceMethodSymb item.setFilterText(ResourcePathCompletionUtil .getFilterTextForClientResourceAccessAction(resourceMethodSymbol, segments)); return item; - }).collect(Collectors.toList()); + }).toList(); } private static CompletionItem buildCompletionItem(ResourceMethodSymbol resourceMethodSymbol, diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/AbstractCompletionProvider.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/AbstractCompletionProvider.java index 96ee9206dce4..c20fb9e5e50b 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/AbstractCompletionProvider.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/AbstractCompletionProvider.java @@ -381,7 +381,7 @@ protected List getModuleCompletionItems(BallerinaCompletionCon List pkgNameComps = Arrays.stream(name.split("\\.")) .map(ModuleUtil::escapeModuleName) .map(CommonUtil::escapeReservedKeyword) - .collect(Collectors.toList()); + .toList(); String label = pkg.packageOrg().value().isEmpty() ? String.join(".", pkgNameComps) : CommonUtil.getPackageLabel(pkg); String aliasComponent = pkgNameComps.get(pkgNameComps.size() - 1); @@ -545,7 +545,7 @@ protected List expressionCompletions(BallerinaCompletionContex List filteredList = visibleSymbols.stream() .filter(symbolFilter) .sorted(Comparator.comparing(symbol -> symbol.getName().get())) - .collect(Collectors.toList()); + .toList(); completionItems.addAll(this.getCompletionItemList(filteredList, context)); completionItems.addAll(this.getBasicAndOtherTypeCompletions(context)); this.getAnonFunctionDefSnippet(context).ifPresent(completionItems::add); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/AnnotationAccessExpressionNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/AnnotationAccessExpressionNodeContext.java index 93aebe1a03b7..df0290eb371c 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/AnnotationAccessExpressionNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/AnnotationAccessExpressionNodeContext.java @@ -48,7 +48,6 @@ import java.util.List; import java.util.Optional; import java.util.function.Predicate; -import java.util.stream.Collectors; import static io.ballerina.compiler.api.symbols.SymbolKind.ANNOTATION; @@ -179,12 +178,12 @@ private static List getAnnotationEntries(BallerinaCompletionCo QNameRefCompletionUtil.getModuleContent(ctx, (QualifiedNameReferenceNode) nodeAtCursor, predicate) .stream() .map(symbol -> (AnnotationSymbol) symbol) - .collect(Collectors.toList()); + .toList(); } else { annotationSymbols = ctx.visibleSymbols(ctx.getCursorPosition()).stream() .filter(predicate) .map(symbol -> (AnnotationSymbol) symbol) - .collect(Collectors.toList()); + .toList(); } return annotationSymbols; diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/AnnotationDeclarationNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/AnnotationDeclarationNodeContext.java index 166aed22c2b2..bcd34ced950a 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/AnnotationDeclarationNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/AnnotationDeclarationNodeContext.java @@ -43,7 +43,6 @@ import java.util.List; import java.util.Optional; import java.util.function.Predicate; -import java.util.stream.Collectors; /** * Completion provider for {@link AnnotationDeclarationNode} context. @@ -72,7 +71,7 @@ public List getCompletions(BallerinaCompletionContext context, } else { List filteredSymbols = context.visibleSymbols(context.getCursorPosition()).stream() .filter(predicate) - .collect(Collectors.toList()); + .toList(); completionItemList.addAll(this.getCompletionItemList(filteredSymbols, context)); completionItemList.addAll(this.getModuleCompletionItems(context)); completionItemList.add(new SnippetCompletionItem(context, Snippet.DEF_RECORD_TYPE_DESC.get())); @@ -135,7 +134,7 @@ private boolean isValidTypeDescForAnnotations(TypeDefinitionSymbol typeDefinitio return rawType.typeKind() == TypeDescKind.MAP || rawType.typeKind() == TypeDescKind.RECORD; } - private List getAnnotationAttachmentPoints(BallerinaCompletionContext context, + private List getAnnotationAttachmentPoints(BallerinaCompletionContext context, AnnotationDeclarationNode node) { AttachmentPointContext attachmentPointContext = getAttachmentPointContext(context, node); List itemSnippets = new ArrayList<>(); @@ -166,7 +165,7 @@ private List getAnnotationAttachmentPoints(BallerinaCompletion return itemSnippets.stream() .map(snippet -> new SnippetCompletionItem(context, snippet.get())) - .collect(Collectors.toList()); + .toList(); } private List anyAttachmentPoints() { diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/AnnotationNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/AnnotationNodeContext.java index 8b829faf4559..46fa1b71f307 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/AnnotationNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/AnnotationNodeContext.java @@ -42,7 +42,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** * Completion provider for {@link AnnotationNode} context. @@ -95,7 +94,7 @@ private List getCurrentModuleAnnotations(BallerinaCompletionCo .filter(symbol -> symbol.kind() == SymbolKind.ANNOTATION && this.matchingAnnotation((AnnotationSymbol) symbol, annotationNode, attachedNode, ctx)) .map(symbol -> AnnotationUtil.getAnnotationItem((AnnotationSymbol) symbol, ctx)) - .collect(Collectors.toList()); + .toList(); } private List getAnnotationsInModule(BallerinaCompletionContext context, String alias, @@ -118,7 +117,7 @@ private List getAnnotationsInModule(BallerinaCompletionContext .filter(symbol -> symbol.kind() == SymbolKind.ANNOTATION && this.matchingAnnotation((AnnotationSymbol) symbol, annotationNode, attachedNode, context)) .map(symbol -> AnnotationUtil.getAnnotationItem((AnnotationSymbol) symbol, context)) - .collect(Collectors.toList()); + .toList(); } private Node getAttached(AnnotationNode node) { diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ArrayTypeDescriptorNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ArrayTypeDescriptorNodeContext.java index 2e314fa5f068..21b17a108013 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ArrayTypeDescriptorNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ArrayTypeDescriptorNodeContext.java @@ -33,7 +33,6 @@ import java.util.ArrayList; import java.util.List; import java.util.function.Predicate; -import java.util.stream.Collectors; /** * Completion provider for {@link ArrayTypeDescriptorNode} context. @@ -65,7 +64,7 @@ public List getCompletions(BallerinaCompletionContext context, } else { List constants = visibleSymbols.stream() .filter(constantFilter()) - .collect(Collectors.toList()); + .toList(); completionItems.addAll(this.getModuleCompletionItems(context)); completionItems.addAll(this.getCompletionItemList(constants, context)); } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/BlockNodeContextProvider.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/BlockNodeContextProvider.java index b0b39da85f4c..11709cf2760d 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/BlockNodeContextProvider.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/BlockNodeContextProvider.java @@ -46,7 +46,6 @@ import java.util.List; import java.util.Optional; import java.util.function.Predicate; -import java.util.stream.Collectors; /** * Generic completion resolver for the Block Nodes. @@ -222,7 +221,7 @@ protected List getSymbolCompletions(BallerinaCompletionContext symbolFilter = symbolFilter.or(symbol -> symbol.kind() == SymbolKind.FUNCTION); List filteredList = visibleSymbols.stream() .filter(symbolFilter) - .collect(Collectors.toList()); + .toList(); return this.getCompletionItemList(filteredList, context); } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ClientResourceAccessActionNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ClientResourceAccessActionNodeContext.java index 0b6fd172fbd4..9c721790c2ef 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ClientResourceAccessActionNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ClientResourceAccessActionNodeContext.java @@ -59,7 +59,6 @@ import java.util.Iterator; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; import java.util.stream.StreamSupport; /** @@ -120,14 +119,13 @@ public List getCompletions(BallerinaCompletionContext context, completionItems.addAll(this.getNamedArgExpressionCompletionItems(context, node)); } } else { - List clientActions = this.getClientActions(expressionType.get()); + List clientActions = this.getClientActions(expressionType.get()); List resourceMethodSymbols = clientActions.stream() .filter(symbol -> symbol.kind() == SymbolKind.RESOURCE_METHOD) - .map(symbol -> (ResourceMethodSymbol) symbol).collect(Collectors.toList()); + .map(symbol -> (ResourceMethodSymbol) symbol).toList(); List remoteMethods = clientActions.stream() .filter(symbol -> symbol.kind() == SymbolKind.METHOD - && ((MethodSymbol) symbol).qualifiers().contains(Qualifier.REMOTE)) - .map(symbol -> (MethodSymbol) symbol).collect(Collectors.toList()); + && symbol.qualifiers().contains(Qualifier.REMOTE)).toList(); if (node.slashToken().isMissing()) { completionItems.addAll(this.getCompletionItemList(remoteMethods, context)); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/CollectClauseNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/CollectClauseNodeContext.java index a3493abe9aa6..c080a44f82db 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/CollectClauseNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/CollectClauseNodeContext.java @@ -30,7 +30,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; /** * Completion provider for {@link CollectClauseNode} context. @@ -62,7 +61,7 @@ public List getCompletions(BallerinaCompletionContext context, .filter(symbol -> symbol.getName().isPresent() && !symbol.getName().get().contains("$")) .filter(symbol -> completionItems .addAll(populateBallerinaFunctionCompletionItems(symbol, context))) - .collect(Collectors.toList()); + .toList(); } this.sort(context, node, completionItems); return completionItems; diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ConstantDeclarationNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ConstantDeclarationNodeContext.java index 8e87d4f43c51..965e4eaea76d 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ConstantDeclarationNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ConstantDeclarationNodeContext.java @@ -36,7 +36,6 @@ import java.util.List; import java.util.Optional; import java.util.function.Predicate; -import java.util.stream.Collectors; /** * Completion provider for {@link ModulePartNode} context. @@ -119,7 +118,7 @@ protected List initializerContextCompletions(BallerinaCompleti } else { constants = context.visibleSymbols(context.getCursorPosition()).stream() .filter(predicate) - .collect(Collectors.toList()); + .toList(); completionItems.addAll(this.getModuleCompletionItems(context)); completionItems.add(new SnippetCompletionItem(context, Snippet.KW_TRUE.get())); completionItems.add(new SnippetCompletionItem(context, Snippet.KW_FALSE.get())); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/DistinctTypeDescriptorNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/DistinctTypeDescriptorNodeContext.java index 65834fb91c6f..b5f14e1f3c75 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/DistinctTypeDescriptorNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/DistinctTypeDescriptorNodeContext.java @@ -36,7 +36,6 @@ import java.util.ArrayList; import java.util.List; import java.util.function.Predicate; -import java.util.stream.Collectors; /** * Completion provider for {@link DistinctTypeDescriptorNode} context. @@ -78,7 +77,7 @@ public List getCompletions(BallerinaCompletionContext context, completionItems.add(new SnippetCompletionItem(context, Snippet.DEF_OBJECT_TYPE_DESC_SNIPPET.get())); List filteredSymbols = context.visibleSymbols(context.getCursorPosition()).stream() .filter(predicate) - .collect(Collectors.toList()); + .toList(); completionItems.addAll(this.getCompletionItemList(filteredSymbols, context)); } this.sort(context, node, completionItems); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ErrorConstructorExpressionNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ErrorConstructorExpressionNodeContext.java index 871e55ec620a..8739a46f2dc7 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ErrorConstructorExpressionNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ErrorConstructorExpressionNodeContext.java @@ -51,7 +51,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; /** * Completion provider for {@link ErrorConstructorExpressionNode} context. @@ -134,7 +133,7 @@ private List getErrorTypeRefCompletions(BallerinaCompletionCon List errorTypes = ctx.visibleSymbols(ctx.getCursorPosition()).stream() .filter(SymbolUtil.isOfType(TypeDescKind.ERROR) .and(symbol -> !symbol.getName().orElse("").equals(Names.ERROR.getValue()))) - .collect(Collectors.toList()); + .toList(); List completionItems = this.getCompletionItemList(errorTypes, ctx); completionItems.addAll(this.getModuleCompletionItems(ctx)); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ErrorMatchPatternNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ErrorMatchPatternNodeContext.java index 394103915170..a8bba53b0c42 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ErrorMatchPatternNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ErrorMatchPatternNodeContext.java @@ -32,7 +32,6 @@ import java.util.ArrayList; import java.util.List; import java.util.function.Predicate; -import java.util.stream.Collectors; /** * Completion provider for {@link ErrorMatchPatternNode} context. @@ -67,7 +66,7 @@ public List getCompletions(BallerinaCompletionContext context, List visibleSymbols = context.visibleSymbols(context.getCursorPosition()); errorTypes = visibleSymbols.stream() .filter(this.errorTypeFilter()) - .collect(Collectors.toList()); + .toList(); completionItems.addAll(this.getModuleCompletionItems(context)); } completionItems.addAll(this.getCompletionItemList(errorTypes, context)); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ExplicitNewExpressionNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ExplicitNewExpressionNodeContext.java index a29673e0ff01..2b110541484a 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ExplicitNewExpressionNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ExplicitNewExpressionNodeContext.java @@ -43,7 +43,6 @@ import java.util.List; import java.util.Optional; import java.util.function.Predicate; -import java.util.stream.Collectors; /** * Completion provider for {@link ExplicitNewExpressionNode} context. @@ -143,7 +142,7 @@ private List getCompletionsWithinArgs(BallerinaCompletionConte } List completionItems = new ArrayList<>(); if (isNotInNamedArgOnlyContext(ctx, - node.parenthesizedArgList().arguments().stream().collect(Collectors.toList()))) { + node.parenthesizedArgList().arguments().stream().toList())) { completionItems.addAll(this.expressionCompletions(ctx)); } completionItems.addAll(getNamedArgExpressionCompletionItems(ctx, node)); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/FieldAccessContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/FieldAccessContext.java index a73883d9edb7..a231ae323074 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/FieldAccessContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/FieldAccessContext.java @@ -47,7 +47,6 @@ import java.util.List; import java.util.Optional; import java.util.function.Predicate; -import java.util.stream.Collectors; /** * Generic Completion provider for field access providers. @@ -154,7 +153,7 @@ private List getXmlAttributeAccessCompletions(BallerinaComplet */ List xmlNamespaces = context.visibleSymbols(context.getCursorPosition()).stream() .filter(symbol -> symbol.kind() == SymbolKind.XMLNS) - .collect(Collectors.toList()); + .toList(); completionItems.addAll(this.getCompletionItemList(xmlNamespaces, context)); completionItems.addAll(this.getModuleCompletionItems(context)); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/FlushActionNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/FlushActionNodeContext.java index 8f26aaca6232..5d55e8bb9833 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/FlushActionNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/FlushActionNodeContext.java @@ -28,7 +28,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; /** * Completion Provider for {@link FlushActionNode} context. @@ -48,7 +47,7 @@ public List getCompletions(BallerinaCompletionContext context, List visibleSymbols = context.visibleSymbols(context.getCursorPosition()); List filteredWorkers = visibleSymbols.stream() .filter(symbol -> symbol.kind() == SymbolKind.WORKER) - .collect(Collectors.toList()); + .toList(); List completionItems = new ArrayList<>(this.getCompletionItemList(filteredWorkers, context)); completionItems.add(new SnippetCompletionItem(context, Snippet.KW_FUNCTION.get())); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/FunctionCallExpressionNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/FunctionCallExpressionNodeContext.java index 0a0d4202e1f6..a9c732987788 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/FunctionCallExpressionNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/FunctionCallExpressionNodeContext.java @@ -31,7 +31,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** * Completion Provider for {@link FunctionCallExpressionNode} context. @@ -54,7 +53,7 @@ public List getCompletions(BallerinaCompletionContext ctx, Fun completionItems.addAll(this.getCompletionItemList(QNameRefCompletionUtil .getExpressionContextEntries(ctx, qNameRef), ctx)); } else { - if (this.isNotInNamedArgOnlyContext(ctx, node.arguments().stream().collect(Collectors.toList()))) { + if (this.isNotInNamedArgOnlyContext(ctx, node.arguments().stream().toList())) { completionItems.addAll(this.actionKWCompletions(ctx)); completionItems.addAll(this.expressionCompletions(ctx)); } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImplicitNewExpressionNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImplicitNewExpressionNodeContext.java index 8b690d94c16c..ef7057c4db3e 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImplicitNewExpressionNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImplicitNewExpressionNodeContext.java @@ -24,6 +24,7 @@ import io.ballerina.compiler.api.symbols.TypeDefinitionSymbol; import io.ballerina.compiler.api.symbols.TypeDescKind; import io.ballerina.compiler.api.symbols.TypeSymbol; +import io.ballerina.compiler.syntax.tree.FunctionArgumentNode; import io.ballerina.compiler.syntax.tree.ImplicitNewExpressionNode; import io.ballerina.compiler.syntax.tree.Node; import io.ballerina.compiler.syntax.tree.NonTerminalNode; @@ -43,7 +44,6 @@ import java.util.List; import java.util.Optional; import java.util.function.Predicate; -import java.util.stream.Collectors; /** * Completion provider for {@link ImplicitNewExpressionNode} context. @@ -114,8 +114,8 @@ private List getCompletionsWithinArgs(BallerinaCompletionConte return this.getCompletionItemList(QNameRefCompletionUtil.getExpressionContextEntries(ctx, qNameRef), ctx); } List completionItems = new ArrayList<>(); - List arguments = node.parenthesizedArgList().isPresent() ? - node.parenthesizedArgList().get().arguments().stream().collect(Collectors.toList()) + List arguments = node.parenthesizedArgList().isPresent() ? + node.parenthesizedArgList().get().arguments().stream().toList() : Collections.emptyList(); if (isNotInNamedArgOnlyContext(ctx, arguments)) { completionItems.addAll(this.expressionCompletions(ctx)); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportDeclarationNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportDeclarationNodeContext.java index a08b04977ace..2032609a213a 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportDeclarationNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportDeclarationNodeContext.java @@ -90,7 +90,7 @@ public List getCompletions(BallerinaCompletionContext ctx, Imp */ List moduleName = node.moduleName().stream() .filter(token -> !token.isMissing()) - .collect(Collectors.toList()); + .toList(); ArrayList completionItems = new ArrayList<>(); ContextScope contextScope; @@ -230,7 +230,7 @@ private ArrayList orgNameContextCompletions(BallerinaCompletio List pkgNameComps = Arrays.stream(pkgName.split("\\.")) .map(ModuleUtil::escapeModuleName) .map(CommonUtil::escapeReservedKeyword) - .collect(Collectors.toList()); + .toList(); String label = pkg.packageOrg().value().isEmpty() ? String.join(".", pkgNameComps) : CommonUtil.getPackageLabel(pkg); String insertText = orgName.isEmpty() ? "" : orgName + Names.ORG_NAME_SEPARATOR.getValue(); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/IncludedRecordParameterNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/IncludedRecordParameterNodeContext.java index 7474739eda4d..eaff1eded06b 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/IncludedRecordParameterNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/IncludedRecordParameterNodeContext.java @@ -36,7 +36,6 @@ import java.util.Arrays; import java.util.List; import java.util.function.Predicate; -import java.util.stream.Collectors; /** * Completion provider for {@link IncludedRecordParameterNode} context. @@ -68,7 +67,7 @@ public List getCompletions(BallerinaCompletionContext ctx, Inc .filter(symbol -> symbol.kind() == SymbolKind.TYPE_DEFINITION && CommonUtil.getRawType(((TypeDefinitionSymbol) symbol).typeDescriptor()) .typeKind() == TypeDescKind.RECORD) - .collect(Collectors.toList()); + .toList(); // Add the keywords and snippets related to record type descriptor completionItems.addAll(Arrays.asList( new SnippetCompletionItem(ctx, Snippet.KW_RECORD.get()), diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/InvocationNodeContextProvider.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/InvocationNodeContextProvider.java index 1931ec9dd7d2..0b245a219c06 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/InvocationNodeContextProvider.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/InvocationNodeContextProvider.java @@ -209,7 +209,8 @@ private boolean isValidNamedArgContext(BallerinaCompletionContext context, return true; } - protected boolean isNotInNamedArgOnlyContext(BallerinaCompletionContext context, List arguments) { + protected boolean isNotInNamedArgOnlyContext(BallerinaCompletionContext context, + List arguments) { int cursorPosition = context.getCursorPositionInTree(); for (Node child : arguments) { TextRange textRange = child.textRange(); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/KeySpecifierNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/KeySpecifierNodeContext.java index 993c74622483..2bc09e7ac036 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/KeySpecifierNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/KeySpecifierNodeContext.java @@ -113,7 +113,7 @@ private List getKeyCompletionItems(BallerinaCompletionContext .map(Map.Entry::getValue) .filter(recordFieldSymbol -> recordFieldSymbol.getName().isPresent()) .filter(recordFieldSymbol -> SyntaxInfo.isIdentifier(recordFieldSymbol.getName().get())) - .collect(Collectors.toList()); + .toList(); completionItems.addAll(this.getCompletionItemList(commonFields, context)); return completionItems; diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ListConstructorExpressionNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ListConstructorExpressionNodeContext.java index bf20faca5dfb..3fff6651ba77 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ListConstructorExpressionNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ListConstructorExpressionNodeContext.java @@ -45,7 +45,6 @@ import java.util.Collections; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** * Completion provider for {@link ListConstructorExpressionNode} context. @@ -79,7 +78,7 @@ public List getCompletions(BallerinaCompletionContext context, return completionItems; } - private List spreadOperatorCompletions(BallerinaCompletionContext context) { + private List spreadOperatorCompletions(BallerinaCompletionContext context) { Optional semanticModel = context.currentSemanticModel(); Optional document = context.currentDocument(); if (semanticModel.isEmpty() || document.isEmpty()) { @@ -124,7 +123,7 @@ private List spreadOperatorCompletions(BallerinaCompletionCont CompletionItem completionItem = SpreadCompletionItemBuilder.build(symbol, typeName, context); return new SpreadCompletionItem(context, completionItem, symbol); - }).collect(Collectors.toList()); + }).toList(); } @Override diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ListenerDeclarationNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ListenerDeclarationNodeContext.java index e27e19d7a516..a7d2077367e2 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ListenerDeclarationNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ListenerDeclarationNodeContext.java @@ -52,7 +52,6 @@ import java.util.List; import java.util.Objects; import java.util.Optional; -import java.util.stream.Collectors; import java.util.stream.Stream; import static io.ballerina.compiler.api.symbols.SymbolKind.FUNCTION; @@ -199,7 +198,7 @@ private List listenersAndPackagesItems(BallerinaCompletionCont List visibleSymbols = context.visibleSymbols(context.getCursorPosition()); List listeners = visibleSymbols.stream() .filter(SymbolUtil::isListener) - .collect(Collectors.toList()); + .toList(); completionItems.addAll(this.getCompletionItemList(listeners, context)); return completionItems; @@ -221,7 +220,7 @@ private List listenersInModule(BallerinaCompletionContext cont Stream classesAndTypeDefs = Stream.concat(module.classes().stream(), module.typeDefinitions().stream()); List listeners = classesAndTypeDefs .filter(SymbolUtil::isListener) - .collect(Collectors.toList()); + .toList(); completionItems.addAll(this.getCompletionItemList(listeners, context)); return completionItems; @@ -330,7 +329,7 @@ protected List expressionCompletions(BallerinaCompletionContex Optional objectTypeDesc = getListenerTypeDesc(context, listenerNode); List filteredList = visibleSymbols.stream() .filter(symbol -> symbol.kind() == VARIABLE || symbol.kind() == FUNCTION) - .collect(Collectors.toList()); + .toList(); completionItems.addAll(this.getCompletionItemList(filteredList, context)); completionItems.addAll(this.getModuleCompletionItems(context)); objectTypeDesc.ifPresent(tDesc -> completionItems.add(this.getImplicitNewCItemForClass(tDesc, context))); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/MappingConstructorExpressionNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/MappingConstructorExpressionNodeContext.java index 0ff4a5b55122..3ac7ca7a3d41 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/MappingConstructorExpressionNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/MappingConstructorExpressionNodeContext.java @@ -42,7 +42,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** * Completion provider for {@link MappingConstructorExpressionNode} context. @@ -153,7 +152,7 @@ private List getComputedNameCompletions(BallerinaCompletionCon List filteredList = visibleSymbols.stream() .filter(symbol -> symbol instanceof VariableSymbol || symbol.kind() == SymbolKind.FUNCTION) - .collect(Collectors.toList()); + .toList(); List completionItems = this.getCompletionItemList(filteredList, context); completionItems.addAll(this.getModuleCompletionItems(context)); @@ -166,7 +165,7 @@ protected List getFields(MappingConstructorExpressionNode node) { .filter(field -> !field.isMissing() && field.kind() == SyntaxKind.SPECIFIC_FIELD && ((SpecificFieldNode) field).fieldName().kind() == SyntaxKind.IDENTIFIER_TOKEN) .map(field -> ((IdentifierToken) ((SpecificFieldNode) field).fieldName()).text()) - .collect(Collectors.toList()); + .toList(); } private enum Scope { diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/MappingContextProvider.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/MappingContextProvider.java index dce1a52dda3e..cc22daa05855 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/MappingContextProvider.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/MappingContextProvider.java @@ -56,7 +56,6 @@ import java.util.Map; import java.util.Optional; import java.util.function.Predicate; -import java.util.stream.Collectors; import static io.ballerina.compiler.api.symbols.SymbolKind.FUNCTION; @@ -129,7 +128,7 @@ protected List getVariableCompletionsForFields(BallerinaComple && recFields.get(symbolName.get()).typeDescriptor().typeKind() == typeDescriptor.get().typeKind(); })) - .collect(Collectors.toList()); + .toList(); return this.getCompletionItemList(visibleSymbols, ctx); } @@ -204,7 +203,7 @@ protected List getFieldCompletionItems(BallerinaCompletionCont .filter(this.getVariableFilter()) .filter(varSymbol -> varSymbol.getName().isPresent()) .filter(varSymbol -> !existingFields.contains(varSymbol.getName().get())) - .collect(Collectors.toList()); + .toList(); completionItems.addAll(this.getCompletionItemList(variables, context)); //Spread field can only be used with in a mapping constructor and the fields should be empty if (existingFields.isEmpty() && evalNode.kind() == SyntaxKind.MAPPING_CONSTRUCTOR) { @@ -251,7 +250,7 @@ private List getSpreadFieldCompletionItemsForMap(MappingConstr // For nested maps, we have to treat specially return resolvedType.get().typeKind() == TypeDescKind.MAP && mapTypeSymbol.subtypeOf(resolvedType.get()); - })).collect(Collectors.toList()); + })).toList(); return getSpreadFieldCompletionItemList(visibleSymbols, context); } @@ -268,7 +267,7 @@ private List getSpreadFieldCompletionItemsForRecordFields(Ball Predicate symbolFilter = this.getVariableFilter().or(symbol -> (symbol.kind() == FUNCTION)); List filteredSymbols = context.visibleSymbols(context.getCursorPosition()).stream() .filter(symbolFilter.and(symbol -> isSpreadable(symbol, validFields))) - .collect(Collectors.toList()); + .toList(); return this.getSpreadFieldCompletionItemList(filteredSymbols, context); } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/MappingMatchPatternNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/MappingMatchPatternNodeContext.java index 046870f13e50..684cf12709d7 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/MappingMatchPatternNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/MappingMatchPatternNodeContext.java @@ -29,7 +29,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** * Completion provider for {@link MappingMatchPatternNode} context. @@ -67,7 +66,7 @@ protected List getFields(MappingMatchPatternNode node) { .filter(field -> !field.isMissing() && field.kind() == SyntaxKind.FIELD_MATCH_PATTERN && ((FieldMatchPatternNode) field).fieldNameNode().kind() == SyntaxKind.IDENTIFIER_TOKEN) .map(field -> ((FieldMatchPatternNode) field).fieldNameNode().text()) - .collect(Collectors.toList()); + .toList(); } @Override diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/MatchStatementContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/MatchStatementContext.java index 62ed242b7606..0acc7c1002d4 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/MatchStatementContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/MatchStatementContext.java @@ -28,7 +28,6 @@ import java.util.Arrays; import java.util.List; import java.util.function.Predicate; -import java.util.stream.Collectors; /** * Generic Completion provider for match statement related contexts such as match node and pattern clauses. @@ -51,7 +50,7 @@ protected List getPatternClauseCompletions(BallerinaCompletion snippets.forEach(snippet -> completionItems.add(new SnippetCompletionItem(context, snippet.get()))); List filteredConstants = visibleSymbols.stream() .filter(this.constantFilter()) - .collect(Collectors.toList()); + .toList(); completionItems.addAll(this.getCompletionItemList(filteredConstants, context)); completionItems.addAll(this.getModuleCompletionItems(context)); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ModuleXMLNamespaceDeclarationNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ModuleXMLNamespaceDeclarationNodeContext.java index f70fc7793a38..456f7b6dd994 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ModuleXMLNamespaceDeclarationNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ModuleXMLNamespaceDeclarationNodeContext.java @@ -36,7 +36,6 @@ import java.util.List; import java.util.Optional; import java.util.function.Predicate; -import java.util.stream.Collectors; /** * Completion provider for {@link ModuleXMLNamespaceDeclarationNode} context. @@ -68,7 +67,7 @@ public List getCompletions(BallerinaCompletionContext context, } else { List constants = context.visibleSymbols(context.getCursorPosition()).stream() .filter(predicate) - .collect(Collectors.toList()); + .toList(); completionItems.addAll(this.getCompletionItemList(constants, context)); completionItems.addAll(this.getModuleCompletionItems(context)); } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ObjectConstructorExpressionNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ObjectConstructorExpressionNodeContext.java index bc3507f2044a..d60fca68c64e 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ObjectConstructorExpressionNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ObjectConstructorExpressionNodeContext.java @@ -38,7 +38,6 @@ import java.util.Arrays; import java.util.List; import java.util.function.Predicate; -import java.util.stream.Collectors; /** * Completion provider for {@link ObjectConstructorExpressionNode} context. @@ -110,7 +109,7 @@ private List getTypeReferenceCompletions(BallerinaCompletionCo List visibleSymbols = ctx.visibleSymbols(ctx.getCursorPosition()); List objectEntries = visibleSymbols.stream() .filter(predicate) - .collect(Collectors.toList()); + .toList(); List completionItems = this.getCompletionItemList(objectEntries, ctx); completionItems.addAll(this.getModuleCompletionItems(ctx)); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ObjectFieldNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ObjectFieldNodeContext.java index 73b82b157796..93deacabe011 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ObjectFieldNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ObjectFieldNodeContext.java @@ -37,7 +37,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** * Completion provider for {@link ObjectFieldNode} context. @@ -88,7 +87,7 @@ private List getExpressionContextCompletions(BallerinaCompleti // Specifically add the class fields as the completion items List classFields = ctx.visibleSymbols(ctx.getCursorPosition()).stream() .filter(symbol -> symbol.kind() == SymbolKind.CLASS_FIELD) - .collect(Collectors.toList()); + .toList(); completionItems.addAll(this.getCompletionItemList(classFields, ctx)); Optional contextType = ctx.getContextType(); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/OnFailClauseNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/OnFailClauseNodeContext.java index c978c1b81141..754c826fb676 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/OnFailClauseNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/OnFailClauseNodeContext.java @@ -35,7 +35,6 @@ import java.util.Collections; import java.util.List; import java.util.function.Predicate; -import java.util.stream.Collectors; /** * Completion provider for {@link OnFailClauseNode} context. @@ -69,7 +68,7 @@ public List getCompletions(BallerinaCompletionContext context, List visibleSymbols = context.visibleSymbols(context.getCursorPosition()); List errEntries = visibleSymbols.stream() .filter(errorPredicate) - .collect(Collectors.toList()); + .toList(); completionItems.addAll(this.getCompletionItemList(errEntries, context)); // Add 'var' completion item diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/PanicStatementNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/PanicStatementNodeContext.java index 49e6f872f8df..503882a60200 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/PanicStatementNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/PanicStatementNodeContext.java @@ -30,7 +30,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** * Completion provider for {@link PanicStatementNode} context. @@ -51,7 +50,7 @@ public List getCompletions(BallerinaCompletionContext context, List visibleSymbols = context.visibleSymbols(context.getCursorPosition()); List filteredList = visibleSymbols.stream() .filter(SymbolUtil::isError) - .collect(Collectors.toList()); + .toList(); completionItems.addAll(this.getCompletionItemList(filteredList, context)); completionItems.addAll(this.expressionCompletions(context)); this.sort(context, node, completionItems); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ReceiveActionNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ReceiveActionNodeContext.java index f16f364dc813..3d6db9ef7e36 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ReceiveActionNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ReceiveActionNodeContext.java @@ -27,7 +27,6 @@ import org.ballerinalang.langserver.completions.util.Snippet; import java.util.List; -import java.util.stream.Collectors; /** * Completion provider for {@link ReceiveActionNode}. @@ -47,7 +46,7 @@ public List getCompletions(BallerinaCompletionContext context, List visibleSymbols = context.visibleSymbols(context.getCursorPosition()); List filteredWorkers = visibleSymbols.stream() .filter(symbol -> symbol.kind() == SymbolKind.WORKER) - .collect(Collectors.toList()); + .toList(); List completionItems = this.getCompletionItemList(filteredWorkers, context); completionItems.add(new SnippetCompletionItem(context, Snippet.KW_FUNCTION.get())); this.sort(context, node, completionItems); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/RemoteMethodCallActionNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/RemoteMethodCallActionNodeContext.java index 86050aa93c44..d087019c7ab0 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/RemoteMethodCallActionNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/RemoteMethodCallActionNodeContext.java @@ -17,6 +17,7 @@ import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.api.symbols.FunctionSymbol; +import io.ballerina.compiler.api.symbols.MethodSymbol; import io.ballerina.compiler.api.symbols.Symbol; import io.ballerina.compiler.api.symbols.SymbolKind; import io.ballerina.compiler.api.symbols.TypeSymbol; @@ -36,7 +37,6 @@ import java.util.Collections; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** * Handles the completions for the {@link RemoteMethodCallActionNode}. @@ -77,7 +77,7 @@ public List getCompletions(BallerinaCompletionContext context, Covers the following case where a is a client object and we suggest the remote actions (1) a -> g */ - List clientActions = this.getClientActions(expressionType.get()); + List clientActions = this.getClientActions(expressionType.get()); completionItems.addAll(this.getCompletionItemList(clientActions, context)); } else if (TypeResolverUtil.isInMethodCallParameterContext(node, context.getCursorPositionInTree())) { /* @@ -91,7 +91,7 @@ public List getCompletions(BallerinaCompletionContext context, List items = this.getCompletionItemList(exprEntries, context); completionItems.addAll(items); } else { - if (isNotInNamedArgOnlyContext(context, node.arguments().stream().collect(Collectors.toList()))) { + if (isNotInNamedArgOnlyContext(context, node.arguments().stream().toList())) { completionItems.addAll(this.actionKWCompletions(context)); completionItems.addAll(this.expressionCompletions(context)); } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/RightArrowActionNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/RightArrowActionNodeContext.java index 11d0db2380f3..ee88ba155a15 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/RightArrowActionNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/RightArrowActionNodeContext.java @@ -15,6 +15,7 @@ */ package org.ballerinalang.langserver.completions.providers.context; +import io.ballerina.compiler.api.symbols.MethodSymbol; import io.ballerina.compiler.api.symbols.ObjectTypeSymbol; import io.ballerina.compiler.api.symbols.Qualifier; import io.ballerina.compiler.api.symbols.Symbol; @@ -33,7 +34,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** * Parent completion provider for Right arrow action nodes. @@ -63,7 +63,7 @@ protected List getFilteredItems(BallerinaCompletionContext con Covers the following case where a is a client object and we suggest the remote actions (1) a -> g */ - List clientActions = this.getClientActions(expressionType.get()); + List clientActions = this.getClientActions(expressionType.get()); completionItems.addAll(this.getCompletionItemList(clientActions, context)); } else { /* @@ -73,7 +73,7 @@ protected List getFilteredItems(BallerinaCompletionContext con */ List filteredWorkers = visibleSymbols.stream() .filter(symbol -> symbol.kind() == SymbolKind.WORKER) - .collect(Collectors.toList()); + .toList(); completionItems.addAll(this.getCompletionItemList(filteredWorkers, context)); completionItems.add(new SnippetCompletionItem(context, Snippet.KW_FUNCTION.get())); } @@ -87,7 +87,7 @@ protected List getFilteredItems(BallerinaCompletionContext con * @param symbol Endpoint variable symbol to evaluate * @return {@link List} List of extracted actions as Symbol Info */ - public List getClientActions(Symbol symbol) { + public List getClientActions(Symbol symbol) { if (!SymbolUtil.isObject(symbol)) { return new ArrayList<>(); } @@ -95,6 +95,6 @@ public List getClientActions(Symbol symbol) { return ((ObjectTypeSymbol) typeDescriptor).methods().values().stream() .filter(method -> method.qualifiers().contains(Qualifier.REMOTE) || method.qualifiers().contains(Qualifier.RESOURCE)) - .collect(Collectors.toList()); + .toList(); } } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/SelectClauseNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/SelectClauseNodeContext.java index 19d4884e0214..8e08d58407f3 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/SelectClauseNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/SelectClauseNodeContext.java @@ -36,7 +36,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** * Completion provider for {@link SelectClauseNode} context. @@ -71,9 +70,8 @@ public List getCompletions(BallerinaCompletionContext context, functionSymbols.stream() .filter(symbol -> symbol.typeDescriptor().restParam().isPresent()) .filter(symbol -> symbol.getName().isPresent() && !symbol.getName().get().contains("$")) - .filter(symbol -> completionItems - .addAll(populateBallerinaFunctionCompletionItems(symbol, context))) - .collect(Collectors.toList()); + .forEach(symbol -> completionItems + .addAll(populateBallerinaFunctionCompletionItems(symbol, context))); } } this.sort(context, node, completionItems); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ServiceDeclarationNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ServiceDeclarationNodeContext.java index 6a41264d482a..de416fda8559 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ServiceDeclarationNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ServiceDeclarationNodeContext.java @@ -44,7 +44,6 @@ import java.util.List; import java.util.Optional; import java.util.function.Predicate; -import java.util.stream.Collectors; import static org.ballerinalang.langserver.completions.util.SortingUtil.genSortText; import static org.ballerinalang.langserver.completions.util.SortingUtil.genSortTextForModule; @@ -120,7 +119,7 @@ public List getCompletions(BallerinaCompletionContext context, List visibleSymbols = context.visibleSymbols(context.getCursorPosition()); List listeners = visibleSymbols.stream() .filter(predicate) - .collect(Collectors.toList()); + .toList(); completionItems.addAll(this.getCompletionItemList(listeners, context)); completionItems.addAll(this.getModuleCompletionItems(context)); completionItems.add(new SnippetCompletionItem(context, Snippet.KW_NEW.get())); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/StartActionNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/StartActionNodeContext.java index b28ca435f1e5..22eb4d3b2944 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/StartActionNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/StartActionNodeContext.java @@ -37,7 +37,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; import static io.ballerina.compiler.api.symbols.SymbolKind.FUNCTION; @@ -90,7 +89,7 @@ protected List expressionCompletions(BallerinaCompletionContex List visibleSymbols = context.visibleSymbols(context.getCursorPosition()); List filteredList = visibleSymbols.stream() .filter(symbol -> (symbol instanceof VariableSymbol || symbol.kind() == FUNCTION)) - .collect(Collectors.toList()); + .toList(); completionItems.addAll(this.getCompletionItemList(filteredList, context)); return completionItems; } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/SyncSendActionNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/SyncSendActionNodeContext.java index 5bb61f066412..0bff5fdc811b 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/SyncSendActionNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/SyncSendActionNodeContext.java @@ -28,7 +28,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; /** * Completion provider for {@link SyncSendActionNode} context. @@ -47,7 +46,7 @@ public List getCompletions(BallerinaCompletionContext context, List visibleSymbols = context.visibleSymbols(context.getCursorPosition()); List filteredWorkers = visibleSymbols.stream() .filter(symbol -> symbol.kind() == SymbolKind.WORKER) - .collect(Collectors.toList()); + .toList(); List completionItems = new ArrayList<>(this.getCompletionItemList(filteredWorkers, context)); completionItems.add(new SnippetCompletionItem(context, Snippet.KW_FUNCTION.get())); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/TypeParameterContextProvider.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/TypeParameterContextProvider.java index a52a4a42dd71..eb23bf375e83 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/TypeParameterContextProvider.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/TypeParameterContextProvider.java @@ -130,7 +130,7 @@ private List getTableTypeDescSymbols(BallerinaCompletionContex */ List filtered = context.visibleSymbols(context.getCursorPosition()).stream() .filter(predicate) - .collect(Collectors.toList()); + .toList(); List completionItems = new ArrayList<>(); completionItems.addAll(this.getModuleCompletionItems(context)); completionItems.addAll(this.getCompletionItemList(filtered, context)); @@ -172,7 +172,7 @@ private List getErrorTypeDescSymbols(BallerinaCompletionContex Arrays.asList(new SnippetCompletionItem(context, Snippet.DEF_RECORD_TYPE_DESC.get()), new SnippetCompletionItem(context, Snippet.DEF_CLOSED_RECORD_TYPE_DESC.get()))); List visibleSymbols = context.visibleSymbols(context.getCursorPosition()); - mappingTypes = visibleSymbols.stream().filter(predicate).collect(Collectors.toList()); + mappingTypes = visibleSymbols.stream().filter(predicate).toList(); completionItems.addAll(this.getCompletionItemList(mappingTypes, context)); completionItems.addAll(this.getModuleCompletionItems(context)); } @@ -213,7 +213,7 @@ private List getXMLTypeDescSymbols(BallerinaCompletionContext // modules and the xml sub types are suggested List filtered = visibleSymbols.stream() .filter(predicate) - .collect(Collectors.toList()); + .toList(); completionItems.addAll(this.getCompletionItemList(filtered, context)); completionItems.addAll(this.getModuleCompletionItems(context)); } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/TypeReferenceNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/TypeReferenceNodeContext.java index cf047d9e3636..869a75b59a8d 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/TypeReferenceNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/TypeReferenceNodeContext.java @@ -35,7 +35,6 @@ import java.util.List; import java.util.Optional; import java.util.function.Predicate; -import java.util.stream.Collectors; /** * Completion provider for {@link TypeReferenceNode} context. @@ -65,7 +64,7 @@ public List getCompletions(BallerinaCompletionContext context, completionItems.addAll(this.getCompletionItemList(moduleContent, context)); } else { List symbols = context.visibleSymbols(context.getCursorPosition()).stream() - .filter(predicate.get()).collect(Collectors.toList()); + .filter(predicate.get()).toList(); completionItems.addAll(this.getCompletionItemList(symbols, context)); completionItems.addAll(this.getModuleCompletionItems(context)); } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/TypeTestExpressionNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/TypeTestExpressionNodeContext.java index 9b69b34b4199..0505dd30ad03 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/TypeTestExpressionNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/TypeTestExpressionNodeContext.java @@ -48,7 +48,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** * Completion provider for {@link TypeTestExpressionNode} context. @@ -104,7 +103,7 @@ private List getModuleTypeDescCompletionsForExpression(Balleri if (typeSymbol.get().typeKind() == TypeDescKind.UNION) { typeReferences = ((UnionTypeSymbol) typeSymbol.get()).memberTypeDescriptors().stream() .filter(type -> type.typeKind() == TypeDescKind.TYPE_REFERENCE) - .map(type -> (TypeReferenceTypeSymbol) type).collect(Collectors.toList()); + .map(type -> (TypeReferenceTypeSymbol) type).toList(); } else if (typeSymbol.get().typeKind() == TypeDescKind.TYPE_REFERENCE) { typeReferences = List.of((TypeReferenceTypeSymbol) typeSymbol.get()); } else { diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/WaitActionNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/WaitActionNodeContext.java index 7649bd102bc9..9c52d064b5d9 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/WaitActionNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/WaitActionNodeContext.java @@ -41,7 +41,6 @@ import java.util.List; import java.util.Optional; import java.util.function.Predicate; -import java.util.stream.Collectors; import static io.ballerina.compiler.api.symbols.SymbolKind.FUNCTION; import static io.ballerina.compiler.api.symbols.SymbolKind.PARAMETER; @@ -119,7 +118,7 @@ protected List expressionCompletions(BallerinaCompletionContex .filter(symbol -> (symbol instanceof VariableSymbol || symbol.kind() == PARAMETER || symbol.kind() == FUNCTION || symbol.kind() == WORKER) && !symbol.getName().orElse("").equals(Names.ERROR.getValue())) - .collect(Collectors.toList()); + .toList(); completionItems.addAll(this.getCompletionItemList(filteredList, context)); this.getAnonFunctionDefSnippet(context).ifPresent(completionItems::add); return completionItems; diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/WaitFieldsListNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/WaitFieldsListNodeContext.java index 0e70ed3872db..72cd947a9a60 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/WaitFieldsListNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/WaitFieldsListNodeContext.java @@ -36,7 +36,6 @@ import java.util.List; import java.util.Optional; import java.util.function.Predicate; -import java.util.stream.Collectors; import static io.ballerina.compiler.api.symbols.SymbolKind.WORKER; @@ -79,7 +78,7 @@ protected List expressionCompletions(BallerinaCompletionContex List visibleSymbols = context.visibleSymbols(context.getCursorPosition()); List filteredList = visibleSymbols.stream() .filter(CommonUtil.getVariableFilterPredicate().or(symbol -> symbol.kind() == WORKER)) - .collect(Collectors.toList()); + .toList(); return this.getCompletionItemList(filteredList, context); } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/XMLNSDeclarationNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/XMLNSDeclarationNodeContext.java index eee64d490f37..889bf2593df8 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/XMLNSDeclarationNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/XMLNSDeclarationNodeContext.java @@ -36,7 +36,6 @@ import java.util.List; import java.util.Optional; import java.util.function.Predicate; -import java.util.stream.Collectors; /** * Completion provider for {@link XMLNamespaceDeclarationNode} context. @@ -67,7 +66,7 @@ public List getCompletions(BallerinaCompletionContext context, } else { List constants = context.visibleSymbols(context.getCursorPosition()).stream() .filter(predicate) - .collect(Collectors.toList()); + .toList(); completionItems.addAll(this.getCompletionItemList(constants, context)); completionItems.addAll(this.getModuleCompletionItems(context)); } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/XMLNamePatternChainingNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/XMLNamePatternChainingNodeContext.java index f617d70b9709..169d9465b8e0 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/XMLNamePatternChainingNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/XMLNamePatternChainingNodeContext.java @@ -24,7 +24,6 @@ import org.ballerinalang.langserver.completions.providers.AbstractCompletionProvider; import java.util.List; -import java.util.stream.Collectors; /** * Completion provider for {@link XMLNamePatternChainingNode} context. @@ -41,8 +40,7 @@ public XMLNamePatternChainingNodeContext() { @Override public List getCompletions(BallerinaCompletionContext context, XMLNamePatternChainingNode node) { List visibleSymbols = context.visibleSymbols(context.getCursorPosition()); - List xmlNs = visibleSymbols.stream().filter(symbol -> symbol.kind() == SymbolKind.XMLNS) - .collect(Collectors.toList()); + List xmlNs = visibleSymbols.stream().filter(symbol -> symbol.kind() == SymbolKind.XMLNS).toList(); List completionItems = this.getCompletionItemList(xmlNs, context); this.sort(context, node, completionItems); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/XMLSimpleNameNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/XMLSimpleNameNodeContext.java index be4578fce6b0..f628736bacb0 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/XMLSimpleNameNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/XMLSimpleNameNodeContext.java @@ -24,7 +24,6 @@ import org.ballerinalang.langserver.completions.providers.AbstractCompletionProvider; import java.util.List; -import java.util.stream.Collectors; /** * Completion provider for {@link XMLSimpleNameNode} context. @@ -44,7 +43,7 @@ public List getCompletions(BallerinaCompletionContext context, List xmlNamespaces = visibleSymbols.stream() .filter(symbol -> symbol.kind() == SymbolKind.XMLNS) - .collect(Collectors.toList()); + .toList(); List completionItems = this.getCompletionItemList(xmlNamespaces, context); this.sort(context, node, completionItems); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java index 5aee2ef1ffc5..fd5bce2771c5 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java @@ -46,7 +46,6 @@ import java.util.List; import java.util.Optional; import java.util.function.Predicate; -import java.util.stream.Collectors; import static org.ballerinalang.langserver.completions.util.SortingUtil.genSortText; @@ -207,7 +206,7 @@ public static boolean onServiceTypeDescContext(Token evalToken, BallerinaComplet */ public static List serviceTypeDescContextSymbols(BallerinaCompletionContext context) { List visibleSymbols = context.visibleSymbols(context.getCursorPosition()); - return visibleSymbols.stream().filter(serviceTypeDescPredicate()).collect(Collectors.toList()); + return visibleSymbols.stream().filter(serviceTypeDescPredicate()).toList(); } /** diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/QueryExpressionUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/QueryExpressionUtil.java index b87741723eb5..0733ee17d821 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/QueryExpressionUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/QueryExpressionUtil.java @@ -24,7 +24,6 @@ import java.util.Arrays; import java.util.List; -import java.util.stream.Collectors; /** * A utility to provide completions related to query expressions. @@ -78,6 +77,6 @@ public static List getLangLibMethods(BallerinaCompletionContext langLibMethods.addAll(types.TYPEDESC.langLibMethods()); langLibMethods.addAll(types.XML.langLibMethods()); - return langLibMethods.stream().distinct().collect(Collectors.toList()); + return langLibMethods.stream().distinct().toList(); } } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/CompletionUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/CompletionUtil.java index 4a2f2cf0ef37..f8bff6168e0e 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/CompletionUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/CompletionUtil.java @@ -41,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; /** * Common utility methods for the completion operation. @@ -86,7 +85,7 @@ public static List getCompletionItems(BallerinaCompletionContext return items.stream() .map(LSCompletionItem::getCompletionItem) - .collect(Collectors.toList()); + .toList(); } /** diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/FieldAccessCompletionResolver.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/FieldAccessCompletionResolver.java index 5e27881d4510..fb07bac435ed 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/FieldAccessCompletionResolver.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/FieldAccessCompletionResolver.java @@ -62,7 +62,6 @@ import java.util.List; import java.util.Optional; import java.util.function.Predicate; -import java.util.stream.Collectors; /** * Symbol resolver for the field access expressions. @@ -157,7 +156,7 @@ public Optional transform(FunctionCallExpressionNode node) { functionName = ((SimpleNameReferenceNode) nameRef).name().text(); visibleEntries = context.visibleSymbols(context.getCursorPosition()).stream() .filter(fSymbolPredicate.or(fPointerPredicate)) - .collect(Collectors.toList()); + .toList(); } else { return Optional.empty(); } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/QNameRefCompletionUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/QNameRefCompletionUtil.java index 1ec86a9b0c47..b5d3e33f6fb7 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/QNameRefCompletionUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/QNameRefCompletionUtil.java @@ -27,11 +27,10 @@ import org.ballerinalang.langserver.commons.BallerinaCompletionContext; import org.ballerinalang.langserver.commons.PositionedOperationContext; -import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.function.Predicate; -import java.util.stream.Collectors; /** * Holds the set of utilities to get the qualified name reference associated Completion Items. @@ -71,7 +70,7 @@ public static List getExpressionContextEntries(BallerinaCompletionContex || symbol.kind() == SymbolKind.TYPE_DEFINITION || symbol.kind() == SymbolKind.CLASS || symbol instanceof VariableSymbol) - .collect(Collectors.toList())).orElseGet(ArrayList::new); + .toList()).orElseGet(Collections::emptyList); } /** @@ -110,8 +109,8 @@ public static List getModuleContent(PositionedOperationContext context, QNameRefCompletionUtil.getAlias(qNameRef)); return module.map(moduleSymbol -> moduleSymbol.allSymbols().stream() .filter(predicate) - .collect(Collectors.toList())) - .orElseGet(ArrayList::new); + .toList()) + .orElseGet(Collections::emptyList); } /** @@ -127,8 +126,8 @@ public static List getTypesInModule(BallerinaCompletionContext context, QNameRefCompletionUtil.getAlias(qNameRef)); return module.map(symbol -> symbol.allSymbols().stream() .filter(CommonUtil.typesFilter()) - .collect(Collectors.toList())) - .orElseGet(ArrayList::new); + .toList()) + .orElseGet(Collections::emptyList); } /** diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/AbstractDocumentServiceContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/AbstractDocumentServiceContext.java index 197328235ea1..892e11c2d2d2 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/AbstractDocumentServiceContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/AbstractDocumentServiceContext.java @@ -42,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; import javax.annotation.Nonnull; @@ -161,7 +160,7 @@ public List currentDocImports() { throw new RuntimeException("Cannot find a valid document"); } return ((ModulePartNode) document.get().syntaxTree().rootNode()).imports().stream() - .collect(Collectors.toList()); + .toList(); } @Override diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/CodeActionContextImpl.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/CodeActionContextImpl.java index 4d8954170163..ad5d4cd125d6 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/CodeActionContextImpl.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/CodeActionContextImpl.java @@ -41,7 +41,6 @@ import java.nio.file.Path; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** * Language server context implementation. @@ -107,7 +106,7 @@ public List diagnostics(Path filePath project.sourceRoot(); this.diagnostics = compilation.diagnosticResult().diagnostics().stream() .filter(diag -> projectRoot.resolve(diag.location().lineRange().fileName()).equals(filePath)) - .collect(Collectors.toList()); + .toList(); return this.diagnostics; } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/document/BallerinaDocumentService.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/document/BallerinaDocumentService.java index 5654bb88bf0d..9ec575567a17 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/document/BallerinaDocumentService.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/document/BallerinaDocumentService.java @@ -66,7 +66,6 @@ import java.util.List; import java.util.Optional; import java.util.concurrent.CompletableFuture; -import java.util.stream.Collectors; /** * Implementation of Ballerina Document extension for Language Server. @@ -432,7 +431,7 @@ public CompletableFuture> diagnostics(BallerinaPr return diagnosticsHelper.getLatestDiagnostics(context).entrySet().stream() .filter(entry -> fileUri.equals(entry.getKey())) .map((entry) -> new PublishDiagnosticsParams(entry.getKey(), entry.getValue())) - .collect(Collectors.toList()); + .toList(); } catch (Throwable e) { String msg = "Operation 'ballerinaDocument/diagnostics' failed!"; this.clientLogger.logError(DocumentContext.DC_DIAGNOSTICS, msg, e, params.getDocumentIdentifier(), diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/inlayhint/InlayHintProvider.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/inlayhint/InlayHintProvider.java index e49bdfab411f..546e90d18ff6 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/inlayhint/InlayHintProvider.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/inlayhint/InlayHintProvider.java @@ -62,7 +62,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; /** * Represents the Inlay Hint Provider. @@ -158,7 +157,7 @@ private static Pair, Optional> getParamet return Pair.of(Collections.emptyList(), Optional.empty()); } // Since the method is a lang-lib function, skip the first parameter - return Pair.of(libFunction.get().params().get().stream().skip(1).collect(Collectors.toList()), + return Pair.of(libFunction.get().params().get().stream().skip(1).toList(), libFunction.get().restParam()); } else if (invokableNode.kind() == SyntaxKind.CLIENT_RESOURCE_ACCESS_ACTION) { return context.currentSemanticModel().get() @@ -233,7 +232,7 @@ private static Pair, Optional> getParamet } else if (node.functionName().kind() == SyntaxKind.SIMPLE_NAME_REFERENCE) { functionSymbols = visibleSymbols.stream() .filter(symbol -> symbol.kind() == SymbolKind.FUNCTION) - .map(symbol -> (FunctionSymbol) symbol).collect(Collectors.toList()); + .map(symbol -> (FunctionSymbol) symbol).toList(); functionName = ((SimpleNameReferenceNode) node.functionName()).name().text(); } else { return Pair.of(Collections.emptyList(), Optional.empty()); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/references/DocumentationReferenceFinder.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/references/DocumentationReferenceFinder.java index d331f7ce60fc..d2ef807ed20c 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/references/DocumentationReferenceFinder.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/references/DocumentationReferenceFinder.java @@ -21,25 +21,24 @@ import io.ballerina.compiler.syntax.tree.MarkdownDocumentationNode; import io.ballerina.compiler.syntax.tree.MarkdownParameterDocumentationLineNode; import io.ballerina.compiler.syntax.tree.Node; +import io.ballerina.compiler.syntax.tree.NodeLocation; import io.ballerina.compiler.syntax.tree.NodeTransformer; import io.ballerina.compiler.syntax.tree.RecordFieldNode; import io.ballerina.compiler.syntax.tree.RequiredParameterNode; import io.ballerina.compiler.syntax.tree.SyntaxKind; import io.ballerina.compiler.syntax.tree.TypeDefinitionNode; -import io.ballerina.tools.diagnostics.Location; import org.ballerinalang.langserver.codeaction.CodeActionUtil; import java.util.Collections; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** * Finds references for the given symbol within documentation (parameters). * * @since 2201.6.0 */ -public class DocumentationReferenceFinder extends NodeTransformer> { +public class DocumentationReferenceFinder extends NodeTransformer> { private Symbol symbol; @@ -48,7 +47,7 @@ public DocumentationReferenceFinder(Symbol symbol) { } @Override - public List transform(RequiredParameterNode node) { + public List transform(RequiredParameterNode node) { Optional fnDefNode = CodeActionUtil.getEnclosedFunction(node); if (fnDefNode.isEmpty()) { return Collections.emptyList(); @@ -64,7 +63,7 @@ public List transform(RequiredParameterNode node) { } @Override - public List transform(RecordFieldNode node) { + public List transform(RecordFieldNode node) { if (node.parent().parent().kind() != SyntaxKind.TYPE_DEFINITION) { return Collections.emptyList(); } @@ -84,18 +83,18 @@ public List transform(RecordFieldNode node) { * @param mdNode Markdown documentation node * @return List of locations of the parameters within the documentation */ - private List getParameterLocations(MarkdownDocumentationNode mdNode) { + private List getParameterLocations(MarkdownDocumentationNode mdNode) { return mdNode.documentationLines().stream() .filter(line -> line.kind() == SyntaxKind.MARKDOWN_PARAMETER_DOCUMENTATION_LINE) .map(line -> (MarkdownParameterDocumentationLineNode) line) .map(line -> line.parameterName()) .filter(token -> token.text().equals(symbol.getName().get())) .map(paramToken -> paramToken.location()) - .collect(Collectors.toList()); + .toList(); } @Override - protected List transformSyntaxNode(Node node) { + protected List transformSyntaxNode(Node node) { return Collections.emptyList(); } } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/references/ReferencesUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/references/ReferencesUtil.java index cbcc2136fdf0..f85c7cced045 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/references/ReferencesUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/references/ReferencesUtil.java @@ -18,6 +18,7 @@ import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.api.symbols.Symbol; import io.ballerina.compiler.syntax.tree.ModulePartNode; +import io.ballerina.compiler.syntax.tree.NodeLocation; import io.ballerina.compiler.syntax.tree.NonTerminalNode; import io.ballerina.compiler.syntax.tree.SyntaxKind; import io.ballerina.projects.Document; @@ -61,7 +62,7 @@ public static Map> getReferences(PositionedOperationConte List docReferences = new LinkedList<>(); // Find references in documentation locations.forEach(location -> { - List refs = findReferencesInDocumentation(location, module, context, symbol.get()); + List refs = findReferencesInDocumentation(location, module, context, symbol.get()); if (refs != null && !refs.isEmpty()) { docReferences.addAll(refs); } @@ -93,10 +94,10 @@ public static Map> getReferences(Project project, Symbol return moduleLocationMap; } - private static List findReferencesInDocumentation(Location location, - Module module, - PositionedOperationContext context, - Symbol symbol) { + private static List findReferencesInDocumentation(Location location, + Module module, + PositionedOperationContext context, + Symbol symbol) { Path filePath = PathUtil.getPathFromLocation(module, location); Range range = PositionUtil.getRangeFromLineRange(location.lineRange()); Optional node = context.workspace().syntaxTree(filePath) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/semantictokens/SemanticTokensUtils.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/semantictokens/SemanticTokensUtils.java index d363ca5e5be3..5c3e9a0b1a40 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/semantictokens/SemanticTokensUtils.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/semantictokens/SemanticTokensUtils.java @@ -33,7 +33,6 @@ import java.util.Collections; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** * Semantic tokens util class. @@ -73,7 +72,7 @@ public static SemanticTokens getSemanticTokens(SemanticTokensContext semanticTok public static List getTokenTypes() { return Arrays.stream(SemanticTokensContext.TokenTypes.values()) .map(SemanticTokensContext.TokenTypes::getValue) - .collect(Collectors.toList()); + .toList(); } /** @@ -84,7 +83,7 @@ public static List getTokenTypes() { public static List getTokenTypeModifiers() { return Arrays.stream(SemanticTokensContext.TokenTypeModifiers.values()) .map(SemanticTokensContext.TokenTypeModifiers::getValue) - .collect(Collectors.toList()); + .toList(); } /** diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/signature/SignatureHelpUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/signature/SignatureHelpUtil.java index 994f374ea1f4..0cb3bd8dc3f0 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/signature/SignatureHelpUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/signature/SignatureHelpUtil.java @@ -74,7 +74,6 @@ import java.util.Objects; import java.util.Optional; import java.util.function.Predicate; -import java.util.stream.Collectors; import javax.annotation.Nonnull; @@ -281,7 +280,7 @@ private static Optional getFunctionSymbol(FunctionCallExpressi filteredContent = visibleSymbols.stream() .filter(symbolPredicate.and(symbol -> symbol.getName().isPresent() && symbol.getName().get().equals(funcName))) - .collect(Collectors.toList()); + .toList(); } return filteredContent.stream().findAny(); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/signature/SignatureInfoModelBuilder.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/signature/SignatureInfoModelBuilder.java index 9d297ba018b8..e1d49f380d99 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/signature/SignatureInfoModelBuilder.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/signature/SignatureInfoModelBuilder.java @@ -49,7 +49,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; +import java.util.stream.Stream; /** * A utility for building a SignatureInformation. @@ -182,14 +182,13 @@ private void fillParamInfoModels() { return; } - List parameters = parameterSymbols - .subList(skipFirstParam() ? 1 : 0, parameterSymbols.size()) - .stream() - .map(param -> new Parameter(param, false, false, context)) - .collect(Collectors.toList()); - Optional restParam = functionTypeSymbol.flatMap(FunctionTypeSymbol::restParam); - restParam.ifPresent(parameter -> parameters.add(new Parameter(parameter, false, true, context))); + List parameters = Stream.concat( + parameterSymbols.subList(skipFirstParam() ? 1 : 0, parameterSymbols.size()) + .stream() + .map(param -> new Parameter(param, false, false, context)), + restParam.stream().map(parameter -> new Parameter(parameter, false, true, context)) + ).toList(); // Create a list of param info models for (Parameter param : parameters) { @@ -200,7 +199,7 @@ private void fillParamInfoModels() { includedRecordParams = this.parameterModels.stream() .filter(ParameterInfoModel::isIncludedRecordParam) - .collect(Collectors.toList()); + .toList(); } /** diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/toml/ballerinatoml/completion/BallerinaTomlCompletionContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/toml/ballerinatoml/completion/BallerinaTomlCompletionContext.java index 2625db1e6f4c..852d551ba7bb 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/toml/ballerinatoml/completion/BallerinaTomlCompletionContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/toml/ballerinatoml/completion/BallerinaTomlCompletionContext.java @@ -44,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; /** * Ballerina toml completion context. @@ -101,8 +100,7 @@ public List currentDocImports() { throw new RuntimeException("Cannot find a valid document"); } - return ((ModulePartNode) document.get().syntaxTree().rootNode()).imports().stream() - .collect(Collectors.toList()); + return ((ModulePartNode) document.get().syntaxTree().rootNode()).imports().stream().toList(); } @Override diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/AbstractCodeActionTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/AbstractCodeActionTest.java index 782654173d92..6085b7680bdd 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/AbstractCodeActionTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/AbstractCodeActionTest.java @@ -61,7 +61,6 @@ import java.util.List; import java.util.Objects; import java.util.Optional; -import java.util.stream.Collectors; /** * Abstract test for code action related tests. @@ -98,7 +97,7 @@ public void test(String config) throws IOException, WorkspaceDocumentException { Range finalRange = range; diags = diags.stream() .filter(diag -> PositionUtil.isRangeWithinRange(finalRange, diag.getRange())) - .collect(Collectors.toList()); + .toList(); CodeActionContext codeActionContext = new CodeActionContext(diags); String res = getResponse(sourcePath, finalRange, codeActionContext); @@ -298,7 +297,7 @@ public void negativeTest(String config) throws IOException, WorkspaceDocumentExc Range finalRange = range; diags = diags.stream() .filter(diag -> PositionUtil.isRangeWithinRange(finalRange, diag.getRange())) - .collect(Collectors.toList()); + .toList(); CodeActionContext codeActionContext = new CodeActionContext(diags); String res = TestUtil.getCodeActionResponse(endpoint, sourcePath.toString(), finalRange, codeActionContext); diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/AddModuleToBallerinaTomlCodeActionTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/AddModuleToBallerinaTomlCodeActionTest.java index 60c74c93c93d..9e2074ff8f58 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/AddModuleToBallerinaTomlCodeActionTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/AddModuleToBallerinaTomlCodeActionTest.java @@ -36,7 +36,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; /** * Test class to test module addition to Ballerina.toml. @@ -63,7 +62,7 @@ public void setup() { "x.y", "main.bal"); List localPackages = getLocalPackages(localProjects, languageServer.getWorkspaceManager(), context).stream().map(LSPackageLoader.ModuleInfo::new) - .collect(Collectors.toList()); + .toList(); Mockito.when(getLSPackageLoader().getLocalRepoModules()).thenReturn(localPackages); } catch (Exception e) { //ignore diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/signature/AbstractSignatureHelpTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/signature/AbstractSignatureHelpTest.java index d8aa51bef02e..8b472bcb8b82 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/signature/AbstractSignatureHelpTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/signature/AbstractSignatureHelpTest.java @@ -80,7 +80,8 @@ public void test(String config, String source) // java.nio.file.Files.write(org.ballerinalang.langserver.util.FileUtils.RES_DIR.resolve(configJsonPath), // obj.toString().getBytes(java.nio.charset.StandardCharsets.UTF_8)); - Assert.fail("Failed Test for: " + configJsonPath); + Assert.fail("Failed Test for: " + configJsonPath + "\n Expected: " + + expected + "\n Found: " + responseJson); } } diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/workspace/TestDidChangeWatchedFiles.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/workspace/TestDidChangeWatchedFiles.java index 9f839fd86721..6fced133410f 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/workspace/TestDidChangeWatchedFiles.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/workspace/TestDidChangeWatchedFiles.java @@ -37,7 +37,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; /** * Test the watched file changes. @@ -129,7 +128,7 @@ private void sendSingleFileEvent(Path path, FileChangeType fileChangeType) { private void sendMultipleFileChanges(Map changesMap) { List fileEvents = changesMap.entrySet().stream() .map(entry -> new FileEvent(entry.getKey().toUri().toString(), entry.getValue())) - .collect(Collectors.toList()); + .toList(); DidChangeWatchedFilesParams params = new DidChangeWatchedFilesParams(); params.setChanges(fileEvents); diff --git a/misc/ballerinalang-data-mapper/src/test/java/org/ballerinalang/datamapper/util/DataMapperTestUtils.java b/misc/ballerinalang-data-mapper/src/test/java/org/ballerinalang/datamapper/util/DataMapperTestUtils.java index 4f487ed5ef43..66d61b34af7a 100644 --- a/misc/ballerinalang-data-mapper/src/test/java/org/ballerinalang/datamapper/util/DataMapperTestUtils.java +++ b/misc/ballerinalang-data-mapper/src/test/java/org/ballerinalang/datamapper/util/DataMapperTestUtils.java @@ -37,7 +37,6 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; /** * Common utils that are reused within data-mapper test suits. @@ -89,7 +88,7 @@ public static JsonObject getCodeActionResponse(String source, JsonObject configJ configJsonObject.get("character").getAsInt()); diags = diags.stream(). filter(diag -> PositionUtil.isWithinRange(pos, diag.getRange())) - .collect(Collectors.toList()); + .toList(); CodeActionContext codeActionContext = new CodeActionContext(diags); Range range = new Range(pos, pos); String response = TestUtil.getCodeActionResponse(serviceEndpoint, sourcePath.toString(), range, diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/completion/context/AsyncSendActionNodeContext.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/completion/context/AsyncSendActionNodeContext.java index 25a0260bd4d4..f7761b188435 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/completion/context/AsyncSendActionNodeContext.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/completion/context/AsyncSendActionNodeContext.java @@ -15,6 +15,7 @@ */ package org.ballerinalang.debugadapter.completion.context; +import io.ballerina.compiler.api.symbols.MethodSymbol; import io.ballerina.compiler.api.symbols.Symbol; import io.ballerina.compiler.api.symbols.SymbolKind; import io.ballerina.compiler.api.symbols.TypeSymbol; @@ -27,7 +28,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; import static org.ballerinalang.debugadapter.completion.util.CommonUtil.getClientActions; import static org.ballerinalang.debugadapter.completion.util.CompletionUtil.getCompletionItemList; @@ -61,7 +61,7 @@ private List getFilteredItems(CompletionContext context, Express Covers the following case where a is a client object and we suggest the remote actions (1) a -> g */ - List clientActions = getClientActions(expressionType.get()); + List clientActions = getClientActions(expressionType.get()); completionItems.addAll(getCompletionItemList(clientActions, context)); } else { /* @@ -71,7 +71,7 @@ private List getFilteredItems(CompletionContext context, Express */ List filteredWorkers = visibleSymbols.stream() .filter(symbol -> symbol.kind() == SymbolKind.WORKER) - .collect(Collectors.toList()); + .toList(); completionItems.addAll(getCompletionItemList(filteredWorkers, context)); } diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/completion/context/RemoteMethodCallActionNodeContext.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/completion/context/RemoteMethodCallActionNodeContext.java index 8e32e2b37d64..5f60a0de839e 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/completion/context/RemoteMethodCallActionNodeContext.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/completion/context/RemoteMethodCallActionNodeContext.java @@ -15,6 +15,7 @@ */ package org.ballerinalang.debugadapter.completion.context; +import io.ballerina.compiler.api.symbols.MethodSymbol; import io.ballerina.compiler.api.symbols.Symbol; import io.ballerina.compiler.api.symbols.TypeSymbol; import io.ballerina.compiler.syntax.tree.QualifiedNameReferenceNode; @@ -61,7 +62,7 @@ public List getCompletions(CompletionContext context, RemoteMeth Covers the following case where a is a client object and we suggest the remote actions (1) a -> g */ - List clientActions = getClientActions(expressionType.get()); + List clientActions = getClientActions(expressionType.get()); completionItems.addAll(getCompletionItemList(clientActions, context)); } else if (CommonUtil.isInMethodCallParameterContext(context, node)) { /* diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/completion/util/CommonUtil.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/completion/util/CommonUtil.java index 20f7954ae939..1dbc389ef4ec 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/completion/util/CommonUtil.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/completion/util/CommonUtil.java @@ -19,6 +19,7 @@ import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.api.symbols.FunctionTypeSymbol; import io.ballerina.compiler.api.symbols.IntersectionTypeSymbol; +import io.ballerina.compiler.api.symbols.MethodSymbol; import io.ballerina.compiler.api.symbols.ModuleSymbol; import io.ballerina.compiler.api.symbols.ObjectTypeSymbol; import io.ballerina.compiler.api.symbols.ParameterSymbol; @@ -425,13 +426,13 @@ public static Map currentDocImportsMap(Comp * @param symbol Endpoint variable symbol to evaluate * @return {@link List} List of extracted actions as Symbol Info */ - public static List getClientActions(Symbol symbol) { + public static List getClientActions(Symbol symbol) { if (!SymbolUtil.isObject(symbol)) { return new ArrayList<>(); } TypeSymbol typeDescriptor = CommonUtil.getRawType(SymbolUtil.getTypeDescriptor(symbol).orElseThrow()); return ((ObjectTypeSymbol) typeDescriptor).methods().values().stream() .filter(method -> method.qualifiers().contains(Qualifier.REMOTE)) - .collect(Collectors.toList()); + .toList(); } } diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/completion/util/QNameReferenceUtil.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/completion/util/QNameReferenceUtil.java index a79e9323a317..c5de24405d24 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/completion/util/QNameReferenceUtil.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/completion/util/QNameReferenceUtil.java @@ -28,7 +28,6 @@ import java.util.List; import java.util.Optional; import java.util.function.Predicate; -import java.util.stream.Collectors; /** * Holds the set of utilities to get the qualified name reference associated Completion Items. @@ -76,7 +75,7 @@ public static List getModuleContent(CompletionContext context, Optional module = CommonUtil.searchModuleForAlias(context, QNameReferenceUtil.getAlias(qNameRef)); return module.map(moduleSymbol -> moduleSymbol.allSymbols().stream() .filter(predicate) - .collect(Collectors.toList())) + .toList()) .orElseGet(ArrayList::new); } @@ -127,6 +126,6 @@ public static List getExpressionContextEntries(CompletionContext ctx, St || symbol.kind() == SymbolKind.TYPE_DEFINITION || symbol.kind() == SymbolKind.CLASS || symbol instanceof VariableSymbol) - .collect(Collectors.toList())).orElseGet(ArrayList::new); + .toList()).orElseGet(ArrayList::new); } } diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/ExpressionAsProgramEvaluator.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/ExpressionAsProgramEvaluator.java index 9fc5b29d0969..aa1f0b67ea45 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/ExpressionAsProgramEvaluator.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/ExpressionAsProgramEvaluator.java @@ -510,7 +510,7 @@ private List convertImports(List declarationLi modifier = modifier.withModuleName(newModuleName); return modifier.apply(); - }).collect(Collectors.toList()); + }).toList(); } private void processSnippetFunctionParameters() throws EvaluationException { diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/FunctionInvocationExpressionEvaluator.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/FunctionInvocationExpressionEvaluator.java index b2f1eff20ac8..041bdb289aae 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/FunctionInvocationExpressionEvaluator.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/FunctionInvocationExpressionEvaluator.java @@ -35,7 +35,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; import static io.ballerina.compiler.api.symbols.SymbolKind.FUNCTION; import static org.ballerinalang.debugadapter.evaluation.EvaluationException.createEvaluationException; @@ -102,7 +101,7 @@ private FunctionSymbol resolveFunctionDefinitionSymbol() throws EvaluationExcept functionMatches = resolvedImports.get(modulePrefix.get()).getResolvedSymbol().functions().stream() .filter(symbol -> symbol.getName().isPresent() && modifyName(symbol.getName().get()).equals(functionName)) - .collect(Collectors.toList()); + .toList(); if (functionMatches.size() == 1 && !isPublicSymbol(functionMatches.get(0))) { throw createEvaluationException(NON_PUBLIC_OR_UNDEFINED_ACCESS, functionName); @@ -115,7 +114,7 @@ private FunctionSymbol resolveFunctionDefinitionSymbol() throws EvaluationExcept .filter(symbol -> symbol.kind() == FUNCTION && symbol.getName().isPresent() && modifyName(symbol.getName().get()).equals(functionName)) .map(symbol -> (FunctionSymbol) symbol) - .collect(Collectors.toList()); + .toList(); } if (functionMatches.isEmpty()) { diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/jdi/ObjectReferenceProxyImpl.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/jdi/ObjectReferenceProxyImpl.java index 95dffeb21e92..7e5d3393ea1d 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/jdi/ObjectReferenceProxyImpl.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/jdi/ObjectReferenceProxyImpl.java @@ -28,7 +28,6 @@ import java.util.List; import java.util.Map; -import java.util.stream.Collectors; /** * Proxy implementation for JDI object reference. @@ -109,7 +108,7 @@ public long uniqueID() { */ public List waitingThreads() throws IncompatibleThreadStateException { return getObjectReference().waitingThreads().stream().map(getVirtualMachineProxy()::getThreadReferenceProxy) - .collect(Collectors.toList()); + .toList(); } public ThreadReferenceProxyImpl owningThread() throws IncompatibleThreadStateException { diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/jdi/ThreadGroupReferenceProxyImpl.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/jdi/ThreadGroupReferenceProxyImpl.java index 3f502929ab31..90a461ecf136 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/jdi/ThreadGroupReferenceProxyImpl.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/jdi/ThreadGroupReferenceProxyImpl.java @@ -21,7 +21,6 @@ import org.slf4j.LoggerFactory; import java.util.List; -import java.util.stream.Collectors; /** * Proxy implementation for JDI thread group. @@ -77,12 +76,12 @@ public void resume() { public List threads() { return getThreadGroupReference().threads().stream().map(getVirtualMachineProxy()::getThreadReferenceProxy) - .collect(Collectors.toList()); + .toList(); } public List threadGroups() { return getThreadGroupReference().threadGroups().stream().map(getVirtualMachineProxy() - ::getThreadGroupReferenceProxy).collect(Collectors.toList()); + ::getThreadGroupReferenceProxy).toList(); } @Override diff --git a/misc/docerina/src/main/java/org/ballerinalang/docgen/Generator.java b/misc/docerina/src/main/java/org/ballerinalang/docgen/Generator.java index 2030c69bce42..baeeb2bf1d10 100644 --- a/misc/docerina/src/main/java/org/ballerinalang/docgen/Generator.java +++ b/misc/docerina/src/main/java/org/ballerinalang/docgen/Generator.java @@ -95,7 +95,7 @@ import java.util.List; import java.util.Optional; import java.util.StringJoiner; -import java.util.stream.Collectors; +import java.util.stream.Stream; /** * Generates the Page bClasses for bal packages. @@ -575,13 +575,11 @@ private static BClass getClassModel(ClassDefinitionNode classDefinitionNode, Sem } // Get functions that are not overridden - List functions = includedFunctions.stream().filter(includedFunction -> + List functions = Stream.concat(includedFunctions.stream().filter(includedFunction -> classFunctions .stream() - .noneMatch(objFunction -> objFunction.name.equals(includedFunction.name))) - .collect(Collectors.toList()); - - functions.addAll(classFunctions); + .noneMatch(objFunction -> objFunction.name.equals(includedFunction.name))), + classFunctions.stream()).toList(); if (containsToken(classDefinitionNode.classTypeQualifiers(), SyntaxKind.CLIENT_KEYWORD)) { return new Client(name, description, descriptionSections, isDeprecated, fields, functions, isReadOnly, @@ -692,13 +690,10 @@ private static BObjectType getObjectTypeModel(ObjectTypeDescriptorNode typeDescr } // Get functions that are not overridden - List functions = includedFunctions.stream().filter(includedFunction -> - objectFunctions - .stream() - .noneMatch(objFunction -> objFunction.name.equals(includedFunction.name))) - .collect(Collectors.toList()); - - functions.addAll(objectFunctions); + List functions = Stream.concat( + includedFunctions.stream().filter(includedFunction -> objectFunctions.stream() + .noneMatch(objFunction -> objFunction.name.equals(includedFunction.name))), + objectFunctions.stream()).toList(); return new BObjectType(objectName, description, descriptionSections, isDeprecated, fields, functions); } @@ -708,7 +703,7 @@ private static List mapFunctionTypesToFunctions(List fun for (FunctionType functionType : functionTypes) { List parameters = new ArrayList<>(functionType.paramTypes.stream() .map(type -> new DefaultableVariable(type.name, type.description, false, - type.elementType, "")).collect(Collectors.toList())); + type.elementType, "")).toList()); List returnParameters = new ArrayList<>(); if (functionType.returnType != null) { diff --git a/misc/docerina/src/main/java/org/ballerinalang/docgen/generator/model/BClass.java b/misc/docerina/src/main/java/org/ballerinalang/docgen/generator/model/BClass.java index d756053b5ce1..1f9c0d991952 100644 --- a/misc/docerina/src/main/java/org/ballerinalang/docgen/generator/model/BClass.java +++ b/misc/docerina/src/main/java/org/ballerinalang/docgen/generator/model/BClass.java @@ -19,7 +19,6 @@ import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** * Represent documentation for an BClass. @@ -64,7 +63,7 @@ public Optional getInitMethod(List methods) { public List getOtherMethods(List methods) { return methods.stream() .filter(function -> !function.name.equals("init")) - .collect(Collectors.toList()); + .toList(); } } diff --git a/misc/docerina/src/main/java/org/ballerinalang/docgen/generator/model/Client.java b/misc/docerina/src/main/java/org/ballerinalang/docgen/generator/model/Client.java index 6be5cc73be5d..44f757f23f59 100644 --- a/misc/docerina/src/main/java/org/ballerinalang/docgen/generator/model/Client.java +++ b/misc/docerina/src/main/java/org/ballerinalang/docgen/generator/model/Client.java @@ -18,7 +18,6 @@ import com.google.gson.annotations.Expose; import java.util.List; -import java.util.stream.Collectors; /** * Represent documentation for a Client. @@ -43,18 +42,18 @@ public Client(String name, String description, List descriptionSections, public List getOtherMethods(List methods) { return super.getOtherMethods(methods).stream() .filter(function -> !function.isRemote && !function.isResource) - .collect(Collectors.toList()); + .toList(); } private List getRemoteMethods() { return this.methods.stream() .filter(function -> function.isRemote) - .collect(Collectors.toList()); + .toList(); } private List getResourceMethods() { return this.methods.stream() .filter(function -> function.isResource) - .collect(Collectors.toList()); + .toList(); } } diff --git a/misc/docerina/src/main/java/org/ballerinalang/docgen/generator/model/Listener.java b/misc/docerina/src/main/java/org/ballerinalang/docgen/generator/model/Listener.java index 44567f491c4f..584d5e84dc19 100644 --- a/misc/docerina/src/main/java/org/ballerinalang/docgen/generator/model/Listener.java +++ b/misc/docerina/src/main/java/org/ballerinalang/docgen/generator/model/Listener.java @@ -18,7 +18,6 @@ import com.google.gson.annotations.Expose; import java.util.List; -import java.util.stream.Collectors; /** * Represent documentation for a Listener. @@ -41,7 +40,7 @@ public List getLCMethods(List methods) { .filter(function -> function.name.equals("attach") || function.name.equals("start") || function.name.equals("stop")) - .collect(Collectors.toList()); + .toList(); } @Override @@ -50,6 +49,6 @@ public List getOtherMethods(List methods) { .filter(function -> !(function.name.equals("attach") || function.name.equals("start") || function.name.equals("stop"))) - .collect(Collectors.toList()); + .toList(); } } diff --git a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java index f1a1c31990ae..9fa71cca1988 100644 --- a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java +++ b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java @@ -181,7 +181,7 @@ public static JsonToRecordResponse convert(String jsonString, String recordName, Token semicolon = AbstractNodeFactory.createToken(SyntaxKind.SEMICOLON_TOKEN); return NodeFactory.createTypeDefinitionNode(null, null, typeKeyWord, typeName, entry.getValue(), semicolon); - }).collect(Collectors.toList()); + }).toList(); NodeList moduleMembers; if (isRecordTypeDesc) { diff --git a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java index 681c09398ae5..13c9b46fc9c0 100644 --- a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java +++ b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java @@ -45,7 +45,6 @@ import java.util.Comparator; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import java.util.stream.Stream; import static io.ballerina.identifier.Utils.escapeSpecialCharacters; @@ -219,12 +218,11 @@ public static List extractTypeDescriptorNodes(List} The sorted TypeDescriptorNode list. */ public static List sortTypeDescriptorNodes(List typeDescriptorNodes) { - List nonArrayNodes = typeDescriptorNodes.stream() - .filter(node -> !(node instanceof ArrayTypeDescriptorNode)).collect(Collectors.toList()); - List arrayNodes = typeDescriptorNodes.stream() - .filter(node -> (node instanceof ArrayTypeDescriptorNode)).collect(Collectors.toList()); - nonArrayNodes.sort(Comparator.comparing(TypeDescriptorNode::toSourceCode)); - arrayNodes.sort((node1, node2) -> { + Stream nonArrayNodes = typeDescriptorNodes.stream() + .filter(node -> !(node instanceof ArrayTypeDescriptorNode)) + .sorted(Comparator.comparing(TypeDescriptorNode::toSourceCode)); + Stream arrayNodes = typeDescriptorNodes.stream() + .filter(node -> (node instanceof ArrayTypeDescriptorNode)).sorted((node1, node2) -> { ArrayTypeDescriptorNode arrayNode1 = (ArrayTypeDescriptorNode) node1; ArrayTypeDescriptorNode arrayNode2 = (ArrayTypeDescriptorNode) node2; return getNumberOfDimensions(arrayNode1).equals(getNumberOfDimensions(arrayNode2)) ? @@ -232,7 +230,7 @@ public static List sortTypeDescriptorNodes(List generatedDiagnosticMessages = response.getDiagnostics().stream() - .map(JsonToRecordMapperDiagnostic::toString).collect(Collectors.toList()); + .map(JsonToRecordMapperDiagnostic::toString).toList(); List expectedCDiagnosticMessages = List.of("[ERROR] Provided JSON is invalid : " + "Unterminated object at line 5 column 4 path $.position"); Assert.assertEquals(generatedDiagnosticMessages, expectedCDiagnosticMessages); @@ -417,7 +416,7 @@ public void testJSON2RecordServiceNullJSON() throws IOException, ExecutionExcept io.ballerina.jsonmapper.JsonToRecordResponse response = (io.ballerina.jsonmapper.JsonToRecordResponse) result.get(); List generatedDiagnosticMessages = response.getDiagnostics().stream() - .map(JsonToRecordMapperDiagnostic::toString).collect(Collectors.toList()); + .map(JsonToRecordMapperDiagnostic::toString).toList(); List expectedCDiagnosticMessages = List.of("[ERROR] Provided JSON is unsupported. It may be null or have missing types."); Assert.assertEquals(generatedDiagnosticMessages, expectedCDiagnosticMessages); diff --git a/misc/semver-checker/modules/semver-checker-core/src/main/java/io/ballerina/semver/checker/BallerinaPackageResolver.java b/misc/semver-checker/modules/semver-checker-core/src/main/java/io/ballerina/semver/checker/BallerinaPackageResolver.java index 31245e69bf28..bf63a7b66ac8 100644 --- a/misc/semver-checker/modules/semver-checker-core/src/main/java/io/ballerina/semver/checker/BallerinaPackageResolver.java +++ b/misc/semver-checker/modules/semver-checker-core/src/main/java/io/ballerina/semver/checker/BallerinaPackageResolver.java @@ -101,7 +101,7 @@ SemanticVersion resolveClosestCompatibleCentralVersion(String orgName, String pk "Ballerina central under the org '%s' with name '%s'", orgName, pkgName)); } List availableVersions = publishedVersions.stream().map(SemanticVersion::from) - .collect(Collectors.toList()); + .toList(); Optional compatibleVersion = selectCompatibleVersion(availableVersions, localVersion); if (compatibleVersion.isEmpty()) { diff --git a/misc/semver-checker/modules/semver-checker-core/src/main/java/io/ballerina/semver/checker/comparator/DumbNodeListComparator.java b/misc/semver-checker/modules/semver-checker-core/src/main/java/io/ballerina/semver/checker/comparator/DumbNodeListComparator.java index 3ed215aac0ed..3e34804c91c9 100644 --- a/misc/semver-checker/modules/semver-checker-core/src/main/java/io/ballerina/semver/checker/comparator/DumbNodeListComparator.java +++ b/misc/semver-checker/modules/semver-checker-core/src/main/java/io/ballerina/semver/checker/comparator/DumbNodeListComparator.java @@ -59,8 +59,8 @@ public class DumbNodeListComparator implements Comparator { } DumbNodeListComparator(NodeList newNodes, NodeList oldNodes, DiffKind nodeKind) { - this.newNodes = newNodes != null ? newNodes.stream().collect(Collectors.toList()) : null; - this.oldNodes = oldNodes != null ? oldNodes.stream().collect(Collectors.toList()) : null; + this.newNodes = newNodes != null ? newNodes.stream().toList() : null; + this.oldNodes = oldNodes != null ? oldNodes.stream().toList() : null; this.nodeKind = nodeKind; } diff --git a/misc/semver-checker/modules/semver-checker-core/src/main/java/io/ballerina/semver/checker/comparator/FunctionComparator.java b/misc/semver-checker/modules/semver-checker-core/src/main/java/io/ballerina/semver/checker/comparator/FunctionComparator.java index ff3cfdb3e4e3..b0e48a11371c 100644 --- a/misc/semver-checker/modules/semver-checker-core/src/main/java/io/ballerina/semver/checker/comparator/FunctionComparator.java +++ b/misc/semver-checker/modules/semver-checker-core/src/main/java/io/ballerina/semver/checker/comparator/FunctionComparator.java @@ -39,7 +39,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; import static io.ballerina.compiler.syntax.tree.SyntaxKind.ISOLATED_KEYWORD; import static io.ballerina.compiler.syntax.tree.SyntaxKind.PUBLIC_KEYWORD; @@ -164,8 +163,8 @@ private List compareFunctionQualifiers() { private List compareFunctionParams() { List paramDiffs = new ArrayList<>(); - List newParams = newNode.functionSignature().parameters().stream().collect(Collectors.toList()); - List oldParams = oldNode.functionSignature().parameters().stream().collect(Collectors.toList()); + List newParams = newNode.functionSignature().parameters().stream().toList(); + List oldParams = oldNode.functionSignature().parameters().stream().toList(); ParamListComparator paramComparator = new ParamListComparator(newParams, oldParams); paramComparator.computeDiff().ifPresent(diff -> diff --git a/misc/semver-checker/modules/semver-checker-core/src/main/java/io/ballerina/semver/checker/comparator/ServiceComparator.java b/misc/semver-checker/modules/semver-checker-core/src/main/java/io/ballerina/semver/checker/comparator/ServiceComparator.java index 3fd125d3f169..9af1c5967f6d 100644 --- a/misc/semver-checker/modules/semver-checker-core/src/main/java/io/ballerina/semver/checker/comparator/ServiceComparator.java +++ b/misc/semver-checker/modules/semver-checker-core/src/main/java/io/ballerina/semver/checker/comparator/ServiceComparator.java @@ -43,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; import static io.ballerina.compiler.syntax.tree.SyntaxKind.ISOLATED_KEYWORD; import static io.ballerina.semver.checker.util.SyntaxTreeUtils.getFunctionIdentifier; @@ -145,8 +144,8 @@ private List compareServiceTypeDesc() { private List compareAttachPoints() { // TODO: implement attach point comparator Optional diff = new DumbNodeListComparator<>( - newNode.absoluteResourcePath().stream().collect(Collectors.toList()), - oldNode.absoluteResourcePath().stream().collect(Collectors.toList())) + newNode.absoluteResourcePath().stream().toList(), + oldNode.absoluteResourcePath().stream().toList()) .computeDiff(); return diff.>map(Collections::singletonList).orElseGet(ArrayList::new); } @@ -160,8 +159,8 @@ private List compareListenerExpressions() { new DumbNodeComparator<>(newListener, oldListener, DiffKind.SERVICE_LISTENER_EXPR).computeDiff() .ifPresent(listenerDiffs::add); } else { - new DumbNodeListComparator<>(newNode.expressions().stream().collect(Collectors.toList()), - oldNode.expressions().stream().collect(Collectors.toList())).computeDiff() + new DumbNodeListComparator<>(newNode.expressions().stream().toList(), + oldNode.expressions().stream().toList()).computeDiff() .ifPresent(listenerDiffs::add); } diff --git a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java index d7bcf39d2813..656d70c443ab 100644 --- a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java +++ b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java @@ -54,7 +54,6 @@ import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import static io.ballerina.runtime.api.constants.RuntimeConstants.FILE_NAME_PERIOD_SEPARATOR; @@ -108,7 +107,7 @@ public void process(SimpleVariableNode simpleVariableNode, List annotations) { BLangPackage parent = (BLangPackage) ((BLangFunction) functionNode).parent; String packageName = getPackageName(parent); - annotations = annotations.stream().distinct().collect(Collectors.toList()); + annotations = annotations.stream().distinct().toList(); // Iterate through all the annotations for (AnnotationAttachmentNode attachmentNode : annotations) { diff --git a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/entity/CoverageReport.java b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/entity/CoverageReport.java index a84f893d792d..020bde2d9756 100644 --- a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/entity/CoverageReport.java +++ b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/entity/CoverageReport.java @@ -58,6 +58,7 @@ import java.util.Map; import java.util.Optional; import java.util.Set; +import java.util.stream.Stream; import static io.ballerina.identifier.Utils.decodeIdentifier; import static org.ballerinalang.test.runtime.util.TesterinaConstants.BIN_DIR; @@ -618,17 +619,14 @@ private List getExclusionJarList(JBallerinaBackend jBallerinaBackend, Pack } private List getPlatformLibsList(JBallerinaBackend jBallerinaBackend, Package pkg) { - List platformLibsList = new ArrayList<>(); - Collection otherJarDependencies = jBallerinaBackend.platformLibraryDependencies( - pkg.packageId(), PlatformLibraryScope.DEFAULT); - otherJarDependencies.addAll(jBallerinaBackend.platformLibraryDependencies( - pkg.packageId(), PlatformLibraryScope.PROVIDED)); - for (PlatformLibrary otherJarDependency : otherJarDependencies) { - if (!platformLibsList.contains(otherJarDependency.path())) { - platformLibsList.add(otherJarDependency.path()); - } - } - return platformLibsList; + return Stream.concat( + jBallerinaBackend.platformLibraryDependencies( + pkg.packageId(), PlatformLibraryScope.DEFAULT).stream(), + jBallerinaBackend.platformLibraryDependencies( + pkg.packageId(), PlatformLibraryScope.PROVIDED).stream()) + .map(PlatformLibrary::path) + .distinct() + .toList(); } private List getDependencyJarList(JBallerinaBackend jBallerinaBackend) { @@ -645,10 +643,12 @@ private List getDependencyJarList(JBallerinaBackend jBallerinaBackend) { dependencyPathList.add(generatedJarLibrary.path()); } } - Collection otherJarDependencies = jBallerinaBackend.platformLibraryDependencies( - pkg.packageId(), PlatformLibraryScope.DEFAULT); - otherJarDependencies.addAll(jBallerinaBackend.platformLibraryDependencies( - pkg.packageId(), PlatformLibraryScope.PROVIDED)); + Collection otherJarDependencies = Stream.concat( + jBallerinaBackend.platformLibraryDependencies( + pkg.packageId(), PlatformLibraryScope.DEFAULT).stream(), + jBallerinaBackend.platformLibraryDependencies( + pkg.packageId(), PlatformLibraryScope.PROVIDED).stream()).toList(); + for (PlatformLibrary otherJarDependency : otherJarDependencies) { if (!dependencyPathList.contains(otherJarDependency.path())) { dependencyPathList.add(otherJarDependency.path()); diff --git a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/entity/TestReport.java b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/entity/TestReport.java index f0fbf1181fdb..75e2146a98ec 100644 --- a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/entity/TestReport.java +++ b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/entity/TestReport.java @@ -22,7 +22,6 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.List; -import java.util.stream.Collectors; /** * Final test report with coverage (if enabled). @@ -139,11 +138,11 @@ public void finalizeTestResults(boolean coverage) { // sort the module list to be in the alphabetical order moduleStatus = moduleStatus.stream() .sorted(Comparator.comparing(ModuleStatus::getName)) - .collect(Collectors.toList()); + .toList(); moduleCoverage = moduleCoverage.stream() .sorted(Comparator.comparing(ModuleCoverage::getName)) - .collect(Collectors.toList()); + .toList(); } public float getCoveragePercentage() { diff --git a/misc/toml-parser/src/main/java/io/ballerina/toml/syntax/tree/AbstractNodeFactory.java b/misc/toml-parser/src/main/java/io/ballerina/toml/syntax/tree/AbstractNodeFactory.java index 5af73017a47d..51de768d1e02 100644 --- a/misc/toml-parser/src/main/java/io/ballerina/toml/syntax/tree/AbstractNodeFactory.java +++ b/misc/toml-parser/src/main/java/io/ballerina/toml/syntax/tree/AbstractNodeFactory.java @@ -27,7 +27,6 @@ import java.util.Collection; import java.util.Collections; import java.util.Objects; -import java.util.stream.Collectors; /** * A factory for creating nodes in the syntax tree. @@ -143,7 +142,7 @@ public static MinutiaeList createMinutiaeList(Collection minutiaeNodes minutiaeNodes.stream() .map(minutiae -> Objects.requireNonNull(minutiae, "minutiae should not be null")) .map(Minutiae::internalNode) - .collect(Collectors.toList())), 0); + .toList()), 0); } public static Minutiae createCommentMinutiae(String text) { @@ -188,7 +187,7 @@ public static NodeList createNodeList(Collection nodes) { nodes.stream() .map(node -> Objects.requireNonNull(node, "node should not be null")) .map(Node::internalNode) - .collect(Collectors.toList())).createUnlinkedFacade()); + .toList()).createUnlinkedFacade()); } public static SeparatedNodeList createSeparatedNodeList(Node... nodes) { @@ -206,7 +205,7 @@ public static SeparatedNodeList createSeparatedNodeList(Coll nodes.stream() .map(node -> Objects.requireNonNull(node, "node should not be null")) .map(Node::internalNode) - .collect(Collectors.toList())).createUnlinkedFacade()); + .toList()).createUnlinkedFacade()); } protected static STNode getOptionalSTNode(Node node) { diff --git a/misc/toml-parser/src/main/java/io/ballerina/toml/syntax/tree/MinutiaeList.java b/misc/toml-parser/src/main/java/io/ballerina/toml/syntax/tree/MinutiaeList.java index 9f678916c16e..3fe19c63b730 100644 --- a/misc/toml-parser/src/main/java/io/ballerina/toml/syntax/tree/MinutiaeList.java +++ b/misc/toml-parser/src/main/java/io/ballerina/toml/syntax/tree/MinutiaeList.java @@ -28,7 +28,6 @@ import java.util.Iterator; import java.util.List; import java.util.Objects; -import java.util.stream.Collectors; import static io.ballerina.toml.internal.syntax.NodeListUtils.rangeCheck; import static io.ballerina.toml.internal.syntax.NodeListUtils.rangeCheckForAdd; @@ -87,7 +86,7 @@ public MinutiaeList addAll(Collection c) { List stNodesToBeAdded = c.stream() .map(minutiae -> Objects.requireNonNull(minutiae, "minutiae should not be null")) .map(Minutiae::internalNode) - .collect(Collectors.toList()); + .toList(); return new MinutiaeList(token, internalListNode.addAll(stNodesToBeAdded), position); diff --git a/misc/toml-parser/src/main/java/io/ballerina/toml/syntax/tree/NodeList.java b/misc/toml-parser/src/main/java/io/ballerina/toml/syntax/tree/NodeList.java index a2f5fd7b9000..e0fb3cc7628e 100644 --- a/misc/toml-parser/src/main/java/io/ballerina/toml/syntax/tree/NodeList.java +++ b/misc/toml-parser/src/main/java/io/ballerina/toml/syntax/tree/NodeList.java @@ -26,7 +26,6 @@ import java.util.Iterator; import java.util.List; import java.util.Objects; -import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; @@ -85,7 +84,7 @@ public NodeList addAll(Collection c) { List stNodesToBeAdded = c.stream() .map(node -> Objects.requireNonNull(node, "node should not be null")) .map(Node::internalNode) - .collect(Collectors.toList()); + .toList(); return new NodeList<>(internalListNode.addAll(stNodesToBeAdded).createUnlinkedFacade()); } diff --git a/misc/toml-parser/src/main/java/io/ballerina/toml/syntax/tree/NonTerminalNode.java b/misc/toml-parser/src/main/java/io/ballerina/toml/syntax/tree/NonTerminalNode.java index 1ced0ca46f42..891c931a06ed 100644 --- a/misc/toml-parser/src/main/java/io/ballerina/toml/syntax/tree/NonTerminalNode.java +++ b/misc/toml-parser/src/main/java/io/ballerina/toml/syntax/tree/NonTerminalNode.java @@ -28,7 +28,6 @@ import java.util.Collections; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; import java.util.stream.IntStream; import static io.ballerina.toml.internal.syntax.SyntaxUtils.isSTNodePresent; @@ -70,7 +69,7 @@ public Collection childEntries() { IntStream.range(0, bucketCount()) .filter(bucket -> childInBucket(bucket) != null) .mapToObj(bucket -> new ChildNodeEntry(childNames[bucket], childInBucket(bucket))) - .collect(Collectors.toList())); + .toList()); } @Override diff --git a/misc/xml-to-record-converter/src/main/java/io/ballerina/xmltorecordconverter/util/ConverterUtils.java b/misc/xml-to-record-converter/src/main/java/io/ballerina/xmltorecordconverter/util/ConverterUtils.java index 1ebb5a1c02ea..0a2100f94e26 100644 --- a/misc/xml-to-record-converter/src/main/java/io/ballerina/xmltorecordconverter/util/ConverterUtils.java +++ b/misc/xml-to-record-converter/src/main/java/io/ballerina/xmltorecordconverter/util/ConverterUtils.java @@ -135,7 +135,7 @@ public static List sortTypeDescriptorNodes(List diagnosticFilePaths = compilation.diagnosticResult().diagnostics().stream().map(diagnostic -> - diagnostic.location().lineRange().fileName()).distinct().collect(Collectors.toList()); + diagnostic.location().lineRange().fileName()).distinct().toList(); for (String path : expectedPaths) { Assert.assertTrue(diagnosticFilePaths.contains(path), diagnosticFilePaths.toString()); @@ -2255,7 +2255,7 @@ public void testDocumentsOrder() { PackageCompilation compilation = currentPackage.getCompilation(); List actualDiagnosticPaths = compilation.diagnosticResult().diagnostics().stream().map(diagnostic -> - diagnostic.location().lineRange().fileName()).distinct().collect(Collectors.toList()); + diagnostic.location().lineRange().fileName()).distinct().toList(); List expectedDiagnosticPaths = Arrays.asList( "main.bal", Paths.get("tests").resolve("main_test.bal").toString(), diff --git a/project-api/project-api-test/src/test/java/io/ballerina/projects/test/TestBuildProjectWithGeneratedSources.java b/project-api/project-api-test/src/test/java/io/ballerina/projects/test/TestBuildProjectWithGeneratedSources.java index 19071691641c..727e64cbcdd9 100644 --- a/project-api/project-api-test/src/test/java/io/ballerina/projects/test/TestBuildProjectWithGeneratedSources.java +++ b/project-api/project-api-test/src/test/java/io/ballerina/projects/test/TestBuildProjectWithGeneratedSources.java @@ -30,6 +30,8 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.Test; +import java.io.PrintWriter; +import java.io.StringWriter; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Collection; @@ -189,7 +191,9 @@ private static BuildProject loadBuildProject(Path projectPath, BuildOptions buil buildProject = TestUtils.loadBuildProject(projectPath, buildOptions); } } catch (Exception e) { - Assert.fail(e.getMessage()); + StringWriter errors = new StringWriter(); + e.printStackTrace(new PrintWriter(errors)); + Assert.fail(errors.toString()); } return buildProject; } diff --git a/project-api/project-api-test/src/test/java/io/ballerina/projects/test/plugins/LanguageServerExtensionTests.java b/project-api/project-api-test/src/test/java/io/ballerina/projects/test/plugins/LanguageServerExtensionTests.java index 32810faa8eb8..6fe39b80cbf0 100644 --- a/project-api/project-api-test/src/test/java/io/ballerina/projects/test/plugins/LanguageServerExtensionTests.java +++ b/project-api/project-api-test/src/test/java/io/ballerina/projects/test/plugins/LanguageServerExtensionTests.java @@ -67,7 +67,6 @@ import java.nio.file.Paths; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** * Tests for language server's extensions. @@ -125,7 +124,7 @@ public void testOneCompilerPluginWithOneCodeAction() { List arguments = info.get().getArguments(); arguments = arguments.stream() .map(codeActionArgument -> CodeActionArgument.from(gson.toJsonTree(codeActionArgument))) - .collect(Collectors.toList()); + .toList(); Assert.assertFalse(arguments.isEmpty()); diff --git a/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/LangLibFunctionTest.java b/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/LangLibFunctionTest.java index 970714a69876..a53f787555b1 100644 --- a/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/LangLibFunctionTest.java +++ b/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/LangLibFunctionTest.java @@ -255,11 +255,11 @@ public Object[][] getXMLInfo() { return new Object[][]{ {68, 8, XML, expFunctions}, {69, 17, TYPE_REFERENCE, Stream.concat(expFunctions.stream(), elementFuncs.stream()) - .collect(Collectors.toList())}, + .toList()}, {79, 31, TYPE_REFERENCE, Stream.concat(expFunctions.stream(), piFuncs.stream()) - .collect(Collectors.toList())}, + .toList()}, {80, 17, TYPE_REFERENCE, Stream.concat(expFunctions.stream(), commentFuncs.stream()) - .collect(Collectors.toList())}, + .toList()}, {81, 14, TYPE_REFERENCE, expFunctions}, }; } @@ -384,7 +384,7 @@ public Object[][] getTableInfo() { return new Object[][]{ {64, 22, expFunctions}, - {65, 32, Stream.concat(expFunctions.stream(), additionalFuncs.stream()).collect(Collectors.toList())}, + {65, 32, Stream.concat(expFunctions.stream(), additionalFuncs.stream()).toList()}, {66, 37, expFunctions}, }; } diff --git a/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/ServiceSemanticAPITest.java b/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/ServiceSemanticAPITest.java index 903a9e2cccf6..7eee893952a6 100644 --- a/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/ServiceSemanticAPITest.java +++ b/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/ServiceSemanticAPITest.java @@ -49,7 +49,6 @@ import java.util.Arrays; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; import java.util.stream.Stream; import static io.ballerina.compiler.api.symbols.Qualifier.FINAL; @@ -325,10 +324,10 @@ private List getFilteredSymbolNames(List symbols) { return symbols.stream() .filter(s -> s.getModule().isPresent() && !"ballerina".equals(s.getModule().get().getModule().get().id().orgName())) - .collect(Collectors.toList()); + .toList(); } private List concatSymbols(List moduleSymbols, String... symbols) { - return Stream.concat(moduleSymbols.stream(), Arrays.stream(symbols)).collect(Collectors.toList()); + return Stream.concat(moduleSymbols.stream(), Arrays.stream(symbols)).toList(); } } diff --git a/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/SymbolEquivalenceTest.java b/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/SymbolEquivalenceTest.java index cd78d1742b5f..5a287003768d 100644 --- a/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/SymbolEquivalenceTest.java +++ b/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/SymbolEquivalenceTest.java @@ -34,7 +34,6 @@ import org.testng.annotations.Test; import java.util.List; -import java.util.stream.Collectors; import static io.ballerina.compiler.api.symbols.SymbolKind.RECORD_FIELD; import static io.ballerina.semantic.api.test.util.SemanticAPITestUtils.getDefaultModulesSemanticModel; @@ -72,7 +71,7 @@ public void setup() { public void testSymbols(List positions) { List symbols = positions.stream() .map(pos -> model.symbol(srcFile, pos).get()) - .collect(Collectors.toList()); + .toList(); assertSymbols(symbols); } @@ -113,7 +112,7 @@ public void testTypeRefEquivalence() { SemanticModel typeRefModel = SemanticAPITestUtils.getDefaultModulesSemanticModel("test-src/typedesc_test.bal"); List symbols = positions.stream() .map(pos -> typeRefModel.symbol(typesSrcFile, pos).get()) - .collect(Collectors.toList()); + .toList(); assertSymbols(symbols); } @@ -128,7 +127,7 @@ public void testTypedescriptors(List positions) { case VARIABLE -> ((VariableSymbol) s).typeDescriptor(); default -> throw new AssertionError("Unexpected symbol kind: " + s.kind()); }) - .collect(Collectors.toList()); + .toList(); assertTypeSymbols(types); } diff --git a/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/SymbolLookupTest.java b/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/SymbolLookupTest.java index f54ab542482b..0a26fc95a1d4 100644 --- a/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/SymbolLookupTest.java +++ b/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/SymbolLookupTest.java @@ -41,7 +41,6 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import java.util.stream.Stream; import static io.ballerina.compiler.api.symbols.DiagnosticState.REDECLARED; @@ -418,6 +417,6 @@ private String createSymbolString(Symbol symbol) { } private List concatSymbols(List moduleSymbols, String... symbols) { - return Stream.concat(moduleSymbols.stream(), Arrays.stream(symbols)).collect(Collectors.toList()); + return Stream.concat(moduleSymbols.stream(), Arrays.stream(symbols)).toList(); } } diff --git a/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/TestSourcesTest.java b/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/TestSourcesTest.java index 906d9dcf6c4d..440564936f2f 100644 --- a/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/TestSourcesTest.java +++ b/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/TestSourcesTest.java @@ -37,7 +37,6 @@ import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; import static io.ballerina.compiler.api.symbols.TypeDescKind.FLOAT; import static io.ballerina.compiler.api.symbols.TypeDescKind.INT; @@ -99,7 +98,7 @@ public void testVisibleSymbols(int line, int col, List expSymbols) { String moduleName = sym.getModule().get().id().moduleName(); return moduleName.equals("semapi.baz") || !moduleName.startsWith("lang."); }) - .collect(Collectors.toList()); + .toList(); assertEquals(symbols.size(), expSymbols.size()); assertList(symbols, expSymbols); diff --git a/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/symbols/ClassSymbolTest.java b/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/symbols/ClassSymbolTest.java index 982387fdca33..3f50ae544f34 100644 --- a/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/symbols/ClassSymbolTest.java +++ b/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/symbols/ClassSymbolTest.java @@ -42,7 +42,6 @@ import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; import static io.ballerina.compiler.api.symbols.SymbolKind.CLASS; import static io.ballerina.compiler.api.symbols.SymbolKind.CLASS_FIELD; @@ -88,7 +87,7 @@ public void testSymbolAtCursor() { assertEquals(initMethod.getName().get(), "init"); assertEquals(initMethod.typeDescriptor().params().get().stream() .map(p -> p.getName().get()) - .collect(Collectors.toList()), fieldNames); + .toList(), fieldNames); } @Test diff --git a/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/symbols/UnionTypeSymbolTest.java b/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/symbols/UnionTypeSymbolTest.java index 10ea35627803..bcb5c91c089b 100644 --- a/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/symbols/UnionTypeSymbolTest.java +++ b/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/symbols/UnionTypeSymbolTest.java @@ -32,7 +32,6 @@ import org.testng.annotations.Test; import java.util.List; -import java.util.stream.Collectors; import static io.ballerina.semantic.api.test.util.SemanticAPITestUtils.assertBasicsAndGetSymbol; import static io.ballerina.semantic.api.test.util.SemanticAPITestUtils.getDefaultModulesSemanticModel; @@ -69,7 +68,7 @@ public void testUnionTypeMemberTypes(int line, int col, String name, List memberTypeDescKindList = memberTypeDescriptors .stream() .map(TypeSymbol::typeKind) - .collect(Collectors.toList()); + .toList(); assertList(memberTypeDescKindList, expTypeList); } @@ -112,7 +111,7 @@ public void testSingletonMembers() { .stream() .filter(member -> member.typeKind() == TypeDescKind.SINGLETON) .map(TypeSymbol::signature) - .collect(Collectors.toList()); + .toList(); assertList(signatures, List.of("\"int\"", "\"string\"", "100", "\"200\"", "true")); } diff --git a/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/util/SemanticAPITestUtils.java b/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/util/SemanticAPITestUtils.java index 1b9a0a283c28..c12a31476fc1 100644 --- a/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/util/SemanticAPITestUtils.java +++ b/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/util/SemanticAPITestUtils.java @@ -154,12 +154,12 @@ public static Map getSymbolsInFile(SemanticModel model, Document } public static List getSymbolNames(List mainList, String... args) { - return Stream.concat(mainList.stream(), Stream.of(args)).collect(Collectors.toList()); + return Stream.concat(mainList.stream(), Stream.of(args)).toList(); } @SafeVarargs public static List getSymbolNames(List... lists) { - return Arrays.stream(lists).flatMap(Collection::stream).collect(Collectors.toList()); + return Arrays.stream(lists).flatMap(Collection::stream).toList(); } public static List getSymbolNames(BPackageSymbol pkgSymbol, int symTag) { diff --git a/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/visiblesymbols/BaseVisibleSymbolsTest.java b/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/visiblesymbols/BaseVisibleSymbolsTest.java index 883c0c1e2cda..67f03cb4f1c3 100644 --- a/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/visiblesymbols/BaseVisibleSymbolsTest.java +++ b/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/visiblesymbols/BaseVisibleSymbolsTest.java @@ -37,7 +37,6 @@ import java.util.List; import java.util.Map; import java.util.function.Consumer; -import java.util.stream.Collectors; import java.util.stream.Stream; import static io.ballerina.semantic.api.test.util.SemanticAPITestUtils.getDocumentForSingleSource; @@ -91,7 +90,7 @@ Consumer> getAdditionalAssertions() { } List concat(List list, ExpectedSymbolInfo... symbols) { - return Stream.concat(list.stream(), Stream.of(symbols)).collect(Collectors.toList()); + return Stream.concat(list.stream(), Stream.of(symbols)).toList(); } static class ExpectedSymbolInfo { diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/BreakpointVerificationTest.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/BreakpointVerificationTest.java index f3d7950cb5e9..4e4603e10776 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/BreakpointVerificationTest.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/BreakpointVerificationTest.java @@ -35,7 +35,6 @@ import java.util.Arrays; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** * Test implementation for debug breakpoint verification scenarios. @@ -107,7 +106,7 @@ public void testOnTheFlyBreakpointVerification() throws BallerinaTestException { List breakPoints = Arrays.stream(breakpointResponse.get().getBreakpoints()) .map(breakpoint -> new BallerinaTestDebugPoint(Path.of(breakpoint.getSource().getPath()), breakpoint.getLine(), breakpoint.isVerified())) - .collect(Collectors.toList()); + .toList(); assertBreakpointChanges(breakPoints); } diff --git a/tests/jballerina-integration-test/src/test/java/org/ballerinalang/test/troubleshoot/StrandDumpTest.java b/tests/jballerina-integration-test/src/test/java/org/ballerinalang/test/troubleshoot/StrandDumpTest.java index 5f143179bf79..a8149b761ee6 100644 --- a/tests/jballerina-integration-test/src/test/java/org/ballerinalang/test/troubleshoot/StrandDumpTest.java +++ b/tests/jballerina-integration-test/src/test/java/org/ballerinalang/test/troubleshoot/StrandDumpTest.java @@ -37,7 +37,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import java.util.stream.Stream; /** @@ -175,7 +174,7 @@ private static void populateLeechers(List leecherList, Path leecherF private static List readFileNonEmptyLines(Path filePath) throws BallerinaTestException { try (Stream fileLines = Files.lines(filePath)) { - return fileLines.filter(s -> !s.isBlank()).collect(Collectors.toList()); + return fileLines.filter(s -> !s.isBlank()).toList(); } catch (IOException e) { throw new BallerinaTestException("Failure to read from the file: " + filePath); } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/AnnotationAttachmentTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/AnnotationAttachmentTest.java index e6d375ca2f32..466fb2e4c2a9 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/AnnotationAttachmentTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/AnnotationAttachmentTest.java @@ -61,7 +61,6 @@ import java.util.List; import java.util.Objects; import java.util.Optional; -import java.util.stream.Collectors; /** * Class to test annotation attachments. @@ -459,7 +458,7 @@ public void testAnnotWithEmptyMapConstructorOnService() { .get().getAnnotationAttachments() .stream() .filter(ann -> !isServiceIntropAnnot((BLangAnnotationAttachment) ann)) - .collect(Collectors.toList()); + .toList(); validateEmptyMapConstructorExprInAnnot(attachments, "v20", "A", 1); } @@ -628,7 +627,7 @@ private List getServiceClassAnnotations(String name) getServiceClassForServiceDecl(name).getAnnotationAttachments() .stream() .filter(ann -> !isServiceIntropAnnot((BLangAnnotationAttachment) ann)) - .collect(Collectors.toList()); + .toList(); } private ClassDefinition getServiceClassForServiceDecl(String name) { diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/packaging/PattenTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/packaging/PattenTest.java index 54e6ccc37ed7..0b24d88e1237 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/packaging/PattenTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/packaging/PattenTest.java @@ -12,7 +12,6 @@ import java.util.List; import java.util.function.BiFunction; import java.util.function.Function; -import java.util.stream.Collectors; import java.util.stream.Stream; import static org.wso2.ballerinalang.compiler.packaging.Patten.path; @@ -67,7 +66,7 @@ public void testReduction() { null, null); Patten subject = new Patten(path("hello", "world")); - List strings = subject.convert(mock, null).collect(Collectors.toList()); + List strings = subject.convert(mock, null).toList(); Assert.assertEquals(strings, Collections.singletonList("root-dir > hello > world")); } @@ -82,7 +81,7 @@ public void testDirExpansion() { null, null); Patten subject = new Patten(Patten.LATEST_VERSION_DIR); - List strings = subject.convert(mock, null).collect(Collectors.toList()); + List strings = subject.convert(mock, null).toList(); Assert.assertEquals(strings, Arrays.asList("root-dir > cache1", "root-dir > cache2", @@ -117,7 +116,7 @@ public void testBalExpansion() { s + " > dir2 > dir3 > f.bal"), null); Patten subject = new Patten(Patten.WILDCARD_SOURCE); - List strings = subject.convert(mock, null).collect(Collectors.toList()); + List strings = subject.convert(mock, null).toList(); Assert.assertEquals(strings, Arrays.asList("project-dir > dir1 > x.bal", "project-dir > y.bal", @@ -157,7 +156,7 @@ public void testReductionAndExpansion() { q + " > dir2 > dir3 > f.bal"), null); Patten subject = new Patten(path("hello"), Patten.LATEST_VERSION_DIR, path("world"), Patten.WILDCARD_SOURCE); - List strings = subject.convert(mock, null).collect(Collectors.toList()); + List strings = subject.convert(mock, null).toList(); Assert.assertEquals(strings, Arrays.asList("my-dir > hello > cache1 > world > dir1 > x.bal", "my-dir > hello > cache1 > world > y.bal", diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/packaging/URIConverterTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/packaging/URIConverterTest.java index c348b325ef32..ec78a1567929 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/packaging/URIConverterTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/packaging/URIConverterTest.java @@ -27,7 +27,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; -import java.util.stream.Collectors; import static org.wso2.ballerinalang.compiler.packaging.Patten.path; @@ -43,7 +42,7 @@ public void testURIConverter() { URIConverter subject = new URIConverter(baseURI, new HashMap<>()); List urls = patten.convert(subject, null) - .collect(Collectors.toList()); + .toList(); URI expected = URI.create("http://staging.central.ballerina.io:9090/modules/natasha/foo.bar/1.0.5/"); Assert.assertEquals(urls, Collections.singletonList(expected));