question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Autocomplete for overriding methods does not show if the method has non-imported types

See original GitHub issue

Describe the bug

Assume we’ve this on a.dart file:

import 'dart:async';

abstract class Base {
  FutureOr<String> method() => '';
}

And on b.dart file we are trying to overide Base.method:

import 'a.dart';

class BaseImpl extends Base {
  
  // <~~ typing the word `method` here does not show autocomplete suggestions 

} 

i.e.:

Screen Shot 2022-08-23 at 11 19 03 PM

Though, if we import dart:async in b.dart, the autocomplete for override works.

Screen Shot 2022-08-23 at 11 19 18 PM

The same issue would occur if the non-imported type is an argument of the method instead of a return type.

Expected Behavior:

I would expect the autocomplete to show up, and once it’s selected, it’ll import all the necessary libraries (i.e. dart:async in this case)


Please complete the following information:

  • VS Code version: Version: 1.70.1
  • Dart extension version: v3.46.1
  • Dart/Flutter SDK version: Dart SDK version: 2.17.6 (stable) (Tue Jul 12 12:54:37 2022 +0200) on “macos_x64”

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
DanTupcommented, Nov 21, 2022

https://github.com/dart-lang/sdk/commit/1d64cba68e32ed9ef6b433287a53a36da446a005 addresses the items not showing up in completion, and https://github.com/dart-lang/sdk/commit/699b42c8e3ecfe96d1247241b3c9a9312e65e8bb adds support for bringing in potentially multiple) imports so the code is valid.

These are SDK changes, so will require a future SDK release to show up. Thanks for raising this and figuring out what was triggering it - it saved me some time debugging! 😃

0reactions
DanTupcommented, Nov 16, 2022

Prefixes etc are respected (since they don’t produce additional imports), although we still don’t consider collisions (as noted above, that’s not specific to this).

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - How to make autocomplete show methods suggestions ...
Right click in your editor pane for class A , go to 'Generate...' -> 'Override Methods...'. You'll then be presented with a list...
Read more >
[Intellisense TS] Poor Intellisense support when overriding ...
In the Child class, try to implement the function toOverride : no autocompletion is proposed, yet TS shows the error Non-abstract class ...
Read more >
Overriding and Hiding Methods (The Java™ Tutorials ...
The overriding method has the same name, number and type of parameters, and return type as the method that it overrides. An overriding...
Read more >
Override methods of a superclass | IntelliJ IDEA Documentation
The list does not include the methods that are already overridden or cannot be accessed from the current subclass. Select methods to override....
Read more >
Code Assistance in the NetBeans IDE Java Editor
If there is no matching pair, then the single element is ... For example, type IE , press Ctrl + Space , and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found