Some more cleaning along with one more compile test case.

This commit is contained in:
Matyáš Kříž 2019-05-29 20:06:10 +02:00
parent fe3af6709e
commit b3fd0dacfd
4 changed files with 15 additions and 11 deletions

View File

@ -19,7 +19,7 @@ public struct FileRepresentation {
}
public extension FileRepresentation {
public func mergeInheritance(with files: [FileRepresentation]) -> FileRepresentation {
func mergeInheritance(with files: [FileRepresentation]) -> FileRepresentation {
let tokens = self.declarations.reduce([Token]()) { list, token in
let mergeToken = token.mergeInheritance(with: files)
return list + [mergeToken]
@ -29,8 +29,8 @@ public extension FileRepresentation {
}
}
internal extension Token {
internal func mergeInheritance(with files: [FileRepresentation]) -> Token {
extension Token {
func mergeInheritance(with files: [FileRepresentation]) -> Token {
guard let typeToken = self as? ContainerToken else {
return self
}
@ -39,7 +39,7 @@ internal extension Token {
.compactMap { $0.mergeInheritance(with: files) }
// Merge super declarations
let mergedTokens = inheritedRepresentations.filter { $0.isClassOrProtocolDefinition }
let mergedTokens = inheritedRepresentations.filter { $0.isClassOrProtocolDeclaration }
.map { $0 as! ContainerToken }
.flatMap { $0.children }
.reduce(typeToken.children) { tokens, inheritedToken in
@ -59,9 +59,9 @@ internal extension Token {
}
}
internal static func findToken(forClassOrProtocol name: String, in files: [FileRepresentation]) -> Token? {
static func findToken(forClassOrProtocol name: String, in files: [FileRepresentation]) -> Token? {
return files.flatMap { $0.declarations }
.filter { $0.isClassOrProtocolDefinition }
.filter { $0.isClassOrProtocolDeclaration }
.map { $0 as! ContainerToken }
.first { $0.name == name }
}

View File

@ -28,7 +28,7 @@ public struct MethodParameter: Token, Equatable {
public func isEqual(to other: Token) -> Bool {
guard let other = other as? MethodParameter else { return false }
return self.type == other.type && self.label == other.label
return label == other.label && type == other.type
}
public var isClosure: Bool {

View File

@ -27,11 +27,11 @@ public extension Token {
return serialized
}
var isClassOrProtocolDefinition: Bool {
var isClassOrProtocolDeclaration: Bool {
return self is ProtocolDeclaration || self is ClassDeclaration
}
var isInheritanceDefinition: Bool {
var isInheritanceDeclaration: Bool {
return self is InheritanceDeclaration
}
}

View File

@ -69,13 +69,17 @@ protocol OnlyLabelProtocol {
func empty(_: String)
func some(some: Int) -> [Int]
func double(here there: Bool)
}
class OnlyLabelClass: OnlyLabelProtocol {
func empty(_ mine: String) {
}
func some(some none: Int) -> [Int] {
return []
func some(some none: Int) {
}
func double(here notInHere: Bool) {
}
}