當前位置: 首頁>>代碼示例>>Java>>正文


Java CompilationUnit.getChildrenNodes方法代碼示例

本文整理匯總了Java中com.github.javaparser.ast.CompilationUnit.getChildrenNodes方法的典型用法代碼示例。如果您正苦於以下問題:Java CompilationUnit.getChildrenNodes方法的具體用法?Java CompilationUnit.getChildrenNodes怎麽用?Java CompilationUnit.getChildrenNodes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.github.javaparser.ast.CompilationUnit的用法示例。


在下文中一共展示了CompilationUnit.getChildrenNodes方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: insertCommentsInCu

import com.github.javaparser.ast.CompilationUnit; //導入方法依賴的package包/類
/**
 * Comments are attributed to the thing the comment and are removed from
 * allComments.
 */
private static void insertCommentsInCu(CompilationUnit cu, CommentsCollection commentsCollection){
    if (commentsCollection.size()==0) return;

    // I should sort all the direct children and the comments, if a comment is the first thing then it
    // a comment to the CompilationUnit
    // FIXME if there is no package it could be also a comment to the following class...
    // so I could use some heuristics in these cases to distinguish the two cases

    List<Comment> comments = commentsCollection.getAll();
    PositionUtils.sortByBeginPosition(comments);
    List<Node> children = cu.getChildrenNodes();
    PositionUtils.sortByBeginPosition(children);

    if (cu.getPackage()!=null && (children.isEmpty() || PositionUtils.areInOrder(comments.get(0), children.get(0)))){
        cu.setComment(comments.get(0));
        comments.remove(0);
    }

    insertCommentsInNode(cu,comments);
}
 
開發者ID:plum-umd,項目名稱:java-sketch,代碼行數:25,代碼來源:JavaParser.java

示例2: insertComments

import com.github.javaparser.ast.CompilationUnit; //導入方法依賴的package包/類
/**
 * Comments are attributed to the thing they comment and are removed from
 * the comments.
 */
private void insertComments(CompilationUnit cu, TreeSet<Comment> comments) {
    if (comments.isEmpty())
        return;

    /* I should sort all the direct children and the comments, if a comment
     is the first thing then it
     a comment to the CompilationUnit */

    // FIXME if there is no package it could be also a comment to the following class...
    // so I could use some heuristics in these cases to distinguish the two
    // cases

    List<Node> children = cu.getChildrenNodes();
    PositionUtils.sortByBeginPosition(children);

    Comment firstComment = comments.iterator().next();
    if (cu.getPackage() != null
            && (children.isEmpty() || PositionUtils.areInOrder(
            firstComment, children.get(0)))) {
        cu.setComment(firstComment);
        comments.remove(firstComment);
    }
}
 
開發者ID:javaparser,項目名稱:javasymbolsolver,代碼行數:28,代碼來源:CommentsInserter.java

示例3: insertCommentsInCu

import com.github.javaparser.ast.CompilationUnit; //導入方法依賴的package包/類
/**
 * Comments are attributed to the thing the comment and are removed from
 * allComments.
 */
private static void insertCommentsInCu(CompilationUnit cu, CommentsCollection commentsCollection){
    if (commentsCollection.size()==0) return;

    // I should sort all the direct children and the comments, if a comment is the first thing then it
    // a comment to the CompilationUnit
    // FIXME if there is no package it could be also a comment to the following class...
    // so I could use some heuristics in these cases to distinguish the two cases

    List<Comment> comments = commentsCollection.getAll();
    PositionUtils.sortByBeginPosition(comments);
    List<Node> children = cu.getChildrenNodes();
    PositionUtils.sortByBeginPosition(children);

    if (cu.getPackage()!=null && (children.size()==0 || PositionUtils.areInOrder(comments.get(0), children.get(0)))){
        cu.setComment(comments.get(0));
        comments.remove(0);
    }

    insertCommentsInNode(cu,comments);
}
 
開發者ID:javaparser,項目名稱:javasymbolsolver,代碼行數:25,代碼來源:JavaParser.java

示例4: main

import com.github.javaparser.ast.CompilationUnit; //導入方法依賴的package包/類
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);

}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:33,代碼來源:VOEditorParser2.java

示例5: getBody

import com.github.javaparser.ast.CompilationUnit; //導入方法依賴的package包/類
public static BodyDeclaration getBody(CompilationUnit cu) {
	List<Node> nodes = cu.getChildrenNodes();
	for (Node node : nodes) {
		if (node instanceof BodyDeclaration) {
			return (BodyDeclaration) node;
		}
	}
	return null;
}
 
開發者ID:niaoge,項目名稱:spring-dynamic,代碼行數:10,代碼來源:ParserUtils.java


注:本文中的com.github.javaparser.ast.CompilationUnit.getChildrenNodes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。