noverify icon indicating copy to clipboard operation
noverify copied to clipboard

Store all definition positions instead of only 1

Open quasilyte opened this issue 4 years ago • 2 comments

If a symbol (function, class, etc) is defined more than once inside a project (or even a file), we could store a slice of positions instead of trying to choose one to keep and throwing away all other locations.

Proposed change: change the pos field to be a slice of positions. A position at positions[0] should probably map to a currently selected pos.

info := meta.Info.GetFunction(name)
if len(info.Positions) == 1 {
  // Function is globally unique
} else {
  // More than 1 definition found
}

quasilyte avatar Jun 04 '20 08:06 quasilyte

An alternative structure for indexing: https://gitlab.com/Serenata/Serenata/-/tree/master/src/Indexing/Structures

An ideia: Instead of keep a separated index for classes/traits/funcions..., rewrite the funcions getClass/getTrait... to search in all files and return an array

edgardmessias avatar Jun 08 '20 12:06 edgardmessias

It's totally possible to store all definitions instead of one. That's more precise than choosing one definition and only add new positions for it. In the long run, I guess it's more right thing to do.

If we'll track autoload/require paths in the future, it will be possible to infer which definition is being used. That would be pretty neat.

quasilyte avatar Jun 08 '20 13:06 quasilyte