Java Code Examples for javax.lang.model.element.ExecutableElement#equals()
The following examples show how to use
javax.lang.model.element.ExecutableElement#equals() .
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: DeleteTransformer.java From netbeans with Apache License 2.0 | 6 votes |
private boolean isMatch(Element element, Element elementToFind) { if(element == null) { return false; } if(allMethods == null || element.getKind() != ElementKind.METHOD) { return element.equals(elementToFind); } else { for (ElementHandle<ExecutableElement> mh: allMethods) { ExecutableElement baseMethod = mh.resolve(workingCopy); if (baseMethod==null) { Logger.getLogger("org.netbeans.modules.refactoring.java").log(Level.INFO, "DeleteTransformer cannot resolve {0}", mh); continue; } if (baseMethod.equals(element) || workingCopy.getElements().overrides((ExecutableElement)element, baseMethod, workingCopy.getElementUtilities().enclosingTypeElement(baseMethod))) { return true; } } } return false; }
Example 2
Source File: MethodTreeNode.java From netbeans with Apache License 2.0 | 6 votes |
boolean overridesMethod( ExecutableElement element, CompilationController controller ) { ExecutableElement exec = getElementHandle().resolve(controller); if ( exec == null ){ return false; } ExecutableElement overriddenMethod = exec; while ( true ){ overriddenMethod = controller.getElementUtilities().getOverriddenMethod(overriddenMethod); if ( overriddenMethod == null ){ break; } if ( overriddenMethod.equals( element )){ return true; } } return false; }
Example 3
Source File: AutoOneOfProcessor.java From auto with Apache License 2.0 | 6 votes |
private void validateMethods( TypeElement type, ImmutableSet<ExecutableElement> abstractMethods, ImmutableSet<ExecutableElement> propertyMethods, ExecutableElement kindGetter) { for (ExecutableElement method : abstractMethods) { if (propertyMethods.contains(method)) { checkReturnType(type, method); } else if (!method.equals(kindGetter) && objectMethodToOverride(method) == ObjectMethod.NONE) { // This could reasonably be an error, were it not for an Eclipse bug in // ElementUtils.override that sometimes fails to recognize that one method overrides // another, and therefore leaves us with both an abstract method and the subclass method // that overrides it. This shows up in AutoValueTest.LukesBase for example. // The compilation will fail anyway because the generated concrete classes won't // implement this alien method. errorReporter() .reportWarning( method, "Abstract methods in @AutoOneOf classes must have no parameters"); } } errorReporter().abortIfAnyError(); }
Example 4
Source File: PropertyRefFinder.java From netbeans with Apache License 2.0 | 5 votes |
private boolean isSameOrOverrides(ExecutableElement m1, Collection<ExecutableElement> methods) { for (ExecutableElement method : methods) { if (m1.equals(method) || cc.getElements().overrides(m1, method, (TypeElement) m1.getEnclosingElement())) { return true; } } return false; }
Example 5
Source File: AsyncConverter.java From netbeans with Apache License 2.0 | 5 votes |
private String findFreeName( String name,Element enclosingElement, Element havingName) { for(ExecutableElement method: ElementFilter.methodsIn(enclosingElement.getEnclosedElements())) { if (method.equals(havingName)){ continue; } if ( method.getSimpleName().contentEquals(name)){ return findFreeName(name+1,enclosingElement, havingName); } } return name; }
Example 6
Source File: FieldInjectionPointLogic.java From netbeans with Apache License 2.0 | 5 votes |
private boolean collectSpecializes( Element productionElement, ExecutableElement element, WebBeansModelImplementation model, Set<Element> probableSpecializes, Set<Element> specializeElements ) { ElementUtilities elementUtilities = model.getHelper().getCompilationController().getElementUtilities(); if ( !elementUtilities.overridesMethod(element)){ return false; } ExecutableElement overriddenMethod = elementUtilities. getOverriddenMethod( element); if ( overriddenMethod == null ){ return false; } if (!AnnotationObjectProvider.hasSpecializes(element, model.getHelper())){ return false; } probableSpecializes.add( element); if( overriddenMethod.equals( productionElement ) || specializeElements.contains( productionElement)) { return true; } else { return collectSpecializes(productionElement, overriddenMethod, model, probableSpecializes, specializeElements); } }
Example 7
Source File: JavaEnvironment.java From j2cl with Apache License 2.0 | 5 votes |
boolean isOrOverridesJsFunctionMethod(ExecutableElement methodBinding) { Element declaringType = methodBinding.getEnclosingElement(); if (JsInteropUtils.isJsFunction(declaringType) && methodBinding.equals( getFunctionalInterfaceMethodDecl(declaringType.asType()).baseSymbol())) { return true; } for (MethodSymbol overriddenMethodBinding : getOverriddenMethods(methodBinding)) { if (isOrOverridesJsFunctionMethod(overriddenMethodBinding)) { return true; } } return false; }
Example 8
Source File: Utils.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * @param e1 the first method to compare. * @param e2 the second method to compare. * @return true if member1 overrides/hides or is overriden/hidden by member2. */ public boolean executableMembersEqual(ExecutableElement e1, ExecutableElement e2) { // TODO: investigate if Elements.hides(..) will work here. if (isStatic(e1) && isStatic(e2)) { List<? extends VariableElement> parameters1 = e1.getParameters(); List<? extends VariableElement> parameters2 = e2.getParameters(); if (e1.getSimpleName().equals(e2.getSimpleName()) && parameters1.size() == parameters2.size()) { int j; for (j = 0 ; j < parameters1.size(); j++) { VariableElement v1 = parameters1.get(j); VariableElement v2 = parameters2.get(j); String t1 = getTypeName(v1.asType(), true); String t2 = getTypeName(v2.asType(), true); if (!(t1.equals(t2) || isTypeVariable(v1.asType()) || isTypeVariable(v2.asType()))) { break; } } if (j == parameters1.size()) { return true; } } return false; } else { return elementUtils.overrides(e1, e2, getEnclosingTypeElement(e1)) || elementUtils.overrides(e2, e1, getEnclosingTypeElement(e2)) || e1.equals(e2); } }
Example 9
Source File: ELTypeUtilities.java From netbeans with Apache License 2.0 | 4 votes |
public static TypeMirror getReturnTypeForGenericClass(CompilationContext info, final ExecutableElement method, ELElement elElement, List<Node> rootToNode) { Node node = null; for (int i = rootToNode.size() - 1; i > 0; i--) { node = rootToNode.get(i); if (node instanceof AstIdentifier) { break; } } if (node != null) { Element element = ELTypeUtilities.resolveElement(info, elElement, node); if (element == null) { return method.getReturnType(); } TypeMirror type = element.asType(); // interfaces are at the end of the List - first parameter has to be superclass TypeMirror directSupertype = info.info().getTypes().directSupertypes(type).get(0); if (directSupertype instanceof DeclaredType) { DeclaredType declaredType = (DeclaredType) directSupertype; // index of involved type argument int indexOfTypeArgument = -1; // list of all type arguments List<? extends TypeMirror> typeArguments = declaredType.getTypeArguments(); // search for the same method in the generic class for (Element enclosedElement : declaredType.asElement().getEnclosedElements()) { if (method.equals(enclosedElement)) { TypeMirror returnType = ((ExecutableElement) enclosedElement).getReturnType(); // get index of type argument which is returned by involved method indexOfTypeArgument = info.info().getElementUtilities().enclosingTypeElement(method). getTypeParameters().indexOf(((TypeVariable) returnType).asElement()); break; } } if (indexOfTypeArgument != -1 && indexOfTypeArgument < typeArguments.size()) { return typeArguments.get(indexOfTypeArgument); } } } return method.getReturnType(); }