Search in sources :

Example 1 with ParseException

use of com.github.javaparser.ParseException 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());
    }
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) TableModelDVO(kyj.Fx.dao.wizard.core.model.vo.TableModelDVO) IOException(java.io.IOException) ParseException(com.github.javaparser.ParseException) FileInputStream(java.io.FileInputStream) PackageDeclaration(com.github.javaparser.ast.PackageDeclaration)

Aggregations

ParseException (com.github.javaparser.ParseException)1 CompilationUnit (com.github.javaparser.ast.CompilationUnit)1 PackageDeclaration (com.github.javaparser.ast.PackageDeclaration)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 TableModelDVO (kyj.Fx.dao.wizard.core.model.vo.TableModelDVO)1