com.sun.tools.javac.code.Types.instance()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中com.sun.tools.javac.code.Types.instance()方法的一些代码示例,展示了Types.instance()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Types.instance()方法的具体详情如下:
包路径:com.sun.tools.javac.code.Types
类名称:Types
方法名:instance

Types.instance介绍

暂无

代码示例

代码示例来源:origin: google/error-prone

private GuardedBySymbolResolver(
  ClassSymbol enclosingClass, CompilationUnitTree compilationUnit, Context context, Tree leaf) {
 this.compilationUnit = (JCCompilationUnit) compilationUnit;
 this.enclosingClass = enclosingClass;
 this.context = context;
 this.types = Types.instance(context);
 this.decl = leaf;
}

代码示例来源:origin: google/error-prone

public Types types() {
 return Types.instance(context);
}

代码示例来源:origin: google/error-prone

public Types getTypes() {
 return Types.instance(context);
}

代码示例来源:origin: google/error-prone

public Types types() {
 return Types.instance(context);
}

代码示例来源:origin: uber/NullAway

AccessPathNullnessPropagation(
  Nullness defaultAssumption,
  Predicate<MethodInvocationNode> methodReturnsNonNull,
  Context context,
  Config config,
  Handler handler) {
 this.defaultAssumption = defaultAssumption;
 this.methodReturnsNonNull = methodReturnsNonNull;
 this.context = context;
 this.types = Types.instance(context);
 this.config = config;
 this.handler = handler;
}

代码示例来源:origin: robolectric/robolectric

private static Type getUpperBound(Type type, VisitorState state) {
 return ASTHelpers.getUpperBound(type.tsym.type, Types.instance(state.context));
}

代码示例来源:origin: google/error-prone

static boolean equivalentExprs(Unifier unifier, JCExpression expr1, JCExpression expr2) {
 return expr1.type != null
   && expr2.type != null
   && Types.instance(unifier.getContext()).isSameType(expr2.type, expr1.type)
   && expr2.toString().equals(expr1.toString());
}

代码示例来源:origin: google/error-prone

/** Creates a {@link GuardedByExpression} from a string, given the resolution context. */
static Optional<GuardedByExpression> bindString(String string, GuardedBySymbolResolver resolver) {
 try {
  return Optional.of(
    bind(
      GuardedByUtils.parseString(string, resolver.context()),
      BinderContext.of(
        resolver,
        resolver.enclosingClass(),
        Types.instance(resolver.context()),
        Names.instance(resolver.context()))));
 } catch (IllegalGuardedBy expected) {
  return Optional.empty();
 }
}

代码示例来源:origin: google/error-prone

@Override
public Description matchMethod(MethodTree tree, VisitorState state) {
 ClassTree enclosingClazz = ASTHelpers.findEnclosingNode(state.getPath(), ClassTree.class);
 if (tree.getModifiers().getFlags().contains(Modifier.DEFAULT)
   && IS_FUNCTIONAL_INTERFACE.matches(enclosingClazz, state)) {
  Types types = Types.instance(state.context);
  Set<Symbol> functionalSuperInterfaceSams =
    enclosingClazz.getImplementsClause().stream()
      .filter(t -> IS_FUNCTIONAL_INTERFACE.matches(t, state))
      .map(ASTHelpers::getSymbol)
      .map(TypeSymbol.class::cast)
      .map(types::findDescriptorSymbol) // TypeSymbol to single abstract method of the type
      .collect(toImmutableSet());
  // We designate an override of a superinterface SAM "behavior preserving" if it just
  // calls the SAM of this interface.
  Symbol thisInterfaceSam = types.findDescriptorSymbol(ASTHelpers.getSymbol(enclosingClazz));
  // relatively crude: doesn't verify that the same args are passed in the same order
  // so it can get false positives for behavior-preservingness (false negatives for the check)
  TreeVisitor<Boolean, VisitorState> behaviorPreserving =
    new BehaviorPreservingChecker(thisInterfaceSam);
  if (!Collections.disjoint(
      ASTHelpers.findSuperMethods(ASTHelpers.getSymbol(tree), types),
      functionalSuperInterfaceSams)
    && !tree.accept(behaviorPreserving, state)) {
   return describeMatch(tree);
  }
 }
 return Description.NO_MATCH;
}

代码示例来源:origin: google/error-prone

/**
 * Refines the receiver of a method invocation to type non-null after successful invocation, and
 * refines the value of the expression as a whole to non-null if applicable (e.g., if the method
 * returns a primitive type).
 *
 * <p>NOTE: This transfer makes the unsound assumption that fields reachable via the actual params
 * of this method invocation are not mutated by the callee. To be sound with respect to escaping
 * mutable references in general, we would have to set to top (i.e. NULLABLE) any tracked access
 * path that could contain an alias of an actual parameter of this invocation.
 */
@Override
Nullness visitMethodInvocation(
  MethodInvocationNode node, Updates thenUpdates, Updates elseUpdates, Updates bothUpdates) {
 ClassAndMethod callee = tryGetMethodSymbol(node.getTree(), Types.instance(context));
 if (callee != null && !callee.isStatic) {
  setNonnullIfTrackable(bothUpdates, node.getTarget().getReceiver());
 }
 setUnconditionalArgumentNullness(bothUpdates, node.getArguments(), callee);
 setConditionalArgumentNullness(
   thenUpdates,
   elseUpdates,
   node.getArguments(),
   callee,
   Types.instance(context),
   Symtab.instance(context));
 return returnValueNullness(node, callee);
}

代码示例来源:origin: cincheo/jsweet

/**
 * Creates a new overload scanner.
 */
public OverloadScanner(TranspilationHandler logHandler, JSweetContext context) {
  super(logHandler, context, null);
  this.types = Types.instance(context);
}

代码示例来源:origin: google/error-prone

ty = trueTy;
} else {
 ty = Types.instance(unifier.getContext()).lub(trueTy, falseTy);

代码示例来源:origin: google/error-prone

Types types = Types.instance(state.context);
Symtab symtab = Symtab.instance(state.context);

代码示例来源:origin: cincheo/jsweet

/**
 * Creates a new scanner.
 * 
 * @param logHandler
 *            the handler for reporting messages
 * @param context
 *            the JSweet transpilation context
 * @param compilationUnit
 *            the compilation to be scanned
 */
public AbstractTreeScanner(TranspilationHandler logHandler, JSweetContext context,
    JCCompilationUnit compilationUnit) {
  this.logHandler = logHandler;
  this.context = context;
  this.context.symtab = Symtab.instance(context);
  this.context.names = Names.instance(context);
  this.context.types = Types.instance(context);
  this.context.modelTypes = com.sun.tools.javac.model.JavacTypes.instance(context);
  this.setCompilationUnit(compilationUnit);
}

代码示例来源:origin: cincheo/jsweet

/**
 * Creates a new compilation environment with the given options and
 * classpath.
 */
public static JavaCompilationEnvironment create(JSweetOptions jsweetOptions, String classPath) {
  JSweetContext context = new JSweetContext(jsweetOptions);
  Options options = Options.instance(context);
  options.put(Option.CLASSPATH, classPath);
  options.put(Option.XLINT, "path");
  context.put(Log.outKey, new PrintWriter(System.out));
  // options.put(Option.XLINT_CUSTOM.text + "-" +
  // LintCategory.OPTIONS.option, "true");
  // options.remove(Option.XLINT_CUSTOM.text +
  // LintCategory.OPTIONS.option);
  options.put(Option.XLINT_CUSTOM.text + "-" + LintCategory.OVERRIDES.option, "true");
  JavacFileManager.preRegister(context);
  JavaFileManager fileManager = context.get(JavaFileManager.class);
  Log log = Log.instance(context);
  log.emitWarnings = false;
  log.suppressNotes = true;
  Types javacTypes = Types.instance(context);
  JavaCompiler compiler = JavaCompiler.instance(context);
  compiler.attrParseOnly = true;
  compiler.verbose = false;
  compiler.genEndPos = true;
  compiler.keepComments = true;
  Names names = Names.instance(context);
  Symtab symtab = Symtab.instance(context);
  return new JavaCompilationEnvironment(fileManager, compiler, options, context, log, javacTypes, names, symtab);
}

代码示例来源:origin: com.google.errorprone/error_prone_core

static boolean equivalentExprs(Unifier unifier, JCExpression expr1, JCExpression expr2) {
 return expr1.type != null
   && expr2.type != null
   && Types.instance(unifier.getContext()).isSameType(expr2.type, expr1.type)
   && expr2.toString().equals(expr1.toString());
}

代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac

/** Create a tree maker with null toplevel and NOPOS as initial position.
 */
protected TreeMaker(Context context) {
  context.put(treeMakerKey, this);
  this.pos = Position.NOPOS;
  this.toplevel = null;
  this.names = Name.Table.instance(context);
  this.syms = Symtab.instance(context);
  this.types = Types.instance(context);
}

代码示例来源:origin: sc.fiji/javac

protected Infer(Context context) {
  context.put(inferKey, this);
  syms = Symtab.instance(context);
  types = Types.instance(context);
  rs = Resolve.instance(context);
  chk = Check.instance(context);
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base

protected ElementsService(Context context) {
  context.put(KEY, this);
  jctypes = com.sun.tools.javac.code.Types.instance(context);
  names = Names.instance(context);
  types = JavacTypes.instance(context);
  allowDefaultMethods = Source.instance(context).allowDefaultMethods();
}

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

protected Annotate(Context context) {
  context.put(annotateKey, this);
  attr = Attr.instance(context);
  make = TreeMaker.instance(context);
  log = Log.instance(context);
  syms = Symtab.instance(context);
  names = Names.instance(context);
  rs = Resolve.instance(context);
  types = Types.instance(context);
  cfolder = ConstFold.instance(context);
  chk = Check.instance(context);
}

相关文章

Types类方法