Merge pull request #76332 from DougGregor/sourcekit-drop-ifconfigdecl

Ignore inactive IfConfigDecls in SourceKit's syntax model, formatting, and placeholder expansion
This commit is contained in:
Doug Gregor
2024-09-09 10:50:27 -07:00
committed by GitHub
17 changed files with 44 additions and 996 deletions

View File

@@ -5,6 +5,22 @@
## Swift (next)
* Syntactic SourceKit queries no longer attempt to provide information
within the inactive `#if` regions. For example, given:
```swift
#if DEBUG
extension MyType: CustomDebugStringConvertible {
var debugDescription: String { ... }
}
#endif
```
If `DEBUG` is not set, SourceKit results will not involve the
inactive code. Clients should use either SourceKit-LSP or
swift-syntax for syntactic queries that are independent of the
specific build configuration.
* [SE-0442][]:
TaskGroups can now be created without explicitly specifying their child task's result types:

View File

@@ -487,15 +487,6 @@ private:
if (D->isImplicit())
return Action::Continue();
// Walk into inactive config regions.
if (auto *ICD = dyn_cast<IfConfigDecl>(D)) {
for (auto Clause : ICD->getClauses()) {
for (auto Member : Clause.Elements)
Member.walk(*this);
}
return Action::SkipNode();
}
SourceLoc ContextLoc = D->getStartLoc();
if (auto *GC = D->getAsGenericContext()) {
@@ -1396,17 +1387,6 @@ private:
}
}
// Walk into inactive config regions.
if (auto *ICD = dyn_cast<IfConfigDecl>(D)) {
if (Action.shouldVisitChildren()) {
for (auto Clause : ICD->getClauses()) {
for (auto Member : Clause.Elements)
Member.walk(*this);
}
}
return Action::SkipNode();
}
// FIXME: We ought to be able to use Action::VisitChildrenIf here, but we'd
// need to ensure the AST is walked in source order (currently not the case
// for things like postfix operators).
@@ -1933,19 +1913,6 @@ private:
return IndentContext {ContextLoc, !OutdentChecker::hasOutdent(SM, D)};
}
if (auto *ICD = dyn_cast<IfConfigDecl>(D)) {
for (auto &Clause: ICD->getClauses()) {
if (Clause.Loc == TargetLocation)
break;
if (auto *Cond = Clause.Cond) {
SourceRange CondRange = Cond->getSourceRange();
if (CondRange.isValid() && overlapsTarget(CondRange))
return IndentContext {Clause.Loc, true};
}
}
return IndentContext { ICD->getStartLoc(), false };
}
switch (D->getKind()) {
case DeclKind::InfixOperator:
case DeclKind::PostfixOperator:

View File

@@ -416,7 +416,6 @@ public:
private:
static bool findUrlStartingLoc(StringRef Text, unsigned &Start,
std::regex& Regex);
bool annotateIfConfigConditionIdentifiers(Expr *Cond);
bool handleAttrs(const ParsedDeclAttributes &Attrs);
bool handleAttrs(ArrayRef<TypeOrCustomAttr> Attrs);
@@ -1003,24 +1002,8 @@ ASTWalker::PreWalkAction ModelASTWalker::walkToDeclPre(Decl *D) {
}
pushStructureNode(SN, VD);
} else if (auto *ConfigD = dyn_cast<IfConfigDecl>(D)) {
for (auto &Clause : ConfigD->getClauses()) {
if (Clause.Cond && !annotateIfConfigConditionIdentifiers(Clause.Cond))
return Action::SkipNode();
InactiveClauseRAII inactiveClauseRAII(inInactiveClause, !Clause.isActive);
for (auto &Element : Clause.Elements) {
if (auto *E = Element.dyn_cast<Expr*>()) {
E->walk(*this);
} else if (auto *S = Element.dyn_cast<Stmt*>()) {
S->walk(*this);
} else {
Element.get<Decl*>()->walk(*this);
}
NodesVisitedBefore.insert(Element);
}
}
} else if (isa<IfConfigDecl>(D)) {
// Note: nothing to do.
} else if (auto *EnumCaseD = dyn_cast<EnumCaseDecl>(D)) {
SyntaxStructureNode SN;
setDecl(SN, D);
@@ -1172,17 +1155,6 @@ public:
};
} // end anonymous namespace
bool ModelASTWalker::annotateIfConfigConditionIdentifiers(Expr *Cond) {
if (!Cond)
return true;
auto passNode = [&](CharSourceRange R) {
return passNonTokenNode({ SyntaxNodeKind::BuildConfigId, R });
};
IdRefWalker<decltype(passNode)> Walker(passNode);
return Cond->walk(Walker);
}
bool ModelASTWalker::handleSpecialDeclAttribute(const DeclAttribute *D,
ArrayRef<Token> Toks) {
if (!D)

View File

@@ -1,326 +1,5 @@
// RUN: %target-swift-ide-test -syntax-coloring -source-filename %s -D CONF | %FileCheck %s
// CHECK: <kw>var</kw> f : <type>Int</type>
var f : Int
// CHECK: <#kw>#if</#kw> <#id>os</#id>(<#id>macOS</#id>)
#if os(macOS)
#endif
// CHECK: <#kw>#if</#kw> <#id>CONF</#id>
#if CONF
// CHECK: <kw>var</kw> x : <type>Int</type>
var x : Int
// CHECK: <#kw>#else</#kw>
#else
// CHECK: <kw>var</kw> x : <type>Float</type>
var x : Float
// CHECK: <#kw>#endif</#kw>
#endif
// CHECK: <#kw>#if</#kw> <#id>CONF</#id>
#if CONF
// CHECK: <kw>var</kw> x2 : <type>Int</type>
var x2 : Int
// CHECK: <#kw>#endif</#kw>
#endif
// CHECK: <#kw>#if</#kw> !<#id>CONF</#id>
#if !CONF
// CHECK: <kw>var</kw> x3 : <type>Int</type>
var x3 : Int
// CHECK: <#kw>#else</#kw>
#else
// CHECK: <kw>var</kw> x3 : <type>Float</type>
var x3 : Float
// CHECK: <#kw>#endif</#kw>
#endif
// CHECK: <#kw>#if</#kw> !<#id>CONF</#id>
#if !CONF
// CHECK: <kw>var</kw> x4 : <type>Int</type>
var x4 : Int
// CHECK: <#kw>#endif</#kw>
#endif
// CHECK: <#kw>#if</#kw> <#id>CONF</#id>
#if CONF
// CHECK: <kw>var</kw> y1 : <type>Int</type>
var y1 : Int
// CHECK: <#kw>#elseif</#kw> <#id>BAZ</#id>
#elseif BAZ
// CHECK: <kw>var</kw> y1 : <type>String</type>
var y1 : String
// CHECK: <#kw>#else</#kw>
#else
// CHECK: <kw>var</kw> y1 : <type>Float</type>
var y1 : Float
// CHECK: <#kw>#endif</#kw>
#endif
// CHECK: <#kw>#if</#kw> !<#id>CONF</#id>
#if !CONF
// CHECK: <kw>var</kw> y2 : <type>Int</type>
var y2 : Int
// CHECK: <#kw>#elseif</#kw> <#id>BAZ</#id>
#elseif BAZ
// CHECK: <kw>var</kw> y2 : <type>String</type>
var y2 : String
// CHECK: <#kw>#else</#kw>
#else
// CHECK: <kw>var</kw> y2 : <type>Float</type>
var y2 : Float
// CHECK: <#kw>#endif</#kw>
#endif
// CHECK: <#kw>#if</#kw> !<#id>CONF</#id>
#if !CONF
// CHECK: <kw>var</kw> y3 : <type>Int</type>
var y3 : Int
// CHECK: <#kw>#elseif</#kw> <#id>CONF</#id>
#elseif CONF
// CHECK: <kw>var</kw> y3 : <type>String</type>
var y3 : String
// CHECK: <#kw>#else</#kw>
#else
// CHECK: <kw>var</kw> y3 : <type>Float</type>
var y3 : Float
// CHECK: <#kw>#endif</#kw>
#endif
// CHECK: <kw>var</kw> l : <type>Int</type>
var l : Int
// CHECK: <kw>class</kw> C1 {
class C1 {
// CHECK: <kw>var</kw> f : <type>Int</type>
var f : Int
// CHECK: <#kw>#if</#kw> <#id>CONF</#id>
#if CONF
// CHECK: <kw>var</kw> x : <type>Int</type>
var x : Int
// CHECK: <#kw>#else</#kw>
#else
// CHECK: <kw>var</kw> x : <type>Float</type>
var x : Float
// CHECK: <#kw>#endif</#kw>
#endif
// CHECK: <#kw>#if</#kw> <#id>CONF</#id>
#if CONF
// CHECK: <kw>var</kw> x2 : <type>Int</type>
var x2 : Int
// CHECK: <#kw>#endif</#kw>
#endif
// CHECK: <#kw>#if</#kw> !<#id>CONF</#id>
#if !CONF
// CHECK: <kw>var</kw> x3 : <type>Int</type>
var x3 : Int
// CHECK: <#kw>#else</#kw>
#else
// CHECK: <kw>var</kw> x3 : <type>Float</type>
var x3 : Float
// CHECK: <#kw>#endif</#kw>
#endif
// CHECK: <#kw>#if</#kw> !<#id>CONF</#id>
#if !CONF
// CHECK: <kw>var</kw> x4 : <type>Int</type>
var x4 : Int
// CHECK: <#kw>#endif</#kw>
#endif
// CHECK: <#kw>#if</#kw> <#id>CONF</#id>
#if CONF
// CHECK: <kw>var</kw> y1 : <type>Int</type>
var y1 : Int
// CHECK: <#kw>#elseif</#kw> <#id>BAZ</#id>
#elseif BAZ
// CHECK: <kw>var</kw> y1 : <type>String</type>
var y1 : String
// CHECK: <#kw>#else</#kw>
#else
// CHECK: <kw>var</kw> y1 : <type>Float</type>
var y1 : Float
// CHECK: <#kw>#endif</#kw>
#endif
// CHECK: <#kw>#if</#kw> !<#id>CONF</#id>
#if !CONF
// CHECK: <kw>var</kw> y2 : <type>Int</type>
var y2 : Int
// CHECK: <#kw>#elseif</#kw> <#id>BAZ</#id>
#elseif BAZ
// CHECK: <kw>var</kw> y2 : <type>String</type>
var y2 : String
// CHECK: <#kw>#else</#kw>
#else
// CHECK: <kw>var</kw> y2 : <type>Float</type>
var y2 : Float
// CHECK: <#kw>#endif</#kw>
#endif
// CHECK: <#kw>#if</#kw> !<#id>CONF</#id>
#if !CONF
// CHECK: <kw>var</kw> y3 : <type>Int</type>
var y3 : Int
// CHECK: <#kw>#elseif</#kw> <#id>CONF</#id>
#elseif CONF
// CHECK: <kw>var</kw> y3 : <type>String</type>
var y3 : String
// CHECK: <#kw>#else</#kw>
#else
// CHECK: <kw>var</kw> y3 : <type>Float</type>
var y3 : Float
// CHECK: <#kw>#endif</#kw>
#endif
// CHECK: <kw>var</kw> l : <type>Int</type>
var l : Int
}
// CHECK: <kw>func</kw> test1() {
func test1() {
// CHECK: <kw>var</kw> f : <type>Int</type>
var f : Int
// CHECK: <#kw>#if</#kw> <#id>CONF</#id>
#if CONF
// CHECK: <kw>var</kw> x : <type>Int</type>
var x : Int
// CHECK: <#kw>#else</#kw>
#else
// CHECK: <kw>var</kw> x : <type>Float</type>
var x : Float
// CHECK: <#kw>#endif</#kw>
#endif
// CHECK: <#kw>#if</#kw> <#id>CONF</#id>
#if CONF
// CHECK: <kw>var</kw> x2 : <type>Int</type>
var x2 : Int
// CHECK: <#kw>#endif</#kw>
#endif
// CHECK: <#kw>#if</#kw> !<#id>CONF</#id>
#if !CONF
// CHECK: <kw>var</kw> x3 : <type>Int</type>
var x3 : Int
// CHECK: <#kw>#else</#kw>
#else
// CHECK: <kw>var</kw> x3 : <type>Float</type>
var x3 : Float
// CHECK: <#kw>#endif</#kw>
#endif
// CHECK: <#kw>#if</#kw> !<#id>CONF</#id>
#if !CONF
// CHECK: <kw>var</kw> x4 : <type>Int</type>
var x4 : Int
// CHECK: <#kw>#endif</#kw>
#endif
// CHECK: <#kw>#if</#kw> <#id>CONF</#id>
#if CONF
// CHECK: <kw>var</kw> y1 : <type>Int</type>
var y1 : Int
// CHECK: <#kw>#elseif</#kw> <#id>BAZ</#id>
#elseif BAZ
// CHECK: <kw>var</kw> y1 : <type>String</type>
var y1 : String
// CHECK: <#kw>#else</#kw>
#else
// CHECK: <kw>var</kw> y1 : <type>Float</type>
var y1 : Float
// CHECK: <#kw>#endif</#kw>
#endif
// CHECK: <#kw>#if</#kw> !<#id>CONF</#id>
#if !CONF
// CHECK: <kw>var</kw> y2 : <type>Int</type>
var y2 : Int
// CHECK: <#kw>#elseif</#kw> <#id>BAZ</#id>
#elseif BAZ
// CHECK: <kw>var</kw> y2 : <type>String</type>
var y2 : String
// CHECK: <#kw>#else</#kw>
#else
// CHECK: <kw>var</kw> y2 : <type>Float</type>
var y2 : Float
// CHECK: <#kw>#endif</#kw>
#endif
// CHECK: <#kw>#if</#kw> !<#id>CONF</#id>
#if !CONF
// CHECK: <kw>var</kw> y3 : <type>Int</type>
var y3 : Int
// CHECK: <#kw>#elseif</#kw> <#id>CONF</#id>
#elseif CONF
// CHECK: <kw>var</kw> y3 : <type>String</type>
var y3 : String
// CHECK: <#kw>#else</#kw>
#else
// CHECK: <kw>var</kw> y3 : <type>Float</type>
var y3 : Float
// CHECK: <#kw>#endif</#kw>
#endif
// CHECK: <kw>var</kw> l : <type>Int</type>
var l : Int
}
// CHECK: <kw>class</kw> C2 {
class C2 {
// CHECK: <#kw>#if</#kw> <#id>os</#id>(<#id>iOS</#id>)
#if os(iOS)
// CHECK: <kw>func</kw> foo() {}
func foo() {}
#endif
}
class NestedPoundIf {
// CHECK: <kw>class</kw> NestedPoundIf {
func foo1() {
// CHECK: <kw>func</kw> foo1() {
#if os(macOS)
// CHECK: <#kw>#if</#kw> <#id>os</#id>(<#id>macOS</#id>)
var a = 1
// CHECK: <kw>var</kw> a = <int>1</int>
#if USE_METAL
// CHECK: <#kw>#if</#kw> <#id>USE_METAL</#id>
var b = 2
// CHECK: <kw>var</kw> b = <int>2</int>
#if os(iOS)
// CHECK: <#kw>#if</#kw> <#id>os</#id>(<#id>iOS</#id>)
var c = 3
// CHECK: <kw>var</kw> c = <int>3</int>
#else
// CHECK: <#kw>#else</#kw>
var c = 3
// CHECK: <kw>var</kw> c = <int>3</int>
#endif
// CHECK: <#kw>#endif</#kw>
#else
// CHECK: <#kw>#else</#kw>
var b = 2
// CHECK: <kw>var</kw> b = <int>2</int>
#endif
// CHECK: <#kw>#endif</#kw>
#else
// CHECK: <#kw>#else</#kw>
var a = 1
// CHECK: <kw>var</kw> a = <int>1</int>
#endif
// CHECK: <#kw>#endif</#kw>
}
func foo2() {}
// CHECK: <kw>func</kw> foo2() {}
func foo3() {}
// CHECK: <kw>func</kw> foo3() {}
}
// CHECK: <#kw>#error</#kw>(<str>"Error"</str>)
#error("Error")
// CHECK: <#kw>#warning</#kw>(<str>"Warning"</str>)

View File

@@ -1,14 +0,0 @@
// RUN: %target-swift-ide-test -syntax-coloring -source-filename %s | %FileCheck %s
// RUN: %target-swift-ide-test -syntax-coloring -typecheck -source-filename %s | %FileCheck %s
// CHECK: <#kw>#if</#kw> <#id>d</#id>
// CHECK-NEXT: <kw>func</kw> bar() {
// CHECK-NEXT: <#kw>#if</#kw> <#id>d</#id>
// CHECK-NEXT: }
// CHECK-NEXT: <kw>func</kw> foo() {}
#if d
func bar() {
#if d
}
func foo() {}

View File

@@ -147,17 +147,11 @@ braced2(x: {<#T##() -> Void#>}, y: Int)
// CHECK-NEXT: }, y: Int)
braced3({
#if true
<#T##() -> Int#>
#endif
})
// CHECK: braced3({
// CHECK-NEXT: #if true
// CHECK-NEXT: {
// CHECK: braced3 {
// CHECK-NEXT: <#code#>
// CHECK-NEXT: }
// CHECK-NEXT: #endif
// CHECK-NEXT: })
// CHECK-NEXT: }
func returnTrailing() -> Int {
return withtrail(<#T##() -> ()#>)
@@ -260,17 +254,6 @@ func activeWithTrailing() {
// CHECK: forEach {
// CHECK-NEXT: <#code#>
}
#if false
func inactive() {
foo(<#T##value: Foo##Foo#>)
// CHECK: foo(Foo)
}
func inactiveWithTrailing() {
forEach(<#T##() -> ()#>)
// CHECK: forEach {
// CHECK-NEXT: <#code#>
}
#endif
expandClosureWithInternalParameterNames {
withtrail(<#T##callback: (Int, Int) -> Bool##(_ a: Int, _ b: Int) -> Bool#>)

View File

@@ -35,7 +35,7 @@ print(false)
// RUN: %FileCheck --strict-whitespace %s <%t.response
// CHECK: key.sourcetext: "#else"
// CHECK: key.sourcetext: " let i = 3"
// CHECK: key.sourcetext: " func b () {"
// CHECK: key.sourcetext: "let i = 3"
// CHECK: key.sourcetext: "func b () {"
// CHECK: key.sourcetext: "#elseif os(OSX)"
// CHECK: key.sourcetext: " func b () {"
// CHECK: key.sourcetext: "func b () {"

View File

@@ -1428,106 +1428,6 @@
}
]
},
{
key.kind: source.lang.swift.decl.extension,
key.name: "Result",
key.offset: 2496,
key.length: 36,
key.nameoffset: 2506,
key.namelength: 6,
key.bodyoffset: 2514,
key.bodylength: 17,
key.substructure: [
{
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "foo()",
key.offset: 2517,
key.length: 13,
key.nameoffset: 2522,
key.namelength: 5,
key.bodyoffset: 2529,
key.bodylength: 0
}
]
},
{
key.kind: source.lang.swift.decl.extension,
key.name: "Outer",
key.offset: 2534,
key.length: 53,
key.nameoffset: 2544,
key.namelength: 5,
key.bodyoffset: 2551,
key.bodylength: 35,
key.substructure: [
{
key.kind: source.lang.swift.decl.class,
key.name: "Inner",
key.offset: 2554,
key.length: 31,
key.nameoffset: 2560,
key.namelength: 5,
key.bodyoffset: 2567,
key.bodylength: 17,
key.substructure: [
{
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "deinit",
key.offset: 2572,
key.length: 9,
key.nameoffset: 2572,
key.namelength: 6,
key.bodyoffset: 2580,
key.bodylength: 0
}
]
}
]
},
{
key.kind: source.lang.swift.decl.extension,
key.accessibility: source.lang.swift.accessibility.public,
key.name: "Outer2",
key.offset: 2596,
key.length: 55,
key.nameoffset: 2606,
key.namelength: 6,
key.bodyoffset: 2614,
key.bodylength: 36,
key.attributes: [
{
key.offset: 2589,
key.length: 6,
key.attribute: source.decl.attribute.public
}
],
key.substructure: [
{
key.kind: source.lang.swift.decl.class,
key.accessibility: source.lang.swift.accessibility.public,
key.name: "Inner2",
key.offset: 2617,
key.length: 32,
key.nameoffset: 2623,
key.namelength: 6,
key.bodyoffset: 2631,
key.bodylength: 17,
key.substructure: [
{
key.kind: source.lang.swift.decl.function.method.instance,
key.accessibility: source.lang.swift.accessibility.public,
key.name: "deinit",
key.offset: 2636,
key.length: 9,
key.nameoffset: 2636,
key.namelength: 6,
key.bodyoffset: 2644,
key.bodylength: 0
}
]
}
]
},
{
key.kind: source.lang.swift.decl.protocol,
key.accessibility: source.lang.swift.accessibility.internal,
@@ -1578,50 +1478,6 @@
}
]
},
{
key.kind: source.lang.swift.decl.protocol,
key.accessibility: source.lang.swift.accessibility.internal,
key.name: "MyProtocol",
key.offset: 2780,
key.length: 71,
key.nameoffset: 2789,
key.namelength: 10,
key.bodyoffset: 2819,
key.bodylength: 31,
key.inheritedtypes: [
{
key.name: "NSObjectProtocol"
}
],
key.attributes: [
{
key.offset: 2774,
key.length: 5,
key.attribute: source.decl.attribute.objc
}
],
key.elements: [
{
key.kind: source.lang.swift.structure.elem.typeref,
key.offset: 2801,
key.length: 16
}
],
key.substructure: [
{
key.kind: source.lang.swift.decl.var.instance,
key.accessibility: source.lang.swift.accessibility.internal,
key.name: "thing",
key.offset: 2824,
key.length: 25,
key.typename: "NSObject",
key.nameoffset: 2828,
key.namelength: 5,
key.bodyoffset: 2845,
key.bodylength: 3
}
]
},
{
key.kind: source.lang.swift.decl.class,
key.accessibility: source.lang.swift.accessibility.internal,
@@ -1631,44 +1487,7 @@
key.nameoffset: 2866,
key.namelength: 1,
key.bodyoffset: 2869,
key.bodylength: 59,
key.substructure: [
{
key.kind: source.lang.swift.decl.function.method.instance,
key.accessibility: source.lang.swift.accessibility.internal,
key.name: "foo(a:)",
key.offset: 2899,
key.length: 19,
key.selector_name: "fooWithA:",
key.nameoffset: 2904,
key.namelength: 11,
key.bodyoffset: 2917,
key.bodylength: 0,
key.attributes: [
{
key.offset: 2893,
key.length: 5,
key.attribute: source.decl.attribute.objc.name
},
{
key.offset: 2883,
key.length: 9,
key.attribute: source.decl.attribute.ibaction
}
],
key.substructure: [
{
key.kind: source.lang.swift.decl.var.parameter,
key.name: "a",
key.offset: 2908,
key.length: 6,
key.typename: "Int",
key.nameoffset: 2908,
key.namelength: 1
}
]
}
]
key.bodylength: 59
}
],
key.diagnostics: [

View File

@@ -1428,106 +1428,6 @@
}
]
},
{
key.kind: source.lang.swift.decl.extension,
key.name: "Result",
key.offset: 2496,
key.length: 36,
key.nameoffset: 2506,
key.namelength: 6,
key.bodyoffset: 2514,
key.bodylength: 17,
key.substructure: [
{
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "foo()",
key.offset: 2517,
key.length: 13,
key.nameoffset: 2522,
key.namelength: 5,
key.bodyoffset: 2529,
key.bodylength: 0
}
]
},
{
key.kind: source.lang.swift.decl.extension,
key.name: "Outer",
key.offset: 2534,
key.length: 53,
key.nameoffset: 2544,
key.namelength: 5,
key.bodyoffset: 2551,
key.bodylength: 35,
key.substructure: [
{
key.kind: source.lang.swift.decl.class,
key.name: "Inner",
key.offset: 2554,
key.length: 31,
key.nameoffset: 2560,
key.namelength: 5,
key.bodyoffset: 2567,
key.bodylength: 17,
key.substructure: [
{
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "deinit",
key.offset: 2572,
key.length: 9,
key.nameoffset: 2572,
key.namelength: 6,
key.bodyoffset: 2580,
key.bodylength: 0
}
]
}
]
},
{
key.kind: source.lang.swift.decl.extension,
key.accessibility: source.lang.swift.accessibility.public,
key.name: "Outer2",
key.offset: 2596,
key.length: 55,
key.nameoffset: 2606,
key.namelength: 6,
key.bodyoffset: 2614,
key.bodylength: 36,
key.attributes: [
{
key.offset: 2589,
key.length: 6,
key.attribute: source.decl.attribute.public
}
],
key.substructure: [
{
key.kind: source.lang.swift.decl.class,
key.accessibility: source.lang.swift.accessibility.public,
key.name: "Inner2",
key.offset: 2617,
key.length: 32,
key.nameoffset: 2623,
key.namelength: 6,
key.bodyoffset: 2631,
key.bodylength: 17,
key.substructure: [
{
key.kind: source.lang.swift.decl.function.method.instance,
key.accessibility: source.lang.swift.accessibility.public,
key.name: "deinit",
key.offset: 2636,
key.length: 9,
key.nameoffset: 2636,
key.namelength: 6,
key.bodyoffset: 2644,
key.bodylength: 0
}
]
}
]
},
{
key.kind: source.lang.swift.decl.protocol,
key.accessibility: source.lang.swift.accessibility.internal,
@@ -1578,50 +1478,6 @@
}
]
},
{
key.kind: source.lang.swift.decl.protocol,
key.accessibility: source.lang.swift.accessibility.internal,
key.name: "MyProtocol",
key.offset: 2780,
key.length: 71,
key.nameoffset: 2789,
key.namelength: 10,
key.bodyoffset: 2819,
key.bodylength: 31,
key.inheritedtypes: [
{
key.name: "NSObjectProtocol"
}
],
key.attributes: [
{
key.offset: 2774,
key.length: 5,
key.attribute: source.decl.attribute.objc
}
],
key.elements: [
{
key.kind: source.lang.swift.structure.elem.typeref,
key.offset: 2801,
key.length: 16
}
],
key.substructure: [
{
key.kind: source.lang.swift.decl.var.instance,
key.accessibility: source.lang.swift.accessibility.internal,
key.name: "thing",
key.offset: 2824,
key.length: 25,
key.typename: "NSObject",
key.nameoffset: 2828,
key.namelength: 5,
key.bodyoffset: 2845,
key.bodylength: 3
}
]
},
{
key.kind: source.lang.swift.decl.class,
key.accessibility: source.lang.swift.accessibility.internal,
@@ -1631,44 +1487,7 @@
key.nameoffset: 2866,
key.namelength: 1,
key.bodyoffset: 2869,
key.bodylength: 59,
key.substructure: [
{
key.kind: source.lang.swift.decl.function.method.instance,
key.accessibility: source.lang.swift.accessibility.internal,
key.name: "foo(a:)",
key.offset: 2899,
key.length: 19,
key.selector_name: "fooWithA:",
key.nameoffset: 2904,
key.namelength: 11,
key.bodyoffset: 2917,
key.bodylength: 0,
key.attributes: [
{
key.offset: 2893,
key.length: 5,
key.attribute: source.decl.attribute.objc.name
},
{
key.offset: 2883,
key.length: 9,
key.attribute: source.decl.attribute.ibaction
}
],
key.substructure: [
{
key.kind: source.lang.swift.decl.var.parameter,
key.name: "a",
key.offset: 2908,
key.length: 6,
key.typename: "Int",
key.nameoffset: 2908,
key.namelength: 1
}
]
}
]
key.bodylength: 59
}
],
key.diagnostics: [

View File

@@ -1428,106 +1428,6 @@
}
]
},
{
key.kind: source.lang.swift.decl.extension,
key.name: "Result",
key.offset: 2496,
key.length: 36,
key.nameoffset: 2506,
key.namelength: 6,
key.bodyoffset: 2514,
key.bodylength: 17,
key.substructure: [
{
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "foo()",
key.offset: 2517,
key.length: 13,
key.nameoffset: 2522,
key.namelength: 5,
key.bodyoffset: 2529,
key.bodylength: 0
}
]
},
{
key.kind: source.lang.swift.decl.extension,
key.name: "Outer",
key.offset: 2534,
key.length: 53,
key.nameoffset: 2544,
key.namelength: 5,
key.bodyoffset: 2551,
key.bodylength: 35,
key.substructure: [
{
key.kind: source.lang.swift.decl.class,
key.name: "Inner",
key.offset: 2554,
key.length: 31,
key.nameoffset: 2560,
key.namelength: 5,
key.bodyoffset: 2567,
key.bodylength: 17,
key.substructure: [
{
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "deinit",
key.offset: 2572,
key.length: 9,
key.nameoffset: 2572,
key.namelength: 6,
key.bodyoffset: 2580,
key.bodylength: 0
}
]
}
]
},
{
key.kind: source.lang.swift.decl.extension,
key.accessibility: source.lang.swift.accessibility.public,
key.name: "Outer2",
key.offset: 2596,
key.length: 55,
key.nameoffset: 2606,
key.namelength: 6,
key.bodyoffset: 2614,
key.bodylength: 36,
key.attributes: [
{
key.offset: 2589,
key.length: 6,
key.attribute: source.decl.attribute.public
}
],
key.substructure: [
{
key.kind: source.lang.swift.decl.class,
key.accessibility: source.lang.swift.accessibility.public,
key.name: "Inner2",
key.offset: 2617,
key.length: 32,
key.nameoffset: 2623,
key.namelength: 6,
key.bodyoffset: 2631,
key.bodylength: 17,
key.substructure: [
{
key.kind: source.lang.swift.decl.function.method.instance,
key.accessibility: source.lang.swift.accessibility.public,
key.name: "deinit",
key.offset: 2636,
key.length: 9,
key.nameoffset: 2636,
key.namelength: 6,
key.bodyoffset: 2644,
key.bodylength: 0
}
]
}
]
},
{
key.kind: source.lang.swift.decl.protocol,
key.accessibility: source.lang.swift.accessibility.internal,
@@ -1578,50 +1478,6 @@
}
]
},
{
key.kind: source.lang.swift.decl.protocol,
key.accessibility: source.lang.swift.accessibility.internal,
key.name: "MyProtocol",
key.offset: 2780,
key.length: 71,
key.nameoffset: 2789,
key.namelength: 10,
key.bodyoffset: 2819,
key.bodylength: 31,
key.inheritedtypes: [
{
key.name: "NSObjectProtocol"
}
],
key.attributes: [
{
key.offset: 2774,
key.length: 5,
key.attribute: source.decl.attribute.objc
}
],
key.elements: [
{
key.kind: source.lang.swift.structure.elem.typeref,
key.offset: 2801,
key.length: 16
}
],
key.substructure: [
{
key.kind: source.lang.swift.decl.var.instance,
key.accessibility: source.lang.swift.accessibility.internal,
key.name: "thing",
key.offset: 2824,
key.length: 25,
key.typename: "NSObject",
key.nameoffset: 2828,
key.namelength: 5,
key.bodyoffset: 2845,
key.bodylength: 3
}
]
},
{
key.kind: source.lang.swift.decl.class,
key.accessibility: source.lang.swift.accessibility.internal,
@@ -1631,44 +1487,7 @@
key.nameoffset: 2866,
key.namelength: 1,
key.bodyoffset: 2869,
key.bodylength: 59,
key.substructure: [
{
key.kind: source.lang.swift.decl.function.method.instance,
key.accessibility: source.lang.swift.accessibility.internal,
key.name: "foo(a:)",
key.offset: 2899,
key.length: 19,
key.selector_name: "fooWithA:",
key.nameoffset: 2904,
key.namelength: 11,
key.bodyoffset: 2917,
key.bodylength: 0,
key.attributes: [
{
key.offset: 2893,
key.length: 5,
key.attribute: source.decl.attribute.objc.name
},
{
key.offset: 2883,
key.length: 9,
key.attribute: source.decl.attribute.ibaction
}
],
key.substructure: [
{
key.kind: source.lang.swift.decl.var.parameter,
key.name: "a",
key.offset: 2908,
key.length: 6,
key.typename: "Int",
key.nameoffset: 2908,
key.namelength: 1
}
]
}
]
key.bodylength: 59
}
],
key.diagnostics: [

View File

@@ -64,7 +64,7 @@
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.buildconfig.id,
key.kind: source.lang.swift.syntaxtype.identifier,
key.offset: 140,
key.length: 4
},
@@ -79,7 +79,7 @@
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.typeidentifier,
key.kind: source.lang.swift.syntaxtype.identifier,
key.offset: 153,
key.length: 3
},
@@ -99,7 +99,7 @@
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.typeidentifier,
key.kind: source.lang.swift.syntaxtype.identifier,
key.offset: 171,
key.length: 5
},

View File

@@ -357,17 +357,17 @@ let x = [
var array: [String] = []
#else
var array: [String] = {
return ["one",
"two"]
return ["one",
"two"]
}()
#endif
#if os(iOS)
var source: String? {
if true {
if otherCondition {
return "true"
}
}
if true {
if otherCondition {
return "true"
}
}
}
#endif

View File

@@ -37,7 +37,7 @@ func collatz(n: Int, m: String?) {
#if true
func foo() -> Int {
0
0
}
#else
1

View File

@@ -37,7 +37,7 @@ func collatz(n: Int, m: String?) {
#if true
func foo() -> Int {
0
0
}
#else
1

View File

@@ -37,7 +37,7 @@ func collatz(n: Int, m: String?) {
#if true
func foo() -> Int {
0
0
}
#else
1

View File

@@ -37,7 +37,7 @@ func collatz(n: Int, m: String?) {
#if true
func foo() -> Int {
0
0
}
#else
1

View File

@@ -1608,9 +1608,11 @@ private:
if (auto *ICD = dyn_cast<IfConfigDecl>(D)) {
// The base walker assumes the content of active IfConfigDecl clauses
// has been injected into the parent context and will be walked there.
// This doesn't hold for pre-typechecked ASTs and we need to find
// placeholders in inactive clauses anyway, so walk them here.
// This doesn't hold for pre-typechecked ASTs, so walk them here.
for (auto Clause: ICD->getClauses()) {
if (!Clause.isActive)
continue;
for (auto Elem: Clause.Elements) {
Elem.walk(*this);
}
@@ -1798,20 +1800,6 @@ private:
return Action::Continue(S);
}
PreWalkAction walkToDeclPre(Decl *D) override {
if (auto *ICD = dyn_cast<IfConfigDecl>(D)) {
for (auto Clause : ICD->getClauses()) {
// Active clase elements are visited normally.
if (Clause.isActive)
continue;
for (auto Member : Clause.Elements)
Member.walk(*this);
}
return Action::SkipNode();
}
return Action::Continue();
}
ArgumentList *findEnclosingCallArg(SourceFile &SF, SourceLoc SL) {
EnclosingCallAndArg = {nullptr, nullptr};
OuterExpr = nullptr;