瀏覽代碼

fix how template function names are simplified (#499)

Maggie Nolan 5 年之前
父節點
當前提交
27840fff0d
共有 2 個檔案被更改,包括 14 行新增5 行删除
  1. 12
    3
      internal/graph/graph.go
  2. 2
    2
      internal/graph/graph_test.go

+ 12
- 3
internal/graph/graph.go 查看文件

28
 )
28
 )
29
 
29
 
30
 var (
30
 var (
31
-	javaRegExp               = regexp.MustCompile(`^(?:[a-z]\w*\.)*([A-Z][\w\$]*\.(?:<init>|[a-z][\w\$]*(?:\$\d+)?))(?:(?:\()|$)`)
32
-	goRegExp                 = regexp.MustCompile(`^(?:[\w\-\.]+\/)+(.+)`)
33
-	cppRegExp                = regexp.MustCompile(`^(?:[_a-zA-Z]\w*::)+(_*[A-Z]\w*::~?[_a-zA-Z]\w*)`)
31
+	// Removes package name and method arugments for Java method names.
32
+	// See tests for examples.
33
+	javaRegExp = regexp.MustCompile(`^(?:[a-z]\w*\.)*([A-Z][\w\$]*\.(?:<init>|[a-z][\w\$]*(?:\$\d+)?))(?:(?:\()|$)`)
34
+	// Removes package name and method arugments for Go function names.
35
+	// See tests for examples.
36
+	goRegExp = regexp.MustCompile(`^(?:[\w\-\.]+\/)+(.+)`)
37
+	// Strips C++ namespace prefix from a C++ function / method name.
38
+	// NOTE: Make sure to keep the template parameters in the name. Normally,
39
+	// template parameters are stripped from the C++ names but when
40
+	// -symbolize=demangle=templates flag is used, they will not be.
41
+	// See tests for examples.
42
+	cppRegExp                = regexp.MustCompile(`^(?:[_a-zA-Z]\w*::)+(_*[A-Z]\w*::~?[_a-zA-Z]\w*(?:<.*>)?)`)
34
 	cppAnonymousPrefixRegExp = regexp.MustCompile(`^\(anonymous namespace\)::`)
43
 	cppAnonymousPrefixRegExp = regexp.MustCompile(`^\(anonymous namespace\)::`)
35
 )
44
 )
36
 
45
 

+ 2
- 2
internal/graph/graph_test.go 查看文件

476
 			"Foo::bar",
476
 			"Foo::bar",
477
 		},
477
 		},
478
 		{
478
 		{
479
-			"Foo::bar::baz<float, long, int>::operator()",
480
-			"Foo::bar::baz<float, long, int>::operator()",
479
+			"cpp::namespace::Class::method<float, long, int>()",
480
+			"Class::method<float, long, int>",
481
 		},
481
 		},
482
 		{
482
 		{
483
 			"foo",
483
 			"foo",