-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Keep package structure in rootTreeOrProvider
#5276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keep package structure in rootTreeOrProvider
#5276
Conversation
test performance please |
performance test scheduled: 1 job(s) in queue, 0 running. |
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/5276/ to see the changes. Benchmarks is based on merging with master (a821035) |
test performance please |
performance test scheduled: 1 job(s) in queue, 1 running. |
Can you clarify what problem this PR solves? What is Is there another way to solve this rather than introducing a complete new tree traversal? |
That would not be a complete tree traversal, it would be quite shallow. Traverse from the root package until you find the first |
It looks like a complete tree traversal to me: override def traverse(tree: tpd.Tree)(implicit ctx: Context): Unit = {
if (tree.isInstanceOf[tpd.TypeDef] && tree.symbol.isClass) {
...
}
traverseChildren(tree)
}
|
Given a class symbol, the value of
In the IDE, we always want to see the top level imports, because this information is necessary to correctly do renamings.
This PR is only important in the 3rd scenario. When setting the Now that we have IDE tests where the files are not "open in the IDE", I'll add tests where that matters. |
Also I don't think the benchmark set |
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/5276/ to see the changes. Benchmarks is based on merging with master (193e064) |
No, they do not |
@Duhemm what is the state of this PR |
`rootTreeOrProvider` is a property of `ClassSymbol`, and contain the tree that defines this symbol (or a mean to get that tree). When the tree came from unpickled TASTY files, we were able to see the nested packages from which the tree comes, along with the imports. However, when the symbol has been loaded from source, we were filling the `rootTreeOrProvider` only with the `TypeDef` that introduced this symbol. This commit moves the assignment of `rootTreeOrProvider` out of the typer and into its own phase. Before assigning, we recreate the package structure so that the information that we get out of `rootTreeOrProvider` is the same regardless of whether the symbol has been loaded from source or unpickled from TASTY.
We only need to traverse the tree down to the top level classes, but no further.
3726933
to
6272e8d
Compare
@nicolasstucki I've added a test that illustrates why this patch is needed. Without the addition of I've addressed your comments:
|
I think 6272e8d should be reverted. If it does not transform the tree then it doesn't have to be a macro transform |
@Duhemm something failed in the tests |
Yes you are right, it is better as a phase. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise looks good
During typer, set `rootTreeOrProvider` to be the typed class def. This information will be overwritten in `SetRootTree` to include the whole package structure, but we may never reach this phase.
6272e8d
to
136b0ce
Compare
@nicolasstucki I've fixed the test in 136b0ce, do you mind taking another look? |
rootTreeOrProvider
is a property ofClassSymbol
, and contain thetree that defines this symbol (or a mean to get that tree).
When the tree came from unpickled TASTY files, we were able to see the
nested packages from which the tree comes, along with the imports.
However, when the symbol has been loaded from source, we were filling
the
rootTreeOrProvider
only with theTypeDef
that introduced thissymbol.
This commit moves the assignment of
rootTreeOrProvider
out of thetyper and into its own phase. Before assigning, we recreate the package
structure so that the information that we get out of
rootTreeOrProvider
is the same regardless of whether the symbol hasbeen loaded from source or unpickled from TASTY.