Skip to content

Commit

Permalink
remove placeholders map
Browse files Browse the repository at this point in the history
  • Loading branch information
bishabosha committed Jul 17, 2023
1 parent 5fde72c commit aa27580
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions sbt-bridge/src/dotty/tools/xsbt/CompilerBridgeDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,14 @@ public boolean sourcesRequired() {
}

private static VirtualFile asVirtualFile(SourceFile sourceFile, DelegatingReporter reporter,
HashMap<AbstractFile, VirtualFile> lookup, Map<AbstractFile, VirtualFile> placeholders) {
VirtualFile maybeCached = lookup.get(sourceFile.file());
if (maybeCached != null) {
return maybeCached;
} else {
return fallbackVirtualFile(reporter, sourceFile, placeholders);
}
HashMap<AbstractFile, VirtualFile> lookup) {
return lookup.computeIfAbsent(sourceFile.file(), path -> {
reportMissingFile(reporter, sourceFile);
if (sourceFile.file().jpath() != null)
return new BasicPathBasedFile(sourceFile);
else
return new PlaceholderVirtualFile(sourceFile);
});
}

private static void reportMissingFile(DelegatingReporter reporter, SourceFile sourceFile) {
Expand All @@ -75,17 +76,6 @@ private static void reportMissingFile(DelegatingReporter reporter, SourceFile so
reporter.reportBasicWarning(message);
}

private static VirtualFile fallbackVirtualFile(DelegatingReporter reporter, SourceFile sourceFile,
Map<AbstractFile, VirtualFile> placeholders) {
return placeholders.computeIfAbsent(sourceFile.file(), path -> {
reportMissingFile(reporter, sourceFile);
if (sourceFile.file().jpath() != null)
return new BasicPathBasedFile(sourceFile);
else
return new PlaceholderVirtualFile(sourceFile);
});
}

synchronized public void run(VirtualFile[] sources, AnalysisCallback callback, Logger log, Reporter delegate) {
VirtualFile[] sortedSources = new VirtualFile[sources.length];
System.arraycopy(sources, 0, sortedSources, 0, sources.length);
Expand All @@ -101,13 +91,12 @@ synchronized public void run(VirtualFile[] sources, AnalysisCallback callback, L
lookup.put(abstractFile, source);
}

HashMap<AbstractFile, VirtualFile> placeholders = new HashMap<>();

DelegatingReporter reporter = new DelegatingReporter(delegate, (self, sourceFile) ->
asVirtualFile(sourceFile, self, lookup, placeholders).id());
asVirtualFile(sourceFile, self, lookup).id()
);

IncrementalCallback incCallback = new IncrementalCallback(callback, sourceFile ->
asVirtualFile(sourceFile, reporter, lookup, placeholders)
asVirtualFile(sourceFile, reporter, lookup)
);

try {
Expand Down

0 comments on commit aa27580

Please sign in to comment.