Selaa lähdekoodia

Fix Shotness with Python

Vadim Markovtsev 8 vuotta sitten
vanhempi
commit
8e263bcafc
2 muutettua tiedostoa jossa 11 lisäystä ja 12 poistoa
  1. 10 11
      README.md
  2. 1 1
      shotness.go

+ 10 - 11
README.md

@@ -183,17 +183,16 @@ can be visualized with t-SNE implemented in TF Projector.
 #### Structural hotness
 #### Structural hotness
 
 
 ```
 ```
-      15  jinja2/environment.py:compile [FunctionDef]
-       9  jinja2/environment.py:parse [FunctionDef]
-       8  jinja2/runtime.py:call [FunctionDef]
-       8  jinja2/runtime.py:__init__ [FunctionDef]
-       8  jinja2/runtime.py:__call__ [FunctionDef]
-       7  jinja2/ext.py:parse [FunctionDef]
-       7  jinja2/runtime.py:length [FunctionDef]
-       7  jinja2/environment.py:get_template [FunctionDef]
-       7  jinja2/runtime.py:_fail_with_undefined_error [FunctionDef]
-       6  jinja2/optimizer.py:optimize [FunctionDef]
-
+      46  jinja2/compiler.py:visit_Template [FunctionDef]
+      42  jinja2/compiler.py:visit_For [FunctionDef]
+      34  jinja2/compiler.py:visit_Output [FunctionDef]
+      29  jinja2/environment.py:compile [FunctionDef]
+      27  jinja2/compiler.py:visit_Include [FunctionDef]
+      22  jinja2/compiler.py:visit_Macro [FunctionDef]
+      22  jinja2/compiler.py:visit_FromImport [FunctionDef]
+      21  jinja2/compiler.py:visit_Filter [FunctionDef]
+      21  jinja2/runtime.py:__call__ [FunctionDef]
+      20  jinja2/compiler.py:visit_Block [FunctionDef]
 ```
 ```
 
 
 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.

+ 1 - 1
shotness.go

@@ -226,7 +226,7 @@ func (shotness *ShotnessAnalysis) Consume(deps map[string]interface{}) (map[stri
 				}
 				}
 				startLine := node.StartPosition.Line
 				startLine := node.StartPosition.Line
 				endLine := node.StartPosition.Line
 				endLine := node.StartPosition.Line
-				if node.EndPosition != nil {
+				if node.EndPosition != nil && node.EndPosition.Line > node.StartPosition.Line {
 					endLine = node.EndPosition.Line
 					endLine = node.EndPosition.Line
 				} else {
 				} else {
 					// we need to determine node.EndPosition.Line
 					// we need to determine node.EndPosition.Line