/** * Adds a new import to the rewriter's record and returns a {@link Type} node that can be used * in the code as a reference to the type. The type binding can be an array binding, type variable or wildcard. * If the binding is a generic type, the type parameters are ignored. For parameterized types, also the type * arguments are processed and imports added if necessary. Anonymous types inside type arguments are normalized to their base type, wildcard * of wildcards are ignored. * <p> * No imports are added for types that are already known. If a import for a type is recorded to be removed, this record is discarded instead. * </p> * <p> * The content of the compilation unit itself is actually not modified * in any way by this method; rather, the rewriter just records that a new import has been added. * </p> * @param typeSig the signature of the type to be added. * @param ast the AST to create the returned type for. * @return a type node for the given type signature. Type names are simple names if an import could be used, * or else qualified names if an import conflict prevented an import. */ public Type addImportFromSignature(String typeSig, AST ast) { return addImportFromSignature(typeSig, ast, this.defaultContext); }
/** * Adds a new import to the rewriter's record and returns a {@link Type} node that can be used * in the code as a reference to the type. The type binding can be an array binding, type variable or wildcard. * If the binding is a generic type, the type parameters are ignored. For parameterized types, also the type * arguments are processed and imports added if necessary. Anonymous types inside type arguments are normalized to their base type, wildcard * of wildcards are ignored. * <p> * No imports are added for types that are already known. If a import for a type is recorded to be removed, this record is discarded instead. * </p> * <p> * The content of the compilation unit itself is actually not modified * in any way by this method; rather, the rewriter just records that a new import has been added. * </p> * @param typeSig the signature of the type to be added. * @param ast the AST to create the returned type for. * @return a type node for the given type signature. Type names are simple names if an import could be used, * or else qualified names if an import conflict prevented an import. */ public Type addImportFromSignature(String typeSig, AST ast) { return addImportFromSignature(typeSig, ast, this.defaultContext); }
/** * Adds a new import to the rewriter's record and returns a {@link Type} node that can be used * in the code as a reference to the type. The type binding can be an array binding, type variable or wildcard. * If the binding is a generic type, the type parameters are ignored. For parameterized types, also the type * arguments are processed and imports added if necessary. Anonymous types inside type arguments are normalized to their base type, wildcard * of wildcards are ignored. * <p> * No imports are added for types that are already known. If a import for a type is recorded to be removed, this record is discarded instead. * </p> * <p> * The content of the compilation unit itself is actually not modified * in any way by this method; rather, the rewriter just records that a new import has been added. * </p> * @param typeSig the signature of the type to be added. * @param ast the AST to create the returned type for. * @return a type node for the given type signature. Type names are simple names if an import could be used, * or else qualified names if an import conflict prevented an import. */ public Type addImportFromSignature(String typeSig, AST ast) { return addImportFromSignature(typeSig, ast, this.defaultContext); }
/** * Adds a new import to the rewriter's record and returns a {@link Type} node that can be used * in the code as a reference to the type. The type binding can be an array binding, type variable or wildcard. * If the binding is a generic type, the type parameters are ignored. For parameterized types, also the type * arguments are processed and imports added if necessary. Anonymous types inside type arguments are normalized to their base type, wildcard * of wildcards are ignored. * <p> * No imports are added for types that are already known. If a import for a type is recorded to be removed, this record is discarded instead. * </p> * <p> * The content of the compilation unit itself is actually not modified * in any way by this method; rather, the rewriter just records that a new import has been added. * </p> * @param typeSig the signature of the type to be added. * @param ast the AST to create the returned type for. * @return a type node for the given type signature. Type names are simple names if an import could be used, * or else qualified names if an import conflict prevented an import. */ public Type addImportFromSignature(String typeSig, AST ast) { return addImportFromSignature(typeSig, ast, this.defaultContext); }
/** * Adds a new import to the rewriter's record and returns a {@link Type} node that can be used * in the code as a reference to the type. The type binding can be an array binding, type variable or wildcard. * If the binding is a generic type, the type parameters are ignored. For parameterized types, also the type * arguments are processed and imports added if necessary. Anonymous types inside type arguments are normalized to their base type, wildcard * of wildcards are ignored. * <p> * No imports are added for types that are already known. If a import for a type is recorded to be removed, this record is discarded instead. * </p> * <p> * The content of the compilation unit itself is actually not modified * in any way by this method; rather, the rewriter just records that a new import has been added. * </p> * @param typeSig the signature of the type to be added. * @param ast the AST to create the returned type for. * @return a type node for the given type signature. Type names are simple names if an import could be used, * or else qualified names if an import conflict prevented an import. */ public Type addImportFromSignature(String typeSig, AST ast) { return addImportFromSignature(typeSig, ast, this.defaultContext); }
/** * Adds a new import to the rewriter's record and returns a {@link Type} node that can be used * in the code as a reference to the type. The type binding can be an array binding, type variable or wildcard. * If the binding is a generic type, the type parameters are ignored. For parameterized types, also the type * arguments are processed and imports added if necessary. Anonymous types inside type arguments are normalized to their base type, wildcard * of wildcards are ignored. * <p> * No imports are added for types that are already known. If a import for a type is recorded to be removed, this record is discarded instead. * </p> * <p> * The content of the compilation unit itself is actually not modified * in any way by this method; rather, the rewriter just records that a new import has been added. * </p> * @param typeSig the signature of the type to be added. * @param ast the AST to create the returned type for. * @return returns a type to which the type binding can be assigned to. The returned type contains is unqualified * when an import could be added or was already known. It is fully qualified, if an import conflict prevented the import. */ public Type addImportFromSignature(String typeSig, AST ast) { return addImportFromSignature(typeSig, ast, this.defaultContext); }
/** * Returns a new ast node corresponding to the given type. * * @param rewrite * the compilation unit rewrite to use * @param type * the specified type * @return A corresponding ast node */ protected static ASTNode createCorrespondingNode(final CompilationUnitRewrite rewrite, final TType type) { return rewrite.getImportRewrite().addImportFromSignature(new BindingKey(type.getBindingKey()).toSignature(), rewrite.getAST()); }
/** * Returns a new ast node corresponding to the given type. * * @param rewrite the compilation unit rewrite to use * @param type the new type * @param node the old node * @return A corresponding ast node */ protected static ASTNode createCorrespondingNode(final CompilationUnitRewrite rewrite, final TType type, ASTNode node) { ImportRewrite importRewrite= rewrite.getImportRewrite(); ImportRewriteContext context = new ContextSensitiveImportRewriteContext(node, importRewrite); return importRewrite.addImportFromSignature(new BindingKey(type.getBindingKey()).toSignature(), rewrite.getAST(), context); }
return ast.newPrimitiveType(PrimitiveType.toCode(Signature.toString(typeSig))); case Signature.ARRAY_TYPE_SIGNATURE: Type elementType= addImportFromSignature(Signature.getElementType(typeSig), ast, context); return ast.newArrayType(elementType, Signature.getArrayCount(typeSig)); case Signature.CLASS_TYPE_SIGNATURE: argNodes.add(ast.newWildcardType()); } else { argNodes.add(addImportFromSignature(curr, ast, context)); char ch= typeSig.charAt(0); if (ch != Signature.C_STAR) { Type bound= addImportFromSignature(typeSig.substring(1), ast, context); wildcardType.setBound(bound, ch == Signature.C_EXTENDS); return addImportFromSignature(typeSig.substring(1), ast, context); default: throw new IllegalArgumentException("Unknown type signature kind: " + typeSig); //$NON-NLS-1$
return ast.newPrimitiveType(PrimitiveType.toCode(Signature.toString(typeSig))); case Signature.ARRAY_TYPE_SIGNATURE: Type elementType= addImportFromSignature(Signature.getElementType(typeSig), ast, context); return ast.newArrayType(elementType, Signature.getArrayCount(typeSig)); case Signature.CLASS_TYPE_SIGNATURE: argNodes.add(ast.newWildcardType()); } else { argNodes.add(addImportFromSignature(curr, ast, context)); char ch= typeSig.charAt(0); if (ch != Signature.C_STAR) { Type bound= addImportFromSignature(typeSig.substring(1), ast, context); wildcardType.setBound(bound, ch == Signature.C_EXTENDS); return addImportFromSignature(typeSig.substring(1), ast, context); default: throw new IllegalArgumentException("Unknown type signature kind: " + typeSig); //$NON-NLS-1$
return ast.newPrimitiveType(PrimitiveType.toCode(Signature.toString(typeSig))); case Signature.ARRAY_TYPE_SIGNATURE: Type elementType= addImportFromSignature(Signature.getElementType(typeSig), ast, context); return ast.newArrayType(elementType, Signature.getArrayCount(typeSig)); case Signature.CLASS_TYPE_SIGNATURE: argNodes.add(ast.newWildcardType()); } else { argNodes.add(addImportFromSignature(curr, ast, context)); char ch= typeSig.charAt(0); if (ch != Signature.C_STAR) { Type bound= addImportFromSignature(typeSig.substring(1), ast, context); wildcardType.setBound(bound, ch == Signature.C_EXTENDS); return addImportFromSignature(typeSig.substring(1), ast, context); default: throw new IllegalArgumentException("Unknown type signature kind: " + typeSig); //$NON-NLS-1$
return ast.newPrimitiveType(PrimitiveType.toCode(Signature.toString(typeSig))); case Signature.ARRAY_TYPE_SIGNATURE: Type elementType= addImportFromSignature(Signature.getElementType(typeSig), ast, context); return ast.newArrayType(elementType, Signature.getArrayCount(typeSig)); case Signature.CLASS_TYPE_SIGNATURE: argNodes.add(ast.newWildcardType()); } else { argNodes.add(addImportFromSignature(curr, ast, context)); char ch= typeSig.charAt(0); if (ch != Signature.C_STAR) { Type bound= addImportFromSignature(typeSig.substring(1), ast, context); wildcardType.setBound(bound, ch == Signature.C_EXTENDS); return addImportFromSignature(typeSig.substring(1), ast, context); default: throw new IllegalArgumentException("Unknown type signature kind: " + typeSig); //$NON-NLS-1$
/** * Returns a new ast node corresponding to the given type. * * @param rewrite the compilation unit rewrite to use * @param type the new type * @param node the old node * @return A corresponding ast node */ protected static ASTNode createCorrespondingNode(final CompilationUnitRewrite rewrite, final TType type, ASTNode node) { ImportRewrite importRewrite= rewrite.getImportRewrite(); ImportRewriteContext context = new ContextSensitiveImportRewriteContext(node, importRewrite); return importRewrite.addImportFromSignature(new BindingKey(type.getBindingKey()).toSignature(), rewrite.getAST(), context); }
return ast.newPrimitiveType(PrimitiveType.toCode(Signature.toString(typeSig))); case Signature.ARRAY_TYPE_SIGNATURE: Type elementType= addImportFromSignature(Signature.getElementType(typeSig), ast, context); return ast.newArrayType(elementType, Signature.getArrayCount(typeSig)); case Signature.CLASS_TYPE_SIGNATURE: argNodes.add(ast.newWildcardType()); } else { argNodes.add(addImportFromSignature(curr, ast, context)); char ch= typeSig.charAt(0); if (ch != Signature.C_STAR) { Type bound= addImportFromSignature(typeSig.substring(1), ast, context); wildcardType.setBound(bound, ch == Signature.C_EXTENDS); return addImportFromSignature(typeSig.substring(1), ast, context); default: throw new IllegalArgumentException("Unknown type signature kind: " + typeSig); //$NON-NLS-1$
return ast.newPrimitiveType(PrimitiveType.toCode(Signature.toString(typeSig))); case Signature.ARRAY_TYPE_SIGNATURE: Type elementType= addImportFromSignature(Signature.getElementType(typeSig), ast, context); return ast.newArrayType(elementType, Signature.getArrayCount(typeSig)); case Signature.CLASS_TYPE_SIGNATURE: argNodes.add(ast.newWildcardType()); } else { argNodes.add(addImportFromSignature(curr, ast, context)); char ch= typeSig.charAt(0); if (ch != Signature.C_STAR) { Type bound= addImportFromSignature(typeSig.substring(1), ast, context); wildcardType.setBound(bound, ch == Signature.C_EXTENDS); return addImportFromSignature(typeSig.substring(1), ast, context); default: throw new IllegalArgumentException("Unknown type signature kind: " + typeSig); //$NON-NLS-1$
chosenType= chosenType.getTypeDeclaration(); BindingKey bindingKey= new BindingKey(chosenType.getBindingKey()); typeArgument= rewrite.getImportRewrite().addImportFromSignature(bindingKey.toSignature(), rewrite.getAST()); ArrayList nestedTypeArgumentCvs= getTypeArgumentCvs(elementCv, tCModel);
chosenType= chosenType.getTypeDeclaration(); BindingKey bindingKey= new BindingKey(chosenType.getBindingKey()); typeArgument= rewrite.getImportRewrite().addImportFromSignature(bindingKey.toSignature(), rewrite.getAST()); ArrayList<CollectionElementVariable2> nestedTypeArgumentCvs= getTypeArgumentCvs(elementCv, tCModel);
chosenType= chosenType.getTypeDeclaration(); BindingKey bindingKey= new BindingKey(chosenType.getBindingKey()); typeArgument= rewrite.getImportRewrite().addImportFromSignature(bindingKey.toSignature(), rewrite.getAST()); ArrayList<CollectionElementVariable2> nestedTypeArgumentCvs= getTypeArgumentCvs(elementCv, tCModel);