use of com.github.javaparser.ast.PackageDeclaration in project Gargoyle by callakrsos.
the class VOEditorParser method parse.
public void parse() throws ParseException {
// FileInputStream in = new FileInputStream(fileName);
CompilationUnit cu = JavaParser.parse(is);
PackageDeclaration package1 = cu.getPackage();
LOGGER.debug(package1.getName().toString());
LOGGER.debug(String.format("package name : %s", package1.getName().getName()));
// prints the resulting compilation unit to default system output
LOGGER.debug(cu.toString());
new MethodVisitor().visit(cu, null);
}
use of com.github.javaparser.ast.PackageDeclaration in project Gargoyle by callakrsos.
the class VoEditorController method setFromFile.
/********************************
* 작성일 : 2016. 7. 4. 작성자 : KYJ
*
*
* @param voFile
* @throws IOException
* @throws FileNotFoundException
********************************/
public void setFromFile(File voFile) {
if (voFile == null || !voFile.exists())
return;
if (voFile.isFile()) {
CompilationUnit cu;
try (FileInputStream in = new FileInputStream(voFile)) {
// parse the file
cu = JavaParser.parse(in);
PackageDeclaration packageDeclaration = cu.getPackage();
txtPackageName.setText(packageDeclaration.getName().toString());
txtClassName.setText(voFile.getName().substring(0, voFile.getName().indexOf('.')));
txtLocation.setText(voFile.getAbsolutePath());
MethodVisitor methodVisitor = new MethodVisitor();
methodVisitor.visit(cu, null);
List<TableModelDVO> valideFieldMeta = methodVisitor.getValideFieldMeta(t -> {
TableModelDVO tableModelDVO = new TableModelDVO();
tableModelDVO.setName(t.getName());
tableModelDVO.setType(t.getFieldType().getSimpleName());
return tableModelDVO;
});
this.tbVoEditor.getItems().addAll(valideFieldMeta);
} catch (IOException | ParseException e) {
LOGGER.error(ValueUtil.toString(e));
}
} else {
txtLocation.setText(voFile.getAbsolutePath());
}
}
use of com.github.javaparser.ast.PackageDeclaration in project Gargoyle by callakrsos.
the class VOEditorParser2 method main.
public static void main(String[] args) throws ParseException, IOException {
String fileName = "C:\\Users\\KYJ\\JAVA_FX\\gagoyleWorkspace\\VisualFxVoEditor\\src\\main\\java\\com\\kyj\\fx\\voeditor\\visual\\main\\model\\vo\\ClassPathEntry.java";
FileInputStream in = new FileInputStream(fileName);
CompilationUnit cu;
try {
// parse the file
cu = JavaParser.parse(in);
} finally {
in.close();
}
PackageDeclaration packageDeclaration = cu.getPackage();
// System.out.println(packageDeclaration.getName().toString());
// System.out.println();
// System.out.println(String.format("package name : %s",
// packageDeclaration.getName().getName()));
ClassMeta classMeta = new ClassMeta("");
classMeta.setPackageName(packageDeclaration.getName().toString());
ArrayList<FieldMeta> fields = new ArrayList<FieldMeta>();
VoEditor voEditor = new VoEditor(classMeta, fields);
List<Node> childrenNodes = cu.getChildrenNodes();
for (Node n : childrenNodes) {
}
new MethodVisitor().visit(cu, null);
}
Aggregations