-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
502 additions
and
11 deletions.
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; | ||
} | ||
|
||
export 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; | ||
} | ||
|
||
export 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.