mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-25 09:55:29 +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);
|
String text = evaluateTemplate(context, template, fullLine);
|
||||||
if (!text.endsWith(lineDelimiter))
|
if (text != null && !text.endsWith(lineDelimiter))
|
||||||
text += lineDelimiter;
|
text += lineDelimiter;
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ public class StubUtility {
|
||||||
CodeTemplateContextType.TYPE_COMMENT
|
CodeTemplateContextType.TYPE_COMMENT
|
||||||
};
|
};
|
||||||
String text = evaluateTemplate(context, template, fullLine);
|
String text = evaluateTemplate(context, template, fullLine);
|
||||||
if (!text.endsWith(lineDelimiter))
|
if (text != null && !text.endsWith(lineDelimiter))
|
||||||
text += lineDelimiter;
|
text += lineDelimiter;
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,7 +211,11 @@ public class NewClassCodeGenerator {
|
||||||
String headerContent = constructHeaderFileContent(headerTU, publicMethods,
|
String headerContent = constructHeaderFileContent(headerTU, publicMethods,
|
||||||
protectedMethods, privateMethods, headerWorkingCopy.getBuffer().getContents(),
|
protectedMethods, privateMethods, headerWorkingCopy.getBuffer().getContents(),
|
||||||
new SubProgressMonitor(monitor, 100));
|
new SubProgressMonitor(monitor, 100));
|
||||||
headerContent= formatSource(headerContent, headerTU);
|
if (headerContent != null) {
|
||||||
|
headerContent= formatSource(headerContent, headerTU);
|
||||||
|
} else {
|
||||||
|
headerContent = ""; //$NON-NLS-1$
|
||||||
|
}
|
||||||
headerWorkingCopy.getBuffer().setContents(headerContent);
|
headerWorkingCopy.getBuffer().setContents(headerContent);
|
||||||
|
|
||||||
if (monitor.isCanceled()) {
|
if (monitor.isCanceled()) {
|
||||||
|
@ -250,7 +254,11 @@ public class NewClassCodeGenerator {
|
||||||
String sourceContent = constructSourceFileContent(sourceTU, headerTU,
|
String sourceContent = constructSourceFileContent(sourceTU, headerTU,
|
||||||
publicMethods, protectedMethods, privateMethods,
|
publicMethods, protectedMethods, privateMethods,
|
||||||
sourceWorkingCopy.getBuffer().getContents(), new SubProgressMonitor(monitor, 100));
|
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);
|
sourceWorkingCopy.getBuffer().setContents(sourceContent);
|
||||||
|
|
||||||
if (monitor.isCanceled()) {
|
if (monitor.isCanceled()) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue