Skip to content

Commit 1d5b271

Browse files
keertipCommit Queue
authored andcommitted
[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 <[email protected]> Commit-Queue: Keerti Parthasarathy <[email protected]>
1 parent d3c323e commit 1d5b271

File tree

2 files changed

+12
-52
lines changed

2 files changed

+12
-52
lines changed

pkg/analysis_server/lib/src/services/completion/dart/declaration_helper.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1831,6 +1831,18 @@ class DeclarationHelper {
18311831
if (mustBeAssignable) {
18321832
return;
18331833
}
1834+
if (checkVisibilty &&
1835+
!visibilityTracker.isVisible(
1836+
element: constructors.first.enclosingElement,
1837+
importData: importData,
1838+
)) {
1839+
return;
1840+
}
1841+
1842+
if (checkVisibilty) {
1843+
checkVisibilty = false;
1844+
}
1845+
18341846
for (var constructor in constructors) {
18351847
if (constructor.isVisibleIn(request.libraryElement) &&
18361848
(allowNonFactory || constructor.isFactory)) {

pkg/analysis_server/test/services/completion/dart/completion_test.dart

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4881,18 +4881,6 @@ class Map{}class tst {var newt;void newf(){}test() {var newz;new ^/* */;}}
48814881
suggestions
48824882
Map
48834883
kind: constructorInvocation
4884-
Map.from
4885-
kind: constructorInvocation
4886-
Map.fromEntries
4887-
kind: constructorInvocation
4888-
Map.fromIterable
4889-
kind: constructorInvocation
4890-
Map.fromIterables
4891-
kind: constructorInvocation
4892-
Map.identity
4893-
kind: constructorInvocation
4894-
Map.unmodifiable
4895-
kind: constructorInvocation
48964884
''');
48974885
}
48984886

@@ -4905,18 +4893,6 @@ class Map{}class F{m(){new ^;}}
49054893
suggestions
49064894
Map
49074895
kind: constructorInvocation
4908-
Map.from
4909-
kind: constructorInvocation
4910-
Map.fromEntries
4911-
kind: constructorInvocation
4912-
Map.fromIterable
4913-
kind: constructorInvocation
4914-
Map.fromIterables
4915-
kind: constructorInvocation
4916-
Map.identity
4917-
kind: constructorInvocation
4918-
Map.unmodifiable
4919-
kind: constructorInvocation
49204896
''');
49214897
}
49224898

@@ -4929,18 +4905,6 @@ class Map{}class F{m(){new ^
49294905
suggestions
49304906
Map
49314907
kind: constructorInvocation
4932-
Map.from
4933-
kind: constructorInvocation
4934-
Map.fromEntries
4935-
kind: constructorInvocation
4936-
Map.fromIterable
4937-
kind: constructorInvocation
4938-
Map.fromIterables
4939-
kind: constructorInvocation
4940-
Map.identity
4941-
kind: constructorInvocation
4942-
Map.unmodifiable
4943-
kind: constructorInvocation
49444908
''');
49454909
}
49464910

@@ -5372,10 +5336,6 @@ replacement
53725336
suggestions
53735337
List
53745338
kind: constructorInvocation
5375-
List.empty
5376-
kind: constructorInvocation
5377-
List.generate
5378-
kind: constructorInvocation
53795339
''');
53805340
}
53815341

@@ -5522,18 +5482,6 @@ class List{}class XXX {XXX.fisk();}void f() {f(); new ^}}
55225482
suggestions
55235483
List
55245484
kind: constructorInvocation
5525-
List.empty
5526-
kind: constructorInvocation
5527-
List.filled
5528-
kind: constructorInvocation
5529-
List.from
5530-
kind: constructorInvocation
5531-
List.generate
5532-
kind: constructorInvocation
5533-
List.of
5534-
kind: constructorInvocation
5535-
List.unmodifiable
5536-
kind: constructorInvocation
55375485
XXX.fisk
55385486
kind: constructorInvocation
55395487
''');

0 commit comments

Comments
 (0)