Skip to content

Commit 12a22df

Browse files
cushonronshapiro
authored andcommitted
Handle varargs lambda parameters
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=150214546
1 parent 24edd0c commit 12a22df

7 files changed

Lines changed: 16 additions & 55 deletions

File tree

core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ static VarArgsOrNot valueOf(boolean b) {
227227
boolean isYes() {
228228
return this == YES;
229229
}
230+
231+
static VarArgsOrNot fromVariable(VariableTree node) {
232+
return valueOf((((JCTree.JCVariableDecl) node).mods.flags & Flags.VARARGS) == Flags.VARARGS);
233+
}
230234
}
231235

232236
/** Whether the formal parameter declaration is a receiver. */
@@ -912,7 +916,7 @@ void visitVariables(
912916
annotationDirection,
913917
Optional.of(fragment.getModifiers()),
914918
fragment.getType(),
915-
VarArgsOrNot.NO,
919+
VarArgsOrNot.fromVariable(fragment),
916920
ImmutableList.<AnnotationTree>of(),
917921
fragment.getName(),
918922
"",
@@ -2307,7 +2311,7 @@ private void visitToDeclare(
23072311
String equals,
23082312
Optional<String> trailing) {
23092313
sync(node);
2310-
boolean varargs = (((JCTree.JCVariableDecl) node).mods.flags & Flags.VARARGS) == Flags.VARARGS;
2314+
boolean varargs = VarArgsOrNot.fromVariable(node).isYes();
23112315
List<? extends AnnotationTree> varargsAnnotations = ImmutableList.of();
23122316
Tree type = node.getType();
23132317
if (varargs) {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class B36194204 {
2+
{
3+
Function<String[], String> f = (String... s) -> s[0];
4+
}
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class B36194204 {
2+
{
3+
Function<String[], String> f = (String... s) -> s[0];
4+
}
5+
}

eclipse_plugin/.classpath

Lines changed: 0 additions & 10 deletions
This file was deleted.

eclipse_plugin/.project

Lines changed: 0 additions & 34 deletions
This file was deleted.

eclipse_plugin/.settings/org.eclipse.jdt.core.prefs

Lines changed: 0 additions & 7 deletions
This file was deleted.

eclipse_plugin/lib/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)