@@ -423,7 +423,7 @@ class SemanticdbConsumer(sourceFile: java.nio.file.Path) extends TastyConsumer {
423
423
symbolToSymbolString(symbol)
424
424
}
425
425
426
- println(symbol_path)
426
+ println(symbol_path + " : " + range )
427
427
// We want to add symbols coming from our file
428
428
// if (symbol.pos.sourceFile != sourceFile) return
429
429
if (symbol_path == " " || symbol.isUselessOccurrence) return
@@ -533,10 +533,26 @@ class SemanticdbConsumer(sourceFile: java.nio.file.Path) extends TastyConsumer {
533
533
val len =
534
534
if (name == " <init>" ) 0
535
535
else name.length
536
- return s.Range (range.endLine,
537
- range.endColumn - len,
538
- range.endLine,
539
- range.endColumn)
536
+ /* The position of a select is the position of the whole select expression,
537
+ from the start to the end.
538
+ To get the position of only the selected operand, we distinguish two cases:
539
+ - either we are selecting an operator ending with a ':' (for those the execution
540
+ order is reversed), so the selected expression is at the start.
541
+ Ex: A #:: B -> the position of the select is the range "#:: B", so we pick the range "#::"
542
+ - either the select is in normal order, in this case we select the end of it.
543
+ Ex: A + B -> the position of the select is the range "A +", so we pick the range "+"
544
+ */
545
+ if (name.endsWith(" :" )) {
546
+ return s.Range (range.startLine,
547
+ range.startColumn,
548
+ range.startLine,
549
+ range.startColumn + len)
550
+ } else {
551
+ return s.Range (range.endLine,
552
+ range.endColumn - len,
553
+ range.endLine,
554
+ range.endColumn)
555
+ }
540
556
}
541
557
542
558
def getImportPath (path_term : Term ): String = {
@@ -831,7 +847,6 @@ class SemanticdbConsumer(sourceFile: java.nio.file.Path) extends TastyConsumer {
831
847
}
832
848
833
849
case Term .Select (qualifier, _) => {
834
- println(" SELECT => " + tree)
835
850
val range = {
836
851
val r = rangeSelect(tree.symbol.trueName, tree.pos)
837
852
if (tree.symbol.trueName == " <init>" )
@@ -841,6 +856,7 @@ class SemanticdbConsumer(sourceFile: java.nio.file.Path) extends TastyConsumer {
841
856
r.endCharacter + 1 )
842
857
else r
843
858
}
859
+ println(" SELECT => " + tree + tree.pos.start + " :" + tree.pos.end)
844
860
addOccurenceTree(tree, s.SymbolOccurrence .Role .REFERENCE , range, forceAddBecauseParents)
845
861
super .traverseTree(tree)
846
862
}
0 commit comments