Closed Coeur closed 5 years ago
We read case
and ,
for a valid situation like:
enum Foo {
case get, set
func bar() {}
}
We read var
and let
for similar reasons like:
let get = true
var set: Bool?
func bar() {}
OK, I found a nice solution by interpreting ,
as a declarative token.
I've also added support for:
// https://stackoverflow.com/a/30593673/1033581
extension Collection {
/// Returns the element at the specified index iff it is within bounds, otherwise nil.
subscript (safe index: Index) -> Iterator.Element? {
return indices.contains(index) ? self[index] : nil
}
}
and:
var foo: Int = -1 {
willSet {
print(newValue)
}
didSet {
print(foo)
}
}
I've been through the list of tokens in https://github.com/google/code-prettify/blob/master/src/lang-swift.js (last commit is from me by the way), so I think we're not missing much now.
The Swift tests all pass. The CI jobs (AppVeyor and Travis) are failing for other reasons.
HI @Coeur thanks very much! Is it possible to add several new tests? For the new identifiers and new state.
HI @Coeur thanks very much! Is it possible to add several new tests? For the new identifiers and new state.
Sure, I was planning to, but was busy on an "emergency release" in office, ah ah. Will do it today.
@terryyin done. The most interesting test is test_keyword_declarations
, as it's filled with traps.
Thanks!
This is an untested attempt to fix #240 by adding a declarative state to ignore variable names like
get
orset
.