/** * An alternative to {@link JavacFileManager#preRegister(Context)} that installs a {@link * MaskedClassLoader}. */ public static void preRegisterFileManager(Context context) { context.put( JavaFileManager.class, new Context.Factory<JavaFileManager>() { @Override public JavaFileManager make(Context c) { return new MaskedFileManager(c); } }); }
public static void bind(Context context, ImportPolicy policy) { context.put(ImportPolicy.class, checkNotNull(policy)); }
private Context prepareContext(Context baseContext, JCCompilationUnit compilationUnit) { Context context = new SubContext(baseContext); if (context.get(JavaFileManager.class) == null) { JavacFileManager.preRegister(context); } context.put(JCCompilationUnit.class, compilationUnit); context.put(PackageSymbol.class, compilationUnit.packge); context.put(RULE_TYPE_VARS, typeVariables()); return context; }
private RefasterRuleBuilderScanner(Context context) { this.context = new SubContext(context); if (context.get(PLACEHOLDER_METHODS_KEY) == null) { this.placeholderMethods = new HashMap<>(); context.put(PLACEHOLDER_METHODS_KEY, placeholderMethods); } else { this.placeholderMethods = context.get(PLACEHOLDER_METHODS_KEY); } this.beforeTemplates = new ArrayList<>(); this.afterTemplates = new ArrayList<>(); }
/** * adds a listener for attribution. */ private void prepareContext(Context context) { TaskListener otherListener = context.get(TaskListener.class); if (otherListener == null) { context.put(TaskListener.class, listener); } else { // handle cases of multiple listeners context.put(TaskListener.class, (TaskListener)null); TaskListeners listeners = new TaskListeners(); listeners.add(otherListener); listeners.add(listener); context.put(TaskListener.class, listeners); } }
/** * Retrieve an instance of {@link TrustingNullnessAnalysis} from the {@code context}. If there is * no {@link TrustingNullnessAnalysis} currently in the {@code context}, create one, insert it, * and return it. */ public static TrustingNullnessAnalysis instance(Context context) { TrustingNullnessAnalysis instance = context.get(TRUSTING_NULLNESS_KEY); if (instance == null) { instance = new TrustingNullnessAnalysis(); context.put(TRUSTING_NULLNESS_KEY, instance); } return instance; }
/** * Retrieve an instance of {@link NullnessAnalysis} from the {@code context}. If there is no * {@link NullnessAnalysis} currently in the {@code context}, create one, insert it, and return * it. */ public static NullnessAnalysis instance(Context context) { NullnessAnalysis instance = context.get(NULLNESS_ANALYSIS_KEY); if (instance == null) { instance = new NullnessAnalysis(); context.put(NULLNESS_ANALYSIS_KEY, instance); } return instance; }
public static EnclosingEnvironmentNullness instance(Context context) { EnclosingEnvironmentNullness instance = context.get(ENCLOSING_ENVIRONMENT_NULLNESS_ANALYSIS_KEY); if (instance == null) { instance = new EnclosingEnvironmentNullness(); context.put(ENCLOSING_ENVIRONMENT_NULLNESS_ANALYSIS_KEY, instance); } return instance; }
/** * @param context Javac context * @param methodReturnsNonNull predicate determining whether a method is assumed to return NonNull * value * @param config analysis config * @return instance of the analysis */ public static AccessPathNullnessAnalysis instance( Context context, Predicate<MethodInvocationNode> methodReturnsNonNull, Config config, Handler handler) { AccessPathNullnessAnalysis instance = context.get(FIELD_NULLNESS_ANALYSIS_KEY); if (instance == null) { instance = new AccessPathNullnessAnalysis(methodReturnsNonNull, context, config, handler); context.put(FIELD_NULLNESS_ANALYSIS_KEY, instance); } return instance; }
throw new IllegalArgumentException("Exception during argument processing: " + e); context.put(ErrorProneOptions.class, errorProneOptions); JavacTaskImpl task = (JavacTaskImpl)
beforeTemplates.add(template); if (template instanceof BlockTemplate) { context.put(UTemplater.REQUIRE_BLOCK_KEY, /* data= */ true);
subContext.put(ErrorProneOptions.class, errorProneOptions); Log log = Log.instance(context); JCCompilationUnit compilation = (JCCompilationUnit) path.getCompilationUnit();
public static void preRegister(final Context context, final ClasspathInfo cpInfo) { context.put(docEnvKey, new Context.Factory<DocEnv>() { public DocEnv make(Context c) { return new JavadocEnv(c, cpInfo); } }); }
/** Create a new diagnostic factory. */ protected Factory(Context context) { context.put(diagnosticFactoryKey, this); messages = Messages.instance(context); prefix = "compiler"; }
private Context prepareContext(Context baseContext, JCCompilationUnit compilationUnit) { Context context = new SubContext(baseContext); if (context.get(JavaFileManager.class) == null) { JavacFileManager.preRegister(context); } context.put(JCCompilationUnit.class, compilationUnit); context.put(PackageSymbol.class, compilationUnit.packge); context.put(RULE_TYPE_VARS, typeVariables()); return context; }
public static void preRegister(final Context context) { context.put(scannerFactoryKey, new Context.Factory<Scanner.Factory>() { public Factory make() { return new Factory(context); } }); }
public static void setInCompiler(JavaCompiler compiler, Context context) { context.put(CommentCollectingParserFactory.key(), (ParserFactory)null); Field field; try { field = Permit.getField(JavaCompiler.class, "parserFactory"); field.set(compiler, new CommentCollectingParserFactory(context)); } catch (Exception e) { throw new IllegalStateException("Could not set comment sensitive parser in the compiler", e); } } }
public static void setInCompiler(JavaCompiler compiler, Context context) { context.put(CommentCollectingParserFactory.key(), (ParserFactory) null); Field field; try { field = Permit.getField(JavaCompiler.class, "parserFactory"); field.set(compiler, new CommentCollectingParserFactory(context)); } catch (Exception e) { throw new IllegalStateException("Could not set comment sensitive parser in the compiler", e); } } }
public static void setInCompiler(JavaCompiler compiler, Context context) { context.put(CommentCollectingParserFactory.key(), (Parser.Factory)null); Field field; try { field = Permit.getField(JavaCompiler.class, "parserFactory"); field.set(compiler, new CommentCollectingParserFactory(context)); } catch (Exception e) { throw new IllegalStateException("Could not set comment sensitive parser in the compiler", e); } } }
/** Create a new parser factory. */ protected Factory(Context context) { context.put(parserFactoryKey, this); this.F = TreeMaker.instance(context); this.log = Log.instance(context); this.names = Name.Table.instance(context); this.keywords = Keywords.instance(context); this.source = Source.instance(context); this.options = Options.instance(context); }