diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java index 7003dc3ee73..3a1304489f0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 QNX Software Systems and others. + * Copyright (c) 2004, 2009 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -72,7 +72,16 @@ public class NewClassCodeGenerator { private ITranslationUnit fCreatedSourceTU = null; private ICElement fCreatedClass = null; private String fFullyQualifiedClassName; + private boolean fForceSourceFileCreation; + /** + * When set to true, the source file is created, even if no stubs have + * been selected. + */ + public void setForceSourceFileCreation(boolean force) { + fForceSourceFileCreation = force; + } + public static class CodeGeneratorException extends CoreException { /** * Comment for serialVersionUID @@ -195,9 +204,7 @@ public class NewClassCodeGenerator { List protectedMethods = getStubs(ASTAccessVisibility.PROTECTED, true); List privateMethods = getStubs(ASTAccessVisibility.PRIVATE, true); - if (publicMethods.isEmpty() && protectedMethods.isEmpty() && privateMethods.isEmpty()) { - //TODO need prefs option - // don't create source file if no method bodies + if (!fForceSourceFileCreation && publicMethods.isEmpty() && protectedMethods.isEmpty() && privateMethods.isEmpty()) { monitor.worked(100); } else { IFile sourceFile = NewSourceFileGenerator.createSourceFile(fSourcePath, true, new SubProgressMonitor(monitor, 50)); 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 bdfe0369a5e..b3b1d2519dc 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 QNX Software Systems and others. + * Copyright (c) 2004, 2009 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -1917,6 +1917,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { namespace, baseClasses, methodStubs); + generator.setForceSourceFileCreation(true); generator.createClass(monitor); fCreatedClass = generator.getCreatedClass();