Revert "Merge from vscode 81d7885dc2e9dc617e1522697a2966bc4025a45d (#5949)" (#5983)

This reverts commit d15a3fcc98.
This commit is contained in:
Karl Burtram
2019-06-11 12:35:58 -07:00
committed by GitHub
parent 95a50b7892
commit 5a7562a37b
926 changed files with 11394 additions and 19540 deletions

View File

@@ -45,15 +45,16 @@ type LoadedScriptsItem = BaseTreeItem;
class BaseTreeItem {
private _showedMoreThanOne: boolean;
private _children = new Map<string, BaseTreeItem>();
private _children: { [key: string]: BaseTreeItem; };
private _source: Source;
constructor(private _parent: BaseTreeItem | undefined, private _label: string) {
this._children = {};
this._showedMoreThanOne = false;
}
isLeaf(): boolean {
return this._children.size === 0;
return Object.keys(this._children).length === 0;
}
getSession(): IDebugSession | undefined {
@@ -65,12 +66,12 @@ class BaseTreeItem {
setSource(session: IDebugSession, source: Source): void {
this._source = source;
this._children.clear();
this._children = {};
if (source.raw && source.raw.sources) {
for (const src of source.raw.sources) {
if (src.name && src.path) {
const s = new BaseTreeItem(this, src.name);
this._children.set(src.path, s);
this._children[src.path] = s;
const ss = session.getSource(src);
s.setSource(session, ss);
}
@@ -79,26 +80,26 @@ class BaseTreeItem {
}
createIfNeeded<T extends BaseTreeItem>(key: string, factory: (parent: BaseTreeItem, label: string) => T): T {
let child = <T>this._children.get(key);
let child = <T>this._children[key];
if (!child) {
child = factory(this, key);
this._children.set(key, child);
this._children[key] = child;
}
return child;
}
getChild(key: string): BaseTreeItem | undefined {
return this._children.get(key);
getChild(key: string): BaseTreeItem {
return this._children[key];
}
remove(key: string): void {
this._children.delete(key);
delete this._children[key];
}
removeFromParent(): void {
if (this._parent) {
this._parent.remove(this._label);
if (this._parent._children.size === 0) {
if (Object.keys(this._parent._children).length === 0) {
this._parent.removeFromParent();
}
}
@@ -141,7 +142,7 @@ class BaseTreeItem {
if (child) {
return child.hasChildren();
}
return this._children.size > 0;
return Object.keys(this._children).length > 0;
}
// skips intermediate single-child nodes
@@ -150,10 +151,7 @@ class BaseTreeItem {
if (child) {
return child.getChildren();
}
const array: BaseTreeItem[] = [];
for (let child of this._children.values()) {
array.push(child);
}
const array = Object.keys(this._children).map(key => this._children[key]);
return Promise.resolve(array.sort((a, b) => this.compare(a, b)));
}
@@ -201,11 +199,12 @@ class BaseTreeItem {
private oneChild(): BaseTreeItem | undefined {
if (SMART && !this._source && !this._showedMoreThanOne && !(this instanceof RootFolderTreeItem) && !(this instanceof SessionTreeItem)) {
if (this._children.size === 1) {
return this._children.values().next().value;
const keys = Object.keys(this._children);
if (keys.length === 1) {
return this._children[keys[0]];
}
// if a node had more than one child once, it will never be skipped again
if (this._children.size > 1) {
if (keys.length > 1) {
this._showedMoreThanOne = true;
}
}
@@ -244,7 +243,7 @@ class SessionTreeItem extends BaseTreeItem {
private _session: IDebugSession;
private _initialized: boolean;
private _map = new Map<string, BaseTreeItem>();
private _map: Map<string, BaseTreeItem>;
private _labelService: ILabelService;
constructor(labelService: ILabelService, parent: BaseTreeItem, session: IDebugSession, private _environmentService: IEnvironmentService, private rootProvider: IWorkspaceContextService) {
@@ -252,6 +251,7 @@ class SessionTreeItem extends BaseTreeItem {
this._labelService = labelService;
this._initialized = false;
this._session = session;
this._map = new Map();
}
getSession(): IDebugSession {
@@ -417,7 +417,7 @@ export class LoadedScriptsView extends ViewletPanel {
const root = new RootTreeItem(this.debugService.getModel(), this.environmentService, this.contextService, this.labelService);
this.treeLabels = this.instantiationService.createInstance(ResourceLabels, { onDidChangeVisibility: this.onDidChangeBodyVisibility });
this._register(this.treeLabels);
this.disposables.push(this.treeLabels);
this.tree = this.instantiationService.createInstance(WorkbenchAsyncDataTree, this.treeContainer, new LoadedScriptsDelegate(),
[new LoadedScriptsRenderer(this.treeLabels)],
@@ -443,11 +443,11 @@ export class LoadedScriptsView extends ViewletPanel {
this.tree.updateChildren();
}
}, 300);
this._register(this.changeScheduler);
this.disposables.push(this.changeScheduler);
const loadedScriptsNavigator = new TreeResourceNavigator2(this.tree);
this._register(loadedScriptsNavigator);
this._register(loadedScriptsNavigator.onDidOpenResource(e => {
this.disposables.push(loadedScriptsNavigator);
this.disposables.push(loadedScriptsNavigator.onDidOpenResource(e => {
if (e.element instanceof BaseTreeItem) {
const source = e.element.getSource();
if (source && source.available) {
@@ -457,7 +457,7 @@ export class LoadedScriptsView extends ViewletPanel {
}
}));
this._register(this.tree.onDidChangeFocus(() => {
this.disposables.push(this.tree.onDidChangeFocus(() => {
const focus = this.tree.getFocus();
if (focus instanceof SessionTreeItem) {
this.loadedScriptsItemType.set('session');
@@ -467,7 +467,7 @@ export class LoadedScriptsView extends ViewletPanel {
}));
const registerLoadedSourceListener = (session: IDebugSession) => {
this._register(session.onDidLoadedSource(event => {
this.disposables.push(session.onDidLoadedSource(event => {
let sessionRoot: SessionTreeItem;
switch (event.reason) {
case 'new':
@@ -501,17 +501,17 @@ export class LoadedScriptsView extends ViewletPanel {
}));
};
this._register(this.debugService.onDidNewSession(registerLoadedSourceListener));
this.disposables.push(this.debugService.onDidNewSession(registerLoadedSourceListener));
this.debugService.getModel().getSessions().forEach(registerLoadedSourceListener);
this._register(this.debugService.onDidEndSession(session => {
this.disposables.push(this.debugService.onDidEndSession(session => {
root.remove(session.getId());
this.changeScheduler.schedule();
}));
this.changeScheduler.schedule(0);
this._register(this.onDidChangeBodyVisibility(visible => {
this.disposables.push(this.onDidChangeBodyVisibility(visible => {
if (visible && this.treeNeedsRefreshOnVisible) {
this.changeScheduler.schedule();
}