@Override public CompilationTask getTask( Writer out, JavaFileManager fileManager, DiagnosticListener<? super JavaFileObject> diagnosticListener, Iterable<String> options, Iterable<String> classes, Iterable<? extends JavaFileObject> compilationUnits) { ErrorProneOptions errorProneOptions = ErrorProneOptions.processArgs(options); List<String> remainingOptions = Arrays.asList(errorProneOptions.getRemainingArgs()); ImmutableList<String> javacOpts = ImmutableList.copyOf(remainingOptions); javacOpts = defaultToLatestSupportedLanguageLevel(javacOpts); javacOpts = setCompilePolicyToByFile(javacOpts); final JavacTaskImpl task = (JavacTaskImpl) javacTool.getTask( out, fileManager, diagnosticListener, javacOpts, classes, compilationUnits); setupMessageBundle(task.getContext()); RefactoringCollection[] refactoringCollection = {null}; task.addTaskListener( createAnalyzer( scannerSupplier, errorProneOptions, task.getContext(), refactoringCollection)); if (refactoringCollection[0] != null) { task.addTaskListener(new RefactoringTask(task.getContext(), refactoringCollection[0])); } task.addTaskListener(new CFCacheClearingListener()); return task; }
public static JavacTrees instance(JavaCompiler.CompilationTask task) { if (!(task instanceof JavacTaskImpl)) throw new IllegalArgumentException(); return instance(((JavacTaskImpl)task).getContext()); }
public static JavacTrees instance(JavaCompiler.CompilationTask task) { if (!(task instanceof JavacTaskImpl)) throw new IllegalArgumentException(); return instance(((JavacTaskImpl)task).getContext()); }
private AssignComments(final CompilationInfo info, final Tree commentMapTarget, final TokenSequence<JavaTokenId> seq, final CompilationUnitTree cut, final SourcePositions positions) { this.info = info; this.unit = cut; this.seq = seq; this.commentMapTarget = commentMapTarget; this.commentService = CommentHandlerService.instance(info.impl.getJavacTask().getContext()); this.positions = positions; }
/** Creates a new instance of CommentUtilities */ TreeUtilities(final CompilationInfo info) { assert info != null; this.info = info; this.handler = CommentHandlerService.instance(info.impl.getJavacTask().getContext()); }
TreeMaker(WorkingCopy copy, TreeFactory delegate) { this.delegate = delegate; this.copy = copy; this.handler = CommentHandlerService.instance(copy.impl.getJavacTask().getContext()); this.model = ASTService.instance(copy.impl.getJavacTask().getContext()); }
CommentReplicator(Set<Tree> presentNodes) { this.stillPresent = presentNodes; this.commentHandler = CommentHandlerService.instance(impl.getJavacTask().getContext()); }
@Override public void started(TaskEvent e) { if (e != null && e.getKind() == TaskEvent.Kind.GENERATE) { JCClassDecl tree = syms2trees.get((ClassSymbol)e.getTypeElement()); if (tree != null) pruneTree(tree, Symtab.instance(jti.getContext()), null); } } @Override
public ImportAnalysis2(CompilationInfo info) { this(JavaSourceAccessor.getINSTANCE().getJavacTask(info).getContext()); cs = DiffContext.getCodeStyle(info); }
private ElementUtilities( @NonNull final JavacTaskImpl jt, @NullAllowed final CompilationInfo info) { this.ctx = jt.getContext(); this.delegate = ElementsService.instance(ctx); this.info = info; } /**
private void addPresentInResult(Map<Tree, Boolean> present, Tree t, boolean mark) { present.put(t, Boolean.valueOf(mark)); CommentSetImpl csi = CommentHandlerService.instance(impl.getJavacTask().getContext()).getComments(t); for (RelativePosition pos : RelativePosition.values()) { useComments(csi.getComments(pos)); } }
/**Checks whether the given scope is in "static" context. */ public boolean isStaticContext(Scope scope) { return Resolve.instance(info.impl.getJavacTask().getContext()).isStatic(((JavacScope)scope).getEnv()); }
private Element getElementByFQN(String fqn) { Elements elements = copy.getElements(); Element element = elements.getTypeElement(fqn); if (element == null) element = elements.getPackageElement(fqn); if (element == null) element = Symtab.instance(copy.impl.getJavacTask().getContext()).enterClass((com.sun.tools.javac.util.Name)elements.getName(fqn)); return element; }
/**Attribute the given tree in the given context. */ public TypeMirror attributeTree(Tree tree, Scope scope) { if (scope instanceof NBScope && ((NBScope)scope).areAccessibilityChecksDisabled()) { NBResolve.instance(info.impl.getJavacTask().getContext()).disableAccessibilityChecks(); } try { return info.impl.getJavacTask().attributeTree((JCTree) tree, ((JavacScope) scope).getEnv()); } finally { NBResolve.instance(info.impl.getJavacTask().getContext()).restoreAccessbilityChecks(); } }
/**Attribute the given tree until the given <code>to</code> tree is reached. * Returns scope valid at point when <code>to</code> is reached. */ public Scope attributeTreeTo(Tree tree, Scope scope, Tree to) { if (scope instanceof NBScope && ((NBScope)scope).areAccessibilityChecksDisabled()) { NBResolve.instance(info.impl.getJavacTask().getContext()).disableAccessibilityChecks(); } try { return info.impl.getJavacTask().attributeTreeTo((JCTree)tree, ((JavacScope)scope).getEnv(), (JCTree)to); } finally { NBResolve.instance(info.impl.getJavacTask().getContext()).restoreAccessbilityChecks(); } }
public Scope reattributeTreeTo(Tree tree, Scope scope, Tree to) { Env<AttrContext> env = ((JavacScope)scope).getEnv(); copyInnerClassIndexes(env.tree, tree); if (scope instanceof NBScope && ((NBScope)scope).areAccessibilityChecksDisabled()) { NBResolve.instance(info.impl.getJavacTask().getContext()).disableAccessibilityChecks(); } try { return info.impl.getJavacTask().attributeTreeTo((JCTree)tree, env, (JCTree)to); } finally { NBResolve.instance(info.impl.getJavacTask().getContext()).restoreAccessbilityChecks(); } }
public TypeMirror reattributeTree(Tree tree, Scope scope) { Env<AttrContext> env = ((JavacScope)scope).getEnv(); copyInnerClassIndexes(env.tree, tree); if (scope instanceof NBScope && ((NBScope)scope).areAccessibilityChecksDisabled()) { NBResolve.instance(info.impl.getJavacTask().getContext()).disableAccessibilityChecks(); } try { return info.impl.getJavacTask().attributeTree((JCTree)tree, env); } finally { NBResolve.instance(info.impl.getJavacTask().getContext()).restoreAccessbilityChecks(); } }
/** * Returns the {@link SourceVersion} used by the javac represented by this {@link CompilationInfo}. * @return SourceVersion * @since 0.47 */ public @NonNull SourceVersion getSourceVersion() { checkConfinement(); return Source.toSourceVersion(Source.instance(impl.getJavacTask().getContext())); }
@NonNull private Lookup getPluginServices(final JavacTaskImpl jt) { return Lookups.fixed( jt.getElements(), jt.getTypes(), JavacTrees.instance(jt.getContext()), JavaSourceAccessor.getINSTANCE().createElementUtilities(jt)); }
public static boolean checkTypesAssignable(CompilationInfo info, TypeMirror from, TypeMirror to) { Context c = ((JavacTaskImpl) info.impl.getJavacTask()).getContext(); if (from.getKind() == TypeKind.TYPEVAR) { Types types = Types.instance(c); TypeVar t = types.substBound((TypeVar)from, com.sun.tools.javac.util.List.of((Type)from), com.sun.tools.javac.util.List.of(types.boxedTypeOrType((Type)to))); return info.getTypes().isAssignable(t.getUpperBound(), to) || info.getTypes().isAssignable(to, t.getUpperBound()); } if (from.getKind() == TypeKind.WILDCARD) { from = Types.instance(c).wildUpperBound((Type)from); } return Check.instance(c).checkType(null, (Type)from, (Type)to).getKind() != TypeKind.ERROR; }