本文整理汇总了Java中japa.parser.ast.body.MethodDeclaration.getParameters方法的典型用法代码示例。如果您正苦于以下问题:Java MethodDeclaration.getParameters方法的具体用法?Java MethodDeclaration.getParameters怎么用?Java MethodDeclaration.getParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类japa.parser.ast.body.MethodDeclaration
的用法示例。
在下文中一共展示了MethodDeclaration.getParameters方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: methodDeclMatches
import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
private static boolean methodDeclMatches(MethodDeclaration methodDecl, Method method) {
if (!method.getName().equals(methodDecl.getName())) {
return false;
}
if (!typeMatches(getRawTypeName(methodDecl.getType()), method.getReturnType())) {
return false;
}
List<Parameter> declParams = methodDecl.getParameters();
Class<?>[] methodParams = method.getParameterTypes();
if (declParams.size() != methodParams.length) {
return false;
}
for (int i = 0; i < declParams.size(); i++) {
if (!typeMatches(getRawTypeName(declParams.get(i).getType()), methodParams[i])) {
return false;
}
}
return true;
}
示例2: isGetterMethod
import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
private boolean isGetterMethod(MethodDeclaration method)
{
if ((method.getBody() != null) && (method.getBody().getStmts() != null))
{
LinkedList<String> attNames = getAttributesNames();
if (attNames.size() == 0)
return false;
List<Statement> stmts = method.getBody().getStmts();
for (Statement stmt : stmts)
for (String name : attNames)
if ((stmt.toString().matches("(.*)return(\\s+)" + name + "(\\s*);")) && (method.getModifiers() == ModifierSet.PUBLIC) && (method.getParameters() == null))
return true;
}
return false;
}
示例3: isSetterMethod
import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
private boolean isSetterMethod(MethodDeclaration method)
{
if ((method.getBody() != null) && (method.getBody().getStmts() != null))
{
LinkedList<String> attNames = getAttributesNames();
if (attNames.size() == 0)
return false;
List<Statement> stmts = method.getBody().getStmts();
for (Statement stmt : stmts)
for (String name : attNames)
if ((method.getModifiers() == ModifierSet.PUBLIC) && (method.getParameters() != null) && (method.getParameters().size() == 1) && (method.getType().equals(new VoidType())) && (stmt.toString().matches("(.*)"+name+"(\\s*)=(.*)"+method.getParameters().get(0).getId().getName()+"(.*);")))
return true;
}
return false;
}
示例4: createMethod
import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
private JavaMethod createMethod (MethodDeclaration method) {
String className = classStack.peek().getName();
String name = method.getName();
boolean isStatic = ModifierSet.hasModifier(method.getModifiers(), ModifierSet.STATIC);
String returnType = method.getType().toString();
ArrayList<Argument> arguments = new ArrayList<Argument>();
if (method.getParameters() != null) {
for (Parameter parameter : method.getParameters()) {
arguments.add(new Argument(getArgumentType(parameter), parameter.getId().getName()));
}
}
return new JavaMethod(className, name, isStatic, returnType, null, arguments, method.getBeginLine(), method.getEndLine());
}
示例5: extractParametersName
import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
private ArrayList<String> extractParametersName(MethodDeclaration methodDeclaration) {
ArrayList<String> parametersName = new ArrayList<String>();
if (methodDeclaration.getParameters() != null) {
for (Parameter parameter : methodDeclaration.getParameters()) {
parametersName.add(parameter.getId().getName());
}
}
return parametersName;
}
示例6: computeMethodName
import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
/**
* Compute the mangled method name, containing type information.
*/
public static String computeMethodName(MethodDeclaration meth) {
StringBuffer sb = new StringBuffer();
sb.append(meth.getName()).append("(");
if (meth.getParameters() != null) {
for (int i = 0; i < meth.getParameters().size(); ++i) {
sb.append(meth.getParameters().get(i).getType());
if (i < meth.getParameters().size() - 1) {
sb.append(", ");
}
}
}
sb.append(")");
return sb.toString();
}
示例7: visit
import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
public R visit(MethodDeclaration n, A arg) {
if (n.getJavaDoc() != null) {
n.getJavaDoc().accept(this, arg);
}
if (n.getAnnotations() != null) {
for (AnnotationExpr a : n.getAnnotations()) {
a.accept(this, arg);
}
}
if (n.getTypeParameters() != null) {
for (TypeParameter t : n.getTypeParameters()) {
t.accept(this, arg);
}
}
n.getType().accept(this, arg);
if (n.getParameters() != null) {
for (Parameter p : n.getParameters()) {
p.accept(this, arg);
}
}
if (n.getThrows() != null) {
for (NameExpr name : n.getThrows()) {
name.accept(this, arg);
}
}
if (n.getBody() != null) {
n.getBody().accept(this, arg);
}
return null;
}
示例8: visit
import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
public void visit(MethodDeclaration n, A arg) {
if (n.getJavaDoc() != null) {
n.getJavaDoc().accept(this, arg);
}
if (n.getAnnotations() != null) {
for (AnnotationExpr a : n.getAnnotations()) {
a.accept(this, arg);
}
}
if (n.getTypeParameters() != null) {
for (TypeParameter t : n.getTypeParameters()) {
t.accept(this, arg);
}
}
n.getType().accept(this, arg);
if (n.getParameters() != null) {
for (Parameter p : n.getParameters()) {
p.accept(this, arg);
}
}
if (n.getThrows() != null) {
for (NameExpr name : n.getThrows()) {
name.accept(this, arg);
}
}
if (n.getBody() != null) {
n.getBody().accept(this, arg);
}
}
示例9: visit
import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
public Node visit(MethodDeclaration n, A arg) {
if (n.getJavaDoc() != null) {
n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg));
}
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);
}
List<TypeParameter> typeParameters = n.getTypeParameters();
if (typeParameters != null) {
for (int i = 0; i < typeParameters.size(); i++) {
typeParameters.set(i, (TypeParameter) typeParameters.get(i).accept(this, arg));
}
removeNulls(typeParameters);
}
n.setType((Type) n.getType().accept(this, arg));
List<Parameter> parameters = n.getParameters();
if (parameters != null) {
for (int i = 0; i < parameters.size(); i++) {
parameters.set(i, (Parameter) parameters.get(i).accept(this, arg));
}
removeNulls(parameters);
}
List<NameExpr> throwz = n.getThrows();
if (throwz != null) {
for (int i = 0; i < throwz.size(); i++) {
throwz.set(i, (NameExpr) throwz.get(i).accept(this, arg));
}
removeNulls(throwz);
}
if (n.getBody() != null) {
n.setBody((BlockStmt) n.getBody().accept(this, arg));
}
return n;
}
示例10: isSetRootComponentMethod
import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
private static boolean isSetRootComponentMethod(MethodDeclaration method) {
return "setRootComponent".equals(method.getName())
&& method.getParameters()!=null
&& method.getParameters().size() == 1
&& isSetRootComponentMethodParameter(method.getParameters().get(0))
&& hasAnnotation(method, "AutoGenerated");
}
示例11: visit
import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
@Override
public void visit(MethodDeclaration n, Object arg)
{ String prevMethod = currentMethod;
currentMethod = n.getName();
indentLevel++;
if(n.getJavaDoc() != null)
{ n.getJavaDoc().accept(this, arg);
}
if(n.getAnnotations() != null)
{ for(AnnotationExpr a : n.getAnnotations())
{ a.accept(this, arg);
}
}
if(n.getTypeParameters() != null)
{ for(TypeParameter t : n.getTypeParameters())
{ t.accept(this, arg);
}
}
n.getType().accept(this, arg);
if(n.getParameters() != null)
{ for (Parameter p : n.getParameters())
{ p.accept(this, arg);
}
}
if(n.getThrows() != null)
{ for(NameExpr name : n.getThrows())
{ name.accept(this, arg);
}
}
if(n.getBody() != null)
{ BlockStmt block = n.getBody();
for(int i=0;i<indentLevel;i++)
System.out.print("..");
System.out.println("Analyse de la méthode "+currentMethod);
checkBlock(block);
block.accept(this, arg);
}
currentMethod = prevMethod;
indentLevel--;
}
示例12: visit
import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
@Override
public void visit(MethodDeclaration n, Object arg)
{ String prevMethod = currentMethod;
currentMethod = n.getName();
indentLevel++;
if(n.getJavaDoc() != null)
{ n.getJavaDoc().accept(this, arg);
}
if(n.getAnnotations() != null)
{ for(AnnotationExpr a : n.getAnnotations())
{ a.accept(this, arg);
}
}
if(n.getTypeParameters() != null)
{ for(TypeParameter t : n.getTypeParameters())
{ t.accept(this, arg);
}
}
n.getType().accept(this, arg);
if(n.getParameters() != null)
{ for (Parameter p : n.getParameters())
{ p.accept(this, arg);
}
}
if(n.getThrows() != null)
{ for(NameExpr name : n.getThrows())
{ name.accept(this, arg);
}
}
if(n.getBody() != null)
{ BlockStmt block = n.getBody();
//if(name.equals("getZoneArray"))
// System.out.println();
for(int i=0;i<indentLevel;i++)
System.out.print("..");
System.out.println("Analyse de la méthode "+currentMethod);
checkBlock(block);
block.accept(this, arg);
}
currentMethod = prevMethod;
indentLevel--;
}
示例13: visit
import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
@Override
public void visit(MethodDeclaration n, Object arg)
{ String prevMethod = currentMethod;
currentMethod = n.getName();
indentLevel++;
if(n.getJavaDoc() != null)
{ n.getJavaDoc().accept(this, arg);
}
if(n.getAnnotations() != null)
{ for(AnnotationExpr a : n.getAnnotations())
{ a.accept(this, arg);
}
}
if(n.getTypeParameters() != null)
{ for(TypeParameter t : n.getTypeParameters())
{ t.accept(this, arg);
}
}
n.getType().accept(this, arg);
if(n.getParameters() != null)
{ for (Parameter p : n.getParameters())
{ p.accept(this, arg);
}
}
if(n.getThrows() != null)
{ for(NameExpr name : n.getThrows())
{ name.accept(this, arg);
}
}
if(n.getBody() != null)
{ BlockStmt block = n.getBody();
for(int i=0;i<indentLevel;i++)
System.out.print("..");
System.out.println("Analyse de la méthode "+currentMethod);
checkBlock(block);
block.accept(this, arg);
}
currentMethod = prevMethod;
indentLevel--;
}
示例14: visit
import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
@Override
public MethodDeclaration visit(MethodDeclaration n, Void arg) {
if (!n.isGenerator()) {
throw new UnsupportedOperationException("cannot transform non-generator");
}
// Desugar ALL the loops!
n.accept(new LoopDesugarTransform(), null);
if (CompilerSettings.dumpDesugar) {
System.err.println(n);
}
Generator g = new Generator();
Map<String, TypedVariableDeclarator> vars = new HashMap<String, TypedVariableDeclarator>();
// Mangle all our scope variables.
n.accept(new ScopeMangleTransform(), vars);
if (CompilerSettings.dumpMangle) {
System.err.println(n);
}
// Generate the body.
n.accept(new LinearizeTransform(), g);
List<BodyDeclaration> generatorBody = new ArrayList<BodyDeclaration>();
// Add the fields to the generator body.
for (Map.Entry<String, TypedVariableDeclarator> kv : vars.entrySet()) {
VariableDeclarator decl = new VariableDeclarator(new VariableDeclaratorId(kv.getKey()), null);
generatorBody.add(new FieldDeclaration(ModifierSet.PRIVATE, kv.getValue().type, decl));
}
// Add the moveNext method to the generator body.
generatorBody.add(new MethodDeclaration(0, 0, 0, 0, null, ModifierSet.PROTECTED,
null, null, new PrimitiveType(Primitive.Boolean),
"moveNext", null, 0, null, false,
new BlockStmt(g.generate())));
ObjectCreationExpr o = new ObjectCreationExpr(0, 0, 0, 0, null, makeRtGeneratorType(n.getType()), null, null, generatorBody);
List<Statement> methodBody = new ArrayList<Statement>();
methodBody.add(new ReturnStmt(o));
MethodDeclaration n2 = new MethodDeclaration(n.getBeginLine(),
n.getBeginColumn(),
n.getEndLine(),
n.getEndColumn(),
n.getJavaDoc(),
n.getModifiers(),
n.getAnnotations(),
n.getTypeParameters(),
makeRtGeneratorType(n.getType()),
n.getName(),
n.getParameters(),
n.getArrayCount(),
n.getThrows(),
false,
new BlockStmt(methodBody));
return n2;
}
示例15: visit
import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
public void visit(MethodDeclaration n, Object arg) {
printJavadoc(n.getJavaDoc(), arg);
printMemberAnnotations(n.getAnnotations(), arg);
printModifiers(n.getModifiers());
printTypeParameters(n.getTypeParameters(), arg);
if (n.getTypeParameters() != null) {
printer.print(" ");
}
n.getType().accept(this, arg);
if (n.isGenerator()) {
printer.print("*");
}
printer.print(" ");
printer.print(n.getName());
printer.print("(");
if (n.getParameters() != null) {
for (Iterator<Parameter> i = n.getParameters().iterator(); i.hasNext();) {
Parameter p = i.next();
p.accept(this, arg);
if (i.hasNext()) {
printer.print(", ");
}
}
}
printer.print(")");
for (int i = 0; i < n.getArrayCount(); i++) {
printer.print("[]");
}
if (n.getThrows() != null) {
printer.print(" throws ");
for (Iterator<NameExpr> i = n.getThrows().iterator(); i.hasNext();) {
NameExpr name = i.next();
name.accept(this, arg);
if (i.hasNext()) {
printer.print(", ");
}
}
}
if (n.getBody() == null) {
printer.print(";");
} else {
printer.print(" ");
n.getBody().accept(this, arg);
}
}