JavaScript Highlighter: disable debug prints by default
This commit is contained in:
parent
83cfba74a8
commit
7b54a18bcc
|
@ -27,6 +27,7 @@ class JavaScriptHighlighter {
|
||||||
private var currentIndex: String.Index!
|
private var currentIndex: String.Index!
|
||||||
private var indent = ""
|
private var indent = ""
|
||||||
private(set) var tokens = [(token: TokenType, range: NSRange)]()
|
private(set) var tokens = [(token: TokenType, range: NSRange)]()
|
||||||
|
var debug = false
|
||||||
|
|
||||||
init(text: String) {
|
init(text: String) {
|
||||||
self.text = text
|
self.text = text
|
||||||
|
@ -38,8 +39,10 @@ class JavaScriptHighlighter {
|
||||||
self.attributed = mutableAttributed
|
self.attributed = mutableAttributed
|
||||||
}
|
}
|
||||||
|
|
||||||
private func print(_ str: String) {
|
private func print(_ str: @autoclosure () -> String) {
|
||||||
Swift.print("\(indent)\(str)")
|
if debug {
|
||||||
|
Swift.print("\(indent)\(str())")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func range(from: String.Index, to: String.Index) -> NSRange {
|
private func range(from: String.Index, to: String.Index) -> NSRange {
|
||||||
|
|
|
@ -9,5 +9,6 @@
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
let source = "`$foo ${blah} bar`"
|
let source = "`$foo ${blah} bar`"
|
||||||
_ = JavaScriptHighlighter(text: source).highlight()
|
let highlighter = JavaScriptHighlighter(text: source)
|
||||||
|
highlighter.debug = true
|
||||||
|
highlighter.highlight()
|
||||||
|
|
Loading…
Reference in New Issue