public class BasicCustomizers extends Object
Pre-made Codelet customizers.
aliteralmind __DASH__ github __AT__ yahoo __DOT__ com), dual-licensed under the LGPL (version 3.0 or later) or the ASL (version 2.0). See source code for details. http://codelet.aliteralmind.com, https://github.com/aliteralmind/codelet| Modifier and Type | Method and Description |
|---|---|
static <T extends CodeletTemplateBase> |
eliminateCmtBlocksPkgLineAndPkgReferences(CodeletInstance instance,
CodeletType needed_defaultAlterType,
Boolean doElim_multiLineCmts,
Boolean doElim_packageDecl,
Boolean doElim_allPkgRefs)
Eliminate all multi-line comments, the package declaration line, and any references to that package.
|
static <T extends CodeletTemplateBase> |
eliminateCommentBlocksAndPackageDecl(CodeletInstance instance,
CodeletType needed_defaultAlterType)
Eliminate all multi-line comments and the package declaration line.
|
static <T extends CodeletTemplateBase> |
lineRange(CodeletInstance instance,
CodeletType needed_defaultAlterType,
Integer startAppearance_num,
Boolean is_startLineRegex,
String startLine_findWhat,
Integer endAppearance_num,
Boolean is_endLineRegex,
String endLine_findWhat,
String indentRegexToElim_emptyStrIfNone)
Text snippet: Eliminates all lines except those between a specific start and end line, based on text found in those (start and end) lines.
|
static <T extends CodeletTemplateBase> |
lineRangeWithReplace(CodeletInstance instance,
CodeletType needed_defaultAlterType,
Integer startAppearance_num,
Boolean is_startLineRegex,
String startLine_findWhat,
String startLine_rplcWith,
String startRplcWhat_notMatchNums,
Integer endAppearance_num,
Boolean is_endLineRegex,
String endLine_findWhat,
String endLine_rplcWith,
String endRplcWhat_notMatchNums,
String indentRegexToElim_emptyStrIfNone)
Text snippet: Eliminates all lines except those between a specific start and end line, based on text found in those (start and end) lines--also makes replacements on the start and end lines only.
|
public static final <T extends CodeletTemplateBase> CustomizationInstructions<T> lineRange(CodeletInstance instance, CodeletType needed_defaultAlterType, Integer startAppearance_num, Boolean is_startLineRegex, String startLine_findWhat, Integer endAppearance_num, Boolean is_endLineRegex, String endLine_findWhat, String indentRegexToElim_emptyStrIfNone) throws PatternSyntaxException
Text snippet: Eliminates all lines except those between a specific start and end line, based on text found in those (start and end) lines. The start and end lines are also kept.
{@.codelet com.github.aliteralmind.codelet.examples.adder.AdderDemo%lineRange(1, false, "Adder adder", 1, false, "println(adder.getSum())", "^ ")}
Given this source code, this taglet displays the range of lines beginning with "Adder adder", and ending with the second "println(adder.getSum())". This also eliminates the indentation of the kept lines, which is two tabs at line-start: "^ ".
Adder adder = new Adder(); System.out.println(adder.getSum()); adder = new Adder(5, -7, 20, 27); System.out.println(adder.getSum());
zzBasicCustomizers.lineRange
.allalterer: All alterers, as a whole..elimindent: NewLineAltererFor.eliminateIndentationOrNull.linenums: The start and end line numbers of the snippet.filter: NewLineFilterFor.lineRange.dbgEveryLine_ifNonNull.endalterer: NewLineFilterFor.lineRange.dbgEnd_ifNonNull.endvalidfilter: NewLineFilterFor.lineRange.dbgEndFilter_ifNonNull.startalterer: NewLineFilterFor.lineRange.dbgStart_ifNonNull.startvalidfilter: NewLineFilterFor.lineRange.dbgStartFilter_ifNonNulltemplate: The templateFull names:
zzBasicCustomizers.lineRange.allalterer zzBasicCustomizers.lineRange.elimindent zzBasicCustomizers.lineRange.linenums zzBasicCustomizers.lineRange.filter zzBasicCustomizers.lineRange.filter.endalterer zzBasicCustomizers.lineRange.filter.endvalidfilter zzBasicCustomizers.lineRange.filter.startalterer zzBasicCustomizers.lineRange.filter.startvalidfilter zzBasicCustomizers.lineRange.template
instance - May not be null. When calling this customizer from a taglet, exclude this parameter. All other parameters are required.startAppearance_num - If the text to be found (startLine_findWhat) exists in multiple lines, this is the one to use. Must be greater than zero (although -1, meaning "ignore this setting", is equivalent to 1: the first appearance).is_startLineRegex - If true then startLine_findWhat is treated as a regular expression. Otherwise, startLine_findWhat is treated as a literal.startLine_findWhat - The search term that defines the line-range start line. If a regex, this may or may not include start or end-of-line anchors ('^' and '$') (matching is done with Matcher.find()).endAppearance_num - The appearance number of the end-line search term. If it happens to exist before the start-line search-term, then this parameter must be at least equal to two.is_endLineRegex - If true then endLine_findWhat is treated as a regular expression.endLine_findWhat - The search term that defines the line-range end line.indentRegexToElim_emptyStrIfNone - The regular expression representing the indentation that should be eliminated from the line-range. Since these lines exist in the middle of a file, they may be extra-indented.CustomizationInstructions.<T>newForMaybeElimIndent_tabToSpcEscHtml(instance, filter, indentRegexToElim_emptyStrIfNone)
filter is created with
NewLineFilterFor.lineRangePatternSyntaxExceptionlineRangeWithReplacepublic static final <T extends CodeletTemplateBase> CustomizationInstructions<T> lineRangeWithReplace(CodeletInstance instance, CodeletType needed_defaultAlterType, Integer startAppearance_num, Boolean is_startLineRegex, String startLine_findWhat, String startLine_rplcWith, String startRplcWhat_notMatchNums, Integer endAppearance_num, Boolean is_endLineRegex, String endLine_findWhat, String endLine_rplcWith, String endRplcWhat_notMatchNums, String indentRegexToElim_emptyStrIfNone) throws PatternSyntaxException
Text snippet: Eliminates all lines except those between a specific start and end line, based on text found in those (start and end) lines--also makes replacements on the start and end lines only. The start and end lines are also kept. This function is useful when lines must be marked, but those marks should not be seen in the final output.
{@.codelet com.github.aliteralmind.codelet.examples.adder.AdderDemoWithSnippetEndMarker%lineRangeWithReplace(1, true, "(Adder adder)", "$1", "FIRST", 1, true, "; +//End snippet$", ";", "FIRST", "^ ")}
Adder adder = new Adder(); System.out.println(adder.getSum()); adder = new Adder(5, -7, 20, 27); System.out.println(adder.getSum());
Snippet starts with the line containing "Adder adder", which is replaced with itself: "$1". The last line in the range ends the regular expression "; +//End snippet$" which is replaced with a semi-colon. This also deletes the indentation of the kept lines, which is two tabs at line-start: "^ ". View example
This only documents things that are different from lineRange.
zzBasicCustomizers.lineRangeWithReplace
allalterer: All alterers, as a whole..elimindent: NewLineAltererFor.eliminateIndentationOrNullfilter: NewLineFilterFor.lineRange.dbgEveryLine_ifNonNull.endalterer: NewLineFilterFor.lineRange.dbgEnd_ifNonNull.endvalidfilter: NewLineFilterFor.lineRange.dbgEndFilter_ifNonNull.startalterer: NewLineFilterFor.lineRange.dbgStart_ifNonNull.startvalidfilter: NewLineFilterFor.lineRange.dbgStartFilter_ifNonNulltemplate: The templateFull names:
zzBasicCustomizers.lineRangeWithReplace.allalterer zzBasicCustomizers.lineRangeWithReplace.elimindent zzBasicCustomizers.lineRangeWithReplace.filter zzBasicCustomizers.lineRangeWithReplace.filter.endalterer zzBasicCustomizers.lineRangeWithReplace.filter.endvalidfilter zzBasicCustomizers.lineRangeWithReplace.filter.startalterer zzBasicCustomizers.lineRangeWithReplace.filter.startvalidfilter zzBasicCustomizers.lineRangeWithReplace.template
startLine_findWhat - The text or match that defines the line-range start line. To search for text only (make no replacement), either setis_startLineRegex to false, andstartLine_findWhat ("text to find") and startLine_rplcWith to the same text ("text to find")is_startLineRegex to true,startLine_findWhat to the expected text surrounded by a capture group ("(text to find)"), andstartLine_rplcWith to "$1"startRplcWhat_notMatchNums - In most cases, this should be set to "FIRST". See com.github.xbn.regexutil.ReplacedInEachInput.PatternSyntaxExceptionpublic static final <T extends CodeletTemplateBase> CustomizationInstructions<T> eliminateCommentBlocksAndPackageDecl(CodeletInstance instance, CodeletType needed_defaultAlterType)
Eliminate all multi-line comments and the package declaration line.
public static final <T extends CodeletTemplateBase> CustomizationInstructions<T> eliminateCmtBlocksPkgLineAndPkgReferences(CodeletInstance instance, CodeletType needed_defaultAlterType, Boolean doElim_multiLineCmts, Boolean doElim_packageDecl, Boolean doElim_allPkgRefs)
Eliminate all multi-line comments, the package declaration line, and any references to that package.
{@.codelet com.github.aliteralmind.codelet.examples.adder.Adder%eliminateCmtBlocksPkgLineAndPkgReferences(false, true, false)}
/**
<p>Adds zero or more integers.</p>
**/
public class Adder {
private final int sum;
public Adder(int... numbers_to_add) {
int sum2 = 0;
for(int i : numbers_to_add) {
sum2 += i;
}
sum = sum2;
}
public int getSum() {
return sum;
}
}
Prints all lines except the package declaration. Full example
{@.codelet com.github.aliteralmind.codelet.examples.adder.AdderDemoWithFullyQualified%eliminateCommentBlocksAndPackageDecl()}
public class AdderDemoWithFullyQualified {
public static final void main(String[] ignored) {
com.github.aliteralmind.codelet.examples.adder.Adder adder = new com.github.aliteralmind.codelet.examples.adder.Adder();
System.out.println(adder.getSum());
adder = new com.github.aliteralmind.codelet.examples.adder.Adder(5, -7, 20, 27);
System.out.println(adder.getSum()); //End snippet
}
}
Eliminates the package declaration and all multi-line comment blocks (including license and JavaDoc). (Intro example)
zzBasicCustomizers.eliminateCmtBlocksPkgLineAndPkgReferences
alterers: All alterers, as a wholeblockmarks: NewLineFilterFor.lineRange.dbgBlockMarks_ifNonNullfilter: NewLineFilterFor.eliminateAllCmtBlocksAndPackageLine.dbgLnFilter_ifNonNullpkglinevalidator: NewLineFilterFor.eliminateAllCmtBlocksAndPackageLine.dbgPkgLnVldtr_ifNonNullpkglinevalidfilter: NewLineFilterFor.eliminateAllCmtBlocksAndPackageLine.dbgValidResultFilter_ifNonNulltemplate: NewLineFilterFor.eliminateAllCmtBlocksAndPackageLine.dbgPkgLnVldtr_ifNonNullelimpkgrefsreplacer: NewLineAltererFor.elimPackageReferencesFull names:
zzBasicCustomizers.eliminateCmtBlocksPkgLineAndPkgReferences.alterers zzBasicCustomizers.eliminateCmtBlocksPkgLineAndPkgReferences.blockmarks zzBasicCustomizers.eliminateCmtBlocksPkgLineAndPkgReferences.filter zzBasicCustomizers.eliminateCmtBlocksPkgLineAndPkgReferences.pkglinevalidator zzBasicCustomizers.eliminateCmtBlocksPkgLineAndPkgReferences.pkglinevalidfilter zzBasicCustomizers.eliminateCmtBlocksPkgLineAndPkgReferences.template zzBasicCustomizers.eliminateCmtBlocksPkgLineAndPkgReferences.elimpkgrefsreplacer
doElim_allPkgRefs - If doElim_packageDecl is false, this must also be false.null instructions object, using the default template, where the filter is created by
NewLineFilterFor.eliminateAllCmtBlocksAndPackageLine
dbgLnFilter_ifNonNull parameter is set to
CodeletBaseConfig.getDebugApblIfOn(instance)
CodeletBaseConfig.getDebugApblIfTagletVerbose(instance)eliminateCommentBlocksAndPackageDeclCopyright 2014, Jeff Epstein, All Rights Reserved. See top of source code files for copyright notice.
https://github.com/aliteralmind/codelet