Skip to content

Commit

Permalink
Issue 512: fixed source file lookup when building translator closure.
Browse files Browse the repository at this point in the history
	Change on 2015/04/07 by tball <tball@google.com>
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=90556769
  • Loading branch information
tomball authored and kstanger committed Apr 9, 2015
1 parent d4b5106 commit b548298
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Expand Up @@ -444,7 +444,7 @@ private void maybeAddToClosure(ITypeBinding type) {
return;
}
typeName = typeName.substring(0, iDot);
sourceName = typeName.replace('.', File.pathSeparatorChar) + ".java";
sourceName = typeName.replace('.', File.separatorChar) + ".java";
if (seenFiles.contains(sourceName)) {
return;
}
Expand All @@ -469,7 +469,7 @@ private boolean findClassFile(String typeName) {
String path = typeName.replace('.', '/') + ".class";
InputFile f = null;
try {
f = FileUtil.findOnSourcePath(path);
f = FileUtil.findOnClassPath(path);
} catch (IOException e) {
ErrorUtil.warning(e.getMessage());
}
Expand Down
Expand Up @@ -16,17 +16,17 @@
import com.google.common.io.CharStreams;
import com.google.devtools.j2objc.J2ObjC;
import com.google.devtools.j2objc.Options;
import com.google.devtools.j2objc.file.InputFile;
import com.google.devtools.j2objc.file.JarredInputFile;
import com.google.devtools.j2objc.file.RegularInputFile;
import com.google.devtools.j2objc.file.InputFile;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Properties;
import java.util.zip.ZipException;

import javax.annotation.Nullable;

Expand All @@ -44,7 +44,21 @@ public class FileUtil {
*/
@Nullable
public static InputFile findOnSourcePath(String filename) throws IOException {
for (String pathEntry : Options.getSourcePathEntries()) {
return findOnPaths(filename, Options.getSourcePathEntries());
}

/**
* Find a {@link com.google.devtools.j2objc.file.InputFile} on the class path,
* either in a directory or a jar.
* Returns a file guaranteed to exist, or null.
*/
@Nullable
public static InputFile findOnClassPath(String filename) throws IOException {
return findOnPaths(filename, Options.getClassPathEntries());
}

private static InputFile findOnPaths(String filename, List<String> paths) throws IOException {
for (String pathEntry : paths) {
File f = new File(pathEntry);
if (f.isDirectory()) {
RegularInputFile regularFile = new RegularInputFile(
Expand Down

0 comments on commit b548298

Please sign in to comment.