Remove getCanonicalFile on the LS side
This commit is contained in:
@@ -67,7 +67,6 @@ public class IClasspathUtil {
|
||||
}
|
||||
|
||||
private static boolean correspondsToBinaryLocation(CPE cpe, File classpathEntryFile) {
|
||||
classpathEntryFile = canonicalFile(classpathEntryFile);
|
||||
File canonicalFile = binaryLocation(cpe);
|
||||
return Objects.equals(canonicalFile, classpathEntryFile);
|
||||
}
|
||||
@@ -75,30 +74,14 @@ public class IClasspathUtil {
|
||||
public static File binaryLocation(CPE cpe) {
|
||||
switch (cpe.getKind()) {
|
||||
case Classpath.ENTRY_KIND_BINARY:
|
||||
return canonicalFile(cpe.getPath());
|
||||
return new File(cpe.getPath());
|
||||
case Classpath.ENTRY_KIND_SOURCE:
|
||||
return canonicalFile(cpe.getOutputFolder());
|
||||
return new File(cpe.getOutputFolder());
|
||||
default:
|
||||
throw new IllegalStateException("Missing switch case?");
|
||||
}
|
||||
}
|
||||
|
||||
private static File canonicalFile(String _f) {
|
||||
if (_f!=null) {
|
||||
File f = new File(_f);
|
||||
return canonicalFile(f);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static File canonicalFile(File f) {
|
||||
try {
|
||||
return f.getCanonicalFile();
|
||||
} catch (IOException e) {
|
||||
return f.getAbsoluteFile();
|
||||
}
|
||||
}
|
||||
|
||||
public static Stream<File> getSourceFolders(IClasspath classpath) {
|
||||
try {
|
||||
if (classpath != null) {
|
||||
|
||||
@@ -72,6 +72,9 @@ public class ClasspathListenerHandlerTest {
|
||||
service.addClasspathListener(classpaths.commandId);
|
||||
ACondition.waitFor("Project with classpath to appear", Duration.ofSeconds(50), () -> {
|
||||
Classpath cp = classpaths.getFor(loc).classpath;
|
||||
for (CPE cpe : cp.getEntries()) {
|
||||
assertTrue(new File(cpe.getPath()).isAbsolute());
|
||||
}
|
||||
assertTrue(cp.getEntries().stream().filter(cpe -> Classpath.isSource(cpe)).count()==1); //has 1 source entry
|
||||
assertClasspath(cp, cp.getEntries().stream().filter(cpe -> Classpath.isBinary(cpe) && cpe.isSystem()).count()>=1); //has some system libraries
|
||||
});
|
||||
@@ -87,6 +90,9 @@ public class ClasspathListenerHandlerTest {
|
||||
File loc = project.getLocation().toFile();
|
||||
ACondition.waitFor("Project with classpath to appear", Duration.ofSeconds(5), () -> {
|
||||
Classpath cp = classpaths.getFor(loc).classpath;
|
||||
for (CPE cpe : cp.getEntries()) {
|
||||
assertTrue(new File(cpe.getPath()).isAbsolute());
|
||||
}
|
||||
assertTrue(cp.getEntries().stream().filter(cpe -> Classpath.isSource(cpe)).count()==1); //has 1 source entry
|
||||
assertClasspath(cp, cp.getEntries().stream().filter(cpe -> Classpath.isBinary(cpe) && cpe.isSystem()).count()>=1); //has some system libraries
|
||||
});
|
||||
@@ -109,6 +115,9 @@ public class ClasspathListenerHandlerTest {
|
||||
service.addClasspathListener(classpaths.commandId);
|
||||
ACondition.waitFor("Project with classpath to appear", Duration.ofSeconds(5), () -> {
|
||||
Classpath cp = classpaths.getFor(loc).classpath;
|
||||
for (CPE cpe : cp.getEntries()) {
|
||||
assertTrue(new File(cpe.getPath()).isAbsolute());
|
||||
}
|
||||
assertTrue(cp.getEntries().stream().filter(cpe -> Classpath.isSource(cpe)).count()==1); //has 1 source entry
|
||||
assertClasspath(cp, cp.getEntries().stream().filter(cpe -> Classpath.isBinary(cpe) && cpe.isSystem()).count()>=1); //has some system libraries
|
||||
});
|
||||
@@ -140,6 +149,9 @@ public class ClasspathListenerHandlerTest {
|
||||
service.addClasspathListener(classpaths.commandId);
|
||||
ACondition.waitFor("Project with classpath to appear", Duration.ofSeconds(5), () -> {
|
||||
Classpath cp = classpaths.getFor(loc).classpath;
|
||||
for (CPE cpe : cp.getEntries()) {
|
||||
assertTrue(new File(cpe.getPath()).isAbsolute());
|
||||
}
|
||||
assertTrue(cp.getEntries().stream().filter(cpe -> Classpath.isSource(cpe)).count()==1); //has 1 source entry
|
||||
assertClasspath(cp, cp.getEntries().stream().filter(cpe -> Classpath.isBinary(cpe) && cpe.isSystem()).count()>=1); //has some system libraries
|
||||
});
|
||||
@@ -162,6 +174,9 @@ public class ClasspathListenerHandlerTest {
|
||||
service.addClasspathListener(classpaths.commandId);
|
||||
ACondition.waitFor("Project with classpath to appear", Duration.ofSeconds(50), () -> {
|
||||
Classpath cp = classpaths.getFor(loc).classpath;
|
||||
for (CPE cpe : cp.getEntries()) {
|
||||
assertTrue(new File(cpe.getPath()).isAbsolute());
|
||||
}
|
||||
assertClasspath(cp, cp.getEntries().stream().filter(cpe -> Classpath.isSource(cpe)).count()>=1); //has source entries
|
||||
CPE dependency = cp.getEntries().stream()
|
||||
.filter(Classpath::isBinary)
|
||||
|
||||
@@ -47,7 +47,7 @@ public class ClasspathUtil {
|
||||
IClasspathEntry[] resolvedJreEntries = ((JavaProject)javaProject).resolveClasspath(new IClasspathEntry[] {jreContainer});
|
||||
Set<String> paths = new HashSet<>();
|
||||
for (IClasspathEntry systemEntry : resolvedJreEntries) {
|
||||
paths.add(systemEntry.getPath().toString());
|
||||
paths.add(systemEntry.getPath().toFile().getAbsolutePath());
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
@@ -109,14 +109,14 @@ public class ClasspathUtil {
|
||||
String kind = toContentKind(entry);
|
||||
switch (kind) {
|
||||
case Classpath.ENTRY_KIND_BINARY: {
|
||||
String path = entry.getPath().toString();
|
||||
String path = entry.getPath().toFile().getAbsolutePath();
|
||||
CPE cpe = CPE.binary(path);
|
||||
if (systemLibs.contains(path)) {
|
||||
cpe.setSystem(true);
|
||||
}
|
||||
IPath sp = entry.getSourceAttachmentPath();
|
||||
if (sp != null) {
|
||||
cpe.setSourceContainerUrl(sp.toFile().toURI().toURL());
|
||||
cpe.setSourceContainerUrl(sp.toFile().getAbsoluteFile().toURI().toURL());
|
||||
// TODO:
|
||||
// IPath srp = entry.getSourceAttachmentRootPath();
|
||||
// if (srp!=null) {
|
||||
|
||||
Reference in New Issue
Block a user