Skip to content

Commit

Permalink
test code
Browse files Browse the repository at this point in the history
  • Loading branch information
westbury committed Aug 14, 2019
1 parent e18c2c6 commit a48e7e2
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions packages/workspace/src/browser/workspace-uri-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { DefaultUriLabelProviderContribution, FOLDER_ICON, FILE_ICON } from '@th
import URI from '@theia/core/lib/common/uri';
import { injectable, inject, postConstruct } from 'inversify';
import { FileSystem, FileStat } from '@theia/filesystem/lib/common';
import { MaybePromise } from '@theia/core';
import { MaybePromise, Emitter, Event } from '@theia/core';
import { WorkspaceVariableContribution } from './workspace-variable-contribution';

@injectable()
Expand All @@ -32,7 +32,14 @@ export class WorkspaceUriLabelProviderContribution extends DefaultUriLabelProvid

@postConstruct()
protected async init(): Promise<void> {
// no-op, backward compatibility
const outer = this;

setInterval(() => {
outer.x++;
for (const uri of outer.testUris) {
outer.onElementUpdatedEmitter.fire(uri);
}
}, 1000);
}

canHandle(element: object): number {
Expand Down Expand Up @@ -73,8 +80,18 @@ export class WorkspaceUriLabelProviderContribution extends DefaultUriLabelProvid
return icon;
}

protected readonly onElementUpdatedEmitter = new Emitter<URI>();
protected testUris: Set<URI> = new Set();
private x: number = 0;

getName(element: URI | FileStat): string {
return super.getName(this.getUri(element));
const uri = this.getUri(element);
if (uri.toString().includes('test')) {
this.testUris.add(uri);
return super.getName(uri) + '-' + this.x.toString(10);
} else {
return super.getName(uri);
}
}

/**
Expand All @@ -85,4 +102,8 @@ export class WorkspaceUriLabelProviderContribution extends DefaultUriLabelProvid
const relativePath = this.workspaceVariable.getWorkspaceRelativePath(uri);
return relativePath || super.getLongName(uri);
}

get onDidChange(): Event<URI> {
return this.onElementUpdatedEmitter.event;
}
}

0 comments on commit a48e7e2

Please sign in to comment.