File tree 2 files changed +9
-12
lines changed
impl/src/main/java/org/jboss/forge/roaster/model/impl
tests/src/test/java/org/jboss/forge/test/roaster/model
2 files changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -291,17 +291,7 @@ public FieldSource<O> setVisibility(final Visibility scope)
291
291
@ Override
292
292
public String getName ()
293
293
{
294
- String result = null ;
295
- for (Object f : field .fragments ())
296
- {
297
- if (f instanceof VariableDeclarationFragment )
298
- {
299
- VariableDeclarationFragment frag = (VariableDeclarationFragment ) f ;
300
- result = frag .getName ().getFullyQualifiedName ();
301
- break ;
302
- }
303
- }
304
- return result ;
294
+ return fragment .getName ().getFullyQualifiedName ();
305
295
}
306
296
307
297
@ Override
@@ -499,4 +489,4 @@ public int getColumnNumber()
499
489
{
500
490
return cu .getColumnNumber (getStartPosition ());
501
491
}
502
- }
492
+ }
Original file line number Diff line number Diff line change 13
13
import org .jboss .forge .roaster .model .source .JavaClassSource ;
14
14
import org .junit .jupiter .api .Test ;
15
15
16
+ import static org .assertj .core .api .Assertions .assertThat ;
16
17
import static org .junit .jupiter .api .Assertions .assertEquals ;
17
18
import static org .junit .jupiter .api .Assertions .assertFalse ;
18
19
import static org .junit .jupiter .api .Assertions .assertTrue ;
@@ -125,4 +126,10 @@ public void testMultipleFieldDeclarationWithInitializers()
125
126
assertEquals (1 , fields .get (2 ).getType ().getArrayDimensions ());
126
127
}
127
128
129
+ @ Test
130
+ public void testMultipleFieldDeclarationParse ()
131
+ {
132
+ JavaClassSource javaClassSource = Roaster .parse (JavaClassSource .class , "public class Test { private String a,b; }" );
133
+ assertThat (javaClassSource .getFields ()).hasSize (2 ).extracting (FieldSource ::getName ).containsExactly ("a" , "b" );
134
+ }
128
135
}
You can’t perform that action at this time.
0 commit comments