Search in sources :

Example 1 with PackageDeclaration

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);
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) PackageDeclaration(com.github.javaparser.ast.PackageDeclaration)

Example 2 with PackageDeclaration

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());
    }
}
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)

Example 3 with PackageDeclaration

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);
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) ClassMeta(com.kyj.fx.voeditor.core.model.meta.ClassMeta) FieldMeta(com.kyj.fx.voeditor.core.model.meta.FieldMeta) Node(com.github.javaparser.ast.Node) ArrayList(java.util.ArrayList) FileInputStream(java.io.FileInputStream) PackageDeclaration(com.github.javaparser.ast.PackageDeclaration) VoEditor(com.kyj.fx.voeditor.core.VoEditor)

Aggregations

CompilationUnit (com.github.javaparser.ast.CompilationUnit)3 PackageDeclaration (com.github.javaparser.ast.PackageDeclaration)3 FileInputStream (java.io.FileInputStream)2 ParseException (com.github.javaparser.ParseException)1 Node (com.github.javaparser.ast.Node)1 VoEditor (com.kyj.fx.voeditor.core.VoEditor)1 ClassMeta (com.kyj.fx.voeditor.core.model.meta.ClassMeta)1 FieldMeta (com.kyj.fx.voeditor.core.model.meta.FieldMeta)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 TableModelDVO (kyj.Fx.dao.wizard.core.model.vo.TableModelDVO)1