2024-01-05 08:40:16 +08:00
|
|
|
package ast
|
|
|
|
|
|
|
|
func FindPrevSiblingExceptLineBreak(node Node) Node {
|
|
|
|
if node == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
prev := node.PrevSibling()
|
2024-01-05 08:43:30 +08:00
|
|
|
if prev != nil && prev.Type() == LineBreakNode && prev.PrevSibling() != nil && prev.PrevSibling().Type() != LineBreakNode {
|
2024-01-05 08:40:16 +08:00
|
|
|
return FindPrevSiblingExceptLineBreak(prev)
|
|
|
|
}
|
|
|
|
return prev
|
|
|
|
}
|
|
|
|
|
|
|
|
func FindNextSiblingExceptLineBreak(node Node) Node {
|
|
|
|
if node == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
next := node.NextSibling()
|
2024-01-05 08:43:30 +08:00
|
|
|
if next != nil && next.Type() == LineBreakNode && next.NextSibling() != nil && next.NextSibling().Type() != LineBreakNode {
|
2024-01-05 08:40:16 +08:00
|
|
|
return FindNextSiblingExceptLineBreak(next)
|
|
|
|
}
|
|
|
|
return next
|
|
|
|
}
|