in intellij-plugin-structure/structure-ide/src/main/java/com/jetbrains/plugin/structure/ide/ParametersListUtil.java [67:114]
private static List<String> parse(@NotNull String parameterString, boolean keepQuotes) {
parameterString = parameterString.trim();
final ArrayList<String> params = new ArrayList<>();
final StringBuilder token = new StringBuilder(128);
boolean inQuotes = false;
boolean escapedQuote = false;
boolean nonEmpty = false;
for (int i = 0; i < parameterString.length(); i++) {
final char ch = parameterString.charAt(i);
if (ch == '\"') {
if (!escapedQuote) {
inQuotes = !inQuotes;
nonEmpty = true;
if (!keepQuotes) {
continue;
}
}
escapedQuote = false;
} else if (Character.isWhitespace(ch)) {
if (!inQuotes) {
if (token.length() > 0 || nonEmpty) {
params.add(token.toString());
token.setLength(0);
nonEmpty = false;
}
continue;
}
} else if (ch == '\\') {
if (i < parameterString.length() - 1 && parameterString.charAt(i + 1) == '"') {
escapedQuote = true;
if (!keepQuotes) {
continue;
}
}
}
token.append(ch);
}
if (token.length() > 0 || nonEmpty) {
params.add(token.toString());
}
return params;
}