|
15 | 15 | import com.intellij.psi.search.GlobalSearchScope; |
16 | 16 | import com.intellij.psi.PsiFile; |
17 | 17 | import com.intellij.psi.PsiManager; |
| 18 | +import com.intellij.openapi.fileEditor.FileEditorManagerEvent; |
| 19 | +import com.intellij.openapi.fileEditor.FileEditorManagerListener; |
18 | 20 | import org.jetbrains.annotations.NotNull; |
19 | 21 |
|
20 | 22 | import core.model.SRCMLHandler; |
@@ -164,6 +166,14 @@ public void after(@NotNull List<? extends VFileEvent> events) { |
164 | 166 | } |
165 | 167 | } |
166 | 168 | }); |
| 169 | + |
| 170 | + connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerListener() { |
| 171 | + @Override |
| 172 | + public void selectionChanged(@NotNull FileEditorManagerEvent event) { |
| 173 | + s.sendToAll(MessageProcessor.encodeData(new Object[]{"IDEA", "WEB", "SHOW_RULES_FOR_FILE", event.getManager().getSelectedFiles()[0].getPath()}).toString()); |
| 174 | + } |
| 175 | + |
| 176 | + }); |
167 | 177 | } |
168 | 178 |
|
169 | 179 | /** |
@@ -279,22 +289,13 @@ void processReceivedMessages(JsonObject messageAsJson) { |
279 | 289 |
|
280 | 290 | case "EXPR_STMT": |
281 | 291 | String exprText = messageAsJson.get("data").getAsString(); |
282 | | - String resultExprXml = SRCMLHandler.createXMLForText(exprText, projectPath + "/tempExprDeclFile.java"); |
| 292 | + String resultExprXml = SRCMLHandler.createXMLForText(exprText, projectPath + "/tempExprFile.java"); |
283 | 293 | s.sendToAll(MessageProcessor.encodeData(new Object[]{"IDEA", "WEB", "EXPR_STMT_XML", resultExprXml}).toString()); |
284 | 294 |
|
285 | 295 | break; |
286 | 296 |
|
287 | | - case "DECL_STMT": |
288 | | - String declText = messageAsJson.get("data").getAsString(); |
289 | | - String resultDeclXml = SRCMLHandler.createXMLForText(declText, projectPath + "/tempExprDeclFile.java"); |
290 | | - s.sendToAll(MessageProcessor.encodeData(new Object[]{"IDEA", "WEB", "DECL_STMT_XML", resultDeclXml}).toString()); |
291 | | - |
292 | | - break; |
293 | | - |
294 | 297 | case "NEW_RULE": |
295 | 298 |
|
296 | | - //TODO first add the rule, then write it in the file |
297 | | - |
298 | 299 | String newRuleIndex = Integer.toString(messageAsJson.get("data").getAsJsonObject().get("index").getAsInt()); |
299 | 300 | String newRuleText = messageAsJson.get("data").getAsJsonObject().get("ruleText").getAsJsonObject().toString(); |
300 | 301 |
|
|
0 commit comments