use of org.python.pydev.ast.codecompletion.revisited.modules.IJavaDefinition in project Pydev by fabioz.
the class ItemPointer method getFileAsURI.
public URI getFileAsURI() {
if (this.uri != null) {
return this.uri;
}
// Also see org.python.pydev.editor.actions.PyOpenAction
Object file = this.file;
if (file instanceof File) {
File f = (File) file;
String filename = f.getName();
if (// treating files without any extension!
PythonPathHelper.isValidSourceFile(filename) || filename.indexOf('.') == -1 || (zipFilePath != null && PythonPathHelper.isValidSourceFile(zipFilePath))) {
// Keep on going as we were going...
} else if (definition instanceof IJavaDefinition) {
Log.log(new RuntimeException("Not currently able to convert JavaDefinition to URI."));
return null;
} else {
boolean giveError = true;
if (definition != null && definition.module instanceof IAbstractJavaClassModule) {
Log.log(new RuntimeException("Not currently able to convert AbstractJavaClassModule to URI."));
return null;
} else {
if (FileTypesPreferences.isValidDll(filename)) {
if (f.exists()) {
// It's a pyd or dll, let's check if it was a cython module to open it...
File parentFile = f.getParentFile();
File newFile = new File(parentFile, StringUtils.stripExtension(f.getName()) + "." + "pyx");
if (!newFile.exists()) {
newFile = new File(parentFile, StringUtils.stripExtension(f.getName()) + "." + "pxd");
}
if (!newFile.exists()) {
newFile = new File(parentFile, StringUtils.stripExtension(f.getName()) + "." + "pxi");
}
if (newFile.exists()) {
giveError = false;
file = newFile;
}
}
}
}
if (giveError) {
return null;
}
}
}
if (zipFilePath != null) {
Log.log(StringUtils.format("Not currently able to convert file with zip path to URI.\nFile: %s\nStart: %s\nEnd: %s\nZip path: %s\n", file, start, end, zipFilePath));
return null;
} else if (file instanceof IFile) {
IFile f = (IFile) file;
return f.getRawLocationURI();
} else if (file instanceof IPath) {
IPath path = (IPath) file;
return path.toFile().toURI();
} else if (file instanceof File) {
return ((File) file).toURI();
} else if (file instanceof URI) {
return (URI) file;
}
return null;
}
Aggregations