本文整理汇总了Java中org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CastVariable2类的典型用法代码示例。如果您正苦于以下问题:Java CastVariable2类的具体用法?Java CastVariable2怎么用?Java CastVariable2使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CastVariable2类属于org.eclipse.jdt.internal.corext.refactoring.typeconstraints2包,在下文中一共展示了CastVariable2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeObsoleteCasts
import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CastVariable2; //导入依赖的package包/类
/**
* Computes the obsolete casts for the specified cast variables.
*
* @param variables the cast variables (element type: <code>CastVariable2</code>)
*/
private void computeObsoleteCasts(final Collection<CastVariable2> variables) {
fObsoleteCasts= new HashMap<ICompilationUnit, Collection<CastVariable2>>();
CastVariable2 variable= null;
for (final Iterator<CastVariable2> iterator= variables.iterator(); iterator.hasNext();) {
variable= iterator.next();
final TType type= (TType) variable.getExpressionVariable().getData(DATA_TYPE_ESTIMATE);
if (type != null && type.canAssignTo(variable.getType())) {
final ICompilationUnit unit= variable.getCompilationUnit();
Collection<CastVariable2> casts= fObsoleteCasts.get(unit);
if (casts != null)
casts.add(variable);
else {
casts= new ArrayList<CastVariable2>(1);
casts.add(variable);
fObsoleteCasts.put(unit, casts);
}
}
}
}
示例2: rewriteDeclarations
import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CastVariable2; //导入依赖的package包/类
private void rewriteDeclarations(InferTypeArgumentsUpdate update, IProgressMonitor pm)
throws CoreException {
HashMap<ICompilationUnit, CuUpdate> updates = update.getUpdates();
Set<Entry<ICompilationUnit, CuUpdate>> entrySet = updates.entrySet();
pm.beginTask("", entrySet.size()); // $NON-NLS-1$
pm.setTaskName(RefactoringCoreMessages.InferTypeArgumentsRefactoring_creatingChanges);
for (Iterator<Entry<ICompilationUnit, CuUpdate>> iter = entrySet.iterator(); iter.hasNext(); ) {
if (pm.isCanceled()) throw new OperationCanceledException();
Entry<ICompilationUnit, CuUpdate> entry = iter.next();
ICompilationUnit cu = entry.getKey();
pm.worked(1);
pm.subTask(BasicElementLabels.getFileName(cu));
CompilationUnitRewrite rewrite = new CompilationUnitRewrite(cu);
rewrite.setResolveBindings(false);
CuUpdate cuUpdate = entry.getValue();
for (Iterator<CollectionElementVariable2> cvIter = cuUpdate.getDeclarations().iterator();
cvIter.hasNext(); ) {
ConstraintVariable2 cv = cvIter.next();
rewriteConstraintVariable(cv, rewrite, fTCModel, fLeaveUnconstrainedRaw, null);
}
for (Iterator<CastVariable2> castsIter = cuUpdate.getCastsToRemove().iterator();
castsIter.hasNext(); ) {
CastVariable2 castCv = castsIter.next();
rewriteCastVariable(castCv, rewrite, fTCModel);
}
CompilationUnitChange change = rewrite.createChange(true);
if (change != null) {
fChangeManager.manage(cu, change);
}
}
}
示例3: rewriteCastVariable
import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CastVariable2; //导入依赖的package包/类
private static ASTNode rewriteCastVariable(
CastVariable2 castCv,
CompilationUnitRewrite rewrite,
InferTypeArgumentsTCModel tCModel) { // , List positionGroups) {
ASTNode node = castCv.getRange().getNode(rewrite.getRoot());
ConstraintVariable2 expressionVariable = castCv.getExpressionVariable();
ConstraintVariable2 methodReceiverCv = tCModel.getMethodReceiverCv(expressionVariable);
if (methodReceiverCv != null) {
TType chosenReceiverType =
InferTypeArgumentsConstraintsSolver.getChosenType(methodReceiverCv);
if (chosenReceiverType == null) return null;
else if (!InferTypeArgumentsTCModel.isAGenericType(chosenReceiverType)) return null;
else if (hasUnboundElement(methodReceiverCv, tCModel)) return null;
}
CastExpression castExpression = (CastExpression) node;
Expression expression = castExpression.getExpression();
ASTNode nodeToReplace;
if (castExpression.getParent() instanceof ParenthesizedExpression)
nodeToReplace = castExpression.getParent();
else nodeToReplace = castExpression;
Expression newExpression = (Expression) rewrite.getASTRewrite().createMoveTarget(expression);
rewrite
.getASTRewrite()
.replace(
nodeToReplace,
newExpression,
rewrite.createGroupDescription(
RefactoringCoreMessages.InferTypeArgumentsRefactoring_removeCast));
rewrite.getImportRemover().registerRemovedNode(nodeToReplace);
return newExpression;
}
示例4: InferTypeArgumentsTCModel
import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CastVariable2; //导入依赖的package包/类
public InferTypeArgumentsTCModel() {
fTypeConstraints = new HashMap<ITypeConstraint2, ITypeConstraint2>();
fConstraintVariables =
new LinkedHashMap<
ConstraintVariable2,
ConstraintVariable2>(); // make iteration independent of hashCode() implementation
fCastVariables = new ArrayList<CastVariable2>();
fCuScopedConstraintVariables = new HashSet<ConstraintVariable2>();
fTypeEnvironment = new TypeEnvironment(true);
}
示例5: makeCastVariable
import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CastVariable2; //导入依赖的package包/类
public CastVariable2 makeCastVariable(
CastExpression castExpression, ConstraintVariable2 expressionCv) {
ITypeBinding typeBinding = castExpression.resolveTypeBinding();
ICompilationUnit cu = RefactoringASTParser.getCompilationUnit(castExpression);
CompilationUnitRange range = new CompilationUnitRange(cu, castExpression);
CastVariable2 castCv = new CastVariable2(createTType(typeBinding), range, expressionCv);
fCastVariables.add(castCv);
return castCv;
}
示例6: findCastsToRemove
import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CastVariable2; //导入依赖的package包/类
private void findCastsToRemove(CastVariable2[] castVariables) {
for (int i = 0; i < castVariables.length; i++) {
CastVariable2 castCv = castVariables[i];
ConstraintVariable2 expressionVariable = castCv.getExpressionVariable();
TType chosenType = InferTypeArgumentsConstraintsSolver.getChosenType(expressionVariable);
TType castType = castCv.getType();
TType expressionType = expressionVariable.getType();
if (chosenType != null && TTypes.canAssignTo(chosenType, castType)) {
if (chosenType.equals(expressionType))
continue; // The type has not changed. Don't remove the cast, since it could be
// there to get access to default-visible members or to
// unify types of conditional expressions.
fUpdate.addCastToRemove(castCv);
} else if (expressionVariable instanceof ArrayTypeVariable2
&& castType.isArrayType()) { // bug 97258
ArrayElementVariable2 arrayElementCv = fTCModel.getArrayElementVariable(expressionVariable);
if (arrayElementCv == null) continue;
TType chosenArrayElementType =
InferTypeArgumentsConstraintsSolver.getChosenType(arrayElementCv);
if (chosenArrayElementType != null
&& TTypes.canAssignTo(
chosenArrayElementType, ((ArrayType) castType).getComponentType())) {
if (expressionType instanceof ArrayType
&& chosenArrayElementType.equals(((ArrayType) expressionType).getComponentType()))
continue; // The type has not changed. Don't remove the cast, since it could be
// there to unify types of conditional expressions.
fUpdate.addCastToRemove(castCv);
}
}
}
}
示例7: createCastVariable
import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CastVariable2; //导入依赖的package包/类
/**
* Creates a cast variable.
*
* @param expression the cast expression
* @param variable the associated constraint variable
* @return the created cast variable, or <code>null</code>
*/
public final ConstraintVariable2 createCastVariable(final CastExpression expression, final ConstraintVariable2 variable) {
ITypeBinding binding= expression.resolveTypeBinding();
if (binding.isArray())
binding= binding.getElementType();
if (isConstrainedType(binding)) {
final CastVariable2 result= new CastVariable2(createTType(binding), new CompilationUnitRange(RefactoringASTParser.getCompilationUnit(expression), expression), variable);
fCastVariables.add(result);
return result;
}
return null;
}
示例8: rewriteDeclarations
import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CastVariable2; //导入依赖的package包/类
private void rewriteDeclarations(InferTypeArgumentsUpdate update, IProgressMonitor pm) throws CoreException {
HashMap<ICompilationUnit, CuUpdate> updates= update.getUpdates();
Set<Entry<ICompilationUnit, CuUpdate>> entrySet= updates.entrySet();
pm.beginTask("", entrySet.size()); //$NON-NLS-1$
pm.setTaskName(RefactoringCoreMessages.InferTypeArgumentsRefactoring_creatingChanges);
for (Iterator<Entry<ICompilationUnit, CuUpdate>> iter= entrySet.iterator(); iter.hasNext();) {
if (pm.isCanceled())
throw new OperationCanceledException();
Entry<ICompilationUnit, CuUpdate> entry= iter.next();
ICompilationUnit cu= entry.getKey();
pm.worked(1);
pm.subTask(BasicElementLabels.getFileName(cu));
CompilationUnitRewrite rewrite= new CompilationUnitRewrite(cu);
rewrite.setResolveBindings(false);
CuUpdate cuUpdate= entry.getValue();
for (Iterator<CollectionElementVariable2> cvIter= cuUpdate.getDeclarations().iterator(); cvIter.hasNext();) {
ConstraintVariable2 cv= cvIter.next();
rewriteConstraintVariable(cv, rewrite, fTCModel, fLeaveUnconstrainedRaw, null);
}
for (Iterator<CastVariable2> castsIter= cuUpdate.getCastsToRemove().iterator(); castsIter.hasNext();) {
CastVariable2 castCv= castsIter.next();
rewriteCastVariable(castCv, rewrite, fTCModel);
}
CompilationUnitChange change= rewrite.createChange(true);
if (change != null) {
fChangeManager.manage(cu, change);
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:37,代码来源:InferTypeArgumentsRefactoring.java
示例9: rewriteCastVariable
import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CastVariable2; //导入依赖的package包/类
private static ASTNode rewriteCastVariable(CastVariable2 castCv, CompilationUnitRewrite rewrite, InferTypeArgumentsTCModel tCModel) {//, List positionGroups) {
ASTNode node= castCv.getRange().getNode(rewrite.getRoot());
ConstraintVariable2 expressionVariable= castCv.getExpressionVariable();
ConstraintVariable2 methodReceiverCv= tCModel.getMethodReceiverCv(expressionVariable);
if (methodReceiverCv != null) {
TType chosenReceiverType= InferTypeArgumentsConstraintsSolver.getChosenType(methodReceiverCv);
if (chosenReceiverType == null)
return null;
else if (! InferTypeArgumentsTCModel.isAGenericType(chosenReceiverType))
return null;
else if (hasUnboundElement(methodReceiverCv, tCModel))
return null;
}
CastExpression castExpression= (CastExpression) node;
Expression expression= castExpression.getExpression();
ASTNode nodeToReplace;
if (castExpression.getParent() instanceof ParenthesizedExpression)
nodeToReplace= castExpression.getParent();
else
nodeToReplace= castExpression;
Expression newExpression= (Expression) rewrite.getASTRewrite().createMoveTarget(expression);
rewrite.getASTRewrite().replace(nodeToReplace, newExpression, rewrite.createGroupDescription(RefactoringCoreMessages.InferTypeArgumentsRefactoring_removeCast));
rewrite.getImportRemover().registerRemovedNode(nodeToReplace);
return newExpression;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:29,代码来源:InferTypeArgumentsRefactoring.java
示例10: InferTypeArgumentsTCModel
import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CastVariable2; //导入依赖的package包/类
public InferTypeArgumentsTCModel() {
fTypeConstraints= new HashMap<ITypeConstraint2, ITypeConstraint2>();
fConstraintVariables= new LinkedHashMap<ConstraintVariable2, ConstraintVariable2>(); // make iteration independent of hashCode() implementation
fCastVariables= new ArrayList<CastVariable2>();
fCuScopedConstraintVariables= new HashSet<ConstraintVariable2>();
fTypeEnvironment= new TypeEnvironment(true);
}
示例11: makeCastVariable
import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CastVariable2; //导入依赖的package包/类
public CastVariable2 makeCastVariable(CastExpression castExpression, ConstraintVariable2 expressionCv) {
ITypeBinding typeBinding= castExpression.resolveTypeBinding();
ICompilationUnit cu= RefactoringASTParser.getCompilationUnit(castExpression);
CompilationUnitRange range= new CompilationUnitRange(cu, castExpression);
CastVariable2 castCv= new CastVariable2(createTType(typeBinding), range, expressionCv);
fCastVariables.add(castCv);
return castCv;
}
示例12: findCastsToRemove
import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CastVariable2; //导入依赖的package包/类
private void findCastsToRemove(CastVariable2[] castVariables) {
for (int i= 0; i < castVariables.length; i++) {
CastVariable2 castCv= castVariables[i];
ConstraintVariable2 expressionVariable= castCv.getExpressionVariable();
TType chosenType= InferTypeArgumentsConstraintsSolver.getChosenType(expressionVariable);
TType castType= castCv.getType();
TType expressionType= expressionVariable.getType();
if (chosenType != null && TTypes.canAssignTo(chosenType, castType)) {
if (chosenType.equals(expressionType))
continue; // The type has not changed. Don't remove the cast, since it could be
// there to get access to default-visible members or to
// unify types of conditional expressions.
fUpdate.addCastToRemove(castCv);
} else if (expressionVariable instanceof ArrayTypeVariable2 && castType.isArrayType()) { // bug 97258
ArrayElementVariable2 arrayElementCv= fTCModel.getArrayElementVariable(expressionVariable);
if (arrayElementCv == null)
continue;
TType chosenArrayElementType= InferTypeArgumentsConstraintsSolver.getChosenType(arrayElementCv);
if (chosenArrayElementType != null && TTypes.canAssignTo(chosenArrayElementType, ((ArrayType) castType).getComponentType())) {
if (expressionType instanceof ArrayType && chosenArrayElementType.equals(((ArrayType) expressionType).getComponentType()))
continue; // The type has not changed. Don't remove the cast, since it could be
// there to unify types of conditional expressions.
fUpdate.addCastToRemove(castCv);
}
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:29,代码来源:InferTypeArgumentsConstraintsSolver.java
示例13: createCastVariable
import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CastVariable2; //导入依赖的package包/类
/**
* Creates a cast variable.
*
* @param expression the cast expression
* @param variable the associated constraint variable
* @return the created cast variable
*/
public final ConstraintVariable2 createCastVariable(final CastExpression expression, final ConstraintVariable2 variable) {
ITypeBinding binding= expression.resolveTypeBinding();
if (binding.isArray())
binding= binding.getElementType();
if (isConstrainedType(binding)) {
final CastVariable2 result= new CastVariable2(createTType(binding), new CompilationUnitRange(RefactoringASTParser.getCompilationUnit(expression), expression), variable);
fCastVariables.add(result);
return result;
}
return null;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:19,代码来源:SuperTypeConstraintsModel.java
示例14: getCastVariables
import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CastVariable2; //导入依赖的package包/类
public CastVariable2[] getCastVariables() {
return fCastVariables.toArray(new CastVariable2[fCastVariables.size()]);
}
示例15: getCastsToRemove
import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CastVariable2; //导入依赖的package包/类
public List<CastVariable2> getCastsToRemove() {
return fCastsToRemove;
}