꽤 오래 되었기 때문에 나는이 문제의 전체 소스 코드를 여기에 게시하지 않겠다. 당신이 필요합니다
모든 문서는 여기에 있습니다 :. 당신이 전달 소스 코드에서 당신을 위해 컴파일 단위를 생성합니다
Document document = new Document("import java.util.List;\n\nclass X\n{\n\n\tpublic void deleteme()\n\t{\n\t}\n\n}\n");
ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setSource(document.get().toCharArray());
CompilationUnit cu = (CompilationUnit)parser.createAST(null);
cu.recordModifications();
http://publib.boulder.ibm.com/infocenter/iadthelp/v6r0/index.jsp?topic=/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/core/dom/package-summary.html
지금 이것은 간단한 기능입니다 전달한 클래스 정의 내의 모든 메소드를 인쇄합니다.
List<AbstractTypeDeclaration> types = cu.types();
for(AbstractTypeDeclaration type : types) {
if(type.getNodeType() == ASTNode.TYPE_DECLARATION) {
// Class def found
List<BodyDeclaration> bodies = type.bodyDeclarations();
for(BodyDeclaration body : bodies) {
if(body.getNodeType() == ASTNode.METHOD_DECLARATION) {
MethodDeclaration method = (MethodDeclaration)body;
System.out.println("method declaration: ");
System.out.println("name: " + method.getName().getFullyQualifiedName());
System.out.println("modifiers: " + method.getModifiers());
System.out.println("return type: " + method.getReturnType2().toString());
}
}
}
}
이렇게하면 모두 시작됩니다.
이 작업에 익숙해 지려면 약간의 시간이 필요합니다 (제 경우는 많습니다). 그러나 그것은 효과가 있으며, 손을 댈 수있는 가장 좋은 방법입니다.
행운을 빕니다)
ExtremeCoder
편집
: 나는 잊어 버리기 전에
이 내가이 작업을 얻기 위해 사용되는 수입은 (내가 꽤했다 이러한 조직 준비 시간) :
org.eclipse.jdt.core_xxxx.jar
org.eclipse.core.resources_xxxx.jar
org.eclipse.core.jobs_xxxx.jar
org.eclipse.core.runtime_xxxx.jar
org.eclipse.core.contenttype_xxxx.jar
org.eclipse.equinox.common_xxxx.jar
org.eclipse.equinox.preferences_xxxx.jar
org.eclipse.osgi_xxxx.jar
org.eclipse.text_xxxx.jar
여기서 xxxx는 버전 번호를 나타냅니다.