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


Java ArrayType类代码示例

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


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

示例1: printMethodArgs

import com.sun.tools.javac.code.Type.ArrayType; //导入依赖的package包/类
/**
 * Converts a set of method argument types into their corresponding
 * localized string representation.
 *
 * @param args arguments to be rendered
 * @param varArgs if true, the last method argument is regarded as a vararg
 * @param locale the locale in which the string is to be rendered
 * @return localized string representation
 */
protected String printMethodArgs(List<Type> args, boolean varArgs, Locale locale) {
    if (!varArgs) {
        return visitTypes(args, locale);
    } else {
        StringBuffer buf = new StringBuffer();
        while (args.tail.nonEmpty()) {
            buf.append(visit(args.head, locale));
            args = args.tail;
            buf.append(',');
        }
        if (args.head.tag == ARRAY) {
            buf.append(visit(((ArrayType) args.head).elemtype, locale));
            buf.append("...");
        } else {
            buf.append(visit(args.head, locale));
        }
        return buf.toString();
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:29,代码来源:Printer.java

示例2: getTypeName

import com.sun.tools.javac.code.Type.ArrayType; //导入依赖的package包/类
public static String getTypeName(Type t, boolean full) {
    switch (t.getTag()) {
    case ARRAY:
        StringBuilder s = new StringBuilder();
        while (t.hasTag(ARRAY)) {
            s.append("[]");
            t = ((ArrayType)t).elemtype;
        }
        s.insert(0, getTypeName(t, full));
        return s.toString();
    case CLASS:
        return ClassDocImpl.getClassName((ClassSymbol)t.tsym, full);
    default:
        return t.tsym.getQualifiedName().toString();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:TypeMaker.java

示例3: printMethodArgs

import com.sun.tools.javac.code.Type.ArrayType; //导入依赖的package包/类
/**
 * Converts a set of method argument types into their corresponding
 * localized string representation.
 *
 * @param args arguments to be rendered
 * @param varArgs if true, the last method argument is regarded as a vararg
 * @param locale the locale in which the string is to be rendered
 * @return localized string representation
 */
protected String printMethodArgs(List<Type> args, boolean varArgs, Locale locale) {
    if (!varArgs) {
        return visitTypes(args, locale);
    } else {
        StringBuilder buf = new StringBuilder();
        while (args.tail.nonEmpty()) {
            buf.append(visit(args.head, locale));
            args = args.tail;
            buf.append(',');
        }
        if (args.head.unannotatedType().hasTag(TypeTag.ARRAY)) {
            buf.append(visit(((ArrayType) args.head.unannotatedType()).elemtype, locale));
            if (args.head.getAnnotationMirrors().nonEmpty()) {
                buf.append(' ');
                buf.append(args.head.getAnnotationMirrors());
                buf.append(' ');
            }
            buf.append("...");
        } else {
            buf.append(visit(args.head, locale));
        }
        return buf.toString();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:Printer.java

示例4: printMethodArgs

import com.sun.tools.javac.code.Type.ArrayType; //导入依赖的package包/类
/**
 * Converts a set of method argument types into their corresponding
 * localized string representation.
 *
 * @param args arguments to be rendered
 * @param varArgs if true, the last method argument is regarded as a vararg
 * @param locale the locale in which the string is to be rendered
 * @return localized string representation
 */
protected String printMethodArgs(List<Type> args, boolean varArgs, Locale locale) {
    if (!varArgs) {
        return visitTypes(args, locale);
    } else {
        StringBuilder buf = new StringBuilder();
        while (args.tail.nonEmpty()) {
            buf.append(visit(args.head, locale));
            args = args.tail;
            buf.append(',');
        }
        if (args.head.hasTag(TypeTag.ARRAY)) {
            buf.append(visit(((ArrayType) args.head).elemtype, locale));
            if (args.head.getAnnotationMirrors().nonEmpty()) {
                buf.append(' ');
                buf.append(args.head.getAnnotationMirrors());
                buf.append(' ');
            }
            buf.append("...");
        } else {
            buf.append(visit(args.head, locale));
        }
        return buf.toString();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:Printer.java

示例5: getType

import com.sun.tools.javac.code.Type.ArrayType; //导入依赖的package包/类
/** Build an instance of a Type. */
public Type getType(Type baseType, boolean isArray, List<Type> typeParams) {
  boolean isGeneric = typeParams != null && !typeParams.isEmpty();
  if (!isArray && !isGeneric) {
    // Simple type.
    return baseType;
  } else if (isArray && !isGeneric) {
    // Array type, not generic.
    ClassSymbol arraySymbol = getSymtab().arrayClass;
    return new ArrayType(baseType, arraySymbol);
  } else if (!isArray && isGeneric) {
    // Generic type, not array.
    com.sun.tools.javac.util.List<Type> typeParamsCopy =
        com.sun.tools.javac.util.List.from(typeParams);
    return new ClassType(Type.noType, typeParamsCopy, baseType.tsym);
  } else {
    throw new IllegalArgumentException("Unsupported arguments to getType");
  }
}
 
开发者ID:google,项目名称:error-prone,代码行数:20,代码来源:VisitorState.java

示例6: matchMethodInvocation

import com.sun.tools.javac.code.Type.ArrayType; //导入依赖的package包/类
@Override
public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState state) {
  if (!ARRAYS_AS_LIST_SINGLE_ARRAY.matches(tree, state)) {
    return NO_MATCH;
  }
  ExpressionTree array = Iterables.getOnlyElement(tree.getArguments());
  Type componentType = ((ArrayType) ASTHelpers.getType(array)).getComponentType();
  if (!componentType.isPrimitive()) {
    return NO_MATCH;
  }
  String guavaUtils = GUAVA_UTILS.get(componentType.getKind());
  if (guavaUtils == null) {
    return NO_MATCH;
  }
  Fix fix =
      SuggestedFix.builder()
          .addImport("com.google.common.primitives." + guavaUtils)
          .replace(tree.getMethodSelect(), guavaUtils + ".asList")
          .build();
  return describeMatch(tree, fix);
}
 
开发者ID:google,项目名称:error-prone,代码行数:22,代码来源:ArraysAsListPrimitiveArray.java

示例7: getTypeName

import com.sun.tools.javac.code.Type.ArrayType; //导入依赖的package包/类
public static String getTypeName(Type t, boolean full) {
    switch (t.tag) {
    case ARRAY:
        StringBuilder s = new StringBuilder();
        while (t.tag == ARRAY) {
            s.append("[]");
            t = ((ArrayType)t).elemtype;
        }
        s.insert(0, getTypeName(t, full));
        return s.toString();
    case CLASS:
        return ClassDocImpl.getClassName((ClassSymbol)t.tsym, full);
    default:
        return t.tsym.getQualifiedName().toString();
    }
}
 
开发者ID:aducode,项目名称:openjdk-source-code-learn,代码行数:17,代码来源:TypeMaker.java

示例8: matchMethodInvocation

import com.sun.tools.javac.code.Type.ArrayType; //导入依赖的package包/类
@Override
public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState state) {
  if (ARRAYS_AS_LIST_SINGLE_ARRAY.matches(tree, state)) {
    JCTree array = (JCTree) tree.getArguments().get(0);
    Type componentType = ((ArrayType) array.type).getComponentType();
    String guavaUtils = GUAVA_UTILS.get(componentType.getKind());
    if (guavaUtils != null) {
      Fix fix = new SuggestedFix()
          .addImport("com.google.common.primitives." + guavaUtils)
          .replace(tree.getMethodSelect(), guavaUtils + ".asList");
      return describeMatch(tree, fix);
    }
  }

  return Description.NO_MATCH;
}
 
开发者ID:diy1,项目名称:error-prone-aspirator,代码行数:17,代码来源:ArraysAsListPrimitiveArray.java

示例9: getType

import com.sun.tools.javac.code.Type.ArrayType; //导入依赖的package包/类
/**
 * Build an instance of a Type.
 */
public Type getType(Type baseType, boolean isArray, List<Type> typeParams) {
  boolean isGeneric = typeParams != null && !typeParams.equals(List.nil());
  if (!isArray && !isGeneric) {
    // Simple type.
    return baseType;
  } else if (isArray && !isGeneric) {
    // Array type, not generic.
    ClassSymbol arraySymbol = getSymtab().arrayClass;
    return new ArrayType(baseType, arraySymbol);
  } else if (!isArray && isGeneric) {
    return new ClassType(Type.noType, typeParams, baseType.tsym);
  } else {
    throw new IllegalArgumentException("Unsupported arguments to getType");
  }
}
 
开发者ID:diy1,项目名称:error-prone-aspirator,代码行数:19,代码来源:VisitorState.java

示例10: visitArray

import com.sun.tools.javac.code.Type.ArrayType; //导入依赖的package包/类
public void visitArray(Attribute.Array a) {
    Name elemName = ((ArrayType) a.type).elemtype.tsym.getQualifiedName();

    if (elemName.equals(elemName.table.names.java_lang_Class)) {   // Class[]
        // Construct a proxy for a MirroredTypesException
        ListBuffer<TypeMirror> elems = new ListBuffer<TypeMirror>();
        for (Attribute value : a.values) {
            Type elem = ((Attribute.Class) value).type;
            elems.append(elem);
        }
        value = new MirroredTypesExceptionProxy(elems.toList());

    } else {
        int len = a.values.length;
        Class<?> returnClassSaved = returnClass;
        returnClass = returnClass.getComponentType();
        try {
            Object res = Array.newInstance(returnClass, len);
            for (int i = 0; i < len; i++) {
                a.values[i].accept(this);
                if (value == null || value instanceof ExceptionProxy) {
                    return;
                }
                try {
                    Array.set(res, i, value);
                } catch (IllegalArgumentException e) {
                    value = null;       // indicates a type mismatch
                    return;
                }
            }
            value = res;
        } finally {
            returnClass = returnClassSaved;
        }
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:37,代码来源:AnnotationProxyMaker.java

示例11: visitArrayType

import com.sun.tools.javac.code.Type.ArrayType; //导入依赖的package包/类
@Override
public Boolean visitArrayType(ArrayType t, Type s) {
    if (t == s)
        return true;

    if (s.isPartial())
        return visit(s, t);

    return s.hasTag(ARRAY)
        && visit(t.elemtype, types.elemtype(s));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:JavacTrees.java

示例12: visitArray

import com.sun.tools.javac.code.Type.ArrayType; //导入依赖的package包/类
public void visitArray(Attribute.Array a) {
    Name elemName = ((ArrayType) a.type).elemtype.tsym.getQualifiedName();

    if (elemName.equals(elemName.table.names.java_lang_Class)) {   // Class[]
        // Construct a proxy for a MirroredTypesException
        ListBuffer<TypeMirror> elems = new ListBuffer<TypeMirror>();
        for (Attribute value : a.values) {
            Type elem = ((Attribute.Class) value).classType;
            elems.append(elem);
        }
        value = new MirroredTypesExceptionProxy(elems.toList());

    } else {
        int len = a.values.length;
        Class<?> returnClassSaved = returnClass;
        returnClass = returnClass.getComponentType();
        try {
            Object res = Array.newInstance(returnClass, len);
            for (int i = 0; i < len; i++) {
                a.values[i].accept(this);
                if (value == null || value instanceof ExceptionProxy) {
                    return;
                }
                try {
                    Array.set(res, i, value);
                } catch (IllegalArgumentException e) {
                    value = null;       // indicates a type mismatch
                    return;
                }
            }
            value = res;
        } finally {
            returnClass = returnClassSaved;
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:37,代码来源:AnnotationProxyMaker.java

示例13: visitArrayType

import com.sun.tools.javac.code.Type.ArrayType; //导入依赖的package包/类
@Override
public String visitArrayType(ArrayType t, Locale locale) {
    StringBuilder res = new StringBuilder();
    printBaseElementType(t, res, locale);
    printBrackets(t, res, locale);
    return res.toString();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:Printer.java

示例14: printBaseElementType

import com.sun.tools.javac.code.Type.ArrayType; //导入依赖的package包/类
void printBaseElementType(Type t, StringBuilder sb, Locale locale) {
    Type arrel = t;
    while (arrel.hasTag(TypeTag.ARRAY)) {
        arrel = arrel.unannotatedType();
        arrel = ((ArrayType) arrel).elemtype;
    }
    sb.append(visit(arrel, locale));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:Printer.java

示例15: printBrackets

import com.sun.tools.javac.code.Type.ArrayType; //导入依赖的package包/类
void printBrackets(Type t, StringBuilder sb, Locale locale) {
    Type arrel = t;
    while (arrel.hasTag(TypeTag.ARRAY)) {
        if (arrel.isAnnotated()) {
            sb.append(' ');
            sb.append(arrel.getAnnotationMirrors());
            sb.append(' ');
        }
        sb.append("[]");
        arrel = arrel.unannotatedType();
        arrel = ((ArrayType) arrel).elemtype;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:Printer.java


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