Java Code Examples for com.google.javascript.rhino.JSDocInfo#Marker
The following examples show how to use
com.google.javascript.rhino.JSDocInfo#Marker .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JsDocInfoParserTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Asserts that a documentation field exists on the given marker. * * @param description The text of the documentation field expected. * @param startCharno The starting character of the text. * @param endLineno The ending line of the text. * @param endCharno The ending character of the text. * @return The marker, for chaining purposes. */ private JSDocInfo.Marker assertDocumentationInMarker(JSDocInfo.Marker marker, String description, int startCharno, int endLineno, int endCharno) { assertTrue(marker.getDescription() != null); assertEquals(description, marker.getDescription().getItem()); // Match positional information. assertEquals(marker.getAnnotation().getStartLine(), marker.getDescription().getStartLine()); assertEquals(startCharno, marker.getDescription().getPositionOnStartLine()); assertEquals(endLineno, marker.getDescription().getEndLine()); assertEquals(endCharno, marker.getDescription().getPositionOnEndLine()); return marker; }
Example 2
Source File: JsDocInfoParserTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Asserts that a type field exists on the given marker. * * @param typeName The name of the type expected in the type field. * @param startCharno The starting character of the type declaration. * @param hasBrackets Whether the type in the type field is expected * to have brackets. * @return The marker, for chaining purposes. */ private JSDocInfo.Marker assertTypeInMarker( JSDocInfo.Marker marker, String typeName, int startLineno, int startCharno, int endLineno, int endCharno, boolean hasBrackets) { assertTrue(marker.getType() != null); assertTrue(marker.getType().getItem().isString()); // Match the name and brackets information. String foundName = marker.getType().getItem().getString(); assertEquals(typeName, foundName); assertEquals(hasBrackets, marker.getType().hasBrackets()); // Match position information. assertEquals(startCharno, marker.getType().getPositionOnStartLine()); assertEquals(endCharno, marker.getType().getPositionOnEndLine()); assertEquals(startLineno, marker.getType().getStartLine()); assertEquals(endLineno, marker.getType().getEndLine()); return marker; }
Example 3
Source File: JsDocInfoParserTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Asserts that a name field exists on the given marker. * * @param name The name expected in the name field. * @param startCharno The starting character of the text. * @return The marker, for chaining purposes. */ @SuppressWarnings("deprecation") private JSDocInfo.Marker assertNameInMarker(JSDocInfo.Marker marker, String name, int startLine, int startCharno) { assertTrue(marker.getName() != null); assertEquals(name, marker.getName().getItem()); assertEquals(startCharno, marker.getName().getPositionOnStartLine()); assertEquals(startCharno + name.length(), marker.getName().getPositionOnEndLine()); assertEquals(startLine, marker.getName().getStartLine()); assertEquals(startLine, marker.getName().getEndLine()); return marker; }
Example 4
Source File: IRFactoryTest.java From astor with GNU General Public License v2.0 | 5 votes |
private void assertMarkerPosition(Node n, int lineno, int charno) { int count = 0; for (JSDocInfo.Marker marker : n.getJSDocInfo().getMarkers()) { assertEquals(lineno, marker.getAnnotation().getStartLine()); assertEquals(charno, marker.getAnnotation().getPositionOnStartLine()); count++; } assertEquals(1, count); }
Example 5
Source File: JsDocInfoParserTest.java From astor with GNU General Public License v2.0 | 5 votes |
public void testParseWithMarkers3() throws Exception { JSDocInfo jsdoc = parse("@return {Foo} some long \n * multiline" + " \n * description */", true); JSDocInfo.Marker returnDoc = assertAnnotationMarker(jsdoc, "return", 0, 0); assertDocumentationInMarker(returnDoc, "some long multiline description", 13, 2, 15); assertEquals(8, returnDoc.getType().getPositionOnStartLine()); assertEquals(12, returnDoc.getType().getPositionOnEndLine()); }
Example 6
Source File: JsDocInfoParserTest.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Asserts that the index-th annotation marker of a given annotation name * is found in the given JSDocInfo. * * @param jsdoc The JSDocInfo in which to search for the annotation marker. * @param annotationName The name/type of the annotation for which to * search. Example: "author" for an "@author" annotation. * @param startLineno The expected starting line number of the marker. * @param startCharno The expected character on the starting line. * @param index The index of the marker. * @return The marker found, for further testing. */ private JSDocInfo.Marker assertAnnotationMarker(JSDocInfo jsdoc, String annotationName, int startLineno, int startCharno, int index) { Collection<JSDocInfo.Marker> markers = jsdoc.getMarkers(); assertTrue(markers.size() > 0); int counter = 0; for (JSDocInfo.Marker marker : markers) { if (marker.getAnnotation() != null) { if (annotationName.equals(marker.getAnnotation().getItem())) { if (counter == index) { assertEquals(startLineno, marker.getAnnotation().getStartLine()); assertEquals(startCharno, marker.getAnnotation().getPositionOnStartLine()); assertEquals(startLineno, marker.getAnnotation().getEndLine()); assertEquals(startCharno + annotationName.length(), marker.getAnnotation().getPositionOnEndLine()); return marker; } counter++; } } } fail("No marker found"); return null; }
Example 7
Source File: JsDoc.java From js-dossier with Apache License 2.0 | 5 votes |
@Nullable private JSTypeExpression getJsTypeExpression(JSDocInfo.Marker marker) { if (marker.getType() == null) { return null; } return new JSTypeExpression(marker.getType().getItem(), ""); }
Example 8
Source File: JsDoc.java From js-dossier with Apache License 2.0 | 5 votes |
static Optional<Annotation> forMarker(JSDocInfo.Marker marker) { for (Annotation a : Annotation.values()) { if (a.annotation.equals(marker.getAnnotation().getItem())) { return Optional.of(a); } } return Optional.empty(); }
Example 9
Source File: JsDocInfoParserTest.java From astor with GNU General Public License v2.0 | 3 votes |
/** * Asserts that an annotation marker of a given annotation name * is found in the given JSDocInfo. * * @param jsdoc The JSDocInfo in which to search for the annotation marker. * @param annotationName The name/type of the annotation for which to * search. Example: "author" for an "@author" annotation. * @param startLineno The expected starting line number of the marker. * @param startCharno The expected character on the starting line. * @return The marker found, for further testing. */ private JSDocInfo.Marker assertAnnotationMarker(JSDocInfo jsdoc, String annotationName, int startLineno, int startCharno) { return assertAnnotationMarker(jsdoc, annotationName, startLineno, startCharno, 0); }