Skip to content
This repository has been archived by the owner on Jan 5, 2022. It is now read-only.

trouble opening file in workspace #4

Open
flmueller opened this issue Feb 24, 2017 · 1 comment
Open

trouble opening file in workspace #4

flmueller opened this issue Feb 24, 2017 · 1 comment

Comments

@flmueller
Copy link

flmueller commented Feb 24, 2017

First of all : great plugin!
I have had problems opening files with the remote command. I finally found the cause:

In OpenFileCommandRunner.javaFileToPluginFile the String javaFile can get truncated in one round of the for loop and might then be wrong in all following rounds. I suggest using a temporary string:

private IFile javaFileToPluginFile(String javaFile) {
for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
if (!project.isOpen()) continue; // TODO opening of project ??
String tempFileName = javaFile;
if (javaFile.startsWith('/' + project.getName())) {
tempFileName = javaFile.substring(project.getName().length() + 1);
} else if (javaFile.startsWith("/")) { // absolute system path
final String projectPath = project.getLocation().toOSString();
if (javaFile.length() < projectPath.length()) continue;
tempFileName = javaFile.substring(projectPath.length());
}
IFile file = project.getFile(tempFileName );
if (file.exists()) {
return file;
}
}
return null;
}

@marook
Copy link
Owner

marook commented Feb 27, 2017 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants