Skip to content

Commit 726825a

Browse files
committed
Renamed the library to SwiftSource
1 parent e721b34 commit 726825a

File tree

13 files changed

+69
-67
lines changed

13 files changed

+69
-67
lines changed

Package.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ let package = Package(
1313
.watchOS(.v6)
1414
],
1515
products: [
16-
.library(name: "SwiftDocCoverage", targets: ["SwiftDocCoverage"]),
16+
.library(name: "SwiftSource", targets: ["SwiftSource"]),
1717
.executable(name: "swift-doc-coverage", targets: ["swift-doc-coverage"])
1818
],
1919
dependencies: [
@@ -22,7 +22,7 @@ let package = Package(
2222
],
2323
targets: [
2424
.target(
25-
name: "SwiftDocCoverage",
25+
name: "SwiftSource",
2626
dependencies: [
2727
.product(name: "SwiftSyntax", package: "swift-syntax"),
2828
.product(name: "SwiftParser", package: "swift-syntax"),
@@ -31,7 +31,7 @@ let package = Package(
3131
.executableTarget(
3232
name: "swift-doc-coverage",
3333
dependencies: [
34-
.target(name: "SwiftDocCoverage"),
34+
.target(name: "SwiftSource"),
3535
.product(name: "ArgumentParser", package: "swift-argument-parser")
3636
]
3737
),

Sources/SwiftDocCoverage/Coverage.swift renamed to Sources/SwiftSource/Coverage.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ extension String : LocalizedError {
3030

3131
public struct Coverage {
3232
let urls: [URL]
33-
let minAccessLevel: AccessLevel
33+
let minAccessLevel: SwiftAccessLevel
3434
let output: Output
3535

3636
private static func files(path: String, ext: String, skipsHiddenFiles: Bool, ignoreFilenameRegex: String) throws -> [URL] {
@@ -42,7 +42,9 @@ public struct Coverage {
4242
if isDirectory.boolValue {
4343
var urls = [URL]()
4444

45-
let regex: NSRegularExpression? = ignoreFilenameRegex.isEmpty ? nil : try NSRegularExpression(pattern: ignoreFilenameRegex)
45+
let regex: NSRegularExpression? = ignoreFilenameRegex.isEmpty
46+
? nil
47+
: try NSRegularExpression(pattern: ignoreFilenameRegex)
4648

4749
let url = URL(fileURLWithPath: path)
4850
let resourceKeys = Set<URLResourceKey>([.nameKey, .isDirectoryKey])
@@ -86,7 +88,7 @@ public struct Coverage {
8688
return formatter
8789
}()
8890

89-
public init(paths: [String], skipsHiddenFiles: Bool = true, ignoreFilenameRegex: String = "", minAccessLevel: AccessLevel = .public, output: Output = TerminalOutput()) throws {
91+
public init(paths: [String], skipsHiddenFiles: Bool = true, ignoreFilenameRegex: String = "", minAccessLevel: SwiftAccessLevel = .public, output: Output = TerminalOutput()) throws {
9092
self.urls = try paths.flatMap {
9193
try Self.files(path: $0, ext: ".swift", skipsHiddenFiles: skipsHiddenFiles, ignoreFilenameRegex: ignoreFilenameRegex)
9294
}
@@ -126,7 +128,7 @@ public struct Coverage {
126128
try urls.forEach { url in
127129
let time = Date()
128130

129-
let source = try Source(url: url)
131+
let source = try SwiftSource(url: url)
130132

131133
guard source.declarations.count > 0 else {
132134
return

Sources/SwiftDocCoverage/DeclProtocol.swift renamed to Sources/SwiftSource/DeclProtocol.swift

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protocol DeclProtocol: DeclSyntaxProtocol {
2828

2929
// var attributes: AttributeListSyntax
3030
var modifiers: DeclModifierListSyntax { get }
31-
var keyword: Keyword { get }
31+
var keyword: SwiftKeyword { get }
3232
var name: TokenSyntax { get }
3333

3434
var genericParameterClause: GenericParameterClauseSyntax? { get }
@@ -43,50 +43,50 @@ extension DeclProtocol {
4343
var funcSignature: FunctionSignatureSyntax? { nil }
4444
var genericWhereClause: GenericWhereClauseSyntax? { nil }
4545

46-
var comments: [Comment] {
47-
leadingTrivia.compactMap { Comment(piece: $0) }
46+
var comments: [SwiftComment] {
47+
leadingTrivia.compactMap { SwiftComment(piece: $0) }
4848
}
49-
var accessLevel: AccessLevel { AccessLevel(modifiers: modifiers) }
49+
var accessLevel: SwiftAccessLevel { SwiftAccessLevel(modifiers: modifiers) }
5050
}
5151

5252
// MARK: -
5353

5454
extension TypeAliasDeclSyntax: DeclProtocol {
55-
var keyword: Keyword { .typealias }
55+
var keyword: SwiftKeyword { .typealias }
5656
}
5757

5858
extension AssociatedTypeDeclSyntax: DeclProtocol {
59-
var keyword: Keyword { .associatedtype }
59+
var keyword: SwiftKeyword { .associatedtype }
6060
}
6161

6262
extension ClassDeclSyntax: DeclProtocol {
63-
var keyword: Keyword { .class }
63+
var keyword: SwiftKeyword { .class }
6464
}
6565

6666
extension ActorDeclSyntax: DeclProtocol {
67-
var keyword: Keyword { .actor }
67+
var keyword: SwiftKeyword { .actor }
6868
}
6969

7070
extension StructDeclSyntax: DeclProtocol {
71-
var keyword: Keyword { .struct }
71+
var keyword: SwiftKeyword { .struct }
7272
}
7373

7474
extension ProtocolDeclSyntax: DeclProtocol {
75-
var keyword: Keyword { .protocol }
75+
var keyword: SwiftKeyword { .protocol }
7676
}
7777

7878
extension ExtensionDeclSyntax: DeclProtocol {
79-
var keyword: Keyword { .extension }
79+
var keyword: SwiftKeyword { .extension }
8080
var name: TokenSyntax { TokenSyntax(.identifier(extendedType.trimmedDescription), presence: .present)}
8181
}
8282

8383
extension FunctionDeclSyntax: DeclProtocol {
84-
var keyword: Keyword { .func }
84+
var keyword: SwiftKeyword { .func }
8585
var funcSignature: FunctionSignatureSyntax? { signature }
8686
}
8787

8888
extension InitializerDeclSyntax: DeclProtocol {
89-
var keyword: Keyword { .`init` }
89+
var keyword: SwiftKeyword { .`init` }
9090

9191
var name: TokenSyntax {
9292
let optionalMark = optionalMark?.trimmedDescription ?? ""
@@ -97,7 +97,7 @@ extension InitializerDeclSyntax: DeclProtocol {
9797
}
9898

9999
extension SubscriptDeclSyntax: DeclProtocol {
100-
var keyword: Keyword { .subscript }
100+
var keyword: SwiftKeyword { .subscript }
101101

102102
var name: TokenSyntax {
103103
TokenSyntax(.identifier("subscript"), presence: .present)
@@ -109,7 +109,7 @@ extension SubscriptDeclSyntax: DeclProtocol {
109109
}
110110

111111
extension VariableDeclSyntax: DeclProtocol {
112-
var keyword: Keyword { Keyword(token: bindingSpecifier)! }
112+
var keyword: SwiftKeyword { SwiftKeyword(token: bindingSpecifier)! }
113113

114114
var name: TokenSyntax {
115115
let name = bindings.map { $0.pattern.trimmedDescription }.joined(separator: ",")
@@ -118,11 +118,11 @@ extension VariableDeclSyntax: DeclProtocol {
118118
}
119119

120120
extension EnumDeclSyntax: DeclProtocol {
121-
var keyword: Keyword { .enum }
121+
var keyword: SwiftKeyword { .enum }
122122
}
123123

124124
extension EnumCaseDeclSyntax: DeclProtocol {
125-
var keyword: Keyword { .case }
125+
var keyword: SwiftKeyword { .case }
126126

127127
var name: TokenSyntax {
128128
let name = elements.map {
@@ -135,10 +135,10 @@ extension EnumCaseDeclSyntax: DeclProtocol {
135135
}
136136

137137
extension PrecedenceGroupDeclSyntax: DeclProtocol {
138-
var keyword: Keyword { .precedencegroup }
138+
var keyword: SwiftKeyword { .precedencegroup }
139139
}
140140

141141
extension MacroDeclSyntax: DeclProtocol {
142-
var keyword: Keyword { .macro }
142+
var keyword: SwiftKeyword { .macro }
143143
var funcSignature: FunctionSignatureSyntax? { signature }
144144
}
File renamed without changes.
File renamed without changes.

Sources/SwiftDocCoverage/AccessLevel.swift renamed to Sources/SwiftSource/SwiftAccessLevel.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// AccessLevel.swift
1+
// SwiftAccessLevel.swift
22
//
33
// Created by Iurii Khvorost <iurii.khvorost@gmail.com> on 11.02.2022.
44
// Copyright © 2022 Iurii Khvorost. All rights reserved.
@@ -24,7 +24,7 @@
2424
import SwiftSyntax
2525

2626

27-
public enum AccessLevel: Int {
27+
public enum SwiftAccessLevel: Int {
2828
case `open`
2929
case `public`
3030
case `internal`
@@ -53,7 +53,7 @@ public enum AccessLevel: Int {
5353
continue
5454
}
5555

56-
if let accessLevel = AccessLevel(token: modifier.name) {
56+
if let accessLevel = SwiftAccessLevel(token: modifier.name) {
5757
self = accessLevel
5858
return
5959
}

Sources/SwiftDocCoverage/Comment.swift renamed to Sources/SwiftSource/SwiftComment.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Comment.swift
1+
// SwiftComment.swift
22
//
33
// Created by Iurii Khvorost <iurii.khvorost@gmail.com> on 11.02.2024.
44
// Copyright © 2022 Iurii Khvorost. All rights reserved.
@@ -24,7 +24,7 @@
2424
import SwiftSyntax
2525

2626

27-
public struct Comment {
27+
public struct SwiftComment {
2828
private let piece: TriviaPiece
2929

3030
public var text: String {

Sources/SwiftDocCoverage/Declaration.swift renamed to Sources/SwiftSource/SwiftDeclaration.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Declaration.swift
1+
// SwiftDeclaration.swift
22
//
33
// Created by Iurii Khvorost <iurii.khvorost@gmail.com> on 09.08.2022.
44
// Copyright © 2022 Iurii Khvorost. All rights reserved.
@@ -35,10 +35,10 @@ fileprivate struct StringBuilder {
3535
}
3636
}
3737

38-
public struct Declaration {
39-
public let comments: [Comment]
40-
public let accessLevel: AccessLevel
41-
public var keyword: Keyword
38+
public struct SwiftDeclaration {
39+
public let comments: [SwiftComment]
40+
public let accessLevel: SwiftAccessLevel
41+
public var keyword: SwiftKeyword
4242
public let name: String
4343
public let line: Int
4444
public let column: Int

Sources/SwiftDocCoverage/Keyword.swift renamed to Sources/SwiftSource/SwiftKeyword.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Keyword.swift
1+
// SwiftKeyword.swift
22
//
33
// Created by Iurii Khvorost <iurii.khvorost@gmail.com> on 11.02.2024.
44
// Copyright © 2022 Iurii Khvorost. All rights reserved.
@@ -24,7 +24,7 @@
2424
import SwiftSyntax
2525

2626

27-
public enum Keyword: String {
27+
public enum SwiftKeyword: String {
2828
case actor
2929
case `associatedtype`
3030
case `case`

Sources/SwiftDocCoverage/Source.swift renamed to Sources/SwiftSource/SwiftSource.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Source.swift
1+
// SwiftSource.swift
22
//
33
// Created by Iurii Khvorost <iurii.khvorost@gmail.com> on 08.08.2022.
44
// Copyright © 2022 Iurii Khvorost. All rights reserved.
@@ -25,9 +25,9 @@ import Foundation
2525
import SwiftSyntax
2626

2727

28-
public struct Source {
28+
public struct SwiftSource {
2929
public let url: URL?
30-
public let declarations: [Declaration]
30+
public let declarations: [SwiftDeclaration]
3131

3232
private init(url: URL?, source: String) {
3333
self.url = url

0 commit comments

Comments
 (0)