analysis

package
v0.0.0-...-d72fd11 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package analysis provides the functionality for analyzing a document.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

type State struct {
	// Map of file names to contents
	Documents map[string]string
	// Selectors is the map of file names to selectors
	Selectors map[string][]master.Selector
	// Database is the database for the state
	Database data.Database[master.Queries]
	// Logger is the logger for the state
	Logger *log.Logger
}

State is the state of the document analysis

func NewState

func NewState(config *config.Config) (state State, err error)

NewState returns a new state with no documents

func (*State) CancelRequest

func (s *State) CancelRequest(
	id string,
) (response *lsp.CancelResponse, err error)

CancelRequest cancels a request

func (*State) CheckPosition

func (s *State) CheckPosition(
	position lsp.Position,
	text string,
) (res parsers.State, err error)

CheckPosition checks if the position is within the struct tag

func (*State) CreateTextDocumentCompletion

func (s *State) CreateTextDocumentCompletion(
	id int,
	document lsp.TextDocumentIdentifier,
	pos lsp.Position,
) (response lsp.CompletionResponse, err error)

CreateTextDocumentCompletion returns the completions for a given text document. It checks if the position is within the struct tag and returns the selectors if the position is within the struct tag.

It also checks if the position is within the struct tag value and returns the selectors if the position is within the struct tag value.

func (*State) GetDiagnosticsForFile

func (s *State) GetDiagnosticsForFile(
	text *string,
	data parsers.StructCommentData,
) (diagnostics []lsp.Diagnostic, err error)

GetDiagnosticsForFile returns diagnostics for a given file text is all the characters in the file

func (*State) Hover

func (s *State) Hover(
	id int,
	uri string,
	position lsp.Position,
) (*lsp.HoverResponse, error)

Hover returns a hover response for the given uri and position

func (*State) OpenDocument

func (s *State) OpenDocument(
	uri string,
	content *string,
) (diags []lsp.Diagnostic, err error)

OpenDocument opens a document in the state and returns any diagnostics for the document

uri is the uri of the document

content is the content of the document

func (*State) TextDocumentCodeAction

func (s *State) TextDocumentCodeAction(
	id int,
	uri string,
) lsp.TextDocumentCodeActionResponse

TextDocumentCodeAction returns the code actions for a given text document.

func (*State) UpdateDocument

func (s *State) UpdateDocument(
	uri, content string,
) (diags []lsp.Diagnostic, err error)

UpdateDocument updates the state with the given document

Jump to

Keyboard shortcuts

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