守护进程方法
客户端可以使用的守护进程方法列表。
Biome 守护进程使用 JSON-RPC,这是一种轻量级的 RPC(远程过程调用)协议,第三方客户端(例如编辑器扩展)都可以利用它。
客户端使用以下 JSON 载荷发送请求,其中 method 是本页面列出的方法之一。下面是一个 biome/open_project 请求的示例:
{
"jsonrpc": "2.0",
"id": 1,
"method": "biome/open_project",
"params": {
"path": "/Some/path",
"openUninitialized": false
}
}
自定义方法
biome/file_features
接受 SupportsFeatureParams。
interface SupportsFeatureParams {
features: FeatureName;
inlineConfig?: Configuration;
/**
* 不应启用的功能
*/
notRequestedFeatures?: FeatureName;
path: string;
projectKey: number;
skipIgnoreCheck?: boolean;
}
返回 FileFeaturesResult。
interface FileFeaturesResult {
featuresSupported: FeaturesSupported;
}
biome/update_settings
接受 UpdateSettingsParams。
interface UpdateSettingsParams {
configuration: Configuration;
extendedConfigurations?: unknown[][];
moduleGraphResolutionKind?: string;
projectKey: number;
workspaceDirectory?: string;
}
返回 UpdateSettingsResult。
interface UpdateSettingsResult {
diagnostics: Diagnostic[];
}
biome/open_project
接受 OpenProjectParams。
interface OpenProjectParams {
/**
* 即使找不到 `biome.json`,是否也应将该文件夹作为项目打开。
*/
openUninitialized: boolean;
/**
* 要打开的路径
*/
path: string;
}
返回 OpenProjectResult。
interface OpenProjectResult {
/**
* 该项目的唯一标识符
*/
projectKey: number;
}
biome/scan_project
接受 ScanProjectParams。
interface ScanProjectParams {
/**
* 强制扫描该文件夹,即使它已经在监视之中。
*/
force: boolean;
projectKey: number;
scanKind: ScanKind;
verbose?: boolean;
/**
* 监视器是否应监视此路径。如果监视器已经在监视此路径,则不执行任何操作。
*/
watch: boolean;
}
返回 ScanProjectResult。
interface ScanProjectResult {
/**
* 在项目内找到的子配置文件列表
*/
configurationFiles: string[];
/**
* 扫描项目期间报告的诊断信息。
*/
diagnostics: Diagnostic[];
/**
* 扫描的持续时间。
*/
duration: Duration;
}
biome/open_file
接受 OpenFileParams。
interface OpenFileParams {
content: FileContent;
documentFileSource?: DocumentFileSource;
/**
* 用于启用更多文档服务,例如语义模型
*/
editorFeatures?: EditorFeatures;
inlineConfig?: Configuration;
path: string;
/**
* 设置为 `true` 可持久化解析期间使用的节点缓存,以便在文档被编辑时加快后续的重新解析。只有在预期会重新解析时才应启用此选项,例如通过 LSP Proxy 打开文件时。
*/
persistNodeCache?: boolean;
projectKey: number;
}
返回 OpenFileResult。
interface OpenFileResult {
diagnostics: Diagnostic[];
}
biome/change_file
接受 ChangeFileParams。
interface ChangeFileParams {
content: string;
/**
* 用于启用更多文档服务,例如语义模型
*/
editorFeatures?: EditorFeatures;
inlineConfig?: Configuration;
path: string;
projectKey: number;
version: number;
}
返回 ChangeFileResult。
interface ChangeFileResult {
/**
* 更新依赖项和模块数据时发现的问题。这不包括所更改文件的 Lint 或解析结果。
*/
diagnostics: Diagnostic[];
}
biome/close_file
接受 CloseFileParams。
interface CloseFileParams {
path: string;
projectKey: number;
}
返回 void。
biome/file_exists
接受 FileExistsParams。
interface FileExistsParams {
filePath: string;
}
返回 boolean。
biome/is_path_ignored
接受 PathIsIgnoredParams。
interface PathIsIgnoredParams {
/**
* 该路径是否针对特定功能(例如 `formatter.includes`)被忽略。当此字段为空时,Biome 只检查 `files.includes`。
*/
features: FeatureName;
/**
* 控制忽略检查应如何执行
*/
ignoreKind?: IgnoreKind;
/**
* 该路径是否为目录。当调用方已从文件系统遍历中了解文件类型时,用于跳过 stat 调用。
*/
isDir?: boolean;
/**
* 要检查的路径
*/
path: string;
projectKey: number;
}
返回 boolean。
biome/update_module_graph
接受 UpdateModuleGraphParams。
interface UpdateModuleGraphParams {
path: string;
projectKey: number;
/**
* 要应用到模块图的更新类型
*/
updateKind: string;
}
返回 void。
biome/get_syntax_tree
接受 GetSyntaxTreeParams。
interface GetSyntaxTreeParams {
path: string;
projectKey: number;
}
返回 GetSyntaxTreeResult。
interface GetSyntaxTreeResult {
ast: string;
cst: string;
}
biome/check_file_size
接受 CheckFileSizeParams。
interface CheckFileSizeParams {
path: string;
projectKey: number;
}
返回 CheckFileSizeResult。
interface CheckFileSizeResult {
fileSize: number;
limit: number;
}
biome/get_file_content
接受 GetFileContentParams。
interface GetFileContentParams {
path: string;
projectKey: number;
}
返回 string。
biome/get_control_flow_graph
接受 GetControlFlowGraphParams。
interface GetControlFlowGraphParams {
cursor: number;
path: string;
projectKey: number;
}
返回 string。
biome/get_formatter_ir
接受 GetFormatterIRParams。
interface GetFormatterIRParams {
path: string;
projectKey: number;
}
返回 string。
biome/get_type_info
接受 GetTypeInfoParams。
interface GetTypeInfoParams {
path: string;
projectKey: number;
}
返回 string。
biome/get_registered_types
接受 GetRegisteredTypesParams。
interface GetRegisteredTypesParams {
path: string;
projectKey: number;
}
返回 string。
biome/get_semantic_model
接受 GetSemanticModelParams。
interface GetSemanticModelParams {
path: string;
projectKey: number;
}
返回 string。
biome/get_module_graph
接受 GetModuleGraphParams。
interface GetModuleGraphParams {}
返回 GetModuleGraphResult。
interface GetModuleGraphResult {
data: object;
}
biome/pull_diagnostics
接受 PullDiagnosticsParams。
interface PullDiagnosticsParams {
categories: RuleCategories;
/**
* 纳入诊断信息所需的最低严重性等级。严重性低于此阈值的诊断信息会被完全忽略(不计入、不序列化)。默认为 [`Severity::Hint`](包含全部内容)。
*/
diagnosticLevel?: Severity;
/**
* 在配置基础上额外应用的规则
*/
enabledRules?: string[];
/**
* 为 true 时,在应用 diagnostic_level 过滤器之前,将 assist 诊断信息(`assist/*`)提升为错误严重性等级。
*/
enforceAssist?: boolean;
/**
* 为 `true` 时,诊断信息包含用于规则修复的代码建议。
*/
includeCodeFix?: boolean;
inlineConfig?: Configuration;
/**
* 要拉取的诊断类型数量上限。该限制用于限制要拉取的 [Diagnostic] 数量。不过,工作区仍会处理来自分析器的所有诊断以计算其严重性等级。如果未提供值,工作区将拉取所有诊断。
*/
maxDiagnostics?: unknown;
only?: string[];
path: string;
projectKey: number;
skip?: string[];
}
返回 PullDiagnosticsResult。
interface PullDiagnosticsResult {
diagnostics: Diagnostic[];
errors: number;
infos: number;
/**
* 解析错误的数量(`errors` 的子集)。`--skip-parse-errors` 用它来区分解析错误与分析器错误。
*/
parseErrors: number;
skippedDiagnostics: number;
warnings: number;
}
biome/process_file
接受 ProcessFileParams。
interface ProcessFileParams {
categories: RuleCategories;
content: FileContent;
diagnosticLevel: Severity;
enabledRules?: string[];
enforceAssist: boolean;
fixFileMode?: FixFileMode;
format: boolean;
includeCodeFix: boolean;
maxDiagnostics?: unknown;
only?: string[];
path: string;
projectKey: number;
skip?: string[];
skipParseErrors: boolean;
suppressionReason?: unknown;
write: boolean;
}
返回 ProcessFileResult。
interface ProcessFileResult {
appliedFixes: number;
diagnostics: Diagnostic[];
errors: number;
formatWithErrorsDisabled: boolean;
infos: number;
output?: unknown;
parseErrors: number;
skippedDiagnostics: number;
skippedSuggestedFixes: number;
warnings: number;
}
biome/pull_actions
接受 PullActionsParams。
interface PullActionsParams {
categories?: RuleCategories;
/**
* 为 `false` 时,返回的操作具有 `suggestion: None`(不计算 `BatchMutation`)。`codeAction/resolve` 用它来延迟计算编辑。
*/
computeActions?: boolean;
enabledRules?: string[];
inlineConfig?: Configuration;
only?: string[];
path: string;
projectKey: number;
range?: TextRange;
skip?: string[];
suppressionReason?: unknown;
}
返回 PullActionsResult。
interface PullActionsResult {
actions: CodeAction[];
}
biome/pull_diagnostics_and_actions
接受 PullDiagnosticsAndActionsParams。
interface PullDiagnosticsAndActionsParams {
categories?: RuleCategories;
enabledRules?: string[];
inlineConfig?: Configuration;
only?: string[];
path: string;
projectKey: number;
skip?: string[];
}
返回 PullDiagnosticsAndActionsResult。
interface PullDiagnosticsAndActionsResult {
diagnostics: unknown[][];
}
biome/format_file
接受 FormatFileParams。
interface FormatFileParams {
inlineConfig?: Configuration;
path: string;
projectKey: number;
}
返回 Printed。
interface Printed {
code: string;
range?: TextRange;
sourcemap: SourceMarker[];
verbatimRanges: TextRange[];
}
biome/format_range
接受 FormatRangeParams。
interface FormatRangeParams {
inlineConfig?: Configuration;
path: string;
projectKey: number;
range: TextRange;
}
返回 Printed。
interface Printed {
code: string;
range?: TextRange;
sourcemap: SourceMarker[];
verbatimRanges: TextRange[];
}
biome/format_on_type
接受 FormatOnTypeParams。
interface FormatOnTypeParams {
inlineConfig?: Configuration;
offset: number;
path: string;
projectKey: number;
}
返回 Printed。
interface Printed {
code: string;
range?: TextRange;
sourcemap: SourceMarker[];
verbatimRanges: TextRange[];
}
biome/fix_file
接受 FixFileParams。
interface FixFileParams {
/**
* 要应用到文件的规则
*/
enabledRules?: string[];
fixFileMode: FixFileMode;
inlineConfig?: Configuration;
only?: string[];
path: string;
projectKey: number;
ruleCategories: RuleCategories;
shouldFormat: boolean;
skip?: string[];
suppressionReason?: unknown;
}
返回 FixFileResult。
interface FixFileResult {
/**
* 应用到文件的所有代码操作的列表
*/
actions: FixAction[];
/**
* 应用所有修复后文件的新源代码
*/
code: string;
/**
* 错误数量
*/
errors: number;
/**
* 被跳过的建议修复数量
*/
skippedSuggestedFixes: number;
}
biome/rename
接受 RenameParams。
interface RenameParams {
newName: string;
path: string;
projectKey: number;
symbolAt: number;
}
返回 RenameResult。
interface RenameResult {
/**
* 要应用于源代码的文本编辑操作列表
*/
indels: TextEdit;
/**
* 被此重命名操作修改的源代码范围
*/
range: TextRange;
}
biome/parse_pattern
接受 ParsePatternParams。
interface ParsePatternParams {
defaultLanguage: string;
pattern: string;
}
返回 ParsePatternResult。
interface ParsePatternResult {
patternId: string;
}
biome/search_pattern
接受 SearchPatternParams。
interface SearchPatternParams {
path: string;
pattern: string;
projectKey: number;
}
返回 SearchResults。
interface SearchResults {
matches: TextRange[];
path: string;
}
biome/drop_pattern
接受 DropPatternParams。
interface DropPatternParams {
pattern: string;
}
返回 void。