Skip to content

Commit 5595a12

Browse files
Sahar MehrpourSahar Mehrpour
authored andcommitted
deployment problem fixed
1 parent ead96a3 commit 5595a12

3 files changed

Lines changed: 22 additions & 27 deletions

File tree

src/ChatServer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void onOpen(WebSocket conn, ClientHandshake handshake) {
5151

5252
this.sendInitialMessages(conn, MessageProcessor.encodeData(new Object[]{"IDEA", "WEB", "ENTER", (conn + " has entered the room!")}).toString());
5353

54-
// for (int i = 0; i < Math.min(100, manager.getSrcml().fileNumber); i++) {
54+
// for (int i = 0; i < Math.min(5, manager.getSrcml().fileNumber); i++) {
5555
for (int i = 0; i < manager.getSrcml().fileNumber; i++) {
5656
this.sendInitialMessages(conn, MessageProcessor.encodeData(new Object[]{"IDEA", "WEB", "XML",
5757
MessageProcessor.encodeXMLData(new Object[]{manager.getSrcml().getPaths().get(i), manager.getSrcml().getXmls().get(i)})
@@ -62,6 +62,7 @@ public void onOpen(WebSocket conn, ClientHandshake handshake) {
6262
this.sendInitialMessages(conn, MessageProcessor.encodeData(new Object[]{"IDEA", "WEB", "TAG_TABLE", manager.getAllTags()}).toString());
6363
this.sendInitialMessages(conn, MessageProcessor.encodeData(new Object[]{"IDEA", "WEB", "VERIFY_RULES", ""}).toString());
6464
this.sendInitialMessages(conn, MessageProcessor.encodeData(new Object[]{"IDEA", "WEB", "PROJECT_HIERARCHY", manager.generateProjectHierarchyAsJSON()}).toString());
65+
this.sendInitialMessages(conn, MessageProcessor.encodeData(new Object[]{"IDEA", "WEB", "PROJECT", manager.projectPath}).toString());
6566

6667
sendBackedUpMessages();
6768
}

src/FileChangeManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class FileChangeManager implements ProjectComponent {
3838
private List<List<String>> ruleIndexText; // index - text
3939
private List<List<String>> tagNameText; // tagName - text
4040
private Project currentProject;
41-
private String projectPath;
41+
public String projectPath;
4242

4343
FileChangeManager(Project project, ChatServer server, SRCMLxml xmlP, List<List<String>> ruleList, List<List<String>> tagList) {
4444
connection = ApplicationManager.getApplication().getMessageBus().connect();

src/core/model/SRCMLHandler.java

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44

55
package core.model;
66

7-
import java.io.BufferedReader;
7+
import com.intellij.execution.ExecutionException;
8+
import com.intellij.execution.configurations.GeneralCommandLine;
9+
import com.intellij.execution.process.ProcessOutput;
10+
import com.intellij.execution.util.ExecUtil;
11+
812
import java.io.IOException;
9-
import java.io.InputStreamReader;
1013
import java.io.PrintWriter;
14+
import java.nio.charset.Charset;
1115

1216
public class SRCMLHandler {
1317

@@ -91,37 +95,27 @@ public static String addXMLForProject(SRCMLxml srcml, String filePath) {
9195
* @return xml String
9296
*/
9397
private static String createXMLForFile(String path) {
94-
return runShellCommand(new String[]{"srcml", path})[0];
98+
return runShellCommand(new String[]{"/usr/local/bin/srcml", path});
9599
}
96100

97101

98102
/**
99103
* run the shell command
100104
*
101105
* @param command (terminal command)
102-
* @return output and errors
106+
* @return output
103107
*/
104-
private static String[] runShellCommand(String[] command) {
105-
try {
106-
Process p = Runtime.getRuntime().exec(command);
107-
108-
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
109-
BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
110-
111-
String line, resultInput = "", resultError = "";
112-
while ((line = stdInput.readLine()) != null) {
113-
resultInput = resultInput + line + '\n';
114-
}
108+
private static String runShellCommand(String[] command) {
109+
GeneralCommandLine generalCommandLine = new GeneralCommandLine(command);
110+
generalCommandLine.setCharset(Charset.forName("UTF-8"));
115111

116-
while ((line = stdError.readLine()) != null) {
117-
resultError = resultError + line + '\n';
118-
}
119-
return new String[]{resultInput, resultError};
112+
try {
113+
ProcessOutput processOutput = ExecUtil.execAndGetOutput(generalCommandLine);
114+
return String.join("\n", processOutput.getStdoutLines());
120115

121-
} catch (IOException e) {
122-
System.out.println("Exception: ");
116+
} catch (ExecutionException e) {
123117
e.printStackTrace();
124-
return new String[]{"", ""};
118+
return e.toString();
125119
}
126120

127121
}
@@ -135,13 +129,13 @@ private static String[] runShellCommand(String[] command) {
135129
*/
136130
public static int findLineNumber(String fullPath) {
137131

138-
String[] str = new String[]{"srcml", "--unit", "1", fullPath};
139-
String[] src = runShellCommand(str);
132+
String[] str = new String[]{"/usr/local/bin/srcml", "--unit", "1", fullPath};
133+
String src = runShellCommand(str);
140134

141135
//File filePath = new File(fullPath);
142136
//filePath.delete();
143137

144-
return src[0].length();
138+
return src.length();
145139
}
146140

147141

0 commit comments

Comments
 (0)