-
-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the ability to add comment commands on the same line as an import…
… statement
- Loading branch information
Showing
3 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
Tests/Fixtures/Sources/DeclarationVisitorFixtures/ImportFixture.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import Foundation | ||
// periphery:ignore | ||
import CoreGraphics | ||
import Swift // periphery:ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import Foundation | ||
@testable import SourceGraph | ||
@testable import SyntaxAnalysis | ||
@testable import TestShared | ||
import XCTest | ||
|
||
final class ImportVisitTest: XCTestCase { | ||
private var results: [ImportStatement]! | ||
|
||
override func setUpWithError() throws { | ||
try super.setUpWithError() | ||
let multiplexingVisitor = try MultiplexingSyntaxVisitor(file: fixturePath) | ||
let visitor = multiplexingVisitor.add(ImportSyntaxVisitor.self) | ||
multiplexingVisitor.visit() | ||
results = visitor.importStatements | ||
} | ||
|
||
override func tearDown() { | ||
results = nil | ||
super.tearDown() | ||
} | ||
|
||
func testCommentCommands() { | ||
let expectedIgnored = ["CoreGraphics", "Swift"] | ||
let actualIgnored = results.filter { $0.commentCommands.contains(.ignore) }.map(\.module) | ||
XCTAssertEqual(actualIgnored, expectedIgnored, "Ignored modules did not match the expected set") | ||
|
||
let actualUnignored = results.filter { !$0.commentCommands.contains(.ignore) }.map(\.module) | ||
let expectedUnignored = ["Foundation"] | ||
XCTAssertEqual(actualUnignored, expectedUnignored, "Unignored modules did not match the expected set") | ||
} | ||
|
||
// MARK: - Private | ||
|
||
private var fixturePath: SourceFile { | ||
let path = FixturesProjectPath.appending("Sources/DeclarationVisitorFixtures/ImportFixture.swift") | ||
return SourceFile(path: path, modules: ["DeclarationVisitorFixtures"]) | ||
} | ||
|
||
private func fixtureLocation(line: Int, column: Int = 9) -> Location { | ||
Location(file: fixturePath, line: line, column: column) | ||
} | ||
} |