Skip to content

Commit 903e909

Browse files
ahornaceVladimir Kotal
authored andcommitted
Fix missing email addresses in go xref
fixes #3659
1 parent 7b938e4 commit 903e909

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

opengrok-indexer/src/main/jflex/analysis/golang/GolangXref.lex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ File = [a-zA-Z]{FNameChar}* "." ([Gg][Oo] | [Tt][Xx][Tt] | [Hh][Tt][Mm][Ll]? |
171171
}
172172
{FNameChar}+ "@" {FNameChar}+ "." {FNameChar}+ {
173173
chkLOC();
174+
onEmailAddressMatched(yytext(), yychar);
174175
}
175176
}
176177

opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/golang/GolangXrefTest.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,27 @@
3232
/**
3333
* Tests the {@link GolangXref} class.
3434
*/
35-
public class GolangXrefTest extends XrefTestBase {
35+
class GolangXrefTest extends XrefTestBase {
3636

3737
@Test
38-
public void sampleTest() throws IOException {
38+
void sampleTest() throws IOException {
3939
writeAndCompare(new GolangAnalyzerFactory(),
4040
"analysis/golang/sample.go",
4141
"analysis/golang/sample_xref.html",
4242
readTagsFromResource("analysis/golang/sampletags"), 101);
4343
}
4444

4545
@Test
46-
public void shouldCloseTruncatedStringSpan() throws IOException {
46+
void shouldCloseTruncatedStringSpan() throws IOException {
4747
writeAndCompare(new GolangAnalyzerFactory(),
4848
"analysis/golang/truncated.go",
4949
"analysis/golang/truncated_xref.html", null, 1);
5050
}
51+
52+
@Test
53+
void shouldContainEmail() throws IOException {
54+
writeAndCompare(new GolangAnalyzerFactory(),
55+
"analysis/golang/email.go",
56+
"analysis/golang/email_xref.html", null, 3);
57+
}
5158
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const (
2+
3+
)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>sampleFile - OpenGrok cross reference for /sampleFile</title></head><body>
6+
<a class="l" name="1" href="#1">1</a><b>const</b> (
7+
<a class="l" name="2" href="#2">2</a> <a href="/source/s?defs=email" class="intelliWindow-symbol" data-definition-place="undefined-in-file">email</a> = <span class="s">&quot;[email protected]&quot;</span>
8+
<a class="l" name="3" href="#3">3</a>)
9+
<a class="l" name="4" href="#4">4</a></body>
10+
</html>

0 commit comments

Comments
 (0)