3N/A/*
3N/A * CDDL HEADER START
3N/A *
3N/A * The contents of this file are subject to the terms of the
3N/A * Common Development and Distribution License (the "License").
3N/A * You may not use this file except in compliance with the License.
3N/A *
3N/A * See LICENSE.txt included in this distribution for the specific
3N/A * language governing permissions and limitations under the License.
3N/A *
3N/A * When distributing Covered Code, include this CDDL HEADER in each
3N/A * file and include the License file at LICENSE.txt.
3N/A * If applicable, add the following below this CDDL HEADER, with the
3N/A * fields enclosed by brackets "[]" replaced with your own identifying
3N/A * information: Portions Copyright [yyyy] [name of copyright owner]
3N/A *
3N/A * CDDL HEADER END
3N/A */
3N/A
3N/A/*
1058N/A * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
3N/A */
3N/A
3N/A/*
3N/A * Cross reference a Java file
3N/A */
3N/A
3N/Apackage org.opensolaris.opengrok.analysis.java;
850N/Aimport org.opensolaris.opengrok.analysis.JFlexXref;
850N/Aimport java.io.IOException;
850N/Aimport java.io.Writer;
850N/Aimport java.io.Reader;
3N/Aimport org.opensolaris.opengrok.web.Util;
3N/A
3N/A%%
3N/A%public
3N/A%class JavaXref
850N/A%extends JFlexXref
3N/A%unicode
3N/A%ignorecase
3N/A%int
3N/A%{
193N/A /* Must match WhiteSpace regex */
193N/A private final static String WHITE_SPACE = "[ \t\f\r]+";
193N/A
1020N/A // TODO move this into an include file when bug #16053 is fixed
1020N/A @Override
1020N/A protected int getLineNumber() { return yyline; }
1020N/A @Override
1020N/A protected void setLineNumber(int x) { yyline = x; }
3N/A%}
3N/A
193N/A/* Must match WHITE_SPACE constant */
936N/AWhiteSpace = [ \t\f]+
1020N/AEOL = \r|\n|\r\n
3N/AIdentifier = [a-zA-Z_] [a-zA-Z0-9_]+
3N/A
3N/AURIChar = [\?\+\%\&\:\/\.\@\_\;\=\$\,\-\!\~\*\\]
3N/AFNameChar = [a-zA-Z0-9_\-\.]
1070N/AFile = [a-zA-Z]{FNameChar}* "." ("java"|"properties"|"props"|"xml"|"conf"|"txt"|"htm"|"html"|"ini"|"jnlp"|"jad"|"diff"|"patch")
3N/APath = "/"? [a-zA-Z]{FNameChar}* ("/" [a-zA-Z]{FNameChar}*[a-zA-Z0-9])+
3N/A
1073N/ANumber = (0[xX][0-9a-fA-F]+|[0-9]+\.[0-9]+|[0-9]+)(([eE][+-]?[0-9]+)?[ufdlUFDL]*)?
3N/A
199N/AJavadocWithClassArg = "@throws" | "@exception"
199N/AJavadocWithParamNameArg = "@param"
199N/A
199N/AClassName = ({Identifier} ".")* {Identifier}
199N/AParamName = {Identifier} | "<" {Identifier} ">"
193N/A
193N/A%state STRING COMMENT SCOMMENT QSTRING JAVADOC
3N/A
3N/A%%
3N/A<YYINITIAL>{
943N/A
943N/A{Identifier} {
943N/A String id = yytext();
1469N/A writeSymbol(id, Consts.kwd, yyline, false);
943N/A}
3N/A
1013N/A"<" ({File}|{Path}) ">" {
1013N/A out.write("&lt;");
1013N/A String path = yytext();
1013N/A path = path.substring(1, path.length() - 1);
974N/A out.write("<a href=\""+urlPrefix+"path=");
1013N/A out.write(path);
271N/A appendProject();
271N/A out.write("\">");
1013N/A out.write(path);
271N/A out.write("</a>");
1013N/A out.write("&gt;");
1013N/A}
3N/A
974N/A/*{Hier}
974N/A { out.write(Util.breadcrumbPath(urlPrefix+"defs=",yytext(),'.'));}
3N/A*/
1013N/A{Number} { out.write("<span class=\"n\">"); out.write(yytext()); out.write("</span>"); }
3N/A
1370N/A \" { yybegin(STRING);out.write("<span class=\"s\">\""); spans.push("s"); }
1370N/A \' { yybegin(QSTRING);out.write("<span class=\"s\">\'"); spans.push("s"); }
1370N/A "/**" / [^/] { yybegin(JAVADOC);out.write("<span class=\"c\">/**"); spans.push("c"); }
1370N/A "/*" { yybegin(COMMENT);out.write("<span class=\"c\">/*"); spans.push("c"); }
1370N/A "//" { yybegin(SCOMMENT);out.write("<span class=\"c\">//"); spans.push("c"); }
3N/A}
3N/A
3N/A<STRING> {
1013N/A \" {WhiteSpace} \" { out.write(yytext());}
1370N/A \" { yybegin(YYINITIAL); out.write("\"</span>"); spans.pop(); }
974N/A \\\\ { out.write("\\\\"); }
974N/A \\\" { out.write("\\\""); }
3N/A}
3N/A
3N/A<QSTRING> {
3N/A "\\\\" { out.write("\\\\"); }
1028N/A "\\\'" { out.write("\\\'"); }
1013N/A \' {WhiteSpace} \' { out.write(yytext()); }
1370N/A \' { yybegin(YYINITIAL); out.write("'</span>"); spans.pop(); }
3N/A}
3N/A
193N/A<COMMENT, JAVADOC> {
1370N/A"*/" { yybegin(YYINITIAL); out.write("*/</span>"); spans.pop(); }
3N/A}
3N/A
193N/A<JAVADOC> {
199N/A {JavadocWithParamNameArg} {WhiteSpace} {ParamName} |
199N/A {JavadocWithClassArg} {WhiteSpace} {ClassName} {
193N/A String text = yytext();
193N/A String[] tokens = text.split(WHITE_SPACE, 2);
193N/A out.append("<strong>").append(tokens[0]).append("</strong>")
193N/A .append(text.substring(tokens[0].length(),
193N/A text.length() - tokens[1].length()))
193N/A .append("<em>").append(tokens[1]).append("</em>");
193N/A }
193N/A "@" {Identifier} {
193N/A out.append("<strong>").append(yytext()).append("</strong>");
193N/A }
193N/A}
193N/A
3N/A<SCOMMENT> {
936N/A {WhiteSpace}*{EOL} {
1370N/A yybegin(YYINITIAL); out.write("</span>"); spans.pop();
1020N/A startNewLine();
89N/A }
3N/A}
3N/A
3N/A
193N/A<YYINITIAL, STRING, COMMENT, SCOMMENT, QSTRING, JAVADOC> {
974N/A"&" {out.write( "&amp;");}
974N/A"<" {out.write( "&lt;");}
974N/A">" {out.write( "&gt;");}
1020N/A{WhiteSpace}*{EOL} { startNewLine(); }
1013N/A {WhiteSpace} { out.write(yytext()); }
974N/A [!-~] { out.write(yycharat(0)); }
974N/A . { writeUnicodeChar(yycharat(0)); }
3N/A}
3N/A
193N/A<STRING, COMMENT, SCOMMENT, STRING, QSTRING, JAVADOC> {
3N/A{Path}
974N/A { out.write(Util.breadcrumbPath(urlPrefix+"path=",yytext(),'/'));}
3N/A
3N/A{File}
974N/A {
1013N/A String path = yytext();
974N/A out.write("<a href=\""+urlPrefix+"path=");
1013N/A out.write(path);
271N/A appendProject();
271N/A out.write("\">");
1013N/A out.write(path);
271N/A out.write("</a>");}
3N/A
3N/A("http" | "https" | "ftp" ) "://" ({FNameChar}|{URIChar})+[a-zA-Z0-9/]
974N/A {
1013N/A String url = yytext();
974N/A out.write("<a href=\"");
1472N/A out.write(Util.uriEncodeURL(url));out.write("\">");
1469N/A out.write(Util.htmlize(url));out.write("</a>");}
3N/A
3N/A{FNameChar}+ "@" {FNameChar}+ "." {FNameChar}+
974N/A {
1122N/A writeEMailAddress(yytext());
974N/A }
3N/A}