Skip to content

Commit 797b076

Browse files
keertipCommit Queue
authored andcommitted
Check for visisbility only once when adding completions for element members.
Change-Id: Icc482b005407262afe746d066971bb071a5e4508 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431380 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Keerti Parthasarathy <[email protected]>
1 parent a4e0a0b commit 797b076

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,6 +1697,7 @@ class DeclarationHelper {
16971697
element.constructors,
16981698
importData,
16991699
allowNonFactory: !element.isAbstract,
1700+
checkVisibilty: false,
17001701
);
17011702
}
17021703
}
@@ -1708,6 +1709,7 @@ class DeclarationHelper {
17081709
required ImportData? importData,
17091710
required bool hasClassName,
17101711
required bool isConstructorRedirect,
1712+
bool checkVisibilty = true,
17111713
}) {
17121714
if (mustBeAssignable) {
17131715
return;
@@ -1717,10 +1719,11 @@ class DeclarationHelper {
17171719
return;
17181720
}
17191721
if (importData?.isNotImported ?? false) {
1720-
if (!visibilityTracker.isVisible(
1721-
element: element.enclosingElement,
1722-
importData: importData,
1723-
)) {
1722+
if (checkVisibilty &&
1723+
!visibilityTracker.isVisible(
1724+
element: element.enclosingElement,
1725+
importData: importData,
1726+
)) {
17241727
// If the constructor is on a class from a not-yet-imported library and
17251728
// the class isn't visible, then we shouldn't suggest it.
17261729
//
@@ -1763,6 +1766,7 @@ class DeclarationHelper {
17631766
List<ConstructorElement> constructors,
17641767
ImportData? importData, {
17651768
bool allowNonFactory = true,
1769+
bool checkVisibilty = true,
17661770
}) {
17671771
if (mustBeAssignable) {
17681772
return;
@@ -1775,6 +1779,7 @@ class DeclarationHelper {
17751779
hasClassName: false,
17761780
importData: importData,
17771781
isConstructorRedirect: false,
1782+
checkVisibilty: checkVisibilty,
17781783
);
17791784
}
17801785
}
@@ -1852,7 +1857,11 @@ class DeclarationHelper {
18521857
}
18531858
if (!mustBeType) {
18541859
_suggestStaticFields(element.fields, importData);
1855-
_suggestConstructors(element.constructors, importData);
1860+
_suggestConstructors(
1861+
element.constructors,
1862+
importData,
1863+
checkVisibilty: false,
1864+
);
18561865
}
18571866
}
18581867
}

0 commit comments

Comments
 (0)