当前位置: 首页>>代码示例>>Java>>正文


Java Assignment.getLeftHandSide方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.dom.Assignment.getLeftHandSide方法的典型用法代码示例。如果您正苦于以下问题:Java Assignment.getLeftHandSide方法的具体用法?Java Assignment.getLeftHandSide怎么用?Java Assignment.getLeftHandSide使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.dom.Assignment的用法示例。


在下文中一共展示了Assignment.getLeftHandSide方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isAcumulationAssign

import org.eclipse.jdt.core.dom.Assignment; //导入方法依赖的package包/类
private static boolean isAcumulationAssign(Assignment assignment, InfixExpression.Operator op, Predicate<Expression> acceptExpression) {
	if(!(
			assignment.getRightHandSide() instanceof InfixExpression && 
			assignment.getLeftHandSide() instanceof SimpleName &&
			assignment.getOperator() == Assignment.Operator.ASSIGN))
		return false;

	InfixExpression exp = (InfixExpression) assignment.getRightHandSide();
	if(exp.getOperator() != op)
		return false;

	String assignVar = assignment.getLeftHandSide().toString();
	if(	exp.getLeftOperand() instanceof SimpleName &&
			exp.getLeftOperand().toString().equals(assignVar) &&
			acceptExpression.test(exp.getRightOperand()))
		return true;

	if(	exp.getRightOperand() instanceof SimpleName && 
			exp.getRightOperand().toString().equals(assignVar) &&
			acceptExpression.test(exp.getLeftOperand()))
		return true;

	return false;
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:25,代码来源:VarParser.java

示例2: getAssignedVariable

import org.eclipse.jdt.core.dom.Assignment; //导入方法依赖的package包/类
/**
 * Returns the binding of the variable written in an Assignment.
 * @param assignment The assignment
 * @return The binding or <code>null</code> if no bindings are available.
 */
public static IVariableBinding getAssignedVariable(Assignment assignment) {
	Expression leftHand = assignment.getLeftHandSide();
	switch (leftHand.getNodeType()) {
	case ASTNode.SIMPLE_NAME:
		return (IVariableBinding) ((SimpleName) leftHand).resolveBinding();
	case ASTNode.QUALIFIED_NAME:
		return (IVariableBinding) ((QualifiedName) leftHand).getName().resolveBinding();
	case ASTNode.FIELD_ACCESS:
		return ((FieldAccess) leftHand).resolveFieldBinding();
	case ASTNode.SUPER_FIELD_ACCESS:
		return ((SuperFieldAccess) leftHand).resolveFieldBinding();
	default:
		return null;
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:21,代码来源:Bindings.java

示例3: isLeftHandSideOfAssignment

import org.eclipse.jdt.core.dom.Assignment; //导入方法依赖的package包/类
static boolean isLeftHandSideOfAssignment(ASTNode node) {
	Assignment assignment = (Assignment) ASTNodes.getParent(node, ASTNode.ASSIGNMENT);
	if (assignment != null) {
		Expression leftHandSide = assignment.getLeftHandSide();
		if (leftHandSide == node) {
			return true;
		}
		if (ASTNodes.isParent(node, leftHandSide)) {
			switch (leftHandSide.getNodeType()) {
				case ASTNode.SIMPLE_NAME:
					return true;
				case ASTNode.FIELD_ACCESS:
					return node == ((FieldAccess) leftHandSide).getName();
				case ASTNode.QUALIFIED_NAME:
					return node == ((QualifiedName) leftHandSide).getName();
				case ASTNode.SUPER_FIELD_ACCESS:
					return node == ((SuperFieldAccess) leftHandSide).getName();
				default:
					return false;
			}
		}
	}
	return false;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:25,代码来源:SnippetFinder.java

示例4: getLeftHandSideVarBinding

import org.eclipse.jdt.core.dom.Assignment; //导入方法依赖的package包/类
/**
 * for an assignment x = y returns the variable binding of x
 * 
 * @param varBinding
 * @param assignment
 * @return
 */
private static IVariableBinding getLeftHandSideVarBinding(Assignment assignment) {
	Expression leftHnsd = assignment.getLeftHandSide();
	if (leftHnsd instanceof SimpleName) {
		IBinding bind = ((SimpleName) leftHnsd).resolveBinding();
		if (bind instanceof IVariableBinding) {
			return ((IVariableBinding) bind).getVariableDeclaration();
		}
	}
	if (leftHnsd instanceof FieldAccess) {
		FieldAccess fa = (FieldAccess) leftHnsd;
		return fa.resolveFieldBinding();
	}
	// Leave it null - cannot determine actual domains for arrays
	// workaround for bugs related to objects created in complex expression
	// if (leftHnsd instanceof ArrayAccess) {
	// ArrayAccess aa = (ArrayAccess) leftHnsd;
	// return getArrayAccessVarBinding(aa);
	// }
	return null;
}
 
开发者ID:aroog,项目名称:code,代码行数:28,代码来源:Utils.java

示例5: getAssignedVariable

import org.eclipse.jdt.core.dom.Assignment; //导入方法依赖的package包/类
/**
 * Returns the binding of the variable written in an Assignment.
 *
 * @param assignment The assignment
 * @return The binding or <code>null</code> if no bindings are available.
 */
public static IVariableBinding getAssignedVariable(Assignment assignment) {
  Expression leftHand = assignment.getLeftHandSide();
  switch (leftHand.getNodeType()) {
    case ASTNode.SIMPLE_NAME:
      return (IVariableBinding) ((SimpleName) leftHand).resolveBinding();
    case ASTNode.QUALIFIED_NAME:
      return (IVariableBinding) ((QualifiedName) leftHand).getName().resolveBinding();
    case ASTNode.FIELD_ACCESS:
      return ((FieldAccess) leftHand).resolveFieldBinding();
    case ASTNode.SUPER_FIELD_ACCESS:
      return ((SuperFieldAccess) leftHand).resolveFieldBinding();
    default:
      return null;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:Bindings.java

示例6: isLeftHandSideOfAssignment

import org.eclipse.jdt.core.dom.Assignment; //导入方法依赖的package包/类
private static boolean isLeftHandSideOfAssignment(ASTNode node) {
  Assignment assignment = (Assignment) ASTNodes.getParent(node, ASTNode.ASSIGNMENT);
  if (assignment != null) {
    Expression leftHandSide = assignment.getLeftHandSide();
    if (leftHandSide == node) {
      return true;
    }
    if (ASTNodes.isParent(node, leftHandSide)) {
      switch (leftHandSide.getNodeType()) {
        case ASTNode.SIMPLE_NAME:
          return true;
        case ASTNode.FIELD_ACCESS:
          return node == ((FieldAccess) leftHandSide).getName();
        case ASTNode.QUALIFIED_NAME:
          return node == ((QualifiedName) leftHandSide).getName();
        case ASTNode.SUPER_FIELD_ACCESS:
          return node == ((SuperFieldAccess) leftHandSide).getName();
        default:
          return false;
      }
    }
  }
  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:SnippetFinder.java

示例7: endVisit

import org.eclipse.jdt.core.dom.Assignment; //导入方法依赖的package包/类
@Override
public void endVisit(Assignment node) {
	Expression lhs= node.getLeftHandSide();
	Expression rhs= node.getRightHandSide();

	ConstraintVariable2 left= getConstraintVariable(lhs);
	ConstraintVariable2 right= getConstraintVariable(rhs);
	if (node.resolveBoxing()) {
		ImmutableTypeVariable2 boxed= fTCModel.makeImmutableTypeVariable(node.resolveTypeBinding(), node);
		setConstraintVariable(node, boxed);
	} else {
		setConstraintVariable(node, left); // type of assignement is type of 'left'
	}
	if (left == null || right == null)
		return;

	Assignment.Operator op= node.getOperator();
	if (op == Assignment.Operator.PLUS_ASSIGN && (lhs.resolveTypeBinding() == node.getAST().resolveWellKnownType("java.lang.String"))) { //$NON-NLS-1$
		//Special handling for automatic String conversion: do nothing; the RHS can be anything.
	} else {
		fTCModel.createElementEqualsConstraints(left, right);
		fTCModel.createSubtypeConstraint(right, left); // left= right;  -->  [right] <= [left]
	}
	//TODO: other implicit conversions: numeric promotion, autoboxing?
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:InferTypeArgumentsConstraintCreator.java

示例8: isLeftHandSideOfAssignment

import org.eclipse.jdt.core.dom.Assignment; //导入方法依赖的package包/类
private static boolean isLeftHandSideOfAssignment(ASTNode node) {
	Assignment assignment= (Assignment)ASTNodes.getParent(node, ASTNode.ASSIGNMENT);
	if (assignment != null) {
		Expression leftHandSide= assignment.getLeftHandSide();
		if (leftHandSide == node) {
			return true;
		}
		if (ASTNodes.isParent(node, leftHandSide)) {
			switch (leftHandSide.getNodeType()) {
				case ASTNode.SIMPLE_NAME:
					return true;
				case ASTNode.FIELD_ACCESS:
					return node == ((FieldAccess)leftHandSide).getName();
				case ASTNode.QUALIFIED_NAME:
					return node == ((QualifiedName)leftHandSide).getName();
				case ASTNode.SUPER_FIELD_ACCESS:
					return node == ((SuperFieldAccess)leftHandSide).getName();
				default:
					return false;
			}
		}
	}
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:SnippetFinder.java

示例9: isLeftValue

import org.eclipse.jdt.core.dom.Assignment; //导入方法依赖的package包/类
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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:ExtractTempRefactoring.java

示例10: getAssignedVariable

import org.eclipse.jdt.core.dom.Assignment; //导入方法依赖的package包/类
/**
 * Returns the binding of the variable written in an Assignment.
 * @param assignment The assignment
 * @return The binding or <code>null</code> if no bindings are available.
 */
public static IVariableBinding getAssignedVariable(Assignment assignment) {
	Expression leftHand = assignment.getLeftHandSide();
	switch (leftHand.getNodeType()) {
		case ASTNode.SIMPLE_NAME:
			return (IVariableBinding) ((SimpleName) leftHand).resolveBinding();
		case ASTNode.QUALIFIED_NAME:
			return (IVariableBinding) ((QualifiedName) leftHand).getName().resolveBinding();
		case ASTNode.FIELD_ACCESS:
			return ((FieldAccess) leftHand).resolveFieldBinding();
		case ASTNode.SUPER_FIELD_ACCESS:
			return ((SuperFieldAccess) leftHand).resolveFieldBinding();
		default:
			return null;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:Bindings.java

示例11: isAssigned

import org.eclipse.jdt.core.dom.Assignment; //导入方法依赖的package包/类
private boolean isAssigned(Statement statement, SimpleName name) {
	if (statement instanceof ExpressionStatement) {
		ExpressionStatement exstat= (ExpressionStatement) statement;
		if (exstat.getExpression() instanceof Assignment) {
			Assignment assignment= (Assignment) exstat.getExpression();
			return assignment.getLeftHandSide() == name;
		}
	}
	return false;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:11,代码来源:NewVariableCorrectionProposal.java

示例12: isForStatementInit

import org.eclipse.jdt.core.dom.Assignment; //导入方法依赖的package包/类
private boolean isForStatementInit(Statement statement, SimpleName name) {
	if (statement instanceof ForStatement) {
		ForStatement forStatement= (ForStatement) statement;
		List<Expression> list = forStatement.initializers();
		if (list.size() == 1 && list.get(0) instanceof Assignment) {
			Assignment assignment= (Assignment) list.get(0);
			return assignment.getLeftHandSide() == name;
		}
	}
	return false;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:12,代码来源:NewVariableCorrectionProposal.java

示例13: endVisit

import org.eclipse.jdt.core.dom.Assignment; //导入方法依赖的package包/类
@Override
public void endVisit(Assignment node) {
  Expression lhs = node.getLeftHandSide();
  Expression rhs = node.getRightHandSide();

  ConstraintVariable2 left = getConstraintVariable(lhs);
  ConstraintVariable2 right = getConstraintVariable(rhs);
  if (node.resolveBoxing()) {
    ImmutableTypeVariable2 boxed =
        fTCModel.makeImmutableTypeVariable(node.resolveTypeBinding(), node);
    setConstraintVariable(node, boxed);
  } else {
    setConstraintVariable(node, left); // type of assignement is type of 'left'
  }
  if (left == null || right == null) return;

  Assignment.Operator op = node.getOperator();
  if (op == Assignment.Operator.PLUS_ASSIGN
      && (lhs.resolveTypeBinding()
          == node.getAST().resolveWellKnownType("java.lang.String"))) { // $NON-NLS-1$
    // Special handling for automatic String conversion: do nothing; the RHS can be anything.
  } else {
    fTCModel.createElementEqualsConstraints(left, right);
    fTCModel.createSubtypeConstraint(right, left); // left= right;  -->  [right] <= [left]
  }
  // TODO: other implicit conversions: numeric promotion, autoboxing?
}
 
开发者ID:eclipse,项目名称:che,代码行数:28,代码来源:InferTypeArgumentsConstraintCreator.java

示例14: isAssignmentToTemp

import org.eclipse.jdt.core.dom.Assignment; //导入方法依赖的package包/类
private boolean isAssignmentToTemp(Assignment assignment) {
  if (fTempBinding == null) return false;

  if (!(assignment.getLeftHandSide() instanceof Name)) return false;
  Name ref = (Name) assignment.getLeftHandSide();
  return isNameReferenceToTemp(ref);
}
 
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:TempAssignmentFinder.java

示例15: isLeftValue

import org.eclipse.jdt.core.dom.Assignment; //导入方法依赖的package包/类
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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:16,代码来源:ExtractTempRefactoring.java


注:本文中的org.eclipse.jdt.core.dom.Assignment.getLeftHandSide方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。