本文整理汇总了Java中com.github.javaparser.ast.type.UnknownType类的典型用法代码示例。如果您正苦于以下问题:Java UnknownType类的具体用法?Java UnknownType怎么用?Java UnknownType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnknownType类属于com.github.javaparser.ast.type包,在下文中一共展示了UnknownType类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import com.github.javaparser.ast.type.UnknownType; //导入依赖的package包/类
@Override
public JCTree visit(final UnknownType n, final Object arg) {
//ARG0 TypeTag
// An unknown type is a primitive type idetified
// by label defined in code/TypeTags
TypeTag arg0 = TypeTag.UNKNOWN;
return new AJCPrimitiveTypeTree(make.TypeIdent(arg0), ((n.getComment() != null) ? n.getComment().getContent() : null));
}
示例2: asKind
import com.github.javaparser.ast.type.UnknownType; //导入依赖的package包/类
public static TypeKind asKind(Type type) {
if(type instanceof ClassOrInterfaceType) {
return TypeKind.DECLARED;
} else if(type instanceof PrimitiveType) {
switch (((PrimitiveType) type).getType()) {
case Boolean:
return TypeKind.BOOLEAN;
case Byte:
return TypeKind.BYTE;
case Char:
return TypeKind.CHAR;
case Double:
return TypeKind.DOUBLE;
case Float:
return TypeKind.FLOAT;
case Int:
return TypeKind.INT;
case Long:
return TypeKind.LONG;
case Short:
return TypeKind.SHORT;
}
} else if(type instanceof ReferenceType) {
return asKind(((ReferenceType) type).getType());
} else if(type instanceof UnknownType) {
return TypeKind.OTHER;
} else if(type instanceof VoidType) {
return TypeKind.VOID;
} else if(type instanceof WildcardType) {
return TypeKind.WILDCARD;
}
return TypeKind.ERROR;
}
示例3: visit
import com.github.javaparser.ast.type.UnknownType; //导入依赖的package包/类
@Override
public Type visit(Parameter node, Boolean solveLambdas) {
if (node.getType() instanceof UnknownType) {
throw new IllegalStateException("Parameter has unknown type: " + node);
}
return facade.convertToUsage(node.getType(), node);
}
示例4: visit
import com.github.javaparser.ast.type.UnknownType; //导入依赖的package包/类
@Override
public ResolvedType visit(Parameter node, Boolean solveLambdas) {
if (node.getType() instanceof UnknownType) {
throw new IllegalStateException("Parameter has unknown type: " + node);
}
return facade.convertToUsage(node.getType(), node);
}
示例5: getType
import com.github.javaparser.ast.type.UnknownType; //导入依赖的package包/类
@Override
public ResolvedType getType() {
if (wrappedNode.getType() instanceof UnknownType && JavaParserFactory.getContext(wrappedNode, typeSolver) instanceof LambdaExprContext) {
Optional<Value> value = JavaParserFactory.getContext(wrappedNode, typeSolver).solveSymbolAsValue(wrappedNode.getNameAsString(), typeSolver);
if (value.isPresent()) {
return value.get().getType();
}
}
ResolvedType res = JavaParserFacade.get(typeSolver).convert(wrappedNode.getType(), wrappedNode);
if (isVariadic()) {
res = new ResolvedArrayType(res);
}
return res;
}
示例6: visit
import com.github.javaparser.ast.type.UnknownType; //导入依赖的package包/类
@Override
public Node visit(
UnknownType n, Map<Node, Node> arg
) {
if (arg.containsKey(n)) {
return arg.get(n);
}
return super.visit(n, arg);
}
示例7: visit
import com.github.javaparser.ast.type.UnknownType; //导入依赖的package包/类
@Override
public void visit(UnknownType n, Script arg) {
}
示例8: visit
import com.github.javaparser.ast.type.UnknownType; //导入依赖的package包/类
@Override
public void visit(final UnknownType n, final Object arg) {
printer.printLn("UnknownType");
// Nothing to dump
}
示例9: convertToUsage
import com.github.javaparser.ast.type.UnknownType; //导入依赖的package包/类
public Type convertToUsage(com.github.javaparser.ast.type.Type type, Node context) {
if (type instanceof UnknownType) {
throw new IllegalArgumentException("Unknown type");
}
return convertToUsage(type, JavaParserFactory.getContext(context, typeSolver));
}
示例10: isExplicitlyTyped
import com.github.javaparser.ast.type.UnknownType; //导入依赖的package包/类
public static boolean isExplicitlyTyped(LambdaExpr lambdaExpr) {
return lambdaExpr.getParameters().stream().allMatch(p -> !(p.getType() instanceof UnknownType));
}
示例11: isImplicitlyTyped
import com.github.javaparser.ast.type.UnknownType; //导入依赖的package包/类
private boolean isImplicitlyTyped(LambdaExpr lambdaExpr) {
return lambdaExpr.getParameters().stream().anyMatch(p -> p.getType() instanceof UnknownType);
}
示例12: visit
import com.github.javaparser.ast.type.UnknownType; //导入依赖的package包/类
@Override
public void visit(final UnknownType n, final Context ctx) {
visitNode(n, ctx);
super.visit(n, ctx);
}
示例13: transformUnary
import com.github.javaparser.ast.type.UnknownType; //导入依赖的package包/类
public Node transformUnary(Expression source, UnaryExpr expr) {
final Expression data = expr.getExpr();
switch (expr.getOperator()) {
// x++
case posIncrement:
// x--
case posDecrement:
// For post increment / decrement,
// we want to store the de/incremented value,
// but use the current value.
// So, we will generate setX(getX() + 1),
// as the setX function returns the previous value
final String setter = generateSetterMethod(data);
final String getter = generateGetterMethod(data);
MethodCallExpr methodCall = new MethodCallExpr();
methodCall.setName(setter);
MethodCallExpr get = new MethodCallExpr();
get.setName(getter);
final BinaryExpr.Operator operator = expr.getOperator() == Operator.posIncrement ? BinaryExpr.Operator.plus : BinaryExpr.Operator.minus;
BinaryExpr op = new BinaryExpr(get, new IntegerLiteralExpr("1"), operator);
methodCall.setArgs(Arrays.asList(op));
initExtras(methodCall, data);
return methodCall;
// ++x
// --x
case preIncrement:
case preDecrement:
// For pre increment / decrement,
// we want to de/increment the value,
// and use the updated value immediately
// So, we will use computeX_1(i -> i++)
// TODO: Have a global INCREMENT function we can just reference instead
String compute = generateComputeMethod(data) + "_1";
List<Parameter> params = new ArrayList<>();
Type type = new UnknownType();
VariableDeclaratorId id = new VariableDeclaratorId("i");
params.add(new Parameter(type, id));
UnaryExpr copy = new UnaryExpr(new NameExpr("i"), expr.getOperator());
Statement body = new ExpressionStmt(copy);
LambdaExpr lambda = new LambdaExpr(params, body, false);
methodCall = new MethodCallExpr();
methodCall.setName(compute);
methodCall.setArgs(Arrays.asList(lambda));
initExtras(methodCall, data);
return methodCall;
case inverse:
case negative:
case not:
case positive:
throw new NotImplemented("Need to implement unary operator " + expr.getOperator() + " in " + getClass());
}
return expr;
// return new StringLiteralExpr(expr.toSource());
}
示例14: visit
import com.github.javaparser.ast.type.UnknownType; //导入依赖的package包/类
@Override
public void visit(UnknownType n, Void arg) {
out.println("UnknownType: " + (extended ? n : ""));
super.visit(n, arg);
}