All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.checkerframework.dataflow.cfg.node.MethodAccessNode Maven / Gradle / Ivy

Go to download

dataflow-shaded is a dataflow framework based on the javac compiler. It differs from the org.checkerframework:dataflow artifact in two ways. First, the packages in this artifact have been renamed to org.checkerframework.shaded.*. Second, unlike the dataflow artifact, this artifact contains the dependencies it requires.

There is a newer version: 3.42.0-eisop5
Show newest version
package org.checkerframework.dataflow.cfg.node;

import com.sun.source.tree.ExpressionTree;
import com.sun.source.tree.Tree;

import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.dataflow.qual.SideEffectFree;
import org.checkerframework.javacutil.ElementUtils;
import org.checkerframework.javacutil.TreeUtils;

import java.util.Collection;
import java.util.Collections;
import java.util.Objects;

import javax.lang.model.element.ExecutableElement;

/**
 * A node for a method access, including a receiver:
 *
 * 
 *   expression . method ()
 * 
*/ public class MethodAccessNode extends Node { /** The tree of the method access. */ protected final ExpressionTree tree; /** The element of the accessed method. */ protected final ExecutableElement method; /** The receiver node of the method access. */ protected final Node receiver; /** * Create a new MethodAccessNode. * * @param tree the expression that is a method access * @param receiver the receiver */ public MethodAccessNode(ExpressionTree tree, Node receiver) { this(tree, (ExecutableElement) TreeUtils.elementFromUse(tree), receiver); } /** * Create a new MethodAccessNode. * * @param tree the expression that is a method access * @param method the element for the method * @param receiver the receiver */ public MethodAccessNode(ExpressionTree tree, ExecutableElement method, Node receiver) { super(TreeUtils.typeOf(tree)); assert TreeUtils.isMethodAccess(tree); this.tree = tree; assert TreeUtils.isUseOfElement(tree) : "@AssumeAssertion(nullness): tree kind"; this.method = method; this.receiver = receiver; } public ExecutableElement getMethod() { return method; } public Node getReceiver() { return receiver; } @Override public Tree getTree() { return tree; } @Override public R accept(NodeVisitor visitor, P p) { return visitor.visitMethodAccess(this, p); } @Override public String toString() { return getReceiver() + "." + method.getSimpleName(); } @Override public boolean equals(@Nullable Object obj) { if (!(obj instanceof MethodAccessNode)) { return false; } MethodAccessNode other = (MethodAccessNode) obj; return getReceiver().equals(other.getReceiver()) && getMethod().equals(other.getMethod()); } @Override public int hashCode() { return Objects.hash(getReceiver(), getMethod()); } @Override @SideEffectFree public Collection getOperands() { return Collections.singletonList(receiver); } /** * Determine whether the method is static or not. * * @return whether the method is static or not */ public boolean isStatic() { return ElementUtils.isStatic(getMethod()); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy