diff --git a/cli/src/main/java/net/neoforged/jst/cli/Main.java b/cli/src/main/java/net/neoforged/jst/cli/Main.java index cef1d0c..c54c54b 100644 --- a/cli/src/main/java/net/neoforged/jst/cli/Main.java +++ b/cli/src/main/java/net/neoforged/jst/cli/Main.java @@ -31,6 +31,9 @@ public class Main implements Callable { @CommandLine.Option(names = "--libraries-list", description = "Specifies a file that contains a path to an archive or directory to add to the classpath on each line.") Path librariesList; + @CommandLine.Option(names = "--ignore-prefix", description = "Do not transforms entry whose path start with this prefix.") + List ignoredPrefixes = new ArrayList<>(); + @CommandLine.Option(names = "--classpath", description = "Additional classpath entries to use. Is combined with --libraries-list.", converter = ClasspathConverter.class) List addToClasspath = new ArrayList<>(); @@ -69,6 +72,9 @@ public Integer call() throws Exception { for (Path path : addToClasspath) { processor.addLibrary(path); } + for (String ignoredPrefix : ignoredPrefixes) { + processor.addIgnoredPrefix(ignoredPrefix); + } processor.setMaxQueueDepth(maxQueueDepth); diff --git a/cli/src/main/java/net/neoforged/jst/cli/SourceFileProcessor.java b/cli/src/main/java/net/neoforged/jst/cli/SourceFileProcessor.java index 1d338f4..e0f43fd 100644 --- a/cli/src/main/java/net/neoforged/jst/cli/SourceFileProcessor.java +++ b/cli/src/main/java/net/neoforged/jst/cli/SourceFileProcessor.java @@ -17,6 +17,7 @@ import java.nio.file.Path; import java.nio.file.attribute.FileTime; import java.time.Instant; +import java.util.ArrayList; import java.util.List; /** @@ -27,6 +28,8 @@ class SourceFileProcessor implements AutoCloseable { private final IntelliJEnvironmentImpl ijEnv = new IntelliJEnvironmentImpl(); private int maxQueueDepth = 50; + private final List ignoredPrefixes = new ArrayList<>(); + public SourceFileProcessor() throws IOException { ijEnv.addCurrentJdkToClassPath(); } @@ -83,7 +86,7 @@ private void processEntry(FileEntry entry, VirtualFile sourceRoot, List transformers, byte[] originalContentBytes) { // Instead of parsing the content we actually read from the file, we read the virtual file that is // visible to IntelliJ from adding the source jar. The reasoning is that IntelliJ will cache this internally @@ -138,6 +150,11 @@ public void addLibrary(Path library) { ClasspathSetup.addLibrary(library, ijEnv); } + public void addIgnoredPrefix(String ignoredPrefix) { + System.out.println("Not transforming entries starting with " + ignoredPrefix); + this.ignoredPrefixes.add(ignoredPrefix); + } + @Override public void close() throws IOException { ijEnv.close(); diff --git a/parchment/src/main/java/net/neoforged/jst/parchment/GatherReplacementsVisitor.java b/parchment/src/main/java/net/neoforged/jst/parchment/GatherReplacementsVisitor.java index db5d351..3e71ce0 100644 --- a/parchment/src/main/java/net/neoforged/jst/parchment/GatherReplacementsVisitor.java +++ b/parchment/src/main/java/net/neoforged/jst/parchment/GatherReplacementsVisitor.java @@ -54,8 +54,9 @@ public void visitElement(@NotNull PsiElement element) { if (foundClass == null) { throw new IllegalStateException("Failed to find how class " + psiClass.getQualifiedName() + " was loaded while processing it"); } else if (foundClass != psiClass) { - throw new IllegalStateException("Class " + psiClass + " was loaded from two different sources: " + - psiClass.getContainingFile() + " and " + foundClass.getContainingFile()); + throw new IllegalStateException("Class " + psiClass.getQualifiedName() + " was loaded from two different sources: " + + psiClass.getContainingFile().getVirtualFile().getPath() + " and " + + foundClass.getContainingFile().getVirtualFile().getPath()); } }