swift format

This commit is contained in:
Adam Fowler
2021-03-18 10:34:52 +00:00
parent 16a2c54be6
commit c560bd0fd9
3 changed files with 34 additions and 53 deletions

View File

@@ -284,7 +284,7 @@ extension HBParser {
unsafeAdvance()
}
if startIndex == index {
return subParser(startIndex..<startIndex)
return subParser(startIndex ..< startIndex)
}
return subParser(startIndex ..< index)
}
@@ -404,8 +404,9 @@ extension HBParser {
func getPosition() -> Int {
return index
}
mutating func setPosition(_ index: Int) throws {
guard range.contains(index) else { throw Error.invalidPosition }
guard range.contains(index) else { throw Error.invalidPosition }
guard validateUTF8Character(at: index).0 != nil else { throw Error.invalidPosition }
_setPosition(index)
}

View File

@@ -61,7 +61,7 @@ extension HBMustacheTemplate {
// section
parser.unsafeAdvance()
let (name, method) = try parseName(&parser)
if newLine && hasLineFinished(&parser) {
if newLine, hasLineFinished(&parser) {
setNewLine = true
if parser.current() == "\n" {
parser.unsafeAdvance()
@@ -77,7 +77,7 @@ extension HBMustacheTemplate {
// inverted section
parser.unsafeAdvance()
let (name, method) = try parseName(&parser)
if newLine && hasLineFinished(&parser) {
if newLine, hasLineFinished(&parser) {
setNewLine = true
if parser.current() == "\n" {
parser.unsafeAdvance()
@@ -96,7 +96,7 @@ extension HBMustacheTemplate {
guard name == sectionName else {
throw Error.sectionCloseNameIncorrect
}
if newLine && hasLineFinished(&parser) {
if newLine, hasLineFinished(&parser) {
setNewLine = true
if parser.current() == "\n" {
parser.unsafeAdvance()
@@ -111,7 +111,7 @@ extension HBMustacheTemplate {
// comment
parser.unsafeAdvance()
_ = try parseComment(&parser)
if newLine && hasLineFinished(&parser) {
if newLine, hasLineFinished(&parser) {
setNewLine = true
if !parser.reachedEnd() {
parser.unsafeAdvance()
@@ -143,16 +143,16 @@ extension HBMustacheTemplate {
// partial
parser.unsafeAdvance()
let (name, _) = try parseName(&parser)
/*if newLine && hasLineFinished(&parser) {
setNewLine = true
if parser.current() == "\n" {
parser.unsafeAdvance()
}
}*/
/* if newLine && hasLineFinished(&parser) {
setNewLine = true
if parser.current() == "\n" {
parser.unsafeAdvance()
}
} */
if whiteSpaceBefore.count > 0 {
tokens.append(.text(whiteSpaceBefore))
}
if newLine && hasLineFinished(&parser) {
if newLine, hasLineFinished(&parser) {
setNewLine = true
if parser.current() == "\n" {
parser.unsafeAdvance()