本文整理匯總了Golang中github.com/ditashi/jsbeautifier-go/tokenizer.Token.WhitespaceBefore方法的典型用法代碼示例。如果您正苦於以下問題:Golang Token.WhitespaceBefore方法的具體用法?Golang Token.WhitespaceBefore怎麽用?Golang Token.WhitespaceBefore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/ditashi/jsbeautifier-go/tokenizer.Token
的用法示例。
在下文中一共展示了Token.WhitespaceBefore方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: print_token_line_indentation
func (self *jsbeautifier) print_token_line_indentation(current_token tokenizer.Token) {
if self.output.just_added_newline() {
line := self.output.current_line
if self.options["keep_array_indentation"].(bool) && self.is_array(self.flags.mode) && current_token.WantedNewLine() {
line.push(current_token.WhitespaceBefore())
self.output.space_before_token = false
} else if self.output.set_indent(self.flags.indentation_level) {
self.flags.line_indent_level = self.flags.indentation_level
}
}
}
示例2: handle_block_comment
func (self *jsbeautifier) handle_block_comment(current_token *tokenizer.Token) {
lines := strings.Split(strings.Replace(current_token.Text(), "\x0d", "", -1), "\x0a")
javadoc := true
starless := true
last_indent := current_token.WhitespaceBefore()
last_indent_length := len(last_indent)
self.print_newline(false, true)
if len(lines) > 1 {
for _, l := range lines[1:] {
trims := strings.TrimSpace(l)
if trims == "" || trims[0] != '*' {
javadoc = false
break
}
}
if !javadoc {
for _, l := range lines[1:] {
trims := strings.TrimSpace(l)
if trims != "" && !strings.HasPrefix(l, last_indent) {
starless = false
break
}
}
}
} else {
javadoc = false
starless = false
}
self.print_token(*current_token, lines[0])
for _, l := range lines[1:] {
self.print_newline(false, true)
if javadoc {
self.print_token(*current_token, " "+strings.TrimSpace(l))
} else if starless && len(l) > last_indent_length {
self.print_token(*current_token, l[last_indent_length:])
} else {
self.output.add_token(l)
}
}
self.print_newline(false, true)
}