-
Bug
-
Resolution: Done
-
Critical
-
1.3.3.Final
-
None
Consider the following test:
@Test public void testFieldTypesByteExtraDimensionDeclarationTest() { final JavaClass javaClass = JavaParser.create(JavaClass.class); final Field<JavaClass> field = javaClass.addField("public byte content1[], content2;"); Assert.assertEquals("content1", field.getName()); Assert.assertEquals("byte[]", field.getQualifiedType()); Assert.assertEquals("byte[]", field.getType()); Assert.assertTrue(field.getTypeInspector().isArray()); }
The above shown behavior is obviously incorrect since the second 'field' named content2 is 'lost' and so is information about it's type.
The underlying issue is that of the parser treating the FieldDeclaration as that belonging to a single field, whereas there may be several VariableDeclarationFragments within the same FieldDeclaration. Ideally, this should be solved by introducing a new type like Variable to identify individual variables in the declaration, or to change the semantic of Field to refer to the individual variables.