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


Java ConditionalExpression类代码示例

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


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

示例1: getStatementType

import org.eclipse.jdt.core.dom.ConditionalExpression; //导入依赖的package包/类
/**
 * Method that check statement type.
 * @author Mariana Azevedo
 * @since 13/07/2014
 * @param itStatement
 */
private void getStatementType(Object itStatement) {
	if (itStatement instanceof CatchClause){
		this.visitor.visit((CatchClause)itStatement);
	}else if (itStatement instanceof ForStatement){
		this.visitor.visit((ForStatement)itStatement);
	}else if (itStatement instanceof IfStatement){
		this.visitor.visit((IfStatement)itStatement);
	}else if (itStatement instanceof WhileStatement){
		this.visitor.visit((WhileStatement)itStatement);
	}else if (itStatement instanceof TryStatement){
		this.visitor.visit((TryStatement)itStatement);
	}else if (itStatement instanceof ConditionalExpression){
		this.visitor.visit((ConditionalExpression)itStatement);
	}else if (itStatement instanceof SwitchCase){
		this.visitor.visit((SwitchCase)itStatement);
	}else if (itStatement instanceof DoStatement){
		this.visitor.visit((DoStatement)itStatement);
	}else if (itStatement instanceof ExpressionStatement){
		this.visitor.visit((ExpressionStatement)itStatement);
	}
}
 
开发者ID:mariazevedo88,项目名称:o3smeasures-tool,代码行数:28,代码来源:WeightMethodsPerClassVisitor.java

示例2: resolveBinding

import org.eclipse.jdt.core.dom.ConditionalExpression; //导入依赖的package包/类
public static IBinding resolveBinding(Expression expression) {
  if (expression instanceof Name) return ((Name) expression).resolveBinding();
  if (expression instanceof ParenthesizedExpression)
    return resolveBinding(((ParenthesizedExpression) expression).getExpression());
  else if (expression instanceof Assignment)
    return resolveBinding(((Assignment) expression).getLeftHandSide()); // TODO ???
  else if (expression instanceof MethodInvocation)
    return ((MethodInvocation) expression).resolveMethodBinding();
  else if (expression instanceof SuperMethodInvocation)
    return ((SuperMethodInvocation) expression).resolveMethodBinding();
  else if (expression instanceof FieldAccess)
    return ((FieldAccess) expression).resolveFieldBinding();
  else if (expression instanceof SuperFieldAccess)
    return ((SuperFieldAccess) expression).resolveFieldBinding();
  else if (expression instanceof ConditionalExpression)
    return resolveBinding(((ConditionalExpression) expression).getThenExpression());
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:ExpressionVariable.java

示例3: create

import org.eclipse.jdt.core.dom.ConditionalExpression; //导入依赖的package包/类
@Override
public ITypeConstraint[] create(ConditionalExpression node) {
  List<ITypeConstraint> result = new ArrayList<ITypeConstraint>();
  Expression thenExpression = node.getThenExpression();
  Expression elseExpression = node.getElseExpression();
  ConstraintVariable whole =
      fConstraintVariableFactory.makeExpressionOrTypeVariable(node, getContext());
  ConstraintVariable ev1 =
      fConstraintVariableFactory.makeExpressionOrTypeVariable(thenExpression, getContext());
  ConstraintVariable ev2 =
      fConstraintVariableFactory.makeExpressionOrTypeVariable(elseExpression, getContext());
  ITypeConstraint[] constraints1 = fTypeConstraintFactory.createEqualsConstraint(ev1, ev2);
  ITypeConstraint[] constraints2 = fTypeConstraintFactory.createSubtypeConstraint(ev1, whole);
  ITypeConstraint[] constraints3 = fTypeConstraintFactory.createSubtypeConstraint(ev2, whole);
  result.addAll(Arrays.asList(constraints1));
  result.addAll(Arrays.asList(constraints2));
  result.addAll(Arrays.asList(constraints3));
  return result.toArray(new ITypeConstraint[result.size()]);
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:FullConstraintCreator.java

示例4: resolveBinding

import org.eclipse.jdt.core.dom.ConditionalExpression; //导入依赖的package包/类
public static IBinding resolveBinding(Expression expression){
	if (expression instanceof Name)
		return ((Name)expression).resolveBinding();
	if (expression instanceof ParenthesizedExpression)
		return resolveBinding(((ParenthesizedExpression)expression).getExpression());
	else if (expression instanceof Assignment)
		return resolveBinding(((Assignment)expression).getLeftHandSide());//TODO ???
	else if (expression instanceof MethodInvocation)
		return ((MethodInvocation)expression).resolveMethodBinding();
	else if (expression instanceof SuperMethodInvocation)
		return ((SuperMethodInvocation)expression).resolveMethodBinding();
	else if (expression instanceof FieldAccess)
		return ((FieldAccess)expression).resolveFieldBinding();
	else if (expression instanceof SuperFieldAccess)
		return ((SuperFieldAccess)expression).resolveFieldBinding();
	else if (expression instanceof ConditionalExpression)
		return resolveBinding(((ConditionalExpression)expression).getThenExpression());
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:ExpressionVariable.java

示例5: create

import org.eclipse.jdt.core.dom.ConditionalExpression; //导入依赖的package包/类
@Override
public ITypeConstraint[] create(ConditionalExpression node) {
	List<ITypeConstraint> result= new ArrayList<ITypeConstraint>();
	Expression thenExpression= node.getThenExpression();
	Expression elseExpression= node.getElseExpression();
	ConstraintVariable whole= fConstraintVariableFactory.makeExpressionOrTypeVariable(node, getContext());
	ConstraintVariable ev1= fConstraintVariableFactory.makeExpressionOrTypeVariable(thenExpression, getContext());
	ConstraintVariable ev2= fConstraintVariableFactory.makeExpressionOrTypeVariable(elseExpression, getContext());
	ITypeConstraint[] constraints1= fTypeConstraintFactory.createEqualsConstraint(ev1, ev2);
	ITypeConstraint[] constraints2= fTypeConstraintFactory.createSubtypeConstraint(ev1, whole);
	ITypeConstraint[] constraints3= fTypeConstraintFactory.createSubtypeConstraint(ev2, whole);
	result.addAll(Arrays.asList(constraints1));
	result.addAll(Arrays.asList(constraints2));
	result.addAll(Arrays.asList(constraints3));
	return result.toArray(new ITypeConstraint[result.size()]);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:FullConstraintCreator.java

示例6: createAddQualifiedHashCode

import org.eclipse.jdt.core.dom.ConditionalExpression; //导入依赖的package包/类
private Statement createAddQualifiedHashCode(IVariableBinding binding) {

		MethodInvocation invoc= fAst.newMethodInvocation();
		invoc.setExpression(getThisAccessForHashCode(binding.getName()));
		invoc.setName(fAst.newSimpleName(METHODNAME_HASH_CODE));

		InfixExpression expr= fAst.newInfixExpression();
		expr.setOperator(Operator.EQUALS);
		expr.setLeftOperand(getThisAccessForHashCode(binding.getName()));
		expr.setRightOperand(fAst.newNullLiteral());

		ConditionalExpression cexpr= fAst.newConditionalExpression();
		cexpr.setThenExpression(fAst.newNumberLiteral("0")); //$NON-NLS-1$
		cexpr.setElseExpression(invoc);
		cexpr.setExpression(parenthesize(expr));

		return prepareAssignment(parenthesize(cexpr));
	}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:GenerateHashCodeEqualsOperation.java

示例7: visit

import org.eclipse.jdt.core.dom.ConditionalExpression; //导入依赖的package包/类
@Override
public boolean visit(ConditionalExpression node) {
    if (expressionToReplace != null) {
        return false;
    }

    if (node.getExpression() instanceof InfixExpression) {
        InfixExpression condExpr = (InfixExpression) node.getExpression();
        boolean retVal = findFirstAndSecondFloat(node, condExpr);
        if (condExpr.getOperator() == InfixExpression.Operator.GREATER) {
            return retVal;
        }
        else if (condExpr.getOperator() == InfixExpression.Operator.LESS) {
            swapFirstAndSecondFloat();
            return retVal;
        }
    }
    return true;
}
 
开发者ID:kjlubick,项目名称:fb-contrib-eclipse-quick-fixes,代码行数:20,代码来源:CompareFloatResolution.java

示例8: findFirstAndSecondFloat

import org.eclipse.jdt.core.dom.ConditionalExpression; //导入依赖的package包/类
private boolean findFirstAndSecondFloat(ConditionalExpression node, InfixExpression condExpr) {
    if (!handleTwoSimpleNames(node, condExpr)) {
        // this is a if diff > 0 case
        try {
            if (condExpr.getLeftOperand() instanceof SimpleName) {
                findDiffAndFloats((SimpleName) condExpr.getLeftOperand());
            } else if (condExpr.getRightOperand() instanceof SimpleName) {
                findDiffAndFloats((SimpleName) condExpr.getRightOperand());
            } else {
                return true; // unexpected comparison
            }
            floatOrDouble = getFloatOrDouble(firstFloat, secondFloat);
            expressionToReplace = node;

        } catch (CouldntFindDiffException e) {
            return true; // keep nesting if we have a problem
        }
    }
    return false;
}
 
开发者ID:kjlubick,项目名称:fb-contrib-eclipse-quick-fixes,代码行数:21,代码来源:CompareFloatResolution.java

示例9: fillConditionalExpression

import org.eclipse.jdt.core.dom.ConditionalExpression; //导入依赖的package包/类
/**
 * Fills conditional/ternary skeleton pieces.
 * @param node The conditional/ternary part of the skeleton.
 * @param curConstraint The constraint for the type of the
 * expressions generated from this piece of the skeleton.
 * @param parentsOfHoles All nodes that are parents of some hole.
 * @return The synthesized expressions corresponding to this
 * skeleton piece and the type constraint representing their types.
 */
private ExpressionsAndTypeConstraints fillConditionalExpression(Expression node, TypeConstraint curConstraint, Set<ASTNode> parentsOfHoles) {
	ConditionalExpression cond = (ConditionalExpression)node;
	// TODO: Do a better job of constraining left/right to be similar?  E.g., if we have right but not left.
	ExpressionsAndTypeConstraints condResult = fillSkeleton(cond.getExpression(), new SupertypeBound(booleanType), parentsOfHoles);
	ExpressionsAndTypeConstraints thenResult = fillSkeleton(cond.getThenExpression(), curConstraint, parentsOfHoles);
	ExpressionsAndTypeConstraints elseResult = fillSkeleton(cond.getElseExpression(), curConstraint, parentsOfHoles);
	Map<String, ArrayList<codehint.ast.Expression>> resultExprs = new HashMap<String, ArrayList<codehint.ast.Expression>>(thenResult.getExprs().size());
	for (codehint.ast.Expression condExpr: Utils.singleton(condResult.getExprs().values()))
		for (Map.Entry<String, ArrayList<codehint.ast.Expression>> thenExprs: thenResult.getExprs().entrySet()) {
			IJavaType thenType = "null".equals(thenExprs.getKey()) ? null : EclipseUtils.getFullyQualifiedType(thenExprs.getKey(), stack, target, typeCache);
			for (Map.Entry<String, ArrayList<codehint.ast.Expression>> elseExprs: elseResult.getExprs().entrySet()) {
				IJavaType elseType = "null".equals(elseExprs.getKey()) ? null : EclipseUtils.getFullyQualifiedType(elseExprs.getKey(), stack, target, typeCache);
				if ((thenType == null && EclipseUtils.isObject(elseType)) || (elseType == null && EclipseUtils.isObject(thenType)) || subtypeChecker.isSubtypeOf(thenType, elseType) || subtypeChecker.isSubtypeOf(elseType, thenType))
					for (codehint.ast.Expression thenExpr: thenExprs.getValue())
						for (codehint.ast.Expression elseExpr: elseExprs.getValue())
							Utils.addToListMap(resultExprs, thenExprs.getKey(), expressionMaker.makeConditional(condExpr, thenExpr, elseExpr, thenExpr.getStaticType()));
			}
		}
	return new ExpressionsAndTypeConstraints(resultExprs, thenResult.getTypeConstraint());
}
 
开发者ID:jgalenson,项目名称:codehint,代码行数:30,代码来源:ExpressionSkeleton.java

示例10: visit

import org.eclipse.jdt.core.dom.ConditionalExpression; //导入依赖的package包/类
/**
 * @see ASTVisitor#visit(ConditionalExpression)
 */
@Override
public boolean visit(ConditionalExpression node) {
	cyclomaticComplexityIndex++;
	sumCyclomaticComplexity++;
	inspectExpression(node.getExpression());
	return true;
}
 
开发者ID:mariazevedo88,项目名称:o3smeasures-tool,代码行数:11,代码来源:CyclomaticComplexityVisitor.java

示例11: endVisit

import org.eclipse.jdt.core.dom.ConditionalExpression; //导入依赖的package包/类
@Override
public void endVisit(ConditionalExpression node) {
	if (skipNode(node)) {
		return;
	}
	Expression thenPart = node.getThenExpression();
	Expression elsePart = node.getElseExpression();
	if ((thenPart != null && fSelection.coveredBy(thenPart)) || (elsePart != null && fSelection.coveredBy(elsePart))) {
		GenericSequentialFlowInfo info = createSequential();
		setFlowInfo(node, info);
		endVisitConditional(info, node.getExpression(), new ASTNode[] { thenPart, elsePart });
	} else {
		super.endVisit(node);
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:16,代码来源:InputFlowAnalyzer.java

示例12: endVisit

import org.eclipse.jdt.core.dom.ConditionalExpression; //导入依赖的package包/类
@Override
public void endVisit(ConditionalExpression node) {
	if (skipNode(node)) {
		return;
	}
	ConditionalFlowInfo info = createConditional();
	setFlowInfo(node, info);
	info.mergeCondition(getFlowInfo(node.getExpression()), fFlowContext);
	info.merge(getFlowInfo(node.getThenExpression()), getFlowInfo(node.getElseExpression()), fFlowContext);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:11,代码来源:FlowAnalyzer.java

示例13: getExpressionPrecedence

import org.eclipse.jdt.core.dom.ConditionalExpression; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:48,代码来源:OperatorPrecedence.java

示例14: endVisit

import org.eclipse.jdt.core.dom.ConditionalExpression; //导入依赖的package包/类
@Override
public void endVisit(ConditionalExpression node) {
  // for now, no support for passing generic types through conditional expressions
  ImmutableTypeVariable2 boxed =
      fTCModel.makeImmutableTypeVariable(node.resolveTypeBinding(), node);
  setConstraintVariable(node, boxed);
}
 
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:InferTypeArgumentsConstraintCreator.java

示例15: returnsConditionalExpression

import org.eclipse.jdt.core.dom.ConditionalExpression; //导入依赖的package包/类
public boolean returnsConditionalExpression() {
  ASTNode last = getLastStatement();
  if (last instanceof ReturnStatement) {
    return ((ReturnStatement) last).getExpression() instanceof ConditionalExpression;
  }
  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:SourceProvider.java


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