Browse Source

Merge pull request #207 from vmarkovtsev/master

Adjust the name XPath in Shotness
Vadim Markovtsev 6 years ago
parent
commit
5f1d4e37fd
2 changed files with 2 additions and 3 deletions
  1. 0 1
      Gopkg.lock
  2. 2 2
      leaves/shotness.go

+ 0 - 1
Gopkg.lock

@@ -639,7 +639,6 @@
     "gopkg.in/bblfsh/sdk.v2/uast/nodes",
     "gopkg.in/bblfsh/sdk.v2/uast/nodes",
     "gopkg.in/bblfsh/sdk.v2/uast/nodes/nodesproto",
     "gopkg.in/bblfsh/sdk.v2/uast/nodes/nodesproto",
     "gopkg.in/bblfsh/sdk.v2/uast/query",
     "gopkg.in/bblfsh/sdk.v2/uast/query",
-    "gopkg.in/bblfsh/sdk.v2/uast/role",
     "gopkg.in/cheggaaa/pb.v1",
     "gopkg.in/cheggaaa/pb.v1",
     "gopkg.in/src-d/enry.v1",
     "gopkg.in/src-d/enry.v1",
     "gopkg.in/src-d/go-billy-siva.v4",
     "gopkg.in/src-d/go-billy-siva.v4",

+ 2 - 2
leaves/shotness.go

@@ -48,7 +48,7 @@ const (
 	DefaultShotnessXpathStruct = "//uast:FunctionGroup"
 	DefaultShotnessXpathStruct = "//uast:FunctionGroup"
 	// DefaultShotnessXpathName is the default UAST XPath to choose the names of the analysed nodes.
 	// DefaultShotnessXpathName is the default UAST XPath to choose the names of the analysed nodes.
 	// It looks at the current tree level and at the immediate children.
 	// It looks at the current tree level and at the immediate children.
-	DefaultShotnessXpathName = "//uast:Function/../../Name"
+	DefaultShotnessXpathName = "/Nodes/uast:Alias/Name"
 )
 )
 
 
 type nodeShotness struct {
 type nodeShotness struct {
@@ -468,7 +468,7 @@ func (shotness *ShotnessAnalysis) extractNodes(root uast_nodes.Node) (map[string
 		if internal[uast_nodes.UniqueKey(node)] {
 		if internal[uast_nodes.UniqueKey(node)] {
 			continue
 			continue
 		}
 		}
-		nodeName, err := tools.FilterNode(node, shotness.XpathName)
+		nodeName, err := tools.FilterNode(node, "/*"+shotness.XpathName)
 		if err != nil {
 		if err != nil {
 			return nil, err
 			return nil, err
 		}
 		}