Browse Source

fix regex for shortening java names (#444)

Margaret Nolan 6 years ago
parent
commit
1647c5607f
2 changed files with 9 additions and 1 deletions
  1. 1
    1
      internal/graph/graph.go
  2. 8
    0
      internal/graph/graph_test.go

+ 1
- 1
internal/graph/graph.go View File

28
 )
28
 )
29
 
29
 
30
 var (
30
 var (
31
-	javaRegExp = regexp.MustCompile(`^(?:[a-z]\w*\.)*([A-Z][\w\$]*\.(?:<init>|[a-z]\w*(?:\$\d+)?))(?:(?:\()|$)`)
31
+	javaRegExp = regexp.MustCompile(`^(?:[a-z]\w*\.)*([A-Z][\w\$]*\.(?:<init>|[a-z][\w\$]*(?:\$\d+)?))(?:(?:\()|$)`)
32
 	goRegExp   = regexp.MustCompile(`^(?:[\w\-\.]+\/)+(.+)`)
32
 	goRegExp   = regexp.MustCompile(`^(?:[\w\-\.]+\/)+(.+)`)
33
 	cppRegExp  = regexp.MustCompile(`^(?:(?:\(anonymous namespace\)::)(\w+$))|(?:(?:\(anonymous namespace\)::)?(?:[_a-zA-Z]\w*\::|)*(_*[A-Z]\w*::~?[_a-zA-Z]\w*)$)`)
33
 	cppRegExp  = regexp.MustCompile(`^(?:(?:\(anonymous namespace\)::)(\w+$))|(?:(?:\(anonymous namespace\)::)?(?:[_a-zA-Z]\w*\::|)*(_*[A-Z]\w*::~?[_a-zA-Z]\w*)$)`)
34
 )
34
 )

+ 8
- 0
internal/graph/graph_test.go View File

475
 			"foo",
475
 			"foo",
476
 			"foo",
476
 			"foo",
477
 		},
477
 		},
478
+		{
479
+			"com.google.perftools.gwp.benchmark.FloatBench.lambda$run$0",
480
+			"FloatBench.lambda$run$0",
481
+		},
482
+		{
483
+			"java.bar.foo.FooBar.run$0",
484
+			"FooBar.run$0",
485
+		},
478
 	}
486
 	}
479
 	for _, tc := range testcases {
487
 	for _, tc := range testcases {
480
 		name := ShortenFunctionName(tc.name)
488
 		name := ShortenFunctionName(tc.name)