예제 #1
0
파일: Java5.java 프로젝트: TTwxj/groovy
 public static GenericsType configureTypeVariableDefinition(ClassNode base, ClassNode[] cBounds) {
   ClassNode redirect = base.redirect();
   base.setRedirect(null);
   GenericsType gt;
   if (cBounds == null || cBounds.length == 0) {
     gt = new GenericsType(base);
   } else {
     gt = new GenericsType(base, cBounds, null);
     gt.setName(base.getName());
     gt.setPlaceholder(true);
   }
   base.setRedirect(redirect);
   return gt;
 }
예제 #2
0
파일: Java5.java 프로젝트: bodiam/discobot
 private GenericsType configureTypeVariableDefinition(TypeVariable tv) {
   ClassNode base = configureTypeVariableReference(tv);
   ClassNode redirect = base.redirect();
   base.setRedirect(null);
   Type[] tBounds = tv.getBounds();
   GenericsType gt;
   if (tBounds.length == 0) {
     gt = new GenericsType(base);
   } else {
     ClassNode[] cBounds = configureTypes(tBounds);
     gt = new GenericsType(base, cBounds, null);
     gt.setName(base.getName());
     gt.setPlaceholder(true);
   }
   base.setRedirect(redirect);
   return gt;
 }
예제 #3
0
파일: Java5.java 프로젝트: bodiam/discobot
 private ClassNode configureTypeVariableReference(TypeVariable tv) {
   ClassNode cn = ClassHelper.makeWithoutCaching(tv.getName());
   cn.setGenericsPlaceHolder(true);
   ClassNode cn2 = ClassHelper.makeWithoutCaching(tv.getName());
   cn2.setGenericsPlaceHolder(true);
   GenericsType[] gts = new GenericsType[] {new GenericsType(cn2)};
   cn.setGenericsTypes(gts);
   cn.setRedirect(ClassHelper.OBJECT_TYPE);
   return cn;
 }
예제 #4
0
파일: Java5.java 프로젝트: TTwxj/groovy
 public static ClassNode configureTypeVariableReference(String name) {
   ClassNode cn = ClassHelper.makeWithoutCaching(name);
   cn.setGenericsPlaceHolder(true);
   ClassNode cn2 = ClassHelper.makeWithoutCaching(name);
   cn2.setGenericsPlaceHolder(true);
   GenericsType[] gts = new GenericsType[] {new GenericsType(cn2)};
   cn.setGenericsTypes(gts);
   cn.setRedirect(ClassHelper.OBJECT_TYPE);
   return cn;
 }
예제 #5
0
 public ClassNode getPlainNodeReference() {
   if (ClassHelper.isPrimitiveType(this)) return this;
   ClassNode n = new ClassNode(name, modifiers, superClass, null, null);
   n.isPrimaryNode = false;
   n.setRedirect(redirect());
   if (isArray()) {
     n.componentType = redirect().getComponentType();
   }
   return n;
 }
예제 #6
0
파일: Java5.java 프로젝트: bodiam/discobot
 private ClassNode makeClassNode(CompileUnit cu, Type t, Class c) {
   ClassNode back = null;
   if (cu != null) back = cu.getClass(c.getName());
   if (back == null) back = ClassHelper.make(c);
   if (!(t instanceof Class)) {
     ClassNode front = configureType(t);
     front.setRedirect(back);
     return front;
   }
   return back;
 }
예제 #7
0
  public static ClassNode nonGeneric(ClassNode type) {
    if (type.isUsingGenerics()) {
      final ClassNode nonGen = ClassHelper.makeWithoutCaching(type.getName());
      nonGen.setRedirect(type);
      nonGen.setGenericsTypes(null);
      nonGen.setUsingGenerics(false);
      return nonGen;
    }

    if (type.isArray()) {
      final ClassNode nonGen = ClassHelper.makeWithoutCaching(Object.class);
      nonGen.setUsingGenerics(false);
      return nonGen.makeArray();
    }

    return type.getPlainNodeReference();
  }
예제 #8
0
파일: Java5.java 프로젝트: bodiam/discobot
  private ClassNode configureWildcardType(WildcardType wildcardType) {
    ClassNode base = ClassHelper.makeWithoutCaching("?");
    base.setRedirect(ClassHelper.OBJECT_TYPE);
    // TODO: more than one lower bound for wildcards?
    ClassNode[] lowers = configureTypes(wildcardType.getLowerBounds());
    ClassNode lower = null;
    // TODO: is it safe to remove this? What was the original intention?
    if (lower != null) lower = lowers[0];

    ClassNode[] upper = configureTypes(wildcardType.getUpperBounds());
    GenericsType t = new GenericsType(base, upper, lower);
    t.setWildcard(true);

    ClassNode ref = ClassHelper.makeWithoutCaching(Object.class, false);
    ref.setGenericsTypes(new GenericsType[] {t});

    return ref;
  }
 private GenericsType makePlaceholder(int i) {
   ClassNode type = ClassHelper.makeWithoutCaching("T" + i);
   type.setRedirect(OBJECT_TYPE);
   type.setGenericsPlaceHolder(true);
   return new GenericsType(type);
 }