Skip to content

Commit

Permalink
1372: "Source directories" in project properties is whitespace sensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
vladdu committed Sep 24, 2014
1 parent 37df0b5 commit 76617d5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static List<IPath> unpackList(final String string, final String sep) {
final List<String> sresult = new ArrayList<String>(Arrays.asList(v));
final List<IPath> result = new ArrayList<IPath>();
for (final String s : sresult) {
final Path path = new Path(s);
final Path path = new Path(s.trim());
if (!path.isEmpty()) {
result.add(path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ protected String createList(final String[] items) {

@Override
protected String[] parseString(final String stringList) {
return PreferencesUtils.unpackArray(stringList);
final String[] result = PreferencesUtils.unpackArray(stringList);
for (int i = 0; i < result.length; i++) {
result[i] = result[i].trim();
}
return result;
}

@Override
Expand Down
14 changes: 12 additions & 2 deletions org.erlide.util/src/org/erlide/util/PreferencesUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import java.util.ArrayList;
import java.util.List;

import org.eclipse.xtext.xbase.lib.Functions;
import org.eclipse.xtext.xbase.lib.ListExtensions;

public final class PreferencesUtils {

private static final String SEP = ";";
Expand All @@ -15,14 +18,21 @@ public static String packList(final Iterable<String> list) {
}

public static List<String> unpackList(final String string) {
return ListsUtils.unpackList(string, SEP);
List<String> result = ListsUtils.unpackList(string, SEP);
result = ListExtensions.map(result, new Functions.Function1<String, String>() {
@Override
public String apply(final String p) {
return p.trim();
}
});
return result;
}

public static String packArray(final String[] strs) {
final StringBuilder result = new StringBuilder();
for (final String s : strs) {
if (s.length() > 0) {
result.append(s).append(SEP);
result.append(s.trim()).append(SEP);
}
}
final String r = result.length() == 0 ? "" : result.substring(0, result.length()
Expand Down

0 comments on commit 76617d5

Please sign in to comment.