• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Node类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中japa.parser.ast.Node的典型用法代码示例。如果您正苦于以下问题:Java Node类的具体用法?Java Node怎么用?Java Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Node类属于japa.parser.ast包,在下文中一共展示了Node类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: resolve

import japa.parser.ast.Node; //导入依赖的package包/类
@Override
public NodeData resolve(Node node, String mappedClass) {
    if (!(node instanceof ClassOrInterfaceDeclaration)) {
        throw new IllegalArgumentException("this annotation belongs only on ClassOrInterfaceDeclaration");
    }

    final TypeDeclaration dclr = (TypeDeclaration) node;
    if (!(dclr.getParentNode() instanceof CompilationUnit)) {
        //handling nested classes
        return null;
    }
    final String name = dclr.getName();

    final Collection<FieldDescriptor> primaryKeyDescriptors = getPrimaryKeyDescriptors(mappedClass);

    if (primaryKeyDescriptors != null && primaryKeyDescriptors.size() > 1  && nodeContainsPkFields(dclr,
            primaryKeyDescriptors)) {
        final NodeAndImports<ClassOrInterfaceDeclaration> primaryKeyClass = createPrimaryKeyClass(name, primaryKeyDescriptors);
        final String pkClassName = primaryKeyClass.node.getName();
        return new NodeData(new SingleMemberAnnotationExpr(new NameExpr(SIMPLE_NAME), new NameExpr(name + "." + pkClassName + ".class")),
                new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false), primaryKeyClass.imprts, primaryKeyClass.node);

    }
    return null;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:26,代码来源:IdClassResolver.java


示例2: resolve

import japa.parser.ast.Node; //导入依赖的package包/类
@Override
public NodeData resolve(Node node, String mappedClass) {
    if (!(node instanceof ClassOrInterfaceDeclaration)) {
        throw new IllegalArgumentException("this annotation belongs only on ClassOrInterfaceDeclaration");
    }

    final TypeDeclaration dclr = (TypeDeclaration) node;
    if (!(dclr.getParentNode() instanceof CompilationUnit)) {
        //handling nested classes
        return null;
    }

    final String name = dclr.getName();
    final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString();
    final String enclosingClass = pckg + "." + name;

    final ClassDescriptor cd = OjbUtil.findClassDescriptor(enclosingClass, descriptorRepositories);
    if (cd != null) {
        return new NodeData(new MarkerAnnotationExpr(new NameExpr(SIMPLE_NAME)),
                new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
    }

    return null;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:25,代码来源:EntityResolver.java


示例3: resolve

import japa.parser.ast.Node; //导入依赖的package包/类
@Override
public final NodeData resolve(Node node, String mappedClass) {
    if (!(node instanceof FieldDeclaration)) {
        throw new IllegalArgumentException("this annotation belongs only on FieldDeclaration");
    }

    final FieldDeclaration field = (FieldDeclaration) node;

    if (ResolverUtil.canFieldBeAnnotated(field)) {
        final TypeDeclaration dclr = (TypeDeclaration) node.getParentNode();

        final String name = dclr.getName();
        final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString();
        final String fullyQualifiedClass = pckg + "." + name;
        final boolean mappedColumn = OjbUtil.isMappedColumn(mappedClass, ParserUtil.getFieldName(field),
                descriptorRepositories);
        if (mappedColumn) {
            return getAnnotationNodes(fullyQualifiedClass, ParserUtil.getFieldName(field), mappedClass);
        }
    }
    return null;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:23,代码来源:AbstractMappedFieldResolver.java


示例4: resolve

import japa.parser.ast.Node; //导入依赖的package包/类
@Override
public NodeData resolve(Node node, String mappedClass) {
    if (!(node instanceof ClassOrInterfaceDeclaration)) {
        throw new IllegalArgumentException("this annotation belongs only on ClassOrInterfaceDeclaration");
    }

    final TypeDeclaration dclr = (TypeDeclaration) node;
    if (!(dclr.getParentNode() instanceof CompilationUnit)) {
        //handling nested classes
        return null;
    }

    final String name = dclr.getName();
    final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString();
    final String enclosingClass = pckg + "." + name;
    if (!enclosingClass.equals(mappedClass)) {
        return new NodeData(new MarkerAnnotationExpr(new NameExpr(SIMPLE_NAME)),
            new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
    }
    return null;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:22,代码来源:MappedSuperClassResolver.java


示例5: resolve

import japa.parser.ast.Node; //导入依赖的package包/类
@Override
public NodeData resolve(Node node, String mappedClass) {
    if (!(node instanceof ClassOrInterfaceDeclaration)) {
        throw new IllegalArgumentException("this annotation belongs only on ClassOrInterfaceDeclaration");
    }

    final TypeDeclaration dclr = (TypeDeclaration) node;
    if (!(dclr.getParentNode() instanceof CompilationUnit)) {
        //handling nested classes
        return null;
    }
    final String name = dclr.getName();
    final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString();
    final String enclosingClass = pckg + "." + name;
    final Collection<String> customizedFieldsOnNode = getFieldsOnNode(dclr, getCustomizedFields(mappedClass));
    if (customizedFieldsOnNode == null || customizedFieldsOnNode.isEmpty()) {
        LOG.info(ResolverUtil.logMsgForClass(enclosingClass, mappedClass) + " has no customized fields");
        return null;
    }
    return new NodeData(new SingleMemberAnnotationExpr(new NameExpr(SIMPLE_NAME), new NameExpr("CreateCustomizerFor" + customizedFieldsOnNode.toString())),
            new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:23,代码来源:CustomizerResolver.java


示例6: resolve

import japa.parser.ast.Node; //导入依赖的package包/类
@Override
public NodeData resolve(Node node, String mappedClass) {
    if (!(node instanceof FieldDeclaration)) {
        throw new IllegalArgumentException("this annotation belongs only on FieldDeclaration");
    }

    final FieldDeclaration field = (FieldDeclaration) node;

    if (ResolverUtil.canFieldBeAnnotated(field)) {
        final boolean mappedColumn = OjbUtil.isMappedColumn(mappedClass, ParserUtil.getFieldName(field),
                descriptorRepositories);
        if (!mappedColumn) {
            return new NodeData(new MarkerAnnotationExpr(new NameExpr(SIMPLE_NAME)),
                    new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
        }
    }
    return null;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:19,代码来源:TransientResolver.java


示例7: appendNode

import japa.parser.ast.Node; //导入依赖的package包/类
private void appendNode(StringBuilder s, Node node) {
	for (int lineNum = node.getBeginLine(); lineNum <= node.getEndLine(); lineNum++) {
		String line = lines.get(lineNum);
		int start;
		if (lineNum == node.getBeginLine())
			start = node.getBeginColumn();
		else
			start = 0;
		int end;
		if (lineNum == node.getEndLine())
			end = node.getEndColumn();
		else
			end = line.length();
		s.append(line.substring(start, end));
	}
}
 
开发者ID:davidmoten,项目名称:rxjava-parallel,代码行数:17,代码来源:MethodVisitor.java


示例8: getNode

import japa.parser.ast.Node; //导入依赖的package包/类
public static Node getNode(CompilationUnit unit, String fqName) {
	String pkg = getQualifiedName(unit.getPackage().getName());
	if (!fqName.startsWith(pkg)) {
		return null;
	}
	if (fqName.equals(pkg)) {
		return unit.getPackage();
	}

	String name = fqName.substring(pkg.length() + 1);

	for (TypeDeclaration typeDecl : unit.getTypes()) {
		if (name.startsWith(typeDecl.getName())) {
			if (name.length() == typeDecl.getName().length()) {
				return typeDecl;
			} else {
				return getNode(typeDecl, name.substring(typeDecl.getName().length() + 1));
			}
		}
	}

	return null;
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:24,代码来源:JavaParserUtils.java


示例9: visit

import japa.parser.ast.Node; //导入依赖的package包/类
public Node visit(ExplicitConstructorInvocationStmt n, A arg) {
    if (!n.isThis()) {
        if (n.getExpr() != null) {
            n.setExpr((Expression) n.getExpr().accept(this, arg));
        }
    }
    List<Type> typeArgs = n.getTypeArgs();
    if (typeArgs != null) {
        for (int i = 0; i < typeArgs.size(); i++) {
            typeArgs.set(i, (Type) typeArgs.get(i).accept(this, arg));
        }
        removeNulls(typeArgs);
    }
    List<Expression> args = n.getArgs();
    if (args != null) {
        for (int i = 0; i < args.size(); i++) {
            args.set(i, (Expression) args.get(i).accept(this, arg));
        }
        removeNulls(args);
    }
    return n;
}
 
开发者ID:rfw,项目名称:genja,代码行数:23,代码来源:ModifierVisitorAdapter.java


示例10: nodesEquals

import japa.parser.ast.Node; //导入依赖的package包/类
private <T extends Node> boolean nodesEquals(List<T> nodes1, List<T> nodes2) {
    if (nodes1 == null) {
        if (nodes2 == null) {
            return true;
        }
        return false;
    } else if (nodes2 == null) {
        return false;
    }
    if (nodes1.size() != nodes2.size()) {
        return false;
    }
    for (int i = 0; i < nodes1.size(); i++) {
        if (!nodeEquals(nodes1.get(i), nodes2.get(i))) {
            return false;
        }
    }
    return true;
}
 
开发者ID:rfw,项目名称:genja,代码行数:20,代码来源:EqualsVisitor.java


示例11: nodeEquals

import japa.parser.ast.Node; //导入依赖的package包/类
private <T extends Node> boolean nodeEquals(T n1, T n2) {
    if (n1 == n2) {
        return true;
    }
    if (n1 == null) {
        if (n2 == null) {
            return true;
        }
        return false;
    } else if (n2 == null) {
        return false;
    }
    if (n1.getClass() != n2.getClass()) {
        return false;
    }
    return n1.accept(this, n2).booleanValue();
}
 
开发者ID:rfw,项目名称:genja,代码行数:18,代码来源:EqualsVisitor.java


示例12: visit

import japa.parser.ast.Node; //导入依赖的package包/类
public Boolean visit(Parameter n1, Node arg) {
    Parameter n2 = (Parameter) arg;

    if (n1.getModifiers() != n2.getModifiers()) {
        return Boolean.FALSE;
    }

    if (!nodeEquals(n1.getId(), n2.getId())) {
        return Boolean.FALSE;
    }

    if (!nodeEquals(n1.getType(), n2.getType())) {
        return Boolean.FALSE;
    }

    if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) {
        return Boolean.FALSE;
    }

    return Boolean.TRUE;
}
 
开发者ID:rfw,项目名称:genja,代码行数:22,代码来源:EqualsVisitor.java


示例13: doTest

import japa.parser.ast.Node; //导入依赖的package包/类
void doTest(String source, Node node) {
    String parsed = node.toString();

    assertTrue(node.getClass().getName() + ": " + parsed, node.getBeginLine() >= 0);
    assertTrue(node.getClass().getName() + ": " + parsed, node.getBeginColumn() >= 0);
    assertTrue(node.getClass().getName() + ": " + parsed, node.getEndLine() >= 0);
    assertTrue(node.getClass().getName() + ": " + parsed, node.getEndColumn() >= 0);

    if (node.getBeginLine() == node.getEndLine()) {
        assertTrue(node.getClass().getName() + ": " + parsed, node.getBeginColumn() <= node.getEndColumn());
    } else {
        assertTrue(node.getClass().getName() + ": " + parsed, node.getBeginLine() <= node.getEndLine());
    }

    String substr = substring(source, node.getBeginLine(), node.getBeginColumn(), node.getEndLine(), node.getEndColumn());
    assertEquals(node.getClass().getName(), trimLines(parsed), trimLines(substr));
}
 
开发者ID:rfw,项目名称:genja,代码行数:18,代码来源:TestNodePositions.java


示例14: resolve

import japa.parser.ast.Node; //导入依赖的package包/类
@Override
public NodeData resolve(Node node, String mappedClass) {
    if (!(node instanceof ClassOrInterfaceDeclaration)) {
        throw new IllegalArgumentException("this annotation belongs only on ClassOrInterfaceDeclaration");
    }

    final TypeDeclaration dclr = (TypeDeclaration) node;
    if (!(dclr.getParentNode() instanceof CompilationUnit)) {
        //handling nested classes
        return null;
    }
    final String name = dclr.getName();
    final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString();
    final String enclosingClass = pckg + "." + name;

    final ClassDescriptor cd = OjbUtil.findClassDescriptor(enclosingClass, descriptorRepositories);
    if (cd != null) {
        final String tableName = getMappedTable(enclosingClass);
        if (tableName == null) {
            LOG.error(ResolverUtil.logMsgForClass(enclosingClass, mappedClass) + " table could not be found");
            return null;
        }

        return new NodeData(new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), Collections.singletonList(new MemberValuePair("name", new StringLiteralExpr(upperCaseTableName ? tableName.toUpperCase() : tableName)))),
                new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
    }
    return null;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:29,代码来源:TableResolver.java


示例15: getCompilationUnit

import japa.parser.ast.Node; //导入依赖的package包/类
/** walks up the tree until reaching the CompilationUnit. */
private CompilationUnit getCompilationUnit(Node n) {
    Node unit = n;
    while (!(unit instanceof CompilationUnit) && unit != null) {
        unit = unit.getParentNode();
    }
    return (CompilationUnit) unit;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:9,代码来源:AnnotationHelper.java


示例16: fullRegion

import japa.parser.ast.Node; //导入依赖的package包/类
public static LineRegion fullRegion(Node node) {
	LineRegion result = region(node);
	if (node instanceof BodyDeclaration) {
		BodyDeclaration bodyDecl = (BodyDeclaration) node;
		if (bodyDecl.getAnnotations() != null) {
			for (AnnotationExpr annotation : bodyDecl.getAnnotations()) {
				result = result.union(region(annotation));
			}
		}
		if (bodyDecl.getJavaDoc() != null) {
			result = result.union(region(bodyDecl.getJavaDoc()));
		}
	}
	return result;
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:16,代码来源:LineUtils.java


示例17: visit

import japa.parser.ast.Node; //导入依赖的package包/类
@Override
public Node visit(BreakStmt n, Generator s) {
    if (n.getId() != null && s.labels.containsKey(n.getId())) {
        // Generate a jump to another label, if the label is inside our state machine.
        return Generator.generateJump(s.labels.get(n.getId()).breakPoint);
    }

    // Otherwise we just move the statement out.
    return n;
}
 
开发者ID:rfw,项目名称:genja,代码行数:11,代码来源:LabeledJumpTransform.java


示例18: visit

import japa.parser.ast.Node; //导入依赖的package包/类
@Override
public Node visit(ForeachStmt n, Void arg) {
    super.visit(n, arg);

    // Reword the loop.
    throw new TransformException("not supported yet");
}
 
开发者ID:rfw,项目名称:genja,代码行数:8,代码来源:LoopDesugarTransform.java



注:本文中的japa.parser.ast.Node类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WrapperFactory类代码示例发布时间:2022-05-22
下一篇:
Java Data类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap