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


Java ElementKind.isInterface方法代码示例

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


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

示例1: paramElementFor

import javax.lang.model.element.ElementKind; //导入方法依赖的package包/类
private static Element paramElementFor(Element methodOrClass, ParamTree ptag) {
    ElementKind kind = methodOrClass.getKind();
    List<? extends Element> params = Collections.emptyList();
    if (kind == ElementKind.METHOD || kind == ElementKind.CONSTRUCTOR) {
        ExecutableElement ee = (ExecutableElement) methodOrClass;
        params = ptag.isTypeParameter()
                ? ee.getTypeParameters()
                : ee.getParameters();
    } else if (kind.isClass() || kind.isInterface()) {
        TypeElement te = (TypeElement) methodOrClass;
        params = te.getTypeParameters();
    }

    for (Element param : params) {
        if (param.getSimpleName().contentEquals(ptag.getName().getName())) {
            return param;
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:JavadocImports.java

示例2: attributeParamIdentifier

import javax.lang.model.element.ElementKind; //导入方法依赖的package包/类
private Symbol attributeParamIdentifier(TreePath path, DCParam ptag) {
    Symbol javadocSymbol = getElement(path);
    if (javadocSymbol == null)
        return null;
    ElementKind kind = javadocSymbol.getKind();
    List<? extends Symbol> params = List.nil();
    if (kind == ElementKind.METHOD || kind == ElementKind.CONSTRUCTOR) {
        MethodSymbol ee = (MethodSymbol) javadocSymbol;
        params = ptag.isTypeParameter()
                ? ee.getTypeParameters()
                : ee.getParameters();
    } else if (kind.isClass() || kind.isInterface()) {
        ClassSymbol te = (ClassSymbol) javadocSymbol;
        params = te.getTypeParameters();
    }

    for (Symbol param : params) {
        if (param.getSimpleName() == ptag.getName().getName()) {
            return param;
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:JavacTrees.java

示例3: enclosingTypeOf

import javax.lang.model.element.ElementKind; //导入方法依赖的package包/类
private TypeElement enclosingTypeOf(Element element) {
  for (Element e = element; e != null;) {
    ElementKind kind = e.getKind();
    if (kind.isClass() || kind.isInterface()) {
      return (TypeElement) e;
    }
    e = e.getEnclosingElement();
  }
  throw new NoSuchElementException();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:Round.java

示例4: isSameKind

import javax.lang.model.element.ElementKind; //导入方法依赖的package包/类
private static boolean isSameKind (ElementKind k1, ElementKind k2) {
    if ((k1 == k2) ||
       (k1 == ElementKind.OTHER && (k2.isClass() || k2.isInterface())) ||     
       (k2 == ElementKind.OTHER && (k1.isClass() || k1.isInterface()))) {
        return true;
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ElementHandle.java

示例5: signatureEquals

import javax.lang.model.element.ElementKind; //导入方法依赖的package包/类
/**
 * Tests if the handle has this same signature as the parameter.
 * The handles has the same signatures if it is resolved into the same
 * element in the same {@link javax.tools.JavaCompiler} task, but may be resolved into
 * the different {@link Element} in the different {@link javax.tools.JavaCompiler} task.
 * @param element to be checked
 * @return true if this handle resolves into the same {@link Element}
 * in the same {@link javax.tools.JavaCompiler} task.
 */
public boolean signatureEquals (@NonNull final T element) {
    final ElementKind ek = element.getKind();
    final ElementKind thisKind = getKind();
    if ((ek != thisKind) && !(thisKind == ElementKind.OTHER && (ek.isClass() || ek.isInterface()))) {
        return false;
    }
    final ElementHandle<T> handle = create (element);
    return signatureEquals (handle);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ElementHandle.java

示例6: createTypeElementHandle

import javax.lang.model.element.ElementKind; //导入方法依赖的package包/类
/**
 * Creates an {@link ElementHandle} representing a {@link TypeElement}.
 * @param kind the {@link ElementKind} of the {@link TypeElement},
 * allowed values are {@link ElementKind#CLASS}, {@link ElementKind#INTERFACE},
 * {@link ElementKind#ENUM} and {@link ElementKind#ANNOTATION_TYPE}.
 * @param binaryName the class binary name as specified by JLS §13.1
 * @return the created {@link ElementHandle}
 * @throws IllegalArgumentException if kind is neither class nor interface
 * @since 0.98
 */
@NonNull
public static ElementHandle<TypeElement> createTypeElementHandle(
    @NonNull final ElementKind kind,
    @NonNull final String binaryName) throws IllegalArgumentException {
    Parameters.notNull("kind", kind);   //NOI18N
    Parameters.notNull("binaryName", binaryName);   //NOI18N
    if (!kind.isClass() && !kind.isInterface()) {
        throw new IllegalArgumentException(kind.toString());
    }
    return new ElementHandle<TypeElement>(kind, binaryName);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:ElementHandle.java

示例7: checkModifiersIfNested

import javax.lang.model.element.ElementKind; //导入方法依赖的package包/类
private void checkModifiersIfNested(TypeElement type) {
    ElementKind enclosingKind = type.getEnclosingElement().getKind();
    if (enclosingKind.isClass() || enclosingKind.isInterface()) {
        if (type.getModifiers().contains(PRIVATE)) {
            mErrorReporter.abortWithError("@AutoParcel class must not be private", type);
        }
        if (!type.getModifiers().contains(STATIC)) {
            mErrorReporter.abortWithError("Nested @AutoParcel class must be static", type);
        }
    }
    // In principle type.getEnclosingElement() could be an ExecutableElement (for a class
    // declared inside a method), but since RoundEnvironment.getElementsAnnotatedWith doesn't
    // return such classes we won't see them here.
}
 
开发者ID:foodora,项目名称:android-auto-mapper,代码行数:15,代码来源:AutoMappperProcessor.java

示例8: getPanel

import javax.lang.model.element.ElementKind; //导入方法依赖的package包/类
@Override
public CustomRefactoringPanel getPanel(ChangeListener parent) {
    if (panel == null) {
        String suffix = "";
        if(handle != null && handle.getKind() == Tree.Kind.LABELED_STATEMENT) {
            suffix = getString("LBL_Label");
        } else if (handle != null && handle.getElementHandle() !=null) {
            ElementKind kind = handle.getElementHandle().getKind();
            if (kind!=null && (kind.isClass() || kind.isInterface())) {
                suffix  = kind.isInterface() ? getString("LBL_Interface") : getString("LBL_Class");
            } else if (kind == ElementKind.METHOD) {
                suffix = getString("LBL_Method");
            } else if (kind == ElementKind.FIELD) {
                suffix = getString("LBL_Field");
            } else if (kind == ElementKind.LOCAL_VARIABLE) {
                suffix = getString("LBL_LocalVar");
            } else if (kind == ElementKind.PACKAGE || (handle == null && fromListener)) {
                suffix = pkgRename ? getString("LBL_Package") : getString("LBL_Folder");
            } else if (kind == ElementKind.PARAMETER) {
                suffix = getString("LBL_Parameter");
            }
        }
        suffix = suffix + " " + this.oldName; // NOI18N
        panel = new RenamePanel(handle, newName, parent, NbBundle.getMessage(RenamePanel.class, "LBL_Rename") + " " + suffix, !fromListener, fromListener && !byPassPakageRename);
    }
    return panel;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:RenameRefactoringUI.java

示例9: getEnclosingTypeElement

import javax.lang.model.element.ElementKind; //导入方法依赖的package包/类
public TypeElement getEnclosingTypeElement(Element e) {
    if (e.getKind() == ElementKind.PACKAGE)
        return null;
    Element encl = e.getEnclosingElement();
    ElementKind kind = encl.getKind();
    if (kind == ElementKind.PACKAGE)
        return null;
    while (!(kind.isClass() || kind.isInterface())) {
        encl = encl.getEnclosingElement();
    }
    return (TypeElement)encl;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:Utils.java

示例10: getFile

import javax.lang.model.element.ElementKind; //导入方法依赖的package包/类
/**
 * Returns a source file in which the passed element
 * is declared in. This tuned up version of {@code SourceUtils.getFile}
 * is necessary as sequential invocations of {@code SourceUtils.getFile} are
 * excessively slow.
 *
 * @param element an element to find {@link FileObject} for
 * @param cpInfo scope where the file will be searched
 * @param cache a cache
 * @return the source file
 * @see SourceUtils#getFile(org.netbeans.api.java.source.ElementHandle, org.netbeans.api.java.source.ClasspathInfo) SourceUtils.getFile
 */
public static FileObject getFile(final Element element, final ClasspathInfo cpInfo, final Cache cache) {
    Parameters.notNull("element", element); //NOI18N
    Parameters.notNull("cpInfo", cpInfo);   //NOI18N
    Parameters.notNull("cache", cache);   //NOI18N

    Element current = element;
    Element prev = current.getKind() == ElementKind.PACKAGE ? current : null;
    while (current.getKind() != ElementKind.PACKAGE) {
        prev = current;
        current = current.getEnclosingElement();
    }
    if (prev == null) {
        return null;
    }

    final ElementKind kind = prev.getKind();
    String fqn;
    if (kind.isClass() || kind.isInterface()) {
        fqn = ((TypeElement) prev).getQualifiedName().toString();
    } else if (kind == ElementKind.PACKAGE) {
        fqn = ((PackageElement) prev).getQualifiedName().toString();
    } else {
        return null;
    }

    Object cached = cache.cacheOfSrcFiles.get(fqn);
    if (cached == null) {
        final ElementHandle<? extends Element> handle = ElementHandle.create(prev);
        cached = SourceUtils.getFile(handle, cpInfo);
        cache.cacheOfSrcFiles.put(fqn, cached != null ? cached : Cache.NULL);
    } else if (cached == Cache.NULL) {
        cached = null;
    }
    return (FileObject) cached;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:48,代码来源:SourceUtilsEx.java

示例11: findType

import javax.lang.model.element.ElementKind; //导入方法依赖的package包/类
private TypeElement findType(Tree selector) {
    TypeMirror tm = ci.getTrees().getTypeMirror(new TreePath(getCurrentPath(), selector));
    if (tm != null && tm.getKind() == TypeKind.DECLARED) {
        TypeElement t = (TypeElement)ci.getTypes().asElement(tm);
        ElementKind ek = t.getKind();
        if (!(ek.isClass() || ek.isInterface())) {
            // PENDING: an error, log
            return null;
        }
        // the referenced type must be in the same CU, cannot be a superclass.
        return t;
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:InstanceRefFinder.java

示例12: visitDeclared

import javax.lang.model.element.ElementKind; //导入方法依赖的package包/类
@Override
public Void visitDeclared(DeclaredType type, Void p) {
    TypeElement element = (TypeElement)type.asElement();
    String name = element.getQualifiedName().toString();
    ElementKind kind = element.getEnclosingElement().getKind();
    if (kind.isClass() || kind.isInterface() || kind == ElementKind.PACKAGE) {
        try {
            String s = SourceUtils.resolveImport(info, path, name);
            int idx = s.indexOf('.');
            if (idx < 0) {
                importedTypes.add(name);
            } else {
                importedTypes.add(name.substring(0, name.length() - s.length() + idx));
            }
            name = s;
        } catch (Exception e) {
            Logger.getLogger("global").log(Level.INFO, null, e); //NOI18N
        }
    }
    builder.append(name);
    Iterator<? extends TypeMirror> it = type.getTypeArguments().iterator();
    if (it.hasNext()) {
        builder.append('<'); //NOI18N
        while(it.hasNext()) {
            visit(it.next());
            if (it.hasNext())
                builder.append(", "); //NOI18N
        }
        builder.append('>'); //NOI18N
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:AutoImport.java

示例13: handleNode

import javax.lang.model.element.ElementKind; //导入方法依赖的package包/类
private void handleNode(
        final Tree node,
        final Map<Tree,WhiteListQuery.Result> p) {
    final Element e = trees.getElement(getCurrentPath());
    if (e == null) {
        return;
    }
    final ElementKind k = e.getKind();
    ElementHandle<?> eh = null;
    Tree toReport =  null;
    if (k.isClass() || k.isInterface()) {
        TypeMirror type = e.asType();
        if (type != null) {
            type = findComponentType(type);
            if (type.getKind() == TypeKind.DECLARED) {
                eh = ElementHandle.create(((DeclaredType)type).asElement());
                toReport=node;
            }
        }
    } else if ((k == ElementKind.METHOD || k == ElementKind.CONSTRUCTOR) &&
            !methodInvocation.isEmpty()) {
        toReport=methodInvocation.peekFirst();
        eh = ElementHandle.create(e);
    }
    final WhiteListQuery.Result res;
    if (toReport != null &&
        !(res=whiteList.check(eh,WhiteListQuery.Operation.USAGE)).isAllowed()) {
            p.put(toReport,res);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:WhiteListSupport.java

示例14: addPublicTypes

import javax.lang.model.element.ElementKind; //导入方法依赖的package包/类
void addPublicTypes(List<TypeElement> list, Element e) {
    ElementKind kind = e.getKind();
    if ((kind.isClass() || kind.isInterface())
            && e.getModifiers().contains(Modifier.PUBLIC)) {
        list.add((TypeElement)e);
        for (Element enc : e.getEnclosedElements()) {
            addPublicTypes(list, enc);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:TraverseProc.java

示例15: isTypeElement

import javax.lang.model.element.ElementKind; //导入方法依赖的package包/类
private static boolean isTypeElement(Element element) {
  ElementKind kind = element.getKind();
  return kind.isClass()
      || kind.isInterface();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:SourceNames.java


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