mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 01:06:01 +02:00
Don't produce a blank line at the top of the file if file comment
template is blank. Trim blank lines at the end of the file.
This commit is contained in:
parent
83c3e6d27f
commit
06e1b830a8
3 changed files with 19 additions and 9 deletions
|
@ -212,8 +212,22 @@ public class StubUtility {
|
|||
String[] fullLine= { CodeTemplateContextType.FILE_COMMENT };
|
||||
|
||||
String text = evaluateTemplate(context, template, fullLine);
|
||||
if (text != null && !text.endsWith(lineDelimiter))
|
||||
text += lineDelimiter;
|
||||
if (text != null) {
|
||||
// Remove blank lines at the end.
|
||||
int len = text.length();
|
||||
while (true) {
|
||||
int offset = len - lineDelimiter.length();
|
||||
if (!text.startsWith(lineDelimiter, offset))
|
||||
break;
|
||||
len = offset;
|
||||
}
|
||||
len += lineDelimiter.length();
|
||||
if (len < text.length()) {
|
||||
text = text.substring(0, len);
|
||||
} else if (!text.endsWith(lineDelimiter)) {
|
||||
text += lineDelimiter; // Add a line delimiter at the end.
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,8 @@
|
|||
*
|
||||
* Created on: ${date}
|
||||
* Author: ${user}
|
||||
*/</template>
|
||||
*/
|
||||
</template>
|
||||
|
||||
<template name="typecomment" id="org.eclipse.cdt.ui.text.codetemplates.typecomment" description="%CodeTemplates.typecomment" context="org.eclipse.cdt.ui.text.codetemplates.typecomment_context" enabled="true">/*
|
||||
*
|
||||
|
@ -45,7 +46,6 @@
|
|||
*/</template>
|
||||
|
||||
<template name="%CodeTemplates.cppsourcefile" id="org.eclipse.cdt.ui.text.codetemplates.cppsourcefile" description="%CodeTemplates.cppsourcefile.desc" context="org.eclipse.cdt.core.cxxSource.contenttype_context" enabled="true">${filecomment}
|
||||
|
||||
${includes}
|
||||
|
||||
${namespace_begin}
|
||||
|
@ -55,7 +55,6 @@ ${declarations}
|
|||
${namespace_end}</template>
|
||||
|
||||
<template name="%CodeTemplates.cpptestfile" id="org.eclipse.cdt.ui.text.codetemplates.cpptestfile" description="%CodeTemplates.cpptestfile.desc" context="org.eclipse.cdt.core.cxxSource.contenttype_context" enabled="true">${filecomment}
|
||||
|
||||
${includes}
|
||||
|
||||
${namespace_begin}
|
||||
|
@ -65,7 +64,6 @@ ${declarations}
|
|||
${namespace_end}</template>
|
||||
|
||||
<template name="%CodeTemplates.cppheaderfile" id="org.eclipse.cdt.ui.text.codetemplates.cppheaderfile" description="%CodeTemplates.cppheaderfile.desc" context="org.eclipse.cdt.core.cxxHeader.contenttype_context" enabled="true">${filecomment}
|
||||
|
||||
#ifndef ${include_guard_symbol}
|
||||
#define ${include_guard_symbol}
|
||||
|
||||
|
@ -76,16 +74,15 @@ ${namespace_begin}
|
|||
${declarations}
|
||||
|
||||
${namespace_end}
|
||||
|
||||
#endif /* ${include_guard_symbol} */</template>
|
||||
|
||||
<template name="%CodeTemplates.csourcefile" id="org.eclipse.cdt.ui.text.codetemplates.csourcefile" description="%CodeTemplates.csourcefile.desc" context="org.eclipse.cdt.core.cSource.contenttype_context" enabled="true">${filecomment}
|
||||
|
||||
${includes}
|
||||
|
||||
${declarations}</template>
|
||||
|
||||
<template name="%CodeTemplates.cheaderfile" id="org.eclipse.cdt.ui.text.codetemplates.cheaderfile" description="%CodeTemplates.cheaderfile.desc" context="org.eclipse.cdt.core.cHeader.contenttype_context" enabled="true">${filecomment}
|
||||
|
||||
#ifndef ${include_guard_symbol}
|
||||
#define ${include_guard_symbol}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
</template>
|
||||
|
||||
<template name="%FileTemplates.textfile" id="org.eclipse.cdt.ui.text.codetemplates.textfile" description="%FileTemplates.textfile.desc" context="org.eclipse.core.runtime.text.contenttype_context" enabled="true">${file_name}
|
||||
|
||||
Created on: ${date}
|
||||
Author: ${user}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue