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
79 changes: 79 additions & 0 deletions desktop/internal/core/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ type buildOutcome struct {
Edit *BuildOptionEdit `json:"edit"`
// Discovery answers build.decodeTestDiscovery.
Discovery *BuildTestDiscovery `json:"discovery"`
// Tree answers build.modelTree.
Tree *BuildModelTree `json:"tree"`
}

func (o buildOutcome) failure(command string) error {
Expand Down Expand Up @@ -447,6 +449,83 @@ func (c *Client) DecodeBuildModel(ctx context.Context, manifest json.RawMessage,
return *result.Model, nil
}

// BuildModelTreeRequest asks for the tree of one loaded model (build.modelTree): its projects
// nested by parent, each with its tasks in folders, its dependencies and its targets. Query
// narrows the tree to the nodes it matches; GroupHeadings labels the folder of each task group
// in the user's language, and the query matches those labels too.
type BuildModelTreeRequest struct {
Model BuildModelTreeInput `json:"model"`
Query string `json:"query,omitempty"`
GroupHeadings map[string]string `json:"groupHeadings,omitempty"`
}

// BuildModelTreeInput is the part of a decoded model the tree reads.
type BuildModelTreeInput struct {
Projects []BuildProject `json:"projects"`
Targets []BuildTarget `json:"targets"`
Tasks []BuildTask `json:"tasks"`
}

// BuildModelTree is the Build tool window's tree of one instance. Project is the instance's
// only root project, whose contents Nodes holds beside the instance's own; with several root
// projects or none it is nil and Nodes holds the instance's nodes, then the root projects.
// Truncated says Core cut a tree too large to show whole.
type BuildModelTree struct {
Project *BuildTreeNode `json:"project"`
Nodes []BuildTreeNode `json:"nodes"`
Truncated bool `json:"truncated"`
}

// The kinds of a BuildTreeNode.
const (
BuildTreeProject = "project"
BuildTreeFolder = "folder"
BuildTreeTask = "task"
BuildTreeTargets = "targets"
BuildTreeTarget = "target"
BuildTreeDependencies = "dependencies"
BuildTreeTests = "tests"
)

// BuildTreeNode is one node of a BuildModelTree. Key is unique in the instance and stable
// across reloads and filters. ProjectID and TargetID are what a task runs on, empty for the
// whole instance; TaskID is a declared or a model task. Group names the task group a folder
// stands for, empty for a category folder. Matched marks a node the query matches itself.
// Targets, dependencies and tests nodes have no label: the host names them.
type BuildTreeNode struct {
Kind string `json:"kind"`
Key string `json:"key"`
Label string `json:"label"`
Detail string `json:"detail"`
Tooltip string `json:"tooltip"`
Group string `json:"group"`
ProjectID string `json:"projectID"`
TargetID string `json:"targetID"`
TaskID string `json:"taskID"`
Matched bool `json:"matched"`
Children []BuildTreeNode `json:"children"`
}

// BuildModelTree lays out the tree of one loaded model for the Build tool window.
func (c *Client) BuildModelTree(ctx context.Context, manifest json.RawMessage, buildSystemID string, request BuildModelTreeRequest) (BuildModelTree, error) {
const command = "build.modelTree"
var result buildOutcome
if err := c.Execute(ctx, command, struct {
Manifest json.RawMessage `json:"manifest"`
BuildSystemID string `json:"buildSystemID"`
Request BuildModelTreeRequest `json:"request"`
}{manifest, buildSystemID, request}, &result); err != nil {
return BuildModelTree{}, err
}
if err := result.failure(command); err != nil {
return BuildModelTree{}, err
}
if result.Tree == nil {
return BuildModelTree{}, newParseError(command, "build model tree returned no tree", "")
}
return *result.Tree, nil
}

// BuildDecodeDebugRequest validates the raw result of a provider's debug preparation. Run is
// the run declaration the preparation was planned for, whose `debug.adapter` Core answers.
// Native debug preparation takes no launch options, so the request carries none.
Expand Down
13 changes: 10 additions & 3 deletions desktop/internal/fileicons/NOTICE
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
File-type and folder icons of the Lithe desktop client.

The SVGs in svg/ are the file-tree icons the previous Lithe macOS client shipped in
Most SVGs in svg/ are the file-tree icons the previous Lithe macOS client shipped in
macos/Resources/IDEAIcons/, restored byte for byte from commit f1e8d8139^ of this
repository. Except for the two noted below, they come from the JetBrains IntelliJ
repository; the Build tool window icons listed last were copied byte for byte from the
upstream repository. Except for the two noted below, they come from the JetBrains IntelliJ
Platform Community repository (https://github.com/JetBrains/intellij-community) and are
distributed under the Apache License 2.0; see LICENSE-APACHE-2.0.txt. The previous
client's NOTICE.txt records their source paths and revisions, chiefly:
client's NOTICE.txt records the source paths and revisions of the restored icons, chiefly:

- fileTypes/*.svg: platform/icons/src/expui/fileTypes/ (revisions
e8d21e84ee23f99ae7237fbb4530ff2e7c3b47c5, c7f91397daa3a961b4e78bc634fe467a0a7d9ade,
Expand All @@ -30,6 +31,12 @@ client's NOTICE.txt records their source paths and revisions, chiefly:
db_muted_breakpoint.svg (and their _dark siblings): IntelliJ Community classic debugger icons
from platform/icons/src/debugger/ in the previous client's debugger/ assets (copyright headers
2000-2021 JetBrains); the previous NOTICE.txt did not record their source revision.
- The Build tool window icons, each with its _dark sibling, from revision
512e1e2ade0c185a1bf30e5286e5f45eef7351a4: taskGroup.svg from platform/icons/src/expui/build/
(the New UI form of the configFolder icon of IntelliJ's Maven and Gradle task folders);
module.svg, artifact.svg, library.svg, libraryFolder.svg and testGroup.svg from
platform/icons/src/expui/nodes/; task.svg from
platform/external-system-impl/resources/icons/newui/.

license.svg and makefile.svg (and their _dark siblings) are original Lithe icons,
because the Community set has no LICENSE or Makefile glyph; they follow the Lithe
Expand Down
47 changes: 47 additions & 0 deletions desktop/internal/fileicons/fileicons.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,53 @@ func ForBreakpoint(enabled, verified, muted, dark bool) gfx.Icon {
return iconForVariant(&DbSetBreakpoint, &DbSetBreakpointDark, dark)
}

// BuildNode identifies a kind of row in the Build tool window's tree. Each kind draws the
// IntelliJ New UI icon of the same node in IntelliJ's Maven and Gradle tool windows.
type BuildNode uint8

const (
// BuildProject is a project or module of a build system and is the zero value.
BuildProject BuildNode = iota
// BuildTaskFolder is a folder of tasks, such as a Maven project's Lifecycle or Plugins.
BuildTaskFolder
// BuildTask is a task.
BuildTask
// BuildTargets is the folder of a project's targets.
BuildTargets
// BuildTarget is a target that a build system builds.
BuildTarget
// BuildDependencies is the folder of a project's or a workspace's dependencies.
BuildDependencies
// BuildDependency is one dependency.
BuildDependency
// BuildTests is the folder of the tests a build system discovered.
BuildTests
// buildNodeCount is the number of build node kinds.
buildNodeCount
)

// buildNodeIcons stores the light and dark icon of each build node kind.
var buildNodeIcons = [buildNodeCount][2]*gfx.Icon{
BuildProject: {&Module, &ModuleDark},
BuildTaskFolder: {&TaskGroup, &TaskGroupDark},
BuildTask: {&Task, &TaskDark},
BuildTargets: {&Folder, &FolderDark},
BuildTarget: {&Artifact, &ArtifactDark},
BuildDependencies: {&LibraryFolder, &LibraryFolderDark},
BuildDependency: {&Library, &LibraryDark},
BuildTests: {&TestGroup, &TestGroupDark},
}

// ForBuildNode returns the icon of a Build tool window row of the given kind, using its dark
// variant when dark is set. An unknown kind gets the icon of a task folder.
func ForBuildNode(node BuildNode, dark bool) gfx.Icon {
if node >= buildNodeCount {
node = BuildTaskFolder
}
variants := buildNodeIcons[node]
return iconForVariant(variants[0], variants[1], dark)
}

// fileKind selects the icon family for a file basename.
func fileKind(name string) kind {
lowerName := strings.ToLower(name)
Expand Down
27 changes: 27 additions & 0 deletions desktop/internal/fileicons/fileicons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,33 @@ func TestForBreakpoint(t *testing.T) {
}
}

// TestForBuildNode checks that every Build tool window row kind gets its own layered IntelliJ
// icon in both looks, and that an unknown kind falls back to the task folder's.
func TestForBuildNode(t *testing.T) {
cases := []struct {
node BuildNode
lightIcon *gfx.Icon
darkIcon *gfx.Icon
}{
{BuildProject, &Module, &ModuleDark},
{BuildTaskFolder, &TaskGroup, &TaskGroupDark},
{BuildTask, &Task, &TaskDark},
{BuildTargets, &Folder, &FolderDark},
{BuildTarget, &Artifact, &ArtifactDark},
{BuildDependencies, &LibraryFolder, &LibraryFolderDark},
{BuildDependency, &Library, &LibraryDark},
{BuildTests, &TestGroup, &TestGroupDark},
{buildNodeCount, &TaskGroup, &TaskGroupDark},
}
if len(cases) != int(buildNodeCount)+1 {
t.Fatalf("cases cover %d kinds; want all %d and an unknown one", len(cases), buildNodeCount)
}
for _, test := range cases {
requireGeneratedIcon(t, ForBuildNode(test.node, false), test.lightIcon)
requireGeneratedIcon(t, ForBuildNode(test.node, true), test.darkIcon)
}
}

func requireGeneratedIcon(t *testing.T, got gfx.Icon, want *gfx.Icon) {
t.Helper()
if len(got.Layers) == 0 || len(want.Layers) == 0 || &got.Layers[0] != &want.Layers[0] {
Expand Down
Loading
Loading