本文整理汇总了Java中com.github.javaparser.ast.nodeTypes.NodeWithType类的典型用法代码示例。如果您正苦于以下问题:Java NodeWithType类的具体用法?Java NodeWithType怎么用?Java NodeWithType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NodeWithType类属于com.github.javaparser.ast.nodeTypes包,在下文中一共展示了NodeWithType类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveTypesUsingImports
import com.github.javaparser.ast.nodeTypes.NodeWithType; //导入依赖的package包/类
/**
* Resolve all the types in the expression.
* This will replace the Class with the full qualified name using the template imports.
* @param expression A Java expression from the Template
*/
private void resolveTypesUsingImports(Expression expression)
{
if (expression instanceof NodeWithType)
{
NodeWithType nodeWithType = ((NodeWithType) expression);
nodeWithType.setType(getQualifiedName(nodeWithType.getType()));
}
// Recurse downward in the expression
expression
.getChildNodes()
.stream()
.filter(Expression.class::isInstance)
.map(Expression.class::cast)
.forEach(this::resolveTypesUsingImports);
}
示例2: processSpecialNodeTypes
import com.github.javaparser.ast.nodeTypes.NodeWithType; //导入依赖的package包/类
/**
* Given a variable declaration of some sort, check it's name and type and
* if it looks like any of the key type changes between unsafe and atomic
* queues, perform the conversion to change it's type.
*
* @param node
* @param name
*/
private static void processSpecialNodeTypes(NodeWithType<?, Type> node, String name) {
Type type = node.getType();
if ("buffer".equals(name) && isRefArray(type, "E")) {
node.setType(atomicRefArrayType((ArrayType) type));
} else if ("sBuffer".equals(name) && isLongArray(type)) {
node.setType(atomicLongArrayType());
} else if (PrimitiveType.longType().equals(type)) {
switch(name) {
case "mask":
case "offset":
case "seqOffset":
case "lookAheadElementOffset":
node.setType(PrimitiveType.intType());
}
}
}
示例3: processSpecialNodeTypes
import com.github.javaparser.ast.nodeTypes.NodeWithType; //导入依赖的package包/类
/**
* Given a variable declaration of some sort, check it's name and type and
* if it looks like any of the key type changes between unsafe and atomic
* queues, perform the conversion to change it's type.
*
* @param node
* @param name
*/
private static void processSpecialNodeTypes(NodeWithType<?, Type> node, String name) {
Type type = node.getType();
if (node instanceof MethodDeclaration && ("newBufferAndOffset".equals(name) || "nextArrayOffset".equals(name))) {
node.setType(PrimitiveType.intType());
} else if (PrimitiveType.longType().equals(type)) {
switch(name) {
case "offset":
case "offsetInNew":
case "offsetInOld":
case "lookAheadElementOffset":
node.setType(PrimitiveType.intType());
}
} else if (isRefType(type, "LinkedQueueNode")) {
node.setType(simpleParametricType("LinkedQueueAtomicNode", "E"));
} else if (isRefArray(type, "E")) {
node.setType(atomicRefArrayType((ArrayType) type));
}
}