File tree 1 file changed +12
-1
lines changed
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,10 @@ func (tree *SymbolTree) Find(name string) Symbol {
55
55
func (tree * SymbolTree ) GetNearestScopedTree (index int ) * SymbolTree {
56
56
if tree .Scopes != nil {
57
57
for _ , scopedTree := range tree .Scopes {
58
+ if scopedTree == tree || scopedTree == nil {
59
+ continue
60
+ }
61
+
58
62
if index >= scopedTree .StartPos .Index && index <= scopedTree .EndPos .Index {
59
63
return scopedTree .GetNearestScopedTree (index )
60
64
}
@@ -84,11 +88,18 @@ func (tree *SymbolTree) Add(sym Symbol) {
84
88
tree .EndPos = loc .EndPos
85
89
}
86
90
87
- if cSym := CastChildrenSymbol (sym ); cSym != nil {
91
+ if cSym := CastChildrenSymbol (sym ); cSym != nil && cSym . Children () != tree {
88
92
if tree .Scopes == nil {
89
93
tree .Scopes = []* SymbolTree {}
90
94
}
91
95
96
+ // check if already exists
97
+ for _ , scopedTree := range tree .Scopes {
98
+ if scopedTree == cSym .Children () {
99
+ return
100
+ }
101
+ }
102
+
92
103
tree .Scopes = append (tree .Scopes , cSym .Children ())
93
104
cSym .Children ().Parent = tree
94
105
You can’t perform that action at this time.
0 commit comments