Java Code Examples for javax.lang.model.element.ElementKind#TYPE_PARAMETER
The following examples show how to use
javax.lang.model.element.ElementKind#TYPE_PARAMETER .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WhereUsedPanelVariable.java From netbeans with Apache License 2.0 | 6 votes |
@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); } }); }
Example 2
Source File: Names.java From featured with Apache License 2.0 | 6 votes |
private TypeName getFeatureParameterTypeVariableName(DeclaredType featureType, int featureParameterIndex) { Element paramElem = getFeatureParameterElement(featureType, featureParameterIndex); if (paramElem == null) { return null; } if (paramElem.getKind() == ElementKind.TYPE_PARAMETER) { return TypeVariableName.get((TypeVariable) paramElem.asType()); } else if (paramElem.getKind() == ElementKind.CLASS) { return TypeName.get(paramElem.asType()); } return null; }
Example 3
Source File: Checker.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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); } } }
Example 4
Source File: Checker.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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); } } }
Example 5
Source File: TreeBackedTrees.java From buck with Apache License 2.0 | 5 votes |
@Override @Nullable public Tree getTree(Element element) { if (element.getKind() == ElementKind.TYPE_PARAMETER) { // This is a weird javac behavior that we're emulating. return null; } TreePath path = getPath(element); if (path == null) { return null; } return path.getLeaf(); }
Example 6
Source File: Checker.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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); } } }
Example 7
Source File: Names.java From featured with Apache License 2.0 | 5 votes |
private TypeVariableName getParameterTypeVariableName(FeatureNode featureNode, int parameterIndex) { TypeMirror type = featureNode.getElement().asType(); if (type.getKind() != TypeKind.DECLARED) { throw new IllegalArgumentException("FeatureNode type is not supported: " + featureNode); } Element paramElem = getFeatureParameterElement((DeclaredType) type, parameterIndex); if (paramElem.getKind() == ElementKind.TYPE_PARAMETER) { return TypeVariableName.get((TypeVariable) paramElem.asType()); } throw new IllegalArgumentException( "Expecting paramElem of kind TYPE_PARAMETER, while received" + paramElem); }
Example 8
Source File: Names.java From featured with Apache License 2.0 | 5 votes |
private ClassName getFeatureParameterClass(FeatureNode featureNode, int parameterIndex) { TypeMirror superClass = featureNode.getElement().getSuperclass(); if (superClass.getKind() != TypeKind.DECLARED) { throw new IllegalArgumentException( "Check model validator. It must check feature super class."); } Element argElem = getFeatureParameterElement((DeclaredType) superClass, parameterIndex); if (argElem == null || argElem.getKind() == ElementKind.TYPE_PARAMETER) { return null; } return ClassName.get((TypeElement) argElem); }
Example 9
Source File: Checker.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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); } } }
Example 10
Source File: Checker.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
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); } } }
Example 11
Source File: SourceCodeAnalysisImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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; } }
Example 12
Source File: Checker.java From hottub with GNU General Public License v2.0 | 5 votes |
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); } } }
Example 13
Source File: Checker.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
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); } } }
Example 14
Source File: TypeParameterElementImpl.java From FreeBuilder with Apache License 2.0 | 4 votes |
@Override public ElementKind getKind() { return ElementKind.TYPE_PARAMETER; }
Example 15
Source File: ElementUtil.java From j2objc with Apache License 2.0 | 4 votes |
public static boolean isTypeParameterElement(Element e) { return e.getKind() == ElementKind.TYPE_PARAMETER; }
Example 16
Source File: Symbol.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@DefinedBy(Api.LANGUAGE_MODEL) public ElementKind getKind() { return ElementKind.TYPE_PARAMETER; }
Example 17
Source File: GenericElementParameter.java From FreeBuilder with Apache License 2.0 | 4 votes |
@Override public ElementKind getKind() { return ElementKind.TYPE_PARAMETER; }
Example 18
Source File: TypeParameterElementImpl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public ElementKind getKind() { return ElementKind.TYPE_PARAMETER; }
Example 19
Source File: InstantRenamePerformer.java From netbeans with Apache License 2.0 | 4 votes |
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; }
Example 20
Source File: PullUpTransformer.java From netbeans with Apache License 2.0 | 4 votes |
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; }