public Enter enter() { return Enter.instance(context); }
public Infer infer() { return Infer.instance(context); }
@Path("/todo/{varX}/{varY}") @Produces({"application/xml", "application/json"}) public Todo whatEverNameYouLike(@PathParam("varX") String varX, @PathParam("varY") String varY) { Todo todo = new Todo(); todo.setSummary(varX); todo.setDescription(varY); return todo; }
/** Finds a declaration with the given name and type that is in scope at the current location. */ @Nullable public static Symbol findIdent(String name, VisitorState state, KindSelector kind) { ClassType enclosingClass = ASTHelpers.getType(state.findEnclosing(ClassTree.class)); if (enclosingClass == null || enclosingClass.tsym == null) { return null; } Env<AttrContext> env = Enter.instance(state.context).getClassEnv(enclosingClass.tsym); MethodTree enclosingMethod = state.findEnclosing(MethodTree.class); if (enclosingMethod != null) { env = MemberEnter.instance(state.context).getMethodEnv((JCMethodDecl) enclosingMethod, env); } try { Method method = Resolve.class.getDeclaredMethod("findIdent", Env.class, Name.class, KindSelector.class); method.setAccessible(true); Symbol result = (Symbol) method.invoke(Resolve.instance(state.context), env, state.getName(name), kind); return result.exists() ? result : null; } catch (ReflectiveOperationException e) { throw new LinkageError(e.getMessage(), e); } }
Iterable<Type> argTypes, Iterable<Type> tyargTypes) { Resolve resolve = Resolve.instance(state.context); Enter enter = Enter.instance(state.context); Log log = Log.instance(state.context); DeferredDiagnosticHandler handler = new DeferredDiagnosticHandler(log); try { return resolve.resolveInternalMethod( enter.getEnv(base), base.type, name,
Enter.instance(state.context) .getEnv(ASTHelpers.getSymbol(state.findEnclosing(ClassTree.class))); Streams.stream(Iterables.concat(env.info.getLocalElements(), enclosingTypes)) .map(sym -> sym.getSimpleName().toString()) .collect(ImmutableSet.toImmutableSet());
private static boolean maybeFunctionalInterface(Type type, Types types, VisitorState state) { try { return types.isFunctionalInterface(type); } catch (CompletionFailure e) { // Report completion errors to avoid e.g. https://github.com/bazelbuild/bazel/issues/4105 Check.instance(state.context) .completionError((DiagnosticPosition) state.getPath().getLeaf(), e); return false; } } }
public void visitDoLoop(JCDoWhileLoop tree) { attribStat(tree.body, env.dup(tree)); attribExpr(tree.cond, env, syms.booleanType); result = null; }
public void analyzeTree(Env<AttrContext> env, TreeMaker make) { new AliveAnalyzer().analyzeTree(env, make); new AssignAnalyzer(log, syms, lint, names).analyzeTree(env); new FlowAnalyzer().analyzeTree(env, make); new CaptureAnalyzer().analyzeTree(env, make); }
return (MethodType) checkMethod.invoke( Resolve.instance(inliner.getContext()), env, site, throw new InferException( ImmutableList.of( ((Resolve.InapplicableMethodException) e.getTargetException()).getDiagnostic()));
private Symbol attribIdent(String name) { Attr attr = Attr.instance(context); TreeMaker tm = TreeMaker.instance(context); return attr.attribIdent(tm.Ident(getName(name)), compilationUnit); }
enter.getTopLevelEnv(TreeMaker.instance(inliner.getContext()).TopLevel(List.<JCTree>nil())); resultInfo = resultInfoCtor.newInstance( Attr.instance(inliner.getContext()), KindSelector.PCK, Type.noType); } catch (ReflectiveOperationException e) { throw new LinkageError(e.getMessage(), e);
ctx.tree.getTag() == Tag.CLASSDEF ? ((ClassSymbol) ASTHelpers.getSymbol(ctx.tree)).members().getSymbols() : ctx.info.getLocalElements()) .flatMap( symbols ->
Todo todo = new Todo(); todo.setSummary("This is a test"); todo.setDescription("This is a test");
@Override public boolean compatible(Type found, Type req, Warner warn) { //return type must be compatible in both current context and assignment context return chk.basicHandler.compatible(found, inferenceContext().asFree(req), warn); }
/** * Create a method check context to be used during the most specific applicability check */ ResultInfo methodCheckResult(Type to, DeferredAttr.DeferredAttrContext deferredAttrContext, Warner rsWarner, Type actual) { return attr.new ResultInfo(Kinds.VAL, to, new MostSpecificCheckContext(strict, deferredAttrContext, rsWarner, actual)); }
/** Attribute a type argument list, returning a list of types. * Check that all the types are references. */ List<Type> attribTypes(List<JCExpression> trees, Env<AttrContext> env) { List<Type> types = attribAnyTypes(trees, env); return chk.checkRefTypes(trees, types); }
/** * @param symStr the string representation of a symbol * @return the Symbol object, or null if it cannot be found */ // TODO(cushon): deal with binary compat issues and return ClassSymbol @Nullable public Symbol getSymbolFromString(String symStr) { symStr = inferBinaryName(symStr); Name name = getName(symStr); Modules modules = Modules.instance(context); boolean modular = modules.getDefaultModule() != getSymtab().noModule; if (!modular) { return getSymbolFromString(getSymtab().noModule, name); } for (ModuleSymbol msym : Modules.instance(context).allModules()) { ClassSymbol result = getSymbolFromString(msym, name); if (result != null) { // TODO(cushon): the path where we iterate over all modules is probably slow. // Try to learn some lessons from JDK-8189747, and consider disallowing this case and // requiring users to call the getSymbolFromString(ModuleSymbol, Name) overload instead. return result; } } return null; }
/** * Return true if this parameter is assignable to the target parameter. This will consider * subclassing, autoboxing and null. */ boolean isAssignableTo(Parameter target, VisitorState state) { if (state.getTypes().isSameType(type(), Type.noType) || state.getTypes().isSameType(target.type(), Type.noType)) { return false; } try { return state.getTypes().isAssignable(type(), target.type()); } catch (CompletionFailure e) { // Report completion errors to avoid e.g. https://github.com/bazelbuild/bazel/issues/4105 Check.instance(state.context) .completionError((DiagnosticPosition) state.getPath().getLeaf(), e); return false; } }
public void visitWhileLoop(JCWhileLoop tree) { attribExpr(tree.cond, env, syms.booleanType); attribStat(tree.body, env.dup(tree)); result = null; }