Skip to content

Commit ba17c72

Browse files
committed
Only check for Playgrounds import at end of parsing
1 parent ec8512c commit ba17c72

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Sources/SwiftLanguageService/PlaygroundsMacro.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ final class PlaygroundMacroFinder: SyntaxAnyVisitor {
4848
private var result: [PlaygroundItem] = []
4949

5050
/// Keep track of if "Playgrounds" has been imported
51-
private var isPlaygroundImported: Bool = false
51+
fileprivate var isPlaygroundImported: Bool = false
5252

5353
private init(baseID: String, snapshot: DocumentSnapshot) {
5454
self.baseID = baseID
@@ -70,7 +70,7 @@ final class PlaygroundMacroFinder: SyntaxAnyVisitor {
7070
}
7171
let visitor = PlaygroundMacroFinder(baseID: "\(moduleName)/\(baseName)", snapshot: snapshot)
7272
visitor.walk(node)
73-
return visitor.result
73+
return visitor.isPlaygroundImported ? visitor.result : []
7474
}
7575

7676
/// Add a playground location with the given parameters to the `result` array.
@@ -99,7 +99,7 @@ final class PlaygroundMacroFinder: SyntaxAnyVisitor {
9999
}
100100

101101
override func visit(_ node: MacroExpansionExprSyntax) -> SyntaxVisitorContinueKind {
102-
guard isPlaygroundImported, node.macroName.text == "Playground" else {
102+
guard node.macroName.text == "Playground" else {
103103
return .skipChildren
104104
}
105105

0 commit comments

Comments
 (0)