Skip to content

Commit

Permalink
Don't add empty brackets if lambda has no arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Frotty committed Jan 10, 2020
1 parent 9f6a733 commit 2dad075
Showing 1 changed file with 15 additions and 10 deletions.
Expand Up @@ -605,18 +605,23 @@ private void addParamSnippet(String replacementString, FuncLink f, CompletionIte
if (singleAbstractMethod != null) {
paramNames = Utils.init(paramNames);

lambdaReplacement = new StringBuilder(" (");
for (int i = 0; i < singleAbstractMethod.getParameterTypes().size(); i++) {
if (i > 0) {
lambdaReplacement.append(", ");
if (singleAbstractMethod.getParameterTypes().size() == 0) {
lambdaReplacement = new StringBuilder(" -> \n");
cu.getCuInfo().getIndentationMode().appendIndent(lambdaReplacement, 1);
} else {
lambdaReplacement = new StringBuilder(" (");
for (int i = 0; i < singleAbstractMethod.getParameterTypes().size(); i++) {
if (i > 0) {
lambdaReplacement.append(", ");
}
lambdaReplacement.append(singleAbstractMethod.getParameterType(i));
lambdaReplacement.append(" ");
lambdaReplacement.append(singleAbstractMethod.getParameterName(i));
}
lambdaReplacement.append(singleAbstractMethod.getParameterType(i));
lambdaReplacement.append(" ");
lambdaReplacement.append(singleAbstractMethod.getParameterName(i));
lambdaReplacement.append(") ->\n");
// only need to add one indent here, because \n already indents to the same line as before
cu.getCuInfo().getIndentationMode().appendIndent(lambdaReplacement, 1);
}
lambdaReplacement.append(") ->\n");
// only need to add one indent here, because \n already indents to the same line as before
cu.getCuInfo().getIndentationMode().appendIndent(lambdaReplacement, 1);
}
}
}
Expand Down

0 comments on commit 2dad075

Please sign in to comment.