Search in sources :

Example 6 with ResolvedFieldDeclaration

use of com.github.javaparser.resolution.declarations.ResolvedFieldDeclaration in project javaparser by javaparser.

the class JavaParserInterfaceDeclarationTest method testGetAllNonStaticFields.

@Test
public void testGetAllNonStaticFields() {
    JavaParserClassDeclaration constructorDeclaration = (JavaParserClassDeclaration) typeSolver.solveType("com.github.javaparser.ast.body.ConstructorDeclaration");
    List<ResolvedFieldDeclaration> allFields = constructorDeclaration.getAllNonStaticFields();
    assertEquals(13, allFields.size());
    ResolvedFieldDeclaration ResolvedFieldDeclaration;
    ResolvedFieldDeclaration = allFields.get(0);
    assertEquals("modifiers", ResolvedFieldDeclaration.getName());
    ResolvedFieldDeclaration = allFields.get(1);
    assertEquals("typeParameters", ResolvedFieldDeclaration.getName());
    ResolvedFieldDeclaration = allFields.get(2);
    assertEquals("name", ResolvedFieldDeclaration.getName());
    ResolvedFieldDeclaration = allFields.get(3);
    assertEquals("parameters", ResolvedFieldDeclaration.getName());
    ResolvedFieldDeclaration = allFields.get(4);
    assertEquals("throws_", ResolvedFieldDeclaration.getName());
    ResolvedFieldDeclaration = allFields.get(5);
    assertEquals("body", ResolvedFieldDeclaration.getName());
    ResolvedFieldDeclaration = allFields.get(6);
    assertEquals("annotations", ResolvedFieldDeclaration.getName());
    ResolvedFieldDeclaration = allFields.get(7);
    assertEquals("range", ResolvedFieldDeclaration.getName());
    ResolvedFieldDeclaration = allFields.get(8);
    assertEquals("parentNode", ResolvedFieldDeclaration.getName());
    ResolvedFieldDeclaration = allFields.get(9);
    assertEquals("childrenNodes", ResolvedFieldDeclaration.getName());
    ResolvedFieldDeclaration = allFields.get(10);
    assertEquals("orphanComments", ResolvedFieldDeclaration.getName());
    ResolvedFieldDeclaration = allFields.get(11);
    assertEquals("userData", ResolvedFieldDeclaration.getName());
    ResolvedFieldDeclaration = allFields.get(12);
    assertEquals("comment", ResolvedFieldDeclaration.getName());
}
Also used : ResolvedFieldDeclaration(com.github.javaparser.resolution.declarations.ResolvedFieldDeclaration) AbstractTest(com.github.javaparser.symbolsolver.AbstractTest) Test(org.junit.Test)

Example 7 with ResolvedFieldDeclaration

use of com.github.javaparser.resolution.declarations.ResolvedFieldDeclaration in project javaparser by javaparser.

the class JavaParserClassDeclarationTest method testGetDeclaredFields.

@Test
public void testGetDeclaredFields() {
    JavaParserClassDeclaration constructorDeclaration = (JavaParserClassDeclaration) typeSolverNewCode.solveType("com.github.javaparser.ast.body.ConstructorDeclaration");
    List<ResolvedFieldDeclaration> allFields = constructorDeclaration.getDeclaredFields();
    assertEquals(6, allFields.size());
    ResolvedFieldDeclaration fieldDeclaration = null;
    fieldDeclaration = allFields.get(0);
    assertEquals("modifiers", fieldDeclaration.getName());
    fieldDeclaration = allFields.get(1);
    assertEquals("typeParameters", fieldDeclaration.getName());
    fieldDeclaration = allFields.get(2);
    assertEquals("name", fieldDeclaration.getName());
    fieldDeclaration = allFields.get(3);
    assertEquals("parameters", fieldDeclaration.getName());
    fieldDeclaration = allFields.get(4);
    assertEquals("throws_", fieldDeclaration.getName());
    fieldDeclaration = allFields.get(5);
    assertEquals("body", fieldDeclaration.getName());
}
Also used : ResolvedFieldDeclaration(com.github.javaparser.resolution.declarations.ResolvedFieldDeclaration) AbstractTest(com.github.javaparser.symbolsolver.AbstractTest) Test(org.junit.Test)

Example 8 with ResolvedFieldDeclaration

use of com.github.javaparser.resolution.declarations.ResolvedFieldDeclaration in project javaparser by javaparser.

the class JavaParserClassDeclarationTest method testGetAllFields.

@Test
public void testGetAllFields() {
    JavaParserClassDeclaration constructorDeclaration = (JavaParserClassDeclaration) typeSolverNewCode.solveType("com.github.javaparser.ast.body.ConstructorDeclaration");
    List<ResolvedFieldDeclaration> allFields = constructorDeclaration.getAllFields();
    assertEquals(16, allFields.size());
    ResolvedFieldDeclaration fieldDeclaration = null;
    fieldDeclaration = allFields.get(0);
    assertEquals("modifiers", fieldDeclaration.getName());
    fieldDeclaration = allFields.get(1);
    assertEquals("typeParameters", fieldDeclaration.getName());
    fieldDeclaration = allFields.get(2);
    assertEquals("name", fieldDeclaration.getName());
    fieldDeclaration = allFields.get(3);
    assertEquals("parameters", fieldDeclaration.getName());
    fieldDeclaration = allFields.get(4);
    assertEquals("throws_", fieldDeclaration.getName());
    fieldDeclaration = allFields.get(5);
    assertEquals("body", fieldDeclaration.getName());
    fieldDeclaration = allFields.get(6);
    assertEquals("annotations", fieldDeclaration.getName());
    fieldDeclaration = allFields.get(7);
    assertEquals("NODE_BY_BEGIN_POSITION", fieldDeclaration.getName());
    fieldDeclaration = allFields.get(8);
    assertEquals("range", fieldDeclaration.getName());
    fieldDeclaration = allFields.get(9);
    assertEquals("parentNode", fieldDeclaration.getName());
    fieldDeclaration = allFields.get(10);
    assertEquals("childrenNodes", fieldDeclaration.getName());
    fieldDeclaration = allFields.get(11);
    assertEquals("orphanComments", fieldDeclaration.getName());
    fieldDeclaration = allFields.get(12);
    assertEquals("userData", fieldDeclaration.getName());
    fieldDeclaration = allFields.get(13);
    assertEquals("comment", fieldDeclaration.getName());
    fieldDeclaration = allFields.get(14);
    assertEquals("ABSOLUTE_BEGIN_LINE", fieldDeclaration.getName());
    fieldDeclaration = allFields.get(15);
    assertEquals("ABSOLUTE_END_LINE", fieldDeclaration.getName());
}
Also used : ResolvedFieldDeclaration(com.github.javaparser.resolution.declarations.ResolvedFieldDeclaration) AbstractTest(com.github.javaparser.symbolsolver.AbstractTest) Test(org.junit.Test)

Example 9 with ResolvedFieldDeclaration

use of com.github.javaparser.resolution.declarations.ResolvedFieldDeclaration in project javaparser by javaparser.

the class JavaParserClassDeclarationTest method testGetFieldForExistingField.

// /
// / Test fields
// /
@Test
public void testGetFieldForExistingField() {
    JavaParserClassDeclaration constructorDeclaration = (JavaParserClassDeclaration) typeSolverNewCode.solveType("com.github.javaparser.ast.body.ConstructorDeclaration");
    ResolvedFieldDeclaration fieldDeclaration = null;
    // declared field
    fieldDeclaration = constructorDeclaration.getField("modifiers");
    assertEquals("modifiers", fieldDeclaration.getName());
    assertEquals("java.util.EnumSet", fieldDeclaration.getType().asReferenceType().getQualifiedName());
    assertEquals(AccessSpecifier.PRIVATE, fieldDeclaration.accessSpecifier());
    assertEquals(false, fieldDeclaration.isStatic());
    // inherited field
    fieldDeclaration = constructorDeclaration.getField("annotations");
    assertEquals("annotations", fieldDeclaration.getName());
    assertEquals("java.util.List", fieldDeclaration.getType().asReferenceType().getQualifiedName());
    assertEquals(AccessSpecifier.PRIVATE, fieldDeclaration.accessSpecifier());
}
Also used : ResolvedFieldDeclaration(com.github.javaparser.resolution.declarations.ResolvedFieldDeclaration) AbstractTest(com.github.javaparser.symbolsolver.AbstractTest) Test(org.junit.Test)

Example 10 with ResolvedFieldDeclaration

use of com.github.javaparser.resolution.declarations.ResolvedFieldDeclaration in project javaparser by javaparser.

the class JavaParserInterfaceDeclarationTest method testGetDeclaredFields.

@Test
public void testGetDeclaredFields() {
    JavaParserClassDeclaration constructorDeclaration = (JavaParserClassDeclaration) typeSolver.solveType("com.github.javaparser.ast.body.ConstructorDeclaration");
    List<ResolvedFieldDeclaration> allFields = constructorDeclaration.getDeclaredFields();
    assertEquals(6, allFields.size());
    ResolvedFieldDeclaration ResolvedFieldDeclaration;
    ResolvedFieldDeclaration = allFields.get(0);
    assertEquals("modifiers", ResolvedFieldDeclaration.getName());
    ResolvedFieldDeclaration = allFields.get(1);
    assertEquals("typeParameters", ResolvedFieldDeclaration.getName());
    ResolvedFieldDeclaration = allFields.get(2);
    assertEquals("name", ResolvedFieldDeclaration.getName());
    ResolvedFieldDeclaration = allFields.get(3);
    assertEquals("parameters", ResolvedFieldDeclaration.getName());
    ResolvedFieldDeclaration = allFields.get(4);
    assertEquals("throws_", ResolvedFieldDeclaration.getName());
    ResolvedFieldDeclaration = allFields.get(5);
    assertEquals("body", ResolvedFieldDeclaration.getName());
}
Also used : ResolvedFieldDeclaration(com.github.javaparser.resolution.declarations.ResolvedFieldDeclaration) AbstractTest(com.github.javaparser.symbolsolver.AbstractTest) Test(org.junit.Test)

Aggregations

ResolvedFieldDeclaration (com.github.javaparser.resolution.declarations.ResolvedFieldDeclaration)10 AbstractTest (com.github.javaparser.symbolsolver.AbstractTest)10 Test (org.junit.Test)10