/** * Collects the necessary imports for an element represented by the specified AST node. * * @param project the java project containing the element * @param node the AST node specifying the element for which imports should be collected * @param typeBindings the set of type bindings (element type: Set <ITypeBinding>). * @param staticBindings the set of bindings (element type: Set <IBinding>). * @param declarations <code>true</code> if method declarations are treated as abstract, <code>false</code> otherwise */ public static void collectImports(final IJavaProject project, final ASTNode node, final Collection<ITypeBinding> typeBindings, final Collection<IBinding> staticBindings, final boolean declarations) { collectImports(project, node, typeBindings, staticBindings, null, declarations); }
/** * Collects the necessary imports for an element represented by the specified AST node. * * @param project the java project containing the element * @param node the AST node specifying the element for which imports should be collected * @param typeBindings the set of type bindings (element type: Set <ITypeBinding>). * @param staticBindings the set of bindings (element type: Set <IBinding>). * @param declarations <code>true</code> if method declarations are treated as abstract, <code>false</code> otherwise */ public static void collectImports(final IJavaProject project, final ASTNode node, final Collection typeBindings, final Collection staticBindings, final boolean declarations) { collectImports(project, node, typeBindings, staticBindings, null, declarations); }
/** * Collects the necessary imports for an element represented by the specified AST node. * * @param project the java project containing the element * @param node the AST node specifying the element for which imports should be collected * @param typeBindings the set of type bindings (element type: Set <ITypeBinding>). * @param staticBindings the set of bindings (element type: Set <IBinding>). * @param declarations <code>true</code> if method declarations are treated as abstract, <code>false</code> otherwise */ public static void collectImports(final IJavaProject project, final ASTNode node, final Collection<ITypeBinding> typeBindings, final Collection<IBinding> staticBindings, final boolean declarations) { collectImports(project, node, typeBindings, staticBindings, null, declarations); }
/** * Creates a new method body rewriter. * * @param targetRewrite * the target compilation unit rewrite to use * @param rewrite * the source ast rewrite to use * @param sourceDeclaration * the source method declaration */ public MethodBodyRewriter(final CompilationUnitRewrite targetRewrite, final ASTRewrite rewrite, final MethodDeclaration sourceDeclaration) { Assert.isNotNull(targetRewrite); Assert.isNotNull(rewrite); Assert.isNotNull(sourceDeclaration); fTargetRewrite= targetRewrite; fRewrite= rewrite; fDeclaration= sourceDeclaration; fStaticImports.clear(); ImportRewriteUtil.collectImports(fMethod.getJavaProject(), sourceDeclaration, new HashSet(), fStaticImports, false); }
/** * Creates a new method body rewriter. * * @param targetRewrite * the target compilation unit rewrite to use * @param rewrite * the source ast rewrite to use * @param sourceDeclaration * the source method declaration */ public MethodBodyRewriter(final CompilationUnitRewrite targetRewrite, final ASTRewrite rewrite, final MethodDeclaration sourceDeclaration) { Assert.isNotNull(targetRewrite); Assert.isNotNull(rewrite); Assert.isNotNull(sourceDeclaration); fTargetRewrite= targetRewrite; fRewrite= rewrite; fDeclaration= sourceDeclaration; fStaticImports.clear(); ImportRewriteUtil.collectImports(fMethod.getJavaProject(), sourceDeclaration, new HashSet<ITypeBinding>(), fStaticImports, false); }
/** * Creates a new method body rewriter. * * @param targetRewrite * the target compilation unit rewrite to use * @param rewrite * the source ast rewrite to use * @param sourceDeclaration * the source method declaration */ public MethodBodyRewriter(final CompilationUnitRewrite targetRewrite, final ASTRewrite rewrite, final MethodDeclaration sourceDeclaration) { Assert.isNotNull(targetRewrite); Assert.isNotNull(rewrite); Assert.isNotNull(sourceDeclaration); fTargetRewrite= targetRewrite; fRewrite= rewrite; fDeclaration= sourceDeclaration; fStaticImports.clear(); ImportRewriteUtil.collectImports(fMethod.getJavaProject(), sourceDeclaration, new HashSet<ITypeBinding>(), fStaticImports, false); }
/** * Creates the type parameters of the new supertype. * * @param targetRewrite * the target compilation unit rewrite * @param subType * the subtype * @param sourceDeclaration * the type declaration of the source type * @param targetDeclaration * the type declaration of the target type */ protected final void createTypeParameters(final ASTRewrite targetRewrite, final IType subType, final AbstractTypeDeclaration sourceDeclaration, final AbstractTypeDeclaration targetDeclaration) { Assert.isNotNull(targetRewrite); Assert.isNotNull(sourceDeclaration); Assert.isNotNull(targetDeclaration); if (sourceDeclaration instanceof TypeDeclaration) { TypeParameter parameter= null; final ListRewrite rewrite= targetRewrite.getListRewrite(targetDeclaration, TypeDeclaration.TYPE_PARAMETERS_PROPERTY); for (final Iterator iterator= ((TypeDeclaration) sourceDeclaration).typeParameters().iterator(); iterator.hasNext();) { parameter= (TypeParameter) iterator.next(); rewrite.insertLast(ASTNode.copySubtree(targetRewrite.getAST(), parameter), null); ImportRewriteUtil.collectImports(subType.getJavaProject(), sourceDeclaration, fTypeBindings, fStaticBindings, false); } } }
/** * Creates the type parameters of the new supertype. * * @param targetRewrite * the target compilation unit rewrite * @param subType * the subtype * @param sourceDeclaration * the type declaration of the source type * @param targetDeclaration * the type declaration of the target type */ protected final void createTypeParameters(final ASTRewrite targetRewrite, final IType subType, final AbstractTypeDeclaration sourceDeclaration, final AbstractTypeDeclaration targetDeclaration) { Assert.isNotNull(targetRewrite); Assert.isNotNull(sourceDeclaration); Assert.isNotNull(targetDeclaration); if (sourceDeclaration instanceof TypeDeclaration) { TypeParameter parameter= null; final ListRewrite rewrite= targetRewrite.getListRewrite(targetDeclaration, TypeDeclaration.TYPE_PARAMETERS_PROPERTY); for (final Iterator<TypeParameter> iterator= ((TypeDeclaration) sourceDeclaration).typeParameters().iterator(); iterator.hasNext();) { parameter= iterator.next(); rewrite.insertLast(ASTNode.copySubtree(targetRewrite.getAST(), parameter), null); ImportRewriteUtil.collectImports(subType.getJavaProject(), sourceDeclaration, fTypeBindings, fStaticBindings, false); } } }
/** * Creates the type parameters of the new supertype. * * @param targetRewrite * the target compilation unit rewrite * @param subType * the subtype * @param sourceDeclaration * the type declaration of the source type * @param targetDeclaration * the type declaration of the target type */ protected final void createTypeParameters(final ASTRewrite targetRewrite, final IType subType, final AbstractTypeDeclaration sourceDeclaration, final AbstractTypeDeclaration targetDeclaration) { Assert.isNotNull(targetRewrite); Assert.isNotNull(sourceDeclaration); Assert.isNotNull(targetDeclaration); if (sourceDeclaration instanceof TypeDeclaration) { TypeParameter parameter= null; final ListRewrite rewrite= targetRewrite.getListRewrite(targetDeclaration, TypeDeclaration.TYPE_PARAMETERS_PROPERTY); for (final Iterator<TypeParameter> iterator= ((TypeDeclaration) sourceDeclaration).typeParameters().iterator(); iterator.hasNext();) { parameter= iterator.next(); rewrite.insertLast(ASTNode.copySubtree(targetRewrite.getAST(), parameter), null); ImportRewriteUtil.collectImports(subType.getJavaProject(), sourceDeclaration, fTypeBindings, fStaticBindings, false); } } }
Assert.isNotNull(fragment); final FieldDeclaration field= (FieldDeclaration) fragment.getParent(); ImportRewriteUtil.collectImports(fSubType.getJavaProject(), field, fTypeBindings, fStaticBindings, false); final ASTRewrite rewrite= ASTRewrite.create(field.getAST()); final ITrackedNodePosition position= rewrite.track(field);
Assert.isNotNull(fragment); final FieldDeclaration field= (FieldDeclaration) fragment.getParent(); ImportRewriteUtil.collectImports(fSubType.getJavaProject(), field, fTypeBindings, fStaticBindings, false); final ASTRewrite rewrite= ASTRewrite.create(field.getAST()); final ITrackedNodePosition position= rewrite.track(field);
Assert.isNotNull(fragment); final FieldDeclaration field= (FieldDeclaration) fragment.getParent(); ImportRewriteUtil.collectImports(fSubType.getJavaProject(), field, fTypeBindings, fStaticBindings, false); final ASTRewrite rewrite= ASTRewrite.create(field.getAST()); final ITrackedNodePosition position= rewrite.track(field);
ImportRewriteUtil.collectImports(fType.getJavaProject(), declaration, fTypeImports, fStaticImports, false); if (binding != null) fTypeImports.remove(binding);
Assert.isNotNull(targetRewrite); Assert.isNotNull(declaration); ImportRewriteUtil.collectImports(fSubType.getJavaProject(), declaration, fTypeBindings, fStaticBindings, true); final ASTRewrite rewrite= ASTRewrite.create(declaration.getAST()); final ITrackedNodePosition position= rewrite.track(declaration);
ImportRewriteUtil.collectImports(fType.getJavaProject(), declaration, fTypeImports, fStaticImports, false); if (binding != null) fTypeImports.remove(binding);
ImportRewriteUtil.collectImports(fType.getJavaProject(), declaration, fTypeImports, fStaticImports, false); if (binding != null) fTypeImports.remove(binding);
Assert.isNotNull(declaration); IJavaProject sourceProject= fSubType.getJavaProject(); ImportRewriteUtil.collectImports(sourceProject, declaration, fTypeBindings, fStaticBindings, true); ASTRewrite rewrite= ASTRewrite.create(declaration.getAST()); ITrackedNodePosition position= rewrite.track(declaration);
Assert.isNotNull(declaration); IJavaProject sourceProject= fSubType.getJavaProject(); ImportRewriteUtil.collectImports(sourceProject, declaration, fTypeBindings, fStaticBindings, true); ASTRewrite rewrite= ASTRewrite.create(declaration.getAST()); ITrackedNodePosition position= rewrite.track(declaration);