diff --git a/pkg/analysis_server/lib/src/services/completion/dart/declaration_helper.dart b/pkg/analysis_server/lib/src/services/completion/dart/declaration_helper.dart index b28e8c98e71..e9ec9b5a7f1 100644 --- a/pkg/analysis_server/lib/src/services/completion/dart/declaration_helper.dart +++ b/pkg/analysis_server/lib/src/services/completion/dart/declaration_helper.dart @@ -1831,6 +1831,18 @@ class DeclarationHelper { if (mustBeAssignable) { return; } + if (checkVisibilty && + !visibilityTracker.isVisible( + element: constructors.first.enclosingElement, + importData: importData, + )) { + return; + } + + if (checkVisibilty) { + checkVisibilty = false; + } + for (var constructor in constructors) { if (constructor.isVisibleIn(request.libraryElement) && (allowNonFactory || constructor.isFactory)) { diff --git a/pkg/analysis_server/test/services/completion/dart/completion_test.dart b/pkg/analysis_server/test/services/completion/dart/completion_test.dart index cc27ccb136f..837974ee098 100644 --- a/pkg/analysis_server/test/services/completion/dart/completion_test.dart +++ b/pkg/analysis_server/test/services/completion/dart/completion_test.dart @@ -4881,18 +4881,6 @@ class Map{}class tst {var newt;void newf(){}test() {var newz;new ^/* */;}} suggestions Map kind: constructorInvocation - Map.from - kind: constructorInvocation - Map.fromEntries - kind: constructorInvocation - Map.fromIterable - kind: constructorInvocation - Map.fromIterables - kind: constructorInvocation - Map.identity - kind: constructorInvocation - Map.unmodifiable - kind: constructorInvocation '''); } @@ -4905,18 +4893,6 @@ class Map{}class F{m(){new ^;}} suggestions Map kind: constructorInvocation - Map.from - kind: constructorInvocation - Map.fromEntries - kind: constructorInvocation - Map.fromIterable - kind: constructorInvocation - Map.fromIterables - kind: constructorInvocation - Map.identity - kind: constructorInvocation - Map.unmodifiable - kind: constructorInvocation '''); } @@ -4929,18 +4905,6 @@ class Map{}class F{m(){new ^ suggestions Map kind: constructorInvocation - Map.from - kind: constructorInvocation - Map.fromEntries - kind: constructorInvocation - Map.fromIterable - kind: constructorInvocation - Map.fromIterables - kind: constructorInvocation - Map.identity - kind: constructorInvocation - Map.unmodifiable - kind: constructorInvocation '''); } @@ -5372,10 +5336,6 @@ replacement suggestions List kind: constructorInvocation - List.empty - kind: constructorInvocation - List.generate - kind: constructorInvocation '''); } @@ -5522,18 +5482,6 @@ class List{}class XXX {XXX.fisk();}void f() {f(); new ^}} suggestions List kind: constructorInvocation - List.empty - kind: constructorInvocation - List.filled - kind: constructorInvocation - List.from - kind: constructorInvocation - List.generate - kind: constructorInvocation - List.of - kind: constructorInvocation - List.unmodifiable - kind: constructorInvocation XXX.fisk kind: constructorInvocation ''');