void appendText(FormatJavadocText text) { text.immutable = this.immutable; if (this.depth == text.depth) { addSeparator(text); this.sourceEnd = text.sourceEnd; if (text.isClosingHtmlTag()) { // close the tag this.htmlTagIndex = text.htmlTagIndex; } } else { appendNode(text); } if (text.isHtmlTag()) { switch (text.htmlTagIndex & JAVADOC_TAGS_ID_MASK) { case JAVADOC_CODE_TAGS_ID: text.linesBefore = this.htmlNodesPtr == -1 ? 0 : 2; break; case JAVADOC_SEPARATOR_TAGS_ID: text.linesBefore = 1; break; case JAVADOC_SINGLE_BREAK_TAG_ID: if (!text.isClosingHtmlTag()) text.linesBefore = 1; break; case JAVADOC_BREAK_TAGS_ID: if (!text.isClosingHtmlTag()) text.linesBefore = 1; } } } void appendNode(FormatJavadocNode node) {
FormatJavadocText lastText = textHierarchy[text.depth]; if (lastText != null) { lastText.appendText(text); for (int i=text.depth-1; i>=0; i--) { textHierarchy[i].sourceEnd = text.sourceEnd; FormatJavadocText parentText = textHierarchy[text.depth-1]; if (parentText != null) { parentText.appendText(text); for (int i=text.depth-2; i>=0; i--) { textHierarchy[i].sourceEnd = text.sourceEnd; if (text.isHtmlTag()) { switch (text.getHtmlTagID()) { case JAVADOC_CODE_TAGS_ID: text.linesBefore = this.nodesPtr == -1 ? 0 : 2;
while (lastNode.isText()) { FormatJavadocText lastText = (FormatJavadocText) lastNode; int lastTagCategory = lastText.getHtmlTagID(); boolean lastSingleTag = lastTagCategory <= JAVADOC_SINGLE_TAGS_ID; boolean lastTextCanHaveChildren = lastText.isHtmlTag() && !lastText.isClosingHtmlTag() && !lastSingleTag; if (lastText.depth == htmlDepth || // found same html tag level => use it lastText.htmlNodesPtr == -1) { // no more sub-levels => add one if (lastText.isHtmlTag()) { boolean setLinesBefore = lastText.separatorsPtr == -1 || (ptr == 0 && lastText.isClosingHtmlTag()); if (!setLinesBefore && ptr > 0 && lastText.isClosingHtmlTag()) { switch (lastText.getHtmlTagID()) { case JAVADOC_CODE_TAGS_ID: if (node.linesBefore < 2) { if (text != null && text.isHtmlTag() && !text.isClosingHtmlTag() && text.getHtmlTagIndex() == lastText.getHtmlTagIndex() && !lastText.isClosingHtmlTag()) { lastText.closeTag(); return textHierarchy; if (lastTextCanHaveChildren || (htmlDepth == 0 && !lastText.isHtmlTag() && text != null && !text.isHtmlTag())) { if (textHierarchy == null) textHierarchy = new FormatJavadocText[htmlDepth+1]; textHierarchy[ptr] = lastText;
if (text.isImmutable()) { if (text.isImmutableHtmlTag() && newLines > 0 && this.commentIndentation != null) { addInsertEdit(node.sourceStart, this.commentIndentation); this.column += this.commentIndentation.length(); } else if (text.isHtmlTag()) { printJavadocHtmlTag(text, block, newLines>0); } else {
for (int t=0; t<=this.depth; t++) indentation.append('\t'); buffer.append(indentation); if (isImmutable()) { buffer.append("immutable "); //$NON-NLS-1$ buffer.append(this.linesBefore).append(" before, "); //$NON-NLS-1$ String tagID = "no"; //$NON-NLS-1$ switch (getHtmlTagID()) { case JAVADOC_TAGS_ID_MASK: tagID = "mask"; //$NON-NLS-1$
if (text.isHtmlTag()) { if (text.getHtmlTagID() == JAVADOC_SINGLE_BREAK_TAG_ID) {
int nextStart = textStart; int startLine = Util.getLineNumber(textStart, this.lineEnds, 0, this.maxLines); int htmlTagID = text.getHtmlTagID(); if (text.depth >= this.javadocHtmlTagBuffers.length) { int length = this.javadocHtmlTagBuffers.length; if (!needIndentation && text.isTextAfterHtmlSeparatorTag(idx-1)) { needIndentation = true; if (!needIndentation && !isHtmlBreakTag && text.htmlIndexes != null && text.isTextAfterHtmlSeparatorTag(max)) { needIndentation = true;
void appendNode(FormatJavadocNode node) { if (++this.htmlNodesPtr == 0) { // lazy initialization this.htmlNodes = new FormatJavadocNode[DEFAULT_ARRAY_SIZE]; } else { if (this.htmlNodesPtr == this.htmlNodes.length) { int size = this.htmlNodesPtr + DEFAULT_ARRAY_SIZE; System.arraycopy(this.htmlNodes, 0, (this.htmlNodes= new FormatJavadocNode[size]), 0, this.htmlNodesPtr); } } addSeparator(node); this.htmlNodes[this.htmlNodesPtr] = node; this.sourceEnd = node.sourceEnd; }
void addBlock(FormatJavadocBlock block, int htmlLevel) { if (this.nodes != null) { FormatJavadocText[] textHierarchy = getTextHierarchy(block, htmlLevel); if (textHierarchy != null) { FormatJavadocText lastText = textHierarchy[htmlLevel]; if (lastText != null) { lastText.appendNode(block); for (int i=htmlLevel-1; i>=0; i--) { textHierarchy[i].sourceEnd = block.sourceEnd; } this.sourceEnd = block.sourceEnd; if (isParamTag()) { block.flags |= IN_PARAM_TAG; } else if (isDescription()) { block.flags |= IN_DESCRIPTION; } block.flags |= INLINED; return; } } } addNode(block); if (isParamTag()) { block.flags |= IN_PARAM_TAG; } else if (isDescription()) { block.flags |= IN_DESCRIPTION; } block.flags |= INLINED; }
FormatJavadocText text = new FormatJavadocText(start, end-1, lineStart, htmlIndex, htmlDepth==-1 ? 0 : htmlDepth); previousBlock.addText(text); previousBlock.sourceStart = previousStart;
switch (getHtmlTagID()) { case JAVADOC_CODE_TAGS_ID: buffer.append('\n');
private int getTextLength(FormatJavadocBlock block, FormatJavadocText text) { if (text.isImmutable()) { this.scanner.resetTo(text.sourceStart , text.sourceEnd); int textLength = 0;
if (text.isImmutable()) { if (text.isImmutableHtmlTag() && newLines > 0 && this.commentIndentation != null) { addInsertEdit(node.sourceStart, this.commentIndentation); this.column += this.commentIndentation.length(); } else if (text.isHtmlTag()) { printJavadocHtmlTag(text, block, newLines>0); } else {
for (int t=0; t<=this.depth; t++) indentation.append('\t'); buffer.append(indentation); if (isImmutable()) { buffer.append("immutable "); //$NON-NLS-1$ buffer.append(this.linesBefore).append(" before, "); //$NON-NLS-1$ String tagID = "no"; //$NON-NLS-1$ switch (getHtmlTagID()) { case JAVADOC_TAGS_ID_MASK: tagID = "mask"; //$NON-NLS-1$
if (text.isHtmlTag()) { if (text.getHtmlTagID() == JAVADOC_SINGLE_BREAK_TAG_ID) {
int nextStart = textStart; int startLine = Util.getLineNumber(textStart, this.lineEnds, 0, this.maxLines); int htmlTagID = text.getHtmlTagID(); if (text.depth >= this.javadocHtmlTagBuffers.length) { int length = this.javadocHtmlTagBuffers.length; if (!needIndentation && text.isTextAfterHtmlSeparatorTag(idx-1)) { needIndentation = true; if (!needIndentation && !isHtmlBreakTag && text.htmlIndexes != null && text.isTextAfterHtmlSeparatorTag(max)) { needIndentation = true;
void appendNode(FormatJavadocNode node) { if (++this.htmlNodesPtr == 0) { // lazy initialization this.htmlNodes = new FormatJavadocNode[DEFAULT_ARRAY_SIZE]; } else { if (this.htmlNodesPtr == this.htmlNodes.length) { int size = this.htmlNodesPtr + DEFAULT_ARRAY_SIZE; System.arraycopy(this.htmlNodes, 0, (this.htmlNodes= new FormatJavadocNode[size]), 0, this.htmlNodesPtr); } } addSeparator(node); this.htmlNodes[this.htmlNodesPtr] = node; this.sourceEnd = node.sourceEnd; }
void addBlock(FormatJavadocBlock block, int htmlLevel) { if (this.nodes != null) { FormatJavadocText[] textHierarchy = getTextHierarchy(block, htmlLevel); if (textHierarchy != null) { FormatJavadocText lastText = textHierarchy[htmlLevel]; if (lastText != null) { lastText.appendNode(block); for (int i=htmlLevel-1; i>=0; i--) { textHierarchy[i].sourceEnd = block.sourceEnd; } this.sourceEnd = block.sourceEnd; if (isParamTag()) { block.flags |= IN_PARAM_TAG; } else if (isDescription()) { block.flags |= IN_DESCRIPTION; } block.flags |= INLINED; return; } } } addNode(block); if (isParamTag()) { block.flags |= IN_PARAM_TAG; } else if (isDescription()) { block.flags |= IN_DESCRIPTION; } block.flags |= INLINED; }
FormatJavadocText text = new FormatJavadocText(start, end-1, lineStart, htmlIndex, htmlDepth==-1 ? 0 : htmlDepth); previousBlock.addText(text); previousBlock.sourceStart = previousStart;
switch (getHtmlTagID()) { case JAVADOC_CODE_TAGS_ID: buffer.append('\n');