Java Code Examples for javax.lang.model.util.Elements#hides()

The following examples show how to use javax.lang.model.util.Elements#hides() . 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: ElementUtilities.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private boolean isHidden(Element member, List<? extends Element> members, Elements elements, Types types) {
    for (ListIterator<? extends Element> it = members.listIterator(); it.hasNext();) {
        Element hider = it.next();
        if (hider == member)
            return true;
        if (hider.getSimpleName().contentEquals(member.getSimpleName())) {
            if (elements.hides(member, hider)) {
                it.remove();
            } else {
                if (member instanceof VariableElement && hider instanceof VariableElement
                        && (!member.getKind().isField() || hider.getKind().isField()))
                    return true;
                TypeMirror memberType = member.asType();
                TypeMirror hiderType = hider.asType();
                if (memberType.getKind() == TypeKind.EXECUTABLE && hiderType.getKind() == TypeKind.EXECUTABLE) {
                    if (types.isSubsignature((ExecutableType)hiderType, (ExecutableType)memberType))
                        return true;
                } else {
                    return false;
                }
            }
        }
    }
    return false;
}
 
Example 2
Source File: VarUsageVisitor.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private boolean isMethodAvailable(TypeElement subTypeElement, 
        ExecutableElement execElem, TypeElement superTypeElement) {
    Elements elements = workingCopy.getElements();
    List<? extends Element> memberElements = elements.getAllMembers(superTypeElement);
    for (Element elem : memberElements) {
        if(ElementKind.METHOD.equals(elem.getKind())){
            if(execElem.getModifiers().contains(Modifier.STATIC) && elements.hides(execElem, elem)){
                return true;
            }else{
                if(execElem.equals(elem) || elements.overrides(execElem, (ExecutableElement)elem, 
                        subTypeElement)){
                    return true;
                }
            }
        }
    }

    return false;
}
 
Example 3
Source File: UseSuperTypeRefactoringPlugin.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private boolean hidesSupTypeMember(Element methElement, TypeElement superTypeElement) {
    Elements elements = workingCopy.getElements();
    List<? extends Element> containedElements = elements.getAllMembers(superTypeElement);
    for (Element elem : containedElements) {
        boolean isPresentInSuperType = methElement.equals(elem) || 
                elements.hides(methElement, elem);
        if ((elem != null) && isStatic(elem) && isPresentInSuperType) {
            return true;
        }
    }
    return false;
}
 
Example 4
Source File: VarUsageVisitor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private boolean isHidingMember(TypeElement subTypeElement, Element variableElement, 
        TypeElement superTypeElement) {
    //TODO: We do not handle nested types yet (includes enums)
    Elements elements = workingCopy.getElements();
    List<? extends Element> memberElements = elements.getAllMembers(superTypeElement);
    for (Element elem : memberElements) {
        if(variableElement.equals(elem) || elements.hides(variableElement, elem)){
            return true;
        }
    }
    return false;
}