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 lexer = Lexer(templateString: context.template.templateString)
|
||||
let line = lexer.lexemeLine(lexeme)
|
||||
let highlight = "\(String(Array(repeating: " ", count: line.offset)))^\(String(Array(repeating: "~", count: max(tokenContent.count - 1, 0))))"
|
||||
let description = """
|
||||
\(templateName)\(line.number):\(line.offset): error: \(error.description)
|
||||
\(line.content)
|
||||
\(highlight)
|
||||
"""
|
||||
return TemplateSyntaxError(description)
|
||||
let highlight = "\(String(Array(repeating: " ", count: line.offset)))^\(String(Array(repeating: "~", count: max(tokenContent.length - 1, 0))))"
|
||||
let description = "\(templateName)\(line.number):\(line.offset): error: \(error.description)\n\(line.content)\n\(highlight)"
|
||||
let error = TemplateSyntaxError(description)
|
||||
return error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,4 +83,13 @@ extension String {
|
||||
var range: Range<String.Index> {
|
||||
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)
|
||||
|
||||
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)
|
||||
return result + until
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user