use of org.eclipse.ceylon.langtools.tools.javac.code.Symbol in project ceylon by eclipse.
the class Gen method setTypeAnnotationPositions.
private void setTypeAnnotationPositions(int treePos) {
MethodSymbol meth = code.meth;
boolean initOrClinit = code.meth.getKind() == org.eclipse.ceylon.javax.lang.model.element.ElementKind.CONSTRUCTOR || code.meth.getKind() == org.eclipse.ceylon.javax.lang.model.element.ElementKind.STATIC_INIT;
for (Attribute.TypeCompound ta : meth.getRawTypeAttributes()) {
if (ta.hasUnknownPosition())
ta.tryFixPosition();
if (ta.position.matchesPos(treePos))
ta.position.updatePosOffset(code.cp);
}
if (!initOrClinit)
return;
for (Attribute.TypeCompound ta : meth.owner.getRawTypeAttributes()) {
if (ta.hasUnknownPosition())
ta.tryFixPosition();
if (ta.position.matchesPos(treePos))
ta.position.updatePosOffset(code.cp);
}
ClassSymbol clazz = meth.enclClass();
for (Symbol s : new org.eclipse.ceylon.langtools.tools.javac.model.FilteredMemberList(clazz.members())) {
if (!s.getKind().isField())
continue;
for (Attribute.TypeCompound ta : s.getRawTypeAttributes()) {
if (ta.hasUnknownPosition())
ta.tryFixPosition();
if (ta.position.matchesPos(treePos))
ta.position.updatePosOffset(code.cp);
}
}
}
use of org.eclipse.ceylon.langtools.tools.javac.code.Symbol in project ceylon by eclipse.
the class JavacElements method hides.
public boolean hides(Element hiderEl, Element hideeEl) {
Symbol hider = cast(Symbol.class, hiderEl);
Symbol hidee = cast(Symbol.class, hideeEl);
// Names must match. Nothing hides itself (just try it).
if (hider == hidee || hider.kind != hidee.kind || hider.name != hidee.name) {
return false;
}
// Methods only hide methods with matching signatures.
if (hider.kind == Kinds.MTH) {
if (!hider.isStatic() || !types.isSubSignature(hider.type, hidee.type)) {
return false;
}
}
// Hider must be in a subclass of hidee's class.
// Note that if M1 hides M2, and M2 hides M3, and M3 is accessible
// in M1's class, then M1 and M2 both hide M3.
ClassSymbol hiderClass = hider.owner.enclClass();
ClassSymbol hideeClass = hidee.owner.enclClass();
if (hiderClass == null || hideeClass == null || !hiderClass.isSubClass(hideeClass, types)) {
return false;
}
// The method isInheritedIn is poorly named: it checks only access.
return hidee.isInheritedIn(hiderClass, types);
}
use of org.eclipse.ceylon.langtools.tools.javac.code.Symbol in project ceylon by eclipse.
the class JavacElements method getTreeAndTopLevel.
/**
* Returns the tree node and compilation unit corresponding to this
* element, or null if they can't be found.
*/
private Pair<JCTree, JCCompilationUnit> getTreeAndTopLevel(Element e) {
Symbol sym = cast(Symbol.class, e);
Env<AttrContext> enterEnv = getEnterEnv(sym);
if (enterEnv == null)
return null;
JCTree tree = TreeInfo.declarationFor(sym, enterEnv.tree);
if (tree == null || enterEnv.toplevel == null)
return null;
return new Pair<JCTree, JCCompilationUnit>(tree, enterEnv.toplevel);
}
use of org.eclipse.ceylon.langtools.tools.javac.code.Symbol in project ceylon by eclipse.
the class JavacElements method getAllMembers.
/**
* {@inheritDoc}
*/
public FilteredMemberList getAllMembers(TypeElement element) {
Symbol sym = cast(Symbol.class, element);
Scope scope = sym.members().dupUnshared();
List<Type> closure = types.closure(sym.asType());
for (Type t : closure) addMembers(scope, t);
return new FilteredMemberList(scope);
}
use of org.eclipse.ceylon.langtools.tools.javac.code.Symbol in project ceylon by eclipse.
the class JavacTypes method asMemberOf.
/**
* 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);
}
Aggregations