types

package
v0.0.0-...-71ea618 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NavigateToRangeCommand          = "snyk.navigateToRange"
	WorkspaceScanCommand            = "snyk.workspace.scan"
	WorkspaceFolderScanCommand      = "snyk.workspaceFolder.scan"
	OpenBrowserCommand              = "snyk.openBrowser"
	LoginCommand                    = "snyk.login"
	CopyAuthLinkCommand             = "snyk.copyAuthLink"
	LogoutCommand                   = "snyk.logout"
	TrustWorkspaceFoldersCommand    = "snyk.trustWorkspaceFolders"
	OpenLearnLesson                 = "snyk.openLearnLesson"
	GetLearnLesson                  = "snyk.getLearnLesson"
	GetSettingsSastEnabled          = "snyk.getSettingsSastEnabled"
	GetFeatureFlagStatus            = "snyk.getFeatureFlagStatus"
	GetActiveUserCommand            = "snyk.getActiveUser"
	ReportAnalyticsCommand          = "snyk.reportAnalytics"
	ExecuteCLICommand               = "snyk.executeCLI"
	ClearCacheCommand               = "snyk.clearCache"
	GenerateIssueDescriptionCommand = "snyk.generateIssueDescription"
	// Snyk Code specific commands
	CodeFixCommand        = "snyk.code.fix"
	CodeSubmitFixFeedback = "snyk.code.submitFixFeedback"
	CodeFixDiffsCommand   = "snyk.code.fixDiffs"
)
View Source
const WorkDoneProgressBeginKind = "begin"
View Source
const WorkDoneProgressEndKind = "end"
View Source
const WorkDoneProgressReportKind = "report"

Variables

View Source
var (
	DefaultOpenBrowserFunc = func(url string) {
		browser.Stdout = os.Stderr
		_ = browser.OpenURL(url)
	}
)

Functions

This section is empty.

Types

type AnalyticsEventParam

type AnalyticsEventParam struct {
	InteractionType string         `json:"interactionType"`
	Category        []string       `json:"category"`
	Status          string         `json:"status"`
	TargetId        string         `json:"targetId"`
	TimestampMs     int64          `json:"timestampMs"`
	DurationMs      int64          `json:"durationMs"`
	Results         map[string]any `json:"results"`
	Errors          []any          `json:"errors"`
	Extension       map[string]any `json:"extension"`
	InteractionUUID string         `json:"interactionId"`
}

type ApplyWorkspaceEditParams

type ApplyWorkspaceEditParams struct {
	Label string `json:"label,omitempty"`
	/**
	 * The edits to apply.
	 */
	Edit *sglsp.WorkspaceEdit `json:"edit"`
}

type ApplyWorkspaceEditResult

type ApplyWorkspaceEditResult struct {
	/**
	 * Indicates whether the edit was applied or not.
	 */
	Applied bool `json:"applied"`

	/**
	* An optional textual description for why the edit was not applied.
	* This may be used by the server for diagnostic logging or to provide
	* a suitable error for a request that triggered the edit.
	 */
	FailureReason string `json:"failureReason,omitempty"`

	/**
	* Depending on the client's failure handling strategy `failedChange`
	* might contain the index of the change that failed. This property is
	* only available if the client signals a `failureHandling` strategy
	* in its client capabilities.
	 */
	FailedChange uint `json:"failedChange,omitempty"`
}

type AuthenticationMethod

type AuthenticationMethod string
const EmptyAuthenticationMethod AuthenticationMethod = ""
const FakeAuthentication AuthenticationMethod = "fake"
const OAuthAuthentication AuthenticationMethod = "oauth"
const TokenAuthentication AuthenticationMethod = "token"

type AuthenticationParams

type AuthenticationParams struct {
	Token  string `json:"token"`
	ApiUrl string `json:"apiUrl,omitempty"`
}

type Clearer

type Clearer interface {
	Clear()
}

type CliError

type CliError CliOutput

func (CliError) Error

func (e CliError) Error() string

type CliOutput

type CliOutput struct {
	Code         int    `json:"code,omitempty"`
	ErrorMessage string `json:"error,omitempty"`
	Path         string `json:"path,omitempty"`
	Command      string `json:"command,omitempty"`
}

type ClientCapabilities

type ClientCapabilities struct {
	Workspace    WorkspaceClientCapabilities    `json:"workspace,omitempty"`
	TextDocument TextDocumentClientCapabilities `json:"textDocument,omitempty"`
	Window       WindowClientCapabilities       `json:"window,omitempty"`
	Experimental any                            `json:"experimental,omitempty"`
}

type CodeAction

type CodeAction struct {
	/**
	 * A short, human-readable, title for this code action.
	 */
	Title string `json:"title"`
	/**
	 * The kind of the code action.
	 *
	 * Used to filter code actions.
	 */
	Kind CodeActionKind `json:"kind,omitempty"`
	/**
	 * The diagnostics that this code action resolves.
	 */
	Diagnostics []Diagnostic `json:"diagnostics,omitempty"`
	/**
	 * Marks this as a preferred action. Preferred actions are used by the `auto fix` command and can be targeted
	 * by keybindings.
	 *
	 * A quick fix should be marked preferred if it properly addresses the underlying error.
	 * A refactoring should be marked preferred if it is the most reasonable choice of actions to take.
	 *
	 * @since 3.15.0
	 */
	IsPreferred *bool `json:"isPreferred,omitempty"`
	/**
	 * Marks that the code action cannot currently be applied.
	 *
	 * Clients should follow the following guidelines regarding disabled code actions:
	 *
	 *   - Disabled code actions are not shown in automatic [lightbulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action)
	 *     code action menu.
	 *
	 *   - Disabled actions are shown as faded out in the code action menu when the user request a more specific type
	 *     of code action, such as refactorings.
	 *
	 *   - If the user has a [keybinding](https://code.visualstudio.com/docs/editor/refactoring#_keybindings-for-code-actions)
	 *     that auto applies a code action and only a disabled code actions are returned, the client should show the user an
	 *     error message with `reason` in the editor.
	 *
	 * @since 3.16.0
	 */
	Disabled *struct {
		/**
		 * Human readable description of why the code action is currently disabled.
		 *
		 * This is displayed in the code actions UI.
		 */
		Reason string `json:"reason"`
	} `json:"disabled,omitempty"`
	/**
	 * The workspace edit this code action performs.
	 */
	Edit *sglsp.WorkspaceEdit `json:"edit,omitempty"`

	/**
	 * A command this code action executes. If a code action
	 * provides an edit and a command, first the edit is
	 * executed and then the command.
	 */
	Command *sglsp.Command `json:"command,omitempty"`

	/**
	 * A data entry field that is preserved on a code action between
	 * a `textDocument/codeAction` and a `codeAction/resolve` request.
	 *
	 * Holds a UUID that is used to identify the code action in the resolve request.
	 */
	Data *CodeActionData `json:"data,omitempty"`
}

*

  • A CodeAction represents a change that can be performed in code, e.g. to fix a problem or
  • to refactor code. *
  • A CodeAction can be of these forms:
  • 1. Has Edit but No Command - A simple edit that will be applied when the action is invoked
  • 2. Has Command but No Edit - A command that will be executed when the action is invoked
  • 3. Has both Edit and Command - A command that will be executed after the edit will be applied
  • 4. Has neither Edit nor Command - A deferred code action that would be resolved after codeAction/resolve is received. *
  • A deferred code action would have both Edit & Command omitted, and when invoked by the user, the server would send
  • a new CodeAction with the Edit and/or Command fields populated.

type CodeActionContext

type CodeActionContext struct {
	/**
	 * An array of diagnostics known on the client side overlapping the range provided to the
	 * `textDocument/codeAction` request. They are provided so that the server knows which
	 * errors are currently presented to the user for the given range. There is no guarantee
	 * that these accurately reflect the error state of the resource. The primary parameter
	 * to compute code actions is the provided range.
	 */
	Diagnostics []Diagnostic `json:"diagnostics"`
	/**
	 * Requested kind of actions to return.
	 *
	 * Actions not of this kind are filtered out by the client before being shown. So servers
	 * can omit computing them.
	 */
	Only []CodeActionKind `json:"only,omitempty"`
	/**
	 * The reason why code actions were requested.
	 *
	 * @since 3.17.0
	 */
	TriggerKind CodeActionTriggerKind `json:"triggerKind,omitempty"`
}

type CodeActionData

type CodeActionData uuid.UUID

type CodeActionKind

type CodeActionKind string
const Empty CodeActionKind = ""

*

  • Empty kind.
const QuickFix CodeActionKind = "quickfix"

*

  • Base kind for quickfix actions 'quickfix'.
const Refactor CodeActionKind = "refactor"

*

  • Base kind for refactoring actions 'refactor'.
const RefactorExtract CodeActionKind = "refactor.extract"

*

  • Base kind for refactoring extraction actions: 'refactor.extract'. *
  • Example extract actions: *
  • - Extract method
  • - Extract function
  • - Extract variable
  • - Extract interface from class
  • - ...
const RefactorInline CodeActionKind = "refactor.inline"

*

  • Base kind for refactoring inline actions: 'refactor.inline'. *
  • Example inline actions: *
  • - Inline function
  • - Inline variable
  • - Inline constant
  • - ...
const RefactorRewrite CodeActionKind = "refactor.rewrite"

*

  • Base kind for refactoring rewrite actions: 'refactor.rewrite'. *
  • Example rewrite actions: *
  • - Convert JavaScript function to class
  • - Add or remove parameter
  • - Encapsulate field
  • - Make method static
  • - Move method to base class
  • - ...
const Source CodeActionKind = "source"

*

  • Base kind for source actions: `source`. *
  • Source code actions apply to the entire file.
const SourceFixAll CodeActionKind = "source.fixAll"

*

  • Base kind for a "fix all" source action `source.fixAll`. *
  • ""Fix all"" actions automatically fix errors that have a clear fix that
  • do not require user input. They should not suppress errors or perform
  • unsafe fixes such as generating new types or classes. *
  • @since 3.17.0
const SourceOrganizeImports CodeActionKind = "source.organizeImports"

*

  • Base kind for an organize imports source action
  • `source.organizeImports`.

type CodeActionOptions

type CodeActionOptions struct {
	ResolveProvider bool `json:"resolveProvider,omitempty"`
}

type CodeActionParams

type CodeActionParams struct {
	/**
	 * The document in which the command was invoked.
	 */
	TextDocument sglsp.TextDocumentIdentifier `json:"textDocument"`
	/**
	 * The range for which the command was invoked.
	 */
	Range sglsp.Range `json:"range"`
	/**
	 * Context carrying additional information.
	 */
	Context CodeActionContext `json:"context"`
}

type CodeActionTriggerKind

type CodeActionTriggerKind float64

type CodeDescription

type CodeDescription struct {
	Href Uri `json:"href"`
}

type CodeIssueData

type CodeIssueData struct {
	Key             string            `json:"key,omitempty"`
	Message         string            `json:"message"`
	LeadURL         string            `json:"leadURL,omitempty"`
	Rule            string            `json:"rule"`
	RuleId          string            `json:"ruleId"`
	RepoDatasetSize int               `json:"repoDatasetSize"`
	CWE             []string          `json:"cwe"`
	Text            string            `json:"text"`
	Markers         []Marker          `json:"markers,omitempty"`
	Cols            Point             `json:"cols"`
	Rows            Point             `json:"rows"`
	IsSecurityType  bool              `json:"isSecurityType"`
	PriorityScore   int               `json:"priorityScore"`
	HasAIFix        bool              `json:"hasAIFix"`
	DataFlow        []DataflowElement `json:"dataFlow,omitempty"`
}

type CodeLensRefresh

type CodeLensRefresh struct{}

type CodeLensWorkspaceClientCapabilities

type CodeLensWorkspaceClientCapabilities struct {
	/**
	 * Whether the client implementation supports a refresh request sent from the
	 * server to the client.
	 *
	 * Note that this event is global and will force the client to refresh all
	 * code lenses currently shown. It should be used with absolute care and is
	 * useful for situation where a server for example detect a project wide
	 * change that requires such a calculation.
	 */
	RefreshSupport bool `json:"refreshSupport,omitempty"`
}

type Command

type Command interface {
	Command() CommandData
	Execute(ctx context.Context) (any, error)
}

type CommandData

type CommandData struct {
	/**
	 * Title of the command, like `save`.
	 */
	Title string
	/**
	 * The identifier of the actual command handler.
	 */
	CommandId string
	/**
	 * Arguments that the command handler should be
	 * invoked with.
	 */
	Arguments     []any
	GroupingKey   Key
	GroupingType  GroupingType
	GroupingValue any
}

func (CommandData) GetGroupingKey

func (c CommandData) GetGroupingKey() Key

func (CommandData) GetGroupingType

func (c CommandData) GetGroupingType() GroupingType

func (CommandData) GetGroupingValue

func (c CommandData) GetGroupingValue() any

type CommandName

type CommandName string

type CommandService

type CommandService interface {
	ExecuteCommandData(ctx context.Context, commandData CommandData, server Server) (any, error)
}

type CommandServiceMock

type CommandServiceMock struct {
	// contains filtered or unexported fields
}

func NewCommandServiceMock

func NewCommandServiceMock() *CommandServiceMock

func (*CommandServiceMock) ExecuteCommandData

func (service *CommandServiceMock) ExecuteCommandData(_ context.Context, command CommandData, _ Server) (any, error)

func (*CommandServiceMock) ExecutedCommands

func (service *CommandServiceMock) ExecutedCommands() []CommandData

type CommitChangeLine

type CommitChangeLine struct {
	Line       string `json:"line"`
	LineNumber int    `json:"lineNumber"`
	LineChange string `json:"lineChange"`
}

type CompletionItemKind

type CompletionItemKind int

type ConfigurationItem

type ConfigurationItem struct {
	/**
	 * The scope to get the configuration section for.
	 */
	ScopeURI string `json:"scopeUri,omitempty"`
	/**
	 * The configuration section asked for.
	 */
	Section string `json:"section,omitempty"`
}

type ConfigurationParams

type ConfigurationParams struct {
	Items []ConfigurationItem `json:"items"`
}

*

  • The parameters of a configuration request.

type DataflowElement

type DataflowElement struct {
	Position  int         `json:"position"`
	FilePath  string      `json:"filePath"`
	FlowRange sglsp.Range `json:"flowRange"`
	Content   string      `json:"content"`
}

type DeleteFilesParams

type DeleteFilesParams struct {
	Files []FileDelete `json:"files,omitempty"`
}

type DeltaScanner

type DeltaScanner interface {
	DeltaScanningEnabled() bool
}

type Diagnostic

type Diagnostic struct {
	/**
	 * The range at which the message applies.
	 */
	Range sglsp.Range `json:"range"`

	/**
	 * The diagnostic's severity. Can be omitted. If omitted it is up to the
	 * client to interpret diagnostics as error, warning, info or hint.
	 */
	Severity DiagnosticSeverity `json:"severity,omitempty"`

	/**
	 * The diagnostic's code. Can be omitted. Can be string or int, thus we need
	 * any type
	 */
	Code any `json:"code,omitempty"`

	/**
	 * A human-readable string describing the source of this
	 * diagnostic, e.g. 'typescript' or 'super lint'.
	 */
	Source string `json:"source,omitempty"`

	/**
	 * The diagnostic's message.
	 */
	Message string `json:"message"`

	/**
	* An optional property to describe the error code.
	*
	* @since 3.16.0
	 */
	CodeDescription CodeDescription `json:"codeDescription,omitempty"`

	/**
	* Additional metadata about the diagnostic.
	*
	* @since 3.15.0
	 */
	Tags []DiagnosticTag `json:"diagnosticTag,omitempty"`

	/**
	* An array of related diagnostic information, e.g. when symbol-names within
	* a scope collide all definitions can be marked via this property.
	 */
	RelatedInformation []DiagnosticRelatedInformation `json:"relatedInformation,omitempty"`

	/**
	* A data entry field that is preserved between a
	* `textDocument/publishDiagnostics` notification and
	* `textDocument/codeAction` request.
	*
	* @since 3.16.0
	 */
	Data ScanIssue `json:"data,omitempty"`
}

type DiagnosticRelatedInformation

type DiagnosticRelatedInformation struct {
	Location sglsp.Location `json:"location"`
	Message  string         `json:"message"`
}

type DiagnosticResult

type DiagnosticResult struct {
	Uri         sglsp.DocumentURI
	Diagnostics []Diagnostic
	Err         error
}

type DiagnosticSeverity

type DiagnosticSeverity int
const (
	DiagnosticsSeverityError       DiagnosticSeverity = 1
	DiagnosticsSeverityWarning     DiagnosticSeverity = 2
	DiagnosticsSeverityInformation DiagnosticSeverity = 3
	DiagnosticsSeverityHint        DiagnosticSeverity = 4
)

type DiagnosticTag

type DiagnosticTag int
const (
	/**
	* Unused or unnecessary code.
	*
	* Clients are allowed to render diagnostics with this tag faded out
	* instead of having an error squiggle.
	 */
	Unnecessary DiagnosticTag = 1

	/**
	* Deprecated or obsolete code.
	*
	* Clients are allowed to rendered diagnostics with this tag strike through.
	 */
	Deprecated DiagnosticTag = 2
)

type DidChangeConfigurationParams

type DidChangeConfigurationParams struct {
	// The actual changed settings
	Settings Settings `json:"settings"`
}

type DidChangeWorkspaceFoldersParams

type DidChangeWorkspaceFoldersParams struct {
	// The actual workspace folder change Event.
	Event WorkspaceFoldersChangeEvent `json:"Event,omitempty"`
}

type DocumentationFormat

type DocumentationFormat string

type FileDelete

type FileDelete struct {
	Uri sglsp.DocumentURI `json:"uri,omitempty"`
}

type FileOperationFilter

type FileOperationFilter struct {
	Pattern FileOperationPattern `json:"pattern,omitempty"`
}

type FileOperationPattern

type FileOperationPattern struct {
	Glob string `json:"glob,omitempty"`
}

type FileOperationRegistrationOptions

type FileOperationRegistrationOptions struct {
	Filters []FileOperationFilter `json:"filters,omitempty"`
}

type FileOperationsServerCapabilities

type FileOperationsServerCapabilities struct {
	WillDeleteBool bool                             `json:"willDeleteBool,omitempty"`
	WillDelete     FileOperationRegistrationOptions `json:"willDelete,omitempty"`
}

type Filterable

type Filterable interface {
	GetFilteringKey() Key
}

type Folder

type Folder interface {
	Clearer
	ClearDiagnosticsByIssueType(removedType product.FilterableIssueType)
	IsScanned() bool
	SetStatus(status FolderStatus)
	ScanFolder(ctx context.Context)
	ScanFile(ctx context.Context, path string)
	Contains(path string) bool
	FilterAndPublishDiagnostics(p product.Product)
	Path() string
	Uri() lsp.DocumentURI
	Name() string
	Status() FolderStatus
	IsTrusted() bool
}

type FolderConfig

type FolderConfig struct {
	FolderPath           string   `json:"folderPath"`
	BaseBranch           string   `json:"baseBranch"`
	LocalBranches        []string `json:"localBranches,omitempty"`
	AdditionalParameters []string `json:"additionalParameters,omitempty"`
}

FolderConfig is exchanged between IDE and LS IDE sends this as part of the settings/initialization LS sends this via the $/snyk.folderConfig notification

type FolderConfigsParam

type FolderConfigsParam struct {
	FolderConfigs []FolderConfig `json:"folderConfigs"`
}

type FolderStatus

type FolderStatus int

type GetSdk

type GetSdk struct {
	FolderPath string       `json:"folder,omitempty"`
	Result     chan []LsSdk `json:"-"`
}

type Groupable

type Groupable interface {
	GetGroupingKey() Key
	GetGroupingValue() any
	GetGroupingType() GroupingType
}

type GroupingFunction

type GroupingFunction func(groupables []Groupable) any

func MaxSemver

func MaxSemver(logger zerolog.Logger) GroupingFunction

type GroupingType

type GroupingType string
const Quickfix GroupingType = "quickfix-grouping"

type IacIssueData

type IacIssueData struct {
	Key           string   `json:"key,omitempty"`
	PublicId      string   `json:"publicId"`
	Documentation string   `json:"documentation"`
	LineNumber    int      `json:"lineNumber"`
	Issue         string   `json:"issue"`
	Impact        string   `json:"impact"`
	Resolve       string   `json:"resolve,omitempty"`
	Path          []string `json:"path"`
	References    []string `json:"references,omitempty"`
}

type IgnoreDetails

type IgnoreDetails struct {
	Category   string    `json:"category"`
	Reason     string    `json:"reason"`
	Expiration string    `json:"expiration"`
	IgnoredOn  time.Time `json:"ignoredOn"`
	IgnoredBy  string    `json:"ignoredBy"`
}

type InitializeParams

type InitializeParams struct {
	ProcessID int `json:"processId,omitempty"`

	// RootPath is DEPRECATED in favor of the RootURI field.
	RootPath string `json:"rootPath,omitempty"`

	// The rootUri of the workspace. Is null if no folder is open. If both `rootPath` and `rootUri` are set `rootUri` wins.
	RootURI               sglsp.DocumentURI  `json:"rootUri,omitempty"`
	ClientInfo            sglsp.ClientInfo   `json:"clientInfo,omitempty"`
	Trace                 sglsp.Trace        `json:"trace,omitempty"`
	InitializationOptions Settings           `json:"initializationOptions,omitempty"`
	Capabilities          ClientCapabilities `json:"capabilities"`

	WorkDoneToken    string            `json:"workDoneToken,omitempty"`
	WorkspaceFolders []WorkspaceFolder `json:"workspaceFolders,omitempty"`
}

type InitializeResult

type InitializeResult struct {
	ServerInfo   ServerInfo         `json:"serverInfo,omitempty"`
	Capabilities ServerCapabilities `json:"capabilities,omitempty"`
}

type InitializedParams

type InitializedParams struct{}

type InlineValue

type InlineValue struct {
	/**
	 * The document range for which the inline value applies.
	 */
	Range sglsp.Range `json:"range"`

	/**
	 * The text of the inline value.
	 */
	Text string `json:"text"`
}

*

  • Provide inline value as text. *
  • @since 3.17.0

type InlineValueContext

type InlineValueContext struct {
	/**
	 * The stack frame (as a DAP Id) where the execution has stopped.
	 */
	FrameId int `json:"frameId"`

	/**
	 * The document range where execution has stopped.
	 * Typically the end position of the range denotes the line where the
	 * inline values are shown.
	 */
	StoppedLocation sglsp.Range `json:"stoppedLocation"`
}

type InlineValueParams

type InlineValueParams struct {
	/**
	 * The text document.
	 */
	TextDocument sglsp.TextDocumentIdentifier `json:"textDocument"`

	/**
	 * The document range for which inline values should be computed.
	 */
	Range sglsp.Range `json:"range"`

	/**
	 * Additional information about the context in which inline values were
	 * requested.
	 */
	Context InlineValueContext `json:"context"`
}

*

  • A parameter literal used in inline value requests. *
  • @since 3.17.0

type InlineValueRefresh

type InlineValueRefresh struct{}

type InlineValueWorkspaceClientCapabilities

type InlineValueWorkspaceClientCapabilities struct {
	/**
	 * Whether the client implementation supports a refresh request sent from the
	 * server to the client.
	 *
	 * Note that this event is global and will force the client to refresh all
	 * inline values currently shown. It should be used with absolute care and is
	 * useful for situation where a server for example detect a project wide
	 * change that requires such a calculation.
	 */
	RefreshSupport bool `json:"refreshSupport,omitempty"`
}

type Key

type Key string

type LogMessageParams

type LogMessageParams struct {
	/**
	 * The message type. See {@link MessageType}
	 */
	Type MessageType `json:"type"`

	/**
	 * The actual message
	 */
	Message string `json:"message"`
}

type LogTraceParams

type LogTraceParams struct {
	/**
	 * The message to be logged.
	 */
	Message string `json:"message"`

	/**
	 * Additional information that can be computed if the `trace` configuration
	 * is set to `'verbose'`
	 */
	Verbose string `json:"verbose"`
}

type LsSdk

type LsSdk struct {
	Type string `json:"type,omitempty"`
	Path string `json:"path,omitempty"`
}

type Marker

type Marker struct {
	Msg Point            `json:"msg"`
	Pos []MarkerPosition `json:"pos"`
}

type MarkerPosition

type MarkerPosition struct {
	Position
	File string `json:"file"`
}

type MessageAction

type MessageAction string

type MessageActionItem

type MessageActionItem struct {
	Title string `json:"title"`
}

type MessageType

type MessageType int
const Error MessageType = 1
const Info MessageType = 3
const Log MessageType = 4
const Warning MessageType = 2

type OssIdentifiers

type OssIdentifiers struct {
	CWE []string `json:"CWE,omitempty"`
	CVE []string `json:"CVE,omitempty"`
}

type OssIssueData

type OssIssueData struct {
	Key               string         `json:"key,omitempty"`
	RuleId            string         `json:"ruleId"`
	License           string         `json:"license,omitempty"`
	Identifiers       OssIdentifiers `json:"identifiers,omitempty"`
	Description       string         `json:"description"`
	Language          string         `json:"language"`
	PackageManager    string         `json:"packageManager"`
	PackageName       string         `json:"packageName"`
	Name              string         `json:"name"`
	Version           string         `json:"version"`
	Exploit           string         `json:"exploit,omitempty"`
	CVSSv3            string         `json:"CVSSv3,omitempty"`
	CvssScore         string         `json:"cvssScore,omitempty"`
	FixedIn           []string       `json:"fixedIn,omitempty"`
	From              []string       `json:"from"`
	UpgradePath       []any          `json:"upgradePath"`
	IsPatchable       bool           `json:"isPatchable"`
	IsUpgradable      bool           `json:"isUpgradable"`
	ProjectName       string         `json:"projectName"`
	DisplayTargetFile string         `json:"displayTargetFile"`
	MatchingIssues    []OssIssueData `json:"matchingIssues"`
	Lesson            string         `json:"lessonUrl,omitempty"`
}

Snyk Open Source

type Point

type Point = [2]int

type Position

type Position struct {
	Cols Point `json:"cols"`
	Rows Point `json:"rows"`
}

type ProgressParams

type ProgressParams struct {
	/**
	 * The progress token provided by the client or server.
	 */
	Token ProgressToken `json:"token"`
	/**
	 * The progress data.
	 */
	Value any `json:"value,omitempty"`
}

type ProgressToken

type ProgressToken string

type PublishDiagnosticsParams

type PublishDiagnosticsParams struct {
	URI         sglsp.DocumentURI `json:"uri"`
	Diagnostics []Diagnostic      `json:"diagnostics"`
}

type ScanIssue

type ScanIssue struct {
	// Unique key identifying an issue in the whole result set. Not the same as the Snyk issue ID.
	Id                  string                      `json:"id"`
	Title               string                      `json:"title"`
	Severity            string                      `json:"severity"`
	FilePath            string                      `json:"filePath"`
	Range               sglsp.Range                 `json:"range"`
	IsIgnored           bool                        `json:"isIgnored"`
	IsNew               bool                        `json:"isNew"`
	IgnoreDetails       IgnoreDetails               `json:"ignoreDetails"`
	FilterableIssueType product.FilterableIssueType `json:"filterableIssueType,omitempty"`
	AdditionalData      any                         `json:"additionalData,omitempty"`
}

type ScanSnapshotClearerExister

type ScanSnapshotClearerExister interface {
	Init(folderPath []string) error
	Clear(folderPath []string, deleteOnlyExpired bool)
	Exists(folderPath, commitHash string, p product.Product) bool
}

type ScanStatus

type ScanStatus string
const (
	InProgress  ScanStatus = "inProgress"
	Success     ScanStatus = "success"
	ErrorStatus ScanStatus = "error"
)

type Server

type Server interface {
	Notify(ctx context.Context, method string, params any) error
	Callback(ctx context.Context, method string, params any) (*jrpc2.Response, error)
}

type ServerCapabilities

type ServerCapabilities struct {
	TextDocumentSync                 *sglsp.TextDocumentSyncOptionsOrKind   `json:"textDocumentSync,omitempty"`
	HoverProvider                    bool                                   `json:"hoverProvider,omitempty"`
	CompletionProvider               *sglsp.CompletionOptions               `json:"completionProvider,omitempty"`
	SignatureHelpProvider            *sglsp.SignatureHelpOptions            `json:"signatureHelpProvider,omitempty"`
	DefinitionProvider               bool                                   `json:"definitionProvider,omitempty"`
	TypeDefinitionProvider           bool                                   `json:"typeDefinitionProvider,omitempty"`
	ReferencesProvider               bool                                   `json:"referencesProvider,omitempty"`
	DocumentHighlightProvider        bool                                   `json:"documentHighlightProvider,omitempty"`
	DocumentSymbolProvider           bool                                   `json:"documentSymbolProvider,omitempty"`
	WorkspaceSymbolProvider          bool                                   `json:"workspaceSymbolProvider,omitempty"`
	ImplementationProvider           bool                                   `json:"implementationProvider,omitempty"`
	CodeActionProvider               *CodeActionOptions                     `json:"codeActionProvider,omitempty"`
	CodeLensProvider                 *sglsp.CodeLensOptions                 `json:"codeLensProvider,omitempty"`
	DocumentFormattingProvider       bool                                   `json:"documentFormattingProvider,omitempty"`
	DocumentRangeFormattingProvider  bool                                   `json:"documentRangeFormattingProvider,omitempty"`
	DocumentOnTypeFormattingProvider *sglsp.DocumentOnTypeFormattingOptions `json:"documentOnTypeFormattingProvider,omitempty"`
	RenameProvider                   bool                                   `json:"renameProvider,omitempty"`
	ExecuteCommandProvider           *sglsp.ExecuteCommandOptions           `json:"executeCommandProvider,omitempty"`
	SemanticHighlighting             *sglsp.SemanticHighlightingOptions     `json:"semanticHighlighting,omitempty"`
	Workspace                        *WorkspaceCapabilities                 `json:"workspace,omitempty"`
	InlineValueProvider              bool                                   `json:"inlineValueProvider,omitempty"`
}

type ServerInfo

type ServerInfo struct {
	Name    string `json:"name,omitempty"`
	Version string `json:"version,omitempty"`
}

type Settings

type Settings struct {
	// global settings start
	ActivateSnykOpenSource           string               `json:"activateSnykOpenSource,omitempty"`
	ActivateSnykCode                 string               `json:"activateSnykCode,omitempty"`
	ActivateSnykIac                  string               `json:"activateSnykIac,omitempty"`
	Insecure                         string               `json:"insecure,omitempty"`
	Endpoint                         string               `json:"endpoint,omitempty"`
	Organization                     string               `json:"organization,omitempty"`
	Path                             string               `json:"path,omitempty"`
	CliPath                          string               `json:"cliPath,omitempty"`
	Token                            string               `json:"token,omitempty"`
	IntegrationName                  string               `json:"integrationName,omitempty"`
	IntegrationVersion               string               `json:"integrationVersion,omitempty"`
	AutomaticAuthentication          string               `json:"automaticAuthentication,omitempty"`
	DeviceId                         string               `json:"deviceId,omitempty"`
	FilterSeverity                   SeverityFilter       `json:"filterSeverity,omitempty"`
	SendErrorReports                 string               `json:"sendErrorReports,omitempty"`
	ManageBinariesAutomatically      string               `json:"manageBinariesAutomatically,omitempty"`
	EnableTrustedFoldersFeature      string               `json:"enableTrustedFoldersFeature,omitempty"`
	ActivateSnykCodeSecurity         string               `json:"activateSnykCodeSecurity,omitempty"`
	ActivateSnykCodeQuality          string               `json:"activateSnykCodeQuality,omitempty"`
	OsPlatform                       string               `json:"osPlatform,omitempty"`
	OsArch                           string               `json:"osArch,omitempty"`
	RuntimeVersion                   string               `json:"runtimeVersion,omitempty"`
	RuntimeName                      string               `json:"runtimeName,omitempty"`
	ScanningMode                     string               `json:"scanningMode,omitempty"`
	AuthenticationMethod             AuthenticationMethod `json:"authenticationMethod,omitempty"`
	SnykCodeApi                      string               `json:"snykCodeApi,omitempty"`
	EnableSnykLearnCodeActions       string               `json:"enableSnykLearnCodeActions,omitempty"`
	EnableSnykOSSQuickFixCodeActions string               `json:"enableSnykOSSQuickFixCodeActions,omitempty"`
	EnableSnykOpenBrowserActions     string               `json:"enableSnykOpenBrowserActions,omitempty"`
	EnableDeltaFindings              string               `json:"enableDeltaFindings,omitempty"` // should this be global?
	RequiredProtocolVersion          string               `json:"requiredProtocolVersion,omitempty"`
	HoverVerbosity                   *int                 `json:"hoverVerbosity,omitempty"`
	OutputFormat                     *string              `json:"outputFormat,omitempty"`
	// global settings end
	// folder specific settings start
	AdditionalParams string         `json:"additionalParams,omitempty"` // TODO make folder specific, move to folder config
	AdditionalEnv    string         `json:"additionalEnv,omitempty"`    // TODO make folder specific, move to folder config
	TrustedFolders   []string       `json:"trustedFolders,omitempty"`   // TODO make folder specific, move to folder config
	FolderConfigs    []FolderConfig `json:"folderConfigs,omitempty"`
}

Settings is the struct that is parsed from the InitializationParams.InitializationOptions field

type SeverityFilter

type SeverityFilter struct {
	Critical bool `json:"critical,omitempty"`
	High     bool `json:"high,omitempty"`
	Medium   bool `json:"medium,omitempty"`
	Low      bool `json:"low,omitempty"`
}

func DefaultSeverityFilter

func DefaultSeverityFilter() SeverityFilter

func NewSeverityFilter

func NewSeverityFilter(critical bool, high bool, medium bool, low bool) SeverityFilter

type ShowDocumentParams

type ShowDocumentParams struct {
	/**
	 * The document uri to show.
	 */
	Uri sglsp.DocumentURI `json:"uri"`

	/**
	 * Indicates to show the resource in an external program.
	 * To show for example `https://code.visualstudio.com/`
	 * in the default WEB browser set `external` to `true`.
	 */
	External bool `json:"external"`

	/**
	 * An optional property to indicate whether the editor
	 * showing the document should take focus or not.
	 * Clients might ignore this property if an external
	 * program is started.
	 */
	TakeFocus bool `json:"takeFocus"`

	/**
	 * An optional selection range if the document is a text
	 * document. Clients might ignore the property if an
	 * external program is started or the file is not a text
	 * file.
	 */
	Selection sglsp.Range `json:"selection"`
}

*

  • Params to show a document. *
  • @since 3.16.0

type ShowMessageRequest

type ShowMessageRequest struct {
	Message string                                                 `json:"message"`
	Type    MessageType                                            `json:"type"`
	Actions *data_structure.OrderedMap[MessageAction, CommandData] `json:"actions"`
}

type ShowMessageRequestParams

type ShowMessageRequestParams struct {
	Type    MessageType         `json:"type"`
	Message string              `json:"message"`
	Actions []MessageActionItem `json:"actions"`
}

type SnykIsAvailableCli

type SnykIsAvailableCli struct {
	CliPath string `json:"cliPath"`
}

type SnykScanParams

type SnykScanParams struct {
	// Status can be either InProgress, Success or ErrorStatus
	Status ScanStatus `json:"status"`
	// Product under scan (Snyk Code, Snyk Open Source, etc...)
	Product string `json:"product"`
	// FolderPath is the root-folder of the current scan
	FolderPath string `json:"folderPath"`
	// Error Message
	ErrorMessage string `json:"errorMessage,omitempty"`
	// CliError contains structured error information from the CLI
	CliError *CliError `json:"cliError,omitempty"`
}

SnykScanParams is the type for the $/snyk/scan message

type SnykTrustedFoldersParams

type SnykTrustedFoldersParams struct {
	TrustedFolders []string `json:"trustedFolders"`
}

type TextDocumentClientCapabilities

type TextDocumentClientCapabilities struct {
	Declaration *struct {
		LinkSupport bool `json:"linkSupport,omitempty"`
	} `json:"declaration,omitempty"`

	Definition *struct {
		LinkSupport bool `json:"linkSupport,omitempty"`
	} `json:"definition,omitempty"`

	Implementation *struct {
		LinkSupport bool `json:"linkSupport,omitempty"`

		DynamicRegistration bool `json:"dynamicRegistration,omitempty"`
	} `json:"implementation,omitempty"`

	TypeDefinition *struct {
		LinkSupport bool `json:"linkSupport,omitempty"`
	} `json:"typeDefinition,omitempty"`

	Synchronization *struct {
		WillSave          bool `json:"willSave,omitempty"`
		DidSave           bool `json:"didSave,omitempty"`
		WillSaveWaitUntil bool `json:"willSaveWaitUntil,omitempty"`
	} `json:"synchronization,omitempty"`

	DocumentSymbol struct {
		SymbolKind struct {
			ValueSet []int `json:"valueSet,omitempty"`
		} `json:"symbolKind,omitempty"`

		HierarchicalDocumentSymbolSupport bool `json:"hierarchicalDocumentSymbolSupport,omitempty"`
	} `json:"documentSymbol,omitempty"`

	Formatting *struct {
		DynamicRegistration bool `json:"dynamicRegistration,omitempty"`
	} `json:"formatting,omitempty"`

	RangeFormatting *struct {
		DynamicRegistration bool `json:"dynamicRegistration,omitempty"`
	} `json:"rangeFormatting,omitempty"`

	Rename *struct {
		DynamicRegistration bool `json:"dynamicRegistration,omitempty"`

		PrepareSupport bool `json:"prepareSupport,omitempty"`
	} `json:"rename,omitempty"`

	SemanticHighlightingCapabilities *struct {
		SemanticHighlighting bool `json:"semanticHighlighting,omitempty"`
	} `json:"semanticHighlightingCapabilities,omitempty"`

	CodeAction struct {
		DynamicRegistration bool `json:"dynamicRegistration,omitempty"`

		IsPreferredSupport bool `json:"isPreferredSupport,omitempty"`

		CodeActionLiteralSupport struct {
			CodeActionKind struct {
				ValueSet []CodeActionKind `json:"valueSet,omitempty"`
			} `json:"codeActionKind,omitempty"`
		} `json:"codeActionLiteralSupport,omitempty"`
	} `json:"codeAction,omitempty"`

	Completion struct {
		CompletionItem struct {
			DocumentationFormat []DocumentationFormat `json:"documentationFormat,omitempty"`
			SnippetSupport      bool                  `json:"snippetSupport,omitempty"`
		} `json:"completionItem,omitempty"`

		CompletionItemKind struct {
			ValueSet []CompletionItemKind `json:"valueSet,omitempty"`
		} `json:"completionItemKind,omitempty"`

		ContextSupport bool `json:"contextSupport,omitempty"`
	} `json:"completion,omitempty"`

	SignatureHelp *struct {
		SignatureInformation struct {
			ParameterInformation struct {
				LabelOffsetSupport bool `json:"labelOffsetSupport,omitempty"`
			} `json:"parameterInformation,omitempty"`
		} `json:"signatureInformation,omitempty"`
	} `json:"signatureHelp,omitempty"`

	DocumentLink *struct {
		DynamicRegistration bool `json:"dynamicRegistration,omitempty"`

		TooltipSupport bool `json:"tooltipSupport,omitempty"`
	} `json:"documentLink,omitempty"`

	Hover *struct {
		ContentFormat []string `json:"contentFormat,omitempty"`
	} `json:"hover,omitempty"`

	FoldingRange *struct {
		DynamicRegistration bool `json:"dynamicRegistration,omitempty"`

		RangeLimit interface{} `json:"rangeLimit,omitempty"`

		LineFoldingOnly bool `json:"lineFoldingOnly,omitempty"`
	} `json:"foldingRange,omitempty"`

	CallHierarchy *struct {
		DynamicRegistration bool `json:"dynamicRegistration,omitempty"`
	} `json:"callHierarchy,omitempty"`

	ColorProvider *struct {
		DynamicRegistration bool `json:"dynamicRegistration,omitempty"`
	} `json:"colorProvider,omitempty"`

	/**
	 * Capabilities specific to the `textDocument/inlineValue` request.
	 *
	 * @since 3.17.0
	 */
	InlineValue *struct {
		DynamicRegistration bool `json:"dynamicRegistration,omitempty"`
	} `json:"inlineValue,omitempty"`
}

type TextDocumentSaveReason

type TextDocumentSaveReason int
const (
	Manual     TextDocumentSaveReason = 0
	AfterDelay TextDocumentSaveReason = 1
	FocusOut   TextDocumentSaveReason = 2
)

type TrustRequester

type TrustRequester interface {
	StartRequestTrustCommunication()
	EndRequestTrustCommunication()
	IsTrustRequestOngoing() bool
}

type Uri

type Uri string

type WillSaveTextDocumentParams

type WillSaveTextDocumentParams struct {
	TextDocument sglsp.TextDocumentIdentifier `json:"textDocument"`
	Reason       TextDocumentSaveReason       `json:"reason"`
}

type WindowClientCapabilities

type WindowClientCapabilities struct {
	WorkDoneProgress bool `json:"workDoneProgress,omitempty"`
}

type WorkDoneProgressBegin

type WorkDoneProgressBegin struct {
	WorkDoneProgressKind
	/**
	 * Mandatory title of the progress operation. Used to briefly inform about
	 * the kind of operation being performed.
	 *
	 * Examples: "Indexing" or "Linking dependencies".
	 */
	Title string `json:"title"`
	/**
	 * Controls if a cancel button should show to allow the user to cancel the
	 * long running operation. Clients that don't support cancellation are allowed
	 * to ignore the setting.
	 */
	Cancellable bool `json:"cancellable,omitempty"`
	/**
	 * Optional, more detailed associated progress message. Contains
	 * complementary information to the `title`.
	 *
	 * Examples: "3/25 files", "project/src/module2", "node_modules/some_dep".
	 * If unset, the previous progress message (if any) is still valid.
	 */
	Message string `json:"message,omitempty"`
	/**
	 * Optional progress percentage to display (value 100 is considered 100%).
	 * If not provided infinite progress is assumed and clients are allowed
	 * to ignore the `percentage` value in subsequent in report notifications.
	 *
	 * The value should be steadily rising. Clients are free to ignore values
	 * that are not following this rule. The value range is [0, 100].
	 */
	Percentage int `json:"percentage,omitempty"`
}

type WorkDoneProgressEnd

type WorkDoneProgressEnd struct {
	WorkDoneProgressKind
	/**
	 * Optional, a final message indicating to for example indicate the outcome
	 * of the operation.
	 */
	Message string `json:"message,omitempty"`
}

type WorkDoneProgressKind

type WorkDoneProgressKind struct {
	Kind string `json:"kind"`
}

type WorkDoneProgressReport

type WorkDoneProgressReport struct {
	WorkDoneProgressKind
	/**
	 * Controls enablement state of a cancel button.
	 *
	 * Clients that don't support cancellation or don't support controlling the button's
	 * enablement state are allowed to ignore the property.
	 */
	Cancellable bool `json:"cancellable,omitempty"`
	/**
	 * Optional, more detailed associated progress message. Contains
	 * complementary information to the `title`.
	 *
	 * Examples: "3/25 files", "project/src/module2", "node_modules/some_dep".
	 * If unset, the previous progress message (if any) is still valid.
	 */
	Message string `json:"message,omitempty"`
	/**
	 * Optional progress percentage to display (value 100 is considered 100%).
	 * If not provided infinite progress is assumed and clients are allowed
	 * to ignore the `percentage` value in subsequent in report notifications.
	 *
	 * The value should be steadily rising. Clients are free to ignore values
	 * that are not following this rule. The value range is [0, 100]
	 */
	Percentage int `json:"percentage,omitempty"`
}

type WorkdoneProgressCancelParams

type WorkdoneProgressCancelParams struct {
	Token ProgressToken `json:"token"`
}

type Workspace

type Workspace interface {
	Clearer
	TrustRequester
	GetScanSnapshotClearerExister() ScanSnapshotClearerExister
	RemoveFolder(folderPath string)
	DeleteFile(filePath string)
	AddFolder(f Folder)
	GetFolderContaining(path string) Folder
	Folders() (folder []Folder)
	ScanWorkspace(ctx context.Context)
	ChangeWorkspaceFolders(params DidChangeWorkspaceFoldersParams) []Folder
	GetFolderTrust() (trusted []Folder, untrusted []Folder)
	ClearIssuesByType(removedType product.FilterableIssueType)
	TrustFoldersAndScan(ctx context.Context, foldersToBeTrusted []Folder)
}

type WorkspaceCapabilities

type WorkspaceCapabilities struct {
	WorkspaceFolders *WorkspaceFoldersServerCapabilities `json:"workspaceFolders,omitempty"`
	FileOperations   *FileOperationsServerCapabilities   `json:"fileOperations,omitempty"`
}

type WorkspaceClientCapabilities

type WorkspaceClientCapabilities struct {
	WorkspaceEdit struct {
		DocumentChanges    bool     `json:"documentChanges,omitempty"`
		ResourceOperations []string `json:"resourceOperations,omitempty"`
	} `json:"workspaceEdit,omitempty"`

	ApplyEdit bool `json:"applyEdit,omitempty"`

	Symbol struct {
		SymbolKind struct {
			ValueSet []int `json:"valueSet,omitempty"`
		} `json:"symbolKind,omitempty"`
	} `json:"symbol,omitempty"`

	DidChangeWatchedFiles *struct {
		DynamicRegistration bool `json:"dynamicRegistration,omitempty"`
	} `json:"didChangeWatchedFiles,omitempty"`

	ExecuteCommand *struct {
		DynamicRegistration bool `json:"dynamicRegistration,omitempty"`
	} `json:"executeCommand,omitempty"`

	WorkspaceFolders bool `json:"workspaceFolders,omitempty"`

	Configuration bool `json:"configuration,omitempty"`

	CodeLens CodeLensWorkspaceClientCapabilities `json:"codeLens,omitempty"`

	InlineValue InlineValueWorkspaceClientCapabilities `json:"inlineValue,omitempty"`
}

type WorkspaceFolder

type WorkspaceFolder struct {
	// The associated Uri for this workspace folder.
	Uri sglsp.DocumentURI `json:"uri,omitempty"`

	// The Name of the workspace folder. Used to refer to this
	// workspace folder in the user interface.
	Name string `json:"name,omitempty"`
}

type WorkspaceFoldersChangeEvent

type WorkspaceFoldersChangeEvent struct {
	// The array of Added workspace folders
	Added []WorkspaceFolder `json:"Added,omitempty"`

	// The array of the Removed workspace folders
	Removed []WorkspaceFolder `json:"Removed,omitempty"`
}

WorkspaceFoldersChangeEvent The workspace folder change event.

type WorkspaceFoldersServerCapabilities

type WorkspaceFoldersServerCapabilities struct {
	/**
	 * The server has support for workspace folders
	 */
	Supported bool `json:"supported,omitempty"`

	/**
	 * Whether the server wants to receive workspace folder
	 * change notifications.
	 *
	 * If a string is provided, the string is treated as an ID
	 * under which the notification is registered on the client
	 * side. The ID can be used to unregister for these events
	 * using the `client/unregisterCapability` request.
	 */
	ChangeNotifications string `json:"changeNotifications,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL