-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(document-symbols): add yamlls document-symbols
- Loading branch information
Showing
9 changed files
with
94 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package yamlls | ||
|
||
import ( | ||
"context" | ||
|
||
lsp "go.lsp.dev/protocol" | ||
) | ||
|
||
func (yamllsConnector Connector) CallDocumentSymbol(ctx context.Context, params *lsp.DocumentSymbolParams) (result []interface{}, err error) { | ||
if yamllsConnector.server == nil { | ||
return []interface{}{}, nil | ||
} | ||
return yamllsConnector.server.DocumentSymbol(ctx, params) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
//go:build integration | ||
|
||
package yamlls | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
|
||
"github.com/mrjosh/helm-ls/internal/util" | ||
"github.com/stretchr/testify/assert" | ||
lsp "go.lsp.dev/protocol" | ||
"go.lsp.dev/uri" | ||
) | ||
|
||
func TestYamllsDocumentSymoblIntegration(t *testing.T) { | ||
config := util.DefaultConfig.YamllsConfiguration | ||
|
||
testCases := []struct { | ||
file string | ||
expectedLen int | ||
}{ | ||
{ | ||
file: "../../../testdata/example/templates/deployment.yaml", | ||
expectedLen: 4, | ||
}, | ||
{ | ||
file: "../../../testdata/example/templates/ingress.yaml", | ||
expectedLen: 6, | ||
}, | ||
} | ||
for _, tt1 := range testCases { | ||
tt := tt1 | ||
t.Run(tt.file, func(t *testing.T) { | ||
t.Parallel() | ||
yamllsConnector, documents, _ := getYamlLsConnector(t, config) | ||
openFile(t, documents, tt.file, yamllsConnector) | ||
|
||
assert.EventuallyWithT(t, func(c *assert.CollectT) { | ||
result, err := yamllsConnector.CallDocumentSymbol(context.Background(), &lsp.DocumentSymbolParams{ | ||
TextDocument: lsp.TextDocumentIdentifier{ | ||
URI: uri.File(tt.file), | ||
}, | ||
}) | ||
assert.NoError(c, err) | ||
assert.Len(c, result, tt.expectedLen) | ||
}, time.Second*10, time.Second*2) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package handler | ||
|
||
import ( | ||
"context" | ||
|
||
lsp "go.lsp.dev/protocol" | ||
) | ||
|
||
// DocumentSymbol implements protocol.Server. | ||
func (h *langHandler) DocumentSymbol(ctx context.Context, params *lsp.DocumentSymbolParams) (result []interface{}, err error) { | ||
return h.yamllsConnector.CallDocumentSymbol(ctx, params) | ||
} |