Skip to content
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
8 changes: 4 additions & 4 deletions SwiftEvolve/Sources/SwiftEvolve/AnyEvolution.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import SwiftSyntax

struct AnyEvolution {
public struct AnyEvolution {
var value: Evolution

init(_ value: Evolution) {
Expand All @@ -31,7 +31,7 @@ struct AnyEvolution {
}

extension AnyEvolution: CustomStringConvertible {
var description: String {
public var description: String {
return String(describing: value)
}
}
Expand All @@ -44,7 +44,7 @@ extension AnyEvolution: Codable {
case value
}

init(from decoder: Decoder) throws {
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)

let kind = try container.decode(Kind.self, forKey: .kind)
Expand All @@ -53,7 +53,7 @@ extension AnyEvolution: Codable {

}

func encode(to encoder: Encoder) throws {
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)

try container.encode(value.kind, forKey: .kind)
Expand Down
4 changes: 2 additions & 2 deletions SwiftEvolve/Sources/SwiftEvolve/CommandLine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ enum CommandLineError: Error, CustomStringConvertible {
}

extension SwiftEvolveTool.Step {
init(arguments: [String]) throws {
public init(arguments: [String]) throws {
let command = arguments.first!
let rest = Array(arguments.dropFirst())

Expand Down Expand Up @@ -126,7 +126,7 @@ extension SwiftEvolveTool.Step: CustomStringConvertible {
}
}

var description: String {
public var description: String {
return arguments.map { $0.shellEscaped }.joined(separator: " ")
}
}
Expand Down
60 changes: 30 additions & 30 deletions SwiftEvolve/Sources/SwiftEvolve/DeclContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ private func makeName(from declarationChain: [Decl]) -> String {
return declarationChain.map { $0.name }.joined(separator: ".")
}

struct DeclContext {
public struct DeclContext {
private(set) var name: String

var declarationChain: [Decl] = [] {
didSet { name = makeName(from: declarationChain) }
}

init(declarationChain: [Decl] = []) {
public init(declarationChain: [Decl] = []) {
self.declarationChain = declarationChain
name = makeName(from: declarationChain)
}
Expand Down Expand Up @@ -64,7 +64,7 @@ struct DeclContext {
}

extension DeclContext: CustomStringConvertible {
var description: String {
public var description: String {
return name
}

Expand Down Expand Up @@ -112,7 +112,7 @@ extension DeclContext {
}
}

enum AccessLevel: String {
public enum AccessLevel: String {
case `private`, `fileprivate`, `internal`, `public`, `open`
}

Expand All @@ -137,7 +137,7 @@ extension SyntaxProtocol {
}
}

protocol Decl {
public protocol Decl {
/// We do the same trick here that SwiftSyntax does with `SyntaxProtocol` and
/// `Syntax`. Picking the same name that is already used by SyntaxProtocol
/// means we don't have to reimplement the property in terms of Syntax(self).
Expand All @@ -153,7 +153,7 @@ protocol Decl {
func lookupDirect(_ name: String) -> Decl?
}

extension Decl {
public extension Decl {
var isResilient: Bool { return true }
var isStored: Bool { return false }

Expand All @@ -162,7 +162,7 @@ extension Decl {
}
}

extension Decl where Self: DeclWithMembers {
public extension Decl where Self: DeclWithMembers {
func lookupDirect(_ name: String) -> Decl? {
for item in members.members {
guard let member = item.decl.asDecl else { continue }
Expand All @@ -174,7 +174,7 @@ extension Decl where Self: DeclWithMembers {
}
}

extension Decl where Self: AbstractFunctionDecl {
public extension Decl where Self: AbstractFunctionDecl {
func lookupDirect(_ name: String) -> Decl? {
guard let body = self.body else { return nil }
for item in body.statements {
Expand All @@ -188,11 +188,11 @@ extension Decl where Self: AbstractFunctionDecl {
}

extension SourceFileSyntax: Decl {
var name: String { return "(file)" }
public var name: String { return "(file)" }

var modifiers: ModifierListSyntax? { return nil }
public var modifiers: ModifierListSyntax? { return nil }

func lookupDirect(_ name: String) -> Decl? {
public func lookupDirect(_ name: String) -> Decl? {
for item in statements {
guard let decl = item.item.asDecl else { continue }
if decl.name == name {
Expand All @@ -204,63 +204,63 @@ extension SourceFileSyntax: Decl {
}

extension ClassDeclSyntax: Decl {
var name: String {
public var name: String {
return identifier.text
}

var isResilient: Bool {
public var isResilient: Bool {
return !attributes.contains(named: "_fixed_layout")
}
}

extension StructDeclSyntax: Decl {
var name: String {
public var name: String {
return identifier.text
}

var isResilient: Bool {
public var isResilient: Bool {
return !attributes.contains(named: "_fixed_layout")
}
}

extension EnumDeclSyntax: Decl {
var name: String {
public var name: String {
return identifier.text
}

var isResilient: Bool {
public var isResilient: Bool {
return !attributes.contains(named: "_frozen")
}
}

extension ProtocolDeclSyntax: Decl {
var name: String {
public var name: String {
return identifier.text
}
}

extension ExtensionDeclSyntax: Decl {
var name: String {
public var name: String {
return "(extension \(extendedType.typeText))"
}
}

extension TypealiasDeclSyntax: Decl {
var name: String {
public var name: String {
return identifier.text
}

func lookupDirect(_ name: String) -> Decl? {
public func lookupDirect(_ name: String) -> Decl? {
fatalError("Not implemented: \(type(of: self)).lookupDirect(_:)")
}
}

extension AssociatedtypeDeclSyntax: Decl {
var name: String {
public var name: String {
return identifier.text
}

func lookupDirect(_ name: String) -> Decl? {
public func lookupDirect(_ name: String) -> Decl? {
fatalError("Not implemented: \(type(of: self)).lookupDirect(_:)")
}
}
Expand All @@ -270,7 +270,7 @@ extension FunctionDeclSyntax: Decl {}
extension InitializerDeclSyntax: Decl {}

extension SubscriptDeclSyntax: Decl {
func lookupDirect(_ name: String) -> Decl? {
public func lookupDirect(_ name: String) -> Decl? {
fatalError("Not implemented: \(type(of: self)).lookupDirect(_:)")
}
}
Expand Down Expand Up @@ -342,7 +342,7 @@ extension VariableDeclSyntax: Decl {
}
}

var name: String {
public var name: String {
let list = boundProperties
if list.count == 1 { return list.first!.name.text }
let nameList = list.map { $0.name.text }
Expand All @@ -364,7 +364,7 @@ extension VariableDeclSyntax: Decl {

// FIXME: Is isResilient == true correct?

var isStored: Bool {
public var isStored: Bool {
// FIXME: It's wrong to describe the whole decl as stored or not stored;
// each individual binding (or, arguably, each individual bound property)
// is stored or not stored.
Expand Down Expand Up @@ -397,7 +397,7 @@ extension VariableDeclSyntax: Decl {
}
}

func lookupDirect(_ name: String) -> Decl? {
public func lookupDirect(_ name: String) -> Decl? {
return nil
}
}
Expand All @@ -418,7 +418,7 @@ extension EnumCaseElementSyntax {
}

extension EnumCaseDeclSyntax: Decl {
var name: String {
public var name: String {
if elements.count == 1 {
return elements.first!.name
}
Expand All @@ -427,11 +427,11 @@ extension EnumCaseDeclSyntax: Decl {
}
}

var isStored: Bool {
public var isStored: Bool {
return true
}

func lookupDirect(_ name: String) -> Decl? {
public func lookupDirect(_ name: String) -> Decl? {
return nil
}
}
Expand Down
Loading