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


Java VarSymbol.flags方法代码示例

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


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

示例1: getDefinedSerializableFields

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入方法依赖的package包/类
private VarSymbol getDefinedSerializableFields(ClassSymbol def) {
    Names names = def.name.table.names;

    /* SERIALIZABLE_FIELDS can be private,
     * so must lookup by ClassSymbol, not by ClassDocImpl.
     */
    for (Scope.Entry e = def.members().lookup(names.fromString(SERIALIZABLE_FIELDS)); e.scope != null; e = e.next()) {
        if (e.sym.kind == Kinds.VAR) {
            VarSymbol f = (VarSymbol)e.sym;
            if ((f.flags() & Flags.STATIC) != 0 &&
                (f.flags() & Flags.PRIVATE) != 0) {
                return f;
            }
        }
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:SerializedForm.java

示例2: computeDefaultSerializableFields

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入方法依赖的package包/类
private void computeDefaultSerializableFields(DocEnv env,
                                              ClassSymbol def,
                                              ClassDocImpl cd) {
    for (Scope.Entry e = def.members().elems; e != null; e = e.sibling) {
        if (e.sym != null && e.sym.kind == Kinds.VAR) {
            VarSymbol f = (VarSymbol)e.sym;
            if ((f.flags() & Flags.STATIC) == 0 &&
                (f.flags() & Flags.TRANSIENT) == 0) {
                //### No modifier filtering applied here.
                FieldDocImpl fd = env.getFieldDoc(f);
                //### Add to beginning.
                //### Preserve order used by old 'javadoc'.
                fields.prepend(fd);
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:SerializedForm.java

示例3: getDefinedSerializableFields

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入方法依赖的package包/类
private VarSymbol getDefinedSerializableFields(ClassSymbol def) {
    Names names = def.name.table.names;

    /* SERIALIZABLE_FIELDS can be private,
     */
    for (Symbol sym : def.members().getSymbolsByName(names.fromString(SERIALIZABLE_FIELDS))) {
        if (sym.kind == VAR) {
            VarSymbol f = (VarSymbol) sym;
            if ((f.flags() & Flags.STATIC) != 0
                    && (f.flags() & Flags.PRIVATE) != 0) {
                return f;
            }
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:WorkArounds.java

示例4: getDefinedSerializableFields

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入方法依赖的package包/类
private VarSymbol getDefinedSerializableFields(ClassSymbol def) {
    Names names = def.name.table.names;

    /* SERIALIZABLE_FIELDS can be private,
     * so must lookup by ClassSymbol, not by ClassDocImpl.
     */
    for (Symbol sym : def.members().getSymbolsByName(names.fromString(SERIALIZABLE_FIELDS))) {
        if (sym.kind == VAR) {
            VarSymbol f = (VarSymbol)sym;
            if ((f.flags() & Flags.STATIC) != 0 &&
                (f.flags() & Flags.PRIVATE) != 0) {
                return f;
            }
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:SerializedForm.java

示例5: computeDefaultSerializableFields

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入方法依赖的package包/类
private void computeDefaultSerializableFields(DocEnv env,
                                              ClassSymbol def,
                                              ClassDocImpl cd) {
    for (Symbol sym : def.members().getSymbols(NON_RECURSIVE)) {
        if (sym != null && sym.kind == VAR) {
            VarSymbol f = (VarSymbol)sym;
            if ((f.flags() & Flags.STATIC) == 0 &&
                (f.flags() & Flags.TRANSIENT) == 0) {
                //### No modifier filtering applied here.
                FieldDocImpl fd = env.getFieldDoc(f);
                //### Add to beginning.
                //### Preserve order used by old 'javadoc'.
                fields.prepend(fd);
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:SerializedForm.java

示例6: getDefinedSerializableFields

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入方法依赖的package包/类
private VarSymbol getDefinedSerializableFields(ClassSymbol def) {
    Name.Table names = def.name.table;

    /* SERIALIZABLE_FIELDS can be private,
     * so must lookup by ClassSymbol, not by ClassDocImpl.
     */
    for (Scope.Entry e = def.members().lookup(names.fromString(SERIALIZABLE_FIELDS)); e.scope != null; e = e.next()) {
        if (e.sym.kind == Kinds.VAR) {
            VarSymbol f = (VarSymbol)e.sym;
            if ((f.flags() & Flags.STATIC) != 0 &&
                (f.flags() & Flags.PRIVATE) != 0) {
                return f;
            }
        }
    }
    return null;
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:18,代码来源:SerializedForm.java

示例7: enumValues

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入方法依赖的package包/类
/** @return all values of the given enum type, in declaration order. */
public static LinkedHashSet<String> enumValues(TypeSymbol enumType) {
  if (enumType.getKind() != ElementKind.ENUM) {
    throw new IllegalStateException();
  }
  Scope scope = enumType.members();
  Deque<String> values = new ArrayDeque<>();
  for (Symbol sym : scope.getSymbols()) {
    if (sym instanceof VarSymbol) {
      VarSymbol var = (VarSymbol) sym;
      if ((var.flags() & Flags.ENUM) != 0) {
        /**
         * Javac gives us the members backwards, apparently. It's worth making an effort to
         * preserve declaration order because it's useful for diagnostics (e.g. in {@link
         * MissingCasesInEnumSwitch}).
         */
        values.push(sym.name.toString());
      }
    }
  }
  return new LinkedHashSet<>(values);
}
 
开发者ID:google,项目名称:error-prone,代码行数:23,代码来源:ASTHelpers.java

示例8: matchMethod

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入方法依赖的package包/类
@Override
public Description matchMethod(MethodTree tree, VisitorState state) {
  for (VariableTree parameter : tree.getParameters()) {
    VarSymbol sym = ASTHelpers.getSymbol(parameter);
    if (sym == null) {
      continue;
    }
    if (!CompileTimeConstantExpressionMatcher.hasCompileTimeConstantAnnotation(state, sym)) {
      continue;
    }
    if ((sym.flags() & FINAL) == FINAL
        || (sym.flags() & EFFECTIVELY_FINAL) == EFFECTIVELY_FINAL) {
      continue;
    }
    return describeMatch(parameter);
  }
  return NO_MATCH;
}
 
开发者ID:google,项目名称:error-prone,代码行数:19,代码来源:NonFinalCompileTimeConstant.java

示例9: matchSynchronized

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入方法依赖的package包/类
@Override
public Description matchSynchronized(SynchronizedTree tree, VisitorState state) {
  Symbol symbol = ASTHelpers.getSymbol(stripParentheses(tree.getExpression()));
  if (!(symbol instanceof VarSymbol)) {
    return NO_MATCH;
  }

  // TODO(cushon): check that the receiver doesn't contain mutable state.
  // Currently 'this.locks[i].mu' is accepted if 'mu' is final but 'locks' is non-final.
  VarSymbol varSymbol = (VarSymbol) symbol;
  if (varSymbol.isLocal() || varSymbol.isStatic() || (varSymbol.flags() & Flags.FINAL) != 0) {
    return NO_MATCH;
  }
  if (ASTHelpers.hasAnnotation(varSymbol, LazyInit.class, state)) {
    return NO_MATCH;
  }

  Name ownerName = varSymbol.owner.enclClass().getQualifiedName();
  if (Stream.of("java.io.Writer", "java.io.Reader").anyMatch(ownerName::contentEquals)) {
    // These classes contain a non-final 'lock' variable available to subclasses, and we can't
    // make these locks final.
    return NO_MATCH;
  }

  return describeMatch(tree.getExpression());
}
 
开发者ID:google,项目名称:error-prone,代码行数:27,代码来源:SynchronizeOnNonFinalField.java

示例10: isAssignableAsBlankFinal

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入方法依赖的package包/类
/** Is given blank final variable assignable, i.e. in a scope where it
 *  may be assigned to even though it is final?
 *  @param v      The blank final variable.
 *  @param env    The current environment.
 */
boolean isAssignableAsBlankFinal(VarSymbol v, Env<AttrContext> env) {
    Symbol owner = env.info.scope.owner;
       // owner refers to the innermost variable, method or
       // initializer block declaration at this point.
    return
        v.owner == owner
        ||
        ((owner.name == names.init ||    // i.e. we are in a constructor
          owner.kind == VAR ||           // i.e. we are in a variable initializer
          (owner.flags() & BLOCK) != 0)  // i.e. we are in an initializer block
         &&
         v.owner == owner.owner
         &&
         ((v.flags() & STATIC) != 0) == Resolve.isStatic(env));
}
 
开发者ID:sebastianoe,项目名称:s4j,代码行数:21,代码来源:Attr.java

示例11: checkAssignable

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入方法依赖的package包/类
/** Check that variable can be assigned to.
 *  @param pos    The current source code position.
 *  @param v      The assigned varaible
 *  @param base   If the variable is referred to in a Select, the part
 *                to the left of the `.', null otherwise.
 *  @param env    The current environment.
 */
void checkAssignable(DiagnosticPosition pos, VarSymbol v, JCTree base, Env<AttrContext> env) {
    if ((v.flags() & FINAL) != 0 &&
        ((v.flags() & HASINIT) != 0
         ||
         !((base == null ||
           (base.getTag() == JCTree.IDENT && TreeInfo.name(base) == names._this)) &&
           isAssignableAsBlankFinal(v, env)))) {
        if (v.isResourceVariable()) { //TWR resource
            log.error(pos, "try.resource.may.not.be.assigned", v);
        } else {
            log.error(pos, "cant.assign.val.to.final.var", v);
        }
    } else if ((v.flags() & EFFECTIVELY_FINAL) != 0) {
        v.flags_field &= ~EFFECTIVELY_FINAL;
    }
}
 
开发者ID:sebastianoe,项目名称:s4j,代码行数:24,代码来源:Attr.java

示例12: computeDefaultSerializableFields

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入方法依赖的package包/类
private void computeDefaultSerializableFields(ClassSymbol te) {
    for (Symbol sym : te.members().getSymbols(NON_RECURSIVE)) {
        if (sym != null && sym.kind == VAR) {
            VarSymbol f = (VarSymbol) sym;
            if ((f.flags() & Flags.STATIC) == 0
                    && (f.flags() & Flags.TRANSIENT) == 0) {
                //### No modifier filtering applied here.
                //### Add to beginning.
                //### Preserve order used by old 'javadoc'.
                fields.add(f);
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:WorkArounds.java

示例13: shouldDocument

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入方法依赖的package包/类
/** Check whether this member should be documented. */
public boolean shouldDocument(VarSymbol sym) {
    long mod = sym.flags();

    if ((mod & Flags.SYNTHETIC) != 0) {
        return false;
    }

    return showAccess.checkModifier(translateModifiers(mod));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:DocEnv.java

示例14: shouldDocument

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入方法依赖的package包/类
/** Check whether this member should be documented. */
public boolean shouldDocument(VarSymbol sym) {
    long mod = sym.flags();
    if (isSynthetic(mod)) {
        return false;
    }
    return filter.checkModifier(translateModifiers(mod));
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:9,代码来源:DocEnv.java

示例15: tryFinallyClose

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入方法依赖的package包/类
private boolean tryFinallyClose(VarSymbol var, TreePath path, VisitorState state) {
  if ((var.flags() & (Flags.FINAL | Flags.EFFECTIVELY_FINAL)) == 0) {
    return false;
  }
  Tree parent = path.getParentPath().getLeaf();
  if (parent.getKind() != Tree.Kind.BLOCK) {
    return false;
  }
  BlockTree block = (BlockTree) parent;
  int idx = block.getStatements().indexOf(path.getLeaf());
  if (idx == -1 || idx == block.getStatements().size() - 1) {
    return false;
  }
  StatementTree next = block.getStatements().get(idx + 1);
  if (!(next instanceof TryTree)) {
    return false;
  }
  TryTree tryTree = (TryTree) next;
  if (tryTree.getFinallyBlock() == null) {
    return false;
  }
  boolean[] closed = {false};
  tryTree
      .getFinallyBlock()
      .accept(
          new TreeScanner<Void, Void>() {
            @Override
            public Void visitMethodInvocation(MethodInvocationTree tree, Void unused) {
              if (CLOSE_METHOD.matches(tree, state)
                  && Objects.equals(getSymbol(getReceiver(tree)), var)) {
                closed[0] = true;
              }
              return null;
            }
          },
          null);
  return closed[0];
}
 
开发者ID:google,项目名称:error-prone,代码行数:39,代码来源:AbstractMustBeClosedChecker.java


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