Commit 428e6672 authored by Drew's avatar Drew

Swift snapshot swift-DEVELOPMENT-SNAPSHOT-2016-03-16-a

parent 8347abdf
......@@ -25,7 +25,7 @@ public func collectSources(sourceDescriptions: [String], taskForCalculatingPath
if description.hasSuffix("**.swift") {
let basepath = String(Array(description.characters)[0..<description.characters.count - 9])
let manager = NSFileManager.defaultManager()
guard let enumerator = manager.enumeratorAtPath(basepath) else {
guard let enumerator = manager.enumerator(atPath: basepath) else {
fatalError("Invalid path \(basepath)")
}
while let source_ns = enumerator.nextObject() as? NSString {
......
......@@ -33,3 +33,36 @@ extension NSString {
#endif
}
}
// These parts of the "great swift renaming" are not yet implemented on Linux
#if os(Linux)
extension NSCharacterSet {
class func letter() -> NSCharacterSet {
return self.letterCharacterSet()
}
class func whitespace() -> NSCharacterSet {
return self.whitespaceCharacterSet()
}
}
extension NSFileManager {
func enumerator(atPath path: String) -> NSDirectoryEnumerator? {
return self.enumeratorAtPath(path)
}
func createDirectory(atPath path: String, withIntermediateDirectories createIntermediates: Bool, attributes: [String : AnyObject]? = [:]) throws {
return try self.createDirectoryAtPath(path, withIntermediateDirectories: createIntermediates, attributes: attributes)
}
func attributesOfItem(atPath path: String) throws -> [String : Any] {
return try self.attributesOfItemAtPath(path)
}
func removeItem(atPath path: String) throws {
return try self.removeItemAtPath(path)
}
}
extension NSString {
var deletingLastPathComponent: String {
return self.stringByDeletingLastPathComponent
}
}
#endif
\ No newline at end of file
......@@ -13,7 +13,7 @@
// limitations under the License.
import Foundation
enum PackageError: ErrorType {
enum PackageError: ErrorProtocol {
case NonVectorImport
case ParserFailed
case NonPackage
......@@ -39,7 +39,7 @@ private extension Task {
existingValue = []
}
var newValue = existingValue
newValue.appendContentsOf(vectorValue)
newValue.append(contentsOf: vectorValue)
self[optionName] = ParseValue.Vector(newValue)
//apply overlays to the model property
if optionName == "use-overlays" {
......@@ -157,7 +157,7 @@ final public class Package {
guard let parser = Parser(filepath: filepath) else { throw PackageError.ParserFailed }
let result = try parser.parse()
let basepath = filepath.toNSString.stringByDeletingLastPathComponent
let basepath = filepath.toNSString.deletingLastPathComponent
try self.init(type: result, overlay: overlay, pathOnDisk:basepath, focusOnTask: focusOnTask)
}
......@@ -201,7 +201,7 @@ final public class Package {
}
for importFile in imports {
guard let importFileString = importFile.string else { fatalError("Non-string import \(importFile)")}
let adjustedImportPath = (pathOnDisk.pathWithTrailingSlash + importFileString).toNSString.stringByDeletingLastPathComponent.pathWithTrailingSlash
let adjustedImportPath = (pathOnDisk.pathWithTrailingSlash + importFileString).toNSString.deletingLastPathComponent.pathWithTrailingSlash
let adjustedFileName = importFileString.toNSString.lastPathComponent
let remotePackage = try Package(filepath: adjustedImportPath + adjustedFileName, overlay: requestedGlobalOverlays, focusOnTask: nil)
remotePackage.adjustedImportPath = adjustedImportPath
......
......@@ -14,7 +14,7 @@
import Foundation
public enum ParseError: ErrorType {
public enum ParseError: ErrorProtocol {
case InvalidPackageFile
case ExpectedTokenType(TokenType, Token?)
case InvalidTokenForValueType(Token?)
......
......@@ -64,15 +64,15 @@ func isCharacterPartOfSet(c: Character?, set: NSCharacterSet) -> Bool {
}
func isValidIdentifierSignalCharacter(c: Character?) -> Bool {
return isCharacterPartOfSet(c, set: NSCharacterSet.letterCharacterSet())
return isCharacterPartOfSet(c, set: NSCharacterSet.letter())
}
func isValidIdenitifierCharacter(c: Character?) -> Bool {
return isCharacterPartOfSet(c, set: NSCharacterSet.letterCharacterSet()) || c == "-" || c == "." || c == "/"
return isCharacterPartOfSet(c, set: NSCharacterSet.letter()) || c == "-" || c == "." || c == "/"
}
func isWhitespace(c: Character?) -> Bool {
return isCharacterPartOfSet(c, set: NSCharacterSet.whitespaceCharacterSet())
return isCharacterPartOfSet(c, set: NSCharacterSet.whitespace())
}
final public class Lexer {
......
......@@ -16,7 +16,7 @@
import Foundation
extension String : ErrorType {}
extension String : ErrorTypeCompatibility {}
enum test {
static func assert(condition: Bool, file: String = #file, functionName: String = #function, line: Int = #line) throws {
......
......@@ -19,7 +19,7 @@ import atpkg
func outputBaseline(lexer: Lexer) {
print("--- baseline ---")
while let token = lexer.next() {
let type = String(reflecting: token.type).stringByReplacingOccurrencesOfString("atpkgparser.", withString: "")
let type = String(reflecting: token.type).replacingOccurrences(of: "atpkgparser.", with: "")
var value = ""
switch token.type {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment