textmate / swift.tmbundle

TextMate support for Swift
72 stars 30 forks source link

Minor fixes for Swift 1.0 & 2.0 #13

Closed natecook1000 closed 9 years ago

natecook1000 commented 9 years ago

This adds several keywords (access modifiers, new Swift 2.0 features, etc.) that have come to Swift since the last syntax update, and fixes the problem where the formatting disappears after foo in this code sample:

protocol A {
    func foo(x: String) -> Int
}

let bar = "This is unformatted."
let baz = foo("So is this.")

struct B : A {
    let y = "Formatting has resumed!"

    func foo(x: String) -> Int {
        return x.characters.count
    }
}
natecook1000 commented 9 years ago

I've removed the potential collision with #14 and updated the various reserved word fields from the Lexical Structure section of Apple's documentation for Swift. 🐦

Here's a code sample that demonstrates some of the problems fixed—public, private, required, guard, throw, and throws should all be highlighted as keywords:

public class Foo {
    public enum FooError : ErrorType {
        case NumericConversionError
    }

    private let bar: String

    public required init(s: String) {
        self.bar = s
    }

    public func asInt() throws -> Int {
        guard let number = Int(bar) else {
            throw FooError.NumericConversionError
        }

        return number
    }
}
infininight commented 9 years ago

Pulled, thanks!

natecook1000 commented 9 years ago

:balloon: :star2: :tada: Thanks, @infininight!