Skip to content

Commit

Permalink
Move empty source handling to common code.
Browse files Browse the repository at this point in the history
This wasn't short-circuited in JDT so no code changes there.

PiperOrigin-RevId: 728421704
  • Loading branch information
gkdn authored and copybara-github committed Feb 19, 2025
1 parent 613673a commit caf4024
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ private void transpileImpl() {
MemberDescriptor.setClosureManglingPatterns();
}

Library library = options.getFrontend().parse(options, problems);
Library library =
options.getSources().isEmpty()
? Library.newEmpty()
: options.getFrontend().parse(options, problems);
try {
problems.abortIfHasErrors();
if (!library.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,11 @@ public JavacParser(Problems problems) {
/** Returns a map from file paths to compilation units after Javac parsing. */
@Nullable
public Library parseFiles(FrontendOptions options) {
ImmutableList<FileInfo> filePaths = options.getSources();
if (filePaths.isEmpty()) {
return Library.newEmpty();
}

// The map must be ordered because it will be iterated over later and if it was not ordered then
// our output would be unstable
final Map<String, String> targetPathBySourcePath =
filePaths.stream().collect(Collectors.toMap(FileInfo::sourcePath, FileInfo::targetPath));
options.getSources().stream()
.collect(Collectors.toMap(FileInfo::sourcePath, FileInfo::targetPath));

try {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ class KotlinParser(private val problems: Problems) {

/** Returns a list of compilation units after Kotlinc parsing. */
fun parseFiles(options: FrontendOptions): Library {
if (options.sources.isEmpty()) {
return Library.newEmpty()
}

val packageInfoCache = PackageInfoCache(options.classpaths, problems)
val packageAnnotationResolver = getPackageAnnotationResolver(options, packageInfoCache)

Expand Down

0 comments on commit caf4024

Please sign in to comment.