proxy

package
v0.2.663 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Log             *zap.Logger
	Target          lsp.Client
	SourceMapCache  *SourceMapCache
	DiagnosticCache *DiagnosticCache
}

Client is responsible for rewriting messages that are originated from gopls, and are sent to the client.

Since `gopls` is working on Go files, and this is the `templ` LSP, the job of this code is to rewrite incoming requests to adjust the file name from `*_templ.go` to `*.templ`, and to remap the char positions where required.

func NewClient

func NewClient(log *zap.Logger, cache *SourceMapCache, diagnosticCache *DiagnosticCache) (c *Client, init func(lsp.Client))

func (Client) ApplyEdit

func (p Client) ApplyEdit(ctx context.Context, params *lsp.ApplyWorkspaceEditParams) (result *lsp.ApplyWorkspaceEditResponse, err error)

func (Client) Configuration

func (p Client) Configuration(ctx context.Context, params *lsp.ConfigurationParams) (result []interface{}, err error)

func (Client) LogMessage

func (p Client) LogMessage(ctx context.Context, params *lsp.LogMessageParams) (err error)

func (Client) Progress

func (p Client) Progress(ctx context.Context, params *lsp.ProgressParams) (err error)

func (Client) PublishDiagnostics

func (p Client) PublishDiagnostics(ctx context.Context, params *lsp.PublishDiagnosticsParams) (err error)

func (Client) RegisterCapability

func (p Client) RegisterCapability(ctx context.Context, params *lsp.RegistrationParams) (err error)

func (Client) ShowMessage

func (p Client) ShowMessage(ctx context.Context, params *lsp.ShowMessageParams) (err error)

func (Client) ShowMessageRequest

func (p Client) ShowMessageRequest(ctx context.Context, params *lsp.ShowMessageRequestParams) (result *lsp.MessageActionItem, err error)

func (Client) Telemetry

func (p Client) Telemetry(ctx context.Context, params interface{}) (err error)

func (Client) UnregisterCapability

func (p Client) UnregisterCapability(ctx context.Context, params *lsp.UnregistrationParams) (err error)

func (Client) WorkDoneProgressCreate

func (p Client) WorkDoneProgressCreate(ctx context.Context, params *lsp.WorkDoneProgressCreateParams) (err error)

func (Client) WorkspaceFolders

func (p Client) WorkspaceFolders(ctx context.Context) (result []lsp.WorkspaceFolder, err error)

type DiagnosticCache added in v0.2.501

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

func NewDiagnosticCache added in v0.2.501

func NewDiagnosticCache() *DiagnosticCache

func (*DiagnosticCache) AddGoDiagnostics added in v0.2.501

func (dc *DiagnosticCache) AddGoDiagnostics(uri string, templDiagnostics []lsp.Diagnostic) []lsp.Diagnostic

func (*DiagnosticCache) AddTemplDiagnostics added in v0.2.501

func (dc *DiagnosticCache) AddTemplDiagnostics(uri string, goDiagnostics []lsp.Diagnostic) []lsp.Diagnostic

func (*DiagnosticCache) ClearTemplDiagnostics added in v0.2.501

func (dc *DiagnosticCache) ClearTemplDiagnostics(uri string)

type Document

type Document struct {
	Log   *zap.Logger
	Lines []string
}

func NewDocument

func NewDocument(log *zap.Logger, s string) *Document

func (*Document) Apply added in v0.2.232

func (d *Document) Apply(r *lsp.Range, with string)

func (*Document) Delete added in v0.2.232

func (d *Document) Delete(fromLine, fromCol, toLine, toCol int)

func (*Document) DeleteLines added in v0.2.232

func (d *Document) DeleteLines(i, j int)

func (*Document) Insert added in v0.2.232

func (d *Document) Insert(line, col int, lines []string)

func (*Document) InsertLines added in v0.2.232

func (d *Document) InsertLines(i int, withLines []string)

func (*Document) Len added in v0.2.232

func (d *Document) Len() (line, col int)

func (*Document) LineLengths added in v0.2.232

func (d *Document) LineLengths() (lens []int)

func (*Document) Overwrite

func (d *Document) Overwrite(fromLine, fromCol, toLine, toCol int, lines []string)

func (*Document) Replace added in v0.2.282

func (d *Document) Replace(with string)

func (*Document) String

func (d *Document) String() string

type DocumentContents added in v0.2.198

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

func (*DocumentContents) Apply added in v0.2.198

func (dc *DocumentContents) Apply(uri string, changes []lsp.TextDocumentContentChangeEvent) (d *Document, err error)

Apply changes to the document from the client, and return a list of change requests to send back to the client.

func (*DocumentContents) Delete added in v0.2.198

func (dc *DocumentContents) Delete(uri string)

Delete a document from memory.

func (*DocumentContents) Get added in v0.2.198

func (dc *DocumentContents) Get(uri string) (d *Document, ok bool)

Get the contents of a document.

func (*DocumentContents) Set added in v0.2.198

func (dc *DocumentContents) Set(uri string, d *Document)

Set the contents of a document.

func (*DocumentContents) URIs added in v0.2.198

func (dc *DocumentContents) URIs() (uris []string)

type Server

type Server struct {
	Log             *zap.Logger
	Client          lsp.Client
	Target          lsp.Server
	SourceMapCache  *SourceMapCache
	DiagnosticCache *DiagnosticCache
	TemplSource     *DocumentContents
	GoSource        map[string]string
}

Server is responsible for rewriting messages that are originated from the text editor, and need to be sent to gopls.

Since the editor is working on `templ` files, and `gopls` works on Go files, the job of this code is to rewrite incoming requests to adjust the file names from `*.templ` to `*_templ.go` and to remap the line/character positions in the `templ` files to their corresponding locations in the Go file.

This allows gopls to operate as usual.

This code also rewrites the responses back from gopls to do the inverse operation - to put the file names back, and readjust any character positions.

func NewServer

func NewServer(log *zap.Logger, target lsp.Server, cache *SourceMapCache, diagnosticCache *DiagnosticCache) (s *Server, init func(lsp.Client))

func (*Server) CodeAction

func (p *Server) CodeAction(ctx context.Context, params *lsp.CodeActionParams) (result []lsp.CodeAction, err error)

func (*Server) CodeLens

func (p *Server) CodeLens(ctx context.Context, params *lsp.CodeLensParams) (result []lsp.CodeLens, err error)

func (*Server) CodeLensRefresh

func (p *Server) CodeLensRefresh(ctx context.Context) (err error)

func (*Server) CodeLensResolve

func (p *Server) CodeLensResolve(ctx context.Context, params *lsp.CodeLens) (result *lsp.CodeLens, err error)

func (*Server) ColorPresentation

func (p *Server) ColorPresentation(ctx context.Context, params *lsp.ColorPresentationParams) (result []lsp.ColorPresentation, err error)

func (*Server) Completion

func (p *Server) Completion(ctx context.Context, params *lsp.CompletionParams) (result *lsp.CompletionList, err error)

func (*Server) CompletionResolve

func (p *Server) CompletionResolve(ctx context.Context, params *lsp.CompletionItem) (result *lsp.CompletionItem, err error)

func (*Server) Declaration

func (p *Server) Declaration(ctx context.Context, params *lsp.DeclarationParams) (result []lsp.Location, err error)

func (*Server) Definition

func (p *Server) Definition(ctx context.Context, params *lsp.DefinitionParams) (result []lsp.Location, err error)

func (*Server) DidChange

func (p *Server) DidChange(ctx context.Context, params *lsp.DidChangeTextDocumentParams) (err error)

func (*Server) DidChangeConfiguration

func (p *Server) DidChangeConfiguration(ctx context.Context, params *lsp.DidChangeConfigurationParams) (err error)

func (*Server) DidChangeWatchedFiles

func (p *Server) DidChangeWatchedFiles(ctx context.Context, params *lsp.DidChangeWatchedFilesParams) (err error)

func (*Server) DidChangeWorkspaceFolders

func (p *Server) DidChangeWorkspaceFolders(ctx context.Context, params *lsp.DidChangeWorkspaceFoldersParams) (err error)

func (*Server) DidClose

func (p *Server) DidClose(ctx context.Context, params *lsp.DidCloseTextDocumentParams) (err error)

func (*Server) DidCreateFiles

func (p *Server) DidCreateFiles(ctx context.Context, params *lsp.CreateFilesParams) (err error)

func (*Server) DidDeleteFiles

func (p *Server) DidDeleteFiles(ctx context.Context, params *lsp.DeleteFilesParams) (err error)

func (*Server) DidOpen

func (p *Server) DidOpen(ctx context.Context, params *lsp.DidOpenTextDocumentParams) (err error)

func (*Server) DidRenameFiles

func (p *Server) DidRenameFiles(ctx context.Context, params *lsp.RenameFilesParams) (err error)

func (*Server) DidSave

func (p *Server) DidSave(ctx context.Context, params *lsp.DidSaveTextDocumentParams) (err error)

func (*Server) DocumentColor

func (p *Server) DocumentColor(ctx context.Context, params *lsp.DocumentColorParams) (result []lsp.ColorInformation, err error)

func (*Server) DocumentHighlight

func (p *Server) DocumentHighlight(ctx context.Context, params *lsp.DocumentHighlightParams) (result []lsp.DocumentHighlight, err error)
func (p *Server) DocumentLink(ctx context.Context, params *lsp.DocumentLinkParams) (result []lsp.DocumentLink, err error)

func (*Server) DocumentLinkResolve

func (p *Server) DocumentLinkResolve(ctx context.Context, params *lsp.DocumentLink) (result *lsp.DocumentLink, err error)

func (*Server) DocumentSymbol

func (p *Server) DocumentSymbol(ctx context.Context, params *lsp.DocumentSymbolParams) (result []interface{}, err error)

func (*Server) ExecuteCommand

func (p *Server) ExecuteCommand(ctx context.Context, params *lsp.ExecuteCommandParams) (result interface{}, err error)

func (*Server) Exit

func (p *Server) Exit(ctx context.Context) (err error)

func (*Server) FoldingRanges

func (p *Server) FoldingRanges(ctx context.Context, params *lsp.FoldingRangeParams) (result []lsp.FoldingRange, err error)

func (*Server) Formatting

func (p *Server) Formatting(ctx context.Context, params *lsp.DocumentFormattingParams) (result []lsp.TextEdit, err error)

func (*Server) Hover

func (p *Server) Hover(ctx context.Context, params *lsp.HoverParams) (result *lsp.Hover, err error)

func (*Server) Implementation

func (p *Server) Implementation(ctx context.Context, params *lsp.ImplementationParams) (result []lsp.Location, err error)

func (*Server) IncomingCalls

func (p *Server) IncomingCalls(ctx context.Context, params *lsp.CallHierarchyIncomingCallsParams) (result []lsp.CallHierarchyIncomingCall, err error)

func (*Server) Initialize

func (p *Server) Initialize(ctx context.Context, params *lsp.InitializeParams) (result *lsp.InitializeResult, err error)

func (*Server) Initialized

func (p *Server) Initialized(ctx context.Context, params *lsp.InitializedParams) (err error)

func (*Server) LinkedEditingRange

func (p *Server) LinkedEditingRange(ctx context.Context, params *lsp.LinkedEditingRangeParams) (result *lsp.LinkedEditingRanges, err error)

func (*Server) LogTrace

func (p *Server) LogTrace(ctx context.Context, params *lsp.LogTraceParams) (err error)

func (*Server) Moniker

func (p *Server) Moniker(ctx context.Context, params *lsp.MonikerParams) (result []lsp.Moniker, err error)

func (*Server) OnTypeFormatting

func (p *Server) OnTypeFormatting(ctx context.Context, params *lsp.DocumentOnTypeFormattingParams) (result []lsp.TextEdit, err error)

func (*Server) OutgoingCalls

func (p *Server) OutgoingCalls(ctx context.Context, params *lsp.CallHierarchyOutgoingCallsParams) (result []lsp.CallHierarchyOutgoingCall, err error)

func (*Server) PrepareCallHierarchy

func (p *Server) PrepareCallHierarchy(ctx context.Context, params *lsp.CallHierarchyPrepareParams) (result []lsp.CallHierarchyItem, err error)

func (*Server) PrepareRename

func (p *Server) PrepareRename(ctx context.Context, params *lsp.PrepareRenameParams) (result *lsp.Range, err error)

func (*Server) RangeFormatting

func (p *Server) RangeFormatting(ctx context.Context, params *lsp.DocumentRangeFormattingParams) (result []lsp.TextEdit, err error)

func (*Server) References

func (p *Server) References(ctx context.Context, params *lsp.ReferenceParams) (result []lsp.Location, err error)

func (*Server) Rename

func (p *Server) Rename(ctx context.Context, params *lsp.RenameParams) (result *lsp.WorkspaceEdit, err error)

func (*Server) Request

func (p *Server) Request(ctx context.Context, method string, params interface{}) (result interface{}, err error)

func (*Server) SemanticTokensFull

func (p *Server) SemanticTokensFull(ctx context.Context, params *lsp.SemanticTokensParams) (result *lsp.SemanticTokens, err error)

func (*Server) SemanticTokensFullDelta

func (p *Server) SemanticTokensFullDelta(ctx context.Context, params *lsp.SemanticTokensDeltaParams) (result interface{}, err error)

func (*Server) SemanticTokensRange

func (p *Server) SemanticTokensRange(ctx context.Context, params *lsp.SemanticTokensRangeParams) (result *lsp.SemanticTokens, err error)

func (*Server) SemanticTokensRefresh

func (p *Server) SemanticTokensRefresh(ctx context.Context) (err error)

func (*Server) SetTrace

func (p *Server) SetTrace(ctx context.Context, params *lsp.SetTraceParams) (err error)

func (*Server) ShowDocument

func (p *Server) ShowDocument(ctx context.Context, params *lsp.ShowDocumentParams) (result *lsp.ShowDocumentResult, err error)

func (*Server) Shutdown

func (p *Server) Shutdown(ctx context.Context) (err error)

func (*Server) SignatureHelp

func (p *Server) SignatureHelp(ctx context.Context, params *lsp.SignatureHelpParams) (result *lsp.SignatureHelp, err error)

func (*Server) Symbols

func (p *Server) Symbols(ctx context.Context, params *lsp.WorkspaceSymbolParams) (result []lsp.SymbolInformation, err error)

func (*Server) TypeDefinition

func (p *Server) TypeDefinition(ctx context.Context, params *lsp.TypeDefinitionParams) (result []lsp.Location, err error)

func (*Server) WillCreateFiles

func (p *Server) WillCreateFiles(ctx context.Context, params *lsp.CreateFilesParams) (result *lsp.WorkspaceEdit, err error)

func (*Server) WillDeleteFiles

func (p *Server) WillDeleteFiles(ctx context.Context, params *lsp.DeleteFilesParams) (result *lsp.WorkspaceEdit, err error)

func (*Server) WillRenameFiles

func (p *Server) WillRenameFiles(ctx context.Context, params *lsp.RenameFilesParams) (result *lsp.WorkspaceEdit, err error)

func (*Server) WillSave

func (p *Server) WillSave(ctx context.Context, params *lsp.WillSaveTextDocumentParams) (err error)

func (*Server) WillSaveWaitUntil

func (p *Server) WillSaveWaitUntil(ctx context.Context, params *lsp.WillSaveTextDocumentParams) (result []lsp.TextEdit, err error)

func (*Server) WorkDoneProgressCancel

func (p *Server) WorkDoneProgressCancel(ctx context.Context, params *lsp.WorkDoneProgressCancelParams) (err error)

type SourceMapCache

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

SourceMapCache is a cache of .templ file URIs to the source map.

func NewSourceMapCache

func NewSourceMapCache() *SourceMapCache

NewSourceMapCache creates a cache of .templ file URIs to the source map.

func (*SourceMapCache) Delete

func (fc *SourceMapCache) Delete(uri string)

func (*SourceMapCache) Get

func (fc *SourceMapCache) Get(uri string) (m *parser.SourceMap, ok bool)

func (*SourceMapCache) Set

func (fc *SourceMapCache) Set(uri string, m *parser.SourceMap)

func (*SourceMapCache) URIs added in v0.2.198

func (fc *SourceMapCache) URIs() (uris []string)

Jump to

Keyboard shortcuts

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