Skip to content

Commit

Permalink
Change parseCommand method
Browse files Browse the repository at this point in the history
so that it returns a single string instead of an array of strings; empty lines and comments are removed
  • Loading branch information
Valentin Georgiev committed Apr 11, 2012
1 parent 508ba4c commit e4aa762
Showing 1 changed file with 10 additions and 7 deletions.
Expand Up @@ -28,7 +28,8 @@
public class RunUtil {

public static final String fileseparator = java.io.File.separator;
public static String cmdparser = "(;?\r?\n|;)";
public static String NEWLINE = System.getProperty("line.separator");
public static String cmdparser = "(;?\r?\n|;)";

public static String getSelectedCode(final ExecutionEvent event) throws CoreException {
try {
Expand Down Expand Up @@ -97,13 +98,15 @@ public static String fixFilepath(String filepath) {
return filepath;
}

public static String[] parseCommand(String command) {
public static String parseCommand(String command) {
String[] cmd = command.split(cmdparser);
ArrayList<String> list = new ArrayList<String>();
StringBuilder builder = new StringBuilder();
for (String s : cmd)
if (!s.startsWith("#") && s.length() != 0)
list.add(s);
cmd = list.toArray(new String[list.size()]);
return cmd;
if (!s.startsWith("#") && s.length() != 0) {
builder.append(s);
builder.append(NEWLINE);
}
String cmdstr = builder.toString();
return cmdstr;
}
}

0 comments on commit e4aa762

Please sign in to comment.