mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 10:46:02 +02:00
Let new class wizard created empty source file, bug 269498.
This commit is contained in:
parent
8fc63d723e
commit
7bf6393aac
2 changed files with 13 additions and 5 deletions
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -72,6 +72,15 @@ public class NewClassCodeGenerator {
|
||||||
private ITranslationUnit fCreatedSourceTU = null;
|
private ITranslationUnit fCreatedSourceTU = null;
|
||||||
private ICElement fCreatedClass = null;
|
private ICElement fCreatedClass = null;
|
||||||
private String fFullyQualifiedClassName;
|
private String fFullyQualifiedClassName;
|
||||||
|
private boolean fForceSourceFileCreation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When set to <code>true</code>, 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 {
|
public static class CodeGeneratorException extends CoreException {
|
||||||
/**
|
/**
|
||||||
|
@ -195,9 +204,7 @@ public class NewClassCodeGenerator {
|
||||||
List<IMethodStub> protectedMethods = getStubs(ASTAccessVisibility.PROTECTED, true);
|
List<IMethodStub> protectedMethods = getStubs(ASTAccessVisibility.PROTECTED, true);
|
||||||
List<IMethodStub> privateMethods = getStubs(ASTAccessVisibility.PRIVATE, true);
|
List<IMethodStub> privateMethods = getStubs(ASTAccessVisibility.PRIVATE, true);
|
||||||
|
|
||||||
if (publicMethods.isEmpty() && protectedMethods.isEmpty() && privateMethods.isEmpty()) {
|
if (!fForceSourceFileCreation && publicMethods.isEmpty() && protectedMethods.isEmpty() && privateMethods.isEmpty()) {
|
||||||
//TODO need prefs option
|
|
||||||
// don't create source file if no method bodies
|
|
||||||
monitor.worked(100);
|
monitor.worked(100);
|
||||||
} else {
|
} else {
|
||||||
IFile sourceFile = NewSourceFileGenerator.createSourceFile(fSourcePath, true, new SubProgressMonitor(monitor, 50));
|
IFile sourceFile = NewSourceFileGenerator.createSourceFile(fSourcePath, true, new SubProgressMonitor(monitor, 50));
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -1917,6 +1917,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
||||||
namespace,
|
namespace,
|
||||||
baseClasses,
|
baseClasses,
|
||||||
methodStubs);
|
methodStubs);
|
||||||
|
generator.setForceSourceFileCreation(true);
|
||||||
generator.createClass(monitor);
|
generator.createClass(monitor);
|
||||||
|
|
||||||
fCreatedClass = generator.getCreatedClass();
|
fCreatedClass = generator.getCreatedClass();
|
||||||
|
|
Loading…
Add table
Reference in a new issue