Uploaded image for project: 'Forge'
  1. Forge
  2. FORGE-1097

Forge Java parser fails to distinguish between several fields in a FieldDeclaration

    Details

      Description

      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.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                gastaldi George Gastaldi
                Reporter:
                vineet.reynolds Vineet Reynolds
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: