|
2 | 2 | import com.google.gson.JsonObject; |
3 | 3 | import com.intellij.openapi.application.ApplicationManager; |
4 | 4 | import com.intellij.openapi.components.ProjectComponent; |
| 5 | +import com.intellij.openapi.vfs.LocalFileSystem; |
5 | 6 | import com.intellij.util.messages.MessageBusConnection; |
6 | 7 | import com.intellij.openapi.vfs.VirtualFileManager; |
7 | 8 | import com.intellij.openapi.vfs.newvfs.BulkFileListener; |
@@ -246,16 +247,16 @@ void processReceivedMessages(JsonObject messageAsJson) { |
246 | 247 | //System.out.println(SRCMLHandler.findLineNumber(projectPath + "/tempResultXmlFile.xml")); |
247 | 248 |
|
248 | 249 | EventQueue.invokeLater(() -> { |
249 | | - String[] filePath = messageAsJson.get("data").getAsJsonObject().get("fileName").getAsString().split("/"); |
250 | | - String fileToFocusOn = filePath[filePath.length - 1]; |
251 | | - int indexToFocusOn = SRCMLHandler.findLineNumber(projectPath + "/tempResultXmlFile.xml"); |
252 | | -// Project currentProject = ProjectManager.getInstance().getOpenProjects()[0]; |
253 | | - VirtualFile theVFile = FilenameIndex.getVirtualFilesByName(currentProject, fileToFocusOn, GlobalSearchScope.projectScope(currentProject)).iterator().next(); |
254 | | - FileEditorManager.getInstance(currentProject).openFile(theVFile, true); |
| 250 | + String fileRelativePath = messageAsJson.get("data").getAsJsonObject().get("fileName").getAsString(); |
| 251 | + String relativePath = fileRelativePath.startsWith("/") ? fileRelativePath : "/" + fileRelativePath; |
| 252 | + VirtualFile fileByPath = LocalFileSystem.getInstance().findFileByPath(relativePath); |
| 253 | + FileEditorManager.getInstance(currentProject).openFile(fileByPath, true); |
255 | 254 | Editor theEditor = FileEditorManager.getInstance(currentProject).getSelectedTextEditor(); |
| 255 | + int indexToFocusOn = SRCMLHandler.findLineNumber(projectPath + "/tempResultXmlFile.xml"); |
256 | 256 | theEditor.getCaretModel().moveToOffset(indexToFocusOn); |
257 | 257 | theEditor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); |
258 | 258 | }); |
| 259 | + |
259 | 260 | break; |
260 | 261 |
|
261 | 262 | case "MODIFIED_RULE": |
|
0 commit comments