当前位置: 首页>>代码示例>>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;未经允许,请勿转载。