@@ -423,7 +423,7 @@ class SemanticdbConsumer(sourceFile: java.nio.file.Path) extends TastyConsumer {
423423 symbolToSymbolString(symbol)
424424 }
425425
426- println(symbol_path)
426+ println(symbol_path + " : " + range )
427427 // We want to add symbols coming from our file
428428 // if (symbol.pos.sourceFile != sourceFile) return
429429 if (symbol_path == " " || symbol.isUselessOccurrence) return
@@ -533,10 +533,26 @@ class SemanticdbConsumer(sourceFile: java.nio.file.Path) extends TastyConsumer {
533533 val len =
534534 if (name == " <init>" ) 0
535535 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+ }
540556 }
541557
542558 def getImportPath (path_term : Term ): String = {
@@ -831,7 +847,6 @@ class SemanticdbConsumer(sourceFile: java.nio.file.Path) extends TastyConsumer {
831847 }
832848
833849 case Term .Select (qualifier, _) => {
834- println(" SELECT => " + tree)
835850 val range = {
836851 val r = rangeSelect(tree.symbol.trueName, tree.pos)
837852 if (tree.symbol.trueName == " <init>" )
@@ -841,6 +856,7 @@ class SemanticdbConsumer(sourceFile: java.nio.file.Path) extends TastyConsumer {
841856 r.endCharacter + 1 )
842857 else r
843858 }
859+ println(" SELECT => " + tree + tree.pos.start + " :" + tree.pos.end)
844860 addOccurenceTree(tree, s.SymbolOccurrence .Role .REFERENCE , range, forceAddBecauseParents)
845861 super .traverseTree(tree)
846862 }
0 commit comments