Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ Provider 读取实际生效值及已发布的源哈希;回读失败保留草
Maven 模型缓存版本 2 保存上游实际选中的来源,即使来源由带空格路径的 `.mvn/maven.config`
指定,外部编辑或删除也会使缓存失效;不以宿主猜测的默认路径代替上游事实。

### 模块结构:侧栏、标签页和条目列表

2026-11-17(#2086)起宿主声明 `sourceSettings` 版本 1,对标 IDEA“项目结构 → 模块”:插件把每个模块投影成侧栏组里的一个来源(`parent` 表示父模块),字段按 `section` 分成“源 / 路径 / 依赖”等标签页,依赖、源目录这类有序列表用 `entryList` 字段。宿主只做通用渲染,不认识任何工具:

- 模块列表在表单左侧,只显示所选模块;浏览模块和标签页不产生草稿,也不读写文件。只有一组字段时不显示标签。
- 条目列表的添加菜单按插件声明的条目种类走:`file` / `directory` 打开原生选择器,返回绝对路径由插件换算成工具写法;`choice` 打开候选项对话框,只列尚未在列表中的项。导出、作用域等属性是条目行右侧的布尔/枚举列。
- 条目的 `title` / `detail` 只用于显示。宿主比较草稿、Core 比较和规划写入时都忽略它们,写给插件的值里也会去掉。
- 全部移除是显式的空列表,不等于“继承”;插件没有给出继承值时不提供“重置”,以免一次点击清空列表。
- 只读来源(依赖由 Maven/Gradle/IDEA 文件决定的模块)只显示条目,没有工具栏和选中状态。

正确做法:Eclipse 模块的依赖在插件里改写 `.classpath`,保留未知条目和属性;宿主只把用户的顺序、增删和属性交给 Core。错误做法:宿主根据路径后缀猜测条目种类,或把标题写回工具文件。

## 考虑过的备选方案

- 只提示默认路径、要求用户重新填写:省去读取逻辑,但无法证明显示值与工具一致,也增加误操作,因此不作为非敏感配置的默认交互。
Expand Down
51 changes: 48 additions & 3 deletions desktop/internal/core/source_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,61 @@ type SettingsSource struct {
Revision string `json:"revision"`
Writable bool `json:"writable"`
Fields []SourceSettingField `json:"fields"`
// Parent names an earlier source of the same sidebar group under which
// the module list nests this one.
Parent string `json:"parent,omitempty"`
}

type SourceSettingField struct {
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
// Section is the tab (sidebar) or subheading (form) holding the field.
Section string `json:"section,omitempty"`
Kind string `json:"kind"`
Value json.RawMessage `json:"value"`
InheritedValue json.RawMessage `json:"inheritedValue,omitempty"`
EffectiveValue json.RawMessage `json:"effectiveValue"`
EffectiveSource string `json:"effectiveSource"`
Options []PluginSettingOption `json:"options,omitempty"`
// EntryKinds and Attributes describe an entryList's add menu and columns.
EntryKinds []SourceEntryKind `json:"entryKinds,omitempty"`
Attributes []SourceEntryAttribute `json:"attributes,omitempty"`
}

// SourceEntryKind is one item of an entryList's add menu: a native file or
// directory picker, or a choice among values the plugin offers now.
type SourceEntryKind struct {
ID string `json:"id"`
Title string `json:"title"`
Input string `json:"input"`
Extensions []string `json:"extensions,omitempty"`
Choices []SourceEntryChoice `json:"choices,omitempty"`
}

type SourceEntryChoice struct {
Value string `json:"value"`
Title string `json:"title"`
Detail string `json:"detail,omitempty"`
}

// SourceEntryAttribute is a per-entry boolean or enum column.
type SourceEntryAttribute struct {
ID string `json:"id"`
Title string `json:"title"`
Kind string `json:"kind"`
Options []PluginSettingOption `json:"options,omitempty"`
}

// SourceEntry is one ordered entryList item. Title and Detail are display text
// Core ignores when it compares and plans edits.
type SourceEntry struct {
Kind string `json:"kind"`
Value string `json:"value"`
Title string `json:"title,omitempty"`
Detail string `json:"detail,omitempty"`
// Attributes holds a bool or an option value per declared attribute ID.
Attributes map[string]any `json:"attributes,omitempty"`
}

// SourceSettingInput is the unparsed view draft projected by Core. Inherit
Expand All @@ -51,6 +94,8 @@ type SourceSettingInput struct {
Choice string `json:"choice"`
On bool `json:"on"`
Inherit bool `json:"inherit"`
// Entries is the ordered entryList draft; other kinds leave it empty.
Entries []SourceEntry `json:"entries"`
}

type SourceSettingsLimits struct {
Expand Down
20 changes: 20 additions & 0 deletions desktop/internal/i18n/shared.generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions desktop/internal/pluginhost/pluginhost.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ func Declared() Capabilities {
for _, name := range baseline {
declared[name] = []int{0}
}
// Version 1 adds module sidebars, field sections and entry lists, which the
// settings window's source forms render.
declared["sourceSettings"] = []int{0, 1}
return declared
}

Expand Down
11 changes: 9 additions & 2 deletions desktop/internal/pluginhost/pluginhost_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"path/filepath"
"runtime"
"slices"
"testing"
)

Expand Down Expand Up @@ -66,8 +67,14 @@ func TestDeclaredServesTheBaselineOfEveryWiredCapability(t *testing.T) {
t.Fatalf("declared = %v", declared)
}
for _, name := range want {
if versions := declared[name]; len(versions) != 1 || versions[0] != 0 {
t.Fatalf("%s = %v, want [0]", name, versions)
wanted := []int{0}
// The settings window renders the module sidebars, sections and entry
// lists that version 1 adds.
if name == "sourceSettings" {
wanted = []int{0, 1}
}
if versions := declared[name]; !slices.Equal(versions, wanted) {
t.Fatalf("%s = %v, want %v", name, versions, wanted)
}
}
// Capabilities nothing here serves stay absent so their plugins are not
Expand Down
Loading
Loading