Skip to content

Commit 51c0024

Browse files
committed
Whitelist instead of blacklist
1 parent 9b05823 commit 51c0024

File tree

3 files changed

+181
-15
lines changed

3 files changed

+181
-15
lines changed

test/SourceKit/Indexing/index_effective_access_level.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,15 @@ struct InternalStruct {
201201
let propertyReferencingPublicClassFromModule: Module.ModuleClass
202202
let propertyReferencingPublicClassFromExportedModule: Exported.ExportedClass
203203
}
204+
205+
public typealias Alias = Int
206+
207+
public var globalVariable: Int = 0
208+
209+
protocol ProtocolWithAssociatedType {
210+
associatedtype T
211+
}
212+
213+
struct ProtocolWithAssociatedTypeImpl: ProtocolWithAssociatedType {
214+
typealias T = Int
215+
}

test/SourceKit/Indexing/index_effective_access_level.swift.response

Lines changed: 148 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,7 @@
366366
key.name: "T",
367367
key.usr: "s:28index_effective_access_level21PublicPropertyWrapperV1Txmfp",
368368
key.line: 53,
369-
key.column: 37,
370-
key.effective_access: source.decl.effective_access.internal
369+
key.column: 37
371370
},
372371
{
373372
key.kind: source.lang.swift.decl.var.instance,
@@ -477,8 +476,7 @@
477476
key.name: "T",
478477
key.usr: "s:28index_effective_access_level23InternalPropertyWrapperV1Txmfp",
479478
key.line: 61,
480-
key.column: 32,
481-
key.effective_access: source.decl.effective_access.internal
479+
key.column: 32
482480
},
483481
{
484482
key.kind: source.lang.swift.decl.var.instance,
@@ -539,8 +537,7 @@
539537
key.name: "T",
540538
key.usr: "s:28index_effective_access_level26FilePrivatePropertyWrapper33_2295DDF1454D6A6D9229E8222CD85214LLV1Txmfp",
541539
key.line: 66,
542-
key.column: 47,
543-
key.effective_access: source.decl.effective_access.fileprivate
540+
key.column: 47
544541
},
545542
{
546543
key.kind: source.lang.swift.decl.var.instance,
@@ -619,8 +616,7 @@
619616
key.name: "T",
620617
key.usr: "s:28index_effective_access_level22PrivatePropertyWrapper33_2295DDF1454D6A6D9229E8222CD85214LLV1Txmfp",
621618
key.line: 71,
622-
key.column: 39,
623-
key.effective_access: source.decl.effective_access.fileprivate
619+
key.column: 39
624620
},
625621
{
626622
key.kind: source.lang.swift.decl.var.instance,
@@ -3629,6 +3625,150 @@
36293625
}
36303626
],
36313627
key.effective_access: source.decl.effective_access.internal
3628+
},
3629+
{
3630+
key.kind: source.lang.swift.decl.typealias,
3631+
key.name: "Alias",
3632+
key.usr: "s:28index_effective_access_level5Aliasa",
3633+
key.line: 205,
3634+
key.column: 18,
3635+
key.entities: [
3636+
{
3637+
key.kind: source.lang.swift.ref.struct,
3638+
key.name: "Int",
3639+
key.usr: "s:Si",
3640+
key.line: 205,
3641+
key.column: 26
3642+
}
3643+
],
3644+
key.attributes: [
3645+
{
3646+
key.attribute: source.decl.attribute.public
3647+
}
3648+
],
3649+
key.effective_access: source.decl.effective_access.public
3650+
},
3651+
{
3652+
key.kind: source.lang.swift.decl.var.global,
3653+
key.name: "globalVariable",
3654+
key.usr: "s:28index_effective_access_level14globalVariableSivp",
3655+
key.line: 207,
3656+
key.column: 12,
3657+
key.entities: [
3658+
{
3659+
key.kind: source.lang.swift.decl.function.accessor.getter,
3660+
key.usr: "s:28index_effective_access_level14globalVariableSivg",
3661+
key.line: 207,
3662+
key.column: 12,
3663+
key.is_implicit: 1,
3664+
key.attributes: [
3665+
{
3666+
key.attribute: source.decl.attribute.public
3667+
}
3668+
]
3669+
},
3670+
{
3671+
key.kind: source.lang.swift.decl.function.accessor.setter,
3672+
key.usr: "s:28index_effective_access_level14globalVariableSivs",
3673+
key.line: 207,
3674+
key.column: 12,
3675+
key.is_implicit: 1,
3676+
key.attributes: [
3677+
{
3678+
key.attribute: source.decl.attribute.public
3679+
}
3680+
]
3681+
}
3682+
],
3683+
key.attributes: [
3684+
{
3685+
key.attribute: source.decl.attribute.public
3686+
}
3687+
],
3688+
key.effective_access: source.decl.effective_access.public
3689+
},
3690+
{
3691+
key.kind: source.lang.swift.ref.struct,
3692+
key.name: "Int",
3693+
key.usr: "s:Si",
3694+
key.line: 207,
3695+
key.column: 28
3696+
},
3697+
{
3698+
key.kind: source.lang.swift.decl.protocol,
3699+
key.name: "ProtocolWithAssociatedType",
3700+
key.usr: "s:28index_effective_access_level26ProtocolWithAssociatedTypeP",
3701+
key.line: 209,
3702+
key.column: 10,
3703+
key.entities: [
3704+
{
3705+
key.kind: source.lang.swift.decl.associatedtype,
3706+
key.name: "T",
3707+
key.usr: "s:28index_effective_access_level26ProtocolWithAssociatedTypeP1TQa",
3708+
key.line: 210,
3709+
key.column: 20,
3710+
key.effective_access: source.decl.effective_access.internal
3711+
}
3712+
],
3713+
key.effective_access: source.decl.effective_access.internal
3714+
},
3715+
{
3716+
key.kind: source.lang.swift.decl.struct,
3717+
key.name: "ProtocolWithAssociatedTypeImpl",
3718+
key.usr: "s:28index_effective_access_level30ProtocolWithAssociatedTypeImplV",
3719+
key.line: 213,
3720+
key.column: 8,
3721+
key.related: [
3722+
{
3723+
key.kind: source.lang.swift.ref.protocol,
3724+
key.name: "ProtocolWithAssociatedType",
3725+
key.usr: "s:28index_effective_access_level26ProtocolWithAssociatedTypeP",
3726+
key.line: 213,
3727+
key.column: 40
3728+
}
3729+
],
3730+
key.entities: [
3731+
{
3732+
key.kind: source.lang.swift.ref.protocol,
3733+
key.name: "ProtocolWithAssociatedType",
3734+
key.usr: "s:28index_effective_access_level26ProtocolWithAssociatedTypeP",
3735+
key.line: 213,
3736+
key.column: 40
3737+
},
3738+
{
3739+
key.kind: source.lang.swift.decl.typealias,
3740+
key.name: "T",
3741+
key.usr: "s:28index_effective_access_level30ProtocolWithAssociatedTypeImplV1Ta",
3742+
key.line: 214,
3743+
key.column: 15,
3744+
key.related: [
3745+
{
3746+
key.kind: source.lang.swift.ref.associatedtype,
3747+
key.name: "T",
3748+
key.usr: "s:28index_effective_access_level26ProtocolWithAssociatedTypeP1TQa"
3749+
}
3750+
],
3751+
key.entities: [
3752+
{
3753+
key.kind: source.lang.swift.ref.struct,
3754+
key.name: "Int",
3755+
key.usr: "s:Si",
3756+
key.line: 214,
3757+
key.column: 19
3758+
}
3759+
],
3760+
key.effective_access: source.decl.effective_access.internal
3761+
},
3762+
{
3763+
key.kind: source.lang.swift.decl.function.constructor,
3764+
key.usr: "s:28index_effective_access_level30ProtocolWithAssociatedTypeImplVACycfc",
3765+
key.line: 213,
3766+
key.column: 8,
3767+
key.is_implicit: 1,
3768+
key.effective_access: source.decl.effective_access.internal
3769+
}
3770+
],
3771+
key.effective_access: source.decl.effective_access.internal
36323772
}
36333773
]
36343774
}

tools/SourceKit/lib/SwiftLang/SwiftIndexing.cpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,24 +148,38 @@ class SKIndexDataConsumer : public IndexDataConsumer {
148148
bool shouldOutputEffectiveAccessOfValueSymbol(SymbolInfo Info) {
149149
SymbolKind Kind = Info.Kind;
150150
SymbolSubKind SubKind = Info.SubKind;
151-
switch (Kind) {
152-
case SymbolKind::Extension:
153-
return false;
154-
default:
155-
break;
156-
}
157151
switch (SubKind) {
158152
case SymbolSubKind::AccessorGetter:
159153
case SymbolSubKind::AccessorSetter:
160154
case SymbolSubKind::SwiftAccessorWillSet:
161155
case SymbolSubKind::SwiftAccessorDidSet:
162156
case SymbolSubKind::SwiftAccessorAddressor:
163157
case SymbolSubKind::SwiftAccessorMutableAddressor:
158+
case SymbolSubKind::SwiftGenericTypeParam:
164159
return false;
165160
default:
166161
break;
167162
}
168-
return true;
163+
switch (Kind) {
164+
case SymbolKind::Enum:
165+
case SymbolKind::Struct:
166+
case SymbolKind::Class:
167+
case SymbolKind::Protocol:
168+
case SymbolKind::Constructor:
169+
case SymbolKind::EnumConstant:
170+
case SymbolKind::Function:
171+
case SymbolKind::StaticMethod:
172+
case SymbolKind::Variable:
173+
case SymbolKind::InstanceMethod:
174+
case SymbolKind::ClassMethod:
175+
case SymbolKind::InstanceProperty:
176+
case SymbolKind::ClassProperty:
177+
case SymbolKind::StaticProperty:
178+
case SymbolKind::TypeAlias:
179+
return true;
180+
default:
181+
return false;
182+
}
169183
}
170184

171185
template <typename F>

0 commit comments

Comments
 (0)