use of org.eclipse.ceylon.javax.tools.JavaFileObject in project ceylon by eclipse.
the class LanguageCompiler method findModuleDescriptorForFile.
private JavaFileObject findModuleDescriptorForFile(File file) {
JavacFileManager dfm = (JavacFileManager) fileManager;
File dir = file.getParentFile();
while (dir != null) {
try {
String name = dir.getPath() + "/module";
JavaFileObject fo = dfm.getJavaFileForInput(StandardLocation.SOURCE_PATH, name, Kind.SOURCE);
if (fo != null) {
return fo;
}
} catch (IOException e) {
// Ignore
}
dir = dir.getParentFile();
}
return null;
}
use of org.eclipse.ceylon.javax.tools.JavaFileObject in project ceylon by eclipse.
the class CeylonModelLoader method loadClassInternal.
private boolean loadClassInternal(String quotedClassName) {
try {
Name name = names.fromString(quotedClassName);
if (syms().classes.containsKey(name))
return true;
JavaFileObject fileObject = fileManager.getJavaFileForInput(PLATFORM_CLASS_PATH, quotedClassName, JavaFileObject.Kind.CLASS);
if (fileObject == null) {
fileObject = fileManager.getJavaFileForInput(CLASS_PATH, quotedClassName, JavaFileObject.Kind.CLASS);
}
if (fileObject != null) {
reader.enterClass(name, fileObject);
return true;
}
return false;
} catch (IOException e) {
// this is not normal, but will result in an error elsewhere, so just log it
logVerbose("IOException loading class: " + e.getMessage());
return false;
}
}
use of org.eclipse.ceylon.javax.tools.JavaFileObject in project ceylon by eclipse.
the class CeyloncFileManager method getJavaFileForInput.
@Override
public JavaFileObject getJavaFileForInput(Location location, String className, JavaFileObject.Kind kind) throws IOException {
nullCheck(location);
// validateClassName(className);
nullCheck(className);
nullCheck(kind);
if (!sourceOrClass.contains(kind))
throw new IllegalArgumentException("Invalid kind " + kind);
JavaFileObject file = getFileForInput(location, forClass(className, kind));
if (file != null && file.getName().endsWith(".ceylon")) {
return new CeylonFileObject(file);
} else {
return file;
}
}
Aggregations