@Override public GuardedByExpression visitMethodInvocation( MethodInvocationTree node, BinderContext context) { checkGuardedBy( node.getArguments().isEmpty() && node.getTypeArguments().isEmpty(), "Only nullary methods are allowed."); ExpressionTree methodSelect = node.getMethodSelect(); switch (methodSelect.getKind()) { case IDENTIFIER: { IdentifierTree identifier = (IdentifierTree) methodSelect; Symbol.MethodSymbol method = context.resolver.resolveMethod(node, identifier.getName()); checkGuardedBy(method != null, identifier.toString()); return bindSelect(computeBase(context, method), method); } case MEMBER_SELECT: { MemberSelectTree select = (MemberSelectTree) methodSelect; GuardedByExpression base = visit(select.getExpression(), context); checkGuardedBy(base != null, select.getExpression().toString()); Symbol.MethodSymbol method = context.resolver.resolveMethod(node, base, select.getIdentifier()); checkGuardedBy(method != null, select.toString()); return bindSelect(normalizeBase(context, method, base), method); } default: throw new IllegalGuardedBy(methodSelect.getKind().toString()); } }
@Override public int hashCode() { int h = 1; h *= 1000003; h ^= this.kind.hashCode(); h *= 1000003; h ^= (bound == null) ? 0 : this.bound.hashCode(); return h; }
SourcePositions sp = trees.getSourcePositions(); for (int treeIndex = 0; treeIndex < length; treeIndex++) { Tree node = treeNodes.get(treeIndex); Tree.Kind kind = node.getKind(); EditorContext.Operation op = null; if (kind.equals(Tree.Kind.METHOD_INVOCATION) || kind.equals(Tree.Kind.NEW_CLASS)) { if (!ci.getTreeUtilities().isSynthetic(ci.getTrees().getPath(cu, node))) { int pos = (int) sp.getStartPosition(cu, node); EditorContext.Position startPosition = String methodClassType; boolean getStartPosFromMethodLength = false; if (kind.equals(Tree.Kind.NEW_CLASS)) { identifier = ((NewClassTree) node).getIdentifier(); methodName = "<init>"; TreePath iPath = TreePath.getPath(cu, identifier); TypeMirror type = trees.getTypeMirror(iPath); if (type.getKind() == TypeKind.ERROR) { if (identifier.getKind() == Tree.Kind.IDENTIFIER) { methodName = ((IdentifierTree) identifier).getName().toString(); TreePath iPath = TreePath.getPath(cu, identifier); TypeElement te = trees.getScope(iPath).getEnclosingClass(); if (te == null) {
if (isMultistatementWildcardTree(p.getLeaf())) { return true; if (p != null && p.getLeaf().getKind() == Kind.IDENTIFIER) { treeName = ((IdentifierTree) p.getLeaf()).getName().toString(); } else if (p != null && p.getLeaf().getKind() == Kind.TYPE_PARAMETER && ((TypeParameterTree) p.getLeaf()).getBounds().isEmpty()) { treeName = ((TypeParameterTree) p.getLeaf()).getName().toString(); } else if (p != null && p.getLeaf().getKind() == Kind.PARAMETERIZED_TYPE && (node.getKind() == Kind.IDENTIFIER || node.getKind() == Kind.MEMBER_SELECT)) { ParameterizedTypeTree ptt = (ParameterizedTypeTree) p.getLeaf(); Element remappable = info.getTrees().getElement(p); if (remappable != null && variablesWithAllowedRemap.contains(remappable) && (options.contains(Options.ALLOW_REMAP_VARIABLE_TO_EXPRESSION) || node.getKind() == Kind.IDENTIFIER)) { TreePath currPath = new TreePath(getCurrentPath(), node); TypeMirror currType = info.getTrees().getTypeMirror(currPath); TypeMirror pType = ((VariableElement) remappable).asType(); String ident = getWildcardTreeName(p.getLeaf()).toString(); if (ident.startsWith("$") && StatementTree.class.isAssignableFrom(node.getKind().asInterface())) { TreePath original = bindState.variables.get(ident);
if (!optionsSet.contains(Options.ALLOW_GO_DEEPER) && !sameKind(scope.getLeaf(), first.getLeaf())) { return Collections.emptyMap(); boolean statement = StatementTree.class.isAssignableFrom(first.getLeaf().getKind().asInterface());
: TokenHierarchy.create(unit.getSourceFile().getCharContent(true), JavaTokenId.language()); TokenSequence<JavaTokenId> seq = tokens.tokenSequence(JavaTokenId.language()); TreePath tp = TreePath.getPath(cut, original); Tree toMap = original; Tree mapTarget = null; if (tp != null && original.getKind() != Kind.COMPILATION_UNIT) { boolean first = true; B: while (p2 != null) { Tree.Kind k = p2.getLeaf().getKind(); if (StatementTree.class.isAssignableFrom(k.asInterface())) { mapTarget = p2.getLeaf(); p2 = p2.getParentPath(); break; switch (p2.getLeaf().getKind()) { case CLASS: case INTERFACE: case ENUM: case METHOD:
Set<Element> result = new LinkedHashSet<>(); Set<Element> safeInitMethods = new LinkedHashSet<>(); Tree enclosingBlockOrMethod = enclosingBlockPath.getLeaf(); if (enclosingBlockOrMethod instanceof VariableTree) { return Collections.emptySet(); : ((MethodTree) enclosingBlockOrMethod).getBody(); List<? extends StatementTree> statements = blockTree.getStatements(); Tree readExprTree = pathToRead.getLeaf(); int readStartPos = getStartPos((JCTree) readExprTree); TreePath classTreePath = enclosingBlockPath; while (!(classTreePath.getLeaf() instanceof ClassTree)) { classTreePath = classTreePath.getParentPath(); if (classTreePath == null) { if (curStmt.getKind().equals(Tree.Kind.TRY)) { TryTree tryTree = (TryTree) curStmt;
case ERRONEOUS: { SourcePositions sps = this.diffContext.trees.getSourcePositions(); int a1 = (int)sps.getStartPosition(diffContext.origUnit, t1); int a2 = (int)sps.getEndPosition(diffContext.origUnit, t1); String msg = ((com.sun.source.tree.Tree)t1).getKind().toString() + " " + t1.getClass().getName(); throw new AssertionError(msg);
TreePath parentPath = path.getParentPath(); Tree leaf = path.getLeaf(); Tree parent = parentPath.getLeaf(); if (parent instanceof AssignmentTree) { if (kind.equals(Tree.Kind.EQUAL_TO) || kind.equals(Tree.Kind.NOT_EQUAL_TO)) { ExpressionTree left = binaryTree.getLeftOperand(); ExpressionTree right = binaryTree.getRightOperand(); return (left.equals(leaf) && right.getKind().equals(Tree.Kind.NULL_LITERAL)) || (right.equals(leaf) && left.getKind().equals(Tree.Kind.NULL_LITERAL));
@Override public Void visitUnary(UnaryTree tree, ExpressionTree expr) { if (tree.getKind().equals(Kind.LOGICAL_COMPLEMENT)) { notApplicable = true; } return super.visitUnary(tree, expr); }
@Override public int hashCode() { int h = 1; h *= 1000003; h ^= this.variable.hashCode(); h *= 1000003; h ^= this.kind.hashCode(); h *= 1000003; h ^= this.expression.hashCode(); return h; }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof ULiteral) { ULiteral that = (ULiteral) o; return (this.kind.equals(that.getKind())) && ((this.value == null) ? (that.getValue() == null) : this.value.equals(that.getValue())); } return false; }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof UUnary) { UUnary that = (UUnary) o; return (this.kind.equals(that.getKind())) && (this.expression.equals(that.getExpression())); } return false; }
@Override public boolean matches(ExpressionTree thisExpression, VisitorState state) { if (thisExpression.getKind().equals(Kind.IDENTIFIER)) { IdentifierTree identifier = (IdentifierTree) thisExpression; if (identifier.getName().contentEquals("this")) { return true; } } return false; } }
@Override public int hashCode() { int h = 1; h *= 1000003; h ^= this.kind.hashCode(); h *= 1000003; h ^= this.expression.hashCode(); return h; }
@Override public int hashCode() { int h = 1; h *= 1000003; h ^= this.kind.hashCode(); h *= 1000003; h ^= (value == null) ? 0 : this.value.hashCode(); return h; }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof UWildcard) { UWildcard that = (UWildcard) o; return (this.kind.equals(that.getKind())) && ((this.bound == null) ? (that.getBound() == null) : this.bound.equals(that.getBound())); } return false; }
@Override public Choice<Unifier> visitBinary(BinaryTree binary, Unifier unifier) { return Choice.condition(getKind().equals(binary.getKind()), unifier) .thenChoose(unifications(getLeftOperand(), binary.getLeftOperand())) .thenChoose(unifications(getRightOperand(), binary.getRightOperand())); }
private static Optional<ExpressionTree> findArgument( AnnotationTree annotation, String parameter) { for (ExpressionTree argument : annotation.getArguments()) { if (argument.getKind().equals(ASSIGNMENT)) { AssignmentTree assignment = (AssignmentTree) argument; if (assignment.getVariable().toString().equals(parameter)) { return Optional.of(ASTHelpers.stripParentheses(assignment.getExpression())); } } } return Optional.empty(); }