Skip to content

Commit

Permalink
references to values.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
qvalentin committed Apr 13, 2024
1 parent 271cac9 commit 6f8e894
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/handler/generic_document_usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func (h *langHandler) NewGenericDocumentUseCase(params lsp.TextDocumentPositionP
Document: doc,
DocumentStore: h.documents,
Chart: chart,
ChartStore: h.chartStore,
Node: node,
ParentNode: parentNode,
ParentNodeType: parentNodeType,
Expand Down
1 change: 1 addition & 0 deletions internal/language_features/generic_document_usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type GenericDocumentUseCase struct {
DocumentStore *lsplocal.DocumentStore
Chart *charts.Chart
Node *sitter.Node
ChartStore *charts.ChartStore
NodeType string
ParentNode *sitter.Node
ParentNodeType string
Expand Down
15 changes: 15 additions & 0 deletions internal/language_features/template_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ func (f *TemplateContextFeature) getReferenceLocations(templateContext lsplocal.
}
}

return append(locations, f.getDefinitionLocations(templateContext)...)
}

func (f *TemplateContextFeature) getDefinitionLocations(templateContext lsplocal.TemplateContext) []lsp.Location {
locations := []lsp.Location{}
if len(templateContext) == 0 || templateContext == nil {
return []lsp.Location{}
}

switch templateContext[0] {
case "Values":
for _, value := range f.Chart.ResolveValueFiles(templateContext.Tail(), f.ChartStore) {
locations = append(locations, value.ValuesFiles.GetPositionsForValue(value.Selector)...)
}
}
return locations
}

Expand Down
4 changes: 4 additions & 0 deletions internal/lsp/symbol_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ func (t TemplateContext) Format() string {
return strings.Join(t, ".")
}

func (t TemplateContext) Tail() TemplateContext {
return t[1:]
}

type SymbolTable struct {
contexts map[string][]sitter.Range
contextsReversed map[sitter.Range]TemplateContext
Expand Down

0 comments on commit 6f8e894

Please sign in to comment.