mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +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[] fullLine= { CodeTemplateContextType.FILE_COMMENT };
|
||||||
|
|
||||||
String text = evaluateTemplate(context, template, fullLine);
|
String text = evaluateTemplate(context, template, fullLine);
|
||||||
if (text != null && !text.endsWith(lineDelimiter))
|
if (text != null) {
|
||||||
text += lineDelimiter;
|
// 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;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,8 @@
|
||||||
*
|
*
|
||||||
* Created on: ${date}
|
* Created on: ${date}
|
||||||
* Author: ${user}
|
* 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">/*
|
<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>
|
||||||
|
|
||||||
<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}
|
<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}
|
${includes}
|
||||||
|
|
||||||
${namespace_begin}
|
${namespace_begin}
|
||||||
|
@ -55,7 +55,6 @@ ${declarations}
|
||||||
${namespace_end}</template>
|
${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}
|
<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}
|
${includes}
|
||||||
|
|
||||||
${namespace_begin}
|
${namespace_begin}
|
||||||
|
@ -65,7 +64,6 @@ ${declarations}
|
||||||
${namespace_end}</template>
|
${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}
|
<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}
|
#ifndef ${include_guard_symbol}
|
||||||
#define ${include_guard_symbol}
|
#define ${include_guard_symbol}
|
||||||
|
|
||||||
|
@ -76,16 +74,15 @@ ${namespace_begin}
|
||||||
${declarations}
|
${declarations}
|
||||||
|
|
||||||
${namespace_end}
|
${namespace_end}
|
||||||
|
|
||||||
#endif /* ${include_guard_symbol} */</template>
|
#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}
|
<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}
|
${includes}
|
||||||
|
|
||||||
${declarations}</template>
|
${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}
|
<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}
|
#ifndef ${include_guard_symbol}
|
||||||
#define ${include_guard_symbol}
|
#define ${include_guard_symbol}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
</template>
|
</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}
|
<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}
|
Created on: ${date}
|
||||||
Author: ${user}
|
Author: ${user}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue