org.eclipse.jdt.core.dom.PostfixExpression Java Examples

The following examples show how to use org.eclipse.jdt.core.dom.PostfixExpression. 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: CodeBlock.java    From SimFix with GNU General Public License v2.0 6 votes vote down vote up
private PostfixExpr visit(PostfixExpression node) {
	int startLine = _cunit.getLineNumber(node.getStartPosition());
	int endLine = _cunit.getLineNumber(node.getStartPosition() + node.getLength());
	PostfixExpr postfixExpr = new PostfixExpr(startLine, endLine, node);
	
	Expr expression = (Expr) process(node.getOperand());
	expression.setParent(postfixExpr);
	postfixExpr.setExpression(expression);
	
	postfixExpr.setOperator(node.getOperator());
	
	Type exprType = NodeUtils.parseExprType(expression, node.getOperator().toString(), null);
	postfixExpr.setType(exprType);
	
	return postfixExpr;
}
 
Example #2
Source File: PreconditionExaminer.java    From JDeodorant with MIT License 6 votes vote down vote up
private boolean isUpdated(Expression expr) {
	if(expr.getParent() instanceof Assignment) {
		Assignment assignment = (Assignment)expr.getParent();
		if(assignment.getLeftHandSide().equals(expr)) {
			return true;
		}
	}
	else if(expr.getParent() instanceof PostfixExpression) {
		return true;
	}
	else if(expr.getParent() instanceof PrefixExpression) {
		PrefixExpression prefix = (PrefixExpression)expr.getParent();
		if(prefix.getOperator().equals(PrefixExpression.Operator.INCREMENT) ||
				prefix.getOperator().equals(PrefixExpression.Operator.DECREMENT)) {
			return true;
		}
	}
	return false;
}
 
Example #3
Source File: AccessAnalyzer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public boolean visit(PostfixExpression node) {
	Expression operand= node.getOperand();
	if (!considerBinding(resolveBinding(operand), operand))
		return true;

	ASTNode parent= node.getParent();
	if (!(parent instanceof ExpressionStatement)) {
		fStatus.addError(RefactoringCoreMessages.SelfEncapsulateField_AccessAnalyzer_cannot_convert_postfix_expression,
			JavaStatusContext.create(fCUnit, SourceRangeFactory.create(node)));
		return false;
	}
	fRewriter.replace(node,
		createInvocation(node.getAST(), node.getOperand(), node.getOperator().toString()),
		createGroupDescription(POSTFIX_ACCESS));
	return false;
}
 
Example #4
Source File: ExtractTempRefactoring.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private static boolean isLeftValue(ASTNode node) {
	ASTNode parent = node.getParent();
	if (parent instanceof Assignment) {
		Assignment assignment = (Assignment) parent;
		if (assignment.getLeftHandSide() == node) {
			return true;
		}
	}
	if (parent instanceof PostfixExpression) {
		return true;
	}
	if (parent instanceof PrefixExpression) {
		PrefixExpression.Operator op = ((PrefixExpression) parent).getOperator();
		if (op.equals(PrefixExpression.Operator.DECREMENT)) {
			return true;
		}
		if (op.equals(PrefixExpression.Operator.INCREMENT)) {
			return true;
		}
		return false;
	}
	return false;
}
 
Example #5
Source File: ExtractFieldRefactoring.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private static boolean isLeftValue(ASTNode node) {
	ASTNode parent = node.getParent();
	if (parent instanceof Assignment) {
		Assignment assignment = (Assignment) parent;
		if (assignment.getLeftHandSide() == node) {
			return true;
		}
	}
	if (parent instanceof PostfixExpression) {
		return true;
	}
	if (parent instanceof PrefixExpression) {
		PrefixExpression.Operator op = ((PrefixExpression) parent).getOperator();
		if (op.equals(PrefixExpression.Operator.DECREMENT)) {
			return true;
		}
		if (op.equals(PrefixExpression.Operator.INCREMENT)) {
			return true;
		}
		return false;
	}
	return false;
}
 
Example #6
Source File: AbstractLoopUtilities.java    From JDeodorant with MIT License 6 votes vote down vote up
public static boolean isUpdatingVariable(Expression updater, SimpleName variable)
{
	if (updater instanceof PrefixExpression)
	{
		PrefixExpression prefixExpression = (PrefixExpression) updater;
		return isSameVariable(prefixExpression.getOperand(), variable);
	}
	else if (updater instanceof PostfixExpression)
	{
		PostfixExpression postfixExpression = (PostfixExpression) updater;
		return isSameVariable(postfixExpression.getOperand(), variable);			
	}
	else if (updater instanceof Assignment)
	{
		Assignment assignment = (Assignment) updater;
		return isSameVariable(assignment.getLeftHandSide(), variable);
	}
	else if (updater instanceof MethodInvocation)
	{
		MethodInvocation methodInvocation = (MethodInvocation) updater;
		return isSameVariable(methodInvocation.getExpression(), variable);
	}
	return false;
}
 
Example #7
Source File: ExtractTempRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static boolean isLeftValue(ASTNode node) {
	ASTNode parent= node.getParent();
	if (parent instanceof Assignment) {
		Assignment assignment= (Assignment) parent;
		if (assignment.getLeftHandSide() == node)
			return true;
	}
	if (parent instanceof PostfixExpression)
		return true;
	if (parent instanceof PrefixExpression) {
		PrefixExpression.Operator op= ((PrefixExpression) parent).getOperator();
		if (op.equals(PrefixExpression.Operator.DECREMENT))
			return true;
		if (op.equals(PrefixExpression.Operator.INCREMENT))
			return true;
		return false;
	}
	return false;
}
 
Example #8
Source File: AbstractLoopUtilities.java    From JDeodorant with MIT License 6 votes vote down vote up
public static Integer getUpdateValue(Expression updater)
{
	if (updater instanceof PrefixExpression || updater instanceof PostfixExpression)
	{
		return AbstractLoopUtilities.getIncrementValue(updater);
	}
	else if (updater instanceof Assignment)
	{
		Assignment assignment = (Assignment) updater;
		return assignmentUpdateValue(assignment);
	}
	else if (updater instanceof MethodInvocation)
	{
		MethodInvocation methodInvocation = (MethodInvocation) updater;
		AbstractLoopBindingInformation bindingInformation = AbstractLoopBindingInformation.getInstance();
		return bindingInformation.getUpdateMethodValue(methodInvocation.resolveMethodBinding().getMethodDeclaration().getKey());
	}
	return null;
}
 
Example #9
Source File: AbstractLoopUtilities.java    From JDeodorant with MIT License 6 votes vote down vote up
private static Integer getIncrementValue(Expression expression)
{
	Integer incrementValue = null;
	String operator = null;
	if (expression instanceof PrefixExpression)
	{
		PrefixExpression prefixExpression  = (PrefixExpression) expression;
		operator = prefixExpression.getOperator().toString();
	}
	else if (expression instanceof PostfixExpression)
	{
		PostfixExpression postfixExpression = (PostfixExpression) expression;
		operator = postfixExpression.getOperator().toString();
	}
	if (operator != null && operator.equals("++"))
	{
		incrementValue = 1;
	}
	else if (operator != null && operator.equals("--"))
	{
		incrementValue = (-1);
	}
	return incrementValue;
}
 
Example #10
Source File: OccurrencesFinder.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean visit(PostfixExpression node) {
	SimpleName name= getSimpleName(node.getOperand());
	if (name != null)
		addWrite(name, name.resolveBinding());
	return true;
}
 
Example #11
Source File: GenerateForLoopAssistProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a {@link PostfixExpression} used to increment the loop variable of a <code>for</code>
 * loop to iterate over an array.
 * 
 * @param rewrite the current {@link ASTRewrite} instance
 * @param variableToIncrement the name of the variable to increment
 * @return a filled {@link PostfixExpression} realizing an incrementation of the specified
 *         variable
 */
private Expression getLinkedIncrementExpression(ASTRewrite rewrite, String variableToIncrement) {
	AST ast= rewrite.getAST();
	PostfixExpression incrementLoopVariable= ast.newPostfixExpression();
	SimpleName name= ast.newSimpleName(variableToIncrement);
	addLinkedPosition(rewrite.track(name), LinkedPositionGroup.NO_STOP, name.getIdentifier());
	incrementLoopVariable.setOperand(name);
	incrementLoopVariable.setOperator(PostfixExpression.Operator.INCREMENT);
	return incrementLoopVariable;
}
 
Example #12
Source File: AbstractMethodFragment.java    From JDeodorant with MIT License 5 votes vote down vote up
private Set<PostfixExpression> getMatchingPostfixAssignments(SimpleName simpleName, List<Expression> postfixExpressions) {
	Set<PostfixExpression> matchingPostfixAssignments = new LinkedHashSet<PostfixExpression>();
	for(Expression expression : postfixExpressions) {
		PostfixExpression postfixExpression = (PostfixExpression)expression;
		Expression operand = postfixExpression.getOperand();
		SimpleName operandName = MethodDeclarationUtility.getRightMostSimpleName(operand);
		if(operandName != null && operandName.equals(simpleName)) {
			matchingPostfixAssignments.add(postfixExpression);
		}
	}
	return matchingPostfixAssignments;
}
 
Example #13
Source File: OperatorPrecedence.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the precedence of the expression. Expression
 * with higher precedence are executed before expressions
 * with lower precedence.
 * i.e. in:
 * <br><code> int a= ++3--;</code></br>
 *
 * the  precedence order is
 * <ul>
 * <li>3</li>
 * <li>++</li>
 * <li>--</li>
 * <li>=</li>
 * </ul>
 * 1. 3 -(++)-> 4<br>
 * 2. 4 -(--)-> 3<br>
 * 3. 3 -(=)-> a<br>
 *
 * @param expression the expression to determine the precedence for
 * @return the precedence the higher to stronger the binding to its operand(s)
 */
public static int getExpressionPrecedence(Expression expression) {
	if (expression instanceof InfixExpression) {
		return getOperatorPrecedence(((InfixExpression)expression).getOperator());
	} else if (expression instanceof Assignment) {
		return ASSIGNMENT;
	} else if (expression instanceof ConditionalExpression) {
		return CONDITIONAL;
	} else if (expression instanceof InstanceofExpression) {
		return RELATIONAL;
	} else if (expression instanceof CastExpression) {
		return TYPEGENERATION;
	} else if (expression instanceof ClassInstanceCreation) {
		return POSTFIX;
	} else if (expression instanceof PrefixExpression) {
		return PREFIX;
	} else if (expression instanceof FieldAccess) {
		return POSTFIX;
	} else if (expression instanceof MethodInvocation) {
		return POSTFIX;
	} else if (expression instanceof ArrayAccess) {
		return POSTFIX;
	} else if (expression instanceof PostfixExpression) {
		return POSTFIX;
	}
	return Integer.MAX_VALUE;
}
 
Example #14
Source File: TempAssignmentFinder.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean visit(PostfixExpression postfixExpression) {
	if (postfixExpression.getOperand() == null)
		return true;
	if (! (postfixExpression.getOperand() instanceof SimpleName))
		return true;
	SimpleName simpleName= (SimpleName)postfixExpression.getOperand();
	if (! isNameReferenceToTemp(simpleName))
		return true;

	fFirstAssignment= postfixExpression;
	return false;
}
 
Example #15
Source File: MoveInstanceMethodProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public final boolean visit(final PostfixExpression node) {
	final IVariableBinding binding= getFieldBinding(node.getOperand());
	if (binding != null)
		fWritten.add(binding.getKey());
	return true;
}
 
Example #16
Source File: TreedUtils.java    From compiler with Apache License 2.0 5 votes vote down vote up
public static String buildASTLabel(ASTNode node) {
	String label = node.getClass().getSimpleName();
	if (node instanceof Expression) {
		if (node.getClass().getSimpleName().endsWith("Literal")) {
			return label + "(" + node.toString() + ")";
		}
		int type = node.getNodeType();
		switch (type) {
		case ASTNode.INFIX_EXPRESSION:
			return label + "(" + ((InfixExpression) node).getOperator().toString() + ")";
		case ASTNode.SIMPLE_NAME:
			return label + "(" + node.toString() + ")";
		case ASTNode.POSTFIX_EXPRESSION:
			return label + "(" + ((PostfixExpression) node).getOperator().toString() + ")";
		case ASTNode.PREFIX_EXPRESSION:
			return label + "(" + ((PrefixExpression) node).getOperator().toString() + ")";
		default:
			break;
		}
	} else if (node instanceof Modifier) {
		return label + "(" + node.toString() + ")";
	} else if (node instanceof Type) {
		if (node instanceof PrimitiveType)
			return label + "(" + node.toString() + ")";
	} else if (node instanceof TextElement) {
		return label + "(" + node.toString() + ")";
	} else if (node instanceof TagElement) {
		String tag = ((TagElement) node).getTagName();
		if (tag == null)
			return label;
		return label + "(" + tag + ")";
	}
	return label;
}
 
Example #17
Source File: TreedUtils.java    From compiler with Apache License 2.0 5 votes vote down vote up
public static char buildLabelForVector(ASTNode node) {
	char label = (char) node.getNodeType();
	if (node instanceof Expression) {
		if (node.getClass().getSimpleName().endsWith("Literal")) {
			return (char) (label | (node.toString().hashCode() << 7));
		}
		int type = node.getNodeType();
		switch (type) {
		case ASTNode.INFIX_EXPRESSION:
			return (char) (label | (((InfixExpression) node).getOperator().toString().hashCode() << 7));
		case ASTNode.SIMPLE_NAME:
			return (char) (label | (node.toString().hashCode() << 7));
		case ASTNode.POSTFIX_EXPRESSION:
			return (char) (label | (((PostfixExpression) node).getOperator().toString().hashCode() << 7));
		case ASTNode.PREFIX_EXPRESSION:
			return (char) (label | (((PrefixExpression) node).getOperator().toString().hashCode() << 7));
		default:
			break;
		}
	} else if (node instanceof Modifier) {
		return (char) (label | (node.toString().hashCode() << 7));
	} else if (node instanceof Type) {
		if (node instanceof PrimitiveType)
			return (char) (label | (node.toString().hashCode() << 7));
	} else if (node instanceof TextElement) {
		return (char) (label | (node.toString().hashCode() << 7));
	} else if (node instanceof TagElement) {
		String tag = ((TagElement) node).getTagName();
		if (tag != null)
			return (char) (label | (((TagElement) node).getTagName().hashCode() << 7));
	}
	return label;
}
 
Example #18
Source File: TreedMapper.java    From compiler with Apache License 2.0 5 votes vote down vote up
private boolean labelMatch(ASTNode nodeM, ASTNode nodeN) {
	if (nodeM.getNodeType() != nodeN.getNodeType())
		return false;
	if (nodeM instanceof Assignment)
		return labelMatch((Assignment) nodeM, (Assignment) nodeN);
	if (nodeM instanceof InfixExpression)
		return labelMatch((InfixExpression) nodeM, (InfixExpression) nodeN);
	if (nodeM instanceof PostfixExpression)
		return labelMatch((PostfixExpression) nodeM, (PostfixExpression) nodeN);
	if (nodeM instanceof PrefixExpression)
		return labelMatch((PrefixExpression) nodeM, (PrefixExpression) nodeN);
	return true;
}
 
Example #19
Source File: Visitor.java    From RefactoringMiner with MIT License 5 votes vote down vote up
public boolean visit(PostfixExpression node) {
	postfixExpressions.add(node.toString());
	if(current.getUserObject() != null) {
		AnonymousClassDeclarationObject anonymous = (AnonymousClassDeclarationObject)current.getUserObject();
		anonymous.getPostfixExpressions().add(node.toString());
	}
	return super.visit(node);
}
 
Example #20
Source File: ASTFlattenerUtils.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public Boolean isAssignedInBody(final Block scope, final SimpleName nameToLookFor) {
  final Function1<Expression, Boolean> _function = (Expression it) -> {
    Expression simpleName = null;
    boolean _matched = false;
    if (it instanceof Assignment) {
      _matched=true;
      simpleName = ((Assignment)it).getLeftHandSide();
    }
    if (!_matched) {
      if (it instanceof PrefixExpression) {
        _matched=true;
        simpleName = ((PrefixExpression)it).getOperand();
      }
    }
    if (!_matched) {
      if (it instanceof PostfixExpression) {
        _matched=true;
        simpleName = ((PostfixExpression)it).getOperand();
      }
    }
    if ((simpleName instanceof SimpleName)) {
      return Boolean.valueOf(((simpleName != null) && nameToLookFor.getIdentifier().equals(((SimpleName)simpleName).getIdentifier())));
    }
    return Boolean.valueOf(false);
  };
  boolean _isEmpty = IterableExtensions.isEmpty(this.findAssignmentsInBlock(scope, _function));
  return Boolean.valueOf((!_isEmpty));
}
 
Example #21
Source File: ASTFlattenerUtils.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public Iterable<Expression> findAssignmentsInBlock(final Block scope, final VariableDeclaration varDecl) {
  final Function1<Expression, Boolean> _function = (Expression it) -> {
    Expression name = null;
    boolean _matched = false;
    if (it instanceof Assignment) {
      _matched=true;
      name = ((Assignment)it).getLeftHandSide();
    }
    if (!_matched) {
      if (it instanceof PrefixExpression) {
        _matched=true;
        name = ((PrefixExpression)it).getOperand();
      }
    }
    if (!_matched) {
      if (it instanceof PostfixExpression) {
        _matched=true;
        name = ((PostfixExpression)it).getOperand();
      }
    }
    if ((name instanceof Name)) {
      final IBinding binding = ((Name)name).resolveBinding();
      if ((binding instanceof IVariableBinding)) {
        final IVariableBinding declBinding = varDecl.resolveBinding();
        return Boolean.valueOf((varDecl.getName().getIdentifier().equals(this.toSimpleName(((Name)name))) && ((IVariableBinding)binding).equals(declBinding)));
      }
    }
    return Boolean.valueOf(false);
  };
  return this.findAssignmentsInBlock(scope, _function);
}
 
Example #22
Source File: AccessAnalyzer.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public boolean visit(PostfixExpression node) {
	Expression operand = node.getOperand();
	if (!considerBinding(resolveBinding(operand), operand)) {
		return true;
	}

	ASTNode parent = node.getParent();
	if (!(parent instanceof ExpressionStatement)) {
		fStatus.addError(RefactoringCoreMessages.SelfEncapsulateField_AccessAnalyzer_cannot_convert_postfix_expression, JavaStatusContext.create(fCUnit, SourceRangeFactory.create(node)));
		return false;
	}
	fRewriter.replace(node, createInvocation(node.getAST(), node.getOperand(), node.getOperator().toString()), createGroupDescription(POSTFIX_ACCESS));
	return false;
}
 
Example #23
Source File: StyledStringVisitor.java    From JDeodorant with MIT License 5 votes vote down vote up
public boolean visit(PostfixExpression expr) {
	/*
	 * PostfixExpression: Expression PostfixOperator
	 */
	activateDiffStyle(expr);
	handleExpression(expr.getOperand());
	styledString.append(expr.getOperator().toString(), determineDiffStyle(expr, new StyledStringStyler(ordinaryStyle)));
	deactivateDiffStyle(expr);
	return false;
}
 
Example #24
Source File: JdtUtils.java    From j2cl with Apache License 2.0 5 votes vote down vote up
public static PostfixOperator getPostfixOperator(PostfixExpression.Operator operator) {
  switch (operator.toString()) {
    case "++":
      return PostfixOperator.INCREMENT;
    case "--":
      return PostfixOperator.DECREMENT;
    default:
      return null;
  }
}
 
Example #25
Source File: BindingSignatureVisitor.java    From JDeodorant with MIT License 4 votes vote down vote up
public boolean visit(PostfixExpression expr) {
	handleExpression(expr.getOperand());
	bindingKeys.add(expr.getOperator().toString());
	return false;
}
 
Example #26
Source File: ControlVariable.java    From JDeodorant with MIT License 4 votes vote down vote up
private static List<ASTNode> getValueContributingModifiers(SimpleName variable)
{
	List<ASTNode> allVariableModifiers  = getAllVariableModifiersInParentMethod(variable);
	List<ASTNode> contributingModifiers = new ArrayList<ASTNode>();
	boolean noModifierInLowerScope      = true;
	MethodDeclaration parentMethod      = AbstractLoopUtilities.findParentMethodDeclaration(variable);
	// create a list of all parents of the specified variable until the root method
	List<ASTNode> variableParents = new ArrayList<ASTNode>();
	ASTNode currentVariableParent = variable.getParent();
	while (currentVariableParent != null && currentVariableParent != parentMethod)
	{
		variableParents.add(currentVariableParent);
		currentVariableParent = currentVariableParent.getParent();
	}
	variableParents.add(parentMethod);
	// we traverse allVariableModifiers and build a list of nodes that will influence the final value
	Iterator<ASTNode> it = allVariableModifiers.iterator();
	while (it.hasNext())
	{
		ASTNode currentNode = it.next();
		boolean currentNodeAdded = false;
		// if the current node is the declaration or an assignment, the list restarts the modifiers. if it is a plus, minus, times, or divide equals, then it adds to the modifiers
		if (currentNode instanceof VariableDeclaration)
		{
			contributingModifiers = new ArrayList<ASTNode>();
			contributingModifiers.add(currentNode);
			currentNodeAdded = true;
			noModifierInLowerScope = true;
		}
		else if (currentNode instanceof Assignment)
		{
			Assignment assignment = (Assignment) currentNode;
			Assignment.Operator operator = assignment.getOperator();
			if (operator == Assignment.Operator.ASSIGN)
			{
				contributingModifiers = new ArrayList<ASTNode>();
				contributingModifiers.add(currentNode);
				currentNodeAdded = true;
				noModifierInLowerScope = true;
			}
			else if (operator == Assignment.Operator.PLUS_ASSIGN ||
					operator == Assignment.Operator.MINUS_ASSIGN ||
					operator == Assignment.Operator.TIMES_ASSIGN ||
					operator == Assignment.Operator.DIVIDE_ASSIGN)
			{
				contributingModifiers.add(currentNode);
				currentNodeAdded = true;
			}				
		}
		else if (currentNode instanceof PrefixExpression || currentNode instanceof PostfixExpression)
		{
			contributingModifiers.add(currentNode);
			currentNodeAdded = true;
		}
		else if (currentNode instanceof MethodInvocation)
		{
			MethodInvocation currentMethodInvocation = (MethodInvocation) currentNode;
			AbstractLoopBindingInformation bindingInformation = AbstractLoopBindingInformation.getInstance();
			String currentMethodBindingKey = currentMethodInvocation.resolveMethodBinding().getMethodDeclaration().getKey();
			if (bindingInformation.updateMethodValuesContains(currentMethodBindingKey))
			{
				contributingModifiers.add(currentNode);
				currentNodeAdded = true;
			}
		}
		// if currentNode was added, move up through it's parents until the first block or conditional parent and check if it is in the variableParents list, if not, it is in a lower scope
		if (currentNodeAdded)
		{
			ASTNode currentNodeParent = currentNode.getParent();
			while (currentNodeParent != null)
			{
				if ((currentNodeParent instanceof MethodDeclaration || currentNodeParent instanceof IfStatement || currentNodeParent instanceof ForStatement ||
						currentNodeParent instanceof WhileStatement || currentNodeParent instanceof DoStatement || currentNodeParent instanceof EnhancedForStatement ||
						currentNodeParent instanceof SwitchStatement || currentNodeParent instanceof TryStatement))
				{
					if (!variableParents.contains(currentNodeParent))
					{
						noModifierInLowerScope = false;
					}
					break;
				}
				currentNodeParent = currentNodeParent.getParent();
			}
		}
	}
	// return constructed list if all modifiers are in same or higher scope
	if (noModifierInLowerScope)
	{
		return contributingModifiers;
	}
	return new ArrayList<ASTNode>();
}
 
Example #27
Source File: BindingSignatureVisitor.java    From JDeodorant with MIT License 4 votes vote down vote up
private void handleExpression(Expression expression) {
	if (expression instanceof ArrayAccess) {
		visit((ArrayAccess) expression);
	} else if (expression instanceof ArrayCreation) {
		visit((ArrayCreation) expression);
	} else if (expression instanceof ArrayInitializer) {
		visit((ArrayInitializer) expression);
	} else if (expression instanceof Assignment) {
		visit((Assignment) expression);
	} else if (expression instanceof BooleanLiteral) {
		visit((BooleanLiteral) expression);
	} else if (expression instanceof CastExpression) {
		visit((CastExpression) expression);
	} else if (expression instanceof CharacterLiteral) {
		visit((CharacterLiteral) expression);
	} else if (expression instanceof ClassInstanceCreation) {
		visit((ClassInstanceCreation) expression);
	} else if (expression instanceof ConditionalExpression) {
		visit((ConditionalExpression) expression);
	} else if (expression instanceof FieldAccess) {
		visit((FieldAccess) expression);
	} else if (expression instanceof InfixExpression) {
		visit((InfixExpression) expression);
	} else if (expression instanceof InstanceofExpression) {
		visit((InstanceofExpression) expression);
	} else if (expression instanceof MethodInvocation) {
		visit((MethodInvocation) expression);
	} else if (expression instanceof NullLiteral) {
		visit((NullLiteral) expression);
	} else if (expression instanceof NumberLiteral) {
		visit((NumberLiteral) expression);
	} else if (expression instanceof ParenthesizedExpression) {
		visit((ParenthesizedExpression) expression);
	} else if (expression instanceof PostfixExpression) {
		visit((PostfixExpression) expression);
	} else if (expression instanceof PrefixExpression) {
		visit((PrefixExpression) expression);
	} else if ((expression instanceof QualifiedName)) {
		visit((QualifiedName) expression);
	} else if (expression instanceof SimpleName) {
		visit((SimpleName) expression);
	} else if (expression instanceof StringLiteral) {
		visit((StringLiteral) expression);
	} else if (expression instanceof SuperFieldAccess) {
		visit((SuperFieldAccess) expression);
	} else if (expression instanceof SuperMethodInvocation) {
		visit((SuperMethodInvocation) expression);
	} else if (expression instanceof ThisExpression) {
		visit((ThisExpression) expression);
	} else if (expression instanceof TypeLiteral) {
		visit((TypeLiteral) expression);
	} else if (expression instanceof VariableDeclarationExpression) {
		visit((VariableDeclarationExpression) expression);
	}
}
 
Example #28
Source File: InstanceOfVariableModifier.java    From JDeodorant with MIT License 4 votes vote down vote up
public boolean instanceOf(Expression expression) {
	if(expression instanceof Assignment || expression instanceof PrefixExpression || expression instanceof PostfixExpression || expression instanceof MethodInvocation)
		return true;
	else
		return false;
}
 
Example #29
Source File: InstanceOfPostfixExpression.java    From JDeodorant with MIT License 4 votes vote down vote up
public boolean instanceOf(Expression expression) {
	if(expression instanceof PostfixExpression)
		return true;
	else
		return false;
}
 
Example #30
Source File: RemoveDeclarationCorrectionProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public boolean visit(PostfixExpression node) {
	fSideEffectNodes.add(node);
	return false;
}