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


Java Parameter类代码示例

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


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

示例1: visit

import japa.parser.ast.body.Parameter; //导入依赖的package包/类
@Override
 public void visit(CatchClause n, Object arg)
 {	int line = n.getBeginLine();
 	Parameter e = n.getExcept();
 	if(!IGNORED_METHODS.contains(currentMethod))
 	{	Type t = e.getType();
  	if(t instanceof ReferenceType)
{	Type t2 = ((ReferenceType)t).getType();
	if(t2 instanceof ClassOrInterfaceType)
	{	String exceptionName = ((ClassOrInterfaceType)t2).getName();
		if(FORBIDDEN_EXCEPTIONS.contains(exceptionName))
		{	printErr("Erreur ligne "+line+" : le catch("+exceptionName+") masque l'appel à "+CHECK_INTERRUPTION_METHOD+"()");
			errorCount++;
		}
	}
	else
	{	System.err.print(">>11111111111 problème : exception non conforme ("+t2.getClass()+")");
	}
}
  	else
{	System.err.print(">>222222222 problème : exception non conforme ("+t.getClass()+")");
  	}
 	}
 	e.accept(this, arg);
     n.getCatchBlock().accept(this, arg);
 }
 
开发者ID:vlabatut,项目名称:totalboumboum,代码行数:27,代码来源:AiVisitor.java

示例2: getArgumentType

import japa.parser.ast.body.Parameter; //导入依赖的package包/类
private ArgumentType getArgumentType (Parameter parameter) {
	String[] typeTokens = parameter.getType().toString().split("\\.");
	String type = typeTokens[typeTokens.length - 1];
	int arrayDim = 0;
	for (int i = 0; i < type.length(); i++) {
		if (type.charAt(i) == '[') arrayDim++;
	}
	type = type.replace("[", "").replace("]", "");

	if (arrayDim >= 1) {
		if (arrayDim > 1) return ArgumentType.ObjectArray;
		ArgumentType arrayType = arrayTypes.get(type);
		if (arrayType == null) {
			return ArgumentType.ObjectArray;
		}
		return arrayType;
	}

	if (plainOldDataTypes.containsKey(type)) return plainOldDataTypes.get(type);
	if (bufferTypes.containsKey(type)) return bufferTypes.get(type);
	if (type.equals("String")) return ArgumentType.String;
	return ArgumentType.Object;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:24,代码来源:RobustJavaMethodParser.java

示例3: methodDeclMatches

import japa.parser.ast.body.Parameter; //导入依赖的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;
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:25,代码来源:JavaParserUtils.java

示例4: constructorDeclMatches

import japa.parser.ast.body.Parameter; //导入依赖的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

示例5: sameTypes

import japa.parser.ast.body.Parameter; //导入依赖的package包/类
private static boolean sameTypes( List<Parameter> l1 , List<Parameter> l2 )
{
	if( l1 == null && l2 == null )
	{
		return true;
	}
	if( l1.size( ) != l2.size( ) )
	{
		return false;
	}
	for( int i = 0 ; i < l1.size( ) ; i++ )
	{
		Parameter p1 = l1.get( i );
		Parameter p2 = l2.get( i );
		if( !p1.getType( ).toString( ).equals( p2.getType( ).toString( ) ) )
		{
			return false;
		}
	}
	
	return true;
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:23,代码来源:BuilderGenerator.java

示例6: visit

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

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

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

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

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

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

示例7: visit

import japa.parser.ast.body.Parameter; //导入依赖的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

示例8: addAttachSkeleton

import japa.parser.ast.body.Parameter; //导入依赖的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);
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:19,代码来源:ControllerCode.java

示例9: addOnBecomingVisibleMethod

import japa.parser.ast.body.Parameter; //导入依赖的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);
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:20,代码来源:ControllerCode.java

示例10: addClaraHandler

import japa.parser.ast.body.Parameter; //导入依赖的package包/类
private MethodDeclaration addClaraHandler(String id, String className) {
	ensureImport(className);
	String shortName = className.substring(className.lastIndexOf(".")+1);
	String handlerName = generateHandlerNameFor(id, shortName);
	
	Parameter p = new Parameter(new ClassOrInterfaceType(shortName), new VariableDeclaratorId("event"));
	MethodDeclaration handler = new MethodDeclaration(
			ModifierSet.PUBLIC, new VoidType(), handlerName, Collections.singletonList(p));
	handler.setBody(new BlockStmt());
	handler.setAnnotations(createClaraHandlerAnnotations(id));
	
	addNotification(handler, shortName+" on "+id);		
	
	addMember(handler);
	return handler;
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:17,代码来源:ControllerCode.java

示例11: hasOneParamWithType

import japa.parser.ast.body.Parameter; //导入依赖的package包/类
private static boolean hasOneParamWithType(MethodDeclaration method, String className) {
	if (method.getParameters().size()!=1) {
		return false;
	}
	Parameter p = method.getParameters().get(0);
	// TODO: could check class matching more carefully...
	if (p.getType() instanceof ClassOrInterfaceType) {
		ClassOrInterfaceType coit = (ClassOrInterfaceType)p.getType();
		return className.endsWith("."+coit.getName());
	}
	else if (p.getType() instanceof ReferenceType) {
		ReferenceType rt = (ReferenceType)p.getType();
		return className.endsWith("."+rt.toString()); // ??
	}
	return false;
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:17,代码来源:ControllerCode.java

示例12: visit

import japa.parser.ast.body.Parameter; //导入依赖的package包/类
@Override
 public void visit(CatchClause n, Object arg)
 {	int line = n.getBeginLine();
 	Parameter e = n.getExcept();
 	if(!IGNORED_METHODS.contains(currentMethod))
 	{	Type t = e.getType();
  	if(t instanceof ReferenceType)
{	Type t2 = ((ReferenceType)t).getType();
	if(t2 instanceof ClassOrInterfaceType)
	{	String exceptionName = ((ClassOrInterfaceType)t2).getName();
		if(FORBIDDEN_EXCEPTIONS.contains(exceptionName))
		{	for(int i=0;i<indentLevel;i++)
				System.out.print(">>");
	       	System.out.println("Erreur ligne "+line+" : le catch("+exceptionName+") masque l'appel à "+CHECK_INTERRUPTION_METHOD+"()");
			errorCount++;
			// à compléter par la création d'un commentaire dans le code source
		}
	}
	else
	{	System.out.print(">>11111111111 problème : exception non conforme ("+t2.getClass()+")");
	}
}
  	else
{	System.out.print(">>222222222 problème : exception non conforme ("+t.getClass()+")");
  	}
 	}
 	e.accept(this, arg);
     n.getCatchBlock().accept(this, arg);
 }
 
开发者ID:vlabatut,项目名称:totalboumboum,代码行数:30,代码来源:AiVisitor.java

示例13: visit

import japa.parser.ast.body.Parameter; //导入依赖的package包/类
@Override
 public void visit(CatchClause n, Object arg)
 {	int line = n.getBeginLine();
 	Parameter e = n.getExcept();
 	if(!IGNORED_METHODS.contains(currentMethod))
 	{	Type t = e.getType();
  	if(t instanceof ReferenceType)
{	Type t2 = ((ReferenceType)t).getType();
	if(t2 instanceof ClassOrInterfaceType)
	{	String exceptionName = ((ClassOrInterfaceType)t2).getName();
		if(FORBIDDEN_EXCEPTIONS.contains(exceptionName))
		{	printErr("Erreur ligne "+line+" : le catch("+exceptionName+") masque l'appel à "+CHECK_INTERRUPTION_METHOD+"()");
			errorCount++;
			//
		}
	}
	else
	{	System.err.print(">>11111111111 problème : exception non conforme ("+t2.getClass()+")");
	}
}
  	else
{	System.err.print(">>222222222 problème : exception non conforme ("+t.getClass()+")");
  	}
 	}
 	e.accept(this, arg);
     n.getCatchBlock().accept(this, arg);
 }
 
开发者ID:vlabatut,项目名称:totalboumboum,代码行数:28,代码来源:AiVisitor.java

示例14: visit

import japa.parser.ast.body.Parameter; //导入依赖的package包/类
@Override
 public void visit(CatchClause n, Object arg)
 {	int line = n.getBeginLine();
 	Parameter e = n.getExcept();
 	if(!IGNORED_METHODS.contains(currentMethod))
 	{	Type t = e.getType();
  	if(t instanceof ReferenceType)
{	Type t2 = ((ReferenceType)t).getType();
	if(t2 instanceof ClassOrInterfaceType)
	{	String exceptionName = ((ClassOrInterfaceType)t2).getName();
		if(FORBIDDEN_EXCEPTIONS.contains(exceptionName))
		{	for(int i=0;i<indentLevel;i++)
				System.out.print(">>");
	       	System.out.println("Erreur ligne "+line+" : le catch("+exceptionName+") masque l'appel à "+CHECK_INTERRUPTION_METHOD+"()");
			errorCount++;
		}
	}
	else
	{	System.out.print(">>11111111111 problème : exception non conforme ("+t2.getClass()+")");
	}
}
  	else
{	System.out.print(">>222222222 problème : exception non conforme ("+t.getClass()+")");
  	}
 	}
 	e.accept(this, arg);
     n.getCatchBlock().accept(this, arg);
 }
 
开发者ID:vlabatut,项目名称:totalboumboum,代码行数:29,代码来源:AiVisitor.java

示例15: buildUnit

import japa.parser.ast.body.Parameter; //导入依赖的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());
}
 
开发者ID:damorim,项目名称:compilers-cin,代码行数:38,代码来源:ParserExample.java


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