Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: automated region configuration [IDE-731] #710

Merged
merged 21 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ dist: build
env:
- GO111MODULE=on
- CGO_ENABLED=0
- LS_PROTOCOL_VERSION=16
- LS_PROTOCOL_VERSION=17
14 changes: 2 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ Right now the language server supports the following actions:
- example:
```json5
{
"token": "the snyk token" // this can be an oauth2.Token string or a legacy token
"token": "the snyk token", // this can be an oauth2.Token string or a legacy token
"apiUrl": "https://api.snyk.io"
}
```
- See https://pkg.go.dev/golang.org/x/[email protected]#Token for more details regarding oauth tokens.
Expand All @@ -197,17 +198,6 @@ Right now the language server supports the following actions:
}
```

- Diagnostics Overview (tabbed tree view)
- method: `$/snyk.diagnosticsOverview`
- params: `types.DiagnosticsOverviewParams`
- example:
```json5
{
"product": "oss", // or "code" or "iac"
"html": "<html>...</html>", // the html to display the overview tabs/tree
}
```

- Trusted Folder Notification
- method: `$/snyk.addTrustedFolders`
- params: `types.SnykTrustedFoldersParams`
Expand Down
7 changes: 6 additions & 1 deletion application/server/execute_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,12 @@ func Test_loginCommand_StartsAuthentication(t *testing.T) {
assert.NotEmpty(t, tokenResponse.ResultString())
assert.True(t, fakeAuthenticationProvider.IsAuthenticated)
assert.Eventually(t, func() bool { return len(jsonRPCRecorder.Notifications()) > 0 }, 5*time.Second, 50*time.Millisecond)
assert.Equal(t, 1, len(jsonRPCRecorder.FindNotificationsByMethod("$/snyk.hasAuthenticated")))
notifications := jsonRPCRecorder.FindNotificationsByMethod("$/snyk.hasAuthenticated")
assert.Equal(t, 1, len(notifications))
var hasAuthenticatedNotification types.AuthenticationParams
err = notifications[0].UnmarshalParams(&hasAuthenticatedNotification)
assert.NoError(t, err)
assert.NotEmpty(t, hasAuthenticatedNotification.ApiUrl)
}

func Test_TrustWorkspaceFolders(t *testing.T) {
Expand Down
27 changes: 12 additions & 15 deletions application/server/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,6 @@ func registerNotifier(c *config.Config, srv types.Server) {
case sglsp.ShowMessageParams:
notifier(c, srv, "window/showMessage", params)
logger.Debug().Interface("message", params).Msg("showing message")
case types.DiagnosticsOverviewParams:
logger.Debug().
Msgf("received diagnostics overview for %s, discarding", params.Product)
case types.PublishDiagnosticsParams:
notifier(c, srv, "textDocument/publishDiagnostics", params)
notifier(c, srv, "$/snyk.publishDiagnostics316", params)
source := "LSP"
if len(params.Diagnostics) > 0 {
source = params.Diagnostics[0].Source
}
logger.Debug().
Interface("documentURI", params.URI).
Interface("source", source).
Interface("diagnosticCount", len(params.Diagnostics)).
Msg("publishing diagnostics")
case types.SnykTrustedFoldersParams:
notifier(c, srv, "$/snyk.addTrustedFolders", params)
logger.Info().
Expand All @@ -130,6 +115,18 @@ func registerNotifier(c *config.Config, srv types.Server) {
// Function blocks on callback, so we need to run it in a separate goroutine
go handleShowMessageRequest(srv, params, &logger)
logger.Debug().Msg("sending show message request to client")
case types.PublishDiagnosticsParams:
notifier(c, srv, "textDocument/publishDiagnostics", params)
notifier(c, srv, "$/snyk.publishDiagnostics316", params)
source := "LSP"
if len(params.Diagnostics) > 0 {
source = params.Diagnostics[0].Source
}
logger.Debug().
Interface("documentURI", params.URI).
Interface("source", source).
Interface("diagnosticCount", len(params.Diagnostics)).
Msg("publishing diagnostics")
case types.ApplyWorkspaceEditParams:
handleApplyWorkspaceEdit(srv, params, &logger)
logger.Debug().
Expand Down
2 changes: 1 addition & 1 deletion application/server/notification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func Test_NotifierShouldSendNotificationToClient(t *testing.T) {
if err != nil {
t.Fatal(err)
}
var expected = types.AuthenticationParams{Token: "test token"}
var expected = types.AuthenticationParams{Token: "test token", ApiUrl: "https://api.snyk.io"}

di.Notifier().Send(expected)
assert.Eventually(
Expand Down
2 changes: 0 additions & 2 deletions domain/ide/workspace/folder.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (

"github.com/sourcegraph/go-lsp"

"github.com/snyk/snyk-ls/domain/ide/workspace/ui"
"github.com/snyk/snyk-ls/domain/snyk"
delta2 "github.com/snyk/snyk-ls/domain/snyk/delta"
"github.com/snyk/snyk-ls/domain/snyk/persistence"
Expand Down Expand Up @@ -614,7 +613,6 @@ func isVisibleSeverity(issue snyk.Issue) bool {
func (f *Folder) publishDiagnostics(product product.Product, issuesByFile snyk.IssuesByFile) {
f.sendHovers(issuesByFile)
f.sendDiagnostics(issuesByFile)
ui.SendDiagnosticsOverview(f.c, product, issuesByFile, f.notifier)
f.sendSuccess(product)
}

Expand Down
196 changes: 0 additions & 196 deletions domain/ide/workspace/ui/diagnostics_overview.go

This file was deleted.

Loading