Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Fix SourceFile Visitor #51

Merged
merged 2 commits into from
Apr 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v1
- name: Build and Test
run: swift test
run: swift test -c release
env:
DEVELOPER_DIR: /Applications/Xcode_11.4.app/Contents/Developer

Expand All @@ -28,4 +28,4 @@ jobs:
apt-get update
apt-get install -y libxml2-dev
- name: Build and Test
run: swift test --enable-test-discovery
run: swift test -c release --enable-test-discovery
19 changes: 13 additions & 6 deletions Sources/SwiftDoc/SourceFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public struct SourceFile: Hashable, Codable {
visitedImports.append(`import`)
}

@discardableResult
func pop() -> Contextual? {
return context.popLast()
}
Expand Down Expand Up @@ -187,27 +188,33 @@ public struct SourceFile: Hashable, Codable {
// MARK: -

override func visitPost(_ node: ClassDeclSyntax) {
assert((pop() as? Symbol)?.api is Class)
let context = pop()
assert((context as? Symbol)?.api is Class)
}

override func visitPost(_ node: EnumDeclSyntax) {
assert((pop() as? Symbol)?.api is Enumeration)
let context = pop()
assert((context as? Symbol)?.api is Enumeration)
}

override func visitPost(_ node: ExtensionDeclSyntax) {
assert(pop() is Extension)
let context = pop()
assert(context is Extension)
}

override func visitPost(_ node: IfConfigClauseSyntax) {
assert(pop() is CompilationCondition)
let context = pop()
assert(context is CompilationCondition)
}

override func visitPost(_ node: ProtocolDeclSyntax) {
assert((pop() as? Symbol)?.api is Protocol)
let context = pop()
assert((context as? Symbol)?.api is Protocol)
}

override func visitPost(_ node: StructDeclSyntax) {
assert((pop() as? Symbol)?.api is Structure)
let context = pop()
assert((context as? Symbol)?.api is Structure)
}
}
}
2 changes: 1 addition & 1 deletion Tests/SwiftDocTests/SourceFileTests.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import XCTest

@testable import SwiftDoc
import SwiftDoc
import SwiftSemantics
import struct SwiftSemantics.Protocol
import SwiftSyntax
Expand Down