From 3ec60d126f5d257006e41e4d800d381daeeaef92 Mon Sep 17 00:00:00 2001 From: Frederik Claus Date: Sat, 7 Oct 2023 13:31:36 +0200 Subject: [PATCH] Removes not well understood sort logic --- .../com/microsoft/jdtls/ext/core/PackageCommand.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/PackageCommand.java b/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/PackageCommand.java index 3918ece0..e2f35f3b 100644 --- a/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/PackageCommand.java +++ b/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/PackageCommand.java @@ -14,7 +14,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.Comparator; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -589,14 +588,9 @@ public static IProject getProject(String projectUri) { throw new IllegalArgumentException(String.format("Did not find container for URI %s", projectUri)); } - // This must be an invisible project. Third party extension could theoretically create invisible projects anywhere - // in the project hierarchy. We therefore pick the most specific path. - // See: https://github.com/microsoft/vscode-java-dependency/pull/791#discussion_r1349435426 - Arrays.sort(containers, (Comparator) (IContainer a, IContainer b) -> { - return b.getFullPath().toPortableString().length() - a.getFullPath().toPortableString().length(); - }); - - return containers[containers.length - 1].getProject(); + // This must be an invisible project. + // There might be more than one way to access it, but all containers should link to the same project. + return containers[0].getProject(); } }