null
if
- * no comment should be added.
+ * @param tu The translation unit to create the source for. The translation unit does not need
+ * to exist.
+ * @param lineDelimiter The line delimiter to be used.
+ * @return Returns the new content or null
if the template is undefined or empty.
+ * @throws CoreException
+ * @since 5.3
+ */
+ public static String getHeaderFileContent(Template template, ITranslationUnit tu,
+ String lineDelimiter) throws CoreException {
+ return getHeaderFileContent(template, tu, null, null, null, null, null, null, null,
+ lineDelimiter);
+ }
+
+ /**
+ * Returns the content for a new header file using the default 'header file' code template.
+ * @param tu The translation unit to create the source for. The translation unit does not need
+ * to exist.
+ * @param typeComment The comment for the type to 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
*/
- public static String getHeaderFileContent(ITranslationUnit tu, String typeComment, String typeContent, String lineDelimiter) throws CoreException {
- return StubUtility.getHeaderFileContent(tu, getFileComment(tu, lineDelimiter), typeComment, typeContent, lineDelimiter);
+ public static String getHeaderFileContent(ITranslationUnit tu, String typeComment,
+ String typeContent, String lineDelimiter) throws CoreException {
+ return getHeaderFileContent(tu, null, null, null, null, typeComment, typeContent, null,
+ lineDelimiter);
}
/**
* Returns the content for a new header file using the default 'header file' code template.
* @param template The file template to use or null
for the default template
- * @param tu The translation unit to create the source for. The translation unit does not need to exist.
- * @param typeComment The comment for the type to created. Used when the code template contains a ${typecomment} variable. Can be null
if
- * no comment should be added.
+ * @param tu The translation unit to create the source for. The translation unit does not need
+ * to exist.
+ * @param typeComment The comment for the type to 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
*/
- public static String getHeaderFileContent(Template template, ITranslationUnit tu, String typeComment, String typeContent, String lineDelimiter) throws CoreException {
- return StubUtility.getHeaderFileContent(template, tu, getFileComment(tu, lineDelimiter), typeComment, typeContent, lineDelimiter);
+ public static String getHeaderFileContent(Template template, ITranslationUnit tu,
+ String typeComment, String typeContent, String lineDelimiter) throws CoreException {
+ return getHeaderFileContent(template, tu, null, null, null, null, typeComment, typeContent,
+ null, lineDelimiter);
+ }
+
+ /**
+ * Returns the content for a new header file using the default 'header file' code template.
+ * @param tu The translation unit to create the source for. The translation unit does not need
+ * to exist.
+ * @param includes Include statements, or {@code null} if there are no includes.
+ * @param namespaceBegin Beginning of namespace declarations, or {@code null} if there is no
+ * namespace.
+ * @param namespaceEnd End of namespace declarations, or {@code null} if there is no
+ * namespace.
+ * @param namespaceName Fully qualified namespace name, or {@code null} if there is no
+ * namespace.
+ * @param typeComment The comment for the type to 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 typeName The name of the type.
+ * @param lineDelimiter The line delimiter to be used.
+ * @return Returns the new content or null
if the template is undefined or empty.
+ * @throws CoreException
+ * @since 5.3
+ */
+ public static String getHeaderFileContent(ITranslationUnit tu, String includes,
+ String namespaceBegin, String namespaceEnd, String namespaceName, String typeComment,
+ String typeContent, String typeName, String lineDelimiter) throws CoreException {
+ return StubUtility.getHeaderFileContent(tu, typeContent,
+ getFileComment(tu, lineDelimiter), includes, namespaceBegin, namespaceEnd,
+ namespaceName, typeComment, typeName, lineDelimiter);
+ }
+
+ /**
+ * Returns the content for a new header file using the default 'header file' code template.
+ * @param template The file template to use or null
for the default template
+ * @param tu The translation unit to create the source for. The translation unit does not need
+ * to exist.
+ * @param includes Include statements, or {@code null} if there are no includes.
+ * @param namespaceBegin Beginning of namespace declarations, or {@code null} if there is no
+ * namespace.
+ * @param namespaceEnd End of namespace declarations, or {@code null} if there is no
+ * namespace.
+ * @param namespaceName Fully qualified namespace name, or {@code null} if there is no
+ * namespace.
+ * @param typeComment The comment for the type to 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 typeName The name of the type.
+ * @param lineDelimiter The line delimiter to be used.
+ * @return Returns the new content or null
if the template is undefined or empty.
+ * @throws CoreException
+ * @since 5.3
+ */
+ public static String getHeaderFileContent(Template template, ITranslationUnit tu,
+ String includes, String namespaceBegin, String namespaceEnd, String namespaceName,
+ String typeComment, String typeContent, String typeName, String lineDelimiter)
+ throws CoreException {
+ return StubUtility.getHeaderFileContent(template, tu, typeContent,
+ getFileComment(tu, lineDelimiter), includes, namespaceBegin, namespaceEnd,
+ namespaceName, typeComment, typeName, lineDelimiter);
}
/**
* Returns the content for a new translation unit using the 'source file' code template.
- * @param tu The translation unit to create the source for. The translation unit does not need to exist.
- * @param typeComment The comment for the type to created. Used when the code template contains a ${typecomment} variable. Can be null
if
- * no comment should be added.
+ * @param tu The translation unit to create the source for. The translation unit does not need
+ * to exist.
+ * @param typeComment The comment for the type to 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
*/
- public static String getBodyFileContent(ITranslationUnit tu, String typeComment, String typeContent, String lineDelimiter) throws CoreException {
- return StubUtility.getBodyFileContent(tu, getFileComment(tu, lineDelimiter), typeComment, typeContent, lineDelimiter);
+ public static String getBodyFileContent(ITranslationUnit tu, String typeComment,
+ String typeContent, String lineDelimiter) throws CoreException {
+ return getBodyFileContent(tu, typeContent, null, null, null, null, typeComment, null,
+ lineDelimiter);
}
/**
* Returns the content for a new translation unit using the 'source file' code template.
* @param template The file template to use or null
for the default template
- * @param tu The translation unit to create the source for. The translation unit does not need to exist.
- * @param typeComment The comment for the type to created. Used when the code template contains a ${typecomment} variable. Can be null
if
- * no comment should be added.
+ * @param tu The translation unit to create the source for. The translation unit does not need
+ * to exist.
+ * @param typeComment The comment for the type to 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
*/
- public static String getBodyFileContent(Template template, ITranslationUnit tu, String typeComment, String typeContent, String lineDelimiter) throws CoreException {
- return StubUtility.getBodyFileContent(template, tu, getFileComment(tu, lineDelimiter), typeComment, typeContent, lineDelimiter);
+ public static String getBodyFileContent(Template template, ITranslationUnit tu,
+ String typeComment, String typeContent, String lineDelimiter) throws CoreException {
+ return getBodyFileContent(template, tu, typeContent, null, null, null, null, typeComment,
+ null, lineDelimiter);
+ }
+
+ /**
+ * Returns the content for a new source file using the default 'source file' code template.
+ * @param tu The translation unit to create the source for. The translation unit does not need
+ * to exist.
+ * @param includes Include statements, or {@code null} if there are no includes.
+ * @param namespaceBegin Beginning of namespace declarations, or {@code null} if there is no
+ * namespace.
+ * @param namespaceEnd End of namespace declarations, or {@code null} if there is no
+ * namespace.
+ * @param namespaceName Fully qualified namespace name, or {@code null} if there is no
+ * namespace.
+ * @param typeComment The comment for the type to 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 typeName The name of the type.
+ * @param lineDelimiter The line delimiter to be used.
+ * @return Returns the new content or null
if the template is undefined or empty.
+ * @throws CoreException
+ * @since 5.3
+ */
+ public static String getBodyFileContent(ITranslationUnit tu,
+ String includes, String namespaceBegin, String namespaceEnd, String namespaceName,
+ String typeComment, String typeContent, String typeName, String lineDelimiter)
+ throws CoreException {
+ return StubUtility.getBodyFileContent(tu, typeContent, getFileComment(tu, lineDelimiter),
+ includes, namespaceBegin, namespaceEnd, namespaceName, typeComment, typeName,
+ lineDelimiter);
+ }
+
+ /**
+ * Returns the content for a new source file using the default 'source file' code template.
+ * @param template The file template to use or null
for the default template
+ * @param tu The translation unit to create the source for. The translation unit does not need
+ * to exist.
+ * @param includes Include statements, or {@code null} if there are no includes.
+ * @param namespaceBegin Beginning of namespace declarations, or {@code null} if there is no
+ * namespace.
+ * @param namespaceEnd End of namespace declarations, or {@code null} if there is no
+ * namespace.
+ * @param namespaceName Fully qualified namespace name, or {@code null} if there is no
+ * namespace.
+ * @param typeComment The comment for the type to 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 typeName The name of the type.
+ * @param lineDelimiter The line delimiter to be used.
+ * @return Returns the new content or null
if the template is undefined or empty.
+ * @throws CoreException
+ * @since 5.3
+ */
+ public static String getBodyFileContent(Template template, ITranslationUnit tu,
+ String includes, String namespaceBegin, String namespaceEnd, String namespaceName,
+ String typeComment, String typeContent, String typeName, String lineDelimiter)
+ throws CoreException {
+ return StubUtility.getBodyFileContent(template, tu, typeContent,
+ getFileComment(tu, lineDelimiter), includes, namespaceBegin, namespaceEnd,
+ namespaceName, typeComment, typeName, lineDelimiter);
+ }
+
+ /**
+ * Returns the content for a new translation unit using the 'test file' code template.
+ * @param tu The translation unit to create the source for. The translation unit does not need
+ * to exist.
+ * @param includes Include statements, or {@code null} if there are no includes.
+ * @param namespaceBegin Beginning of namespace declarations, or {@code null} if there is no
+ * namespace.
+ * @param namespaceEnd End of namespace declarations, or {@code null} if there is no
+ * namespace.
+ * @param namespaceName Fully qualified namespace name, or {@code null} if there is no
+ * namespace.
+ * @param testCases The test cases code.
+ * @param typeName The name of the type.
+ * @param lineDelimiter The line delimiter to be used.
+ * @return Returns the new content or null
if the template is undefined or empty.
+ * @throws CoreException
+ * @since 5.3
+ */
+ public static String getTestFileContent(ITranslationUnit tu,
+ String includes, String namespaceBegin, String namespaceEnd, String namespaceName,
+ String testCases, String typeName, String lineDelimiter) throws CoreException {
+ return StubUtility.getTestFileContent(tu, testCases, getFileComment(tu, lineDelimiter),
+ includes, namespaceBegin, namespaceEnd, namespaceName, typeName, lineDelimiter);
}
/**
@@ -103,8 +272,10 @@ public class CodeGeneration {
* 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(ITranslationUnit tu, String typeName, String methodName, String bodyStatement, String lineDelimiter) throws CoreException {
- return StubUtility.getMethodBodyContent(tu.getCProject(), typeName, methodName, bodyStatement, lineDelimiter);
+ public static String getMethodBodyContent(ITranslationUnit tu, String typeName,
+ String methodName, String bodyStatement, String lineDelimiter) throws CoreException {
+ return StubUtility.getMethodBodyContent(tu.getCProject(), typeName, methodName,
+ bodyStatement, lineDelimiter);
}
/**
@@ -112,16 +283,20 @@ public class CodeGeneration {
* null
is returned if the template is empty.
* The returned string is unformatted and not indented.
*
- * @param tu The translation unit to which the method belongs. The translation unit does not need to exist.
+ * @param tu The translation unit to which the method belongs. The translation unit
+ * does not need to exist.
* @param typeName Name of the type to which the constructor belongs.
* @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).
+ * @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 getConstructorBodyContent(ITranslationUnit tu, String typeName, String bodyStatement, String lineDelimiter) throws CoreException {
- return StubUtility.getConstructorBodyContent(tu.getCProject(), typeName, bodyStatement, lineDelimiter);
+ public static String getConstructorBodyContent(ITranslationUnit tu, String typeName,
+ String bodyStatement, String lineDelimiter) throws CoreException {
+ return StubUtility.getConstructorBodyContent(tu.getCProject(), typeName, bodyStatement,
+ lineDelimiter);
}
/**
@@ -129,40 +304,116 @@ public class CodeGeneration {
* null
is returned if the template is empty.
*
The returned string is unformatted and not indented.
*
- * @param tu The translation unit to which the method belongs. The translation unit does not need to exist.
+ * @param tu The translation unit to which the method belongs. The translation unit
+ * does not need to exist.
* @param typeName Name of the type to which the constructor belongs.
* @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).
+ * @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 getDestructorBodyContent(ITranslationUnit tu, String typeName, String bodyStatement, String lineDelimiter) throws CoreException {
- return StubUtility.getDestructorBodyContent(tu.getCProject(), typeName, bodyStatement, lineDelimiter);
+ public static String getDestructorBodyContent(ITranslationUnit tu, String typeName,
+ String bodyStatement, String lineDelimiter) throws CoreException {
+ return StubUtility.getDestructorBodyContent(tu.getCProject(), typeName, bodyStatement,
+ lineDelimiter);
}
/**
- * Returns the content for a new file comment using the 'file comment' code template. The returned content is unformatted and is not indented.
- * @param tu The translation unit to add the comment to. The translation unit does not need to exist.
+ * Returns the content of the class definition body using the class body template.
+ * null
is returned if the template is empty.
+ *
The returned string is unformatted and not indented.
+ *
+ * @param tu The translation unit to which the method belongs. The translation unit
+ * does not need to exist.
+ * @param className The name of the class.
+ * @param classMemberDeclarations The code to be entered at the place of the variable
+ * ${declarations}.
* @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.
+ * @return Returns the constructed class body content or null
if
+ * the class body code template is empty. The returned string is unformatted and
+ * has no indent (formatting required).
+ * @throws CoreException Thrown when the evaluation of the code template fails.
+ * @since 5.3
+ */
+ public static String getClassBodyContent(ITranslationUnit tu, String className,
+ String classMemberDeclarations, String lineDelimiter)
+ throws CoreException {
+ return StubUtility.getClassBodyContent(tu.getCProject(), className, classMemberDeclarations,
+ lineDelimiter);
+ }
+
+ /**
+ * Returns the content of the beginning of a namespace declaration using the corresponding
+ * template. null
is returned if the template is empty.
+ *
The returned string is unformatted and not indented.
+ *
+ * @param tu The translation unit to which the method belongs. The translation unit
+ * does not need to exist.
+ * @param namespaceName The name of the namespace.
+ * @param lineDelimiter The line delimiter to be used.
+ * @return Returns the constructed beginning of a namespace declaration,or null
if
+ * the namespace code template is empty. The returned string is unformatted and has no
+ * indent (formatting required).
+ * @throws CoreException Thrown when the evaluation of the code template fails.
+ * @since 5.3
+ */
+ public static String getNamespaceBeginContent(ITranslationUnit tu, String namespaceName,
+ String lineDelimiter) throws CoreException {
+ return StubUtility.getNamespaceBeginContent(tu.getCProject(), namespaceName, lineDelimiter);
+ }
+
+ /**
+ * Returns the content of the end of a namespace declaration using the corresponding
+ * template. null
is returned if the template is empty.
+ *
The returned string is unformatted and not indented.
+ *
+ * @param tu The translation unit to which the method belongs. The translation unit
+ * does not need to exist.
+ * @param namespaceName The name of the namespace.
+ * @param lineDelimiter The line delimiter to be used.
+ * @return Returns the constructed end of a namespace declaration,or null
if
+ * the namespace code template is empty. The returned string is unformatted and has no
+ * indent (formatting required).
+ * @throws CoreException Thrown when the evaluation of the code template fails.
+ * @since 5.3
+ */
+ public static String getNamespaceEndContent(ITranslationUnit tu, String namespaceName,
+ String lineDelimiter) throws CoreException {
+ return StubUtility.getNamespaceEndContent(tu.getCProject(), namespaceName, lineDelimiter);
+ }
+
+ /**
+ * Returns the content for a new file comment using the 'file comment' code template.
+ * The returned content is unformatted and is not indented.
+ * @param tu The translation unit to add the comment to. The translation unit does not need
+ * to exist.
+ * @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 5.0
*/
- public static String getFileComment(ITranslationUnit tu, String lineDelimiter) throws CoreException {
+ public static String getFileComment(ITranslationUnit tu, String lineDelimiter)
+ throws CoreException {
return StubUtility.getFileComment(tu, lineDelimiter);
}
/**
- * Returns the content for a new type comment using the 'typecomment' code template. The returned content is unformatted and is not indented.
- * @param tu The translation unit where the type is contained. The translation 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).
+ * Returns the content for a new type comment using the 'typecomment' code template.
+ * The returned content is unformatted and is not indented.
+ * @param tu The translation unit where the type is contained. The translation 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).
* @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.
+ * @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
*/
- public static String getClassComment(ITranslationUnit tu, String typeQualifiedName, String lineDelimiter) throws CoreException {
+ public static String getClassComment(ITranslationUnit tu, String typeQualifiedName,
+ String lineDelimiter) throws CoreException {
return StubUtility.getClassComment(tu, typeQualifiedName, lineDelimiter);
}
@@ -171,19 +422,23 @@ public class CodeGeneration {
* null
is returned if the template is empty.
*
The returned string is unformatted and not indented.
*
- * @param tu The translation unit to which the method belongs. The translation unit does not need to exist.
+ * @param tu The translation unit to which the method belongs. The translation unit
+ * does not need to exist.
* @param declaringTypeName Name of the type to which the method belongs.
* @param methodName Name of the method.
* @param paramNames Names of the parameters for the method.
* @param excTypeSig Thrown exceptions.
* @param retTypeSig Return type.
* @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).
+ * @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(ITranslationUnit tu, String declaringTypeName, String methodName, String[] paramNames, String[] excTypeSig, String retTypeSig, String lineDelimiter) throws CoreException {
- return StubUtility.getMethodComment(tu, declaringTypeName, methodName, paramNames, excTypeSig, retTypeSig, lineDelimiter);
+ public static String getMethodComment(ITranslationUnit tu, String declaringTypeName,
+ String methodName, String[] paramNames, String[] excTypeSig, String retTypeSig,
+ String lineDelimiter) throws CoreException {
+ return StubUtility.getMethodComment(tu, declaringTypeName, methodName, paramNames,
+ excTypeSig, retTypeSig, lineDelimiter);
}
/**
@@ -191,17 +446,20 @@ public class CodeGeneration {
* null
is returned if the template is empty.
*
The returned string is unformatted and not indented.
*
- * @param tu The translation unit to which the method belongs. The translation unit does not need to exist.
+ * @param tu The translation unit to which the method belongs. The translation unit
+ * does not need to exist.
* @param declaringTypeName Name of the type to which the method belongs.
* @param paramNames Names of the parameters for the method.
* @param excTypeSig Thrown exceptions.
* @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).
+ * @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 getConstructorComment(ITranslationUnit tu, String declaringTypeName, String[] paramNames, String[] excTypeSig, String lineDelimiter) throws CoreException {
- return StubUtility.getConstructorComment(tu, declaringTypeName, paramNames, excTypeSig, lineDelimiter);
+ public static String getConstructorComment(ITranslationUnit tu, String declaringTypeName,
+ String[] paramNames, String[] excTypeSig, String lineDelimiter) throws CoreException {
+ return StubUtility.getConstructorComment(tu, declaringTypeName, paramNames, excTypeSig,
+ lineDelimiter);
}
/**
@@ -209,16 +467,17 @@ public class CodeGeneration {
* null
is returned if the template is empty.
*
The returned string is unformatted and not indented.
*
- * @param tu The translation unit to which the method belongs. The translation unit does not need to exist.
+ * @param tu The translation unit to which the method belongs. The translation unit
+ * does not need to exist.
* @param declaringTypeName Name of the type to which the method belongs.
* @param excTypeSig Thrown exceptions.
* @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).
+ * @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 getDestructorComment(ITranslationUnit tu, String declaringTypeName, String[] excTypeSig, String lineDelimiter) throws CoreException {
+ public static String getDestructorComment(ITranslationUnit tu, String declaringTypeName,
+ String[] excTypeSig, String lineDelimiter) throws CoreException {
return StubUtility.getDestructorComment(tu, declaringTypeName, excTypeSig, lineDelimiter);
}
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java
index 364c948afca..f57fb9261cb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java
@@ -9,6 +9,7 @@
* QNX Software Systems - initial API and implementation
* IBM Corporation
* Warren Paul (Nokia) - 174238
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.ui.wizards;
@@ -29,6 +30,7 @@ import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelection;
@@ -105,10 +107,18 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField;
import org.eclipse.cdt.internal.ui.wizards.filewizard.NewSourceFileGenerator;
public class NewClassCreationWizardPage extends NewElementWizardPage {
- protected final static String PAGE_NAME = "NewClassWizardPage"; //$NON-NLS-1$
+ protected static final String PAGE_NAME = "NewClassWizardPage"; //$NON-NLS-1$
protected static final int MAX_FIELD_CHARS = 50;
-
- // field IDs
+
+ // Dialog setting keys.
+ private static final String KEY_NAMESPACE_SELECTED = "namespaceSelected"; //$NON-NLS-1$
+ private static final String KEY_NAMESPACE = "namespace"; //$NON-NLS-1$
+ private static final String KEY_TEST_FILE_SELECTED = "testFileSelected"; //$NON-NLS-1$
+ private static final String KEY_STUB_SELECTED = "stubSelected"; //$NON-NLS-1$
+ private static final String KEY_STUB_VIRTUAL = "stubVirtual"; //$NON-NLS-1$
+ private static final String KEY_STUB_INLINE = "stubInline"; //$NON-NLS-1$
+
+ // Field IDs
protected static final int SOURCE_FOLDER_ID = 1;
protected static final int NAMESPACE_ID = 2;
protected static final int CLASS_NAME_ID = 4;
@@ -116,9 +126,11 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
protected static final int METHOD_STUBS_ID = 16;
protected static final int HEADER_FILE_ID = 32;
protected static final int SOURCE_FILE_ID = 64;
+ /** @since 5.3 */
+ protected static final int TEST_FILE_ID = 128;
protected static final int ALL_FIELDS = SOURCE_FOLDER_ID | NAMESPACE_ID
| CLASS_NAME_ID | BASE_CLASSES_ID | METHOD_STUBS_ID
- | HEADER_FILE_ID | SOURCE_FILE_ID;
+ | HEADER_FILE_ID | SOURCE_FILE_ID | TEST_FILE_ID;
protected int fLastFocusedField = 0;
protected StringButtonDialogField fSourceFolderDialogField;
@@ -127,9 +139,18 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
protected StringDialogField fClassNameDialogField;
protected BaseClassesListDialogField fBaseClassesDialogField;
protected MethodStubsListDialogField fMethodStubsDialogField;
- protected SelectionButtonDialogField fUseDefaultSelection;
protected StringButtonDialogField fHeaderFileDialogField;
- protected StringButtonDialogField fSourceFileDialogField;
+ protected StringButtonDialogField fSourceFileDialogField;
+ /** @since 5.3 */
+ protected StringButtonDialogField fTestFileDialogField;
+ /** @since 5.3 */
+ protected SelectionButtonDialogField fTestFileSelection;
+ /** @since 5.3 */
+ protected boolean fHeaderFileDerivedFromClassName;
+ /** @since 5.3 */
+ protected boolean fSourceFileDerivedFromClassName;
+ /** @since 5.3 */
+ protected boolean fTestFileDerivedFromClassName;
protected IStatus fSourceFolderStatus;
protected IStatus fNamespaceStatus;
@@ -138,10 +159,14 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
protected IStatus fMethodStubsStatus;
protected IStatus fHeaderFileStatus;
protected IStatus fSourceFileStatus;
+ /** @since 5.3 */
+ protected IStatus fTestFileStatus;
protected final IStatus STATUS_OK = new StatusInfo();
- protected IFile fCreatedSourceFile;
protected IFile fCreatedHeaderFile;
+ protected IFile fCreatedSourceFile;
+ /** @since 5.3 */
+ protected IFile fCreatedTestFile;
protected ICElement fCreatedClass;
/**
@@ -150,13 +175,6 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
* created.
*/
private boolean isFirstTime = false;
- /**
- * the default method stubs
- */
- protected static final IMethodStub[] DEFAULT_METHOD_STUBS = {
- new ConstructorMethodStub(),
- new DestructorMethodStub()
- };
/**
@@ -194,9 +212,6 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
fMethodStubsDialogField = new MethodStubsListDialogField(NewClassWizardMessages.NewClassCreationWizardPage_methodStubs_label, methodStubsAdapter);
FileGroupFieldAdapter fileGroupAdapter = new FileGroupFieldAdapter();
- fUseDefaultSelection = new SelectionButtonDialogField(SWT.CHECK);
- fUseDefaultSelection.setDialogFieldListener(fileGroupAdapter);
- fUseDefaultSelection.setLabelText(NewClassWizardMessages.NewClassCreationWizardPage_useDefaultLocation_label);
fHeaderFileDialogField = new StringButtonDialogField(fileGroupAdapter);
fHeaderFileDialogField.setDialogFieldListener(fileGroupAdapter);
fHeaderFileDialogField.setLabelText(NewClassWizardMessages.NewClassCreationWizardPage_headerFile_label);
@@ -205,7 +220,17 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
fSourceFileDialogField.setDialogFieldListener(fileGroupAdapter);
fSourceFileDialogField.setLabelText(NewClassWizardMessages.NewClassCreationWizardPage_sourceFile_label);
fSourceFileDialogField.setButtonLabel(NewClassWizardMessages.NewClassCreationWizardPage_sourceFile_button);
-
+ fTestFileSelection = new SelectionButtonDialogField(SWT.CHECK);
+ fTestFileSelection.setDialogFieldListener(fileGroupAdapter);
+ fTestFileSelection.setLabelText(NewClassWizardMessages.NewClassCreationWizardPage_testFile_label);
+ fTestFileDialogField = new StringButtonDialogField(fileGroupAdapter);
+ fTestFileDialogField.setDialogFieldListener(fileGroupAdapter);
+ fTestFileDialogField.setButtonLabel(NewClassWizardMessages.NewClassCreationWizardPage_testFile_button);
+
+ fHeaderFileDerivedFromClassName = true;
+ fSourceFileDerivedFromClassName = true;
+ fTestFileDerivedFromClassName = true;
+
fSourceFolderStatus = STATUS_OK;
fNamespaceStatus = STATUS_OK;
fClassNameStatus = STATUS_OK;
@@ -213,12 +238,10 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
fMethodStubsStatus = STATUS_OK;
fHeaderFileStatus = STATUS_OK;
fSourceFileStatus = STATUS_OK;
+ fTestFileStatus = STATUS_OK;
fLastFocusedField = 0;
isFirstTime = true;
-
- updateNamespaceEnableState();
- updateFileGroupEnableState();
}
// -------- UI Creation ---------
@@ -339,10 +362,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
protected void createBaseClassesControls(Composite composite, int nColumns) {
fBaseClassesDialogField.doFillIntoGrid(composite, nColumns);
Control listControl = fBaseClassesDialogField.getListControl(null);
- GridData gd = (GridData) listControl.getLayoutData();
- gd.heightHint = convertHeightInCharsToPixels(5);
- gd.grabExcessVerticalSpace = false;
- gd.widthHint = getMaxFieldWidth();
+ LayoutUtil.setVerticalGrabbing(listControl, false);
listControl.addFocusListener(new StatusFocusListener(BASE_CLASSES_ID));
}
@@ -356,53 +376,46 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
protected void createMethodStubsControls(Composite composite, int nColumns) {
fMethodStubsDialogField.doFillIntoGrid(composite, nColumns);
Control listControl = fMethodStubsDialogField.getListControl(null);
- GridData gd = (GridData) listControl.getLayoutData();
- gd.heightHint = convertHeightInCharsToPixels(5);
- gd.grabExcessVerticalSpace = false;
- gd.widthHint = getMaxFieldWidth();
+ LayoutUtil.setHeightHint(listControl,
+ convertHeightInCharsToPixels(6) + convertHeightInCharsToPixels(1) / 2);
+ LayoutUtil.setVerticalGrabbing(listControl, false);
listControl.addFocusListener(new StatusFocusListener(METHOD_STUBS_ID));
}
/**
- * Creates the controls for the file name fields. Expects a GridLayout
with at
- * least 4 columns.
+ * Creates the controls for the file name fields. Expects a GridLayout
with
+ * at least 4 columns.
*
* @param composite the parent composite
* @param nColumns number of columns to span
*/
protected void createFileControls(Composite composite, int nColumns) {
+ fHeaderFileDialogField.doFillIntoGrid(composite, nColumns);
+ Text textControl = fHeaderFileDialogField.getTextControl(null);
+ LayoutUtil.setWidthHint(textControl, getMaxFieldWidth());
+ textControl.addFocusListener(new StatusFocusListener(HEADER_FILE_ID));
+
+ fSourceFileDialogField.doFillIntoGrid(composite, nColumns);
+ textControl = fSourceFileDialogField.getTextControl(null);
+ LayoutUtil.setWidthHint(textControl, getMaxFieldWidth());
+ textControl.addFocusListener(new StatusFocusListener(SOURCE_FILE_ID));
+
Composite tabGroup = new Composite(composite, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
tabGroup.setLayout(layout);
- fUseDefaultSelection.doFillIntoGrid(tabGroup, 1);
+ fTestFileSelection.doFillIntoGrid(tabGroup, 1);
- LayoutUtil.setHorizontalSpan(fHeaderFileDialogField.getLabelControl(composite), 1);
- Text textControl = fHeaderFileDialogField.getTextControl(composite);
+ textControl = fTestFileDialogField.getTextControl(composite);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.widthHint = getMaxFieldWidth();
- gd.horizontalSpan = 1;
+ gd.horizontalSpan = 2;
textControl.setLayoutData(gd);
- textControl.addFocusListener(new StatusFocusListener(HEADER_FILE_ID));
+ textControl.addFocusListener(new StatusFocusListener(TEST_FILE_ID));
- Button button = fHeaderFileDialogField.getChangeControl(composite);
- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.widthHint = SWTUtil.getButtonWidthHint(button);
- button.setLayoutData(gd);
-
- DialogField.createEmptySpace(composite, 1);
-
- LayoutUtil.setHorizontalSpan(fSourceFileDialogField.getLabelControl(composite), 1);
- textControl = fSourceFileDialogField.getTextControl(composite);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint = getMaxFieldWidth();
- gd.horizontalSpan = 1;
- textControl.setLayoutData(gd);
- textControl.addFocusListener(new StatusFocusListener(SOURCE_FILE_ID));
-
- button = fSourceFileDialogField.getChangeControl(composite);
+ Button button = fTestFileDialogField.getChangeControl(composite);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.widthHint = SWTUtil.getButtonWidthHint(button);
button.setLayoutData(gd);
@@ -416,7 +429,14 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
* @param selection used to initialize the fields
*/
public void init(IStructuredSelection selection) {
- ICElement celem = getInitialCElement(selection);
+ if (fDialogSettings == null) {
+ fDialogSettings = getDialogSettings().getSection(PAGE_NAME);
+ if (fDialogSettings == null) {
+ fDialogSettings = getDialogSettings().addNewSection(PAGE_NAME);
+ }
+ }
+
+ ICElement celem = getInitialCElement(selection);
String namespace = null;
if (celem != null) {
@@ -428,8 +448,13 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
}
}
}
+ if (namespace == null) {
+ namespace = fDialogSettings.get(KEY_NAMESPACE);
+ }
+
setNamespaceText(namespace, false);
- setNamespaceSelection(namespace != null, true);
+ setNamespaceSelection(namespace != null || fDialogSettings.getBoolean(KEY_NAMESPACE_SELECTED),
+ true);
IPath folderPath = null;
if (celem != null) {
@@ -450,8 +475,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
ITextSelection textSel = getEditorTextSelection();
if (textSel != null) {
String text = textSel.getText();
- if (text != null && text.length() > 0 &&
- CConventions.validateClassName(text).isOK()) {
+ if (text != null && text.length() > 0 && CConventions.validateClassName(text).isOK()) {
className = text;
}
}
@@ -459,19 +483,28 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
IMethodStub[] stubs = getDefaultMethodStubs();
for (int i = 0; i < stubs.length; ++i) {
- addMethodStub(stubs[i], true);
+ IMethodStub stub = stubs[i];
+ if (stub.canModifyVirtual()) {
+ stub.setVirtual(getBooleanSettingWithDefault(KEY_STUB_VIRTUAL + i, stub.isVirtual()));
+ }
+ if (stub.canModifyInline()) {
+ stub.setInline(getBooleanSettingWithDefault(KEY_STUB_INLINE + i, stub.isInline()));
+ }
+ addMethodStub(stub, getBooleanSettingWithDefault(KEY_STUB_SELECTED + i, true));
}
- //TODO restore dialog settings for method stubs?
- // IDialogSettings section = getDialogSettings().getSection(PAGE_NAME);
- // if (section != null) {
- // enabled = section.getBoolean(stubName);
- // }
- setUseDefaultSelection(true, true);
-
+ setTestFileSelection(fDialogSettings.getBoolean(KEY_TEST_FILE_SELECTED), true);
handleFieldChanged(ALL_FIELDS);
}
-
+
+ private boolean getBooleanSettingWithDefault(String key, boolean defaultValue) {
+ String value = fDialogSettings.get(key);
+ if (value == null) {
+ return defaultValue;
+ }
+ return Boolean.valueOf(value);
+ }
+
/**
* Attempts to extract a C Element from the initial selection.
*
@@ -537,7 +570,10 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
* @return array of method stubs
*/
protected IMethodStub[] getDefaultMethodStubs() {
- return DEFAULT_METHOD_STUBS;
+ return new IMethodStub[] {
+ new ConstructorMethodStub(),
+ new DestructorMethodStub()
+ };
}
/**
@@ -546,7 +582,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
* @return the source folder
*/
public String getSourceFolderText() {
- return fSourceFolderDialogField.getText();
+ return fSourceFolderDialogField.getText().trim();
}
/**
@@ -610,7 +646,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
* @return the namespace
*/
public String getNamespaceText() {
- return fNamespaceDialogField.getText();
+ return fNamespaceDialogField.getText().trim();
}
/**
@@ -661,7 +697,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
* @return the class name
*/
public String getClassName() {
- return fClassNameDialogField.getText();
+ return fClassNameDialogField.getText().trim();
}
/**
@@ -732,34 +768,24 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
}
/**
- * Returns the selection state of the file group checkbox.
- *
- * @return the selection state of the file group checkbox
- */
- public boolean isUseDefaultSelected() {
- return fUseDefaultSelection.isSelected();
- }
-
- /**
- * Sets the use default checkbox's selection state.
+ * Sets the use test file creation checkbox's selection state.
*
* @param isSelected the checkbox's selection state
* @param canBeModified if true
the checkbox is
* modifiable; otherwise it is read-only.
+ * @since 5.3
*/
- public void setUseDefaultSelection(boolean isSelected, boolean canBeModified) {
- fUseDefaultSelection.setSelection(isSelected);
- fUseDefaultSelection.setEnabled(canBeModified);
- updateFileGroupEnableState();
+ public void setTestFileSelection(boolean isSelected, boolean canBeModified) {
+ fTestFileSelection.setSelection(isSelected);
+ fTestFileSelection.setEnabled(canBeModified);
+ updateTestFileEnableState();
}
/**
- * Updates the enable state of buttons related to the use default checkbox.
+ * Updates the enable state of test file name text box.
*/
- private void updateFileGroupEnableState() {
- boolean filegroup = !isUseDefaultSelected();
- fHeaderFileDialogField.setEnabled(filegroup);
- fSourceFileDialogField.setEnabled(filegroup);
+ private void updateTestFileEnableState() {
+ fTestFileDialogField.setEnabled(fTestFileSelection.isSelected());
}
/**
@@ -768,7 +794,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
* @return the header file
*/
public String getHeaderFileText() {
- return fHeaderFileDialogField.getText();
+ return fHeaderFileDialogField.getText().trim();
}
/**
@@ -778,29 +804,16 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
* @param update true
if the dialog should be updated
*/
public void setHeaderFileText(String header, boolean update) {
- fHeaderFileDialogField.setTextWithoutUpdate(header != null ? header : ""); //$NON-NLS-1$
- if (update) {
- fHeaderFileDialogField.dialogFieldChanged();
- }
+ setFileText(fHeaderFileDialogField, header, update);
}
-
+
/**
* Returns the current header file as a path.
*
* @return the header file path
*/
protected IPath getHeaderFileFullPath() {
- String str = getHeaderFileText();
- IPath path = null;
- if (str.length() > 0) {
- path = new Path(str);
- if (!path.isAbsolute()) {
- IPath folderPath = getSourceFolderFullPath();
- if (folderPath != null)
- path = folderPath.append(path);
- }
- }
- return path;
+ return getFilePath(getHeaderFileText());
}
/**
@@ -810,27 +823,16 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
* @param update true
if the dialog should be updated
*/
protected void setHeaderFileFullPath(IPath path, boolean update) {
- String str = null;
- if (path != null) {
- IPath sourceFolder = getSourceFolderFullPath();
- if (sourceFolder != null) {
- IPath relativePath = PathUtil.makeRelativePath(path, sourceFolder);
- if (relativePath != null)
- path = relativePath;
- }
- str = path.makeRelative().toString();
- }
- setHeaderFileText(str, update);
+ setFileFullPath(fHeaderFileDialogField, path, update);
}
-
/**
* Returns the text entered into the source file input field.
*
* @return the source file
*/
public String getSourceFileText() {
- return fSourceFileDialogField.getText();
+ return fSourceFileDialogField.getText().trim();
}
/**
@@ -840,10 +842,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
* @param update true
if the dialog should be updated
*/
public void setSourceFileText(String source, boolean update) {
- fSourceFileDialogField.setTextWithoutUpdate(source != null ? source : ""); //$NON-NLS-1$
- if (update) {
- fSourceFileDialogField.dialogFieldChanged();
- }
+ setFileText(fSourceFileDialogField, source, update);
}
/**
@@ -852,17 +851,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
* @return the source file path
*/
protected IPath getSourceFileFullPath() {
- String str = getSourceFileText();
- IPath path = null;
- if (str.length() > 0) {
- path = new Path(str);
- if (!path.isAbsolute()) {
- IPath folderPath = getSourceFolderFullPath();
- if (folderPath != null)
- path = folderPath.append(path);
- }
- }
- return path;
+ return getFilePath(getSourceFileText());
}
/**
@@ -872,6 +861,80 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
* @param update true
if the dialog should be updated
*/
protected void setSourceFileFullPath(IPath path, boolean update) {
+ setFileFullPath(fSourceFileDialogField, path, update);
+ }
+
+ /**
+ * Returns the text entered into the source file input field.
+ *
+ * @return the source file
+ * @since 5.3
+ */
+ public String getTestFileText() {
+ return fTestFileDialogField.isEnabled() ? fTestFileDialogField.getText().trim() : null;
+ }
+
+ /**
+ * Sets the text of the test file input field.
+ *
+ * @param testFile the test file name
+ * @param update true
if the dialog should be updated
+ * @since 5.3
+ */
+ public void setTestFileText(String testFile, boolean update) {
+ setFileText(fTestFileDialogField, testFile, update);
+ }
+
+ /**
+ * Returns the current test file as a path. Returns {@code null} if creation of test file
+ * is disabled.
+ *
+ * @return the test file path, or {@code null} if creation of test file is disabled.
+ * @since 5.3
+ */
+ protected IPath getTestFileFullPath() {
+ return getFilePath(getTestFileText());
+ }
+
+ /**
+ * Returns a path corresponding to a file name.
+ * @param filename the name of a header, a source, or a test file. Can be {@code null}.
+ * @return the corresponding path, or {@code null} if the filename is {@code null}.
+ */
+ private IPath getFilePath(String filename) {
+ if (filename == null || filename.length() == 0) {
+ return null;
+ }
+ IPath path = new Path(filename);
+ if (!path.isAbsolute()) {
+ IPath folderPath = getSourceFolderFullPath();
+ if (folderPath != null)
+ path = folderPath.append(path);
+ }
+ return path;
+ }
+
+ /**
+ * Sets a file name field to a given value.
+ *
+ * @param field the field to set
+ * @param filename the new value of the field
+ * @param update true
if the dialog should be updated
+ */
+ private void setFileText(StringButtonDialogField field, String filename, boolean update) {
+ field.setTextWithoutUpdate(filename != null ? filename : ""); //$NON-NLS-1$
+ if (update) {
+ field.dialogFieldChanged();
+ }
+ }
+
+ /**
+ * Sets a file name field from the given path.
+ *
+ * @param path the file path
+ * @param update true
if the dialog should be updated
+ */
+ private void setFileFullPath(StringButtonDialogField field, IPath path, boolean update) {
String str = null;
if (path != null) {
IPath sourceFolder = getSourceFolderFullPath();
@@ -882,9 +945,20 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
}
str = path.makeRelative().toString();
}
- setSourceFileText(str, update);
+ setFileText(field, str, update);
}
-
+
+ /**
+ * Sets the test file from the given path.
+ *
+ * @param path the test file path
+ * @param update true
if the dialog should be updated
+ * @since 5.3
+ */
+ protected void setTestFileFullPath(IPath path, boolean update) {
+ setFileFullPath(fTestFileDialogField, path, update);
+ }
+
/*
* @see WizardPage#becomesVisible
*/
@@ -919,7 +993,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
public void focusGained(FocusEvent e) {
if (fLastFocusedField != this.fieldID) {
fLastFocusedField = this.fieldID;
- if( isFirstTime ) {
+ if (isFirstTime) {
isFirstTime = false;
return;
}
@@ -946,19 +1020,17 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
IPath headerPath = getHeaderFileFullPath();
IPath sourcePath = getSourceFileFullPath();
setSourceFolderFullPath(newFolderPath, false);
- if (!isUseDefaultSelected()) {
- if (oldFolderPath != null && oldFolderPath.matchingFirstSegments(newFolderPath) == 0) {
- if (headerPath != null) {
- headerPath = newFolderPath.append(headerPath.lastSegment());
- }
- if (sourcePath != null) {
- sourcePath = newFolderPath.append(sourcePath.lastSegment());
- }
- }
- // adjust the relative paths
- setHeaderFileFullPath(headerPath, false);
- setSourceFileFullPath(sourcePath, false);
- }
+ if (oldFolderPath != null && oldFolderPath.matchingFirstSegments(newFolderPath) == 0) {
+ if (headerPath != null) {
+ headerPath = newFolderPath.append(headerPath.lastSegment());
+ }
+ if (sourcePath != null) {
+ sourcePath = newFolderPath.append(sourcePath.lastSegment());
+ }
+ }
+ // adjust the relative paths
+ setHeaderFileFullPath(headerPath, false);
+ setSourceFileFullPath(sourcePath, false);
handleFieldChanged(SOURCE_FOLDER_ID|ALL_FIELDS);
}
}
@@ -1009,13 +1081,15 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
if (oldFolderPath == null) {
IPath headerPath = getHeaderFileFullPath();
IPath sourcePath = getSourceFileFullPath();
+ IPath testPath = getTestFileFullPath();
IPath newFolderPath = updateSourceFolderFromPath(ns.getEnclosingProject().getProject().getFullPath());
if (newFolderPath != null) {
- changedFields |= SOURCE_FOLDER_ID | HEADER_FILE_ID | SOURCE_FILE_ID;
+ changedFields |= SOURCE_FOLDER_ID | HEADER_FILE_ID | SOURCE_FILE_ID | TEST_FILE_ID;
setSourceFolderFullPath(newFolderPath, false);
- // adjust the relative paths
+ // Adjust the relative paths
setHeaderFileFullPath(headerPath, false);
setSourceFileFullPath(sourcePath, false);
+ setTestFileFullPath(testPath, false);
}
}
setNamespaceText(ns.getQualifiedTypeName().toString(), false);
@@ -1074,21 +1148,19 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
}
/**
- * handles changes to the class name field
+ * Handles changes to the class name field
*/
private final class ClassNameFieldAdapter implements IDialogFieldListener {
public void dialogFieldChanged(DialogField field) {
int changedFields = CLASS_NAME_ID;
- if (isUseDefaultSelected()) {
- updateFilesFromClassName(fClassNameDialogField.getText());
- changedFields |= (HEADER_FILE_ID|SOURCE_FILE_ID);
- }
+ updateFilesFromClassName(fClassNameDialogField.getText().trim());
+ changedFields |= HEADER_FILE_ID | SOURCE_FILE_ID | TEST_FILE_ID;
handleFieldChanged(changedFields);
}
}
/**
- * handles changes to the base classes field
+ * Handles changes to the base classes field
*/
private final class BaseClassesFieldAdapter implements IListAdaptercreateClass
has been called.
@@ -1947,15 +2149,27 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
public IFile getCreatedHeaderFile() {
return fCreatedHeaderFile;
}
-
- /**
- * Returns the created source file. The method only returns a valid file
- * after createClass
has been called.
- *
- * @return the created source file
- * @see #createClass(IProgressMonitor)
- */
+
+ /**
+ * Returns the created source file. The method only returns a valid file
+ * after createClass
has been called.
+ *
+ * @return the created source file
+ * @see #createClass(IProgressMonitor)
+ */
public IFile getCreatedSourceFile() {
- return fCreatedSourceFile;
+ return fCreatedSourceFile;
+ }
+
+ /**
+ * Returns the created test file. The method only returns a valid file
+ * after createClass
has been called.
+ *
+ * @return the created test file
+ * @see #createClass(IProgressMonitor)
+ * @since 5.3
+ */
+ public IFile getCreatedTestFile() {
+ return fCreatedTestFile;
}
}
diff --git a/core/org.eclipse.cdt.ui/templates/default-codetemplates.xml b/core/org.eclipse.cdt.ui/templates/default-codetemplates.xml
index 81325dc23d6..7efcef21724 100644
--- a/core/org.eclipse.cdt.ui/templates/default-codetemplates.xml
+++ b/core/org.eclipse.cdt.ui/templates/default-codetemplates.xml
@@ -11,6 +11,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Anton Leherbauer (Wind River Systems)
+ * Sergey Prigogin (Google)
*******************************************************************************/
-->
@@ -45,21 +46,42 @@
${filecomment}
-${declarations}
+${includes}
+
+${namespace_begin}
+
+${declarations}
+
+${namespace_end}
+
+${filecomment}
+
+${includes}
+
+${namespace_begin}
+
+${declarations}
+
+${namespace_end}
${filecomment}
#ifndef ${include_guard_symbol}
#define ${include_guard_symbol}
-${typecomment}
+${includes}
+
+${namespace_begin}
+
${declarations}
-#endif /* ${include_guard_symbol} */
-
+${namespace_end}
+#endif /* ${include_guard_symbol} */
${filecomment}
+${includes}
+
${declarations}
${filecomment}
@@ -67,18 +89,25 @@ ${declarations}
#ifndef ${include_guard_symbol}
#define ${include_guard_symbol}
+${includes}
+
${declarations}
-#endif /* ${include_guard_symbol} */
-
+#endif /* ${include_guard_symbol} */
-// ${todo} %CodeTemplates.methodstub.tododesc
-${body_statement}
+namespace ${namespace_name} {
-// ${todo} %CodeTemplates.constructorstub.tododesc
-${body_statement}
+} /* namespace ${namespace_name} */
-${body_statement}
-// ${todo} %CodeTemplates.destructorstub.tododesc
+${declarations}
+
+ // ${todo} %CodeTemplates.methodstub.tododesc
+ ${body_statement}
+
+ // ${todo} %CodeTemplates.constructorstub.tododesc
+ ${body_statement}
+
+ ${body_statement}
+ // ${todo} %CodeTemplates.destructorstub.tododesc
diff --git a/core/org.eclipse.cdt.ui/templates/default-templates.properties b/core/org.eclipse.cdt.ui/templates/default-templates.properties
index 20ba0e771cb..e4688b72a92 100644
--- a/core/org.eclipse.cdt.ui/templates/default-templates.properties
+++ b/core/org.eclipse.cdt.ui/templates/default-templates.properties
@@ -7,6 +7,7 @@
#
# Contributors:
# IBM Corporation - initial API and implementation
+# Sergey Prigogin (Google)
###############################################################################
## NOTE TO TRANSLATORS:
@@ -46,13 +47,18 @@ CodeTemplates.methodcomment=Comment for methods
CodeTemplates.cppsourcefile=Default C++ source template
CodeTemplates.cppheaderfile=Default C++ header template
+CodeTemplates.cpptestfile=Default C++ test template
CodeTemplates.csourcefile=Default C source template
CodeTemplates.cheaderfile=Default C header template
CodeTemplates.cppsourcefile.desc=Default template for newly created C++ source files
CodeTemplates.cppheaderfile.desc=Default template for newly created C++ header files
+CodeTemplates.cpptestfile.desc=Default template for newly created C++ test files
CodeTemplates.csourcefile.desc=Default template for newly created C source files
CodeTemplates.cheaderfile.desc=Default template for newly created C header files
+CodeTemplates.namespace_begin=Beginning of namespace declaration
+CodeTemplates.namespace_end=End of namespace declaration
+CodeTemplates.class_body=Code in created class definitions
CodeTemplates.methodstub=Code in created method stubs
CodeTemplates.constructorstub=Code in created constructor stubs
CodeTemplates.destructorstub=Code in created destructor stubs