Search in sources :

Example 1 with SpecIdentifiableElementSection

use of org.eclipse.n4js.jsdoc2spec.adoc.SpecIdentifiableElementSection in project n4js by eclipse.

the class SpecADocXpectMethod method specADoc.

/**
 * Checks that an element/expression produces a certain specification string. Usage:
 *
 * <pre>
 * /* X-PECT specADoc at 'location' ---
 * expected spec output
 * --- * /
 * </pre>
 *
 * The location (at) is optional.
 *
 * Note that the X-PECT comment must be written <b>before</b> the JSDoc comment of the element.
 *
 * @param arg1
 *            the location identified by the offset.
 */
@Xpect
@ParameterParser(syntax = "('at' arg1=STRING)?")
public void specADoc(@StringExpectation(caseSensitive = true) IStringExpectation expectation, IEObjectCoveringRegion arg1) {
    if (expectation == null) {
        throw new IllegalStateException("No expectation specified, add '--- expected expectation ---");
    }
    IdentifiableElement element = getIdentifiableElement(arg1);
    SpecIdentifiableElementSection src = new SpecIdentifiableElementSection(element, repoPathHolder);
    String actual = formatter.createSpecRegionString(src, Collections.emptyMap()).toString();
    expectation.assertEquals(actual);
}
Also used : IdentifiableElement(org.eclipse.n4js.ts.types.IdentifiableElement) SpecIdentifiableElementSection(org.eclipse.n4js.jsdoc2spec.adoc.SpecIdentifiableElementSection) Xpect(org.eclipse.xpect.runner.Xpect) ParameterParser(org.eclipse.xpect.parameter.ParameterParser)

Aggregations

SpecIdentifiableElementSection (org.eclipse.n4js.jsdoc2spec.adoc.SpecIdentifiableElementSection)1 IdentifiableElement (org.eclipse.n4js.ts.types.IdentifiableElement)1 ParameterParser (org.eclipse.xpect.parameter.ParameterParser)1 Xpect (org.eclipse.xpect.runner.Xpect)1