xcode backward compatibility fixes
- moved back to single line string literal - fixed calculating string lenght
This commit is contained in:
@@ -66,13 +66,10 @@ open class SimpleErrorReporter: ErrorReporter {
|
|||||||
let tokenContent = context.template.templateString.substring(with: lexeme.range)
|
let tokenContent = context.template.templateString.substring(with: lexeme.range)
|
||||||
let lexer = Lexer(templateString: context.template.templateString)
|
let lexer = Lexer(templateString: context.template.templateString)
|
||||||
let line = lexer.lexemeLine(lexeme)
|
let line = lexer.lexemeLine(lexeme)
|
||||||
let highlight = "\(String(Array(repeating: " ", count: line.offset)))^\(String(Array(repeating: "~", count: max(tokenContent.count - 1, 0))))"
|
let highlight = "\(String(Array(repeating: " ", count: line.offset)))^\(String(Array(repeating: "~", count: max(tokenContent.length - 1, 0))))"
|
||||||
let description = """
|
let description = "\(templateName)\(line.number):\(line.offset): error: \(error.description)\n\(line.content)\n\(highlight)"
|
||||||
\(templateName)\(line.number):\(line.offset): error: \(error.description)
|
let error = TemplateSyntaxError(description)
|
||||||
\(line.content)
|
return error
|
||||||
\(highlight)
|
|
||||||
"""
|
|
||||||
return TemplateSyntaxError(description)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,4 +83,13 @@ extension String {
|
|||||||
var range: Range<String.Index> {
|
var range: Range<String.Index> {
|
||||||
return startIndex..<endIndex
|
return startIndex..<endIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var length: Int {
|
||||||
|
#if swift(>=3.2)
|
||||||
|
return count
|
||||||
|
#else
|
||||||
|
return characters.count
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ class Scanner {
|
|||||||
let result = content.substring(to: index)
|
let result = content.substring(to: index)
|
||||||
|
|
||||||
if returnUntil {
|
if returnUntil {
|
||||||
range = range.lowerBound..<originalContent.index(range.upperBound, offsetBy: until.count)
|
range = range.lowerBound..<originalContent.index(range.upperBound, offsetBy: until.length)
|
||||||
content = substring.substring(from: until.endIndex)
|
content = substring.substring(from: until.endIndex)
|
||||||
return result + until
|
return result + until
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user