當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。