/** * Creates implementations of the all abstract methods within a class. * * @param clazz the class to create the implementations within * @return the abstract method implementations * @since 0.20 */ public List<? extends MethodTree> createAllAbstractMethodImplementations(TypeElement clazz) { return createAbstractMethodImplementations(clazz, copy.getElementUtilities().findUnimplementedMethods(clazz)); }
/**Returns uncaught exceptions inside the given tree path. */ public Set<TypeMirror> getUncaughtExceptions(TreePath path) { Set<TypeMirror> set = new UnrelatedTypeMirrorSet(info.getTypes()); new UncaughtExceptionsVisitor(info).scan(path, set); return set; }
public void run(CompilationController compilationController) throws Exception { compilationController.toPhase(JavaSource.Phase.RESOLVED); TypeElement type = (TypeElement) treePathHandle.resolveElement(compilationController); if (type != null) { className[0] = ElementUtilities.getBinaryName(type); } } }, true);
@Override public void run(CompilationController controller) throws IOException { controller.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED); TypeElement typeElement = controller.getElements().getTypeElement(className); if (typeElement != null) { result[0] = SourceUtils.getFile(ElementHandle.create(typeElement), controller.getClasspathInfo()); } } }, true);
public Scope getScope() throws IOException { if (scope == null) { controller.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED); scope = controller.getTreeUtilities().scopeFor(offset); } return scope; }
public Object run(WorkingCopy wc) { ExecutableElement execElement = methodElementHandle.resolve(wc); TypeElement typeElement = typeElementHandle.resolve(wc); ClassTree ctree = wc.getTrees().getTree(typeElement); ClassTree newctree = ctree; newctree = wc.getTreeMaker().removeClassMember(ctree, wc.getTrees().getTree(execElement)); wc.rewrite(ctree, newctree); return null; } }, fObj);
public Object run(WorkingCopy wc) { ExecutableElement execElement = execElementHandle.resolve(wc); MethodTree oldTree = wc.getTrees().getTree(execElement); Tree newTree = wc.getTreeMaker().setLabel(oldTree, name); wc.rewrite(oldTree, newTree); return null; } }, javaClass.getFileObject());
@Override public void run(CompilationController info) throws Exception { info.toPhase(JavaSource.Phase.RESOLVED); element[0] = treePathHandle.resolveElement(info); } }, true);
public Object run(WorkingCopy wc) { TreeMaker make = wc.getTreeMaker(); ExpressionTree arg = getArgument(wc); SourcePositions[] positions = new SourcePositions[1]; ExpressionTree newArg = wc.getTreeUtilities().parseExpression(valueSource, positions); wc.rewrite(arg, newArg); return null; } }, method.getJavaClass().getFileObject());
/** * Creates a new instance of ElementGrip */ public ElementGrip(TreePath treePath, CompilationInfo info) { this.delegateElementHandle = TreePathHandle.create(treePath, info); this.toString = UiUtils.getHeader(treePath, info, UiUtils.PrintPart.NAME); this.fileObject = info.getFileObject(); this.icon = UiUtils.getDeclarationIcon(info.getTrees().getElement(treePath)); }
private BlockTree addStatement(WorkingCopy wc, BlockTree blockTree, StatementTree stmtTree) { BlockTree newBlockTree = wc.getTreeMaker().addBlockStatement(blockTree, stmtTree); wc.rewrite(blockTree, newBlockTree); return newBlockTree; }
public static boolean isMainClass (final String className, ClassPath bootPath, ClassPath compilePath, ClassPath sourcePath) { ClasspathInfo cpInfo = ClasspathInfo.create(bootPath, compilePath, sourcePath); return SourceUtils.isMainClass(className, cpInfo); }
private BlockTree removeStatement(WorkingCopy wc, BlockTree blockTree, String beanName, String methodName) { TreeMaker make = wc.getTreeMaker(); ExecutableElement elem = execElementHandle.resolve(wc); StatementTree stmtTree = findPropertyStatement(wc, beanName, methodName); if (stmtTree != null) { return wc.getTreeMaker().removeBlockStatement(blockTree, stmtTree); } return null; }
/** * Returns the preceding immediate comment */ static String getPrecedingImmediateCommentText(CompilationInfo cinfo, Tree tree) { List<Comment> comments = cinfo.getTreeUtilities().getComments(tree, true); return comments.size() > 0 ? comments.get(comments.size()-1).getText() : null; }
private static String removeFieldPrefixSuffix(CharSequence fieldName, boolean isStatic, CodeStyle cs) { return removePrefixSuffix(fieldName, isStatic ? cs.getStaticFieldNamePrefix() : cs.getFieldNamePrefix(), isStatic ? cs.getStaticFieldNameSuffix() : cs.getFieldNameSuffix()); } }
private static String addParamPrefixSuffix(CharSequence name, CodeStyle cs) { return CodeStyleUtils.addPrefixSuffix(name, cs.getParameterNamePrefix(), cs.getParameterNameSuffix()); }
private static FileObject findMatchingChild(String sourceFileName, Collection<FileObject> folders, boolean caseSensitive) { final Match matchSet = caseSensitive ? new CaseSensitiveMatch(sourceFileName) : new CaseInsensitiveMatch(sourceFileName); for (FileObject folder : folders) { for (FileObject child : folder.getChildren()) { if (matchSet.apply(child)) { return child; } } } return null; }
public void run() { assertParserEventThread(); final RootsEvent e = new RootsEvent(ClassIndex.this, ar); for (ClassIndexListener l : listeners) { l.rootsAdded(e); } } };
public boolean equalsHandle(Delegate obj) { ElementDelegate other = (ElementDelegate) obj; return el.signatureEquals(other.el) && cpInfo.equals(other.cpInfo); }