Documentation
¶
Overview ¶
Package ipc provides IPC communication between JS and Go using stdio
Index ¶
- Constants
- func EncodeAST(sourceFile *ast.SourceFile, id string) ([]byte, error)
- func IsIPCMode() bool
- type ApplyFixesRequest
- type ApplyFixesResponse
- type ByteArray
- type Diagnostic
- type ErrorResponse
- type Fix
- type Handler
- type HandshakeRequest
- type HandshakeResponse
- type LanguageOptions
- type LintRequest
- type LintResponse
- type Message
- type MessageKind
- type ParserOptions
- type Position
- type ProjectPaths
- type Range
- type Service
Constants ¶
const Version = "1.0.0"
Version is the IPC protocol version
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ApplyFixesRequest ¶ added in v0.1.12
type ApplyFixesRequest struct {
FileContent string `json:"fileContent"` // Current content of the file
Diagnostics []Diagnostic `json:"diagnostics"` // Diagnostics with fixes to apply
}
ApplyFixesRequest represents a request to apply fixes from JS to Go
type ApplyFixesResponse ¶ added in v0.1.12
type ApplyFixesResponse struct {
FixedContent []string `json:"fixedContent"` // The content after applying fixes (array of intermediate versions)
WasFixed bool `json:"wasFixed"` // Whether any fixes were actually applied
AppliedCount int `json:"appliedCount"` // Number of fixes that were applied
UnappliedCount int `json:"unappliedCount"` // Number of fixes that couldn't be applied
}
ApplyFixesResponse represents a response after applying fixes
type Diagnostic ¶
type Diagnostic struct {
RuleName string `json:"ruleName"`
Message string `json:"message"`
FilePath string `json:"filePath"`
Range Range `json:"range"`
Severity string `json:"severity,omitempty"`
MessageId string `json:"messageId"`
Fixes []Fix `json:"fixes,omitempty"`
}
Diagnostic represents a single lint diagnostic
type ErrorResponse ¶
type ErrorResponse struct {
Message string `json:"message"`
}
ErrorResponse represents an error response
type Fix ¶ added in v0.1.12
type Fix struct {
Text string `json:"text"`
StartPos int `json:"startPos"` // Character position in the file content
EndPos int `json:"endPos"` // Character position in the file content
}
Fix represents a single fix that can be applied
type Handler ¶
type Handler interface {
HandleLint(req LintRequest) (*LintResponse, error)
HandleApplyFixes(req ApplyFixesRequest) (*ApplyFixesResponse, error)
}
Handler defines the interface for handling IPC messages
type HandshakeRequest ¶
type HandshakeRequest struct {
Version string `json:"version"`
}
HandshakeRequest represents a handshake request
type HandshakeResponse ¶
HandshakeResponse represents a handshake response
type LanguageOptions ¶ added in v0.1.13
type LanguageOptions struct {
ParserOptions *ParserOptions `json:"parserOptions,omitempty"`
}
LanguageOptions contains language-specific configuration options
type LintRequest ¶
type LintRequest struct {
Files []string `json:"files,omitempty"`
Config string `json:"config,omitempty"` // Path to rslint.json config file
Format string `json:"format,omitempty"`
WorkingDirectory string `json:"workingDirectory,omitempty"`
// Supports both string level and array [level, options] format
RuleOptions map[string]interface{} `json:"ruleOptions,omitempty"`
FileContents map[string]string `json:"fileContents,omitempty"` // Map of file paths to their contents for VFS
LanguageOptions *LanguageOptions `json:"languageOptions,omitempty"` // Override languageOptions from config file
IncludeEncodedSourceFiles bool `json:"includeEncodedSourceFiles,omitempty"` // Whether to include encoded source files in response
}
LintRequest represents a lint request from JS to Go
type LintResponse ¶
type LintResponse struct {
Diagnostics []Diagnostic `json:"diagnostics"`
ErrorCount int `json:"errorCount"`
FileCount int `json:"fileCount"`
RuleCount int `json:"ruleCount"`
EncodedSourceFiles map[string]ByteArray `json:"encodedSourceFiles,omitempty"`
}
LintResponse represents a lint response from Go to JS
type Message ¶
type Message struct {
Kind MessageKind `json:"kind"`
ID int `json:"id"`
Data interface{} `json:"data,omitempty"`
}
Message represents an IPC message
type MessageKind ¶
type MessageKind string
MessageKind represents the kind of IPC message
const ( // KindLint is sent from JS to Go to request linting KindLint MessageKind = "lint" // KindApplyFixes is sent from JS to Go to request applying fixes KindApplyFixes MessageKind = "applyFixes" // KindResponse is sent from Go to JS with the lint results KindResponse MessageKind = "response" // KindError is sent when an error occurs KindError MessageKind = "error" // KindHandshake is sent for initial connection verification KindHandshake MessageKind = "handshake" // KindExit is sent to request termination KindExit MessageKind = "exit" )
type ParserOptions ¶ added in v0.1.13
type ParserOptions struct {
ProjectService bool `json:"projectService"`
Project ProjectPaths `json:"project,omitempty"`
}
ParserOptions contains parser-specific configuration
type ProjectPaths ¶ added in v0.1.13
type ProjectPaths []string
ProjectPaths represents project paths that can be either a single string or an array of strings
func (*ProjectPaths) UnmarshalJSON ¶ added in v0.1.13
func (p *ProjectPaths) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling to support both string and string[] formats
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages the IPC communication
func NewService ¶
NewService creates a new IPC service