浏览代码

Merge pull request #202 from vmarkovtsev/master

Update the docs about semantic UAST
Vadim Markovtsev 6 年之前
父节点
当前提交
8cb7d29b80
共有 2 个文件被更改,包括 18 次插入15 次删除
  1. 2 2
      README.md
  2. 16 13
      leaves/shotness.go

+ 2 - 2
README.md

@@ -252,8 +252,8 @@ can be visualized with t-SNE implemented in TF Projector.
 ```
 ```
 
 
 Thanks to Babelfish, hercules is able to measure how many times each structural unit has been modified.
 Thanks to Babelfish, hercules is able to measure how many times each structural unit has been modified.
-By default, it looks at functions; refer to [UAST XPath](https://doc.bblf.sh/using-babelfish/uast-querying.html)
-manual to set an other query.
+By default, it looks at functions; refer to [Semantic UAST XPath](https://docs.sourced.tech/babelfish/using-babelfish/uast-querying)
+manual to switch to something else.
 
 
 ```
 ```
 hercules --shotness [--shotness-xpath-*]
 hercules --shotness [--shotness-xpath-*]

+ 16 - 13
leaves/shotness.go

@@ -36,10 +36,11 @@ type ShotnessAnalysis struct {
 const (
 const (
 	// ConfigShotnessXpathStruct is the name of the configuration option (ShotnessAnalysis.Configure())
 	// ConfigShotnessXpathStruct is the name of the configuration option (ShotnessAnalysis.Configure())
 	// which sets the UAST XPath to choose the analysed nodes.
 	// which sets the UAST XPath to choose the analysed nodes.
+	// The format is Semantic UASTv2, see https://docs.sourced.tech/babelfish/using-babelfish/uast-querying
 	ConfigShotnessXpathStruct = "Shotness.XpathStruct"
 	ConfigShotnessXpathStruct = "Shotness.XpathStruct"
 	// ConfigShotnessXpathName is the name of the configuration option (ShotnessAnalysis.Configure())
 	// ConfigShotnessXpathName is the name of the configuration option (ShotnessAnalysis.Configure())
 	// which sets the UAST XPath to find the name of the nodes chosen by ConfigShotnessXpathStruct.
 	// which sets the UAST XPath to find the name of the nodes chosen by ConfigShotnessXpathStruct.
-	// These XPath-s can be different for some languages.
+	// The format is Semantic UASTv2, see https://docs.sourced.tech/babelfish/using-babelfish/uast-querying
 	ConfigShotnessXpathName = "Shotness.XpathName"
 	ConfigShotnessXpathName = "Shotness.XpathName"
 
 
 	// DefaultShotnessXpathStruct is the default UAST XPath to choose the analysed nodes.
 	// DefaultShotnessXpathStruct is the default UAST XPath to choose the analysed nodes.
@@ -47,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 | /name"
+	DefaultShotnessXpathName = "//uast:Function/../../Name"
 )
 )
 
 
 type nodeShotness struct {
 type nodeShotness struct {
@@ -103,16 +104,18 @@ func (shotness *ShotnessAnalysis) Features() []string {
 // ListConfigurationOptions returns the list of changeable public properties of this PipelineItem.
 // ListConfigurationOptions returns the list of changeable public properties of this PipelineItem.
 func (shotness *ShotnessAnalysis) ListConfigurationOptions() []core.ConfigurationOption {
 func (shotness *ShotnessAnalysis) ListConfigurationOptions() []core.ConfigurationOption {
 	opts := [...]core.ConfigurationOption{{
 	opts := [...]core.ConfigurationOption{{
-		Name:        ConfigShotnessXpathStruct,
-		Description: "UAST XPath query to use for filtering the nodes.",
-		Flag:        "shotness-xpath-struct",
-		Type:        core.StringConfigurationOption,
-		Default:     DefaultShotnessXpathStruct}, {
-		Name:        ConfigShotnessXpathName,
-		Description: "UAST XPath query to determine the names of the filtered nodes.",
-		Flag:        "shotness-xpath-name",
-		Type:        core.StringConfigurationOption,
-		Default:     DefaultShotnessXpathName},
+		Name: ConfigShotnessXpathStruct,
+		Description: "Semantic UAST XPath query to use for filtering the nodes. " +
+			"Refer to https://docs.sourced.tech/babelfish/using-babelfish/uast-querying",
+		Flag:    "shotness-xpath-struct",
+		Type:    core.StringConfigurationOption,
+		Default: DefaultShotnessXpathStruct}, {
+		Name: ConfigShotnessXpathName,
+		Description: "Semantic UAST XPath query to determine the names of the filtered nodes. " +
+			"Refer to https://docs.sourced.tech/babelfish/using-babelfish/uast-querying",
+		Flag:    "shotness-xpath-name",
+		Type:    core.StringConfigurationOption,
+		Default: DefaultShotnessXpathName},
 	}
 	}
 	return opts[:]
 	return opts[:]
 }
 }
@@ -124,7 +127,7 @@ func (shotness *ShotnessAnalysis) Flag() string {
 
 
 // Description returns the text which explains what the analysis is doing.
 // Description returns the text which explains what the analysis is doing.
 func (shotness *ShotnessAnalysis) Description() string {
 func (shotness *ShotnessAnalysis) Description() string {
-	return "Structural hotness - the granular alternative to --couples. " +
+	return "Structural hotness - a fine-grained alternative to --couples. " +
 		"Given an XPath over UASTs - selecting functions by default - we build the square " +
 		"Given an XPath over UASTs - selecting functions by default - we build the square " +
 		"co-occurrence matrix. The value in each cell equals to the number of times the pair " +
 		"co-occurrence matrix. The value in each cell equals to the number of times the pair " +
 		"of selected UAST units appeared in the same commit."
 		"of selected UAST units appeared in the same commit."