Skip to content

Commit 3f88d4f

Browse files
Sahar MehrpourSahar Mehrpour
authored andcommitted
responds on active editor changes
1 parent 5595a12 commit 3f88d4f

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

src/FileChangeManager.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import com.intellij.psi.search.GlobalSearchScope;
1616
import com.intellij.psi.PsiFile;
1717
import com.intellij.psi.PsiManager;
18+
import com.intellij.openapi.fileEditor.FileEditorManagerEvent;
19+
import com.intellij.openapi.fileEditor.FileEditorManagerListener;
1820
import org.jetbrains.annotations.NotNull;
1921

2022
import core.model.SRCMLHandler;
@@ -164,6 +166,14 @@ public void after(@NotNull List<? extends VFileEvent> events) {
164166
}
165167
}
166168
});
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+
});
167177
}
168178

169179
/**
@@ -279,22 +289,13 @@ void processReceivedMessages(JsonObject messageAsJson) {
279289

280290
case "EXPR_STMT":
281291
String exprText = messageAsJson.get("data").getAsString();
282-
String resultExprXml = SRCMLHandler.createXMLForText(exprText, projectPath + "/tempExprDeclFile.java");
292+
String resultExprXml = SRCMLHandler.createXMLForText(exprText, projectPath + "/tempExprFile.java");
283293
s.sendToAll(MessageProcessor.encodeData(new Object[]{"IDEA", "WEB", "EXPR_STMT_XML", resultExprXml}).toString());
284294

285295
break;
286296

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-
294297
case "NEW_RULE":
295298

296-
//TODO first add the rule, then write it in the file
297-
298299
String newRuleIndex = Integer.toString(messageAsJson.get("data").getAsJsonObject().get("index").getAsInt());
299300
String newRuleText = messageAsJson.get("data").getAsJsonObject().get("ruleText").getAsJsonObject().toString();
300301

0 commit comments

Comments
 (0)