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 indent = ""
|
||||
private(set) var tokens = [(token: TokenType, range: NSRange)]()
|
||||
var debug = false
|
||||
|
||||
init(text: String) {
|
||||
self.text = text
|
||||
|
@ -38,8 +39,10 @@ class JavaScriptHighlighter {
|
|||
self.attributed = mutableAttributed
|
||||
}
|
||||
|
||||
private func print(_ str: String) {
|
||||
Swift.print("\(indent)\(str)")
|
||||
private func print(_ str: @autoclosure () -> String) {
|
||||
if debug {
|
||||
Swift.print("\(indent)\(str())")
|
||||
}
|
||||
}
|
||||
|
||||
private func range(from: String.Index, to: String.Index) -> NSRange {
|
||||
|
|
|
@ -9,5 +9,6 @@
|
|||
import Foundation
|
||||
|
||||
let source = "`$foo ${blah} bar`"
|
||||
_ = JavaScriptHighlighter(text: source).highlight()
|
||||
|
||||
let highlighter = JavaScriptHighlighter(text: source)
|
||||
highlighter.debug = true
|
||||
highlighter.highlight()
|
||||
|
|
Loading…
Reference in New Issue