Skip to content

Commit

Permalink
remove more old code
Browse files Browse the repository at this point in the history
  • Loading branch information
qvalentin committed Apr 28, 2024
1 parent 27e73fb commit 4e015ff
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 48 deletions.
24 changes: 1 addition & 23 deletions internal/handler/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func (h *langHandler) Completion(ctx context.Context, params *lsp.CompletionPara

usecases := []languagefeatures.CompletionUseCase{
languagefeatures.NewTemplateContextFeature(genericDocumentUseCase),
languagefeatures.NewFunctionCallFeature(genericDocumentUseCase),
}

for _, usecase := range usecases {
Expand All @@ -65,10 +66,6 @@ func (h *langHandler) Completion(ctx context.Context, params *lsp.CompletionPara
if !ok {
return nil, errors.New("Could not get document: " + params.TextDocument.URI.Filename())
}
chart, err := h.chartStore.GetChartForDoc(params.TextDocument.URI)
if err != nil {
logger.Error("Error getting chart info for file", params.TextDocument.URI, err)
}

word, isTextNode := completionAstParsing(doc, params.Position)

Expand Down Expand Up @@ -115,22 +112,6 @@ func (h *langHandler) Completion(ctx context.Context, params *lsp.CompletionPara
variableSplitted = variableSplitted[1:]

Check failure on line 112 in internal/handler/completion.go

View workflow job for this annotation

GitHub Actions / lint (1.21.5, ubuntu-latest)

SA4006: this value of `variableSplitted` is never used (staticcheck)
}

switch variableSplitted[0] {
case "Chart":
items = getVariableCompletionItems(helmdocs.ChartVals)
case "Values":
items = h.getValuesCompletions(chart, variableSplitted[1:])
case "Release":
items = getVariableCompletionItems(helmdocs.ReleaseVals)
case "Files":
items = getVariableCompletionItems(helmdocs.FilesVals)
case "Capabilities":
items = getVariableCompletionItems(helmdocs.CapabilitiesVals)
default:
items = getVariableCompletionItems(helmdocs.BuiltInObjects)
items = append(items, functionsCompletionItems...)
}

return &lsp.CompletionList{IsIncomplete: false, Items: items}, err
}

Expand Down Expand Up @@ -162,9 +143,6 @@ func completionAstParsing(doc *lsplocal.Document, position lsp.Position) (string
switch nodeType {
case gotemplate.NodeTypeIdentifier:
word = relevantChildNode.Content([]byte(doc.Content))
case gotemplate.NodeTypeDot:
logger.Debug("TraverseIdentifierPathUp for dot node")
word = lsplocal.TraverseIdentifierPathUp(relevantChildNode, doc)
case gotemplate.NodeTypeText, gotemplate.NodeTypeTemplate:
return word, true
}
Expand Down
7 changes: 7 additions & 0 deletions internal/language_features/function_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import (
"fmt"

helmdocs "github.com/mrjosh/helm-ls/internal/documentation/helm"
"github.com/mrjosh/helm-ls/internal/protocol"
"github.com/mrjosh/helm-ls/internal/tree-sitter/gotemplate"
lsp "go.lsp.dev/protocol"
)

type FunctionCallFeature struct {
Expand All @@ -28,3 +30,8 @@ func (f *FunctionCallFeature) Hover() (string, error) {
}
return fmt.Sprintf("%s\n\n%s", documentation.Detail, documentation.Doc), nil
}

func (f *FunctionCallFeature) Completion() (result *lsp.CompletionList, err error) {
// TODO: add all functions here
return protocol.NewCompletionResults(helmdocs.HelmFuncs).ToLSP(), nil
}
24 changes: 0 additions & 24 deletions internal/lsp/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,30 +64,6 @@ func isPointLargerOrEq(a sitter.Point, b sitter.Point) bool {
return a.Row > b.Row
}

func TraverseIdentifierPathUp(node *sitter.Node, doc *Document) string {
parent := node.Parent()

if parent == nil {
return ""
}

switch parent.Type() {
case "range_action":
if node.PrevNamedSibling() == nil {
return TraverseIdentifierPathUp(parent, doc)
}
logger.Debug("Range action found")
return TraverseIdentifierPathUp(parent, doc) + parent.NamedChild(0).Content([]byte(doc.Content)) + "[0]"
case "with_action":
if node.PrevNamedSibling() == nil {
return TraverseIdentifierPathUp(parent, doc)
}
logger.Debug("With action found")
return TraverseIdentifierPathUp(parent, doc) + parent.NamedChild(0).Content([]byte(doc.Content))
}
return TraverseIdentifierPathUp(parent, doc)
}

func (d *Document) ApplyChangesToAst(newContent string) {
d.Ast = ParseAst(nil, newContent)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/protocol/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (c *CompletionResult) ToLSP() (result lsp.CompletionItem) {
Detail: c.Documentation.Detail,
InsertText: c.Documentation.Name,
InsertTextFormat: lsp.InsertTextFormatSnippet,
Kind: lsp.CompletionItemKindConstant,
Kind: lsp.CompletionItemKindConstant, // TODO: make this more variable
}
}

Expand Down

0 comments on commit 4e015ff

Please sign in to comment.