Ejemplo n.º 1
0
 @Override
 @Nullable
 protected Unifier defaultAction(Tree node, @Nullable Unifier unifier) {
   Symbol symbol = ASTHelpers.getSymbol(node);
   if (symbol != null
       && symbol.getEnclosingElement() != null
       && symbol
           .getEnclosingElement()
           .getQualifiedName()
           .contentEquals(classIdent().getQualifiedName())
       && symbol.getSimpleName().contentEquals(member())) {
     return memberType().unify(symbol.asType(), unifier);
   }
   return null;
 }
Ejemplo n.º 2
0
 /**
  * Returns the type of an element when that element is viewed as a member of, or otherwise
  * directly contained by, a given type. For example, when viewed as a member of the parameterized
  * type {@code Set<String>}, the {@code Set.add} method is an {@code ExecutableType} whose
  * parameter is of type {@code String}.
  *
  * @param containing the containing type
  * @param element the element
  * @return the type of the element as viewed from the containing type
  * @throws IllegalArgumentException if the element is not a valid one for the given type
  */
 public TypeMirror asMemberOf(DeclaredType containing, Element element) {
   Type site = (Type) containing;
   Symbol sym = (Symbol) element;
   if (types.asSuper(site, sym.getEnclosingElement()) == null)
     throw new IllegalArgumentException(sym + "@" + site);
   return types.memberType(site, sym);
 }