mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 10:46:02 +02:00
Allow to use a workspace relative path for EditorUtility.openEditor
This commit is contained in:
parent
554b3fa756
commit
c82eb0d880
1 changed files with 10 additions and 9 deletions
|
@ -18,6 +18,7 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
|
import org.eclipse.core.filebuffers.FileBuffers;
|
||||||
import org.eclipse.core.resources.IContainer;
|
import org.eclipse.core.resources.IContainer;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IFolder;
|
import org.eclipse.core.resources.IFolder;
|
||||||
|
@ -329,18 +330,18 @@ public class EditorUtility {
|
||||||
* @return an <code>IFile</code> or <code>null</code>
|
* @return an <code>IFile</code> or <code>null</code>
|
||||||
*/
|
*/
|
||||||
private static IFile getWorkspaceFileAtLocation(IPath location, ICElement context) {
|
private static IFile getWorkspaceFileAtLocation(IPath location, ICElement context) {
|
||||||
IProject project= null;
|
IFile file= FileBuffers.getWorkspaceFileAtLocation(location);
|
||||||
if (context != null) {
|
|
||||||
ICProject cProject= context.getCProject();
|
|
||||||
if (cProject != null) {
|
|
||||||
project= cProject.getProject();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
|
|
||||||
IFile file= root.getFileForLocation(location);
|
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
// try to find a linked resource
|
// try to find a linked resource
|
||||||
|
IProject project= null;
|
||||||
|
if (context != null) {
|
||||||
|
ICProject cProject= context.getCProject();
|
||||||
|
if (cProject != null) {
|
||||||
|
project= cProject.getProject();
|
||||||
|
}
|
||||||
|
}
|
||||||
IFile bestMatch= null;
|
IFile bestMatch= null;
|
||||||
|
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
|
||||||
IFile[] files= root.findFilesForLocation(location);
|
IFile[] files= root.findFilesForLocation(location);
|
||||||
for (int i= 0; i < files.length; i++) {
|
for (int i= 0; i < files.length; i++) {
|
||||||
file= files[i];
|
file= files[i];
|
||||||
|
|
Loading…
Add table
Reference in a new issue