37 lines
1.2 KiB
Java
37 lines
1.2 KiB
Java
package parser;
|
|
|
|
import de.dhbwstuttgart.parser.JavaTXParser;
|
|
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
|
import de.dhbwstuttgart.syntaxtree.Field;
|
|
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
|
import org.junit.Test;
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.lang.reflect.Modifier;
|
|
|
|
public class FieldTest {
|
|
private static final String rootDirectory = System.getProperty("user.dir")+"/test/parser/";
|
|
|
|
@Test
|
|
public void test() throws IOException, ClassNotFoundException, ClassNotFoundException {
|
|
|
|
JavaTXParser parser = new JavaTXParser();
|
|
SourceFile f = parser.parse(new File(rootDirectory + "FieldVarTest.jav"));
|
|
|
|
String pkgName = f.getPkgName();
|
|
System.out.println("package: " + pkgName);
|
|
System.out.println("classes:");
|
|
for(ClassOrInterface c : f.getClasses()){
|
|
int mod = c.getModifiers();
|
|
System.out.println(Modifier.toString(mod));
|
|
System.out.println(c.getClassName().toString());
|
|
System.out.println("{");
|
|
for(Field field : c.getFieldDecl()){
|
|
System.out.println(field.getName());
|
|
}
|
|
System.out.println("}");
|
|
}
|
|
}
|
|
}
|