Sdk: Autocomplete of names not in scope gets confused by re-exported libraries

Created on 28 Apr 2019  路  11Comments  路  Source: dart-lang/sdk

Being able to automatically import symbols that aren't yet in scope is great but I'm having trouble with it being a bit too aggressive.

On a bleeding edge Dart SDK from Friday:
Repro steps:

import 'package:flutter/material.dart';

Now autocompleting a name from package:flutter/widgets.dart leads to problems as the symbols are available both through widgets.dart and the material.dart library that reexports them. You see duplicate entries for the same class in the autocomplete lists and the autocomplete functionality sometimes defaults to trying to make the import with a autogen prefix which causes me to have to undo and delete the prefix every time it gets suggested.

Example showing a prefix being generated without me doing anything to try to accept it even though the name is already in scope. In general it would be nice if some acceptance action was required to ever trigger importing with a prefix.
autocomplete

FYI @scheglov

analyzer-completion area-analyzer customer-flutter

All 11 comments

Please send the complete code of the file.

When I try something like your field in an almost empty file, it does NOT cause an import prefix, because it should it, it is the same class.聽 So, it must be some other name in the library that gets shadowed when both package:flutter/widget.dart is imported without a prefix.

same thing happens in vscode

If there is a standalone example how this could be reproduced, it would be faster to fix.
Animated images are less useful :-(

https://github.com/flutter/flutter/issues/33077#issuecomment-494222359

Opened Issue at same time yesterday

I think this is simailar to
https://github.com/dart-lang/sdk/issues/36890
above issue but with vscode

My problem is not appeared after uninstalling both flutter and plugins
But I expected that it could happen because
see this
2019-05-21_16-53-35
But it less annoying than before uninstalling because prefix0 is shown straight in first column now it is much better because it happens now less frequently
but it still showning widgets from multiple packages this is not an expected behaviour since i already imported material package why i need cupertino or widgets packages to be imported

If there is a standalone example how this could be reproduced, it would be faster to fix.
Animated images are less useful :-(

Instead of Gif Image How can i post vscode plugin related logs

@canewsin So, it seems that you are referencing another problem - that multiple possible imports are suggested for a name, even though the file where completion is requested already imports a library that exports this name. (Saying "name" is not quite correct - it should be "element" - name with URI). Yeah, this leads to some overload, although DAS always puts the variants from already imported libraries on the top.

We could compute and send additional data to the client to suppress suggestions for not yet imported libraries, that are already available from already imported libraries.

@scheglov and what about that preix0 tag appears before suggesions those sometimes appears as first suggesion and when selected as [ package: uri as prefix0 ]

I mean like this
57382534-6b994b00-71ad-11e9-90eb-e7b7831d2b89

Yes, the scenario you show is exactly what was fixed in https://github.com/dart-lang/sdk/issues/36890.

Is this a dupe of #36890 and fixed, or something else?

It seems that this issue is a mix of two separate issues.

  1. Filtering duplicates of elements already available via existing imports. This is implemented with existingImports notification in DAS. @lambdabaa is adding support in IntelliJ.
  2. Unnecessary import prefix. This was fixed.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

matanlurey picture matanlurey  路  3Comments

55555Mohit55555 picture 55555Mohit55555  路  3Comments

DartBot picture DartBot  路  3Comments

xster picture xster  路  3Comments

DartBot picture DartBot  路  3Comments