当前位置: 首页>>代码示例>>Java>>正文


Java TypeSymbol类代码示例

本文整理汇总了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;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:PostFlowAnalysis.java

示例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;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:PostFlowAnalysis.java

示例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;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:17,代码来源:JavacTrees.java

示例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;
    */
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:18,代码来源:Type.java

示例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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:LambdaToMethod.java

示例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();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:Scope.java

示例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();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:Scope.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:Symtab.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:TypeAnnotations.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:LambdaToMethod.java

示例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();
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:18,代码来源:Scope.java

示例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();
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:20,代码来源:Scope.java

示例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);
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:18,代码来源:Scope.java

示例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;
}
 
开发者ID:sivakumar-kailasam,项目名称:refactor-faster,代码行数:17,代码来源:UTemplater.java

示例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;
}
 
开发者ID:google,项目名称:error-prone,代码行数:27,代码来源:NullnessPropagationTransfer.java


注:本文中的com.sun.tools.javac.code.Symbol.TypeSymbol类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。