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


Java ReferenceType类代码示例

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


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

示例1: getResolvedName

import japa.parser.ast.type.ReferenceType; //导入依赖的package包/类
public static Type getResolvedName(final JavaType target,
        final JavaType current,
        final CompilationUnitServices compilationUnit) {
    final NameExpr nameExpr = JavaParserUtils.importTypeIfRequired(target,
            compilationUnit.getImports(), current);
    final ClassOrInterfaceType resolvedName = JavaParserUtils
            .getClassOrInterfaceType(nameExpr);
    if (current.getParameters() != null
            && current.getParameters().size() > 0) {
        resolvedName.setTypeArgs(new ArrayList<Type>());
        for (final JavaType param : current.getParameters()) {
            resolvedName.getTypeArgs().add(
                    getResolvedName(target, param, compilationUnit));
        }
    }
    
    if (current.getArray() > 0) {
    	// Primitives includes array declaration in resolvedName
    	if (!current.isPrimitive()){
    		return new ReferenceType(resolvedName, current.getArray());
    	}
    }

    return resolvedName;
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:26,代码来源:JavaParserUtils.java

示例2: importParametersForType

import japa.parser.ast.type.ReferenceType; //导入依赖的package包/类
public static ReferenceType importParametersForType(
        final JavaType targetType, final List<ImportDeclaration> imports,
        final JavaType typeToImport) {
    Validate.notNull(targetType, "Target type is required");
    Validate.notNull(imports, "Compilation unit imports required");
    Validate.notNull(typeToImport, "Java type to import is required");

    final ClassOrInterfaceType cit = getClassOrInterfaceType(importTypeIfRequired(
            targetType, imports, typeToImport));
    
    // Add any type arguments presented for the return type
    if (typeToImport.getParameters().size() > 0) {
        final List<Type> typeArgs = new ArrayList<Type>();
        cit.setTypeArgs(typeArgs);
        for (final JavaType parameter : typeToImport
                .getParameters()) {
            typeArgs.add(JavaParserUtils.importParametersForType(
                    targetType,
                    imports, parameter));
        }
    }
    return  new ReferenceType(cit);
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:24,代码来源:JavaParserUtils.java

示例3: visit

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

示例4: visit

import japa.parser.ast.type.ReferenceType; //导入依赖的package包/类
@Override
public JType visit(WildcardType type, JCodeModel codeModel) {

	if (type.getExtends() != null) {
		final ReferenceType _extends = type.getExtends();
		final JType boundType = _extends.accept(this, codeModel);

		if (!(boundType instanceof JClass)) {
			throw new IllegalArgumentException("Bound type [" + _extends
					+ "]in the wildcard type must be class.");
		}

		final JClass boundClass = (JClass) boundType;
		return boundClass.wildcard();
	} else if (type.getSuper() != null) {
		// TODO
		throw new IllegalArgumentException(
				"Wildcard types with super clause are not supported at the moment.");
	} else {
		throw new IllegalArgumentException(
				"Wildcard type must have either extends or super clause.");
	}
}
 
开发者ID:highsource,项目名称:jaxb2-basics,代码行数:24,代码来源:TypeToJTypeConvertingVisitor.java

示例5: getRawTypeName

import japa.parser.ast.type.ReferenceType; //导入依赖的package包/类
private static String getRawTypeName(Type type) {
	if (type instanceof ClassOrInterfaceType) {
		return getQualifiedName((ClassOrInterfaceType) type);
	}
	if (type instanceof ReferenceType) {
		ReferenceType refType = (ReferenceType) type;
		return getRawTypeName(refType.getType()) + StringUtils.multiply("[]", refType.getArrayCount());
	}
	if (type instanceof PrimitiveType) {
		return ((PrimitiveType) type).getType().name().toLowerCase();
	}
	if (type instanceof VoidType) {
		return "void";
	}
	if (type instanceof WildcardType) {
		return "java.lang.Object";
	}
	return type.toString();
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:20,代码来源:JavaParserUtils.java

示例6: hasOneParamWithType

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

示例7: resolveType

import japa.parser.ast.type.ReferenceType; //导入依赖的package包/类
public static JClass resolveType(JClassContainer _package, String typeDefinition) {

        try {
            FieldDeclaration fieldDeclaration = (FieldDeclaration) JavaParser.parseBodyDeclaration(typeDefinition + " foo;");
            ClassOrInterfaceType c = (ClassOrInterfaceType) ((ReferenceType) fieldDeclaration.getType()).getType();

            return buildClass(_package, c, 0);
        } catch (ParseException e) {
            throw new GenerationException(e);
        }
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:TypeUtil.java

示例8: buildClass

import japa.parser.ast.type.ReferenceType; //导入依赖的package包/类
private static JClass buildClass(JClassContainer _package, ClassOrInterfaceType c, int arrayCount) {
    final String packagePrefix = (c.getScope() != null) ? c.getScope().toString() + "." : "";

    JClass _class;
    try {
        _class = _package.owner().ref(Thread.currentThread().getContextClassLoader().loadClass(packagePrefix + c.getName()));
    } catch (ClassNotFoundException e) {
        _class = _package.owner().ref(packagePrefix + c.getName());
    }

    for (int i=0; i<arrayCount; i++) {
        _class = _class.array();
    }

    List<Type> typeArgs = c.getTypeArgs();
    if (typeArgs != null && typeArgs.size() > 0) {
        JClass[] genericArgumentClasses = new JClass[typeArgs.size()];

        for (int i=0; i<typeArgs.size(); i++) {
            genericArgumentClasses[i] = buildClass(_package, (ClassOrInterfaceType) ((ReferenceType) typeArgs.get(i)).getType(), ((ReferenceType) typeArgs.get(i)).getArrayCount());
        }

        _class = _class.narrow(genericArgumentClasses);
    }

    return _class;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:TypeUtil.java

示例9: getClassOrInterfaceType

import japa.parser.ast.type.ReferenceType; //导入依赖的package包/类
/**
 * Returns the final {@link ClassOrInterfaceType} from a {@link Type}
 * 
 * @param initType
 * @return the final {@link ClassOrInterfaceType} or null if no {@link ClassOrInterfaceType} found
 * 
 */
public static ClassOrInterfaceType getClassOrInterfaceType(Type type) {
    Type tmp = type;
    while (tmp instanceof ReferenceType) {
           tmp = ((ReferenceType) tmp).getType();
    };
    if (tmp instanceof ClassOrInterfaceType){
    	return (ClassOrInterfaceType) tmp;
    }
    return null;
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:18,代码来源:JavaParserUtils.java

示例10: visit

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

示例11: visit

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

示例12: visit

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

示例13: testParse

import japa.parser.ast.type.ReferenceType; //导入依赖的package包/类
public void testParse() throws Exception {

		final String text = "public class Dummy implements java.util.Comparator<java.lang.Integer>{}";

		final CompilationUnit compilationUnit = JavaParser.parse(
				new ByteArrayInputStream(text.getBytes("UTF-8")), "UTF-8");
		final List<TypeDeclaration> typeDeclarations = compilationUnit
				.getTypes();
		assertEquals(1, typeDeclarations.size());
		final TypeDeclaration typeDeclaration = typeDeclarations.get(0);
		assertTrue(typeDeclaration instanceof ClassOrInterfaceDeclaration);
		final ClassOrInterfaceDeclaration classDeclaration = (ClassOrInterfaceDeclaration) typeDeclaration;
		assertEquals("Dummy", classDeclaration.getName());
		final List<ClassOrInterfaceType> implementedInterfaces = classDeclaration
				.getImplements();
		assertEquals(1, implementedInterfaces.size());
		final ClassOrInterfaceType implementedInterface = implementedInterfaces
				.get(0);
		assertEquals("Comparator", implementedInterface.getName());
		final List<Type> typeArgs = implementedInterface.getTypeArgs();
		assertEquals(1, typeArgs.size());
		final Type typeArg = typeArgs.get(0);
		assertTrue(typeArg instanceof ReferenceType);
		final ReferenceType referenceTypeArg = (ReferenceType) typeArg;
		final Type referencedType = referenceTypeArg.getType();
		assertTrue(referencedType instanceof ClassOrInterfaceType);
		final ClassOrInterfaceType typeArgType = (ClassOrInterfaceType) referencedType;
		assertEquals("Integer", typeArgType.getName());

	}
 
开发者ID:highsource,项目名称:jaxb2-basics,代码行数:31,代码来源:JavaTypeParserTest.java

示例14: visit

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

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

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

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

示例15: visit

import japa.parser.ast.type.ReferenceType; //导入依赖的package包/类
public Node visit(WildcardType n, A arg) {
    if (n.getExtends() != null) {
        n.setExtends((ReferenceType) n.getExtends().accept(this, arg));
    }
    if (n.getSuper() != null) {
        n.setSuper((ReferenceType) n.getSuper().accept(this, arg));
    }
    return n;
}
 
开发者ID:rfw,项目名称:genja,代码行数:10,代码来源:ModifierVisitorAdapter.java


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