本文整理匯總了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));
}
}