-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Go to Import could become Go to Directive and inform part files #59703
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
Comments
I think it would be reasonable to include Whether we should change the text though, I'm less sure. I feel like "Imports" might make it more obvious what this does (even if it's not strictly imports) and we already use "Imports" in some other places like "Organize Imports" where we really mean all directives. We could also write something like "Go to Import/Part Directives" to keep the word "import" while being more correct. |
I'm not sure I understand what the goal is for this. I believe the goal for 'Go to Import' is to answer the question "where is this name imported from". A developer presumably wants to know that in order to control the names that are in scope (via If the name is declared in the library then presumably the developer already has control over the library. There are no So, what's the motivation for this feature? |
I feel like this tool would feel more like "if I can't find the declaration inside this file, which direcitve is adding it to this scope?". If it's being added by the parent file or one of its other parts, we could point to the I feel like this could be a good tool for:
But as you said, on part of and part directives you can't add shows/hides so this is harder to follow. P.S.: Not quite sure about augmentations since I've not tested them and I'm unfamiliar if this could be a way to visualise it but maybe. |
My thought was that if a user has invoked this on something that isn't coming from imports, they are probably still wondering where it's coming from and showing the I don't know how big the trees of |
Maybe. If I were looking at a library I wasn't familiar with and it was spread across a lot of files I suspect that I'd just navigate to the declaration site rather than looking for which part it's coming from. But I'm not always representative of our users, so maybe.
I'm not sure that it does, so I'm going to push back a bit. If it says that Would a better solution be to (somehow) display the path through the part structure? Do we need to find a way to display the whole part tree (I mistyped earlier when I said 'graph'), maybe with some indication of where the part in the active editor is in the representation? |
Yeah, that's fair. At first I thought "what if the declaration is in some unfamiliar file and I don't know how it's part of this library?".. however it occurs to me now that because
Perhaps not. If they recognised the "rest" of the path to
I think it probably would. We might have limited ways in which we could show this in VS Code, but I wonder if the hover would be a fair place for it. It's probably similar to what was asked for at #56935, though I think for (there is also a breadcrumb in VS Code, but it's automatically built from the Document Symbol data and not something we can add arbitrary nodes to) |
For this I could say the same about exports. They won't actually help me get where is this coming from entirely. For that I'd use the Go to Declaration (CTRL + CLICK).
It would help to visualise the structure yes (I would like such a tool) but it wouldn't say whether a declaration is "above" or "below" the current part. |
You can. The same way you do today if a source file has multiple parts. All of them have access to anything from any other. And now since you can have any of them with inner children, any of their children's declaration would be accessible to you anywhere. |
It could even be up and down, but yes, there's a single path.
If you meant 'imports' rather than 'exports', I agree. But they will get you to where you can control what's being imported. Getting to a
I'm not sure that concept makes sense, but if it did what would that information tell you? Or, more to the point, what task would that information help you perform?
Correct. The one new thing in terms of namespaces is that you have a little more control over which imported names are in scope. |
The point in that phrase was declaration. It would help me better understand the library structure. For refactorings and similar I think it would be a good tool (even more so if that tree tool existed). Say some class
If I'm in Similar if it was declared inside
It would help me with this. I know I may not find the declaration directly and that would be my entire point here. "Why isn't this closer?" If it is, good, then were done.
I meant exports in the sense where the declaration is being exported one or many times until it gets to the file being imported. |
Ok, I see your point, and I agree. Following the chain of exports to try to see where a declaration is coming from is equally difficult. |
I'm unsure if we'll ever do this. Other things I just wanted to know if you agree a bit on before opening an issue:
I think something like Similar or integrated to the above, I think a tree of declarations would be nice too. It could show all top-level declarations and an open/close if they have inner declarations (classes -> methods -> local variables), if you agree this could be imagined to display inside or alongside the above. This way we could see where some declaration is inside a whole library. If we have a similar issue, please let me know. |
After #56584 is complete and working. I was wondering whether it would make sense for it to also show the
part
directive where a declaration is coming from. For the enhanced parts feature parts are now more complex and can have inner parts with more things so I think this tool would be great for this.@DanTup, not sure what sould be done in this case (if we'd need to replace the text on the context menu) if this is ever implemented just so you are aware of this.
We could also make a new call that would use the same logic but for part files and that would be a new thing but I don't think that is the best experience (the user would need to know if that was either imported or implemented in a part).
The text was updated successfully, but these errors were encountered: