Java Code Examples for com.sun.source.tree.CompoundAssignmentTree#getKind()

The following examples show how to use com.sun.source.tree.CompoundAssignmentTree#getKind() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UAssignOp.java    From Refaster with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public Unifier visitCompoundAssignment(
    CompoundAssignmentTree assignOp, @Nullable Unifier unifier) {
  unifier = (getKind() == assignOp.getKind()) ? unifier : null;
  unifier = getVariable().unify(assignOp.getVariable(), unifier);
  return getExpression().unify(assignOp.getExpression(), unifier);      
}
 
Example 2
Source File: Flow.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public Boolean visitCompoundAssignment(CompoundAssignmentTree node, ConstructorData p) {
    TypeElement oldQName = this.referenceTarget;
    this.referenceTarget = null;

    lValueDereference = true;
    scan(node.getVariable(), null);
    lValueDereference = false;

    Boolean constVal = scan(node.getExpression(), p);

    Element e = info.getTrees().getElement(new TreePath(getCurrentPath(), node.getVariable()));

    if (e != null) {
        if (SUPPORTED_VARIABLES.contains(e.getKind())) {
            VariableElement ve = (VariableElement) e;
            State prevState = variable2State.get(ve);
            if (LOCAL_VARIABLES.contains(e.getKind())) {
                addUse2Values(node.getVariable(), prevState);
            } else if (e.getKind() == ElementKind.FIELD && prevState != null && prevState.hasUnassigned() && !finalCandidates.contains(ve)) {
                usedWhileUndefined.add(ve);
            }
            recordVariableState(ve, getCurrentPath());
        } else if (shouldProcessUndefined(e)) {
            Element cv = canonicalUndefined(e);
            recordVariableState(cv, getCurrentPath());
        }
    }

    this.referenceTarget = oldQName;
    boolean retain = false;
    switch (node.getKind()) {
        case OR_ASSIGNMENT:
            retain = constVal == Boolean.TRUE;
            break;
        case AND_ASSIGNMENT:
            retain = constVal == Boolean.FALSE;
            break;
    }
    return retain ? constVal : null;
}