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


Java ElementKind.TYPE_PARAMETER属性代码示例

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


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

示例1: initialize

@Override
void initialize(final Element element, CompilationController info) {
    final String labelText;
    if(element.getKind() == ElementKind.TYPE_PARAMETER) {
        labelText = UIUtilities.createHeader((TypeParameterElement) element, info.getElements().isDeprecated(element), false, false, true);
    } else {
        labelText = UIUtilities.createHeader((VariableElement) element, info.getElements().isDeprecated(element), false, false, true);
    }
    final Icon labelIcon = ElementIcons.getElementIcon(element.getKind(), element.getModifiers());
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            Dimension preferredSize = label.getPreferredSize();
            label.setText(labelText);
            label.setIcon(labelIcon);
            label.setPreferredSize(preferredSize);
            label.setMinimumSize(preferredSize);
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:WhereUsedPanelVariable.java

示例2: checkParamsDocumented

private void checkParamsDocumented(List<? extends Element> list, List<? extends Tree> trees, DocTreePath docTreePath, Set<String> inheritedParams, List<ErrorDescription> errors) {
    if(foundInheritDoc) return;
    for (int i = 0; i < list.size() && i < trees.size(); i++) {
        if(ctx.isCanceled()) { return; }
        Element e = list.get(i);
        Tree t = trees.get(i);
        if (!foundParams.contains(e) && !inheritedParams.contains(e.getSimpleName().toString())) {
            boolean isTypeParam = e.getKind() == ElementKind.TYPE_PARAMETER;
            CharSequence paramName = (isTypeParam)
                    ? "<" + e.getSimpleName() + ">"
                    : e.getSimpleName();
            DocTreePathHandle dtph = DocTreePathHandle.create(docTreePath, javac);
            if (dtph != null) {
                errors.add(ErrorDescriptionFactory.forTree(ctx, t, MISSING_PARAM_DESC(paramName), AddTagFix.createAddParamTagFix(dtph, e.getSimpleName().toString(), isTypeParam, i).toEditorFix()));
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:Analyzer.java

示例3: checkParamsDocumented

private void checkParamsDocumented(List<? extends Element> list) {
    if (foundInheritDoc)
        return;

    for (Element e: list) {
        if (!foundParams.contains(e)) {
            CharSequence paramName = (e.getKind() == ElementKind.TYPE_PARAMETER)
                    ? "<" + e.getSimpleName() + ">"
                    : e.getSimpleName();
            reportMissing("dc.missing.param", paramName);
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:Checker.java

示例4: isStaticContext

private boolean isStaticContext(AnalyzeTask at, TreePath path) {
    switch (path.getLeaf().getKind()) {
        case ARRAY_TYPE:
        case PRIMITIVE_TYPE:
            return true;
        default:
            Element selectEl = at.trees().getElement(path);
            return selectEl != null && (selectEl.getKind().isClass() || selectEl.getKind().isInterface() || selectEl.getKind() == ElementKind.TYPE_PARAMETER) && selectEl.asType().getKind() != TypeKind.ERROR;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:SourceCodeAnalysisImpl.java

示例5: fixGenericTypes

private <E extends Tree> E fixGenericTypes(E tree, final TreePath path, final Element member) {
    final Map<TypeMirror, TypeParameterElement> mappings = new HashMap<TypeMirror, TypeParameterElement>();
    DeclaredType declaredType = (DeclaredType) sourceType.asType();
    for (TypeMirror typeMirror : declaredType.getTypeArguments()) {
        DeclaredType currentElement = declaredType;
        deepSearchTypes(currentElement, typeMirror, typeMirror, mappings);
    }
    final Types types = workingCopy.getTypes();

    final Map<IdentifierTree, Tree> original2Translated = new HashMap<IdentifierTree, Tree>();
    ErrorAwareTreeScanner<Void, Void> scanner = new ErrorAwareTreeScanner<Void, Void>() {

        @Override
        public Void visitIdentifier(IdentifierTree node, Void p) {
            Element element = workingCopy.getTrees().getElement(new TreePath(path, node));
            if (element != null && element.getKind() == ElementKind.TYPE_PARAMETER) {
                Element typeElement = types.asElement(element.asType());
                if (typeElement != null && typeElement.getKind() == ElementKind.TYPE_PARAMETER) {
                    TypeParameterElement parameterElement = (TypeParameterElement) typeElement;
                    Element genericElement = parameterElement.getGenericElement();
                    if (genericElement != member) {
                        // genericElement is niet gelijk aan het te verplaatsen element. Dus we moeten deze veranderen.
                        // Is het parameterElement gebruikt bij het maken van de superclass

                        Tree type;
                        TypeParameterElement target = mappings.get(parameterElement.asType());
                        if (target != null) {
                            type = make.Type(target.asType());
                        } else {
                            List<? extends TypeMirror> bounds = parameterElement.getBounds();
                            if (bounds.isEmpty()) {
                                type = make.Type("Object"); // NOI18N
                            } else {
                                type = make.Type(bounds.get(0));
                            }
                        }
                        original2Translated.put(node, type);
                    }
                }
            }
            return super.visitIdentifier(node, p);
        }
    };
    scanner.scan(tree, null);
    E result = (E) workingCopy.getTreeUtilities().translate(tree, original2Translated);
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:47,代码来源:PullUpTransformer.java

示例6: allowInstantRename

private static boolean allowInstantRename(CompilationInfo info, Element e, ElementUtilities eu) {
    if(e.getKind() == ElementKind.FIELD) {
        VariableElement variableElement = (VariableElement) e;
        TypeElement typeElement = eu.enclosingTypeElement(e);
        
        boolean isProperty = false;
        try {
            CodeStyle codeStyle = CodeStyle.getDefault(info.getDocument());
            isProperty = eu.hasGetter(typeElement, variableElement, codeStyle);
            isProperty = isProperty || (!variableElement.getModifiers().contains(Modifier.FINAL) &&
                                eu.hasSetter(typeElement, variableElement, codeStyle));
        } catch (IOException ex) {
        }
        if(isProperty) {
            return false;
        }
    }
    if (org.netbeans.modules.java.editor.base.semantic.Utilities.isPrivateElement(e)) {
        return true;
    }
    
    if (isInaccessibleOutsideOuterClass(e, eu)) {
        return true;
    }
    
    //#92160: check for local classes:
    if (e.getKind() == ElementKind.CLASS) {//only classes can be local
        Element enclosing = e.getEnclosingElement();
        final ElementKind enclosingKind = enclosing.getKind();

        //#150352: parent is annonymous class
        if (enclosingKind == ElementKind.CLASS) {
            final Set<ElementKind> fm = EnumSet.of(ElementKind.METHOD, ElementKind.FIELD);
            if (enclosing.getSimpleName().length() == 0 || fm.contains(enclosing.getEnclosingElement().getKind())) {
                return true;
            }
        }


        return LOCAL_CLASS_PARENTS.contains(enclosingKind);
    }

    if (e.getKind() == ElementKind.TYPE_PARAMETER) {
        return true;
    }
    
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:48,代码来源:InstantRenamePerformer.java

示例7: getKind

@DefinedBy(Api.LANGUAGE_MODEL)
public ElementKind getKind() {
    return ElementKind.TYPE_PARAMETER;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:Symbol.java


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