-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Support dependency view #887
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
extension/src/views/gradleTasks/DependencyConfigurationTreeItem.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
import * as vscode from 'vscode'; | ||
|
||
export class DependencyConfigurationTreeItem extends vscode.TreeItem { | ||
private children: vscode.TreeItem[] | undefined; | ||
constructor( | ||
name: string, | ||
collapsibleState: vscode.TreeItemCollapsibleState, | ||
public readonly parentTreeItem: vscode.TreeItem, | ||
// TODO: https://github.com/microsoft/vscode-codicons/issues/77 | ||
iconPath: vscode.ThemeIcon = new vscode.ThemeIcon('file-submodule') | ||
) { | ||
super(name, collapsibleState); | ||
this.iconPath = iconPath; | ||
} | ||
|
||
public setChildren(children: vscode.TreeItem[]): void { | ||
this.children = children; | ||
} | ||
|
||
public getChildren(): vscode.TreeItem[] | undefined { | ||
return this.children; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
import * as vscode from 'vscode'; | ||
|
||
export class DependencyTreeItem extends vscode.TreeItem { | ||
private children: vscode.TreeItem[] | undefined; | ||
private omittedTreeItem: vscode.TreeItem | undefined; | ||
constructor( | ||
name: string, | ||
collapsibleState: vscode.TreeItemCollapsibleState, | ||
public readonly parentTreeItem: vscode.TreeItem, | ||
iconPath: vscode.ThemeIcon = new vscode.ThemeIcon('library') | ||
) { | ||
super(name, collapsibleState); | ||
this.iconPath = iconPath; | ||
} | ||
|
||
public setChildren(children: vscode.TreeItem[]): void { | ||
this.children = children; | ||
} | ||
|
||
public getChildren(): vscode.TreeItem[] | undefined { | ||
return this.children; | ||
} | ||
|
||
public setOmittedTreeItem(item: vscode.TreeItem): void { | ||
this.omittedTreeItem = item; | ||
} | ||
|
||
public getOmittedTreeItem(): vscode.TreeItem | undefined { | ||
return this.omittedTreeItem; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
import * as vscode from 'vscode'; | ||
import { DependencyItem, GradleDependencyType } from '../../proto/gradle_pb'; | ||
import { DependencyConfigurationTreeItem } from './DependencyConfigurationTreeItem'; | ||
import { DependencyTreeItem } from './DependencyTreeItem'; | ||
import { ProjectDependencyTreeItem } from './ProjectDependencyTreeItem'; | ||
export const GRADLE_OMITTED_REVEAL = 'gradle.omitted.reveal'; | ||
|
||
export function protocolItem2ProjectDependencyTreeItem( | ||
protocolItem: DependencyItem, | ||
parent: vscode.TreeItem | ||
): ProjectDependencyTreeItem | undefined { | ||
const name = 'Dependencies'; | ||
const projectItem: ProjectDependencyTreeItem = new ProjectDependencyTreeItem( | ||
name, | ||
vscode.TreeItemCollapsibleState.Collapsed, | ||
parent | ||
); | ||
const children = protocolItem.getChildrenList(); | ||
const treeChildren = []; | ||
for (const child of children) { | ||
if (child.getType() !== GradleDependencyType.CONFIGURATION) { | ||
continue; | ||
} | ||
const configurationItem = protocolItem2DependencyConfigurationTreeItem( | ||
child, | ||
projectItem | ||
); | ||
if (configurationItem) { | ||
treeChildren.push(configurationItem); | ||
} | ||
} | ||
if (!treeChildren.length) { | ||
return undefined; | ||
} | ||
projectItem.setChildren(treeChildren); | ||
return projectItem; | ||
} | ||
|
||
function protocolItem2DependencyConfigurationTreeItem( | ||
protocolItem: DependencyItem, | ||
parent: vscode.TreeItem | ||
): DependencyConfigurationTreeItem | undefined { | ||
const name = protocolItem.getName(); | ||
const storageMap = new Map(); | ||
const configurationItem: DependencyConfigurationTreeItem = new DependencyConfigurationTreeItem( | ||
name, | ||
vscode.TreeItemCollapsibleState.Collapsed, | ||
parent | ||
); | ||
const children = protocolItem.getChildrenList(); | ||
const treeChildren = []; | ||
for (const child of children) { | ||
if (child.getType() !== GradleDependencyType.DEPENDENCY) { | ||
continue; | ||
} | ||
treeChildren.push( | ||
protocolItem2DependencyTreeItem(child, configurationItem, storageMap) | ||
); | ||
} | ||
if (!treeChildren.length) { | ||
return undefined; | ||
} | ||
configurationItem.setChildren(treeChildren); | ||
return configurationItem; | ||
} | ||
|
||
function protocolItem2DependencyTreeItem( | ||
protocolItem: DependencyItem, | ||
parent: vscode.TreeItem, | ||
storageMap: Map<string, vscode.TreeItem> | ||
): DependencyTreeItem { | ||
const name = protocolItem.getName(); | ||
const dependencyItem: DependencyTreeItem = new DependencyTreeItem( | ||
name, | ||
vscode.TreeItemCollapsibleState.Collapsed, | ||
parent | ||
); | ||
if (storageMap.has(name)) { | ||
const omittedTreeItem = storageMap.get(name); | ||
if (omittedTreeItem) { | ||
dependencyItem.setOmittedTreeItem(omittedTreeItem); | ||
} | ||
dependencyItem.contextValue = 'omitted'; | ||
dependencyItem.label = dependencyItem.label + ' (*)'; | ||
dependencyItem.collapsibleState = vscode.TreeItemCollapsibleState.None; | ||
} else { | ||
storageMap.set(name, dependencyItem); | ||
const children = protocolItem.getChildrenList(); | ||
const treeChildren = []; | ||
for (const child of children) { | ||
if (child.getType() !== GradleDependencyType.DEPENDENCY) { | ||
continue; | ||
} | ||
treeChildren.push( | ||
protocolItem2DependencyTreeItem(child, dependencyItem, storageMap) | ||
); | ||
} | ||
dependencyItem.collapsibleState = | ||
treeChildren.length > 0 | ||
? vscode.TreeItemCollapsibleState.Collapsed | ||
: vscode.TreeItemCollapsibleState.None; | ||
dependencyItem.setChildren(treeChildren); | ||
} | ||
return dependencyItem; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we changed the themeicon in https://github.com/microsoft/vscode-gradle/pull/887/files#diff-183471d1a24e3c81ad33c4c977c62b13d94770466ca974bb60b5efcf3d6778d2 , IMO there is no way to check the icon so I simply remove it.