1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Improve path to resource conversion when opening an editor (related to bug 211056)

This commit is contained in:
Anton Leherbauer 2007-12-12 14:20:49 +00:00
parent 1d3da89cf0
commit 214698ca9c

View file

@ -358,8 +358,9 @@ public class EditorUtility {
* @return an <code>IFile</code> or <code>null</code>
*/
private static IFile getWorkspaceFileAtLocation(IPath location, ICElement context) {
// search non-linked resource
IFile file= FileBuffers.getWorkspaceFileAtLocation(location);
if (file == null) {
if (file == null || !CoreModel.hasCNature(file.getProject())) {
// try to find a linked resource
IProject project= null;
if (context != null) {
@ -369,24 +370,27 @@ public class EditorUtility {
}
}
IFile bestMatch= null;
IFile secondBestMatch= null;
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
IFile[] files= root.findFilesForLocation(location);
for (int i= 0; i < files.length; i++) {
file= files[i];
if (file.isAccessible()) {
if (project != null && file.getProject() == project) {
if (project != null && file.getProject().equals(project)) {
bestMatch= file;
break;
}
if (bestMatch == null) {
} else if (CoreModel.hasCNature(file.getProject())) {
bestMatch= file;
if (project == null) {
break;
}
} else {
// match in non-CDT project
secondBestMatch= file;
}
}
}
return bestMatch;
return bestMatch != null ? bestMatch : secondBestMatch;
}
return file;
}