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; }
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; }
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; }
/** * Returns the method which references the specified ast node. * * @param node * the ast node * @return the referencing method * @throws JavaModelException * if an error occurs */ protected final IMethod getReferencingMethod(final ASTNode node) throws JavaModelException { if (node instanceof Type) { final BodyDeclaration parent= (BodyDeclaration) ASTNodes.getParent(node, BodyDeclaration.class); if (parent instanceof MethodDeclaration) { final IMethodBinding binding= ((MethodDeclaration) parent).resolveBinding(); if (binding != null) { final ICompilationUnit unit= RefactoringASTParser.getCompilationUnit(node); final IJavaElement element= unit.getElementAt(node.getStartPosition()); if (element instanceof IMethod) return (IMethod) element; } } } return null; }
/** * Returns the field which corresponds to the specified variable declaration * fragment * * @param fragment * the variable declaration fragment * @return the corresponding field * @throws JavaModelException * if an error occurs */ protected final IField getCorrespondingField(final VariableDeclarationFragment fragment) throws JavaModelException { final IBinding binding= fragment.getName().resolveBinding(); if (binding instanceof IVariableBinding) { final IVariableBinding variable= (IVariableBinding) binding; if (variable.isField()) { final ICompilationUnit unit= RefactoringASTParser.getCompilationUnit(fragment); final IJavaElement element= unit.getElementAt(fragment.getStartPosition()); if (element instanceof IField) return (IField) element; } } return null; }
/** * Creates an exception variable. * * @param name the name of the thrown exception * @return the created exception variable */ public final ConstraintVariable2 createExceptionVariable(final Name name) { final ITypeBinding binding= name.resolveTypeBinding(); if (isConstrainedType(binding)) return (ConstraintVariable2) fConstraintVariables.addExisting(new TypeVariable2(createTType(binding), new CompilationUnitRange(RefactoringASTParser.getCompilationUnit(name), name))); return null; }
/** * Creates an exception variable. * * @param name the name of the thrown exception * @return the created exception variable, or <code>null</code> */ public final ConstraintVariable2 createExceptionVariable(final Name name) { final ITypeBinding binding= name.resolveTypeBinding(); if (isConstrainedType(binding)) return fConstraintVariables.addExisting(new TypeVariable2(createTType(binding), new CompilationUnitRange(RefactoringASTParser.getCompilationUnit(name), name))); return null; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * Creates an exception variable. * * @param name the name of the thrown exception * @return the created exception variable, or <code>null</code> */ public final ConstraintVariable2 createExceptionVariable(final Name name) { final ITypeBinding binding= name.resolveTypeBinding(); if (isConstrainedType(binding)) return fConstraintVariables.addExisting(new TypeVariable2(createTType(binding), new CompilationUnitRange(RefactoringASTParser.getCompilationUnit(name), name))); return null; }
public TypeVariable2 makeTypeVariable(Type type) { ICompilationUnit cu= RefactoringASTParser.getCompilationUnit(type); TType ttype= getBoxedType(type.resolveBinding(), /*no boxing*/null); if (ttype == null) return null; CompilationUnitRange range= new CompilationUnitRange(cu, type); TypeVariable2 typeVariable= new TypeVariable2(ttype, range); TypeVariable2 storedCv= (TypeVariable2) storedCv(typeVariable); if (storedCv == typeVariable) { fCuScopedConstraintVariables.add(storedCv); if (isAGenericType(ttype)) makeElementVariables(storedCv, ttype); makeArrayElementVariable(storedCv); if (JavaPlugin.DEBUG_TYPE_CONSTRAINTS) storedCv.setData(ConstraintVariable2.TO_STRING, type.toString()); } return storedCv; }
public TypeVariable2 makeTypeVariable(Type type) { ICompilationUnit cu= RefactoringASTParser.getCompilationUnit(type); TType ttype= getBoxedType(type.resolveBinding(), /*no boxing*/null); if (ttype == null) return null; CompilationUnitRange range= new CompilationUnitRange(cu, type); TypeVariable2 typeVariable= new TypeVariable2(ttype, range); TypeVariable2 storedCv= (TypeVariable2) storedCv(typeVariable); if (storedCv == typeVariable) { fCuScopedConstraintVariables.add(storedCv); if (isAGenericType(ttype)) makeElementVariables(storedCv, ttype); makeArrayElementVariable(storedCv); if (fStoreToString) storedCv.setData(ConstraintVariable2.TO_STRING, type.toString()); } return storedCv; }
public TypeVariable2 makeTypeVariable(Type type) { ICompilationUnit cu= RefactoringASTParser.getCompilationUnit(type); TType ttype= getBoxedType(type.resolveBinding(), /*no boxing*/null); if (ttype == null) return null; CompilationUnitRange range= new CompilationUnitRange(cu, type); TypeVariable2 typeVariable= new TypeVariable2(ttype, range); TypeVariable2 storedCv= (TypeVariable2) storedCv(typeVariable); if (storedCv == typeVariable) { fCuScopedConstraintVariables.add(storedCv); if (isAGenericType(ttype)) makeElementVariables(storedCv, ttype); makeArrayElementVariable(storedCv); if (JavaPlugin.DEBUG_TYPE_CONSTRAINTS) storedCv.setData(ConstraintVariable2.TO_STRING, type.toString()); } return storedCv; }
/** * Creates a type variable. * * @param type the type * @return the created type variable, or <code>null</code> */ public final ConstraintVariable2 createTypeVariable(final Type type) { ITypeBinding binding= type.resolveBinding(); if (binding != null) { if (binding.isArray()) binding= binding.getElementType(); if (isConstrainedType(binding)) return fConstraintVariables.addExisting(new TypeVariable2(createTType(binding), new CompilationUnitRange(RefactoringASTParser.getCompilationUnit(type), type))); } return null; }
/** * Creates a type variable. * * @param type the type * @return the created type variable */ public final ConstraintVariable2 createTypeVariable(final Type type) { ITypeBinding binding= type.resolveBinding(); if (binding != null) { if (binding.isArray()) binding= binding.getElementType(); if (isConstrainedType(binding)) return (ConstraintVariable2) fConstraintVariables.addExisting(new TypeVariable2(createTType(binding), new CompilationUnitRange(RefactoringASTParser.getCompilationUnit(type), type))); } return null; }
/** * Creates a type variable. * * @param type the type * @return the created type variable, or <code>null</code> */ public final ConstraintVariable2 createTypeVariable(final Type type) { ITypeBinding binding= type.resolveBinding(); if (binding != null) { if (binding.isArray()) binding= binding.getElementType(); if (isConstrainedType(binding)) return fConstraintVariables.addExisting(new TypeVariable2(createTType(binding), new CompilationUnitRange(RefactoringASTParser.getCompilationUnit(type), type))); } return null; }
@Override public final void endVisit(final QualifiedName node) { final ASTNode parent= node.getParent(); final Name qualifier= node.getQualifier(); IBinding binding= qualifier.resolveBinding(); if (binding instanceof ITypeBinding) { final ConstraintVariable2 variable= fModel.createTypeVariable((ITypeBinding) binding, new CompilationUnitRange(RefactoringASTParser.getCompilationUnit(node), new SourceRange(qualifier.getStartPosition(), qualifier.getLength()))); if (variable != null) qualifier.setProperty(PROPERTY_CONSTRAINT_VARIABLE, variable); } binding= node.getName().resolveBinding(); if (binding instanceof IVariableBinding && !(parent instanceof ImportDeclaration)) endVisit((IVariableBinding) binding, qualifier, node); else if (binding instanceof ITypeBinding && parent instanceof MethodDeclaration) endVisit((ITypeBinding) binding, node); }
public final void endVisit(final QualifiedName node) { final ASTNode parent= node.getParent(); final Name qualifier= node.getQualifier(); IBinding binding= qualifier.resolveBinding(); if (binding instanceof ITypeBinding) { final ConstraintVariable2 variable= fModel.createTypeVariable((ITypeBinding) binding, new CompilationUnitRange(RefactoringASTParser.getCompilationUnit(node), new SourceRange(qualifier.getStartPosition(), qualifier.getLength()))); if (variable != null) qualifier.setProperty(PROPERTY_CONSTRAINT_VARIABLE, variable); } binding= node.getName().resolveBinding(); if (binding instanceof IVariableBinding && !(parent instanceof ImportDeclaration)) endVisit((IVariableBinding) binding, qualifier, node); else if (binding instanceof ITypeBinding && parent instanceof MethodDeclaration) endVisit((ITypeBinding) binding, node); }
@Override public final void endVisit(final QualifiedName node) { final ASTNode parent= node.getParent(); final Name qualifier= node.getQualifier(); IBinding binding= qualifier.resolveBinding(); if (binding instanceof ITypeBinding) { final ConstraintVariable2 variable= fModel.createTypeVariable((ITypeBinding) binding, new CompilationUnitRange(RefactoringASTParser.getCompilationUnit(node), new SourceRange(qualifier.getStartPosition(), qualifier.getLength()))); if (variable != null) qualifier.setProperty(PROPERTY_CONSTRAINT_VARIABLE, variable); } binding= node.getName().resolveBinding(); if (binding instanceof IVariableBinding && !(parent instanceof ImportDeclaration)) endVisit((IVariableBinding) binding, qualifier, node); else if (binding instanceof ITypeBinding && parent instanceof MethodDeclaration) endVisit((ITypeBinding) binding, node); }