Skip to content

Commit

Permalink
fixed files form Closure #32
Browse files Browse the repository at this point in the history
  • Loading branch information
tdurieux committed Mar 7, 2017
1 parent ce9e4c8 commit ebeb887
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1355,12 +1355,14 @@ private ExtractionInfo extractMultilineTextualBlock(JsDocToken token,
// Track the start of the line to count whitespace that
// the tokenizer skipped. Because this case is rare, it's easier
// to do this here than in the tokenizer.
int lineStartChar = -1;

do {
switch (token) {
case STAR:
if (ignoreStar) {
// Mark the position after the star as the new start of the line.
lineStartChar = stream.getCharno() + 1;
} else {
// The star is part of the comment.
if (builder.length() > 0) {
Expand All @@ -1379,14 +1381,27 @@ private ExtractionInfo extractMultilineTextualBlock(JsDocToken token,
}

ignoreStar = true;
lineStartChar = 0;
token = next();
continue;

default:
ignoreStar = false;
state = State.SEARCHING_ANNOTATION;

boolean isEOC = token == JsDocToken.EOC;
if (!isEOC) {
if (lineStartChar != -1 && option == WhitespaceOption.PRESERVE) {
int numSpaces = stream.getCharno() - lineStartChar;
for (int i = 0; i < numSpaces; i++) {
builder.append(' ');
}
lineStartChar = -1;
} else if (builder.length() > 0) {
// All tokens must be separated by a space.
builder.append(' ');
}
}

if (token == JsDocToken.EOC ||
token == JsDocToken.EOF ||
Expand All @@ -1411,9 +1426,6 @@ private ExtractionInfo extractMultilineTextualBlock(JsDocToken token,
return new ExtractionInfo(multilineText, token);
}

if (builder.length() > 0) {
builder.append(' ');
}
builder.append(toString(token));

line = stream.getRemainingJSDocLine();
Expand Down

0 comments on commit ebeb887

Please sign in to comment.