CANVE / extractor

Extracts and normalizes the type relationships and call graph of scala sbt projects.
4 stars 1 forks source link

Adapt to 2.11 compiler providing .pos.source but no .sourceFile #8

Open matanox opened 8 years ago

matanox commented 8 years ago

For a given global.Symbol, .sourceFile may return null, whereas pos.source (when the latter is defined) returns a value. Quite certainly a small compiler quirk. Right now the code only looks at .sourceFile. Observed for https://github.com/allenai/pipeline.

So in those cases (seems to be rare) where only pos.source has the path, then we likely miss out on correlating a symbol to a given source and location. Worst, as it currently stands we also deduce whether a symbol is external v.s. project-defined by this value.

So we should likely grab .pos.source if it has something, when .sourceFile does not - everywhere that the latter is currently being used. Which means wrap this all as our own getSourcePath(global.Symbol): Option[String] method somewhere.

matanox commented 8 years ago

Note that for debug, .pos itself is not always defined, so .pos.source shouldn't be attempted except when .pos is defined. So precede if (symbol.pos.toString == "NoPosition") to it.