mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Bug 352239 - NPE using new class wizard when generated source file is
empty
This commit is contained in:
parent
ba139d8080
commit
0b330a4c9e
2 changed files with 12 additions and 4 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue