JFlexXref.java revision 1370
69N/A * CDDL HEADER START 69N/A * The contents of this file are subject to the terms of the 69N/A * Common Development and Distribution License (the "License"). 69N/A * You may not use this file except in compliance with the License. 69N/A * language governing permissions and limitations under the License. 69N/A * When distributing Covered Code, include this CDDL HEADER in each 69N/A * If applicable, add the following below this CDDL HEADER, with the 69N/A * fields enclosed by brackets "[]" replaced with your own identifying 69N/A * information: Portions Copyright [yyyy] [name of copyright owner] 69N/A * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. 69N/A * Portions Copyright 2011, 2012 Jens Elkner. 69N/A * Base class for Xref lexers. 69N/A * @author Lubos Kosco 69N/A * A stack of <span ...> CSS class names currently opened. 69N/A * It is used to close all open spans for a line and re-open them at the 69N/A * start of the next line to produce wellformed XML. So if a 69N/A * <span ...> is opened and do not closed on the same line, the class 69N/A * name used needs to be pushed onto this stack. If the <span ...> 69N/A * gets closed on a different line, it needs to be popped from this stack. 69N/A * If properly done, the stack should be empty when the last line has been 228N/A * Create a new empty instance with the default capacity. 228N/A * The preferred method to add a new span class name to this instance. 228N/A * @param s class name to add. 228N/A * @throws IllegalArgumentException if the given argument is {@code null}. 69N/A * The preferred method to remove the last element from this stack. 69N/A * @return {@code null} if the stack is empty, the removed element 69N/A * @see #push(String) 69N/A /** the {@link SpanStack} for this and only this instance */ 69N/A /** EOF value returned by yylex(). */ 69N/A /** See {@link RuntimeEnvironment#getUserPage()}. Per default initialized 115N/A * in the constructor and here to be consistent and avoid lot of 115N/A * @see #startNewLine() */ 69N/A /** See {@link RuntimeEnvironment#getUserPageSuffix()}. Per default 69N/A * initialized in the constructor and here to be consistent and avoid lot of 69N/A * unnecessary lookups. 69N/A * @see #startNewLine() */ 69N/A * Description of the style to use for a type of definitions. 69N/A /** Name of the style definition as given by CTags. */ 69N/A /** Class name used by the style sheets when rendering the xref. */ 69N/A * The title of the section to which this type belongs, or {@code null} 69N/A * if this type should not be listed in the navigation panel. 69N/A /** Construct a style description. */ 69N/A * Description of styles to use for different types of definitions. new Style(
"class",
"xc",
"Class"),
new Style(
"package",
"xp",
"Package"),
new Style(
"interface",
"xi",
"Interface"),
new Style(
"namespace",
"xn",
"Namespace"),
new Style(
"enum",
"xe",
"Enum"),
new Style(
"struct",
"xs",
"Struct"),
new Style(
"typedef",
"xt",
"Typedef"),
new Style(
"function",
"xf",
"Function"),
new Style(
"method",
"xmt",
"Method"),
new Style(
"subroutine",
"xsr",
"Subroutine"),
* Create a new lexer instance. Initializes {@link #userPageLink}, * {@link #userPageSuffix} using the runtime environment and creates a new * empty {@link SpanStack}. * @see RuntimeEnvironment#getUserPage() * @see RuntimeEnvironment#getUserPageSuffix() // TODO when bug #16053 is fixed, we should add a getter to a file // that's included from all the Xref classes so that we avoid the // The auto-generated constructors for the Xref classes don't // expect a checked exception, so wrap it in an AssertionError. // This should never happen, since all the Xref classes will get // a public static YYEOF field from JFlex. throw ae;
// NOPMD (stack trace is preserved by initCause(), but * Reinitialize the xref with new contents. * @param contents a char buffer with text to analyze * @param length the number of characters to use from the char buffer /** Get the next token from the scanner. */ /** Reset the scanner. */ /** Get the value of {@code yyline}. */ /** Set the value of {@code yyline}. */ * Write xref to the specified {@code Writer}. * @param out xref destination * @throws IOException on error when writing the xref while (
yylex() !=
yyeof) {
// NOPMD while statement intentionally empty // nothing to do here, yylex() will do the work logger.
info(
"The SpanStack named spans is not empty! May be " +
"the Xref lexer is not perfect yet!");
* Write a JavaScript function that returns an array with the definitions * to list in the navigation panel. Each element of the array is itself an * array containing the name of the definition type, the CSS class name for * the type, and an array of (symbol, line) pairs for the definitions of // No definitions, no symbol table to write // We want the symbol table to be sorted // Order by symbol name, and then by line number if multiple // definitions use the same symbol name /* no LF intentionally - xml is whitespace aware ... */ * Get the style description for a definition type. * @param type the definition type * @return the style of a definition type, or {@code null} if no style is * @see #DEFINITION_STYLES * Write out annotation infos for the given line. * @param num linenumber to print * @throws IOException depends on the destination (<var>out</var>). * Terminate the current line and insert preamble for the next line. The * line count will be incremented. * @throws IOException on error when writing the xref * Write a symbol and generate links as appropriate. * @param symbol the symbol to write * @param keywords a set of keywords recognized by this analyzer (no links * will be generated if the symbol is a keyword) * @param line the line number on which the symbol appears * @throws IOException if an error occurs while writing to the stream // This is a keyword, so we don't create a link. // This is the definition of the symbol. // 1) Create an anchor for direct links. (Perhaps we should only // do this when there's exactly one definition of the symbol in // this file? Otherwise, we may end up with multiple anchors with // 2) Create a link that searches for all references to this symbol. // This is a reference to a symbol defined exactly once in this file. // Generate a direct link to the symbol definition. // This is a symbol that is not defined in this file, or a symbol // that is defined more than once in this file. In either case, we // can't generate a direct link to the definition, so generate a // link to search for all definitions of that symbol instead. * Write HTML escape sequence for the specified Unicode character, unless * it's an ISO control character, in which case it is ignored. * @param c the character to write * @throws IOException if an error occurs while writing to the stream * Write an e-mail address. The address will be obfuscated if * {@link RuntimeEnvironment#isObfuscatingEMailAddresses()} returns * @param address the address to write * @throws IOException if an error occurs while writing to the stream