Documentation ¶
Overview ¶
Database operations
Index ¶
- Constants
- Variables
- func BulkDeleteAnn(db *sql.DB, workspace, path string, firstLine uint32, lastLine uint32, ...) error
- func BulkMoveAnn(db *sql.DB, workspace, path string, firstLine uint32, delta int32) error
- func CreateDBFile(dbFilename string) (bool, error)
- func CreateDBSchema(db *sql.DB) error
- func CreateSchema(db *sql.DB) error
- func DeleteAnn(db *sql.DB, workspace, path string, line uint32) error
- func FindWorkspace(w []lsp.WorkspaceFolder, fileURI lsp.URI) (string, string)
- func GetAnn(db *sql.DB, workspace, path string, line uint32) (string, error)
- func InsertAnn(db *sql.DB, workspace, path string, line uint32, text string) error
- func JSONUnmarshal[T any](r io.Reader) (T, error)
- func MakeAllDirs(filename string) error
- func MakeDiagnostic(lr LineRange, m string) lsp.Diagnostic
- func MoveAnn(db *sql.DB, workspace, path string, line uint32, newPath string, ...) error
- func RPath(ws string, fileURI lsp.URI) string
- func ResolveWs(in []lsp.WorkspaceFolder) []lsp.WorkspaceFolder
- func TxBulkAppendAnn(tx *sql.Tx, workspace, path string, firstline, lastline uint32, delta int32) error
- func TxBulkMoveAnn(tx *sql.Tx, workspace, path string, firstLine uint32, delta int32) error
- type Ann
- type DiagnosticMsg
- type LineRange
- type PccGet
- type PccGetResp
- type PccSet
- type PccSetRes
- type Server
- type WorkspaceConfig
Constants ¶
const ( // Pragmas are used to initialize an in-memory database. Useful for tests. Pragmas = `?cache=shared&mode=memory` // For the time being, use an in-memory database. DefaultFilename = `file:test.db` + Pragmas // This socket name causes using stdin/stdout instead of a specific unix // domain socket. DefaultSocket = `:stdstream:` )
const ( // SqliteDriver is the name of the used SQL driver module. SqliteDriver = `sqlite3` InsertDeltaStatementStr = ` BEGIN TRANSACTION; UPDATE TABLE AnnotationLocations SET Line = Line + ? WHERE File = ? AND Line > ? COMMIT;` )
const ( PccSetCmd = `$/pcc/set` PccGetCmd = `$/pcc/get` CancelCmd = `%/cancelRequest` )
const ConfigFilename = `pcc.config.json`
ConfigFilename is the file name that, if found in the workspace, is used to name the workspace.
Variables ¶
var ExitError = fmt.Errorf("exiting")
Functions ¶
func BulkDeleteAnn ¶
func BulkDeleteAnn(db *sql.DB, workspace, path string, firstLine uint32, lastLine uint32, delta int32) error
BulkDeleteAnn bulk-deletes annotations.
func BulkMoveAnn ¶
BulkMoveAnn moves annotation locations starting from given line to EOF by 'delta'.
Note: firstLine is zero-indexed.
func CreateDBFile ¶
CreateDBFile creates an empty database file at the given name.
Returns true if the database needs to be initialized, e.g. if an empty file without a schema was created.
func CreateDBSchema ¶
CreateDBSchema creates the data schema used in this program in an empty database db.
func CreateSchema ¶
CreateSchema creates the database with the appropriate file pkg.
func DeleteAnn ¶
DeleteAnn deletes an annotation for the specific workspace, path and line. The annotation does not need to exist.
func FindWorkspace ¶
FindWorkspace findss the workspace that the file with uri URI belongs to. Returns the workspace URI encoded as string, and the relative path for the provided file.
Example:
For a workspace "file:///ws/file.txt", returns: ("file:///ws", "/file.txt")
func GetAnn ¶
GetAnn retrieves a single annotation. Or an error if that particular annotation does not exist.
func InsertAnn ¶
InsertAnn inserts an annotation into the database. The annotation line must not previously exist.
Args:
- workspace: the workspace, either an URI or a symbolic prefix.
- path: the file path relative to the workspace. For example, for ws="file://dir", and file URI "file://dir/file.txt", then path should be "/file.txt".
func JSONUnmarshal ¶
JSONUnmarshal is a typed parser for a go type.
func MakeAllDirs ¶
MakeAllDirs makes all the directories on the path of the *file* named in the parameter.
func MakeDiagnostic ¶
func MakeDiagnostic(lr LineRange, m string) lsp.Diagnostic
MakeDiagnostic creates a single diagnostic line.
func MoveAnn ¶
MoveAnn moves a single annotation from a file location to another location in a possibly different file.
func RPath ¶
RPath returns a file path relative to the given workspace. ws is the string representation of a workspace URI, e.g. "file:///ws" fileURI is the an URI possibly in that workspace, like "file:///ws/file.txt" In this case we'll be returning "/file.txt", i.e. a path rooted in `ws`.
func ResolveWs ¶
func ResolveWs(in []lsp.WorkspaceFolder) []lsp.WorkspaceFolder
ResolveWs resolves the workspace names, potentially using the marker config filename to get the workspace name.
For a workspace: "file:///ws/file.txt" and a workspace name mapping: "file:///ws" -> "ws" returns:
("ws", "/file.txt")
Types ¶
type Ann ¶
type Ann struct { // Line is the 0-based line index of the line where the annotation is. Line uint32 // Content is the string content of the annotation. Content string }
A single annotation
type DiagnosticMsg ¶
type DiagnosticMsg struct { // The URI of the file to refresh. URI lsp.URI // If set, the diagnostics are always updated. When unset, the Diagnostic // update is allowed to skip some updates. Force bool }
DiagnosticMsg contains the message sent to the diagnostic hander.
type LineRange ¶
type LineRange struct { // Start is zero based. Start uint32 // End is zero based. End uint32 StartCol, EndCol uint32 }
func NewLineRange ¶
NewLineRange creates a unified LineRange from equivalent LSP type.
type PccGetResp ¶
type PccGetResp struct {
Content []string `json:"content"`
}
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) DiagnosticsFn ¶
func (s *Server) DiagnosticsFn()
func (*Server) FindWorkspace ¶
Finds the workspace that the file with uri URI belongs to. Returns the workspace URI encoded as string, and the relative path for the provided file.
func (*Server) GetHandlerFunc ¶
GetHandlerFunc returns a stateful function that can be given to jsonrpc2.StreamServer to serve JSON-RPC2 requests.
func (*Server) MoveAnnotations ¶
INVARIANT: delta != 0.
type WorkspaceConfig ¶
type WorkspaceConfig struct {
WorkspaceName string `json:"workspace_name,omitempty"`
}
Config file is put into the workspace.