public class CodeGenerationResponseProcessor
extends java.lang.Object
| Constructor and Description |
|---|
CodeGenerationResponseProcessor() |
| Modifier and Type | Method and Description |
|---|---|
static int[] |
determineReplacementRange(CodeSnippetDescriptor snippetDescriptor,
GeneratedCode genCode)
Determines the substring of a source code file which should be replaced by
generated code content.
|
static java.lang.String |
ensureEndingNewline(java.lang.String code,
java.lang.String newline)
Appends a newline to a string unless the string already ends with a newline.
|
static java.lang.String |
getEffectiveIndent(CodeSnippetDescriptor snippetDescriptor,
GeneratedCode genCode)
Determines effective indent to apply to generated code content.
|
static boolean |
getShouldEnsureEndingNewline(GeneratedCode genCode)
Determines whether content of generated code should be appended with
newline if it doesn't end with one.
|
static void |
indentCode(java.util.List<GeneratedCode.ContentPart> contentParts,
java.lang.String indent)
Modified content parts in place to insert indents before each occurring line.
|
static void |
repairSplitCrLfs(java.util.List<GeneratedCode.ContentPart> contentParts)
Modifies content parts to remove split CR-LFs, that is, a sequence of
carriage return and line feed which are split across content parts, so
that the carriage return character ends a content part, and the following content part
starts with the line feed character.
|
static boolean |
shouldWrapInGenCodeDirectives(GeneratedCode genCode,
CodeSnippetDescriptor.GeneratedCodeDescriptor generatedCodeDescriptor)
Determines whether generated code content should be wrapped in start/end
directives.
|
public static int[] determineReplacementRange(CodeSnippetDescriptor snippetDescriptor, GeneratedCode genCode)
snippetDescriptor - object containing location descriptors for a
generated code object and its corresponding augmenting code object.genCode - generated code object.public static boolean getShouldEnsureEndingNewline(GeneratedCode genCode)
genCode - generated code objectpublic static java.lang.String ensureEndingNewline(java.lang.String code,
java.lang.String newline)
code - string to append newline tonewline - newline variant to usepublic static void repairSplitCrLfs(java.util.List<GeneratedCode.ContentPart> contentParts)
The indentCode(List, String) method depend on the absence of
split CR-LFs.
contentParts - content parts to be modified.public static java.lang.String getEffectiveIndent(CodeSnippetDescriptor snippetDescriptor, GeneratedCode genCode)
snippetDescriptor - descriptor of augmenting code and
generated code sections corresponding to generated code object.genCode - generated code object.public static boolean shouldWrapInGenCodeDirectives(GeneratedCode genCode, CodeSnippetDescriptor.GeneratedCodeDescriptor generatedCodeDescriptor)
genCode - generated code objectgeneratedCodeDescriptor - generated code descriptorpublic static void indentCode(java.util.List<GeneratedCode.ContentPart> contentParts, java.lang.String indent)
Precondition: repairSplitCrLfs(List) should have been
called on content parts.
Postcondition: the result of the indentation should be the same as indenting the string resulting from concatenating the content parts directly.
contentParts - content parts to be modified.indent - indent to apply.