本文整理汇总了Java中japa.parser.ast.expr.MethodCallExpr类的典型用法代码示例。如果您正苦于以下问题:Java MethodCallExpr类的具体用法?Java MethodCallExpr怎么用?Java MethodCallExpr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MethodCallExpr类属于japa.parser.ast.expr包,在下文中一共展示了MethodCallExpr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import japa.parser.ast.expr.MethodCallExpr; //导入依赖的package包/类
public R visit(MethodCallExpr n, A arg) {
if (n.getScope() != null) {
n.getScope().accept(this, arg);
}
if (n.getTypeArgs() != null) {
for (Type t : n.getTypeArgs()) {
t.accept(this, arg);
}
}
if (n.getArgs() != null) {
for (Expression e : n.getArgs()) {
e.accept(this, arg);
}
}
return null;
}
示例2: visit
import japa.parser.ast.expr.MethodCallExpr; //导入依赖的package包/类
public Boolean visit(MethodCallExpr n1, Node arg) {
MethodCallExpr n2 = (MethodCallExpr) arg;
if (!nodeEquals(n1.getScope(), n2.getScope())) {
return Boolean.FALSE;
}
if (!objEquals(n1.getName(), n2.getName())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getArgs(), n2.getArgs())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getTypeArgs(), n2.getTypeArgs())) {
return Boolean.FALSE;
}
return Boolean.TRUE;
}
示例3: visit
import japa.parser.ast.expr.MethodCallExpr; //导入依赖的package包/类
public Node visit(MethodCallExpr n, A arg) {
if (n.getScope() != null) {
n.setScope((Expression) n.getScope().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;
}
示例4: addAttachSkeleton
import japa.parser.ast.expr.MethodCallExpr; //导入依赖的package包/类
private void addAttachSkeleton() {
List<Parameter> params = Collections.emptyList();
MethodDeclaration method = new MethodDeclaration(
ModifierSet.PUBLIC, new VoidType(), "attach", params);
AnnotationExpr override = new MarkerAnnotationExpr(new NameExpr("Override"));
method.setAnnotations(Collections.singletonList(override));
BlockStmt block = new BlockStmt();
Expression e = new MethodCallExpr(new SuperExpr(), "attach");
List<Statement> sts = Collections.singletonList((Statement)new ExpressionStmt(e));
block.setStmts(sts);
method.setBody(block);
if (getType().getMembers()==null) {
getType().setMembers(new LinkedList<BodyDeclaration>());
}
getType().getMembers().add(method);
}
示例5: addOnBecomingVisibleMethod
import japa.parser.ast.expr.MethodCallExpr; //导入依赖的package包/类
@SuppressWarnings("unused")
private void addOnBecomingVisibleMethod() {
List<Parameter> params = Collections.emptyList();
MethodDeclaration method = new MethodDeclaration(
ModifierSet.PUBLIC, new VoidType(), "onBecomingVisible", params);
AnnotationExpr override = new MarkerAnnotationExpr(new NameExpr("Override"));
method.setAnnotations(Collections.singletonList(override));
BlockStmt block = new BlockStmt();
Expression e = new MethodCallExpr(new SuperExpr(), "onBecomingVisible");
List<Statement> sts = Collections.singletonList((Statement)new ExpressionStmt(e));
block.setStmts(sts);
method.setBody(block);
if (getType().getMembers()==null) {
getType().setMembers(new LinkedList<BodyDeclaration>());
}
getType().getMembers().add(method);
}
示例6: visit
import japa.parser.ast.expr.MethodCallExpr; //导入依赖的package包/类
@Override
public void visit(MethodCallExpr n, Object arg)
{ String name = n.getName();
String calledMethod = n.getScope()+ClassTools.CLASS_SEPARATOR+name;
if(FORBIDDEN_METHODS.contains(calledMethod) || FORBIDDEN_METHODS.contains(name))
{ int line = n.getBeginLine();
printErr("Erreur ligne "+line+" : il est interdit d'utiliser la méthode "+calledMethod+" ; à la place vous devez utiliser la méthode print de votre agent (héritant de ArtificialIntelligence) ou d'un gestionnaire (héritant de AiAbstractHandler)");
errorCount++;
}
}
示例7: buildUnit
import japa.parser.ast.expr.MethodCallExpr; //导入依赖的package包/类
public static void buildUnit() {
CompilationUnit compUnit = new CompilationUnit();
compUnit.setPackage(new PackageDeclaration(ASTHelper
.createNameExpr("compiladores.aula")));
// create the type declaration
ClassOrInterfaceDeclaration type = new ClassOrInterfaceDeclaration(
ModifierSet.PUBLIC, false, "AulaJavaParser");
ASTHelper.addTypeDeclaration(compUnit, type);
// create a method
MethodDeclaration method = new MethodDeclaration(ModifierSet.PUBLIC,
ASTHelper.VOID_TYPE, "main");
method.setModifiers(ModifierSet.addModifier(method.getModifiers(),
ModifierSet.STATIC));
ASTHelper.addMember(type, method);
// add a parameter to the method
Parameter param = ASTHelper.createParameter(
ASTHelper.createReferenceType("String", 0), "args");
param.setVarArgs(true); //makes the parameter a ",,," array
ASTHelper.addParameter(method, param);
// add a body to the method
BlockStmt block = new BlockStmt();
method.setBody(block);
// add a statement do the method body
NameExpr clazz = new NameExpr("System");
FieldAccessExpr field = new FieldAccessExpr(clazz, "out");
MethodCallExpr call = new MethodCallExpr(field, "println");
ASTHelper.addArgument(call, new StringLiteralExpr("Hello World!"));
ASTHelper.addStmt(block, call);
System.out.println(compUnit.toString());
}
示例8: visit
import japa.parser.ast.expr.MethodCallExpr; //导入依赖的package包/类
@Override
public String visit(MethodCallExpr n, Void arg) {
Scope scope = (Scope) n.getData();
Scope.Type context = scope.findFirstNonBlockScope().type;
Scope lhsScope;
if (n.getScope() != null) {
String lhsType = n.getScope().accept(this, arg);
lhsScope = scope.findType(lhsType);
} else {
lhsScope = scope;
}
StringBuilder sb = new StringBuilder();
sb.append(n.getName()).append("(");
if (n.getArgs() != null) {
for (int i = 0; i < n.getArgs().size(); ++i) {
sb.append(n.getArgs().get(i).accept(this, arg));
if (i < n.getArgs().size() - 1) {
sb.append(", ");
}
}
}
sb.append(")");
String name = sb.toString();
switch (context) {
case STATIC:
case INSTANCE:
Scope enclosing = lhsScope.findEnclosingScopeForMethod(name, Scope.Type.CLASS);
if (enclosing == null) {
throw new SemanticException("method " + name + " not present in type on line " + n.getBeginLine());
}
return lhsScope.methods.get(name);
default:
throw new SemanticException("what?? on line " + n.getBeginLine());
} }
示例9: visit
import japa.parser.ast.expr.MethodCallExpr; //导入依赖的package包/类
public void visit(MethodCallExpr n, Object arg) {
if (n.getScope() != null) {
n.getScope().accept(this, arg);
printer.print(".");
}
printTypeArgs(n.getTypeArgs(), arg);
printer.print(n.getName());
printArguments(n.getArgs(), arg);
}
示例10: visit
import japa.parser.ast.expr.MethodCallExpr; //导入依赖的package包/类
public void visit(MethodCallExpr n, A arg) {
if (n.getScope() != null) {
n.getScope().accept(this, arg);
}
if (n.getTypeArgs() != null) {
for (Type t : n.getTypeArgs()) {
t.accept(this, arg);
}
}
if (n.getArgs() != null) {
for (Expression e : n.getArgs()) {
e.accept(this, arg);
}
}
}
示例11: addNotification
import japa.parser.ast.expr.MethodCallExpr; //导入依赖的package包/类
private void addNotification(MethodDeclaration method, String text) {
MethodCallExpr e = new MethodCallExpr(new NameExpr("Notification"), "show");
e.setArgs(Collections.singletonList((Expression)new StringLiteralExpr(text)));
Statement statement = new ExpressionStmt(e);
addToMethod(method, statement);
ensureImport("com.vaadin.ui.Notification");
}
示例12: visit
import japa.parser.ast.expr.MethodCallExpr; //导入依赖的package包/类
@Override
public void visit(MethodCallExpr n, Generator arg) {
throw new TransformException("don't know how to linearize");
}
示例13: visit
import japa.parser.ast.expr.MethodCallExpr; //导入依赖的package包/类
@Override
public Boolean visit(MethodCallExpr n, Void arg) {
return false;
}
示例14: visit
import japa.parser.ast.expr.MethodCallExpr; //导入依赖的package包/类
@Override
public void visit(MethodCallExpr n, Scope arg) {
super.visit(n, arg);
n.setData(arg);
}
示例15: visit
import japa.parser.ast.expr.MethodCallExpr; //导入依赖的package包/类
@Override
public void visit(MethodCallExpr n, Object arg) {
doTest(source, n);
super.visit(n, arg);
}