if (state == State.SEARCHING_ANNOTATION) { state = State.SEARCHING_NEWLINE; token = parseAnnotation(token, extendedTypes); } else { token = next(); checkExtendedTypes(extendedTypes); if (hasParsedFileOverviewDocInfo()) { fileOverviewJSDocInfo = retrieveAndResetParsedJSDocInfo(); Visibility visibility = fileOverviewJSDocInfo.getVisibility(); switch (visibility) { addParserWarning( "msg.bad.fileoverview.visibility.annotation", visibility.toString().toLowerCase()); addParserWarning("msg.unexpected.eof"); checkExtendedTypes(extendedTypes); return false; token = next(); break; token = next(); } else { state = State.SEARCHING_NEWLINE; token = eatTokensUntilEOL();
/** * Parse a description as a {@code @type}. */ public JSDocInfo parseInlineTypeDoc() { skipEOLs(); JsDocToken token = next(); int lineno = stream.getLineno(); int startCharno = stream.getCharno(); Node typeAst = parseParamTypeExpression(token); recordTypeNode(lineno, startCharno, typeAst, token == JsDocToken.LEFT_CURLY); JSTypeExpression expr = createJSTypeExpression(typeAst); if (expr != null) { jsdocBuilder.recordType(expr); jsdocBuilder.recordInlineType(); return retrieveAndResetParsedJSDocInfo(); } return null; }
/** * Gets the next token of the token stream or the buffered token if a matching * was previously made. */ private JsDocToken next() { if (unreadToken == NO_UNREAD_TOKEN) { return stream.getJsDocToken(); } else { return current(); } }
/** * Eats tokens until {@link JsDocToken#EOL} included, and switches back the * state to {@link State#SEARCHING_ANNOTATION}. */ private JsDocToken eatTokensUntilEOL() { return eatTokensUntilEOL(next()); }
private JsDocToken eatUntilEOLIfNotAnnotation() { return eatUntilEOLIfNotAnnotation(next()); }
/** * Records a marker's description if there is one available and record it in * the current marker. */ private JsDocToken recordDescription(JsDocToken token) { // Find marker's description (if applicable). if (jsdocBuilder.shouldParseDocumentation()) { ExtractionInfo descriptionInfo = extractMultilineTextualBlock(token); token = descriptionInfo.token; } else { token = eatTokensUntilEOL(token); } return token; }
Annotation annotation = annotations.get(annotationName); if (annotation == null || annotationName.isEmpty()) { addParserWarning("msg.bad.jsdoc.tag", annotationName); } else { case NG_INJECT: if (jsdocBuilder.isNgInjectRecorded()) { addParserWarning("msg.jsdoc.nginject.extra"); } else { jsdocBuilder.recordNgInject(true); return eatUntilEOLIfNotAnnotation(); addTypeWarning("msg.jsdoc.incompat.type"); return eatUntilEOLIfNotAnnotation(); ExtractionInfo authorInfo = extractSingleLineBlock(); String author = authorInfo.string; addParserWarning("msg.jsdoc.authormissing"); } else { jsdocBuilder.addAuthor(author); token = eatUntilEOLIfNotAnnotation(); addParserWarning("msg.jsdoc.consistidgen"); return eatUntilEOLIfNotAnnotation();
Node fieldTypeList = newNode(Token.LB); Node fieldType = parseFieldType(token); fieldTypeList.addChildToBack(fieldType); } else { addTypeWarning("msg.jsdoc.type.record.duplicate", name); skipEOLs(); if (!match(JsDocToken.COMMA)) { break; next(); skipEOLs(); if (match(JsDocToken.RIGHT_CURLY)) { token = next(); } while (true);
new JsDocInfoParser( new JsDocTokenStream(comment.substring(numOpeningChars), lineno, config, errorReporter); jsdocParser.setFileLevelJsDocBuilder(fileLevelJsDocBuilder); jsdocParser.setFileOverviewJSDocInfo(fileOverviewInfo); if (node.type == Comment.Type.IMPORTANT && node.value.length() > 0) { jsdocParser.parseImportantComment(); } else { jsdocParser.parse();
Set<String> modifies = new HashSet<>(); while (true) { if (match(JsDocToken.STRING)) { String name = stream.getString(); if (!modifiesAnnotationKeywords.contains(name) && !jsdocBuilder.hasParameter(name)) { addParserWarning("msg.jsdoc.modifies.unknown", name); token = next(); } else { addParserWarning("msg.jsdoc.modifies"); return token; if (match(JsDocToken.PIPE)) { token = next(); } else { break; if (!match(JsDocToken.RIGHT_CURLY)) { addParserWarning("msg.jsdoc.modifies"); } else { token = next(); if (!jsdocBuilder.recordModifies(modifies)) { addParserWarning("msg.jsdoc.modifies.duplicate");
/** * Parses a {@link JSDocInfo} object. This parsing method reads all tokens * returned by the {@link JsDocTokenStream#getJsDocToken()} method until the * {@link JsDocToken#EOC} is returned. * * @return {@code true} if JSDoc information was correctly parsed, * {@code false} otherwise */ boolean parse() { state = State.SEARCHING_ANNOTATION; skipEOLs(); JsDocToken token = next(); // Always record that we have a comment. if (jsdocBuilder.shouldParseDocumentation()) { ExtractionInfo blockInfo = extractBlockComment(token); token = blockInfo.token; if (!blockInfo.string.isEmpty()) { jsdocBuilder.recordBlockDescription(blockInfo.string); } } else { if (token != JsDocToken.ANNOTATION && token != JsDocToken.EOC) { // Mark that there was a description, but don't bother marking // what it was. jsdocBuilder.recordBlockDescription(""); } } return parseHelperLoop(token, new ArrayList<ExtendedTypeInfo>()); }
addParserWarning("msg.jsdoc.suppress"); return token; } else { Set<String> suppressions = new HashSet<>(); while (true) { if (match(JsDocToken.STRING)) { String name = stream.getString(); if (!suppressionNames.contains(name)) { addParserWarning("msg.jsdoc.suppress.unknown", name); token = next(); } else { addParserWarning("msg.jsdoc.suppress"); return token; if (match(JsDocToken.PIPE, JsDocToken.COMMA)) { token = next(); } else { break; if (!match(JsDocToken.RIGHT_CURLY)) { addParserWarning("msg.jsdoc.suppress"); } else { token = next(); jsdocBuilder.recordSuppressions(suppressions); return eatUntilEOLIfNotAnnotation();
private void checkExtendedTypes(List<ExtendedTypeInfo> extendedTypes) { for (ExtendedTypeInfo typeInfo : extendedTypes) { // If interface, record the multiple extended interfaces if (jsdocBuilder.isInterfaceRecorded()) { if (!jsdocBuilder.recordExtendedInterface(typeInfo.type)) { addParserWarning("msg.jsdoc.extends.duplicate", typeInfo.lineno, typeInfo.charno); } } else { if (!jsdocBuilder.recordBaseType(typeInfo.type)) { addTypeWarning("msg.jsdoc.incompat.type", typeInfo.lineno, typeInfo.charno); } } } }
/** * Parses inline type info. */ private JSDocInfo parseInlineTypeDoc(Comment node) { String comment = node.value; int lineno = lineno(node.location.start); int charno = charno(node.location.start); // The JsDocInfoParser expects the comment without the initial '/**'. int numOpeningChars = 3; JsDocInfoParser parser = new JsDocInfoParser( new JsDocTokenStream(comment.substring(numOpeningChars), lineno, charno + numOpeningChars), comment, node.location.start.offset, templateNode, config, errorReporter); return parser.parseInlineTypeDoc(); }
private Node reportTypeSyntaxWarning(String warning) { addTypeWarning(warning, stream.getLineno(), stream.getCharno()); return null; }
private void addParserWarning(String messageId) { addParserWarning(messageId, stream.getLineno(), stream.getCharno()); }
private JsDocToken eatUntilEOLIfNotAnnotation(JsDocToken token) { if (token == JsDocToken.ANNOTATION) { state = State.SEARCHING_ANNOTATION; return token; } return eatTokensUntilEOL(token); }
private static JsDocInfoParser getParser(String toParse) { Config config = new Config( new HashSet<String>(), new HashSet<String>(), false, LanguageMode.ECMASCRIPT3); JsDocInfoParser parser = new JsDocInfoParser( new JsDocTokenStream(toParse), toParse, 0, null, config, NullErrorReporter.forOldRhino()); return parser; }
Annotation annotation = annotationNames.get(annotationName); if (annotation == null || annotationName.isEmpty()) { addParserWarning("msg.bad.jsdoc.tag", annotationName); } else { case NG_INJECT: if (jsdocBuilder.isNgInjectRecorded()) { addParserWarning("msg.jsdoc.nginject.extra"); } else { jsdocBuilder.recordNgInject(true); return eatUntilEOLIfNotAnnotation(); addParserWarning("msg.jsdoc.jaggerInject.extra"); } else { jsdocBuilder.recordJaggerInject(true); return eatUntilEOLIfNotAnnotation(); addParserWarning("msg.jsdoc.jaggerModule.extra"); } else { jsdocBuilder.recordJaggerModule(true); return eatUntilEOLIfNotAnnotation(); addParserWarning("msg.jsdoc.jaggerProvide.extra"); } else { jsdocBuilder.recordJaggerProvide(true);
Node fieldTypeList = newNode(Token.LB); Node fieldType = parseFieldType(token); fieldTypeList.addChildToBack(fieldType); } else { addTypeWarning("msg.jsdoc.type.record.duplicate", name); skipEOLs(); if (!match(JsDocToken.COMMA)) { break; next(); skipEOLs(); if (match(JsDocToken.RIGHT_CURLY)) { token = next(); } while (true);