|
|
package protocol |
|
|
|
|
|
import "fmt" |
|
|
|
|
|
|
|
|
type WorkspaceSymbolResult interface { |
|
|
GetName() string |
|
|
GetLocation() Location |
|
|
isWorkspaceSymbol() |
|
|
} |
|
|
|
|
|
func (ws *WorkspaceSymbol) GetName() string { return ws.Name } |
|
|
func (ws *WorkspaceSymbol) GetLocation() Location { |
|
|
switch v := ws.Location.Value.(type) { |
|
|
case Location: |
|
|
return v |
|
|
case LocationUriOnly: |
|
|
return Location{URI: v.URI} |
|
|
} |
|
|
return Location{} |
|
|
} |
|
|
func (ws *WorkspaceSymbol) isWorkspaceSymbol() {} |
|
|
|
|
|
func (si *SymbolInformation) GetName() string { return si.Name } |
|
|
func (si *SymbolInformation) GetLocation() Location { return si.Location } |
|
|
func (si *SymbolInformation) isWorkspaceSymbol() {} |
|
|
|
|
|
|
|
|
func (r Or_Result_workspace_symbol) Results() ([]WorkspaceSymbolResult, error) { |
|
|
if r.Value == nil { |
|
|
return make([]WorkspaceSymbolResult, 0), nil |
|
|
} |
|
|
switch v := r.Value.(type) { |
|
|
case []WorkspaceSymbol: |
|
|
results := make([]WorkspaceSymbolResult, len(v)) |
|
|
for i := range v { |
|
|
results[i] = &v[i] |
|
|
} |
|
|
return results, nil |
|
|
case []SymbolInformation: |
|
|
results := make([]WorkspaceSymbolResult, len(v)) |
|
|
for i := range v { |
|
|
results[i] = &v[i] |
|
|
} |
|
|
return results, nil |
|
|
default: |
|
|
return nil, fmt.Errorf("unknown symbol type: %T", r.Value) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
type DocumentSymbolResult interface { |
|
|
GetRange() Range |
|
|
GetName() string |
|
|
isDocumentSymbol() |
|
|
} |
|
|
|
|
|
func (ds *DocumentSymbol) GetRange() Range { return ds.Range } |
|
|
func (ds *DocumentSymbol) GetName() string { return ds.Name } |
|
|
func (ds *DocumentSymbol) isDocumentSymbol() {} |
|
|
|
|
|
func (si *SymbolInformation) GetRange() Range { return si.Location.Range } |
|
|
|
|
|
|
|
|
func (si *SymbolInformation) isDocumentSymbol() {} |
|
|
|
|
|
|
|
|
func (r Or_Result_textDocument_documentSymbol) Results() ([]DocumentSymbolResult, error) { |
|
|
if r.Value == nil { |
|
|
return make([]DocumentSymbolResult, 0), nil |
|
|
} |
|
|
switch v := r.Value.(type) { |
|
|
case []DocumentSymbol: |
|
|
results := make([]DocumentSymbolResult, len(v)) |
|
|
for i := range v { |
|
|
results[i] = &v[i] |
|
|
} |
|
|
return results, nil |
|
|
case []SymbolInformation: |
|
|
results := make([]DocumentSymbolResult, len(v)) |
|
|
for i := range v { |
|
|
results[i] = &v[i] |
|
|
} |
|
|
return results, nil |
|
|
default: |
|
|
return nil, fmt.Errorf("unknown document symbol type: %T", v) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
type TextEditResult interface { |
|
|
GetRange() Range |
|
|
GetNewText() string |
|
|
isTextEdit() |
|
|
} |
|
|
|
|
|
func (te *TextEdit) GetRange() Range { return te.Range } |
|
|
func (te *TextEdit) GetNewText() string { return te.NewText } |
|
|
func (te *TextEdit) isTextEdit() {} |
|
|
|
|
|
|
|
|
func (e Or_TextDocumentEdit_edits_Elem) AsTextEdit() (TextEdit, error) { |
|
|
if e.Value == nil { |
|
|
return TextEdit{}, fmt.Errorf("nil text edit") |
|
|
} |
|
|
switch v := e.Value.(type) { |
|
|
case TextEdit: |
|
|
return v, nil |
|
|
case AnnotatedTextEdit: |
|
|
return TextEdit{ |
|
|
Range: v.Range, |
|
|
NewText: v.NewText, |
|
|
}, nil |
|
|
default: |
|
|
return TextEdit{}, fmt.Errorf("unknown text edit type: %T", e.Value) |
|
|
} |
|
|
} |
|
|
|