本文整理汇总了Java中org.eclipse.jdt.core.dom.CastExpression.getType方法的典型用法代码示例。如果您正苦于以下问题:Java CastExpression.getType方法的具体用法?Java CastExpression.getType怎么用?Java CastExpression.getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.CastExpression
的用法示例。
在下文中一共展示了CastExpression.getType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import org.eclipse.jdt.core.dom.CastExpression; //导入方法依赖的package包/类
@Override
public ITypeConstraint[] create(CastExpression castExpression) {
Expression expression = castExpression.getExpression();
Type type = castExpression.getType();
ITypeConstraint[] definesConstraint =
fTypeConstraintFactory.createDefinesConstraint(
fConstraintVariableFactory.makeExpressionOrTypeVariable(castExpression, getContext()),
fConstraintVariableFactory.makeTypeVariable(castExpression.getType()));
if (isClassBinding(expression.resolveTypeBinding()) && isClassBinding(type.resolveBinding())) {
ConstraintVariable expressionVariable =
fConstraintVariableFactory.makeExpressionOrTypeVariable(expression, getContext());
ConstraintVariable castExpressionVariable =
fConstraintVariableFactory.makeExpressionOrTypeVariable(castExpression, getContext());
ITypeConstraint[] c2 =
createOrOrSubtypeConstraint(expressionVariable, castExpressionVariable);
if (definesConstraint.length == 0) {
return c2;
} else {
ITypeConstraint c1 = definesConstraint[0];
Collection<ITypeConstraint> constraints = new ArrayList<ITypeConstraint>();
constraints.add(c1);
constraints.addAll(Arrays.asList(c2));
return constraints.toArray(new ITypeConstraint[constraints.size()]);
}
} else return definesConstraint;
}
示例2: create
import org.eclipse.jdt.core.dom.CastExpression; //导入方法依赖的package包/类
@Override
public ITypeConstraint[] create(CastExpression castExpression){
Expression expression= castExpression.getExpression();
Type type= castExpression.getType();
ITypeConstraint[] definesConstraint= fTypeConstraintFactory.createDefinesConstraint(fConstraintVariableFactory.makeExpressionOrTypeVariable(castExpression, getContext()),
fConstraintVariableFactory.makeTypeVariable(castExpression.getType()));
if (isClassBinding(expression.resolveTypeBinding()) && isClassBinding(type.resolveBinding())){
ConstraintVariable expressionVariable= fConstraintVariableFactory.makeExpressionOrTypeVariable(expression, getContext());
ConstraintVariable castExpressionVariable= fConstraintVariableFactory.makeExpressionOrTypeVariable(castExpression, getContext());
ITypeConstraint[] c2 = createOrOrSubtypeConstraint(expressionVariable, castExpressionVariable);
if (definesConstraint.length == 0){
return c2;
} else {
ITypeConstraint c1 = definesConstraint[0];
Collection<ITypeConstraint> constraints= new ArrayList<ITypeConstraint>();
constraints.add(c1);
constraints.addAll(Arrays.asList(c2));
return constraints.toArray(new ITypeConstraint[constraints.size()]);
}
} else
return definesConstraint;
}
示例3: visit
import org.eclipse.jdt.core.dom.CastExpression; //导入方法依赖的package包/类
@Override
public boolean visit(CastExpression node) {
if ("java.lang.ClassCastException".equals(fException.getQualifiedName())) { //$NON-NLS-1$
Type type= node.getType();
fResult.add(new OccurrenceLocation(type.getStartPosition(), type.getLength(), 0, fDescription));
}
return super.visit(node);
}
示例4: visit
import org.eclipse.jdt.core.dom.CastExpression; //导入方法依赖的package包/类
@Override
public final boolean visit(CastExpression node) {
Type type = node.getType();
handleTypeBinding(node, type.resolveBinding(), true);
return true;
}
示例5: endVisit
import org.eclipse.jdt.core.dom.CastExpression; //导入方法依赖的package包/类
@Override
public void endVisit(CastExpression node) {
// if (! (expressionCv instanceof CollectionElementVariable2))
// return; //TODO: returns too early when dealing with nested collections.
Type type = node.getType();
ITypeBinding typeBinding = type.resolveBinding();
if (typeBinding.isPrimitive()) {
ImmutableTypeVariable2 boxed = fTCModel.makeImmutableTypeVariable(typeBinding, node);
setConstraintVariable(node, boxed);
return; // avoid removing numeric conversions
}
ConstraintVariable2 typeCv = getConstraintVariable(type);
if (typeCv == null) return;
// TODO: can this be loosened when we remove casts?
setConstraintVariable(node, typeCv);
Expression expression = node.getExpression();
ConstraintVariable2 expressionCv = getConstraintVariable(expression);
// Avoid removing casts that have not been made obsolete by this refactoring:
if (expressionCv == null) return;
if (expressionCv instanceof ImmutableTypeVariable2) return;
if (!(expressionCv instanceof TypeVariable2
|| expressionCv instanceof IndependentTypeVariable2
|| expressionCv instanceof CollectionElementVariable2)
&& fTCModel.getElementVariables(expressionCv).size() == 0
&& fTCModel.getArrayElementVariable(expressionCv) == null) return;
fTCModel.createAssignmentElementConstraints(typeCv, expressionCv);
if (expression instanceof MethodInvocation) {
MethodInvocation invoc = (MethodInvocation) expression;
if (!isSpecialCloneInvocation(invoc.resolveMethodBinding(), invoc.getExpression())) {
fTCModel.makeCastVariable(node, expressionCv);
}
} else {
fTCModel.makeCastVariable(node, expressionCv);
}
boolean eitherIsIntf =
typeBinding.isInterface() || expression.resolveTypeBinding().isInterface();
if (eitherIsIntf) return;
// TODO: preserve up- and down-castedness!
}
示例6: endVisit
import org.eclipse.jdt.core.dom.CastExpression; //导入方法依赖的package包/类
@Override
public void endVisit(CastExpression node) {
// if (! (expressionCv instanceof CollectionElementVariable2))
// return; //TODO: returns too early when dealing with nested collections.
Type type= node.getType();
ITypeBinding typeBinding= type.resolveBinding();
if (typeBinding.isPrimitive()) {
ImmutableTypeVariable2 boxed= fTCModel.makeImmutableTypeVariable(typeBinding, node);
setConstraintVariable(node, boxed);
return; // avoid removing numeric conversions
}
ConstraintVariable2 typeCv= getConstraintVariable(type);
if (typeCv == null)
return;
//TODO: can this be loosened when we remove casts?
setConstraintVariable(node, typeCv);
Expression expression= node.getExpression();
ConstraintVariable2 expressionCv= getConstraintVariable(expression);
//Avoid removing casts that have not been made obsolete by this refactoring:
if (expressionCv == null)
return;
if (expressionCv instanceof ImmutableTypeVariable2)
return;
if (! (expressionCv instanceof TypeVariable2 || expressionCv instanceof IndependentTypeVariable2 || expressionCv instanceof CollectionElementVariable2)
&& fTCModel.getElementVariables(expressionCv).size() == 0 && fTCModel.getArrayElementVariable(expressionCv) == null)
return;
fTCModel.createAssignmentElementConstraints(typeCv, expressionCv);
if (expression instanceof MethodInvocation) {
MethodInvocation invoc= (MethodInvocation) expression;
if (! isSpecialCloneInvocation(invoc.resolveMethodBinding(), invoc.getExpression())) {
fTCModel.makeCastVariable(node, expressionCv);
}
} else {
fTCModel.makeCastVariable(node, expressionCv);
}
boolean eitherIsIntf= typeBinding.isInterface() || expression.resolveTypeBinding().isInterface();
if (eitherIsIntf)
return;
//TODO: preserve up- and down-castedness!
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:51,代码来源:InferTypeArgumentsConstraintCreator.java