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


Java Symbol类代码示例

本文整理汇总了Java中com.sun.tools.javac.code.Symbol的典型用法代码示例。如果您正苦于以下问题:Java Symbol类的具体用法?Java Symbol怎么用?Java Symbol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Symbol类属于com.sun.tools.javac.code包,在下文中一共展示了Symbol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isExcludedClass

import com.sun.tools.javac.code.Symbol; //导入依赖的package包/类
private boolean isExcludedClass(Symbol.ClassSymbol classSymbol, VisitorState state) {
  String className = classSymbol.getQualifiedName().toString();
  if (config.isExcludedClass(className)) {
    return true;
  }
  if (!config.fromAnnotatedPackage(className)) {
    return true;
  }
  // check annotations
  for (AnnotationMirror anno : classSymbol.getAnnotationMirrors()) {
    if (config.isExcludedClassAnnotation(anno.getAnnotationType().toString())) {
      return true;
    }
  }
  return false;
}
 
开发者ID:uber,项目名称:NullAway,代码行数:17,代码来源:NullAway.java

示例2: DaoEnv

import com.sun.tools.javac.code.Symbol; //导入依赖的package包/类
public DaoEnv(DaoGen daoGen,Symbol.ClassSymbol classSymbol) {
    this.daoGen = daoGen;
    createTime = daoGen.createTime();
    updateTime = daoGen.updateTime();
    daoClassName = classSymbol.getSimpleName().toString();
    if (!daoGen.tableName().isEmpty())
        tableName = daoGen.tablePrefix()+daoGen.tableName();
        //"Activity{Dao}"
    else tableName = daoGen.tablePrefix()+daoClassName.subSequence(0,daoClassName.length()-3);
    if (classSymbol.getInterfaces() != null){
        classSymbol.getInterfaces().forEach(i->{
            if (i.getTypeArguments()!=null && !i.getTypeArguments().isEmpty()){
                if (i.getTypeArguments().size()> 1 || typeParameter != null) throw new RuntimeException("不支持多个类型参数");
                typeParameter = i.getTypeArguments().get(0);
            }
        });
    }
}
 
开发者ID:frankelau,项目名称:pndao,代码行数:19,代码来源:DaoEnv.java

示例3: getMember

import com.sun.tools.javac.code.Symbol; //导入依赖的package包/类
public <T extends Symbol> List<T> getMember(Class<T> type, ElementKind kind, Symbol classSymbol) {
    List<T> results = Lists.newArrayList();
    if (classSymbol.type == null || classSymbol.type.isPrimitiveOrVoid()) {
        return results;
    }
    for (Type t : types.closure(classSymbol.type)) {
        Scope scope = t.tsym.members();
        if (scope == null) continue;
        scope.getElements(symbol -> symbol.getKind() == kind)
                .forEach(s->results.add(type.cast(s)));
    }
    if (classSymbol.owner != null && classSymbol != classSymbol.owner
            && classSymbol.owner instanceof Symbol.ClassSymbol) {
        results.addAll(getMember(type, kind, classSymbol.owner));
    }
    if (classSymbol.type.getEnclosingType() != null && classSymbol.hasOuterInstance()) {
        results.addAll(getMember(type, kind, classSymbol.type.getEnclosingType().asElement()));
    }
    return results;
}
 
开发者ID:frankelau,项目名称:pndao,代码行数:21,代码来源:DaoGenHelper.java

示例4: addAllClasses

import com.sun.tools.javac.code.Symbol; //导入依赖的package包/类
/**
 * Adds all inner classes of this class, and their inner classes recursively, to the list
 */
private void addAllClasses(Collection<TypeElement> list, TypeElement typeElement, boolean filtered) {
    ClassSymbol klass = (ClassSymbol)typeElement;
    try {
        // eliminate needless checking, do this first.
        if (list.contains(klass)) return;
        // ignore classes with invalid Java class names
        if (!JavadocTool.isValidClassName(klass.name.toString())) return;
        if (filtered && !isTypeElementSelected(klass)) return;
        list.add(klass);
        for (Symbol sym : klass.members().getSymbols(NON_RECURSIVE)) {
            if (sym != null && sym.kind == Kind.TYP) {
                ClassSymbol s = (ClassSymbol)sym;
                addAllClasses(list, s, filtered);
            }
        }
    } catch (CompletionFailure e) {
        if (e.getMessage() != null)
            messager.printWarning(e.getMessage());
        else
            messager.printWarningUsingKey("main.unexpected.exception", e);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:ElementsTable.java

示例5: isStructuralInterface

import com.sun.tools.javac.code.Symbol; //导入依赖的package包/类
public static boolean isStructuralInterface( TypeProcessor tp, Symbol sym )
{
  if( sym == null || !sym.isInterface() || !sym.hasAnnotations() )
  {
    return false;
  }

  // use the raw type
  Type type = tp.getTypes().erasure( sym.type );
  sym = type.tsym;

  for( Attribute.Compound annotation : sym.getAnnotationMirrors() )
  {
    if( annotation.type.toString().equals( Structural.class.getName() ) )
    {
      return true;
    }
  }
  return false;
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:21,代码来源:TypeUtil.java

示例6: visitNewClass

import com.sun.tools.javac.code.Symbol; //导入依赖的package包/类
@Override
@CheckForNull
public Void visitNewClass(@NonNull final NewClassTree node, @NonNull final Map<Pair<BinaryName,String>, UsagesData<String>> p) {
    final Symbol sym = ((JCTree.JCNewClass)node).constructor;
    if (sym != null) {
        final Symbol owner = sym.getEnclosingElement();
        if (owner != null && owner.getKind().isClass()) {
            addUsage(
                owner,
                activeClass.peek(),
                p,
                ClassIndexImpl.UsageType.METHOD_REFERENCE);
        }
    }
    return super.visitNewClass (node,p);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:SourceAnalyzerFactory.java

示例7: referenceKind

import com.sun.tools.javac.code.Symbol; //导入依赖的package包/类
/**
 * Get the opcode associated with this method reference
 */
private int referenceKind(Symbol refSym) {
    if (refSym.isConstructor()) {
        return ClassFile.REF_newInvokeSpecial;
    } else {
        if (refSym.isStatic()) {
            return ClassFile.REF_invokeStatic;
        } else if ((refSym.flags() & PRIVATE) != 0) {
            return ClassFile.REF_invokeSpecial;
        } else if (refSym.enclClass().isInterface()) {
            return ClassFile.REF_invokeInterface;
        } else {
            return ClassFile.REF_invokeVirtual;
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:LambdaToMethod.java

示例8: iterator

import com.sun.tools.javac.code.Symbol; //导入依赖的package包/类
public Iterator<Symbol> iterator() {
    return new Iterator<Symbol>() {

        /** The next entry to examine, or null if none. */
        private Scope.Entry nextEntry = scope.elems;

        private boolean hasNextForSure = false;

        public boolean hasNext() {
            if (hasNextForSure) {
                return true;
            }
            while (nextEntry != null && unwanted(nextEntry.sym)) {
                nextEntry = nextEntry.sibling;
            }
            hasNextForSure = (nextEntry != null);
            return hasNextForSure;
        }

        public Symbol next() {
            if (hasNext()) {
                Symbol result = nextEntry.sym;
                nextEntry = nextEntry.sibling;
                hasNextForSure = false;
                return result;
            } else {
                throw new NoSuchElementException();
            }
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:36,代码来源:FilteredMemberList.java

示例9: checkThis

import com.sun.tools.javac.code.Symbol; //导入依赖的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

示例10: preprocessArgument

import com.sun.tools.javac.code.Symbol; //导入依赖的package包/类
/**
 * Preprocess a diagnostic argument. A type/symbol argument is
 * preprocessed by specialized type/symbol preprocessors.
 *
 * @param arg the argument to be translated
 */
protected void preprocessArgument(Object arg) {
    if (arg instanceof Type) {
        preprocessType((Type)arg);
    }
    else if (arg instanceof Symbol) {
        preprocessSymbol((Symbol)arg);
    }
    else if (arg instanceof JCDiagnostic) {
        preprocessDiagnostic((JCDiagnostic)arg);
    }
    else if (arg instanceof Iterable<?>) {
        for (Object o : (Iterable<?>)arg) {
            preprocessArgument(o);
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:RichDiagnosticFormatter.java

示例11: process

import com.sun.tools.javac.code.Symbol; //导入依赖的package包/类
@Override
void process(Diagnostic<? extends JavaFileObject> diagnostic) {
    Element siteSym = getSiteSym(diagnostic);
    if (siteSym.getSimpleName().length() != 0 &&
            ((Symbol)siteSym).outermostClass().getAnnotation(TraceResolve.class) == null) {
        return;
    }
    int candidateIdx = 0;
    for (JCDiagnostic d : subDiagnostics(diagnostic)) {
        boolean isMostSpecific = candidateIdx++ == mostSpecific(diagnostic);
        VerboseCandidateSubdiagProcessor subProc =
                new VerboseCandidateSubdiagProcessor(isMostSpecific, phase(diagnostic), success(diagnostic));
        if (subProc.matches(d)) {
            subProc.process(d);
        } else {
            throw new AssertionError("Bad subdiagnostic: " + d.getCode());
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:ResolveHarness.java

示例12: getTree

import com.sun.tools.javac.code.Symbol; //导入依赖的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

示例13: alreadyDefinedIn

import com.sun.tools.javac.code.Symbol; //导入依赖的package包/类
public boolean alreadyDefinedIn(CharSequence name, TypeMirror returnType, List<TypeMirror> paramTypes, TypeElement enclClass) {
    ClassSymbol clazz = (ClassSymbol)enclClass;
    Scope scope = clazz.members();
    Name n = names.fromString(name.toString());
    ListBuffer<Type> buff = new ListBuffer<>();
    for (TypeMirror tm : paramTypes) {
        buff.append((Type)tm);
    }
    for (Symbol sym : scope.getSymbolsByName(n, Scope.LookupKind.NON_RECURSIVE)) {
        if(sym.type instanceof ExecutableType &&
                jctypes.containsTypeEquivalent(sym.type.asMethodType().getParameterTypes(), buff.toList()) &&
                jctypes.isSameType(sym.type.asMethodType().getReturnType(), (Type)returnType))
            return true;
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ElementsService.java

示例14: visitMethodInvocation

import com.sun.tools.javac.code.Symbol; //导入依赖的package包/类
@Override
public Void visitMethodInvocation(MethodInvocationTree node, Void p) {
    super.visitMethodInvocation(node, p);
    JCMethodInvocation apply = (JCMethodInvocation)node;
    JCIdent ident = (JCIdent)apply.meth;
    Symbol oldSym = ident.sym;
    if (!oldSym.isConstructor()) {
        Object[] staticArgs = new Object[arity.arity];
        for (int i = 0; i < arity.arity ; i++) {
            staticArgs[i] = saks[i].getValue(syms, names, types);
        }
        ident.sym = new Symbol.DynamicMethodSymbol(oldSym.name,
                oldSym.owner, REF_invokeStatic, bsm, oldSym.type, staticArgs);
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:TestInvokeDynamic.java

示例15: qualIdentFor

import com.sun.tools.javac.code.Symbol; //导入依赖的package包/类
private ExpressionTree qualIdentFor(Element e) {
    TreeMaker tm = copy.getTreeMaker();
    if (e.getKind() == ElementKind.PACKAGE) {
        String name = ((PackageElement)e).getQualifiedName().toString();
        if (e instanceof Symbol) {
            int lastDot = name.lastIndexOf('.');
            if (lastDot < 0)
                return tm.Identifier(e);
            return tm.MemberSelect(qualIdentFor(name.substring(0, lastDot)), e);
        }
        return qualIdentFor(name);
    }
    Element ee = e.getEnclosingElement();
    if (e instanceof Symbol)
        return ee.getSimpleName().length() > 0 ? tm.MemberSelect(qualIdentFor(ee), e) : tm.Identifier(e);
    return ee.getSimpleName().length() > 0 ? tm.MemberSelect(qualIdentFor(ee), e.getSimpleName()) : tm.Identifier(e.getSimpleName());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:GeneratorUtilities.java


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