use of com.sun.tools.javac.code.Symbol in project ceylon-compiler by ceylon.
the class Resolve method findIdentInType.
/** Find an identifier among the members of a given type `site'.
* @param env The current environment.
* @param site The type containing the symbol to be found.
* @param name The identifier's name.
* @param kind Indicates the possible symbol kinds
* (a subset of VAL, TYP).
*/
Symbol findIdentInType(Env<AttrContext> env, Type site, Name name, int kind) {
Symbol bestSoFar = typeNotFound;
Symbol sym;
if ((kind & VAR) != 0) {
sym = findField(env, site, name, site.tsym);
if (sym.exists())
return sym;
else if (sym.kind < bestSoFar.kind)
bestSoFar = sym;
}
if ((kind & TYP) != 0) {
sym = findMemberType(env, site, name, site.tsym);
if (sym.exists())
return sym;
else if (sym.kind < bestSoFar.kind)
bestSoFar = sym;
}
return bestSoFar;
}
use of com.sun.tools.javac.code.Symbol in project ceylon-compiler by ceylon.
the class Resolve method resolveConstructor.
/** Resolve constructor.
* @param pos The position to use for error reporting.
* @param env The environment current at the constructor invocation.
* @param site The type of class for which a constructor is searched.
* @param argtypes The types of the constructor invocation's value
* arguments.
* @param typeargtypes The types of the constructor invocation's type
* arguments.
*/
Symbol resolveConstructor(DiagnosticPosition pos, Env<AttrContext> env, Type site, List<Type> argtypes, List<Type> typeargtypes) {
Symbol sym = startResolution();
List<MethodResolutionPhase> steps = methodResolutionSteps;
while (steps.nonEmpty() && steps.head.isApplicable(boxingEnabled, varargsEnabled) && sym.kind >= ERRONEOUS) {
currentStep = steps.head;
sym = resolveConstructor(pos, env, site, argtypes, typeargtypes, steps.head.isBoxingRequired(), env.info.varArgs = steps.head.isVarargsRequired());
methodResolutionCache.put(steps.head, sym);
steps = steps.tail;
}
if (sym.kind >= AMBIGUOUS) {
//if nothing is found return the 'first' error
MethodResolutionPhase errPhase = firstErroneousResolutionPhase();
sym = access(methodResolutionCache.get(errPhase), pos, site, names.init, true, argtypes, typeargtypes);
env.info.varArgs = errPhase.isVarargsRequired();
}
return sym;
}
use of com.sun.tools.javac.code.Symbol in project ceylon-compiler by ceylon.
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 com.sun.tools.javac.code.Symbol in project ceylon-compiler by ceylon.
the class JavacElements method getAnnotation.
/**
* An internal-use utility that creates a reified annotation.
* This overloaded version take annotation inheritance into account.
*/
public static <A extends Annotation> A getAnnotation(ClassSymbol annotated, Class<A> annoType) {
boolean inherited = annoType.isAnnotationPresent(Inherited.class);
A result = null;
while (annotated.name != annotated.name.table.names.java_lang_Object) {
result = getAnnotation((Symbol) annotated, annoType);
if (result != null || !inherited)
break;
Type sup = annotated.getSuperclass();
if (sup.tag != TypeTags.CLASS || sup.isErroneous())
break;
annotated = (ClassSymbol) sup.tsym;
}
return result;
}
use of com.sun.tools.javac.code.Symbol in project ceylon-compiler by ceylon.
the class JavacElements method matchAnnoToTree.
/**
* Returns the tree for an annotation given the annotated element
* and the element's own tree. Returns null if the tree cannot be found.
*/
private JCTree matchAnnoToTree(AnnotationMirror findme, Element e, JCTree tree) {
Symbol sym = cast(Symbol.class, e);
class Vis extends JCTree.Visitor {
List<JCAnnotation> result = null;
public void visitTopLevel(JCCompilationUnit tree) {
result = tree.packageAnnotations;
}
public void visitClassDef(JCClassDecl tree) {
result = tree.mods.annotations;
}
public void visitMethodDef(JCMethodDecl tree) {
result = tree.mods.annotations;
}
public void visitVarDef(JCVariableDecl tree) {
result = tree.mods.annotations;
}
}
Vis vis = new Vis();
tree.accept(vis);
if (vis.result == null)
return null;
return matchAnnoToTree(cast(Attribute.Compound.class, findme), sym.getAnnotationMirrors(), vis.result);
}
Aggregations