Is there a way or plugin to display the references on top of a method declarations in VsCode with Dart code? Something similar to Visual Studio reference display?
According to the official documentation of Visual Studio Code
Some languages like
C#
support inline reference information, that is updated live. This allows you to quickly analyze the impact of your edit or the popularity of your specific method or property throughout your project:
![]()
Tip: Directly invoke thePeek References
action by clicking on these annotations.Tip: Reference information shown in
CodeLens
can be turned on or off through theeditor.codeLens
setting.
It clearly described that,
Some languages like C# support inline reference information, that is updated live.
So it suggests using Peek features of VS Code instead (if Dart programming language does not yet support how C# behaves in showing references of a method).
Here's how:
When you execute a Go to References search (via Shift+F12), or a Peek Definition (via Alt+F12), we embed the result inline
Here's the source for more info regarding that context: Code Navigation
Or if you need to add it specifically to a particular language; under the Language specific editor settings
In addition, if you still want to achieve a similar behavior of it.
Then try this if it matches your use case:
/// [test2] // manual setting of method reference
void test1() { //method 1
debugPrint('this is a test 1');
test2();
}
/// [test3] // manual setting of method reference
void test2() { //method 2
debugPrint('this is a test 2');
test3();
}
/// [test1],[test2] // manual setting of method references
void test3() { //method 3
debugPrint('this is a test 3');
test1();
test2();
}
class ClassA {
void methodA1() {
debugPrint("Test ClassA's method 1");
}
}
class ClassC {
void methodA1() { // I've just decided to mimic the ClassA's methodA1
debugPrint("Test ClassC's method 1");
}
}
class ClassB {
/// [ClassA.methodA1]
void methodB1() {
ClassA().methodA1();
}
}
Kindly read this for more details: Documentation comment references