当前位置: 首页>>代码示例>>Java>>正文


Java ConstructorDeclaration类代码示例

本文整理汇总了Java中japa.parser.ast.body.ConstructorDeclaration的典型用法代码示例。如果您正苦于以下问题:Java ConstructorDeclaration类的具体用法?Java ConstructorDeclaration怎么用?Java ConstructorDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ConstructorDeclaration类属于japa.parser.ast.body包,在下文中一共展示了ConstructorDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNode

import japa.parser.ast.body.ConstructorDeclaration; //导入依赖的package包/类
public static Node getNode(TypeDeclaration typeDecl, String name) {
	if (typeDecl.getMembers() == null) {
		return null;
	}
	for (BodyDeclaration bodyDecl : typeDecl.getMembers()) {
		String bodyDeclName = getName(bodyDecl);
		if (bodyDeclName != null && name.startsWith(bodyDeclName)) {
			if (name.length() == bodyDeclName.length()) {
				return bodyDecl;
			}
			else if (bodyDecl instanceof MethodDeclaration || bodyDecl instanceof ConstructorDeclaration) {
				if (signatureMatches(bodyDecl, name.substring(bodyDeclName.length()))) {
					return bodyDecl;
				}
			}
			else if (bodyDecl instanceof TypeDeclaration) {
				return getNode((TypeDeclaration) bodyDecl, name.substring(bodyDeclName.length() + 1));
			}
		}
	}
	return null;
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:23,代码来源:JavaParserUtils.java

示例2: constructorDeclMatches

import japa.parser.ast.body.ConstructorDeclaration; //导入依赖的package包/类
private static boolean constructorDeclMatches(ConstructorDeclaration constructorDecl, Constructor<?> constructor) {
	if (!constructor.getName().equals(constructorDecl.getName())) {
		return false;
	}

	List<Parameter> declParams = constructorDecl.getParameters();
	Class<?>[] constructorParams = constructor.getParameterTypes();

	if (declParams.size() != constructorParams.length) {
		return false;
	}

	for (int i = 0; i < declParams.size(); i++) {
		if (!typeMatches(getRawTypeName(declParams.get(i).getType()), constructorParams[i])) {
			return false;
		}
	}

	return true;
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:21,代码来源:JavaParserUtils.java

示例3: visit

import japa.parser.ast.body.ConstructorDeclaration; //导入依赖的package包/类
public void visit(ConstructorDeclaration 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);
        }
    }
    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);
        }
    }
    n.getBlock().accept(this, arg);
}
 
开发者ID:rfw,项目名称:genja,代码行数:27,代码来源:VoidVisitorAdapter.java

示例4: getInstance

import japa.parser.ast.body.ConstructorDeclaration; //导入依赖的package包/类
public static JavaParserConstructorMetadataBuilder getInstance(
        final String declaredByMetadataId,
        final ConstructorDeclaration constructorDeclaration,
        final CompilationUnitServices compilationUnitServices,
        final Set<JavaSymbolName> typeParameterNames) {
    return new JavaParserConstructorMetadataBuilder(declaredByMetadataId,
            constructorDeclaration, compilationUnitServices,
            typeParameterNames);
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:10,代码来源:JavaParserConstructorMetadataBuilder.java

示例5: visit

import japa.parser.ast.body.ConstructorDeclaration; //导入依赖的package包/类
@Override
  public void visit(ConstructorDeclaration 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);
          }
      }
      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);
          }
      }
      BlockStmt block = n.getBlock();
      for(int i=0;i<indentLevel;i++)
	System.out.print("..");
System.out.println("Analyse du constructeur "+currentMethod);
  	if(checkConstructor)
  		checkBlock(block);
      block.accept(this, arg);
      
      currentMethod = prevMethod;
  	indentLevel--;
 }
 
开发者ID:vlabatut,项目名称:totalboumboum,代码行数:41,代码来源:AiVisitor.java

示例6: getDeclaration

import japa.parser.ast.body.ConstructorDeclaration; //导入依赖的package包/类
public static ConstructorDeclaration getDeclaration(CompilationUnit unit, Constructor<?> constructor) {
	TypeDeclaration typeDecl = getDeclaration(unit, constructor.getDeclaringClass());
	if (typeDecl == null) {
		return null;
	}
	for (BodyDeclaration decl : typeDecl.getMembers()) {
		if (decl instanceof ConstructorDeclaration) {
			ConstructorDeclaration constructorDecl = (ConstructorDeclaration) decl;
			if (constructorDeclMatches(constructorDecl, constructor)) {
				return constructorDecl;
			}
		}
	}
	return null;
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:16,代码来源:JavaParserUtils.java

示例7: signatureMatches

import japa.parser.ast.body.ConstructorDeclaration; //导入依赖的package包/类
private static boolean signatureMatches(BodyDeclaration decl, String signature) {
	if (!parameterListPattern.matcher(signature).matches()) {
		return false;
	}
	Matcher m = parameterPattern.matcher(signature);

	List<Parameter> parameters = null;

	if (decl instanceof ConstructorDeclaration) {
		parameters = ((ConstructorDeclaration) decl).getParameters();
	} else if (decl instanceof MethodDeclaration) {
		parameters = ((MethodDeclaration) decl).getParameters();
	} else {
		throw new IllegalArgumentException("decl must be a ConstructorDeclaration or a MethodDeclaration");
	}

	if (parameters == null)
	{
		parameters = Collections.emptyList();
	}

	int i = 0;
	while (m.find()) {
		if (i >= parameters.size()) {
			return false;
		}
		Parameter parameter = parameters.get(i);
		String typeName = getRawTypeName(parameter.getType());
		if (!m.group().endsWith(typeName)) {
			return false;
		}
		i++;
	}

	return i == parameters.size();
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:37,代码来源:JavaParserUtils.java

示例8: getName

import japa.parser.ast.body.ConstructorDeclaration; //导入依赖的package包/类
private static String getName(BodyDeclaration decl) {
	if (decl instanceof AnnotationMemberDeclaration) {
		return ((AnnotationMemberDeclaration) decl).getName();
	}
	if (decl instanceof ConstructorDeclaration) {
		return ((ConstructorDeclaration) decl).getName();
	}
	if (decl instanceof EnumConstantDeclaration) {
		return ((EnumConstantDeclaration) decl).getName();
	}
	if (decl instanceof FieldDeclaration) {
		List<VariableDeclarator> variables = ((FieldDeclaration) decl).getVariables();
		if (variables.size() == 1) {
			return variables.get(0).getId().getName();
		} else {
			return null;
		}
	}
	if (decl instanceof MethodDeclaration) {
		return ((MethodDeclaration) decl).getName();
	}
	if (decl instanceof AnnotationDeclaration) {
		return ((AnnotationDeclaration) decl).getName();
	}
	if (decl instanceof ClassOrInterfaceDeclaration) {
		return ((ClassOrInterfaceDeclaration) decl).getName();
	}
	if (decl instanceof EnumDeclaration) {
		return ((EnumDeclaration) decl).getName();
	}
	return null;
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:33,代码来源:JavaParserUtils.java

示例9: visit

import japa.parser.ast.body.ConstructorDeclaration; //导入依赖的package包/类
public R visit(ConstructorDeclaration 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);
        }
    }
    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);
        }
    }
    n.getBlock().accept(this, arg);
    return null;
}
 
开发者ID:rfw,项目名称:genja,代码行数:28,代码来源:GenericVisitorAdapter.java

示例10: visit

import japa.parser.ast.body.ConstructorDeclaration; //导入依赖的package包/类
public Boolean visit(ConstructorDeclaration n1, Node arg) {
    ConstructorDeclaration n2 = (ConstructorDeclaration) arg;

    // javadoc are checked at CompilationUnit

    if (n1.getModifiers() != n2.getModifiers()) {
        return Boolean.FALSE;
    }

    if (!objEquals(n1.getName(), n2.getName())) {
        return Boolean.FALSE;
    }

    if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) {
        return Boolean.FALSE;
    }

    if (!nodeEquals(n1.getBlock(), n2.getBlock())) {
        return Boolean.FALSE;
    }

    if (!nodesEquals(n1.getParameters(), n2.getParameters())) {
        return Boolean.FALSE;
    }

    if (!nodesEquals(n1.getThrows(), n2.getThrows())) {
        return Boolean.FALSE;
    }

    if (!nodesEquals(n1.getTypeParameters(), n2.getTypeParameters())) {
        return Boolean.FALSE;
    }

    return Boolean.TRUE;
}
 
开发者ID:rfw,项目名称:genja,代码行数:36,代码来源:EqualsVisitor.java

示例11: visit

import japa.parser.ast.body.ConstructorDeclaration; //导入依赖的package包/类
public void visit(ConstructorDeclaration n, Object arg) {
    printJavadoc(n.getJavaDoc(), arg);
    printMemberAnnotations(n.getAnnotations(), arg);
    printModifiers(n.getModifiers());

    printTypeParameters(n.getTypeParameters(), arg);
    if (n.getTypeParameters() != null) {
        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(")");

    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(", ");
            }
        }
    }
    printer.print(" ");
    n.getBlock().accept(this, arg);
}
 
开发者ID:rfw,项目名称:genja,代码行数:37,代码来源:DumpVisitor.java

示例12: visit

import japa.parser.ast.body.ConstructorDeclaration; //导入依赖的package包/类
public Node visit(ConstructorDeclaration 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);
    }
    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);
    }
    n.setBlock((BlockStmt) n.getBlock().accept(this, arg));
    return n;
}
 
开发者ID:rfw,项目名称:genja,代码行数:36,代码来源:ModifierVisitorAdapter.java

示例13: visit

import japa.parser.ast.body.ConstructorDeclaration; //导入依赖的package包/类
@Override
    public void visit(ConstructorDeclaration n, Object arg)
    {	String prevMethod = currentMethod;
    	currentMethod = n.getName();
    	indentLevel++;
if(currentMethod.equals("PathFinder"))
	System.out.println();
    	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);
            }
        }
        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);
            }
        }
        BlockStmt block = n.getBlock();
        for(int i=0;i<indentLevel;i++)
			System.out.print("..");
		System.out.println("Analyse du constructeur "+currentMethod);
    	if(checkConstructor)
    		checkBlock(block);
        block.accept(this, arg);
        
        currentMethod = prevMethod;
    	indentLevel--;
   }
 
开发者ID:vlabatut,项目名称:totalboumboum,代码行数:42,代码来源:AiVisitor.java

示例14: visit

import japa.parser.ast.body.ConstructorDeclaration; //导入依赖的package包/类
@Override
public void visit(ConstructorDeclaration n, Generator arg) {
    throw new TransformException("don't know how to linearize");
}
 
开发者ID:rfw,项目名称:genja,代码行数:5,代码来源:LinearizeTransform.java

示例15: visit

import japa.parser.ast.body.ConstructorDeclaration; //导入依赖的package包/类
@Override
public Boolean visit(ConstructorDeclaration n, Void arg) {
    return false;
}
 
开发者ID:rfw,项目名称:genja,代码行数:5,代码来源:NodeAnnotator.java


注:本文中的japa.parser.ast.body.ConstructorDeclaration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。