private Iterable<? extends TreePath> unattributedPrepareThis(TreePath tp) { ExpressionTree thisTree = info.getTreeUtilities().parseExpression("this", new SourcePositions[1]); return Collections.singleton(new TreePath(tp, thisTree)); }
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());
private BlockTree addStatement(WorkingCopy wc, BlockTree blockTree, String beanName, String methodName, String valueSource) { TreeMaker make = wc.getTreeMaker(); ExecutableElement elem = execElementHandle.resolve(wc); ArrayList<ExpressionTree> args = new ArrayList<ExpressionTree>(); if (valueSource != null) { SourcePositions[] positions = new SourcePositions[1]; args.add(wc.getTreeUtilities().parseExpression(valueSource, positions)); } ExpressionTree exprTree = TreeMakerUtils.createMethodInvocation(wc, beanName, methodName, args); ExpressionStatementTree exprStatTree = wc.getTreeMaker().ExpressionStatement(exprTree); return wc.getTreeMaker().addBlockStatement(blockTree, exprStatTree); }
private Iterable<? extends TreePath> fullPrepareThis(TreePath tp) { //XXX: is there a faster way to do this? Collection<TreePath> result = new LinkedList<TreePath>(); Scope scope = info.getTrees().getScope(tp); TypeElement lastClass = null; while (scope != null && scope.getEnclosingClass() != null) { if (lastClass != scope.getEnclosingClass()) { ExpressionTree thisTree = info.getTreeUtilities().parseExpression("this", new SourcePositions[1]); info.getTreeUtilities().attributeTree(thisTree, scope); result.add(new TreePath(tp, thisTree)); } scope = scope.getEnclosingScope(); } return result; }
private static Token<JavaTokenId> findTokenWithText(CompilationInfo info, String text, int start, int end) { TokenHierarchy<?> th = info.getTokenHierarchy(); TokenSequence<JavaTokenId> ts = th.tokenSequence(JavaTokenId.language()).subSequence(start, end); while (ts.moveNext()) { Token<JavaTokenId> t = ts.token(); if (t.id() == JavaTokenId.IDENTIFIER) { boolean nameMatches; if (!(nameMatches = text.equals(info.getTreeUtilities().decodeIdentifier(t.text()).toString()))) { ExpressionTree expr = info.getTreeUtilities().parseExpression(t.text().toString(), new SourcePositions[1]); nameMatches = expr.getKind() == Kind.IDENTIFIER && text.contentEquals(((IdentifierTree) expr).getName()); } if (nameMatches) { return t; } } } return null; }
Tree asBlockTree = tree; tree = ci.getTreeUtilities().parseExpression( expression, sourcePtr
ExpressionTree expr = info.getTreeUtilities().parseExpression(tokenSequence.token().text().toString(), new SourcePositions[1]);
final Tree body = bodyText.charAt(0) == '{' ? tu.parseStatement(bodyText, sp) : tu.parseExpression(bodyText, sp); final Tree fake = body instanceof ExpressionTree ? new ExpressionStatementTree() { @Override