Skip to content

Commit

Permalink
Add a few <pre> tags to JsDocInfoParser
Browse files Browse the repository at this point in the history
There are a few spots where the java auto-formatter wants to reflow a javadoc comment, but the newlines were actually meaningful.  Surrounding these cases with <pre> prevents this.  Also fixed one spot where an accidental reflow occurred.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=222316122
  • Loading branch information
shicks authored and lauraharker committed Nov 21, 2018
1 parent 2efbed7 commit 8107b34
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java
Expand Up @@ -1919,14 +1919,17 @@ private Node parseTypeExpressionAnnotation(JsDocToken token) {
}

/**
* Parse a ParamTypeExpression:
*
* <pre>
* ParamTypeExpression :=
* OptionalParameterType |
* TopLevelTypeExpression |
* '...' TopLevelTypeExpression
*
* OptionalParameterType :=
* TopLevelTypeExpression '='
*
* </pre>
*/
private Node parseParamTypeExpression(JsDocToken token) {
boolean restArg = false;
Expand Down Expand Up @@ -2174,8 +2177,12 @@ private Node parseNameExpression(JsDocToken token) {
}

/**
* TypeName := NameExpression | NameExpression TypeApplication TypeApplication := '.'? '<'
* TypeExpressionList '>'
* Parse a TypeName:
*
* <pre>{@code
* TypeName := NameExpression | NameExpression TypeApplication
* TypeApplication := '.'? '<' TypeExpressionList '>'
* }</pre>
*/
private Node parseTypeName(JsDocToken token) {
Node typeNameNode = parseNameExpression(token);
Expand Down Expand Up @@ -2209,16 +2216,19 @@ private Node parseTypeofType(JsDocToken token) {
}

/**
* Parse a FunctionType:
*
* <pre>
* FunctionType := 'function' FunctionSignatureType
* FunctionSignatureType :=
* TypeParameters '(' 'this' ':' TypeName, ParametersType ')' ResultType
* </pre>
*
* <p>The Node that is produced has type Token.FUNCTION but does not look like a typical
* function node. If there is a 'this:' or 'new:' type, that type is added as a child.
* Then, if there are parameters, a PARAM_LIST node is added as a child. Finally, if
* there is a return type, it is added as a child. This means that the parameters
* could be the first or second child, and the return type could be
* the first, second, or third child.
* <p>The Node that is produced has type Token.FUNCTION but does not look like a typical function
* node. If there is a 'this:' or 'new:' type, that type is added as a child. Then, if there are
* parameters, a PARAM_LIST node is added as a child. Finally, if there is a return type, it is
* added as a child. This means that the parameters could be the first or second child, and the
* return type could be the first, second, or third child.
*/
private Node parseFunctionType(JsDocToken token) {
// NOTE(nicksantos): We're not implementing generics at the moment, so
Expand Down Expand Up @@ -2294,6 +2304,9 @@ private Node parseFunctionType(JsDocToken token) {
}

/**
* Parse a ParametersType:
*
* <pre>
* ParametersType := RestParameterType | NonRestParametersType
* | NonRestParametersType ',' RestParameterType
* RestParameterType := '...' Identifier
Expand All @@ -2304,6 +2317,7 @@ private Node parseFunctionType(JsDocToken token) {
* | OptionalParameterType, OptionalParametersType
* OptionalParameterType := ParameterType=
* ParameterType := TypeExpression | Identifier ':' TypeExpression
* </pre>
*/
// NOTE(nicksantos): The official ES4 grammar forces optional and rest
// arguments to come after the required arguments. Our parser does not
Expand Down

0 comments on commit 8107b34

Please sign in to comment.