X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpdt/ui/CodeGeneration.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpdt/ui/CodeGeneration.java deleted file mode 100644 index 274f574..0000000 --- a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpdt/ui/CodeGeneration.java +++ /dev/null @@ -1,410 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package net.sourceforge.phpdt.ui; - -import net.sourceforge.phpdt.core.ICompilationUnit; -import net.sourceforge.phpdt.core.IMethod; -import net.sourceforge.phpdt.internal.corext.codemanipulation.StubUtility; - -import org.eclipse.core.runtime.CoreException; - -/** - * Class that offers access to the templates contained in the 'code templates' - * preference page. - * - * @since 2.1 - */ -public class CodeGeneration { - - private CodeGeneration() { - } - - /** - * Returns the content for a new compilation unit using the 'new Java file' - * code template. - * - * @param cu - * The compilation to create the source for. The compilation unit - * does not need to exist. - * @param typeComment - * The comment for the type to be created. Used when the code - * template contains a ${typecomment} variable. Can be - * null if no comment should be added. - * @param typeContent - * The code of the type, including type declaration and body. - * @param lineDelimiter - * The line delimiter to be used. - * @return Returns the new content or null if the template is - * undefined or empty. - * @throws CoreException - * Thrown when the evaluation of the code template fails. - */ -// public static String getCompilationUnitContent(ICompilationUnit cu, -// String typeComment, String typeContent, String lineDelimiter) -// throws CoreException { -// return StubUtility.getCompilationUnitContent(cu, typeComment, -// typeContent, lineDelimiter); -// } - - /** - * Returns the content for a new type comment using the 'type comment' code - * template. The returned content is unformatted and is not indented. - * - * @param cu - * The compilation where the type is contained. The compilation - * unit does not need to exist. - * @param typeQualifiedName - * The name of the type to which the comment is added. For inner - * types the name must be qualified and include the outer types - * names (dot separated). See - * {@link net.sourceforge.phpdt.core.IType#getTypeQualifiedName(char)}. - * @param lineDelimiter - * The line delimiter to be used. - * @return Returns the new content or null if the code - * template is undefined or empty. The returned content is - * unformatted and is not indented. - * @throws CoreException - * Thrown when the evaluation of the code template fails. - */ - public static String getTypeComment(ICompilationUnit cu, - String typeQualifiedName, String lineDelimiter) - throws CoreException { - return StubUtility.getTypeComment(cu, typeQualifiedName, lineDelimiter); - } - - /** - * Returns the content for a new field comment using the 'field comment' - * code template. The returned content is unformatted and is not indented. - * - * @param cu - * The compilation where the field is contained. The compilation - * unit does not need to exist. - * @param typeName - * The name of the field declared type. - * @param fieldName - * The name of the field to which the comment is added. - * @param lineDelimiter - * The line delimiter to be used. - * @return Returns the new content or null if the code - * template is undefined or empty. The returned content is - * unformatted and is not indented. - * @throws CoreException - * Thrown when the evaluation of the code template fails. - * @since 3.0 - */ -// public static String getFieldComment(ICompilationUnit cu, String typeName, -// String fieldName, String lineDelimiter) throws CoreException { -// return StubUtility.getFieldComment(cu, typeName, fieldName, -// lineDelimiter); -// } - - /** - * Returns the comment for a method or constructor using the comment code - * templates (constructor / method / overriding method). null - * is returned if the template is empty. - * - * @param cu - * The compilation unit to which the method belongs. The - * compilation unit does not need to exist. - * @param declaringTypeName - * Name of the type to which the method belongs. For inner types - * the name must be qualified and include the outer types names - * (dot separated). See - * {@link net.sourceforge.phpdt.core.IType#getTypeQualifiedName(char)}. - * @param decl - * The MethodDeclaration AST node that will be added as new - * method. The node does not need to exist in an AST (no parent - * needed) and does not need to resolve. See - * {@link net.sourceforge.phpdt.core.dom.AST#newMethodDeclaration()} - * for how to create such a node. - * @param overridden - * The binding of the method that will be overridden by the - * created method or null if no method is - * overridden. - * @param lineDelimiter - * The line delimiter to be used. - * @return Returns the generated method comment or null if - * the code template is empty. The returned content is unformatted - * and not indented (formatting required). - * @throws CoreException - * Thrown when the evaluation of the code template fails. - */ - // public static String getMethodComment(ICompilationUnit cu, String - // declaringTypeName, MethodDeclaration decl, IMethodBinding overridden, - // String lineDelimiter) throws CoreException { - // return StubUtility.getMethodComment(cu, declaringTypeName, decl, - // overridden, lineDelimiter); - // } - /** - * Returns the comment for a method or constructor using the comment code - * templates (constructor / method / overriding method). null - * is returned if the template is empty. - *

- * The returned string is unformatted and not indented. - *

- * Exception types and return type are in signature notation. e.g. a source - * method declared as public void foo(String text, int length) - * would return the array {"QString;","I"} as parameter - * types. See {@link net.sourceforge.phpdt.core.Signature}. - * - * @param cu - * The compilation unit to which the method belongs. The - * compilation unit does not need to exist. - * @param declaringTypeName - * Name of the type to which the method belongs. For inner types - * the name must be qualified and include the outer types names - * (dot separated). See - * {@link net.sourceforge.phpdt.core.IType#getTypeQualifiedName(char)}. - * @param methodName - * Name of the method. - * @param paramNames - * Names of the parameters for the method. - * @param excTypeSig - * Thrown exceptions (Signature notation). - * @param retTypeSig - * Return type (Signature notation) or null for - * constructors. - * @param overridden - * The method that will be overridden by the created method or - * null for non-overriding methods. If not - * null, the method must exist. - * @param lineDelimiter - * The line delimiter to be used. - * @return Returns the constructed comment or null if the - * comment code template is empty. The returned content is - * unformatted and not indented (formatting required). - * @throws CoreException - * Thrown when the evaluation of the code template fails. - */ - public static String getMethodComment(ICompilationUnit cu, - String declaringTypeName, String methodName, String[] paramNames, - String[] excTypeSig, String retTypeSig, IMethod overridden, - String lineDelimiter) throws CoreException { - return StubUtility.getMethodComment(cu, declaringTypeName, methodName, - paramNames, excTypeSig, retTypeSig, overridden, lineDelimiter); - } - - /** - * Returns the comment for a method or constructor using the comment code - * templates (constructor / method / overriding method). null - * is returned if the template is empty. - *

- * The returned string is unformatted and not indented. - * - * @param method - * The method to be documented. The method must exist. - * @param overridden - * The method that will be overridden by the created method or - * null for non-overriding methods. If not - * null, the method must exist. - * @param lineDelimiter - * The line delimiter to be used. - * @return Returns the constructed comment or null if the - * comment code template is empty. The returned string is - * unformatted and and has no indent (formatting required). - * @throws CoreException - * Thrown when the evaluation of the code template fails. - */ - public static String getMethodComment(IMethod method, IMethod overridden, - String lineDelimiter) throws CoreException { - return StubUtility.getMethodComment(method, overridden, lineDelimiter); - } - - /** - * Returns the content of the body for a method or constructor using the - * method body templates. null is returned if the template is - * empty. - *

- * The returned string is unformatted and not indented. - * - * @param cu - * The compilation unit to which the method belongs. The - * compilation unit does not need to exist. - * @param declaringTypeName - * Name of the type to which the method belongs. For inner types - * the name must be qualified and include the outer types names - * (dot separated). See - * {@link net.sourceforge.phpdt.core.IType#getTypeQualifiedName(char)}. - * @param methodName - * Name of the method. - * @param isConstructor - * Defines if the created body is for a constructor. - * @param bodyStatement - * The code to be entered at the place of the variable - * ${body_statement}. - * @param lineDelimiter - * The line delimiter to be used. - * @return Returns the constructed body content or null if - * the comment code template is empty. The returned string is - * unformatted and and has no indent (formatting required). - * @throws CoreException - * Thrown when the evaluation of the code template fails. - */ -// public static String getMethodBodyContent(ICompilationUnit cu, -// String declaringTypeName, String methodName, boolean isConstructor, -// String bodyStatement, String lineDelimiter) throws CoreException { -// return StubUtility.getMethodBodyContent(isConstructor, cu -// .getJavaProject(), declaringTypeName, methodName, -// bodyStatement, lineDelimiter); -// } - - /** - * Returns the content of body for a getter method using the getter method - * body template. null is returned if the template is empty. - *

- * The returned string is unformatted and not indented. - * - * @param cu - * The compilation unit to which the method belongs. The - * compilation unit does not need to exist. - * @param declaringTypeName - * Name of the type to which the method belongs. For inner types - * the name must be qualified and include the outer types names - * (dot separated). See - * {@link net.sourceforge.phpdt.core.IType#getTypeQualifiedName(char)}. - * @param methodName - * The name of the getter method. - * @param fieldName - * The name of the field to get in the getter method, - * corresponding to the template variable for ${field}. - * @param lineDelimiter - * The line delimiter to be used. - * @return Returns the constructed body content or null if - * the comment code template is empty. The returned string is - * unformatted and and has no indent (formatting required). - * @throws CoreException - * Thrown when the evaluation of the code template fails. - * @since 3.0 - */ -// public static String getGetterMethodBodyContent(ICompilationUnit cu, -// String declaringTypeName, String methodName, String fieldName, -// String lineDelimiter) throws CoreException { -// return StubUtility.getGetterMethodBodyContent(cu.getJavaProject(), -// declaringTypeName, methodName, fieldName, lineDelimiter); -// } - - /** - * Returns the content of body for a setter method using the setter method - * body template. null is returned if the template is empty. - *

- * The returned string is unformatted and not indented. - * - * @param cu - * The compilation unit to which the method belongs. The - * compilation unit does not need to exist. - * @param declaringTypeName - * Name of the type to which the method belongs. For inner types - * the name must be qualified and include the outer types names - * (dot separated). See - * {@link net.sourceforge.phpdt.core.IType#getTypeQualifiedName(char)}. - * @param methodName - * The name of the setter method. - * @param fieldName - * The name of the field to be set in the setter method, - * corresponding to the template variable for ${field}. - * @param paramName - * The name of the parameter passed to the setter method, - * corresponding to the template variable for $(param). - * @param lineDelimiter - * The line delimiter to be used. - * @return Returns the constructed body content or null if - * the comment code template is empty. The returned string is - * unformatted and and has no indent (formatting required). - * @throws CoreException - * Thrown when the evaluation of the code template fails. - * @since 3.0 - */ -// public static String getSetterMethodBodyContent(ICompilationUnit cu, -// String declaringTypeName, String methodName, String fieldName, -// String paramName, String lineDelimiter) throws CoreException { -// return StubUtility.getSetterMethodBodyContent(cu.getJavaProject(), -// declaringTypeName, methodName, fieldName, paramName, -// lineDelimiter); -// } - - /** - * Returns the comment for a getter method using the getter comment - * template. null is returned if the template is empty. - *

- * The returned string is unformatted and not indented. - * - * @param cu - * The compilation unit to which the method belongs. The - * compilation unit does not need to exist. - * @param declaringTypeName - * Name of the type to which the method belongs. For inner types - * the name must be qualified and include the outer types names - * (dot separated). See - * {@link net.sourceforge.phpdt.core.IType#getTypeQualifiedName(char)}. - * @param methodName - * Name of the method. - * @param fieldName - * Name of the field to get. - * @param fieldType - * The type of the field to get. - * @param bareFieldName - * The field name without prefix or suffix. - * @param lineDelimiter - * The line delimiter to be used. - * @return Returns the generated getter comment or null if - * the code template is empty. The returned content is not indented. - * @throws CoreException - * Thrown when the evaluation of the code template fails. - * @since 3.0 - */ - public static String getGetterComment(ICompilationUnit cu, - String declaringTypeName, String methodName, String fieldName, - String fieldType, String bareFieldName, String lineDelimiter) - throws CoreException { - return StubUtility.getGetterComment(cu, declaringTypeName, methodName, - fieldName, fieldType, bareFieldName, lineDelimiter); - } - - /** - * Returns the comment for a setter method using the setter method body - * template. null is returned if the template is empty. - *

- * The returned string is unformatted and not indented. - * - * @param cu - * The compilation unit to which the method belongs. The - * compilation unit does not need to exist. - * @param declaringTypeName - * Name of the type to which the method belongs. For inner types - * the name must be qualified and include the outer types names - * (dot separated). See - * {@link net.sourceforge.phpdt.core.IType#getTypeQualifiedName(char)}. - * @param methodName - * Name of the method. - * @param fieldName - * Name of the field that is set. - * @param fieldType - * The type of the field that is to set. - * @param paramName - * The name of the parameter that used to set. - * @param bareFieldName - * The field name without prefix or suffix. - * @param lineDelimiter - * The line delimiter to be used. - * @return Returns the generated setter comment or null if - * the code template is empty. The returned comment is not indented. - * @throws CoreException - * Thrown when the evaluation of the code template fails. - * @since 3.0 - */ - public static String getSetterComment(ICompilationUnit cu, - String declaringTypeName, String methodName, String fieldName, - String fieldType, String paramName, String bareFieldName, - String lineDelimiter) throws CoreException { - return StubUtility.getSetterComment(cu, declaringTypeName, methodName, - fieldName, fieldType, paramName, bareFieldName, lineDelimiter); - } -}