Comments (8)
Yes, this is a request for the analysis server, and yes, if we made this change it would work in all of the IDEs that support navigation through the analysis server.
I agree that it would be good to have better support for navigating to the overridden method.
The one downside I can think of to using ctrl-click navigation for that purpose is that it makes the feature inconsistent. Everywhere else (including other annotations) it will take you to the declaration of the identifier, but here it wouldn't. I don't know how jarring that behavior would be for newer users.
We've been discussing how to provide good navigation when augmentations are enabled and one of the ideas that was proposed was to use code lenses to navigate to important targets, including to overridden methods. That solution leaves ctrl-click navigation consistent while providing more options for navigating to where users might want to go (including being able to navigate both directions in the override chain).
As noted in that comment, there are already commands to support some of this navigation, but they aren't very discoverable.
from sdk.
TIL what "CodeLens" is, so this is all based on very early impression. I'm open to alternatives to ctrl-click, but I have concerns about CodeLens specifically:
- Is this a proprietary VSCode feature? If so, how can it cover all editors?
- It injects copious amounts of UI into the editor with no user action. That seems excessive.
- It seems all CodeLenses need to be precomputed across the entire file to generate these extra links. This makes me worried about performance.
from sdk.
Why not click on the member name? Currently, it does nothing (VS Code). If it is overridden, go to the original member.
from sdk.
Is this a proprietary VSCode feature? If so, how can it cover all editors?
No, it's supported by LSP, so any editor using LSP can support this feature. (Not all LSP-based editors choose to support it, but there's not much we can do about that.)
IntelliJ and Android Studio don't use LSP, but they both have different support for this feature (icons in the editor's left gutter) that the analysis server has been supporting for many years. VS Code is actually behind IntelliJ in this case.
It injects copious amounts of UI into the editor with no user action. That seems excessive.
That's a fair concern. I believe that the current plan is to have a user-setting to enable or disable those code lenses, and to have commands on the pop-up menu for all of these options. Menu items aren't as convenient, but they are less invasive.
It might be worth opening an issue with the VS Code team asking for a cleaner UI.
It seems all CodeLenses need to be precomputed across the entire file to generate these extra links. This makes me worried about performance.
That's also a fair concern, and we'll be keeping a close eye on the performance characteristics. My expectation, partially based on the experiments that @DanTup wrote up, is that it's not likely to be an issue. Hopefully those aren't "famous last words".
Why not click on the member name? Currently, it does nothing (VS Code). If it is overridden, go to the original member.
That would also be a viable option, but it only handles one direction of navigation, and it's useful to be able to navigate both ways (up and down the override chain).
We will also need to support navigation across the 'augmentation' chain if we decide to support augmentations and macros. Having a consistent UX for navigation might trump many other considerations.
from sdk.
FWIW, we do have a "Go to Super" command + context menu entry that will take you where you want in the example above:
![Screenshot 2024-06-05 at 17 42 07](https://private-user-images.githubusercontent.com/1078012/336930540-c9c324a5-56d2-4029-b4d1-9f5a7ca4690e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTgwNDA1ODgsIm5iZiI6MTcxODA0MDI4OCwicGF0aCI6Ii8xMDc4MDEyLzMzNjkzMDU0MC1jOWMzMjRhNS01NmQyLTQwMjktYjRkMS05ZjVhN2NhNDY5MGUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYxMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MTBUMTcyNDQ4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NmQxNTQyMGUwZjZjNzk1YzM2ODVjNmYxYzhkZDc3MTNjNjdkY2UzNmVlOTQ5ZDMwZWNiYTdjOGJmYTFhY2JlMCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.sqW2qVCLGEl0rFEVy87xGbreYR12YLIYG66KxJX800A)
Why not click on the member name? Currently, it does nothing (VS Code). If it is overridden, go to the original member.
Ctrl+Click on a declaration actually does do something in VS Code. By default it will try to "go to definition" and when we return a definition that matches where you invoked it, it will fall back to "go to references". So in your example code above, if there are calls to foo()
it should show those results. This behaviour can be configured in VS Code (although the options are limited to other similar commands):
![Screenshot 2024-06-05 at 17 51 49](https://private-user-images.githubusercontent.com/1078012/336933049-b3cca165-abdd-4d15-9aad-b80fc230f56a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTgwNDA1ODgsIm5iZiI6MTcxODA0MDI4OCwicGF0aCI6Ii8xMDc4MDEyLzMzNjkzMzA0OS1iM2NjYTE2NS1hYmRkLTRkMTUtOWFhZC1iODBmYzIzMGY1NmEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYxMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MTBUMTcyNDQ4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OGQ4MDZkZmM3YWNjODIzNzVmYWNmNjg4ODY2NWNhZjZhM2FmZGFiMTBhMjg4YmNmN2JkOTVmOTRkOTZkN2ZjZCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.WrW8k9vH-h62YkDlcWOHC7oGZ_tWLzrtANK-GeDMKV4)
Unfortuantely we can't really change the behaviour here much because VS Code doesn't ask us to "handle a Ctrl+Click here", it just asks us "Where is the definition of the reference at this location", which is a generic request it uses in many places. Returning the overridden member instead could cause other functionality that uses "definition" to behave incorrectly. While it's more limiting, this does also ensure more consistency between different languages because the kind of navigation is configured once centrally.
I did file an issue to about making "Super" a first-class feature in VS Code (so it might have better UI), but unfortunately it was rejected (microsoft/vscode#47126).
from sdk.
After playing around with it a bit, I think the current state of things is sufficient. I see that the "Go to Super Class/Member" is also available from the keyboard-invocable menu (Ctrl + Shift + P in VSCode), so this action can be performed without much extra UI, or having to do much mouse/trackpad work.
That said, for all intents and purposes @override
is part of the language, even if it's technically not according to the language team. Perhaps it should formally become a modifier keyword, like @required
did. There are several places in Dart where keywords could be excellent navigation anchors, such as:
override void foo() {}
var bar = getBar();
final baz = getBaz();
override
could navigate to the super method, and var
and final
could navigate to the inferred type declaration.
As for this issue, I'm OK with closing it given the existing functionality.
from sdk.
There's a proposal for override becoming a language feature: https://github.com/dart-lang/language/blob/main/working/1610%20-%20override/proposal.md.
...
var
andfinal
could navigate to the inferred type declaration.
I like that idea.
from sdk.
FWIW, in LSP we already support "Go to Type Definition" which you can invoke on a variable (not only where it's declared) to jump directly to the type :-)
![Screenshot 2024-06-05 at 19 55 48](https://private-user-images.githubusercontent.com/1078012/336970572-962b9ccb-3719-4c1b-98a3-03e2870438b4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTgwNDA1ODgsIm5iZiI6MTcxODA0MDI4OCwicGF0aCI6Ii8xMDc4MDEyLzMzNjk3MDU3Mi05NjJiOWNjYi0zNzE5LTRjMWItOThhMy0wM2UyODcwNDM4YjQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYxMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MTBUMTcyNDQ4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9N2RmM2NlM2U1NzI1OGFkNDI4M2ZiMmViOTg2MWUyYzU3YzE2M2M0YjRjMTJiYjNmZWMzZjhmMzQ2NGVkYTk5MCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.KuwCAIVMjOBQ4XUeRooSGq_nl2X5WOJkO871wtMWeUs)
from sdk.
Related Issues (20)
- Dart2Wasm compiler fails building when dart:ffi library is conditionally imported HOT 4
- [Null-aware elements] [meta] Null-aware elements implementation
- [resource_identifiers] `UsageQueryable` proposal HOT 4
- Possible index error in _processExpressionCompilationRequest
- Different async timing whether using vm, node, dart2js and dart2wasm HOT 3
- Macros: Expose doc comments of a declaration
- [Null-aware elements] Implement parser changes
- [Null-aware elements] CFE Implementation
- Make analysis server/IDEs show the distinction between fields and getters accurately and consistently
- The return type 'String' isn't a 'String', as required by the closure's context HOT 2
- Flaky coverage/package:front_end/src/fasta/type_inference/inference_visitor_base.dart on front-end-linux-release-x64-try
- Add `Iterable.fromIterator` (or similar, name less important) HOT 1
- `meta` limitation: `useResult` not available in `factory` constructors HOT 4
- [vm/ffi] Variable length inline arrays no bounds checks HOT 2
- [wildcards] Quick fix: convert `UNUSED_LOCAL_VARIABLE` to wildcard
- [vm/ffi] Add `dladdr` embedder callback
- Analyzer Feedback from IntelliJ
- bug: FutureOr<FutureOr<Object>> does not resolve to FutureOr<Object> HOT 1
- Analyzer allows `super` as expression in several places HOT 4
- future doesn't throw correctly inside try block HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdk.