Skip to main content
summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarc-Andre Laperle2011-07-22 13:27:05 -0400
committerMarc-Andre Laperle2011-07-22 13:27:05 -0400
commit0b330a4c9e3789e32bab8ed6c12bdde4aba57def (patch)
treee2cacf2490079e46998d56b1f221a7ec891df41e /core
parentba139d80802b1c4a5c8f34574f9da496b9306350 (diff)
downloadorg.eclipse.cdt-0b330a4c9e3789e32bab8ed6c12bdde4aba57def.tar.gz
org.eclipse.cdt-0b330a4c9e3789e32bab8ed6c12bdde4aba57def.tar.xz
org.eclipse.cdt-0b330a4c9e3789e32bab8ed6c12bdde4aba57def.zip
Bug 352239 - NPE using new class wizard when generated source file is
empty
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/StubUtility.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java12
2 files changed, 12 insertions, 4 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/StubUtility.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/StubUtility.java
index d53a69d6ff..e11f01fabd 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/StubUtility.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/StubUtility.java
@@ -117,7 +117,7 @@ public class StubUtility {
};
String text = evaluateTemplate(context, template, fullLine);
- if (!text.endsWith(lineDelimiter))
+ if (text != null && !text.endsWith(lineDelimiter))
text += lineDelimiter;
return text;
}
@@ -164,7 +164,7 @@ public class StubUtility {
CodeTemplateContextType.TYPE_COMMENT
};
String text = evaluateTemplate(context, template, fullLine);
- if (!text.endsWith(lineDelimiter))
+ if (text != null && !text.endsWith(lineDelimiter))
text += lineDelimiter;
return text;
}
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 e9438eaa4f..9de3a40e54 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
@@ -211,7 +211,11 @@ public class NewClassCodeGenerator {
String headerContent = constructHeaderFileContent(headerTU, publicMethods,
protectedMethods, privateMethods, headerWorkingCopy.getBuffer().getContents(),
new SubProgressMonitor(monitor, 100));
- headerContent= formatSource(headerContent, headerTU);
+ if (headerContent != null) {
+ headerContent= formatSource(headerContent, headerTU);
+ } else {
+ headerContent = ""; //$NON-NLS-1$
+ }
headerWorkingCopy.getBuffer().setContents(headerContent);
if (monitor.isCanceled()) {
@@ -250,7 +254,11 @@ public class NewClassCodeGenerator {
String sourceContent = constructSourceFileContent(sourceTU, headerTU,
publicMethods, protectedMethods, privateMethods,
sourceWorkingCopy.getBuffer().getContents(), new SubProgressMonitor(monitor, 100));
- sourceContent= formatSource(sourceContent, sourceTU);
+ if (sourceContent != null) {
+ sourceContent = formatSource(sourceContent, sourceTU);
+ } else {
+ sourceContent = ""; //$NON-NLS-1$
+ }
sourceWorkingCopy.getBuffer().setContents(sourceContent);
if (monitor.isCanceled()) {

Back to the top