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


Java Types.getArrayType方法代码示例

本文整理汇总了Java中javax.lang.model.util.Types.getArrayType方法的典型用法代码示例。如果您正苦于以下问题:Java Types.getArrayType方法的具体用法?Java Types.getArrayType怎么用?Java Types.getArrayType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.lang.model.util.Types的用法示例。


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

示例1: TypeMirrors

import javax.lang.model.util.Types; //导入方法依赖的package包/类
TypeMirrors(ProcessingEnvironment env) {
    final Types typeUtils = env.getTypeUtils();
    final Elements elementUtils = env.getElementUtils();

    STRING_MIRROR = elementUtils.getTypeElement("java.lang.String").asType();
    BINARY_MIRROR = typeUtils.getArrayType(typeUtils.getPrimitiveType(TypeKind.BYTE));
    BOOLEAN_MIRROR = elementUtils.getTypeElement(Boolean.class.getName()).asType();
    LONG_MIRROR = elementUtils.getTypeElement(Long.class.getName()).asType();
    INTEGER_MIRROR = elementUtils.getTypeElement(Integer.class.getName()).asType();
    SHORT_MIRROR = elementUtils.getTypeElement(Short.class.getName()).asType();
    BYTE_MIRROR = elementUtils.getTypeElement(Byte.class.getName()).asType();
    DOUBLE_MIRROR = elementUtils.getTypeElement(Double.class.getName()).asType();
    FLOAT_MIRROR = elementUtils.getTypeElement(Float.class.getName()).asType();
    DATE_MIRROR = elementUtils.getTypeElement(Date.class.getName()).asType();

    PRIMITIVE_LONG_MIRROR = typeUtils.getPrimitiveType(TypeKind.LONG);
    PRIMITIVE_INT_MIRROR = typeUtils.getPrimitiveType(TypeKind.INT);
    PRIMITIVE_SHORT_MIRROR = typeUtils.getPrimitiveType(TypeKind.SHORT);
    PRIMITIVE_BYTE_MIRROR = typeUtils.getPrimitiveType(TypeKind.BYTE);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:TypeMirrors.java

示例2: testAddImport11

import javax.lang.model.util.Types; //导入方法依赖的package包/类
public void testAddImport11() throws IOException {
    JavaSource src = getJavaSource(testFile);
    Task<WorkingCopy> task = new Task<WorkingCopy>() {

        public void run(WorkingCopy workingCopy) throws IOException {
            workingCopy.toPhase(Phase.RESOLVED);
            CompilationUnitTree cut = workingCopy.getCompilationUnit();
            TreeMaker make = workingCopy.getTreeMaker();
            ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
            MethodTree node = (MethodTree) clazz.getMembers().get(0);
            BlockTree body = node.getBody();
            List<StatementTree> stats = new ArrayList<StatementTree>();
            for (StatementTree st : body.getStatements()) {
                stats.add(st);
            }
            TypeElement list = workingCopy.getElements().getTypeElement("java.util.Map.Entry");
            Types types = workingCopy.getTypes();
            TypeMirror tm = types.getArrayType(types.erasure(list.asType()));
            stats.add(make.Variable(make.Modifiers(Collections.<Modifier>emptySet()), "entry", make.Type(tm), null));
            workingCopy.rewrite(body, make.Block(stats, false));
        }
    };
    src.runModificationTask(task).commit();
    assertFiles("testAddImport11.pass");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:ImportAnalysisTest.java

示例3: testAddImport13

import javax.lang.model.util.Types; //导入方法依赖的package包/类
public void testAddImport13() throws IOException {
    testFile = getFile(getSourceDir(), getSourcePckg() + "ImportsTest2.java");
    JavaSource src = getJavaSource(testFile);
    Task<WorkingCopy> task = new Task<WorkingCopy>() {

        public void run(WorkingCopy workingCopy) throws IOException {
            workingCopy.toPhase(Phase.RESOLVED);
            CompilationUnitTree cut = workingCopy.getCompilationUnit();
            TreeMaker make = workingCopy.getTreeMaker();
            ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
            MethodTree node = (MethodTree) clazz.getMembers().get(0);
            BlockTree body = node.getBody();
            List<StatementTree> stats = new ArrayList<StatementTree>();
            for (StatementTree st : body.getStatements()) {
                stats.add(st);
            }
            TypeElement list = workingCopy.getElements().getTypeElement("java.util.Map.Entry");
            Types types = workingCopy.getTypes();
            TypeMirror tm = types.getArrayType(types.erasure(list.asType()));
            stats.add(make.Variable(make.Modifiers(Collections.<Modifier>emptySet()), "entry", make.Type(tm), null));
            workingCopy.rewrite(body, make.Block(stats, false));
        }
    };
    src.runModificationTask(task).commit();
    assertFiles("testAddImport13.pass");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ImportAnalysisTest.java

示例4: testAddImport14

import javax.lang.model.util.Types; //导入方法依赖的package包/类
public void testAddImport14() throws IOException {
    testFile = getFile(getSourceDir(), getSourcePckg() + "ImportsTest3.java");
    JavaSource src = getJavaSource(testFile);
    Task<WorkingCopy> task = new Task<WorkingCopy>() {

        public void run(WorkingCopy workingCopy) throws IOException {
            workingCopy.toPhase(Phase.RESOLVED);
            CompilationUnitTree cut = workingCopy.getCompilationUnit();
            TreeMaker make = workingCopy.getTreeMaker();
            ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
            MethodTree node = (MethodTree) clazz.getMembers().get(0);
            BlockTree body = node.getBody();
            List<StatementTree> stats = new ArrayList<StatementTree>();
            for (StatementTree st : body.getStatements()) {
                stats.add(st);
            }
            TypeElement list = workingCopy.getElements().getTypeElement("java.util.Map.Entry");
            Types types = workingCopy.getTypes();
            TypeMirror tm = types.getArrayType(types.erasure(list.asType()));
            stats.add(make.Variable(make.Modifiers(Collections.<Modifier>emptySet()), "entry", make.Type(tm), null));
            workingCopy.rewrite(body, make.Block(stats, false));
        }
    };
    src.runModificationTask(task).commit();
    assertFiles("testAddImport14.pass");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ImportAnalysisTest.java

示例5: testAddImport17

import javax.lang.model.util.Types; //导入方法依赖的package包/类
public void testAddImport17() throws IOException {
    testFile = getFile(getSourceDir(), getSourcePckg() + "ImportsTest6.java");
    JavaSource src = getJavaSource(testFile);
    Task<WorkingCopy> task = new Task<WorkingCopy>() {

        public void run(WorkingCopy workingCopy) throws IOException {
            workingCopy.toPhase(Phase.RESOLVED);
            CompilationUnitTree cut = workingCopy.getCompilationUnit();
            TreeMaker make = workingCopy.getTreeMaker();
            ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
            MethodTree node = (MethodTree) clazz.getMembers().get(0);
            BlockTree body = node.getBody();
            List<StatementTree> stats = new ArrayList<StatementTree>();
            for (StatementTree st : body.getStatements()) {
                stats.add(st);
            }
            TypeElement list = workingCopy.getElements().getTypeElement("java.lang.String");
            Types types = workingCopy.getTypes();
            TypeMirror tm = types.getArrayType(types.erasure(list.asType()));
            stats.add(make.Variable(make.Modifiers(Collections.<Modifier>emptySet()), "s", make.Type(tm), null));
            workingCopy.rewrite(body, make.Block(stats, false));
        }
    };
    src.runModificationTask(task).commit();
    assertFiles("testAddImport17.pass");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ImportAnalysisTest.java

示例6: testAddImportOrder1

import javax.lang.model.util.Types; //导入方法依赖的package包/类
public void testAddImportOrder1() throws IOException {
    testFile = getFile(getSourceDir(), getSourcePckg() + "ImportsTest7.java");
    JavaSource src = getJavaSource(testFile);
    Task<WorkingCopy> task = new Task<WorkingCopy>() {

        public void run(WorkingCopy workingCopy) throws IOException {
            workingCopy.toPhase(Phase.RESOLVED);
            CompilationUnitTree cut = workingCopy.getCompilationUnit();
            TreeMaker make = workingCopy.getTreeMaker();
            ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
            MethodTree node = (MethodTree) clazz.getMembers().get(0);
            BlockTree body = node.getBody();
            List<StatementTree> stats = new ArrayList<StatementTree>();
            for (StatementTree st : body.getStatements()) {
                stats.add(st);
            }
            TypeElement list = workingCopy.getElements().getTypeElement("java.util.LinkedList");
            Types types = workingCopy.getTypes();
            TypeMirror tm = types.getArrayType(types.erasure(list.asType()));
            stats.add(make.Variable(make.Modifiers(Collections.<Modifier>emptySet()), "s", make.Type(tm), null));
            workingCopy.rewrite(body, make.Block(stats, false));
        }
    };
    src.runModificationTask(task).commit();
    assertFiles("testAddImportOrder1.pass");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ImportAnalysisTest.java

示例7: testAddImport8

import javax.lang.model.util.Types; //导入方法依赖的package包/类
public void testAddImport8() throws IOException {
    JavaSource src = getJavaSource(testFile);
    Preferences preferences = MimeLookup.getLookup(JavaTokenId.language().mimeType()).lookup(Preferences.class);
    preferences.putBoolean("importInnerClasses", true);
    Task<WorkingCopy> task = new Task<WorkingCopy>() {

        public void run(WorkingCopy workingCopy) throws IOException {
            workingCopy.toPhase(Phase.RESOLVED);
            CompilationUnitTree cut = workingCopy.getCompilationUnit();
            TreeMaker make = workingCopy.getTreeMaker();
            ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
            MethodTree node = (MethodTree) clazz.getMembers().get(0);
            BlockTree body = node.getBody();
            List<StatementTree> stats = new ArrayList<StatementTree>();
            for (StatementTree st : body.getStatements()) {
                stats.add(st);
            }
            TypeElement list = workingCopy.getElements().getTypeElement("java.util.Map.Entry");
            Types types = workingCopy.getTypes();
            TypeMirror tm = types.getArrayType(types.erasure(list.asType()));
            stats.add(make.Variable(make.Modifiers(Collections.<Modifier>emptySet()), "entry", make.Type(tm), null));
            workingCopy.rewrite(body, make.Block(stats, false));
        }
    };
    src.runModificationTask(task).commit();
    preferences.remove("importInnerClasses");
    assertFiles("testAddImport8.pass");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:ImportAnalysisTest.java

示例8: testAddImport12

import javax.lang.model.util.Types; //导入方法依赖的package包/类
public void testAddImport12() throws IOException {
    JavaSource src = getJavaSource(testFile);
    Task<WorkingCopy> task = new Task<WorkingCopy>() {

        public void run(WorkingCopy workingCopy) throws IOException {
            workingCopy.toPhase(Phase.RESOLVED);
            CompilationUnitTree cut = workingCopy.getCompilationUnit();
            TreeMaker make = workingCopy.getTreeMaker();
            ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
            TypeElement map = workingCopy.getElements().getTypeElement("java.util.Map");
            ClassTree nue = make.addClassImplementsClause(clazz, make.QualIdent(map));
            workingCopy.rewrite(clazz, nue);
            MethodTree node = (MethodTree) clazz.getMembers().get(0);
            BlockTree body = node.getBody();
            List<StatementTree> stats = new ArrayList<StatementTree>();
            for (StatementTree st : body.getStatements()) {
                stats.add(st);
            }
            TypeElement list = workingCopy.getElements().getTypeElement("java.util.Map.Entry");
            Types types = workingCopy.getTypes();
            TypeMirror tm = types.getArrayType(types.erasure(list.asType()));
            stats.add(make.Variable(make.Modifiers(Collections.<Modifier>emptySet()), "entry", make.Type(tm), null));
            workingCopy.rewrite(body, make.Block(stats, false));
        }
    };
    src.runModificationTask(task).commit();
    assertFiles("testAddImport12.pass");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:ImportAnalysisTest.java

示例9: testAddImportSamePackage

import javax.lang.model.util.Types; //导入方法依赖的package包/类
public void testAddImportSamePackage() throws IOException {
    testFile = getFile(getSourceDir(), getSourcePckg() + "ImportsTest7.java");
    JavaSource src = getJavaSource(testFile);
    Task<WorkingCopy> task = new Task<WorkingCopy>() {

        public void run(WorkingCopy workingCopy) throws IOException {
            workingCopy.toPhase(Phase.RESOLVED);
            CompilationUnitTree cut = workingCopy.getCompilationUnit();
            TreeMaker make = workingCopy.getTreeMaker();
            ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
            MethodTree node = (MethodTree) clazz.getMembers().get(0);
            BlockTree body = node.getBody();
            List<StatementTree> stats = new ArrayList<StatementTree>();
            for (StatementTree st : body.getStatements()) {
                stats.add(st);
            }
            TypeElement list = workingCopy.getElements().getTypeElement("org.netbeans.test.codegen.ImportsTest6");
            assertNotNull(list);
            Types types = workingCopy.getTypes();
            TypeMirror tm = types.getArrayType(types.erasure(list.asType()));
            stats.add(make.Variable(make.Modifiers(Collections.<Modifier>emptySet()), "s", make.Type(tm), null));
            workingCopy.rewrite(body, make.Block(stats, false));
        }
    };
    src.runModificationTask(task).commit();
    assertFiles("testAddImportSamePackage.pass");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:ImportAnalysisTest.java


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