[Completion]Do not suggest constructors if element is not visible.

Change-Id: Ic5ebec233199a6d9cf0faf370ac3114bc0251b32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/438580
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
This commit is contained in:
Keerti Parthasarathy
2025-07-07 08:32:33 -07:00
committed by Commit Queue
parent d3c323e26d
commit 1d5b271fe0
2 changed files with 12 additions and 52 deletions
@@ -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)) {
@@ -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
''');