Skip to content

Commit 7f5b779

Browse files
committed
Fix dangling VB span by subclassing JFlexXrefSimple
Also: - Fix to recognize proper VB escaping of quotation-marks. - Fix to close and reopen spans for line-spanning strings. - Escape all HTML special characters in VBXref. - Use Common.xref in VBSymbolTokenizer.
1 parent afac64c commit 7f5b779

File tree

6 files changed

+247
-220
lines changed

6 files changed

+247
-220
lines changed

src/org/opensolaris/opengrok/analysis/vb/VBSymbolTokenizer.lex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,12 @@
2323
*/
2424

2525
/*
26-
* Gets Java symbols - ignores comments, strings, keywords
26+
* Gets VB symbols - ignores comments, strings, keywords
2727
*/
2828

2929
package org.opensolaris.opengrok.analysis.vb;
30-
import java.io.IOException;
31-
import java.io.Reader;
32-
import org.opensolaris.opengrok.analysis.JFlexTokenizer;
3330

31+
import org.opensolaris.opengrok.analysis.JFlexTokenizer;
3432
%%
3533
%public
3634
%class VBSymbolTokenizer
@@ -46,6 +44,7 @@ super(in);
4644

4745
%state STRING COMMENT
4846

47+
%include Common.lexh
4948
%include VB.lexh
5049
%%
5150

@@ -64,12 +63,13 @@ super(in);
6463
}
6564

6665
<STRING> {
66+
\"\" {}
6767
\" { yybegin(YYINITIAL); }
68-
\\\\ | \\\" {}
6968
}
7069

7170
<COMMENT> {
72-
\n { yybegin(YYINITIAL);}
71+
{WhiteSpace} {}
72+
{EOL} { yybegin(YYINITIAL);}
7373
}
7474

7575
<YYINITIAL, STRING, COMMENT> {

src/org/opensolaris/opengrok/analysis/vb/VBXref.lex

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,18 @@
2323
*/
2424

2525
/*
26-
* Cross reference a Java file
26+
* Cross reference a VB file
2727
*/
2828

2929
package org.opensolaris.opengrok.analysis.vb;
30-
import org.opensolaris.opengrok.analysis.JFlexXref;
31-
import java.io.IOException;
32-
import java.io.Writer;
33-
import java.io.Reader;
34-
import org.opensolaris.opengrok.web.Util;
3530

31+
import org.opensolaris.opengrok.analysis.JFlexXrefSimple;
32+
import org.opensolaris.opengrok.web.HtmlConsts;
33+
import org.opensolaris.opengrok.web.Util;
3634
%%
3735
%public
3836
%class VBXref
39-
%extends JFlexXref
37+
%extends JFlexXrefSimple
4038
%unicode
4139
%ignorecase
4240
%int
@@ -85,32 +83,46 @@ File = [a-zA-Z]{FNameChar}* "." ("vb"|"cls"|"frm"|"vbs"|"bas"|"ctl")
8583
/*{Hier}
8684
{ out.write(Util.breadcrumbPath(urlPrefix+"defs=",yytext(),'.'));}
8785
*/
88-
{Number} { out.write("<span class=\"n\">"); out.write(yytext()); out.write("</span>"); }
89-
90-
\" { yybegin(STRING);out.write("<span class=\"s\">\"");}
91-
\' { yybegin(COMMENT);out.write("<span class=\"c\">\'");}
86+
{Number} {
87+
disjointSpan(HtmlConsts.NUMBER_CLASS);
88+
out.write(yytext());
89+
disjointSpan(null);
90+
}
91+
92+
\" {
93+
pushSpan(STRING, HtmlConsts.STRING_CLASS);
94+
out.write(htmlize(yytext()));
95+
}
96+
\' {
97+
pushSpan(COMMENT, HtmlConsts.COMMENT_CLASS);
98+
out.write(htmlize(yytext()));
99+
}
92100
}
93101

94102
<STRING> {
95-
\" {WhiteSpace} \" { out.write(yytext());}
96-
\" { yybegin(YYINITIAL); out.write("\"</span>"); }
97-
\\\\ { out.write("\\\\"); }
98-
\\\" { yybegin(YYINITIAL); out.write("\\\"</span>"); }
99-
103+
\"\" |
104+
\" {WhiteSpace} \" { out.write(htmlize(yytext())); }
105+
\" {
106+
out.write(htmlize(yytext()));
107+
yypop();
108+
}
109+
{WhspChar}*{EOL} {
110+
disjointSpan(null);
111+
startNewLine();
112+
disjointSpan(HtmlConsts.STRING_CLASS);
113+
}
100114
}
101115

102116
<COMMENT> {
103117
{WhspChar}*{EOL} {
104-
yybegin(YYINITIAL); out.write("</span>");
118+
yypop();
105119
startNewLine();
106120
}
107121
}
108122

109123

110124
<YYINITIAL, STRING, COMMENT> {
111-
"&" {out.write( "&amp;");}
112-
"<" {out.write( "&lt;");}
113-
">" {out.write( "&gt;");}
125+
[&<>\'\"] { out.write(htmlize(yytext())); }
114126
{WhspChar}*{EOL} { startNewLine(); }
115127
{WhiteSpace} { out.write(yytext()); }
116128
[!-~] { out.write(yycharat(0)); }

test/org/opensolaris/opengrok/analysis/vb/sample.cls

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,3 +429,9 @@ Private Sub Class_Initialize()
429429
Set Headers = New Collection
430430
Set Cookies = New Collection
431431
End Sub
432+
433+
Private Sub Test_strings()
434+
Dim foo1() As String
435+
Set foo1 = " testing
436+
1-2-3"
437+
End Sub

0 commit comments

Comments
 (0)