use of com.google.devtools.j2objc.file.InputFile in project j2objc by google.
the class FileUtil method findOnPaths.
private static InputFile findOnPaths(String qualifiedName, List<String> paths, String extension) throws IOException {
String sourceFileName = qualifiedName.replace('.', File.separatorChar) + extension;
// Zip/jar files always use forward slashes.
String jarEntryName = qualifiedName.replace('.', '/') + extension;
for (String pathEntry : paths) {
File f = new File(pathEntry);
if (f.isDirectory()) {
RegularInputFile regularFile = new RegularInputFile(pathEntry + File.separatorChar + sourceFileName, sourceFileName);
if (regularFile.exists()) {
return regularFile;
}
} else {
// Assume it's a jar file
JarredInputFile jarFile = new JarredInputFile(pathEntry, jarEntryName);
if (jarFile.exists()) {
return jarFile;
}
}
}
return null;
}
use of com.google.devtools.j2objc.file.InputFile in project j2objc by google.
the class PackageInfoLookup method findPackageData.
private PackageData findPackageData(String packageName) {
try {
String fileName = packageName + ".package-info";
// First look on the sourcepath.
InputFile sourceFile = fileUtil.findOnSourcePath(fileName);
if (sourceFile != null) {
return parseDataFromSourceFile(sourceFile);
}
// Then look on the classpath.
InputFile classFile = fileUtil.findOnClassPath(fileName);
if (classFile != null) {
return parseDataFromClassFile(classFile);
}
} catch (IOException e) {
// Continue with no package-info data.
}
return EMPTY_DATA;
}
use of com.google.devtools.j2objc.file.InputFile in project j2objc by google.
the class FileProcessor method processBuildClosureDependencies.
public void processBuildClosureDependencies() {
if (closureQueue != null) {
while (true) {
InputFile file = closureQueue.getNextFile();
if (file == null) {
processBatch();
file = closureQueue.getNextFile();
}
if (file == null) {
break;
}
processInput(ProcessingContext.fromFile(file, options));
}
}
}
use of com.google.devtools.j2objc.file.InputFile in project j2objc by google.
the class FileProcessor method processInput.
private void processInput(ProcessingContext input) {
try {
InputFile file = input.getFile();
if (isBatchable(file)) {
batchInputs.add(input);
if (batchInputs.size() == batchSize) {
processBatch();
}
return;
}
logger.finest("parsing " + file);
CompilationUnit compilationUnit = parser.parse(file);
if (compilationUnit == null) {
handleError(input);
return;
}
processCompiledSource(input, compilationUnit);
} catch (RuntimeException | Error e) {
ErrorUtil.fatalError(e, input.getOriginalSourcePath());
}
}
use of com.google.devtools.j2objc.file.InputFile in project j2objc by google.
the class GenerationBatch method processJavaFile.
private void processJavaFile(String filename) {
InputFile inputFile;
try {
inputFile = new RegularInputFile(filename, filename);
if (!inputFile.exists()) {
// Convert to a qualified name and search on the sourcepath.
String qualifiedName = filename.substring(0, filename.length() - 5).replace(File.separatorChar, '.');
inputFile = options.fileUtil().findOnSourcePath(qualifiedName);
if (inputFile == null) {
ErrorUtil.error("No such file: " + filename);
return;
}
}
} catch (IOException e) {
ErrorUtil.warning(e.getMessage());
return;
}
addSource(inputFile);
}
Aggregations