本文整理汇总了Java中org.walkmod.javalang.ast.type.PrimitiveType类的典型用法代码示例。如果您正苦于以下问题:Java PrimitiveType类的具体用法?Java PrimitiveType怎么用?Java PrimitiveType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PrimitiveType类属于org.walkmod.javalang.ast.type包,在下文中一共展示了PrimitiveType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import org.walkmod.javalang.ast.type.PrimitiveType; //导入依赖的package包/类
@Override
public SymbolType visit(PrimitiveType n, List<TypeParameter> arg) {
final SymbolType result;
Primitive pt = n.getType();
if (pt.equals(Primitive.Boolean)) {
result = new SymbolType(boolean.class.getName());
} else if (pt.equals(Primitive.Char)) {
result = new SymbolType(char.class.getName());
} else if (pt.equals(Primitive.Double)) {
result = new SymbolType(double.class.getName());
} else if (pt.equals(Primitive.Float)) {
result = new SymbolType(float.class.getName());
} else if (pt.equals(Primitive.Int)) {
result = new SymbolType(int.class.getName());
} else if (pt.equals(Primitive.Long)) {
result = new SymbolType(long.class.getName());
} else if (pt.equals(Primitive.Short)) {
result = new SymbolType(short.class.getName());
} else if (pt.equals(Primitive.Byte)) {
result = new SymbolType(byte.class.getName());
} else {
throw new IllegalArgumentException("unexpected primitive type: " + pt);
}
return result;
}
示例2: visit
import org.walkmod.javalang.ast.type.PrimitiveType; //导入依赖的package包/类
@Override
public void visit(PrimitiveType n, A arg) {
super.visit(n, arg);
Primitive type = n.getType();
if (type.equals(Primitive.Boolean)) {
n.setSymbolData(new SymbolType("boolean"));
} else if (type.equals(Primitive.Byte)) {
n.setSymbolData(new SymbolType("byte"));
} else if (type.equals(Primitive.Char)) {
n.setSymbolData(new SymbolType("char"));
} else if (type.equals(Primitive.Double)) {
n.setSymbolData(new SymbolType("double"));
} else if (type.equals(Primitive.Float)) {
n.setSymbolData(new SymbolType("float"));
} else if (type.equals(Primitive.Int)) {
n.setSymbolData(new SymbolType("int"));
} else if (type.equals(Primitive.Long)) {
n.setSymbolData(new SymbolType("long"));
} else if (type.equals(Primitive.Short)) {
n.setSymbolData(new SymbolType("short"));
}
}
示例3: testAddParameter
import org.walkmod.javalang.ast.type.PrimitiveType; //导入依赖的package包/类
@Test
public void testAddParameter() throws ParseException {
String code = "public class B { public void foo(){} }";
DefaultJavaParser parser = new DefaultJavaParser();
CompilationUnit cu = parser.parse(code, false);
CompilationUnit cu2 = parser.parse(code, false);
MethodDeclaration md = (MethodDeclaration) cu.getTypes().get(0).getMembers().get(0);
List<Parameter> params = new LinkedList<Parameter>();
params.add(new Parameter(new PrimitiveType(Primitive.Int), new VariableDeclaratorId("p")));
md.setParameters(params);
List<Action> actions = getActions(cu2, cu);
Assert.assertEquals(1, actions.size());
assertCode(actions, code, "public class B { public void foo(int p) {} }");
}
示例4: visit
import org.walkmod.javalang.ast.type.PrimitiveType; //导入依赖的package包/类
public R visit(PrimitiveType n, A arg) {
if (n.getAnnotations() != null) {
for (AnnotationExpr ae : n.getAnnotations()) {
ae.accept(this, arg);
}
}
return null;
}
示例5: visit
import org.walkmod.javalang.ast.type.PrimitiveType; //导入依赖的package包/类
public Boolean visit(PrimitiveType n1, Node arg) {
PrimitiveType n2 = (PrimitiveType) arg;
if (n1.getType() != n2.getType()) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) {
return Boolean.FALSE;
}
return Boolean.TRUE;
}
示例6: visit
import org.walkmod.javalang.ast.type.PrimitiveType; //导入依赖的package包/类
@Override
public Node visit(PrimitiveType _n, Object _arg) {
List<AnnotationExpr> ann = visit(_n.getAnnotations(), _arg);
PrimitiveType r = new PrimitiveType(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(),
_n.getType(), ann);
return r;
}
示例7: visit
import org.walkmod.javalang.ast.type.PrimitiveType; //导入依赖的package包/类
public void visit(PrimitiveType n, Object arg) {
prepareComments(n);
printPreviousComments(n, arg);
if (n.getAnnotations() != null) {
for (AnnotationExpr ae : n.getAnnotations()) {
ae.accept(this, arg);
printer.print(" ");
}
}
switch (n.getType()) {
case Boolean:
printer.print("boolean");
break;
case Byte:
printer.print("byte");
break;
case Char:
printer.print("char");
break;
case Double:
printer.print("double");
break;
case Float:
printer.print("float");
break;
case Int:
printer.print("int");
break;
case Long:
printer.print("long");
break;
case Short:
printer.print("short");
break;
}
}
示例8: visit
import org.walkmod.javalang.ast.type.PrimitiveType; //导入依赖的package包/类
public void visit(PrimitiveType n, A arg) {
if (n.getAnnotations() != null) {
for (AnnotationExpr ae : n.getAnnotations()) {
ae.accept(this, arg);
}
}
}
示例9: visit
import org.walkmod.javalang.ast.type.PrimitiveType; //导入依赖的package包/类
public void visit(PrimitiveType n, VisitorContext arg) {
if (preVisitor != null) {
preVisitor.visit(n, arg);
}
if (postVisitor != null) {
postVisitor.visit(n, arg);
}
}
示例10: visit
import org.walkmod.javalang.ast.type.PrimitiveType; //导入依赖的package包/类
public Node visit(PrimitiveType n, A arg) {
final List<AnnotationExpr> annotations = n.getAnnotations();
if (annotations != null) {
for (int i = 0; i < annotations.size(); i++) {
annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg));
}
removeNulls(annotations);
}
return n;
}
示例11: Type
import org.walkmod.javalang.ast.type.PrimitiveType; //导入依赖的package包/类
final public Type Type() throws ParseException {
Type ret;
if (jj_2_11(2)) {
ret = ReferenceType();
} else {
switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
case BOOLEAN:
case BYTE:
case CHAR:
case DOUBLE:
case FLOAT:
case INT:
case LONG:
case SHORT:
ret = PrimitiveType();
break;
default:
jj_la1[59] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
{
if (true)
return ret;
}
throw new Error("Missing return statement in function");
}
示例12: testAddParam
import org.walkmod.javalang.ast.type.PrimitiveType; //导入依赖的package包/类
@Test
public void testAddParam() throws Exception {
CompilationUnit cu = ASTManager.parse("public class A { public void foo(int x){}}");
MethodDeclaration md = (MethodDeclaration) cu.getTypes().get(0).getMembers().get(0);
md.getParameters().add(new Parameter(new PrimitiveType(Primitive.Int), new VariableDeclaratorId("y")));
String s = md.toString();
Assert.assertTrue(s.indexOf('\n') == -1);
}
示例13: visit
import org.walkmod.javalang.ast.type.PrimitiveType; //导入依赖的package包/类
public void visit(PrimitiveType n, VisitorContext ctx) {
Object o = ctx.get(NODE_TO_COMPARE_KEY);
if (o != null && o instanceof PrimitiveType) {
boolean backup = isUpdated();
setIsUpdated(false);
PrimitiveType aux = (PrimitiveType) o;
boolean equals = n.getType().equals(aux.getType());
if (!equals) {
applyUpdate(n, (Node) o);
}
Position pos = popPosition();
pushPosition(aux);
inferASTChanges(n.getAnnotations(), aux.getAnnotations());
popPosition();
pushPosition(pos);
if (equals) {
increaseUnmodifiedNodes(PrimitiveType.class);
} else {
increaseUpdatedNodes(PrimitiveType.class);
}
setIsUpdated(backup || isUpdated());
} else if (o != null) {
setIsUpdated(true);
applyUpdate(n, (Node) o);
}
}
示例14: visit
import org.walkmod.javalang.ast.type.PrimitiveType; //导入依赖的package包/类
@Override
public void visit(PrimitiveType n, A arg) {
n.accept(expressionTypeAnalyzer, arg);
}
示例15: ReferenceType
import org.walkmod.javalang.ast.type.PrimitiveType; //导入依赖的package包/类
final public ReferenceType ReferenceType() throws ParseException {
Type type;
int arrayCount = 0;
List annotations = null;
List accum = null;
AnnotationExpr ann;
switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
case BOOLEAN:
case BYTE:
case CHAR:
case DOUBLE:
case FLOAT:
case INT:
case LONG:
case SHORT:
type = PrimitiveType();
label_27: while (true) {
label_28: while (true) {
switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
case AT:;
break;
default:
jj_la1[60] = jj_gen;
break label_28;
}
ann = Annotation();
annotations = add(annotations, ann);
}
jj_consume_token(LBRACKET);
jj_consume_token(RBRACKET);
arrayCount++;
accum = add(accum, annotations);
annotations = null;
if (jj_2_12(2)) {
;
} else {
break label_27;
}
}
break;
case IDENTIFIER:
type = ClassOrInterfaceType();
label_29: while (true) {
if (jj_2_13(2)) {
;
} else {
break label_29;
}
label_30: while (true) {
switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
case AT:;
break;
default:
jj_la1[61] = jj_gen;
break label_30;
}
ann = Annotation();
annotations = add(annotations, ann);
}
jj_consume_token(LBRACKET);
jj_consume_token(RBRACKET);
arrayCount++;
accum = add(accum, annotations);
annotations = null;
}
break;
default:
jj_la1[62] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{
if (true)
return new ReferenceType(type.getBeginLine(), type.getBeginColumn(), token.endLine, token.endColumn,
type, arrayCount, null, accum);
}
throw new Error("Missing return statement in function");
}