本文整理汇总了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)
}