Skip to content

Commit fd99060

Browse files
committed
more internal types
1 parent fb9fb3f commit fd99060

10 files changed

+30
-63
lines changed

Sources/SyntaxKit/Collections/ArrayLiteral.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,21 @@ import Foundation
3131

3232
/// An array literal value that can be used as a literal.
3333
internal struct ArrayLiteral: LiteralValue, CodeBlockable {
34-
let elements: [Literal]
34+
internal let elements: [Literal]
3535

3636
/// Creates an array with the given elements.
3737
/// - Parameter elements: The array elements.
38-
init(_ elements: [Literal]) {
38+
internal init(_ elements: [Literal]) {
3939
self.elements = elements
4040
}
4141

4242
/// The code block representation of this array literal.
43-
var codeBlock: CodeBlock {
43+
internal var codeBlock: CodeBlock {
4444
Literal.array(elements)
4545
}
4646

4747
/// The Swift type name for this array.
48-
var typeName: String {
48+
internal var typeName: String {
4949
if elements.isEmpty {
5050
return "[Any]"
5151
}
@@ -54,7 +54,7 @@ internal struct ArrayLiteral: LiteralValue, CodeBlockable {
5454
}
5555

5656
/// Renders this array as a Swift literal string.
57-
var literalString: String {
57+
internal var literalString: String {
5858
let elementStrings = elements.map { element in
5959
switch element {
6060
case .integer(let value): return String(value)

Sources/SyntaxKit/Collections/TupleLiteralProtocol.swift renamed to Sources/SyntaxKit/Collections/CodeBlockableLiteral.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// TupleLiteralProtocol.swift
2+
// CodeBlockableLiteral.swift
33
// SyntaxKit
44
//
55
// Created by Leo Dion.
@@ -30,4 +30,4 @@
3030
import Foundation
3131

3232
/// A protocol for tuple literal values that can be used as literals.
33-
public typealias TupleLiteralProtocol = LiteralValue & CodeBlockable
33+
public typealias CodeBlockableLiteral = LiteralValue & CodeBlockable

Sources/SyntaxKit/Collections/DictionaryLiteral.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,21 @@ import Foundation
3131

3232
/// A dictionary literal value that can be used as a literal.
3333
internal struct DictionaryLiteral: LiteralValue, CodeBlockable {
34-
let elements: [(Literal, Literal)]
34+
internal let elements: [(Literal, Literal)]
3535

3636
/// Creates a dictionary with the given key-value pairs.
3737
/// - Parameter elements: The dictionary key-value pairs.
38-
init(_ elements: [(Literal, Literal)]) {
38+
internal init(_ elements: [(Literal, Literal)]) {
3939
self.elements = elements
4040
}
4141

4242
/// The code block representation of this dictionary literal.
43-
var codeBlock: CodeBlock {
43+
internal var codeBlock: CodeBlock {
4444
Literal.dictionary(elements)
4545
}
4646

4747
/// The Swift type name for this dictionary.
48-
var typeName: String {
48+
internal var typeName: String {
4949
if elements.isEmpty {
5050
return "[Any: Any]"
5151
}
@@ -55,7 +55,7 @@ internal struct DictionaryLiteral: LiteralValue, CodeBlockable {
5555
}
5656

5757
/// Renders this dictionary as a Swift literal string.
58-
var literalString: String {
58+
internal var literalString: String {
5959
let elementStrings = elements.map { key, value in
6060
let keyString: String
6161
let valueString: String

Sources/SyntaxKit/Collections/TuplePatternCodeBlock.swift renamed to Sources/SyntaxKit/Collections/PatternConvertableCollection.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// TuplePatternCodeBlock.swift
2+
// PatternConvertableCollection.swift
33
// SyntaxKit
44
//
55
// Created by Leo Dion.
@@ -30,14 +30,14 @@
3030
import SwiftSyntax
3131

3232
/// A tuple pattern that can be used as a CodeBlock for for-in loops.
33-
internal struct TuplePatternCodeBlock: PatternCodeBlock {
33+
internal struct PatternConvertableCollection: PatternCodeBlock {
3434
private let elements: [PatternConvertible?]
3535

3636
internal init(elements: [PatternConvertible?]) {
3737
self.elements = elements
3838
}
3939

40-
var patternSyntax: PatternSyntax {
40+
internal var patternSyntax: PatternSyntax {
4141
let patternElements = TuplePatternElementListSyntax(
4242
elements.enumerated().map { index, element in
4343
let patternElement: TuplePatternElementSyntax
@@ -70,7 +70,7 @@ internal struct TuplePatternCodeBlock: PatternCodeBlock {
7070
)
7171
}
7272

73-
var syntax: SyntaxProtocol {
73+
internal var syntax: SyntaxProtocol {
7474
// For CodeBlock conformance, we return the pattern syntax as an expression
7575
// This is a bit of a hack, but it allows us to use TuplePatternCodeBlock in For loops
7676
patternSyntax

Sources/SyntaxKit/Collections/Tuple.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public struct Tuple: CodeBlock {
5050
/// Creates a tuple pattern that can be used as a CodeBlock.
5151
/// - Parameter elements: Array of pattern elements, where `nil` represents a wildcard pattern.
5252
public static func patternCodeBlock(_ elements: [PatternConvertible?]) -> PatternCodeBlock {
53-
TuplePatternCodeBlock(elements: elements)
53+
PatternConvertableCollection(elements: elements)
5454
}
5555

5656
/// Marks this tuple as async.

Sources/SyntaxKit/Collections/TupleAssignment.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,37 +42,37 @@ internal struct TupleAssignment: CodeBlock {
4242
/// - Parameters:
4343
/// - elements: The names of the variables to destructure into.
4444
/// - value: The expression to destructure.
45-
init(_ elements: [String], equals value: CodeBlock) {
45+
internal init(_ elements: [String], equals value: CodeBlock) {
4646
self.elements = elements
4747
self.value = value
4848
}
4949

5050
/// Marks this destructuring as async.
5151
/// - Returns: A copy of the destructuring marked as async.
52-
func async() -> Self {
52+
internal func async() -> Self {
5353
var copy = self
5454
copy.isAsync = true
5555
return copy
5656
}
5757

5858
/// Marks this destructuring as throwing.
5959
/// - Returns: A copy of the destructuring marked as throwing.
60-
func throwing() -> Self {
60+
internal func throwing() -> Self {
6161
var copy = self
6262
copy.isThrowing = true
6363
return copy
6464
}
6565

6666
/// Marks this destructuring as concurrent async (async let set).
6767
/// - Returns: A copy of the destructuring marked as async set.
68-
func asyncSet() -> Self {
68+
internal func asyncSet() -> Self {
6969
var copy = self
7070
copy.isAsyncSet = true
7171
return copy
7272
}
7373

7474
/// The syntax representation of this tuple assignment.
75-
var syntax: SyntaxProtocol {
75+
internal var syntax: SyntaxProtocol {
7676
if isAsyncSet {
7777
return generateAsyncSetSyntax()
7878
}

Sources/SyntaxKit/Collections/TupleLiteralArray.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,22 @@ import Foundation
3131
import SwiftSyntax
3232

3333
/// A tuple literal value that can be used as a literal.
34-
internal struct TupleLiteralArray: TupleLiteralProtocol {
35-
let elements: [Literal?]
34+
internal struct TupleLiteralArray: CodeBlockableLiteral {
35+
internal let elements: [Literal?]
3636

3737
/// Creates a tuple with the given elements.
3838
/// - Parameter elements: The tuple elements, where `nil` represents a wildcard.
39-
init(_ elements: [Literal?]) {
39+
internal init(_ elements: [Literal?]) {
4040
self.elements = elements
4141
}
4242

4343
/// The code block representation of this tuple literal.
44-
var codeBlock: CodeBlock {
44+
internal var codeBlock: CodeBlock {
4545
Literal.tuple(elements)
4646
}
4747

4848
/// The Swift type name for this tuple.
49-
var typeName: String {
49+
internal var typeName: String {
5050
let elementTypes = elements.map { element in
5151
if let element = element {
5252
switch element {
@@ -68,7 +68,7 @@ internal struct TupleLiteralArray: TupleLiteralProtocol {
6868
}
6969

7070
/// Renders this tuple as a Swift literal string.
71-
var literalString: String {
71+
internal var literalString: String {
7272
let elementStrings = elements.map { element in
7373
if let element = element {
7474
switch element {

Sources/SyntaxKit/Collections/TuplePattern.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ internal struct TuplePattern: PatternConvertible {
3737
self.elements = elements
3838
}
3939

40-
var patternSyntax: PatternSyntax {
40+
internal var patternSyntax: PatternSyntax {
4141
let patternElements = TuplePatternElementListSyntax(
4242
elements.enumerated().map { index, element in
4343
let patternElement: TuplePatternElementSyntax

Sources/SyntaxKit/Collections/TuplePatternCodeBlockProtocol.swift

Lines changed: 0 additions & 33 deletions
This file was deleted.

Sources/SyntaxKit/Expressions/Literal+Convenience.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extension Literal {
4343
}
4444

4545
/// Converts a Literal.tuple to a TupleLiteral for use in Variable declarations.
46-
public var asTupleLiteral: TupleLiteralProtocol? {
46+
public var asTupleLiteral: CodeBlockableLiteral? {
4747
switch self {
4848
case .tuple(let elements):
4949
return TupleLiteralArray(elements)

0 commit comments

Comments
 (0)