eclipse-remote-control icon indicating copy to clipboard operation
eclipse-remote-control copied to clipboard

trouble opening file in workspace

Open flmueller opened this issue 8 years ago • 1 comments

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; }

flmueller avatar Feb 24 '17 17:02 flmueller

Yes. I think you are right.

I personally am no longer actively using eclipse-remote-control. If you can fix the problem I would be happy about a pull request on github.

Thanks, Markus

2017-02-24 18:12 GMT+01:00 flmueller [email protected]:

First of all : great plugin! I have multiple projects with different name lengths in one workspace and have had problems opening files with the remote command. I finally found the cause:

In OpenFileCommandRunner.javaFileToPluginFile the String javaFile can be truncated in one round of the for loop so it will not be longer the original String in the following rounds. I suggest using a temporary string instead:

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; }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/marook/eclipse-remote-control/issues/4, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGXp2BwmHVTmd5xOc_jv0JS1cVS9Ibeks5rfw-ZgaJpZM4MLc2r .

marook avatar Feb 27 '17 06:02 marook