use of com.google.javascript.rhino.JSTypeExpression in project closure-compiler by google.
the class JSDocInfoPrinterTest method testTemplateBound_nullabilityIsPreserved.
@Test
public void testTemplateBound_nullabilityIsPreserved() {
builder.recordTemplateTypeName("T", new JSTypeExpression(JsDocInfoParser.parseTypeString("?Array<number>"), ""));
JSDocInfo info = builder.buildAndReset();
assertThat(jsDocInfoPrinter.print(info)).isEqualTo(lines(//
"/**", " * @template {?Array<number>} T", " */", ""));
}
use of com.google.javascript.rhino.JSTypeExpression in project closure-compiler by google.
the class JSDocInfoPrinterTest method testSeeReferencePrintedWithOtherAnnotations.
@Test
public void testSeeReferencePrintedWithOtherAnnotations() {
builder.recordType(new JSTypeExpression(JsDocInfoParser.parseTypeString("string"), "<testSee>"));
builder.recordReference("SomeClassName for more details");
JSDocInfo info = builder.buildAndReset();
assertThat(jsDocInfoPrinter.print(info)).isEqualTo(LINE_JOINER.join("/**", " * @see SomeClassName for more details", " * @type {string}", " */", ""));
}
use of com.google.javascript.rhino.JSTypeExpression in project closure-compiler by google.
the class JSDocInfoPrinterTest method testInterfaceInheritance.
@Test
public void testInterfaceInheritance() {
builder.recordInterface();
builder.recordExtendedInterface(new JSTypeExpression(JsDocInfoParser.parseTypeString("Foo"), "<testInterfaceInheritance>"));
builder.recordExtendedInterface(new JSTypeExpression(JsDocInfoParser.parseTypeString("Bar"), "<testInterfaceInheritance>"));
JSDocInfo info = builder.buildAndReset();
assertThat(jsDocInfoPrinter.print(info)).isEqualTo("/**\n * @interface\n * @extends {Foo}\n * @extends {Bar}\n */\n");
}
use of com.google.javascript.rhino.JSTypeExpression in project closure-compiler by google.
the class JSDocInfoPrinterTest method testAllDescriptions.
@Test
public void testAllDescriptions() {
builder.recordBlockDescription("Description of the thing");
builder.recordParameter("foo", new JSTypeExpression(JsDocInfoParser.parseTypeString("number"), "<testParam>"));
builder.recordParameter("bar", new JSTypeExpression(JsDocInfoParser.parseTypeString("string"), "<testParam>"));
builder.recordParameterDescription("foo", " A number for foo");
builder.recordParameterDescription("bar", " A multline\n description for bar");
builder.recordReturnType(new JSTypeExpression(JsDocInfoParser.parseTypeString("boolean"), "<testReturn>"));
builder.recordReturnDescription("The return value");
JSDocInfo info = builder.buildAndReset();
assertThat(jsDocInfoPrinter.print(info)).isEqualTo(LINE_JOINER.join("/**", " * Description of the thing", " *", " * @param {number} foo A number for foo", " * @param {string} bar A multline", " * description for bar", " * @return {boolean} The return value", " */", ""));
}
use of com.google.javascript.rhino.JSTypeExpression in project closure-compiler by google.
the class JSDocInfoPrinterTest method testTemplatesBound_mixedWithUnbounded.
@Test
public void testTemplatesBound_mixedWithUnbounded() {
builder.recordTemplateTypeName("T", new JSTypeExpression(JsDocInfoParser.parseTypeString("!Object"), ""));
builder.recordTemplateTypeName("S");
builder.recordTemplateTypeName("R");
builder.recordTemplateTypeName("U", new JSTypeExpression(JsDocInfoParser.parseTypeString("*"), ""));
builder.recordTemplateTypeName("Q");
JSDocInfo info = builder.buildAndReset();
assertThat(jsDocInfoPrinter.print(info)).isEqualTo(lines("/**", " * @template {!Object} T", " * @template S", " * @template R", " * @template {*} U", " * @template Q", " */", ""));
}
Aggregations