本文整理汇总了Java中com.sun.tools.javac.code.Symbol.TypeSymbol类的典型用法代码示例。如果您正苦于以下问题:Java TypeSymbol类的具体用法?Java TypeSymbol怎么用?Java TypeSymbol使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TypeSymbol类属于com.sun.tools.javac.code.Symbol包,在下文中一共展示了TypeSymbol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitClassDef
import com.sun.tools.javac.code.Symbol.TypeSymbol; //导入依赖的package包/类
@Override
public void visitClassDef(JCClassDecl tree) {
TypeSymbol currentClassPrev = currentClass;
currentClass = tree.sym;
List<Pair<TypeSymbol, Symbol>> prevOuterThisStack = outerThisStack;
try {
if (currentClass != null) {
if (currentClass.hasOuterInstance())
outerThisDef(currentClass);
super.visitClassDef(tree);
}
} finally {
outerThisStack = prevOuterThisStack;
currentClass = currentClassPrev;
}
}
示例2: checkThis
import com.sun.tools.javac.code.Symbol.TypeSymbol; //导入依赖的package包/类
private void checkThis(DiagnosticPosition pos, TypeSymbol c) {
if (checkThis && currentClass != c) {
List<Pair<TypeSymbol, Symbol>> ots = outerThisStack;
if (ots.isEmpty()) {
log.error(pos, "no.encl.instance.of.type.in.scope", c); //NOI18N
return;
}
Pair<TypeSymbol, Symbol> ot = ots.head;
TypeSymbol otc = ot.fst;
while (otc != c) {
do {
ots = ots.tail;
if (ots.isEmpty()) {
log.error(pos, "no.encl.instance.of.type.in.scope", c); //NOI18N
return;
}
ot = ots.head;
} while (ot.snd != otc);
if (otc.owner.kind != Kinds.Kind.PCK && !otc.hasOuterInstance()) {
log.error(pos, "cant.ref.before.ctor.called", c); //NOI18N
return;
}
otc = ot.fst;
}
}
}
示例3: getTree
import com.sun.tools.javac.code.Symbol.TypeSymbol; //导入依赖的package包/类
public JCTree getTree(Element element) {
Symbol symbol = (Symbol) element;
TypeSymbol enclosing = symbol.enclClass();
Env<AttrContext> env = enter.getEnv(enclosing);
if (env == null)
return null;
JCClassDecl classNode = env.enclClass;
if (classNode != null) {
if (TreeInfo.symbolFor(classNode) == element)
return classNode;
for (JCTree node : classNode.getMembers())
if (TreeInfo.symbolFor(node) == element)
return node;
}
return null;
}
示例4: ClassType
import com.sun.tools.javac.code.Symbol.TypeSymbol; //导入依赖的package包/类
public ClassType(Type outer, List<Type> typarams, TypeSymbol tsym) {
super(CLASS, tsym);
this.outer_field = outer;
this.typarams_field = typarams;
this.allparams_field = null;
this.supertype_field = null;
this.interfaces_field = null;
/*
// this can happen during error recovery
assert
outer.isParameterized() ?
typarams.length() == tsym.type.typarams().length() :
outer.isRaw() ?
typarams.length() == 0 :
true;
*/
}
示例5: visitNewClass
import com.sun.tools.javac.code.Symbol.TypeSymbol; //导入依赖的package包/类
@Override
public void visitNewClass(JCNewClass tree) {
TypeSymbol def = tree.type.tsym;
boolean inReferencedClass = currentlyInClass(def);
boolean isLocal = def.isLocal();
if ((inReferencedClass && isLocal || lambdaNewClassFilter(context(), tree))) {
TranslationContext<?> localContext = context();
while (localContext != null) {
if (localContext.tree.getTag() == LAMBDA) {
((LambdaTranslationContext)localContext)
.addSymbol(tree.type.getEnclosingType().tsym, CAPTURED_THIS);
}
localContext = localContext.prev;
}
}
if (context() != null && !inReferencedClass && isLocal) {
LambdaTranslationContext lambdaContext = (LambdaTranslationContext)context();
captureLocalClassDefs(def, lambdaContext);
}
super.visitNewClass(tree);
}
示例6: getSymbols
import com.sun.tools.javac.code.Symbol.TypeSymbol; //导入依赖的package包/类
@Override
public Iterable<Symbol> getSymbols(final Filter<Symbol> sf, final LookupKind lookupKind) {
if (filterName != null)
return getSymbolsByName(filterName, sf, lookupKind);
try {
SymbolImporter si = new SymbolImporter(imp.staticImport) {
@Override
Iterable<Symbol> doLookup(TypeSymbol tsym) {
return tsym.members().getSymbols(sf, lookupKind);
}
};
List<Iterable<Symbol>> results =
si.importFrom((TypeSymbol) origin.owner, List.nil());
return () -> createFilterIterator(createCompoundIterator(results,
Iterable::iterator),
s -> filter.accepts(origin, s));
} catch (CompletionFailure cf) {
cfHandler.accept(imp, cf);
return Collections.emptyList();
}
}
示例7: getSymbolsByName
import com.sun.tools.javac.code.Symbol.TypeSymbol; //导入依赖的package包/类
@Override
public Iterable<Symbol> getSymbolsByName(final Name name,
final Filter<Symbol> sf,
final LookupKind lookupKind) {
if (filterName != null && filterName != name)
return Collections.emptyList();
try {
SymbolImporter si = new SymbolImporter(imp.staticImport) {
@Override
Iterable<Symbol> doLookup(TypeSymbol tsym) {
return tsym.members().getSymbolsByName(name, sf, lookupKind);
}
};
List<Iterable<Symbol>> results =
si.importFrom((TypeSymbol) origin.owner, List.nil());
return () -> createFilterIterator(createCompoundIterator(results,
Iterable::iterator),
s -> filter.accepts(origin, s));
} catch (CompletionFailure cf) {
cfHandler.accept(imp, cf);
return Collections.emptyList();
}
}
示例8: enterClass
import com.sun.tools.javac.code.Symbol.TypeSymbol; //导入依赖的package包/类
/** Create a new toplevel or member class symbol with given name
* and owner and enter in `classes' unless already there.
*/
public ClassSymbol enterClass(ModuleSymbol msym, Name name, TypeSymbol owner) {
Assert.checkNonNull(msym);
Name flatname = TypeSymbol.formFlatName(name, owner);
ClassSymbol c = getClass(msym, flatname);
if (c == null) {
c = defineClass(name, owner);
doEnterClass(msym, c);
} else if ((c.name != name || c.owner != owner) && owner.kind == TYP && c.owner.kind == PCK) {
// reassign fields of classes that might have been loaded with
// their flat names.
c.owner.members().remove(c);
c.name = name;
c.owner = owner;
c.fullname = ClassSymbol.formFullName(name, owner);
}
return c;
}
示例9: annotationTargets
import com.sun.tools.javac.code.Symbol.TypeSymbol; //导入依赖的package包/类
public List<Attribute> annotationTargets(TypeSymbol tsym) {
Attribute.Compound atTarget = tsym.getAnnotationTypeMetadata().getTarget();
if (atTarget == null) {
return null;
}
Attribute atValue = atTarget.member(names.value);
if (!(atValue instanceof Attribute.Array)) {
return null;
}
List<Attribute> targets = ((Array)atValue).getValue();
if (targets.stream().anyMatch(a -> !(a instanceof Attribute.Enum))) {
return null;
}
return targets;
}
示例10: visitNewClass
import com.sun.tools.javac.code.Symbol.TypeSymbol; //导入依赖的package包/类
@Override
public void visitNewClass(JCNewClass tree) {
TypeSymbol def = tree.type.tsym;
boolean inReferencedClass = currentlyInClass(def);
boolean isLocal = def.isLocal();
if ((inReferencedClass && isLocal || lambdaNewClassFilter(context(), tree))) {
TranslationContext<?> localContext = context();
final TypeSymbol outerInstanceSymbol = tree.type.getEnclosingType().tsym;
while (localContext != null && !localContext.owner.isStatic()) {
if (localContext.tree.hasTag(LAMBDA)) {
if (outerInstanceSymbol != null) {
JCTree block = capturedDecl(localContext.depth, outerInstanceSymbol);
if (block == null) break;
}
((LambdaTranslationContext)localContext)
.addSymbol(outerInstanceSymbol, CAPTURED_THIS);
}
localContext = localContext.prev;
}
}
if (context() != null && !inReferencedClass && isLocal) {
LambdaTranslationContext lambdaContext = (LambdaTranslationContext)context();
captureLocalClassDefs(def, lambdaContext);
}
super.visitNewClass(tree);
}
示例11: getSymbols
import com.sun.tools.javac.code.Symbol.TypeSymbol; //导入依赖的package包/类
@Override
public Iterable<Symbol> getSymbols(final Filter<Symbol> sf, final LookupKind lookupKind) {
if (filterName != null)
return getSymbolsByName(filterName, sf, lookupKind);
try {
SymbolImporter si = new SymbolImporter(imp.staticImport) {
@Override
Iterable<Symbol> doLookup(TypeSymbol tsym) {
return tsym.members().getSymbols(sf, lookupKind);
}
};
return si.importFrom((TypeSymbol) origin.owner) :: iterator;
} catch (CompletionFailure cf) {
cfHandler.accept(imp, cf);
return Collections.emptyList();
}
}
示例12: getSymbolsByName
import com.sun.tools.javac.code.Symbol.TypeSymbol; //导入依赖的package包/类
@Override
public Iterable<Symbol> getSymbolsByName(final Name name,
final Filter<Symbol> sf,
final LookupKind lookupKind) {
if (filterName != null && filterName != name)
return Collections.emptyList();
try {
SymbolImporter si = new SymbolImporter(imp.staticImport) {
@Override
Iterable<Symbol> doLookup(TypeSymbol tsym) {
return tsym.members().getSymbolsByName(name, sf, lookupKind);
}
};
return si.importFrom((TypeSymbol) origin.owner) :: iterator;
} catch (CompletionFailure cf) {
cfHandler.accept(imp, cf);
return Collections.emptyList();
}
}
示例13: importFrom
import com.sun.tools.javac.code.Symbol.TypeSymbol; //导入依赖的package包/类
Stream<Symbol> importFrom(TypeSymbol tsym) {
if (tsym == null || !processed.add(tsym))
return Stream.empty();
Stream<Symbol> result = Stream.empty();
if (inspectSuperTypes) {
// also import inherited names
result = importFrom(types.supertype(tsym.type).tsym);
for (Type t : types.interfaces(tsym.type))
result = Stream.concat(importFrom(t.tsym), result);
}
return Stream.concat(StreamSupport.stream(doLookup(tsym).spliterator(), false)
.filter(s -> filter.accepts(origin, s)),
result);
}
示例14: visitTypeVar
import com.sun.tools.javac.code.Symbol.TypeSymbol; //导入依赖的package包/类
@Override
public UTypeVar visitTypeVar(TypeVar type, Void v) {
/*
* In order to handle recursively bounded type variables without a stack overflow, we first
* cache a type var with no bounds, then we template the bounds.
*/
TypeSymbol tsym = type.asElement();
if (typeVariables.containsKey(tsym)) {
return typeVariables.get(tsym);
}
UTypeVar var = UTypeVar.create(tsym.getSimpleName().toString());
typeVariables.put(tsym, var); // so the type variable can be used recursively in the bounds
var.setLowerBound(type.getLowerBound().accept(this, null));
var.setUpperBound(type.getUpperBound().accept(this, null));
return var;
}
示例15: knownNonNullMethod
import com.sun.tools.javac.code.Symbol.TypeSymbol; //导入依赖的package包/类
private static boolean knownNonNullMethod(
MethodSymbol methodSymbol, ClassSymbol clazzSymbol, @Nullable Types types) {
if (types == null) {
return false;
}
// Proto getters are not null
if (methodSymbol.name.toString().startsWith("get")
&& methodSymbol.params().isEmpty()
&& !methodSymbol.isStatic()) {
Type type = clazzSymbol.type;
while (type != null) {
TypeSymbol typeSymbol = type.asElement();
if (typeSymbol == null) {
break;
}
if (typeSymbol
.getQualifiedName()
.contentEquals("com.google.protobuf.AbstractMessageLite")) {
return true;
}
type = types.supertype(type);
}
}
return false;
}