Skip to content

Commit 2a55c03

Browse files
committed
Fix ignore comments on protocol declarations. Closes #248
1 parent 6306852 commit 2a55c03

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
##### Bug Fixes
1212

13-
- None.
13+
- Fix ignore comments on protocol declarations.
1414

1515
## 2.4.0 (2020-12-19)
1616

Sources/PeripheryKit/Syntax/MetadataParser.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class MetadataParser: SyntaxVisitor {
5959
trivia: node.leadingTrivia,
6060
at: node.identifier.position
6161
)
62-
return .skipChildren
62+
return .visitChildren
6363
}
6464

6565
override func visit(_ node: StructDeclSyntax) -> SyntaxVisitorContinueKind {

Tests/PeripheryTests/RetentionTest.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,17 @@ class RetentionTest: SourceGraphTestCase {
10851085
XCTAssertReferenced((.varParameter, "param"), descendentOf: (.functionMethodInstance, "someFunc(param:)"))
10861086
XCTAssertReferenced((.varParameter, "b"))
10871087
XCTAssertReferenced((.varParameter, "c"))
1088+
1089+
XCTAssertReferenced(
1090+
(.varParameter, "param"),
1091+
descendentOf:
1092+
(.functionMethodInstance, "protocolFunc(param:)"),
1093+
(.protocol, "Fixture114Protocol"))
1094+
XCTAssertReferenced(
1095+
(.varParameter, "param"),
1096+
descendentOf:
1097+
(.functionMethodInstance, "protocolFunc(param:)"),
1098+
(.class, "Fixture114"))
10881099
}
10891100
}
10901101

Tests/RetentionFixtures/testIgnoreComments.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ public class Fixture113 {
77
}
88
}
99

10+
public protocol Fixture114Protocol {
11+
// periphery:ignore:parameters param
12+
func protocolFunc(param: String)
13+
}
14+
1015
public class Fixture114 {
1116
func referencedFunc() {}
1217

@@ -15,3 +20,8 @@ public class Fixture114 {
1520
print(a)
1621
}
1722
}
23+
24+
extension Fixture114: Fixture114Protocol {
25+
// param is ignored becuse the protocol ignores it.
26+
public func protocolFunc(param: String) {}
27+
}

0 commit comments

Comments
 (0)