mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
Get rid of IEventService in favour of real events (#17515)
This commit is contained in:
@@ -311,7 +311,7 @@ suite('window namespace tests', () => {
|
||||
});
|
||||
|
||||
test('createTerminal, Terminal.name', () => {
|
||||
var terminal = window.createTerminal('foo');
|
||||
const terminal = window.createTerminal('foo');
|
||||
assert.equal(terminal.name, 'foo');
|
||||
|
||||
assert.throws(() => {
|
||||
|
||||
@@ -12,16 +12,16 @@ suite('Browsers', () => {
|
||||
test('all', function () {
|
||||
assert(!(isWindows && isMacintosh));
|
||||
|
||||
var isOpera = browser.isOpera || navigator.userAgent.indexOf('OPR') >= 0;
|
||||
var isIE11orEarlier = browser.isIE11orEarlier;
|
||||
var isFirefox = browser.isFirefox;
|
||||
var isWebKit = browser.isWebKit;
|
||||
var isChrome = browser.isChrome;
|
||||
var isSafari = browser.isSafari;
|
||||
let isOpera = browser.isOpera || navigator.userAgent.indexOf('OPR') >= 0;
|
||||
let isIE11orEarlier = browser.isIE11orEarlier;
|
||||
let isFirefox = browser.isFirefox;
|
||||
let isWebKit = browser.isWebKit;
|
||||
let isChrome = browser.isChrome;
|
||||
let isSafari = browser.isSafari;
|
||||
|
||||
var hasCSSAnimations = browser.hasCSSAnimationSupport();
|
||||
let hasCSSAnimations = browser.hasCSSAnimationSupport();
|
||||
|
||||
var browserCount = 0;
|
||||
let browserCount = 0;
|
||||
if (isOpera) {
|
||||
browserCount++;
|
||||
}
|
||||
|
||||
@@ -11,18 +11,18 @@ import * as DomUtils from 'vs/base/browser/dom';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
var withElementsBySelector = function (selector: string, offdom: boolean = false) {
|
||||
var elements = window.document.querySelectorAll(selector);
|
||||
let withElementsBySelector = function (selector: string, offdom: boolean = false) {
|
||||
let elements = window.document.querySelectorAll(selector);
|
||||
|
||||
var builders = [];
|
||||
for (var i = 0; i < elements.length; i++) {
|
||||
let builders = [];
|
||||
for (let i = 0; i < elements.length; i++) {
|
||||
builders.push(new Builder(<HTMLElement>elements.item(i), offdom));
|
||||
}
|
||||
|
||||
return new MultiBuilder(builders);
|
||||
};
|
||||
|
||||
var withBuilder = function (builder, offdom) {
|
||||
let withBuilder = function (builder, offdom) {
|
||||
if (builder instanceof MultiBuilder) {
|
||||
return new MultiBuilder(builder);
|
||||
}
|
||||
@@ -31,8 +31,8 @@ var withBuilder = function (builder, offdom) {
|
||||
};
|
||||
|
||||
suite('Builder', () => {
|
||||
var fixture: HTMLElement;
|
||||
var fixtureId = 'builder-fixture';
|
||||
let fixture: HTMLElement;
|
||||
let fixtureId = 'builder-fixture';
|
||||
|
||||
setup(() => {
|
||||
fixture = document.createElement('div');
|
||||
@@ -45,21 +45,21 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Dimension.substract()', function () {
|
||||
var d1 = new Dimension(200, 100);
|
||||
var d2 = new Box(10, 20, 30, 40);
|
||||
let d1 = new Dimension(200, 100);
|
||||
let d2 = new Box(10, 20, 30, 40);
|
||||
|
||||
assert.deepEqual(d1.substract(d2), new Dimension(140, 60));
|
||||
});
|
||||
|
||||
test('Position', function () {
|
||||
var p = new Position(200, 100);
|
||||
let p = new Position(200, 100);
|
||||
assert.strictEqual(p.x, 200);
|
||||
assert.strictEqual(p.y, 100);
|
||||
});
|
||||
|
||||
test('Binding', function () {
|
||||
var b = Build.withElementById(fixtureId, false);
|
||||
var element = b.getHTMLElement();
|
||||
let b = Build.withElementById(fixtureId, false);
|
||||
let element = b.getHTMLElement();
|
||||
|
||||
assert(element);
|
||||
|
||||
@@ -95,10 +95,10 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Select', function () {
|
||||
var b = Build.withElementById(fixtureId, false);
|
||||
let b = Build.withElementById(fixtureId, false);
|
||||
assert(b);
|
||||
|
||||
var allDivs = withElementsBySelector('div');
|
||||
let allDivs = withElementsBySelector('div');
|
||||
|
||||
assert(allDivs);
|
||||
assert(allDivs.length >= 1);
|
||||
@@ -106,13 +106,13 @@ suite('Builder', () => {
|
||||
assert(Types.isFunction(allDivs.pop));
|
||||
assert(allDivs instanceof MultiBuilder);
|
||||
|
||||
for (var key in b) {
|
||||
for (let key in b) {
|
||||
if (b.hasOwnProperty(key) && Types.isFunction(b[key])) {
|
||||
assert(allDivs.hasOwnProperty(key));
|
||||
}
|
||||
}
|
||||
|
||||
var noElement = withElementsBySelector('#thiselementdoesnotexist');
|
||||
let noElement = withElementsBySelector('#thiselementdoesnotexist');
|
||||
|
||||
assert(noElement);
|
||||
assert(noElement.length === 0);
|
||||
@@ -120,7 +120,7 @@ suite('Builder', () => {
|
||||
assert(Types.isFunction(noElement.pop));
|
||||
assert(noElement instanceof MultiBuilder);
|
||||
|
||||
for (key in b) {
|
||||
for (let key in b) {
|
||||
if (b.hasOwnProperty(key) && Types.isFunction(b[key])) {
|
||||
assert(noElement.hasOwnProperty(key));
|
||||
}
|
||||
@@ -128,8 +128,8 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Build.withElement()', function () {
|
||||
var f = Build.withElementById(fixtureId, false);
|
||||
var b = $(f.getHTMLElement());
|
||||
let f = Build.withElementById(fixtureId, false);
|
||||
let b = $(f.getHTMLElement());
|
||||
|
||||
b.addClass('foo');
|
||||
assert(b.hasClass('foo'));
|
||||
@@ -142,8 +142,8 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Build.withBuilder()', function () {
|
||||
var f = Build.withElementById(fixtureId, false);
|
||||
var b = withBuilder(f, false);
|
||||
let f = Build.withElementById(fixtureId, false);
|
||||
let b = withBuilder(f, false);
|
||||
|
||||
b.addClass('foo');
|
||||
assert(b.hasClass('foo'));
|
||||
@@ -156,8 +156,8 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Build.withBuilder() - Multibuilder', function () {
|
||||
var f = withElementsBySelector('#' + fixtureId);
|
||||
var b = withBuilder(f, false);
|
||||
let f = withElementsBySelector('#' + fixtureId);
|
||||
let b = withBuilder(f, false);
|
||||
|
||||
b.addClass('foo');
|
||||
assert(b.hasClass('foo')[0]);
|
||||
@@ -167,7 +167,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Build.offDOM()', function () {
|
||||
var b = $();
|
||||
let b = $();
|
||||
assert(b);
|
||||
|
||||
b.div({
|
||||
@@ -189,7 +189,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Build.withElementById()', function () {
|
||||
var b = Build.withElementById(fixtureId, false);
|
||||
let b = Build.withElementById(fixtureId, false);
|
||||
|
||||
b.addClass('foo');
|
||||
assert(b.hasClass('foo'));
|
||||
@@ -201,7 +201,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('withElementsBySelector()', function () {
|
||||
var b = withElementsBySelector('#' + fixtureId, false);
|
||||
let b = withElementsBySelector('#' + fixtureId, false);
|
||||
|
||||
b.addClass('foo');
|
||||
assert(b.hasClass('foo')[0]);
|
||||
@@ -211,7 +211,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Off DOM withElementById and container passed in', function () {
|
||||
var b = Build.withElementById(fixtureId, true);
|
||||
let b = Build.withElementById(fixtureId, true);
|
||||
assert(b);
|
||||
assert.strictEqual(b.getHTMLElement(), document.getElementById(fixtureId));
|
||||
|
||||
@@ -234,7 +234,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Off DOM withSelector and container passed in', function () {
|
||||
var b = withElementsBySelector('#' + fixtureId, true);
|
||||
let b = withElementsBySelector('#' + fixtureId, true);
|
||||
assert(b);
|
||||
|
||||
b.div({
|
||||
@@ -256,7 +256,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.build() with index specified', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.empty();
|
||||
b.div({ id: '1' });
|
||||
b.div({ id: '2' });
|
||||
@@ -267,10 +267,10 @@ suite('Builder', () => {
|
||||
b.build(Build.withElementById(fixtureId), 0);
|
||||
|
||||
b = Build.withElementById(fixtureId);
|
||||
var divs = b.select('div');
|
||||
let divs = b.select('div');
|
||||
assert.strictEqual(divs.length, 4);
|
||||
|
||||
var ids = divs.attr('id');
|
||||
let ids = divs.attr('id');
|
||||
assert.strictEqual(ids.length, 4);
|
||||
assert.strictEqual(ids[0], '4');
|
||||
assert.strictEqual(ids[1], '1');
|
||||
@@ -295,12 +295,12 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.asContainer()', function () {
|
||||
var f = Build.withElementById(fixtureId, false);
|
||||
let f = Build.withElementById(fixtureId, false);
|
||||
f.div({
|
||||
id: 'foobar'
|
||||
});
|
||||
|
||||
var divBuilder = f.asContainer();
|
||||
let divBuilder = f.asContainer();
|
||||
divBuilder.span({
|
||||
innerHtml: 'see man'
|
||||
});
|
||||
@@ -309,26 +309,26 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.clone()', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
|
||||
var clone = b.clone();
|
||||
let clone = b.clone();
|
||||
assert(clone);
|
||||
assert(clone instanceof Builder);
|
||||
assert.strictEqual(b.getHTMLElement(), clone.getHTMLElement());
|
||||
assert.deepEqual(b, clone);
|
||||
|
||||
var multiB = withElementsBySelector('div');
|
||||
let multiB = withElementsBySelector('div');
|
||||
|
||||
var multiClone = multiB.clone();
|
||||
let multiClone = multiB.clone();
|
||||
assert(multiClone);
|
||||
});
|
||||
|
||||
test('Builder.and() with 2 Builders', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
|
||||
var otherB = Build.withElementById(fixtureId);
|
||||
let otherB = Build.withElementById(fixtureId);
|
||||
|
||||
var bAndB = b.and(otherB);
|
||||
let bAndB = b.and(otherB);
|
||||
|
||||
assert.strictEqual(bAndB.length, 2);
|
||||
|
||||
@@ -336,11 +336,11 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.and() with HTMLElement', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
|
||||
var otherB = Build.withElementById(fixtureId);
|
||||
let otherB = Build.withElementById(fixtureId);
|
||||
|
||||
var bAndB = b.and(otherB.getHTMLElement());
|
||||
let bAndB = b.and(otherB.getHTMLElement());
|
||||
|
||||
assert.strictEqual(bAndB.length, 2);
|
||||
|
||||
@@ -348,39 +348,39 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.and() with MultiBuilder', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
|
||||
var allDivs = withElementsBySelector('div');
|
||||
let allDivs = withElementsBySelector('div');
|
||||
|
||||
var bAndB = b.and(allDivs);
|
||||
let bAndB = b.and(allDivs);
|
||||
|
||||
assert.strictEqual(bAndB.length, 1 + allDivs.length);
|
||||
});
|
||||
|
||||
test('Builder.and() with two MultiBuilders', function () {
|
||||
var allDivs = withElementsBySelector('div');
|
||||
var allDivsCount = allDivs.length;
|
||||
let allDivs = withElementsBySelector('div');
|
||||
let allDivsCount = allDivs.length;
|
||||
|
||||
var otherAllDivs = withElementsBySelector('div');
|
||||
let otherAllDivs = withElementsBySelector('div');
|
||||
|
||||
var allDivsAndAllDivs = allDivs.and(otherAllDivs);
|
||||
let allDivsAndAllDivs = allDivs.and(otherAllDivs);
|
||||
|
||||
assert.strictEqual(allDivsAndAllDivs.length, allDivsCount * 2);
|
||||
assert.strictEqual(allDivs.length, allDivsCount * 2);
|
||||
});
|
||||
|
||||
test('Builder.and() with MultiBuilder and HTMLElement', function () {
|
||||
var allDivs = withElementsBySelector('div');
|
||||
var len = allDivs.length;
|
||||
let allDivs = withElementsBySelector('div');
|
||||
let len = allDivs.length;
|
||||
|
||||
var allDivsFixture = allDivs.and(Build.withElementById(fixtureId).getHTMLElement());
|
||||
let allDivsFixture = allDivs.and(Build.withElementById(fixtureId).getHTMLElement());
|
||||
|
||||
assert.strictEqual(allDivsFixture.length, len + 1);
|
||||
assert.strictEqual(allDivs.length, len + 1);
|
||||
});
|
||||
|
||||
test('Builder Multibuilder fn call that returns Multibuilder', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.div(function (div) {
|
||||
div.span();
|
||||
});
|
||||
@@ -393,14 +393,14 @@ suite('Builder', () => {
|
||||
div.span();
|
||||
});
|
||||
|
||||
var multiBuilder = Build.withElementById(fixtureId).select('div');
|
||||
let multiBuilder = Build.withElementById(fixtureId).select('div');
|
||||
assert(multiBuilder.length === 3);
|
||||
|
||||
assert(multiBuilder.select('span').length === 3);
|
||||
});
|
||||
|
||||
test('Builder.p() and other elements', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.empty();
|
||||
b.div(function (div) {
|
||||
assert(div !== b);
|
||||
@@ -445,38 +445,38 @@ suite('Builder', () => {
|
||||
assert.strictEqual(Build.withElementById('builderlink').attr('href'), '#');
|
||||
|
||||
// Assert HTML through DOM
|
||||
var root = document.getElementById(fixtureId);
|
||||
let root = document.getElementById(fixtureId);
|
||||
assert.strictEqual(b.parent().getHTMLElement(), root);
|
||||
assert.strictEqual(root.childNodes.length, 1);
|
||||
|
||||
var div = root.childNodes[0];
|
||||
let div = root.childNodes[0];
|
||||
assert.strictEqual('div', div.nodeName.toLowerCase());
|
||||
assert.strictEqual(b.getHTMLElement(), div);
|
||||
assert.strictEqual(div.childNodes.length, 1);
|
||||
|
||||
var p = div.childNodes[0];
|
||||
let p = div.childNodes[0];
|
||||
assert.strictEqual('p', p.nodeName.toLowerCase());
|
||||
assert.strictEqual(p.childNodes.length, 1);
|
||||
|
||||
var ul = p.childNodes[0];
|
||||
let ul = p.childNodes[0];
|
||||
assert.strictEqual('ul', ul.nodeName.toLowerCase());
|
||||
assert.strictEqual(ul.childNodes.length, 1);
|
||||
|
||||
var li = ul.childNodes[0];
|
||||
let li = ul.childNodes[0];
|
||||
assert.strictEqual('li', li.nodeName.toLowerCase());
|
||||
assert.strictEqual(li.childNodes.length, 3);
|
||||
|
||||
var span = <HTMLElement>li.childNodes[0];
|
||||
let span = <HTMLElement>li.childNodes[0];
|
||||
assert.strictEqual('span', span.nodeName.toLowerCase());
|
||||
assert.strictEqual(span.childNodes.length, 1);
|
||||
assert.strictEqual(span.innerHTML, 'Foo Bar');
|
||||
|
||||
var img = <HTMLElement>li.childNodes[1];
|
||||
let img = <HTMLElement>li.childNodes[1];
|
||||
assert.strictEqual('img', img.nodeName.toLowerCase());
|
||||
assert.strictEqual(img.childNodes.length, 0);
|
||||
assert.strictEqual(img.getAttribute('src'), '#');
|
||||
|
||||
var a = <HTMLElement>li.childNodes[2];
|
||||
let a = <HTMLElement>li.childNodes[2];
|
||||
assert.strictEqual('a', a.nodeName.toLowerCase());
|
||||
assert.strictEqual(a.childNodes.length, 1);
|
||||
assert.strictEqual(a.getAttribute('href'), '#');
|
||||
@@ -484,7 +484,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.p() and other elements', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.element('div', function (div) {
|
||||
div.element('p', function (p) {
|
||||
p.element('ul', function (ul) {
|
||||
@@ -518,7 +518,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.attr()', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.div();
|
||||
|
||||
assert(!b.attr('id'));
|
||||
@@ -565,7 +565,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.style()', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.div();
|
||||
|
||||
b.style('padding-bottom', '5px');
|
||||
@@ -579,7 +579,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.style() as object literal', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.div();
|
||||
|
||||
b.style({
|
||||
@@ -602,7 +602,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.attributes', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.div();
|
||||
|
||||
b.id('foobar');
|
||||
@@ -640,7 +640,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.addClass() and Co', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.div();
|
||||
|
||||
assert(!b.hasClass('foobar'));
|
||||
@@ -689,7 +689,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.color() and .background()', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.div();
|
||||
|
||||
b.color('red').background('blue');
|
||||
@@ -700,7 +700,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.padding() and .margin()', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.div();
|
||||
|
||||
b.padding(4, 3, 2, 1).margin(1, 2, 3, 4);
|
||||
@@ -718,7 +718,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.position()', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.div();
|
||||
|
||||
b.position(100, 200, 300, 400, 'relative');
|
||||
@@ -731,7 +731,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.size(), .minSize() and .maxSize()', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.div();
|
||||
|
||||
b.size(100, 200);
|
||||
@@ -749,7 +749,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.float() and .clear()', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.div();
|
||||
|
||||
b.float('left');
|
||||
@@ -760,7 +760,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.normal(), .italic(), .bold() and underline()', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.div();
|
||||
|
||||
b.italic().underline().bold();
|
||||
@@ -777,7 +777,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.display() and .overflow()', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.div();
|
||||
|
||||
b.display('inline');
|
||||
@@ -788,7 +788,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.show() and .hide()', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.div();
|
||||
|
||||
b.show();
|
||||
@@ -804,7 +804,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.showDelayed()', function (done) {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.div().hide();
|
||||
|
||||
b.showDelayed(20);
|
||||
@@ -817,7 +817,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.showDelayed() but interrupted', function (done) {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.div().hide();
|
||||
|
||||
b.showDelayed(20);
|
||||
@@ -832,7 +832,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.border(), .borderTop(), .borderBottom(), .borderLeft(), .borderRight()', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.div();
|
||||
|
||||
b.border('1px solid red');
|
||||
@@ -867,7 +867,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.textAlign() and .verticalAlign()', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.div();
|
||||
|
||||
b.textAlign('center');
|
||||
@@ -878,7 +878,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.innerHtml()', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.div();
|
||||
|
||||
b.innerHtml('<b>Foo Bar</b>');
|
||||
@@ -887,7 +887,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.safeInnerHtml()', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.div();
|
||||
|
||||
b.safeInnerHtml('<b>Foo Bar</b>');
|
||||
@@ -900,14 +900,14 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.parent(), .children(), .removeChild() and isEmpty()', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.empty();
|
||||
|
||||
assert(b.isEmpty());
|
||||
assert.strictEqual(b.parent().getHTMLElement(), b.getHTMLElement().parentNode);
|
||||
assert(b.children().length === 0);
|
||||
|
||||
var divB;
|
||||
let divB;
|
||||
b.div(function (div) {
|
||||
divB = div.clone();
|
||||
div.span();
|
||||
@@ -926,24 +926,24 @@ suite('Builder', () => {
|
||||
test('Build Client Area', function () {
|
||||
|
||||
// Global
|
||||
var dimensions = $(document.body).getClientArea();
|
||||
let dimensions = $(document.body).getClientArea();
|
||||
assert(dimensions.width > 0);
|
||||
assert(dimensions.height > 0);
|
||||
|
||||
// Local
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
dimensions = b.getClientArea();
|
||||
// assert(dimensions.width >= 0);
|
||||
// assert(dimensions.height >= 0);
|
||||
});
|
||||
|
||||
// test('Builder.select() and .matches()', function () {
|
||||
// var b = Build.withElementById(fixtureId);
|
||||
// let b = Build.withElementById(fixtureId);
|
||||
|
||||
// assert(b.matches('#' + fixtureId));
|
||||
|
||||
// var divs = withElementsBySelector('div');
|
||||
// for (var i = 0; i < divs.length; i++) {
|
||||
// let divs = withElementsBySelector('div');
|
||||
// for (let i = 0; i < divs.length; i++) {
|
||||
// assert (divs.item(i).matches('div'));
|
||||
// }
|
||||
|
||||
@@ -955,14 +955,14 @@ suite('Builder', () => {
|
||||
// });
|
||||
|
||||
test('Builder.select() and .matches()', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
|
||||
assert(b.getTotalSize());
|
||||
assert(b.getContentSize());
|
||||
});
|
||||
|
||||
test('Builder.preventDefault()', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.element('input', {
|
||||
type: 'button'
|
||||
});
|
||||
@@ -981,12 +981,12 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.once()', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.element('input', {
|
||||
type: 'button'
|
||||
});
|
||||
|
||||
var counter = 0;
|
||||
let counter = 0;
|
||||
b.once(DomUtils.EventType.CLICK, function (e) {
|
||||
counter++;
|
||||
assert(counter <= 1);
|
||||
@@ -997,12 +997,12 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.once() with capture', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.element('input', {
|
||||
type: 'button'
|
||||
});
|
||||
|
||||
var counter = 0;
|
||||
let counter = 0;
|
||||
b.once(DomUtils.EventType.CLICK, function (e) {
|
||||
counter++;
|
||||
assert(counter <= 1);
|
||||
@@ -1013,13 +1013,13 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.on() and .off()', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.element('input', {
|
||||
type: 'button'
|
||||
});
|
||||
|
||||
var listeners = [];
|
||||
var counter = 0;
|
||||
let listeners = [];
|
||||
let counter = 0;
|
||||
b.on(DomUtils.EventType.CLICK, function (e) {
|
||||
counter++;
|
||||
}, listeners);
|
||||
@@ -1037,13 +1037,13 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.on() and .off() with capture', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.element('input', {
|
||||
type: 'button'
|
||||
});
|
||||
|
||||
var listeners = [];
|
||||
var counter = 0;
|
||||
let listeners = [];
|
||||
let counter = 0;
|
||||
b.on(DomUtils.EventType.CLICK, function (e) {
|
||||
counter++;
|
||||
}, listeners, true);
|
||||
@@ -1064,17 +1064,17 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.empty()', function () {
|
||||
var inputs = [];
|
||||
var bindings = [];
|
||||
let inputs = [];
|
||||
let bindings = [];
|
||||
|
||||
var b = Build.withElementById(fixtureId);
|
||||
var counter1 = 0;
|
||||
var counter2 = 0;
|
||||
var counter3 = 0;
|
||||
var counter4 = 0;
|
||||
var counter5 = 0;
|
||||
var counter6 = 0;
|
||||
var counter7 = 0;
|
||||
let b = Build.withElementById(fixtureId);
|
||||
let counter1 = 0;
|
||||
let counter2 = 0;
|
||||
let counter3 = 0;
|
||||
let counter4 = 0;
|
||||
let counter5 = 0;
|
||||
let counter6 = 0;
|
||||
let counter7 = 0;
|
||||
|
||||
b.div(function (div) {
|
||||
div.bind('Foo Bar');
|
||||
@@ -1188,7 +1188,7 @@ suite('Builder', () => {
|
||||
input.domClick();
|
||||
});
|
||||
|
||||
for (var i = 0; i < bindings.length; i++) {
|
||||
for (let i = 0; i < bindings.length; i++) {
|
||||
assert(bindings[i].getBinding());
|
||||
assert(bindings[i].getProperty('Foo'));
|
||||
}
|
||||
@@ -1200,7 +1200,7 @@ suite('Builder', () => {
|
||||
input.domClick();
|
||||
});
|
||||
|
||||
for (i = 0; i < bindings.length; i++) {
|
||||
for (let i = 0; i < bindings.length; i++) {
|
||||
assert(!bindings[i].getBinding());
|
||||
assert(!bindings[i].getProperty('Foo'));
|
||||
}
|
||||
@@ -1215,13 +1215,13 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.empty() cleans all listeners', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
var unbindCounter = 0;
|
||||
let b = Build.withElementById(fixtureId);
|
||||
let unbindCounter = 0;
|
||||
|
||||
var old = DomUtils.addDisposableListener;
|
||||
let old = DomUtils.addDisposableListener;
|
||||
try {
|
||||
(DomUtils as any).addDisposableListener = function (node, type, handler) {
|
||||
var unbind: IDisposable = old.call(null, node, type, handler);
|
||||
let unbind: IDisposable = old.call(null, node, type, handler);
|
||||
|
||||
return {
|
||||
dispose: function () {
|
||||
@@ -1251,17 +1251,17 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.destroy()', function () {
|
||||
var inputs = [];
|
||||
var bindings = [];
|
||||
let inputs = [];
|
||||
let bindings = [];
|
||||
|
||||
var b = Build.withElementById(fixtureId);
|
||||
var counter1 = 0;
|
||||
var counter2 = 0;
|
||||
var counter3 = 0;
|
||||
var counter4 = 0;
|
||||
var counter5 = 0;
|
||||
var counter6 = 0;
|
||||
var counter7 = 0;
|
||||
let b = Build.withElementById(fixtureId);
|
||||
let counter1 = 0;
|
||||
let counter2 = 0;
|
||||
let counter3 = 0;
|
||||
let counter4 = 0;
|
||||
let counter5 = 0;
|
||||
let counter6 = 0;
|
||||
let counter7 = 0;
|
||||
|
||||
b.div(function (div) {
|
||||
div.bind('Foo Bar');
|
||||
@@ -1375,7 +1375,7 @@ suite('Builder', () => {
|
||||
input.domClick();
|
||||
});
|
||||
|
||||
for (var i = 0; i < bindings.length; i++) {
|
||||
for (let i = 0; i < bindings.length; i++) {
|
||||
assert(bindings[i].getBinding());
|
||||
assert(bindings[i].getProperty('Foo'));
|
||||
}
|
||||
@@ -1387,7 +1387,7 @@ suite('Builder', () => {
|
||||
input.domClick();
|
||||
});
|
||||
|
||||
for (i = 0; i < bindings.length; i++) {
|
||||
for (let i = 0; i < bindings.length; i++) {
|
||||
assert(!bindings[i].getBinding());
|
||||
assert(!bindings[i].getProperty('Foo'));
|
||||
}
|
||||
@@ -1402,13 +1402,13 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.destroy() cleans all listeners', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
var unbindCounter = 0;
|
||||
let b = Build.withElementById(fixtureId);
|
||||
let unbindCounter = 0;
|
||||
|
||||
var old = DomUtils.addDisposableListener;
|
||||
let old = DomUtils.addDisposableListener;
|
||||
try {
|
||||
(DomUtils as any).addDisposableListener = function (node, type, handler) {
|
||||
var unbind: IDisposable = old.call(null, node, type, handler);
|
||||
let unbind: IDisposable = old.call(null, node, type, handler);
|
||||
|
||||
return {
|
||||
dispose: function () {
|
||||
@@ -1440,10 +1440,10 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.empty() MultiBuilder', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
var inputs = [];
|
||||
let b = Build.withElementById(fixtureId);
|
||||
let inputs = [];
|
||||
|
||||
var firstCounter = 0;
|
||||
let firstCounter = 0;
|
||||
b.div(function (div) {
|
||||
div.element('input', {
|
||||
type: 'button'
|
||||
@@ -1454,7 +1454,7 @@ suite('Builder', () => {
|
||||
inputs.push(div.clone());
|
||||
});
|
||||
|
||||
var secondCounter = 0;
|
||||
let secondCounter = 0;
|
||||
b.div(function (div) {
|
||||
div.element('input', {
|
||||
type: 'button'
|
||||
@@ -1465,7 +1465,7 @@ suite('Builder', () => {
|
||||
inputs.push(div.clone());
|
||||
});
|
||||
|
||||
var thirdCounter = 0;
|
||||
let thirdCounter = 0;
|
||||
b.div(function (div) {
|
||||
div.element('input', {
|
||||
type: 'button'
|
||||
@@ -1490,7 +1490,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder .domFocus(), .domBlur(), .hasFocus()', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
|
||||
b.element('input', { type: 'text' });
|
||||
assert(!b.hasFocus());
|
||||
@@ -1501,7 +1501,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder misc', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.div();
|
||||
|
||||
b.on([DomUtils.EventType.CLICK, DomUtils.EventType.MOUSE_DOWN, DomUtils.EventType.MOUSE_UP], function (e, b) {
|
||||
@@ -1526,7 +1526,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('Builder.offDOM()', function () {
|
||||
var b = Build.withElementById(fixtureId);
|
||||
let b = Build.withElementById(fixtureId);
|
||||
b.div({ id: '1' });
|
||||
|
||||
assert(Build.withElementById('1'));
|
||||
@@ -1537,7 +1537,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('$ - selector construction', function () {
|
||||
var obj = $('div');
|
||||
let obj = $('div');
|
||||
assert(obj instanceof Builder);
|
||||
assert(DomUtils.isHTMLElement(obj.getHTMLElement()));
|
||||
assert.equal(obj.getHTMLElement().tagName.toLowerCase(), 'div');
|
||||
@@ -1595,7 +1595,7 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('$ - wrap elements and builders', function () {
|
||||
var obj = $('#' + fixtureId);
|
||||
let obj = $('#' + fixtureId);
|
||||
assert(obj instanceof Builder);
|
||||
obj = $(obj.getHTMLElement());
|
||||
assert(obj instanceof Builder);
|
||||
@@ -1604,29 +1604,29 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('$ - delegate to #element', function () {
|
||||
var obj = $('a', { 'class': 'a1', innerHtml: 'Hello' });
|
||||
let obj = $('a', { 'class': 'a1', innerHtml: 'Hello' });
|
||||
assert(obj instanceof Builder);
|
||||
var el = obj.getHTMLElement();
|
||||
let el = obj.getHTMLElement();
|
||||
assert.equal(el.tagName.toLowerCase(), 'a');
|
||||
assert.equal(el.className, 'a1');
|
||||
assert.equal(el.innerHTML, 'Hello');
|
||||
});
|
||||
|
||||
test('$ - html', function () {
|
||||
var obj = $('<a class="a1">Hello</a>');
|
||||
let obj = $('<a class="a1">Hello</a>');
|
||||
assert(obj instanceof Builder);
|
||||
var el = obj.getHTMLElement();
|
||||
let el = obj.getHTMLElement();
|
||||
assert.equal(el.tagName.toLowerCase(), 'a');
|
||||
assert.equal(el.className, 'a1');
|
||||
assert.equal(el.innerHTML, 'Hello');
|
||||
});
|
||||
|
||||
test('$ - multiple html tags', function () {
|
||||
var objs = <MultiBuilder>$('<a class="a1">Hello</a><a class="a2">There</a>');
|
||||
let objs = <MultiBuilder>$('<a class="a1">Hello</a><a class="a2">There</a>');
|
||||
assert(objs instanceof MultiBuilder);
|
||||
assert.equal(objs.length, 2);
|
||||
|
||||
var obj = objs.item(0).getHTMLElement();
|
||||
let obj = objs.item(0).getHTMLElement();
|
||||
assert.equal(obj.tagName.toLowerCase(), 'a');
|
||||
assert.equal(obj.className, 'a1');
|
||||
assert.equal(obj.innerHTML, 'Hello');
|
||||
@@ -1638,11 +1638,11 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('$ - html format', function () {
|
||||
var objs = <MultiBuilder>(<any>$)('<a class="{0}">{1}</a><a class="{2}">{3}</a>', 'a1', 'Hello', 'a2', 'There');
|
||||
let objs = <MultiBuilder>(<any>$)('<a class="{0}">{1}</a><a class="{2}">{3}</a>', 'a1', 'Hello', 'a2', 'There');
|
||||
assert(objs instanceof MultiBuilder);
|
||||
assert.equal(objs.length, 2);
|
||||
|
||||
var obj = objs.item(0).getHTMLElement();
|
||||
let obj = objs.item(0).getHTMLElement();
|
||||
assert.equal(obj.tagName.toLowerCase(), 'a');
|
||||
assert.equal(obj.className, 'a1');
|
||||
assert.equal(obj.innerHTML, 'Hello');
|
||||
@@ -1659,9 +1659,9 @@ suite('Builder', () => {
|
||||
});
|
||||
|
||||
test('$ - appendTo, append', function () {
|
||||
var peel = $('<div class="peel"></div>');
|
||||
var core = $('<span class="core"></span>').appendTo(peel);
|
||||
var obj = peel.getHTMLElement();
|
||||
let peel = $('<div class="peel"></div>');
|
||||
let core = $('<span class="core"></span>').appendTo(peel);
|
||||
let obj = peel.getHTMLElement();
|
||||
assert(obj);
|
||||
assert.equal(obj.tagName.toLowerCase(), 'div');
|
||||
assert.equal(obj.className, 'peel');
|
||||
|
||||
@@ -11,7 +11,7 @@ const $ = dom.$;
|
||||
suite('dom', () => {
|
||||
test('hasClass', () => {
|
||||
|
||||
var element = document.createElement('div');
|
||||
let element = document.createElement('div');
|
||||
element.className = 'foobar boo far';
|
||||
|
||||
assert(dom.hasClass(element, 'foobar'));
|
||||
@@ -24,7 +24,7 @@ suite('dom', () => {
|
||||
|
||||
test('removeClass', () => {
|
||||
|
||||
var element = document.createElement('div');
|
||||
let element = document.createElement('div');
|
||||
element.className = 'foobar boo far';
|
||||
|
||||
dom.removeClass(element, 'boo');
|
||||
@@ -56,7 +56,7 @@ suite('dom', () => {
|
||||
});
|
||||
|
||||
test('removeClass should consider hyphens', function () {
|
||||
var element = document.createElement('div');
|
||||
let element = document.createElement('div');
|
||||
|
||||
dom.addClass(element, 'foo-bar bar');
|
||||
assert(dom.hasClass(element, 'foo-bar'));
|
||||
@@ -73,8 +73,8 @@ suite('dom', () => {
|
||||
|
||||
//test('[perf] hasClass * 100000', () => {
|
||||
//
|
||||
// for (var i = 0; i < 100000; i++) {
|
||||
// var element = document.createElement('div');
|
||||
// for (let i = 0; i < 100000; i++) {
|
||||
// let element = document.createElement('div');
|
||||
// element.className = 'foobar boo far';
|
||||
//
|
||||
// assert(dom.hasClass(element, 'far'));
|
||||
@@ -84,21 +84,21 @@ suite('dom', () => {
|
||||
//});
|
||||
|
||||
test('safeStringify', function () {
|
||||
var obj1 = {
|
||||
let obj1 = {
|
||||
friend: null
|
||||
};
|
||||
|
||||
var obj2 = {
|
||||
let obj2 = {
|
||||
friend: null
|
||||
};
|
||||
|
||||
obj1.friend = obj2;
|
||||
obj2.friend = obj1;
|
||||
|
||||
var arr: any = [1];
|
||||
let arr: any = [1];
|
||||
arr.push(arr);
|
||||
|
||||
var circular = {
|
||||
let circular = {
|
||||
a: 42,
|
||||
b: null,
|
||||
c: [
|
||||
@@ -111,7 +111,7 @@ suite('dom', () => {
|
||||
circular.b = circular;
|
||||
circular.d = arr;
|
||||
|
||||
var result = dom.safeStringifyDOMAware(circular);
|
||||
let result = dom.safeStringifyDOMAware(circular);
|
||||
|
||||
assert.deepEqual(JSON.parse(result), {
|
||||
a: 42,
|
||||
@@ -129,7 +129,7 @@ suite('dom', () => {
|
||||
});
|
||||
|
||||
test('safeStringify2', function () {
|
||||
var obj: any = {
|
||||
let obj: any = {
|
||||
a: null,
|
||||
b: document.createElement('div'),
|
||||
c: null,
|
||||
@@ -139,7 +139,7 @@ suite('dom', () => {
|
||||
g: 42
|
||||
};
|
||||
|
||||
var result = dom.safeStringifyDOMAware(obj);
|
||||
let result = dom.safeStringifyDOMAware(obj);
|
||||
|
||||
assert.deepEqual(JSON.parse(result), {
|
||||
a: null,
|
||||
|
||||
@@ -8,7 +8,7 @@ import * as assert from 'assert';
|
||||
import { HighlightedLabel } from 'vs/base/browser/ui/highlightedlabel/highlightedLabel';
|
||||
|
||||
suite('HighlightedLabel', () => {
|
||||
var label: HighlightedLabel;
|
||||
let label: HighlightedLabel;
|
||||
|
||||
setup(() => {
|
||||
label = new HighlightedLabel(document.createElement('div'));
|
||||
|
||||
@@ -9,7 +9,7 @@ import { ProgressBar } from 'vs/base/browser/ui/progressbar/progressbar';
|
||||
import { Builder } from 'vs/base/browser/builder';
|
||||
|
||||
suite('ProgressBar', () => {
|
||||
var fixture: HTMLElement;
|
||||
let fixture: HTMLElement;
|
||||
|
||||
setup(() => {
|
||||
fixture = document.createElement('div');
|
||||
@@ -21,9 +21,9 @@ suite('ProgressBar', () => {
|
||||
});
|
||||
|
||||
test('Progress Bar', function () {
|
||||
var b = new Builder(fixture);
|
||||
const b = new Builder(fixture);
|
||||
|
||||
var bar = new ProgressBar(b);
|
||||
const bar = new ProgressBar(b);
|
||||
assert(bar.getContainer());
|
||||
assert(bar.infinite());
|
||||
assert(bar.total(100));
|
||||
|
||||
@@ -10,11 +10,11 @@ import { DataSource } from 'vs/base/parts/quickopen/browser/quickOpenViewer';
|
||||
|
||||
suite('QuickOpen', () => {
|
||||
test('QuickOpenModel', () => {
|
||||
var model = new QuickOpenModel();
|
||||
const model = new QuickOpenModel();
|
||||
|
||||
var entry1 = new QuickOpenEntry();
|
||||
var entry2 = new QuickOpenEntry();
|
||||
var entry3 = new QuickOpenEntryGroup();
|
||||
const entry1 = new QuickOpenEntry();
|
||||
const entry2 = new QuickOpenEntry();
|
||||
const entry3 = new QuickOpenEntryGroup();
|
||||
|
||||
assert.notEqual(entry1.getId(), entry2.getId());
|
||||
assert.notEqual(entry2.getId(), entry3.getId());
|
||||
@@ -31,15 +31,15 @@ suite('QuickOpen', () => {
|
||||
});
|
||||
|
||||
test('QuickOpenDataSource', () => {
|
||||
var model = new QuickOpenModel();
|
||||
const model = new QuickOpenModel();
|
||||
|
||||
var entry1 = new QuickOpenEntry();
|
||||
var entry2 = new QuickOpenEntry();
|
||||
var entry3 = new QuickOpenEntryGroup();
|
||||
const entry1 = new QuickOpenEntry();
|
||||
const entry2 = new QuickOpenEntry();
|
||||
const entry3 = new QuickOpenEntryGroup();
|
||||
|
||||
model.addEntries([entry1, entry2, entry3]);
|
||||
|
||||
var ds = new DataSource(model);
|
||||
const ds = new DataSource(model);
|
||||
assert.equal(entry1.getId(), ds.getId(null, entry1));
|
||||
assert.equal(true, ds.hasChildren(null, model));
|
||||
assert.equal(false, ds.hasChildren(null, entry1));
|
||||
|
||||
@@ -9,9 +9,9 @@ import arrays = require('vs/base/common/arrays');
|
||||
|
||||
suite('Arrays', () => {
|
||||
test('findFirst', function () {
|
||||
var array = [1, 4, 5, 7, 55, 59, 60, 61, 64, 69];
|
||||
const array = [1, 4, 5, 7, 55, 59, 60, 61, 64, 69];
|
||||
|
||||
var idx = arrays.findFirst(array, e => e >= 0);
|
||||
let idx = arrays.findFirst(array, e => e >= 0);
|
||||
assert.equal(array[idx], 1);
|
||||
|
||||
idx = arrays.findFirst(array, e => e > 1);
|
||||
@@ -37,7 +37,7 @@ suite('Arrays', () => {
|
||||
function compare(a: number, b: number): number {
|
||||
return a - b;
|
||||
}
|
||||
var array = [1, 4, 5, 7, 55, 59, 60, 61, 64, 69];
|
||||
const array = [1, 4, 5, 7, 55, 59, 60, 61, 64, 69];
|
||||
|
||||
assert.equal(arrays.binarySearch(array, 1, compare), 0);
|
||||
assert.equal(arrays.binarySearch(array, 5, compare), 2);
|
||||
|
||||
@@ -16,7 +16,7 @@ suite('CancellationToken', function () {
|
||||
|
||||
test('cancel before token', function (done) {
|
||||
|
||||
var source = new CancellationTokenSource();
|
||||
const source = new CancellationTokenSource();
|
||||
assert.equal(source.token.isCancellationRequested, false);
|
||||
source.cancel();
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ suite('Collections', () => {
|
||||
assert(collections.contains({ toString: 123 }, 'toString'));
|
||||
assert(!collections.contains(Object.create(null), 'toString'));
|
||||
|
||||
var dict = Object.create(null);
|
||||
let dict = Object.create(null);
|
||||
dict['toString'] = 123;
|
||||
assert(collections.contains(dict, 'toString'));
|
||||
});
|
||||
@@ -23,12 +23,12 @@ suite('Collections', () => {
|
||||
collections.forEach({}, () => assert(false));
|
||||
collections.forEach(Object.create(null), () => assert(false));
|
||||
|
||||
var count = 0;
|
||||
let count = 0;
|
||||
collections.forEach({ toString: 123 }, () => count++);
|
||||
assert.equal(count, 1);
|
||||
|
||||
count = 0;
|
||||
var dict = Object.create(null);
|
||||
let dict = Object.create(null);
|
||||
dict['toString'] = 123;
|
||||
collections.forEach(dict, () => count++);
|
||||
assert.equal(count, 1);
|
||||
|
||||
@@ -12,7 +12,7 @@ suite('Errors', () => {
|
||||
assert.strictEqual(toErrorMessage('Foo Bar'), 'Foo Bar');
|
||||
assert.strictEqual(toErrorMessage(new Error('Foo Bar')), 'Foo Bar');
|
||||
|
||||
var error: any = new Error();
|
||||
let error: any = new Error();
|
||||
error.status = 404;
|
||||
error.statusText = 'Not Found';
|
||||
assert.strictEqual(toErrorMessage(error), 'Not Found (HTTP 404)');
|
||||
@@ -34,7 +34,7 @@ suite('Errors', () => {
|
||||
error.detail = {};
|
||||
error.detail.error = [];
|
||||
|
||||
var foo: any = {};
|
||||
let foo: any = {};
|
||||
error.detail.error.push(foo);
|
||||
foo.status = 404;
|
||||
foo.statusText = 'Not Found';
|
||||
|
||||
@@ -159,7 +159,7 @@ suite('Event', function () {
|
||||
});
|
||||
|
||||
test('throwingListener', function () {
|
||||
var origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
|
||||
const origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
|
||||
Errors.setUnexpectedErrorHandler(() => null);
|
||||
|
||||
try {
|
||||
|
||||
@@ -8,7 +8,7 @@ import * as assert from 'assert';
|
||||
import { EventEmitter, OrderGuaranteeEventEmitter } from 'vs/base/common/eventEmitter';
|
||||
|
||||
suite('EventEmitter', () => {
|
||||
var eventEmitter: EventEmitter;
|
||||
let eventEmitter: EventEmitter;
|
||||
|
||||
setup(() => {
|
||||
eventEmitter = new EventEmitter();
|
||||
@@ -20,7 +20,7 @@ suite('EventEmitter', () => {
|
||||
});
|
||||
|
||||
test('add listener, emit other event type', function () {
|
||||
var didCall = false;
|
||||
let didCall = false;
|
||||
eventEmitter.addListener2('eventType1', function (e) {
|
||||
didCall = true;
|
||||
});
|
||||
@@ -29,7 +29,7 @@ suite('EventEmitter', () => {
|
||||
});
|
||||
|
||||
test('add listener, emit event', function () {
|
||||
var didCall = false;
|
||||
let didCall = false;
|
||||
eventEmitter.addListener2('eventType', function (e) {
|
||||
didCall = true;
|
||||
});
|
||||
@@ -38,11 +38,11 @@ suite('EventEmitter', () => {
|
||||
});
|
||||
|
||||
test('add 2 listeners, emit event', function () {
|
||||
var didCallFirst = false;
|
||||
let didCallFirst = false;
|
||||
eventEmitter.addListener2('eventType', function (e) {
|
||||
didCallFirst = true;
|
||||
});
|
||||
var didCallSecond = false;
|
||||
let didCallSecond = false;
|
||||
eventEmitter.addListener2('eventType', function (e) {
|
||||
didCallSecond = true;
|
||||
});
|
||||
@@ -52,8 +52,8 @@ suite('EventEmitter', () => {
|
||||
});
|
||||
|
||||
test('add 1 listener, remove it, emit event', function () {
|
||||
var didCall = false;
|
||||
var remove = eventEmitter.addListener2('eventType', function (e) {
|
||||
let didCall = false;
|
||||
let remove = eventEmitter.addListener2('eventType', function (e) {
|
||||
didCall = true;
|
||||
});
|
||||
remove.dispose();
|
||||
@@ -62,12 +62,12 @@ suite('EventEmitter', () => {
|
||||
});
|
||||
|
||||
test('add 2 listeners, emit event, remove one while processing', function () {
|
||||
var firstCallCount = 0;
|
||||
var remove1 = eventEmitter.addListener2('eventType', function (e) {
|
||||
let firstCallCount = 0;
|
||||
let remove1 = eventEmitter.addListener2('eventType', function (e) {
|
||||
firstCallCount++;
|
||||
remove1.dispose();
|
||||
});
|
||||
var secondCallCount = 0;
|
||||
let secondCallCount = 0;
|
||||
eventEmitter.addListener2('eventType', function (e) {
|
||||
secondCallCount++;
|
||||
});
|
||||
@@ -78,7 +78,7 @@ suite('EventEmitter', () => {
|
||||
});
|
||||
|
||||
test('event object is assert', function () {
|
||||
var data: any;
|
||||
let data: any;
|
||||
eventEmitter.addListener2('eventType', function (e) {
|
||||
data = e.data;
|
||||
});
|
||||
@@ -87,7 +87,7 @@ suite('EventEmitter', () => {
|
||||
});
|
||||
|
||||
test('deferred emit', function () {
|
||||
var calledCount = 0;
|
||||
let calledCount = 0;
|
||||
eventEmitter.addListener2('eventType', function (e) {
|
||||
calledCount++;
|
||||
});
|
||||
@@ -102,7 +102,7 @@ suite('EventEmitter', () => {
|
||||
});
|
||||
|
||||
test('deferred emit maintains events order', function () {
|
||||
var order = 0;
|
||||
let order = 0;
|
||||
eventEmitter.addListener2('eventType2', function (e) {
|
||||
order++;
|
||||
assert.equal(order, 1);
|
||||
@@ -119,7 +119,7 @@ suite('EventEmitter', () => {
|
||||
});
|
||||
|
||||
test('deferred emit maintains events order for bulk listeners', function () {
|
||||
var count = 0;
|
||||
let count = 0;
|
||||
eventEmitter.addBulkListener2(function (events) {
|
||||
assert.equal(events[0].getType(), 'eventType2');
|
||||
assert.equal(events[1].getType(), 'eventType1');
|
||||
@@ -133,7 +133,7 @@ suite('EventEmitter', () => {
|
||||
});
|
||||
|
||||
test('emit notifies bulk listeners', function () {
|
||||
var count = 0;
|
||||
let count = 0;
|
||||
eventEmitter.addBulkListener2(function (events) {
|
||||
count++;
|
||||
});
|
||||
@@ -142,15 +142,15 @@ suite('EventEmitter', () => {
|
||||
});
|
||||
|
||||
test('one event emitter, one listener', function () {
|
||||
var emitter = new EventEmitter();
|
||||
var eventBus = new EventEmitter();
|
||||
let emitter = new EventEmitter();
|
||||
let eventBus = new EventEmitter();
|
||||
|
||||
eventBus.addEmitter2(emitter);
|
||||
var didCallFirst = false;
|
||||
let didCallFirst = false;
|
||||
eventBus.addListener2('eventType', function (e) {
|
||||
didCallFirst = true;
|
||||
});
|
||||
var didCallSecond = false;
|
||||
let didCallSecond = false;
|
||||
eventBus.addListener2('eventType', function (e) {
|
||||
didCallSecond = true;
|
||||
});
|
||||
@@ -161,10 +161,10 @@ suite('EventEmitter', () => {
|
||||
});
|
||||
|
||||
test('two event emitters, two listeners, deferred emit', function () {
|
||||
var callCnt = 0;
|
||||
var emitter1 = new EventEmitter();
|
||||
var emitter2 = new EventEmitter();
|
||||
var eventBus = new EventEmitter();
|
||||
let callCnt = 0;
|
||||
let emitter1 = new EventEmitter();
|
||||
let emitter2 = new EventEmitter();
|
||||
let eventBus = new EventEmitter();
|
||||
|
||||
eventBus.addEmitter2(emitter1);
|
||||
eventBus.addEmitter2(emitter2);
|
||||
@@ -187,16 +187,16 @@ suite('EventEmitter', () => {
|
||||
});
|
||||
|
||||
test('cascading emitters', function () {
|
||||
var emitter1 = new EventEmitter();
|
||||
var emitter2 = new EventEmitter();
|
||||
var emitter3 = new EventEmitter();
|
||||
var emitter4 = new EventEmitter();
|
||||
let emitter1 = new EventEmitter();
|
||||
let emitter2 = new EventEmitter();
|
||||
let emitter3 = new EventEmitter();
|
||||
let emitter4 = new EventEmitter();
|
||||
|
||||
emitter2.addEmitter2(emitter1);
|
||||
emitter3.addEmitter2(emitter2);
|
||||
emitter4.addEmitter2(emitter3);
|
||||
|
||||
var didCall = false;
|
||||
let didCall = false;
|
||||
emitter4.addListener2('eventType', function (e) {
|
||||
didCall = true;
|
||||
});
|
||||
@@ -206,8 +206,8 @@ suite('EventEmitter', () => {
|
||||
});
|
||||
|
||||
test('EventEmitter makes no order guarantees 1', () => {
|
||||
var emitter = new EventEmitter();
|
||||
var actualCallOrder: string[] = [];
|
||||
let emitter = new EventEmitter();
|
||||
let actualCallOrder: string[] = [];
|
||||
|
||||
emitter.addListener2('foo', function () {
|
||||
actualCallOrder.push('listener1-foo');
|
||||
@@ -232,8 +232,8 @@ suite('EventEmitter', () => {
|
||||
});
|
||||
|
||||
test('EventEmitter makes no order guarantees 2', () => {
|
||||
var emitter = new EventEmitter();
|
||||
var actualCallOrder: string[] = [];
|
||||
let emitter = new EventEmitter();
|
||||
let actualCallOrder: string[] = [];
|
||||
|
||||
emitter.addListener2('foo', function () {
|
||||
actualCallOrder.push('listener1-foo');
|
||||
@@ -262,8 +262,8 @@ suite('EventEmitter', () => {
|
||||
});
|
||||
|
||||
test('OrderGuaranteeEventEmitter makes order guarantees 1', () => {
|
||||
var emitter = new OrderGuaranteeEventEmitter();
|
||||
var actualCallOrder: string[] = [];
|
||||
let emitter = new OrderGuaranteeEventEmitter();
|
||||
let actualCallOrder: string[] = [];
|
||||
|
||||
emitter.addListener2('foo', function () {
|
||||
actualCallOrder.push('listener1-foo');
|
||||
@@ -288,8 +288,8 @@ suite('EventEmitter', () => {
|
||||
});
|
||||
|
||||
test('OrderGuaranteeEventEmitter makes order guarantees 2', () => {
|
||||
var emitter = new OrderGuaranteeEventEmitter();
|
||||
var actualCallOrder: string[] = [];
|
||||
let emitter = new OrderGuaranteeEventEmitter();
|
||||
let actualCallOrder: string[] = [];
|
||||
|
||||
emitter.addListener2('foo', function () {
|
||||
actualCallOrder.push('listener1-foo');
|
||||
|
||||
@@ -8,7 +8,7 @@ import * as assert from 'assert';
|
||||
import { IFilter, or, matchesPrefix, matchesStrictPrefix, matchesCamelCase, matchesSubString, matchesContiguousSubString, matchesWords } from 'vs/base/common/filters';
|
||||
|
||||
function filterOk(filter: IFilter, word: string, wordToMatchAgainst: string, highlights?: { start: number; end: number; }[]) {
|
||||
var r = filter(word, wordToMatchAgainst);
|
||||
let r = filter(word, wordToMatchAgainst);
|
||||
assert(r);
|
||||
if (highlights) {
|
||||
assert.deepEqual(r, highlights);
|
||||
@@ -21,8 +21,8 @@ function filterNotOk(filter, word, suggestion) {
|
||||
|
||||
suite('Filters', () => {
|
||||
test('or', function () {
|
||||
var filter, counters;
|
||||
var newFilter = function (i, r) {
|
||||
let filter, counters;
|
||||
let newFilter = function (i, r) {
|
||||
return function () { counters[i]++; return r; };
|
||||
};
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import { guessMimeTypes, registerTextMime } from 'vs/base/common/mime';
|
||||
|
||||
suite('Mime', () => {
|
||||
test('Dynamically Register Text Mime', () => {
|
||||
var guess = guessMimeTypes('foo.monaco');
|
||||
let guess = guessMimeTypes('foo.monaco');
|
||||
assert.deepEqual(guess, ['application/unknown']);
|
||||
|
||||
registerTextMime({ id: 'monaco', extension: '.monaco', mime: 'text/monaco' });
|
||||
@@ -48,7 +48,7 @@ suite('Mime', () => {
|
||||
registerTextMime({ id: 'monaco', extension: '.monaco', mime: 'text/monaco' });
|
||||
registerTextMime({ id: 'foobar', mime: 'text/foobar', firstline: /foobar/ });
|
||||
|
||||
var guess = guessMimeTypes('foo.monaco');
|
||||
let guess = guessMimeTypes('foo.monaco');
|
||||
assert.deepEqual(guess, ['text/monaco', 'text/plain']);
|
||||
|
||||
guess = guessMimeTypes('foo.monaco', 'foobar');
|
||||
@@ -81,7 +81,7 @@ suite('Mime', () => {
|
||||
registerTextMime({ id: 'monaco', extension: '.monaco.xml', mime: 'text/monaco-xml' });
|
||||
registerTextMime({ id: 'monaco', extension: '.monaco.xml.build', mime: 'text/monaco-xml-build' });
|
||||
|
||||
var guess = guessMimeTypes('foo.monaco');
|
||||
let guess = guessMimeTypes('foo.monaco');
|
||||
assert.deepEqual(guess, ['text/monaco', 'text/plain']);
|
||||
|
||||
guess = guessMimeTypes('foo.monaco.xml');
|
||||
@@ -95,7 +95,7 @@ suite('Mime', () => {
|
||||
registerTextMime({ id: 'monaco', extension: '.monaco.xnl', mime: 'text/monaco', userConfigured: true });
|
||||
registerTextMime({ id: 'monaco', extension: '.monaco.xml', mime: 'text/monaco-xml' });
|
||||
|
||||
var guess = guessMimeTypes('foo.monaco.xnl');
|
||||
let guess = guessMimeTypes('foo.monaco.xnl');
|
||||
assert.deepEqual(guess, ['text/monaco', 'text/plain']);
|
||||
});
|
||||
|
||||
@@ -103,7 +103,7 @@ suite('Mime', () => {
|
||||
registerTextMime({ id: 'monaco', filepattern: '**/dot.monaco.xml', mime: 'text/monaco' });
|
||||
registerTextMime({ id: 'other', filepattern: '*ot.other.xml', mime: 'text/other' });
|
||||
|
||||
var guess = guessMimeTypes('/some/path/dot.monaco.xml');
|
||||
let guess = guessMimeTypes('/some/path/dot.monaco.xml');
|
||||
assert.deepEqual(guess, ['text/monaco', 'text/plain']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ import URI from 'vs/base/common/uri';
|
||||
|
||||
function assertUrl(raw: string, scheme: string, domain: string, port: string, path: string, queryString: string, fragmentId: string): void {
|
||||
// check for equivalent behaviour
|
||||
var uri = URI.parse(raw);
|
||||
const uri = URI.parse(raw);
|
||||
assert.equal(uri.scheme, scheme);
|
||||
assert.equal(uri.authority, port ? domain + ':' + port : domain);
|
||||
assert.equal(uri.path, path);
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
import * as assert from 'assert';
|
||||
import objects = require('vs/base/common/objects');
|
||||
|
||||
var check = (one, other, msg) => {
|
||||
let check = (one, other, msg) => {
|
||||
assert(objects.equals(one, other), msg);
|
||||
assert(objects.equals(other, one), '[reverse] ' + msg);
|
||||
};
|
||||
|
||||
var checkNot = (one, other, msg) => {
|
||||
let checkNot = (one, other, msg) => {
|
||||
assert(!objects.equals(one, other), msg);
|
||||
assert(!objects.equals(other, one), '[reverse] ' + msg);
|
||||
};
|
||||
@@ -57,7 +57,7 @@ suite('Objects', () => {
|
||||
|
||||
test('mixin - array', function () {
|
||||
|
||||
var foo: any = {};
|
||||
let foo: any = {};
|
||||
objects.mixin(foo, { bar: [1, 2, 3] });
|
||||
|
||||
assert(foo.bar);
|
||||
@@ -69,11 +69,11 @@ suite('Objects', () => {
|
||||
});
|
||||
|
||||
test('mixin - no overwrite', function () {
|
||||
var foo: any = {
|
||||
let foo: any = {
|
||||
bar: '123'
|
||||
};
|
||||
|
||||
var bar: any = {
|
||||
let bar: any = {
|
||||
bar: '456'
|
||||
};
|
||||
|
||||
@@ -83,8 +83,8 @@ suite('Objects', () => {
|
||||
});
|
||||
|
||||
test('cloneAndChange', () => {
|
||||
var o1 = { something: 'hello' };
|
||||
var o = {
|
||||
let o1 = { something: 'hello' };
|
||||
let o = {
|
||||
o1: o1,
|
||||
o2: o1
|
||||
};
|
||||
@@ -92,21 +92,21 @@ suite('Objects', () => {
|
||||
});
|
||||
|
||||
test('safeStringify', function () {
|
||||
var obj1 = {
|
||||
let obj1 = {
|
||||
friend: null
|
||||
};
|
||||
|
||||
var obj2 = {
|
||||
let obj2 = {
|
||||
friend: null
|
||||
};
|
||||
|
||||
obj1.friend = obj2;
|
||||
obj2.friend = obj1;
|
||||
|
||||
var arr: any = [1];
|
||||
let arr: any = [1];
|
||||
arr.push(arr);
|
||||
|
||||
var circular = {
|
||||
let circular = {
|
||||
a: 42,
|
||||
b: null,
|
||||
c: [
|
||||
@@ -121,7 +121,7 @@ suite('Objects', () => {
|
||||
circular.b = circular;
|
||||
circular.d = arr;
|
||||
|
||||
var result = objects.safeStringify(circular);
|
||||
let result = objects.safeStringify(circular);
|
||||
|
||||
assert.deepEqual(JSON.parse(result), {
|
||||
a: 42,
|
||||
@@ -140,7 +140,7 @@ suite('Objects', () => {
|
||||
|
||||
test('derive', function () {
|
||||
|
||||
var someValue = 2;
|
||||
let someValue = 2;
|
||||
|
||||
function Base(): void {
|
||||
//example
|
||||
@@ -160,8 +160,8 @@ suite('Objects', () => {
|
||||
|
||||
objects.derive(Base, Child);
|
||||
|
||||
var base = new Base();
|
||||
var child = new Child();
|
||||
let base = new Base();
|
||||
let child = new Child();
|
||||
|
||||
assert(base instanceof Base);
|
||||
assert(child instanceof Child);
|
||||
|
||||
@@ -34,7 +34,7 @@ suite('Strings', () => {
|
||||
|
||||
test('computeLineStarts', function () {
|
||||
function assertLineStart(text: string, ...offsets: number[]): void {
|
||||
var actual = strings.computeLineStarts(text);
|
||||
const actual = strings.computeLineStarts(text);
|
||||
assert.equal(actual.length, offsets.length);
|
||||
if (actual.length !== offsets.length) {
|
||||
return;
|
||||
|
||||
@@ -193,18 +193,18 @@ suite('Types', () => {
|
||||
});
|
||||
|
||||
test('create', () => {
|
||||
var zeroConstructor = function () { /**/ };
|
||||
let zeroConstructor = function () { /**/ };
|
||||
|
||||
assert(types.create(zeroConstructor) instanceof zeroConstructor);
|
||||
assert(types.isObject(types.create(zeroConstructor)));
|
||||
|
||||
var manyArgConstructor = function (foo, bar) {
|
||||
let manyArgConstructor = function (foo, bar) {
|
||||
this.foo = foo;
|
||||
this.bar = bar;
|
||||
};
|
||||
|
||||
var foo = {};
|
||||
var bar = 'foo';
|
||||
let foo = {};
|
||||
let bar = 'foo';
|
||||
|
||||
assert(types.create(manyArgConstructor) instanceof manyArgConstructor);
|
||||
assert(types.isObject(types.create(manyArgConstructor)));
|
||||
@@ -212,7 +212,7 @@ suite('Types', () => {
|
||||
assert(types.create(manyArgConstructor, foo, bar) instanceof manyArgConstructor);
|
||||
assert(types.isObject(types.create(manyArgConstructor, foo, bar)));
|
||||
|
||||
var obj = types.create(manyArgConstructor, foo, bar);
|
||||
let obj = types.create(manyArgConstructor, foo, bar);
|
||||
assert.strictEqual(obj.foo, foo);
|
||||
assert.strictEqual(obj.bar, bar);
|
||||
});
|
||||
|
||||
@@ -11,8 +11,8 @@ import decoder = require('vs/base/node/decoder');
|
||||
suite('Decoder', () => {
|
||||
|
||||
test('decoding', function () {
|
||||
var lineDecoder = new decoder.LineDecoder();
|
||||
var res = lineDecoder.write(new Buffer('hello'));
|
||||
const lineDecoder = new decoder.LineDecoder();
|
||||
let res = lineDecoder.write(new Buffer('hello'));
|
||||
assert.equal(res.length, 0);
|
||||
|
||||
res = lineDecoder.write(new Buffer('\nworld'));
|
||||
|
||||
@@ -11,7 +11,7 @@ import encoding = require('vs/base/node/encoding');
|
||||
|
||||
suite('Encoding', () => {
|
||||
test('detectBOM UTF-8', function (done: () => void) {
|
||||
var file = require.toUrl('./fixtures/some_utf8.css');
|
||||
const file = require.toUrl('./fixtures/some_utf8.css');
|
||||
|
||||
encoding.detectEncodingByBOM(file, (error: Error, encoding: string) => {
|
||||
assert.equal(error, null);
|
||||
@@ -22,7 +22,7 @@ suite('Encoding', () => {
|
||||
});
|
||||
|
||||
test('detectBOM UTF-16 LE', function (done: () => void) {
|
||||
var file = require.toUrl('./fixtures/some_utf16le.css');
|
||||
const file = require.toUrl('./fixtures/some_utf16le.css');
|
||||
|
||||
encoding.detectEncodingByBOM(file, (error: Error, encoding: string) => {
|
||||
assert.equal(error, null);
|
||||
@@ -33,7 +33,7 @@ suite('Encoding', () => {
|
||||
});
|
||||
|
||||
test('detectBOM UTF-16 BE', function (done: () => void) {
|
||||
var file = require.toUrl('./fixtures/some_utf16be.css');
|
||||
const file = require.toUrl('./fixtures/some_utf16be.css');
|
||||
|
||||
encoding.detectEncodingByBOM(file, (error: Error, encoding: string) => {
|
||||
assert.equal(error, null);
|
||||
@@ -44,7 +44,7 @@ suite('Encoding', () => {
|
||||
});
|
||||
|
||||
test('detectBOM ANSI', function (done: () => void) {
|
||||
var file = require.toUrl('./fixtures/some_ansi.css');
|
||||
const file = require.toUrl('./fixtures/some_ansi.css');
|
||||
|
||||
encoding.detectEncodingByBOM(file, (error: Error, encoding: string) => {
|
||||
assert.equal(error, null);
|
||||
@@ -55,7 +55,7 @@ suite('Encoding', () => {
|
||||
});
|
||||
|
||||
test('detectBOM ANSI', function (done: () => void) {
|
||||
var file = require.toUrl('./fixtures/empty.txt');
|
||||
const file = require.toUrl('./fixtures/empty.txt');
|
||||
|
||||
encoding.detectEncodingByBOM(file, (error: Error, encoding: string) => {
|
||||
assert.equal(error, null);
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
import * as assert from 'assert';
|
||||
import flow = require('vs/base/node/flow');
|
||||
|
||||
var loop = flow.loop;
|
||||
var sequence = flow.sequence;
|
||||
var parallel = flow.parallel;
|
||||
const loop = flow.loop;
|
||||
const sequence = flow.sequence;
|
||||
const parallel = flow.parallel;
|
||||
|
||||
suite('Flow', () => {
|
||||
function assertCounterEquals(counter, expected): void {
|
||||
@@ -58,7 +58,7 @@ suite('Flow', () => {
|
||||
}
|
||||
|
||||
test('loopSync', function (done: () => void) {
|
||||
var elements = ['1', '2', '3'];
|
||||
const elements = ['1', '2', '3'];
|
||||
loop(elements, function (element, callback, index, total) {
|
||||
assert.ok(index === 0 || index === 1 || index === 2);
|
||||
assert.deepEqual(3, total);
|
||||
@@ -72,7 +72,7 @@ suite('Flow', () => {
|
||||
});
|
||||
|
||||
test('loopByFunctionSync', function (done: () => void) {
|
||||
var elements = function (callback) {
|
||||
const elements = function (callback) {
|
||||
callback(null, ['1', '2', '3']);
|
||||
};
|
||||
|
||||
@@ -87,7 +87,7 @@ suite('Flow', () => {
|
||||
});
|
||||
|
||||
test('loopByFunctionAsync', function (done: () => void) {
|
||||
var elements = function (callback) {
|
||||
const elements = function (callback) {
|
||||
process.nextTick(function () {
|
||||
callback(null, ['1', '2', '3']);
|
||||
});
|
||||
@@ -104,7 +104,7 @@ suite('Flow', () => {
|
||||
});
|
||||
|
||||
test('loopSyncErrorByThrow', function (done: () => void) {
|
||||
var elements = ['1', '2', '3'];
|
||||
const elements = ['1', '2', '3'];
|
||||
loop(elements, function (element, callback) {
|
||||
if (element === '2') {
|
||||
throw new Error('foo');
|
||||
@@ -120,7 +120,7 @@ suite('Flow', () => {
|
||||
});
|
||||
|
||||
test('loopSyncErrorByCallback', function (done: () => void) {
|
||||
var elements = ['1', '2', '3'];
|
||||
const elements = ['1', '2', '3'];
|
||||
loop(elements, function (element, callback) {
|
||||
if (element === '2') {
|
||||
callback(new Error('foo'), null);
|
||||
@@ -136,7 +136,7 @@ suite('Flow', () => {
|
||||
});
|
||||
|
||||
test('loopAsync', function (done: () => void) {
|
||||
var elements = ['1', '2', '3'];
|
||||
const elements = ['1', '2', '3'];
|
||||
loop(elements, function (element, callback) {
|
||||
process.nextTick(function () {
|
||||
callback(null, element);
|
||||
@@ -150,7 +150,7 @@ suite('Flow', () => {
|
||||
});
|
||||
|
||||
test('loopAsyncErrorByCallback', function (done: () => void) {
|
||||
var elements = ['1', '2', '3'];
|
||||
const elements = ['1', '2', '3'];
|
||||
loop(elements, function (element, callback) {
|
||||
process.nextTick(function () {
|
||||
if (element === '2') {
|
||||
@@ -168,8 +168,8 @@ suite('Flow', () => {
|
||||
});
|
||||
|
||||
test('sequenceSync', function (done: () => void) {
|
||||
var assertionCount = 0;
|
||||
var errorCount = 0;
|
||||
let assertionCount = 0;
|
||||
let errorCount = 0;
|
||||
|
||||
sequence(
|
||||
function onError(error) {
|
||||
@@ -204,8 +204,8 @@ suite('Flow', () => {
|
||||
});
|
||||
|
||||
test('sequenceAsync', function (done: () => void) {
|
||||
var assertionCount = 0;
|
||||
var errorCount = 0;
|
||||
let assertionCount = 0;
|
||||
let errorCount = 0;
|
||||
|
||||
sequence(
|
||||
function onError(error) {
|
||||
@@ -240,8 +240,8 @@ suite('Flow', () => {
|
||||
});
|
||||
|
||||
test('sequenceSyncErrorByThrow', function (done: () => void) {
|
||||
var assertionCount = 0;
|
||||
var errorCount = 0;
|
||||
let assertionCount = 0;
|
||||
let errorCount = 0;
|
||||
|
||||
sequence(
|
||||
function onError(error) {
|
||||
@@ -277,8 +277,8 @@ suite('Flow', () => {
|
||||
});
|
||||
|
||||
test('sequenceSyncErrorByCallback', function (done: () => void) {
|
||||
var assertionCount = 0;
|
||||
var errorCount = 0;
|
||||
let assertionCount = 0;
|
||||
let errorCount = 0;
|
||||
|
||||
sequence(
|
||||
function onError(error) {
|
||||
@@ -306,8 +306,8 @@ suite('Flow', () => {
|
||||
});
|
||||
|
||||
test('sequenceAsyncErrorByThrow', function (done: () => void) {
|
||||
var assertionCount = 0;
|
||||
var errorCount = 0;
|
||||
let assertionCount = 0;
|
||||
let errorCount = 0;
|
||||
|
||||
sequence(
|
||||
function onError(error) {
|
||||
@@ -343,8 +343,8 @@ suite('Flow', () => {
|
||||
});
|
||||
|
||||
test('sequenceAsyncErrorByCallback', function (done: () => void) {
|
||||
var assertionCount = 0;
|
||||
var errorCount = 0;
|
||||
let assertionCount = 0;
|
||||
let errorCount = 0;
|
||||
|
||||
sequence(
|
||||
function onError(error) {
|
||||
@@ -384,8 +384,8 @@ suite('Flow', () => {
|
||||
});
|
||||
|
||||
test('tolerateBooleanResults', function (done: () => void) {
|
||||
var assertionCount = 0;
|
||||
var errorCount = 0;
|
||||
let assertionCount = 0;
|
||||
let errorCount = 0;
|
||||
|
||||
sequence(
|
||||
function onError(error) {
|
||||
@@ -413,7 +413,7 @@ suite('Flow', () => {
|
||||
});
|
||||
|
||||
test('loopTolerateBooleanResults', function (done: () => void) {
|
||||
var elements = ['1', '2', '3'];
|
||||
let elements = ['1', '2', '3'];
|
||||
loop(elements, function (element, callback) {
|
||||
process.nextTick(function () {
|
||||
(<any>callback)(true);
|
||||
@@ -427,8 +427,8 @@ suite('Flow', () => {
|
||||
});
|
||||
|
||||
test('parallel', function (done: () => void) {
|
||||
var elements = [1, 2, 3, 4, 5];
|
||||
var sum = 0;
|
||||
let elements = [1, 2, 3, 4, 5];
|
||||
let sum = 0;
|
||||
|
||||
parallel(elements, function (element, callback) {
|
||||
sum += element;
|
||||
@@ -444,9 +444,9 @@ suite('Flow', () => {
|
||||
});
|
||||
|
||||
test('parallel - setTimeout', function (done: () => void) {
|
||||
var elements = [1, 2, 3, 4, 5];
|
||||
var timeouts = [10, 30, 5, 0, 4];
|
||||
var sum = 0;
|
||||
let elements = [1, 2, 3, 4, 5];
|
||||
let timeouts = [10, 30, 5, 0, 4];
|
||||
let sum = 0;
|
||||
|
||||
parallel(elements, function (element, callback) {
|
||||
setTimeout(function () {
|
||||
@@ -464,9 +464,9 @@ suite('Flow', () => {
|
||||
});
|
||||
|
||||
test('parallel - with error', function (done: () => void) {
|
||||
var elements = [1, 2, 3, 4, 5];
|
||||
var timeouts = [10, 30, 5, 0, 4];
|
||||
var sum = 0;
|
||||
const elements = [1, 2, 3, 4, 5];
|
||||
const timeouts = [10, 30, 5, 0, 4];
|
||||
let sum = 0;
|
||||
|
||||
parallel(elements, function (element, callback) {
|
||||
setTimeout(function () {
|
||||
|
||||
@@ -63,7 +63,7 @@ suite('Glob', () => {
|
||||
// });
|
||||
|
||||
test('simple', function () {
|
||||
var p = 'node_modules';
|
||||
let p = 'node_modules';
|
||||
|
||||
assert(glob.match(p, 'node_modules'));
|
||||
assert(!glob.match(p, 'node_module'));
|
||||
@@ -98,7 +98,7 @@ suite('Glob', () => {
|
||||
});
|
||||
|
||||
test('dot hidden', function () {
|
||||
var p = '.*';
|
||||
let p = '.*';
|
||||
|
||||
assert(glob.match(p, '.git'));
|
||||
assert(glob.match(p, '.hidden.txt'));
|
||||
@@ -138,7 +138,7 @@ suite('Glob', () => {
|
||||
});
|
||||
|
||||
test('file pattern', function () {
|
||||
var p = '*.js';
|
||||
let p = '*.js';
|
||||
|
||||
assert(glob.match(p, 'foo.js'));
|
||||
assert(!glob.match(p, 'folder/foo.js'));
|
||||
@@ -167,7 +167,7 @@ suite('Glob', () => {
|
||||
});
|
||||
|
||||
test('star', function () {
|
||||
var p = 'node*modules';
|
||||
let p = 'node*modules';
|
||||
|
||||
assert(glob.match(p, 'node_modules'));
|
||||
assert(glob.match(p, 'node_super_modules'));
|
||||
@@ -184,7 +184,7 @@ suite('Glob', () => {
|
||||
});
|
||||
|
||||
test('questionmark', function () {
|
||||
var p = 'node?modules';
|
||||
let p = 'node?modules';
|
||||
|
||||
assert(glob.match(p, 'node_modules'));
|
||||
assert(!glob.match(p, 'node_super_modules'));
|
||||
@@ -201,7 +201,7 @@ suite('Glob', () => {
|
||||
});
|
||||
|
||||
test('globstar', function () {
|
||||
var p = '**/*.js';
|
||||
let p = '**/*.js';
|
||||
|
||||
assert(glob.match(p, 'foo.js'));
|
||||
assert(glob.match(p, 'folder/foo.js'));
|
||||
@@ -301,7 +301,7 @@ suite('Glob', () => {
|
||||
});
|
||||
|
||||
test('brace expansion', function () {
|
||||
var p = '*.{html,js}';
|
||||
let p = '*.{html,js}';
|
||||
|
||||
assert(glob.match(p, 'foo.js'));
|
||||
assert(glob.match(p, 'foo.html'));
|
||||
@@ -393,10 +393,10 @@ suite('Glob', () => {
|
||||
});
|
||||
|
||||
test('expression support (single)', function () {
|
||||
var siblings = ['test.html', 'test.txt', 'test.ts', 'test.js'];
|
||||
let siblings = ['test.html', 'test.txt', 'test.ts', 'test.js'];
|
||||
|
||||
// { "**/*.js": { "when": "$(basename).ts" } }
|
||||
var expression: glob.IExpression = {
|
||||
let expression: glob.IExpression = {
|
||||
'**/*.js': {
|
||||
when: '$(basename).ts'
|
||||
}
|
||||
@@ -428,10 +428,10 @@ suite('Glob', () => {
|
||||
});
|
||||
|
||||
test('expression support (multiple)', function () {
|
||||
var siblings = ['test.html', 'test.txt', 'test.ts', 'test.js'];
|
||||
let siblings = ['test.html', 'test.txt', 'test.ts', 'test.js'];
|
||||
|
||||
// { "**/*.js": { "when": "$(basename).ts" } }
|
||||
var expression: glob.IExpression = {
|
||||
let expression: glob.IExpression = {
|
||||
'**/*.js': { when: '$(basename).ts' },
|
||||
'**/*.as': true,
|
||||
'**/*.foo': false,
|
||||
@@ -446,7 +446,7 @@ suite('Glob', () => {
|
||||
});
|
||||
|
||||
test('brackets', function () {
|
||||
var p = 'foo.[0-9]';
|
||||
let p = 'foo.[0-9]';
|
||||
|
||||
assert(glob.match(p, 'foo.5'));
|
||||
assert(glob.match(p, 'foo.8'));
|
||||
@@ -462,13 +462,13 @@ suite('Glob', () => {
|
||||
});
|
||||
|
||||
test('full path', function () {
|
||||
var p = 'testing/this/foo.txt';
|
||||
let p = 'testing/this/foo.txt';
|
||||
|
||||
assert(glob.match(p, nativeSep('testing/this/foo.txt')));
|
||||
});
|
||||
|
||||
test('prefix agnostic', function () {
|
||||
var p = '**/*.js';
|
||||
let p = '**/*.js';
|
||||
|
||||
assert(glob.match(p, 'foo.js'));
|
||||
assert(glob.match(p, '/foo.js'));
|
||||
@@ -512,7 +512,7 @@ suite('Glob', () => {
|
||||
});
|
||||
|
||||
test('cached properly', function () {
|
||||
var p = '**/*.js';
|
||||
let p = '**/*.js';
|
||||
|
||||
assert(glob.match(p, 'foo.js'));
|
||||
assert(glob.match(p, 'testing/foo.js'));
|
||||
@@ -572,7 +572,7 @@ suite('Glob', () => {
|
||||
});
|
||||
|
||||
test('invalid glob', function () {
|
||||
var p = '**/*(.js';
|
||||
let p = '**/*(.js';
|
||||
|
||||
assert(!glob.match(p, 'foo.js'));
|
||||
});
|
||||
@@ -590,13 +590,13 @@ suite('Glob', () => {
|
||||
});
|
||||
|
||||
test('expression with disabled glob', function () {
|
||||
var expr = { '**/*.js': false };
|
||||
let expr = { '**/*.js': false };
|
||||
|
||||
assert.strictEqual(glob.match(expr, 'foo.js'), null);
|
||||
});
|
||||
|
||||
test('expression with two non-trivia globs', function () {
|
||||
var expr = {
|
||||
let expr = {
|
||||
'**/*.j?': true,
|
||||
'**/*.t?': true
|
||||
};
|
||||
@@ -606,19 +606,19 @@ suite('Glob', () => {
|
||||
});
|
||||
|
||||
test('expression with empty glob', function () {
|
||||
var expr = { '': true };
|
||||
let expr = { '': true };
|
||||
|
||||
assert.strictEqual(glob.match(expr, 'foo.js'), null);
|
||||
});
|
||||
|
||||
test('expression with other falsy value', function () {
|
||||
var expr = { '**/*.js': 0 };
|
||||
let expr = { '**/*.js': 0 };
|
||||
|
||||
assert.strictEqual(glob.match(expr, 'foo.js'), '**/*.js');
|
||||
});
|
||||
|
||||
test('expression with two basename globs', function () {
|
||||
var expr = {
|
||||
let expr = {
|
||||
'**/bar': true,
|
||||
'**/baz': true
|
||||
};
|
||||
@@ -631,13 +631,13 @@ suite('Glob', () => {
|
||||
});
|
||||
|
||||
test('expression with two basename globs and a siblings expression', function () {
|
||||
var expr = {
|
||||
let expr = {
|
||||
'**/bar': true,
|
||||
'**/baz': true,
|
||||
'**/*.js': { when: '$(basename).ts' }
|
||||
};
|
||||
|
||||
var sibilings = () => ['foo.ts', 'foo.js', 'foo', 'bar'];
|
||||
let sibilings = () => ['foo.ts', 'foo.js', 'foo', 'bar'];
|
||||
|
||||
assert.strictEqual(glob.match(expr, 'bar', sibilings), '**/bar');
|
||||
assert.strictEqual(glob.match(expr, 'foo', sibilings), null);
|
||||
@@ -649,7 +649,7 @@ suite('Glob', () => {
|
||||
});
|
||||
|
||||
test('expression with multipe basename globs', function () {
|
||||
var expr = {
|
||||
let expr = {
|
||||
'**/bar': true,
|
||||
'{**/baz,**/foo}': true
|
||||
};
|
||||
@@ -689,8 +689,8 @@ suite('Glob', () => {
|
||||
assert.strictEqual(glob.parse('{**/baz,**/foo}')('baz/bar', 'bar'), false);
|
||||
assert.strictEqual(glob.parse('{**/baz,**/foo}')('baz/foo', 'foo'), true);
|
||||
|
||||
var expr = { '**/*.js': { when: '$(basename).ts' } };
|
||||
var sibilings = () => ['foo.ts', 'foo.js'];
|
||||
let expr = { '**/*.js': { when: '$(basename).ts' } };
|
||||
let sibilings = () => ['foo.ts', 'foo.js'];
|
||||
|
||||
assert.strictEqual(glob.parse(expr)('bar/baz.js', 'baz.js', sibilings), null);
|
||||
assert.strictEqual(glob.parse(expr)('bar/foo.js', 'foo.js', sibilings), '**/*.js');
|
||||
|
||||
@@ -13,7 +13,7 @@ import mime = require('vs/base/node/mime');
|
||||
suite('Mime', () => {
|
||||
|
||||
test('detectMimesFromFile (JSON saved as PNG)', function (done: () => void) {
|
||||
var file = require.toUrl('./fixtures/some.json.png');
|
||||
const file = require.toUrl('./fixtures/some.json.png');
|
||||
mime.detectMimesFromFile(file, (error, mimes) => {
|
||||
assert.equal(error, null);
|
||||
assert.deepEqual(mimes.mimes, ['text/plain']);
|
||||
@@ -24,7 +24,7 @@ suite('Mime', () => {
|
||||
|
||||
test('detectMimesFromFile (PNG saved as TXT)', function (done: () => void) {
|
||||
mimeCommon.registerTextMime({ id: 'text', mime: 'text/plain', extension: '.txt' });
|
||||
var file = require.toUrl('./fixtures/some.png.txt');
|
||||
const file = require.toUrl('./fixtures/some.png.txt');
|
||||
mime.detectMimesFromFile(file, (error, mimes) => {
|
||||
assert.equal(error, null);
|
||||
assert.deepEqual(mimes.mimes, ['text/plain', 'application/octet-stream']);
|
||||
@@ -34,7 +34,7 @@ suite('Mime', () => {
|
||||
});
|
||||
|
||||
test('detectMimesFromFile (XML saved as PNG)', function (done: () => void) {
|
||||
var file = require.toUrl('./fixtures/some.xml.png');
|
||||
const file = require.toUrl('./fixtures/some.xml.png');
|
||||
mime.detectMimesFromFile(file, (error, mimes) => {
|
||||
assert.equal(error, null);
|
||||
assert.deepEqual(mimes.mimes, ['text/plain']);
|
||||
@@ -44,7 +44,7 @@ suite('Mime', () => {
|
||||
});
|
||||
|
||||
test('detectMimesFromFile (QWOFF saved as TXT)', function (done: () => void) {
|
||||
var file = require.toUrl('./fixtures/some.qwoff.txt');
|
||||
const file = require.toUrl('./fixtures/some.qwoff.txt');
|
||||
mime.detectMimesFromFile(file, (error, mimes) => {
|
||||
assert.equal(error, null);
|
||||
assert.deepEqual(mimes.mimes, ['text/plain', 'application/octet-stream']);
|
||||
@@ -54,7 +54,7 @@ suite('Mime', () => {
|
||||
});
|
||||
|
||||
test('detectMimesFromFile (CSS saved as QWOFF)', function (done: () => void) {
|
||||
var file = require.toUrl('./fixtures/some.css.qwoff');
|
||||
const file = require.toUrl('./fixtures/some.css.qwoff');
|
||||
mime.detectMimesFromFile(file, (error, mimes) => {
|
||||
assert.equal(error, null);
|
||||
assert.deepEqual(mimes.mimes, ['text/plain']);
|
||||
@@ -64,7 +64,7 @@ suite('Mime', () => {
|
||||
});
|
||||
|
||||
test('detectMimesFromFile (PDF)', function (done: () => void) {
|
||||
var file = require.toUrl('./fixtures/some.pdf');
|
||||
const file = require.toUrl('./fixtures/some.pdf');
|
||||
mime.detectMimesFromFile(file, (error, mimes) => {
|
||||
assert.equal(error, null);
|
||||
assert.deepEqual(mimes.mimes, ['application/octet-stream']);
|
||||
|
||||
@@ -12,7 +12,7 @@ import stream = require('vs/base/node/stream');
|
||||
|
||||
suite('Stream', () => {
|
||||
test('readExactlyByFile - ANSI', function (done: () => void) {
|
||||
var file = require.toUrl('./fixtures/file.css');
|
||||
const file = require.toUrl('./fixtures/file.css');
|
||||
|
||||
stream.readExactlyByFile(file, 10, (error: Error, buffer: NodeBuffer, count: number) => {
|
||||
assert.equal(error, null);
|
||||
@@ -24,7 +24,7 @@ suite('Stream', () => {
|
||||
});
|
||||
|
||||
test('readExactlyByFile - empty', function (done: () => void) {
|
||||
var file = require.toUrl('./fixtures/empty.txt');
|
||||
const file = require.toUrl('./fixtures/empty.txt');
|
||||
|
||||
stream.readExactlyByFile(file, 10, (error: Error, buffer: NodeBuffer, count: number) => {
|
||||
assert.equal(error, null);
|
||||
@@ -35,7 +35,7 @@ suite('Stream', () => {
|
||||
});
|
||||
|
||||
test('readExactlyByStream - ANSI', function (done: () => void) {
|
||||
var file = require.toUrl('./fixtures/file.css');
|
||||
const file = require.toUrl('./fixtures/file.css');
|
||||
|
||||
stream.readExactlyByStream(fs.createReadStream(file), 10, (error: Error, buffer: NodeBuffer, count: number) => {
|
||||
assert.equal(error, null);
|
||||
@@ -47,7 +47,7 @@ suite('Stream', () => {
|
||||
});
|
||||
|
||||
test('readExactlyByStream - empty', function (done: () => void) {
|
||||
var file = require.toUrl('./fixtures/empty.txt');
|
||||
const file = require.toUrl('./fixtures/empty.txt');
|
||||
|
||||
stream.readExactlyByStream(fs.createReadStream(file), 10, (error: Error, buffer: NodeBuffer, count: number) => {
|
||||
assert.equal(error, null);
|
||||
@@ -58,7 +58,7 @@ suite('Stream', () => {
|
||||
});
|
||||
|
||||
test('readToMatchingString - ANSI', function (done: () => void) {
|
||||
var file = require.toUrl('./fixtures/file.css');
|
||||
const file = require.toUrl('./fixtures/file.css');
|
||||
|
||||
stream.readToMatchingString(file, '\n', 10, 100, (error: Error, result: string) => {
|
||||
assert.equal(error, null);
|
||||
@@ -70,7 +70,7 @@ suite('Stream', () => {
|
||||
});
|
||||
|
||||
test('readToMatchingString - empty', function (done: () => void) {
|
||||
var file = require.toUrl('./fixtures/empty.txt');
|
||||
const file = require.toUrl('./fixtures/empty.txt');
|
||||
|
||||
stream.readToMatchingString(file, '\n', 10, 100, (error: Error, result: string) => {
|
||||
assert.equal(error, null);
|
||||
|
||||
@@ -17,8 +17,6 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||
import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { EventService } from 'vs/platform/event/common/eventService';
|
||||
import { IExtensionManagementService, IExtensionGalleryService, IExtensionManifest, IGalleryExtension, LocalExtensionType } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { ExtensionManagementService } from 'vs/platform/extensionManagement/node/extensionManagementService';
|
||||
import { ExtensionGalleryService } from 'vs/platform/extensionManagement/node/extensionGalleryService';
|
||||
@@ -164,7 +162,6 @@ export function main(argv: ParsedArgs): TPromise<void> {
|
||||
const { appRoot, extensionsPath, extensionDevelopmentPath, isBuilt } = envService;
|
||||
|
||||
const services = new ServiceCollection();
|
||||
services.set(IEventService, new SyncDescriptor(EventService));
|
||||
services.set(IConfigurationService, new SyncDescriptor(ConfigurationService));
|
||||
services.set(IRequestService, new SyncDescriptor(RequestService));
|
||||
services.set(IExtensionManagementService, new SyncDescriptor(ExtensionManagementService));
|
||||
|
||||
@@ -14,8 +14,6 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { EventService } from 'vs/platform/event/common/eventService';
|
||||
import { ExtensionManagementChannel } from 'vs/platform/extensionManagement/common/extensionManagementIpc';
|
||||
import { IExtensionManagementService, IExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { ExtensionManagementService } from 'vs/platform/extensionManagement/node/extensionManagementService';
|
||||
@@ -62,7 +60,6 @@ const eventPrefix = 'monacoworkbench';
|
||||
function main(server: Server, initData: ISharedProcessInitData): void {
|
||||
const services = new ServiceCollection();
|
||||
|
||||
services.set(IEventService, new SyncDescriptor(EventService));
|
||||
services.set(IEnvironmentService, new SyncDescriptor(EnvironmentService, initData.args, process.execPath));
|
||||
services.set(IConfigurationService, new SyncDescriptor(ConfigurationService));
|
||||
services.set(IRequestService, new SyncDescriptor(RequestService));
|
||||
|
||||
@@ -10,8 +10,6 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
|
||||
import { ContextMenuService } from 'vs/platform/contextview/browser/contextMenuService';
|
||||
import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { ContextViewService } from 'vs/platform/contextview/browser/contextViewService';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { EventService } from 'vs/platform/event/common/eventService';
|
||||
import { IExtensionService } from 'vs/platform/extensions/common/extensions';
|
||||
import { createDecorator, IInstantiationService, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
@@ -121,8 +119,6 @@ export module StaticServices {
|
||||
|
||||
export const telemetryService = define(ITelemetryService, () => NullTelemetryService);
|
||||
|
||||
export const eventService = define(IEventService, () => new EventService());
|
||||
|
||||
export const configurationService = define(IConfigurationService, () => new SimpleConfigurationService());
|
||||
|
||||
export const messageService = define(IMessageService, () => new SimpleMessageService());
|
||||
|
||||
@@ -11,8 +11,7 @@ import { IDisposable, dispose, IReference } from 'vs/base/common/lifecycle';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { ITextModelResolverService, ITextEditorModel } from 'vs/editor/common/services/resolverService';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { EventType as FileEventType, FileChangesEvent, IFileChange } from 'vs/platform/files/common/files';
|
||||
import { IFileService, IFileChange } from 'vs/platform/files/common/files';
|
||||
import { EditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
@@ -33,17 +32,17 @@ interface IRecording {
|
||||
|
||||
class ChangeRecorder {
|
||||
|
||||
private _eventService: IEventService;
|
||||
private _fileService: IFileService;
|
||||
|
||||
constructor(eventService: IEventService) {
|
||||
this._eventService = eventService;
|
||||
constructor(fileService: IFileService) {
|
||||
this._fileService = fileService;
|
||||
}
|
||||
|
||||
public start(): IRecording {
|
||||
|
||||
const changes: IStringDictionary<IFileChange[]> = Object.create(null);
|
||||
|
||||
const stop = this._eventService.addListener2(FileEventType.FILE_CHANGES, (event: FileChangesEvent) => {
|
||||
const stop = this._fileService.onFileChanges((event) => {
|
||||
event.changes.forEach(change => {
|
||||
|
||||
const key = String(change.resource);
|
||||
@@ -274,17 +273,17 @@ export interface BulkEdit {
|
||||
finish(): TPromise<ISelection>;
|
||||
}
|
||||
|
||||
export function bulkEdit(eventService: IEventService, textModelResolverService: ITextModelResolverService, editor: ICommonCodeEditor, edits: IResourceEdit[], progress: IProgressRunner = null): TPromise<any> {
|
||||
let bulk = createBulkEdit(eventService, textModelResolverService, editor);
|
||||
export function bulkEdit(fileService: IFileService, textModelResolverService: ITextModelResolverService, editor: ICommonCodeEditor, edits: IResourceEdit[], progress: IProgressRunner = null): TPromise<any> {
|
||||
let bulk = createBulkEdit(fileService, textModelResolverService, editor);
|
||||
bulk.add(edits);
|
||||
bulk.progress(progress);
|
||||
return bulk.finish();
|
||||
}
|
||||
|
||||
export function createBulkEdit(eventService: IEventService, textModelResolverService: ITextModelResolverService, editor: ICommonCodeEditor): BulkEdit {
|
||||
export function createBulkEdit(fileService: IFileService, textModelResolverService: ITextModelResolverService, editor: ICommonCodeEditor): BulkEdit {
|
||||
|
||||
let all: IResourceEdit[] = [];
|
||||
let recording = new ChangeRecorder(eventService).start();
|
||||
let recording = new ChangeRecorder(fileService).start();
|
||||
let progressRunner: IProgressRunner;
|
||||
|
||||
function progress(progress: IProgressRunner) {
|
||||
|
||||
@@ -10,7 +10,7 @@ import { isPromiseCanceledError } from 'vs/base/common/errors';
|
||||
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { RawContextKey, IContextKey, IContextKeyService, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IMessageService } from 'vs/platform/message/common/message';
|
||||
import { IProgressService } from 'vs/platform/progress/common/progress';
|
||||
@@ -42,7 +42,7 @@ class RenameController implements IEditorContribution {
|
||||
constructor(
|
||||
private editor: ICodeEditor,
|
||||
@IMessageService private _messageService: IMessageService,
|
||||
@IEventService private _eventService: IEventService,
|
||||
@IFileService private _fileService: IFileService,
|
||||
@ITextModelResolverService private _textModelResolverService: ITextModelResolverService,
|
||||
@IProgressService private _progressService: IProgressService,
|
||||
@IContextKeyService contextKeyService: IContextKeyService
|
||||
@@ -132,7 +132,7 @@ class RenameController implements IEditorContribution {
|
||||
|
||||
// start recording of file changes so that we can figure out if a file that
|
||||
// is to be renamed conflicts with another (concurrent) modification
|
||||
let edit = createBulkEdit(this._eventService, this._textModelResolverService, <ICodeEditor>this.editor);
|
||||
let edit = createBulkEdit(this._fileService, this._textModelResolverService, <ICodeEditor>this.editor);
|
||||
|
||||
return rename(this.editor.getModel(), this.editor.getPosition(), newName).then(result => {
|
||||
if (result.rejectReason) {
|
||||
|
||||
@@ -10,24 +10,20 @@ import { TestInstantiationService } from 'vs/platform/instantiation/test/common/
|
||||
import { DeferredAction } from 'vs/platform/actions/common/actions';
|
||||
import Actions = require('vs/base/common/actions');
|
||||
import { AsyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { EventService } from 'vs/platform/event/common/eventService';
|
||||
|
||||
export class TestAction extends Actions.Action {
|
||||
private service;
|
||||
private first: string;
|
||||
private second: string;
|
||||
|
||||
constructor(first: string, second: string, @IEventService eventService: IEventService) {
|
||||
constructor(first: string, second: string) {
|
||||
super(first);
|
||||
this.service = eventService;
|
||||
this.first = first;
|
||||
this.second = second;
|
||||
}
|
||||
|
||||
|
||||
public run(): WinJS.Promise {
|
||||
return WinJS.TPromise.as((!!this.service && !!this.first && !!this.second) ? true : false);
|
||||
return WinJS.TPromise.as((!!this.first && !!this.second) ? true : false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +32,6 @@ suite('Platform actions', () => {
|
||||
test('DeferredAction', (done) => {
|
||||
|
||||
let instantiationService: TestInstantiationService = new TestInstantiationService();
|
||||
instantiationService.stub(IEventService, EventService);
|
||||
|
||||
let action = new DeferredAction(
|
||||
instantiationService,
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { IEventEmitter } from 'vs/base/common/eventEmitter';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
export const IEventService = createDecorator<IEventService>('eventService');
|
||||
|
||||
export interface IEventService {
|
||||
_serviceBrand: any;
|
||||
|
||||
/**
|
||||
* Allows to add a listener to the platform event bus for all emitters that are known to the platform.
|
||||
*/
|
||||
addListener2(eventType: string, listener: (event: any) => void): IDisposable;
|
||||
|
||||
/**
|
||||
* Allows to add an event emitter to the platform bus such as Events from the emitter
|
||||
* can be received from all listeners on the bus.
|
||||
*/
|
||||
addEmitter2(eventEmitter: IEventEmitter, emitterType?: string): IDisposable;
|
||||
|
||||
/**
|
||||
* Emits an event of the given type into the platform event bus.
|
||||
* Note: Instead of emitting directly to the platform bus, it is also possible to register
|
||||
* as event emitter to the bus using addEmitter() with a emitterType specified. This
|
||||
* makes it possible to scope Events on the bus to a specific namespace, depending on the
|
||||
* emitter and avoids polluting the global namespace in the bus with Events.
|
||||
*/
|
||||
emit(eventType: string, e?: any): void;
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { EventEmitter } from 'vs/base/common/eventEmitter';
|
||||
import { IEventService } from './event';
|
||||
|
||||
// --- implementation ------------------------------------------
|
||||
|
||||
export class EventService extends EventEmitter implements IEventService {
|
||||
public _serviceBrand: any;
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import { EXTENSION_IDENTIFIER_PATTERN } from 'vs/platform/extensionManagement/co
|
||||
suite('Extension Identifier Pattern', () => {
|
||||
|
||||
test('extension identifier pattern', () => {
|
||||
var regEx = new RegExp(EXTENSION_IDENTIFIER_PATTERN);
|
||||
const regEx = new RegExp(EXTENSION_IDENTIFIER_PATTERN);
|
||||
assert.equal(true, regEx.test('publisher.name'));
|
||||
assert.equal(true, regEx.test('publiSher.name'));
|
||||
assert.equal(true, regEx.test('publisher.Name'));
|
||||
|
||||
@@ -11,12 +11,24 @@ import glob = require('vs/base/common/glob');
|
||||
import events = require('vs/base/common/events');
|
||||
import { isLinux } from 'vs/base/common/platform';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import Event from 'vs/base/common/event';
|
||||
|
||||
export const IFileService = createDecorator<IFileService>('fileService');
|
||||
|
||||
export interface IFileService {
|
||||
_serviceBrand: any;
|
||||
|
||||
/**
|
||||
* Allows to listen for file changes. The event will fire for every file within the opened workspace
|
||||
* (if any) as well as all files that have been watched explicitly using the #watchFileChanges() API.
|
||||
*/
|
||||
onFileChanges: Event<FileChangesEvent>;
|
||||
|
||||
/**
|
||||
* An event that is fired upon successful completion of a certain file operation.
|
||||
*/
|
||||
onAfterOperation: Event<FileOperationEvent>;
|
||||
|
||||
/**
|
||||
* Resolve the properties of a file identified by the resource.
|
||||
*
|
||||
@@ -137,6 +149,31 @@ export interface IFileService {
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
export enum FileOperation {
|
||||
CREATE,
|
||||
DELETE,
|
||||
MOVE,
|
||||
COPY,
|
||||
IMPORT
|
||||
}
|
||||
|
||||
export class FileOperationEvent {
|
||||
|
||||
constructor(private _resource: URI, private _operation: FileOperation, private _target?: IFileStat) {
|
||||
}
|
||||
|
||||
public get resource(): URI {
|
||||
return this._resource;
|
||||
}
|
||||
|
||||
public get target(): IFileStat {
|
||||
return this._target;
|
||||
}
|
||||
|
||||
public get operation(): FileOperation {
|
||||
return this._operation;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Possible changes that can occur to a file.
|
||||
@@ -147,17 +184,6 @@ export enum FileChangeType {
|
||||
DELETED = 2
|
||||
}
|
||||
|
||||
/**
|
||||
* Possible events to subscribe to
|
||||
*/
|
||||
export const EventType = {
|
||||
|
||||
/**
|
||||
* Send on file changes.
|
||||
*/
|
||||
FILE_CHANGES: 'files:fileChanges'
|
||||
};
|
||||
|
||||
/**
|
||||
* Identifies a single change in a file.
|
||||
*/
|
||||
|
||||
@@ -11,7 +11,6 @@ import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { IThreadService } from 'vs/workbench/services/thread/common/threadService';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { TextFileModelChangeEvent, ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
@@ -39,7 +38,6 @@ export class MainThreadDocuments extends MainThreadDocumentsShape {
|
||||
@IThreadService threadService: IThreadService,
|
||||
@IModelService modelService: IModelService,
|
||||
@IModeService modeService: IModeService,
|
||||
@IEventService eventService: IEventService,
|
||||
@ITextFileService textFileService: ITextFileService,
|
||||
@ICodeEditorService codeEditorService: ICodeEditorService,
|
||||
@IFileService fileService: IFileService,
|
||||
|
||||
@@ -16,7 +16,6 @@ import { Position as EditorPosition } from 'vs/platform/editor/common/editor';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { MainThreadEditorsTracker, TextEditorRevealType, MainThreadTextEditor, IApplyEditsOptions, ITextEditorConfigurationUpdate } from 'vs/workbench/api/node/mainThreadEditorsTracker';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { equals as arrayEquals } from 'vs/base/common/arrays';
|
||||
import { equals as objectEquals } from 'vs/base/common/objects';
|
||||
import { ExtHostContext, MainThreadEditorsShape, ExtHostEditorsShape, ITextEditorPositionData } from './extHost.protocol';
|
||||
@@ -40,7 +39,6 @@ export class MainThreadEditors extends MainThreadEditorsShape {
|
||||
@IEditorGroupService editorGroupService: IEditorGroupService,
|
||||
@ITelemetryService telemetryService: ITelemetryService,
|
||||
@ICodeEditorService editorService: ICodeEditorService,
|
||||
@IEventService eventService: IEventService,
|
||||
@IModelService modelService: IModelService
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -4,15 +4,17 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { FileChangesEvent, FileChangeType } from 'vs/platform/files/common/files';
|
||||
import { FileChangeType, IFileService } from 'vs/platform/files/common/files';
|
||||
import { IThreadService } from 'vs/workbench/services/thread/common/threadService';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { RunOnceScheduler } from 'vs/base/common/async';
|
||||
import { ExtHostContext, ExtHostFileSystemEventServiceShape, FileSystemEvents } from './extHost.protocol';
|
||||
|
||||
export class MainThreadFileSystemEventService {
|
||||
|
||||
constructor( @IEventService eventService: IEventService, @IThreadService threadService: IThreadService) {
|
||||
constructor(
|
||||
@IThreadService threadService: IThreadService,
|
||||
@IFileService fileService: IFileService
|
||||
) {
|
||||
|
||||
const proxy: ExtHostFileSystemEventServiceShape = threadService.get(ExtHostContext.ExtHostFileSystemEventService);
|
||||
const events: FileSystemEvents = {
|
||||
@@ -28,7 +30,7 @@ export class MainThreadFileSystemEventService {
|
||||
events.deleted.length = 0;
|
||||
}, 100);
|
||||
|
||||
eventService.addListener2('files:fileChanges', (event: FileChangesEvent) => {
|
||||
fileService.onFileChanges(event => {
|
||||
for (let change of event.changes) {
|
||||
switch (change.type) {
|
||||
case FileChangeType.ADDED:
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
import { isPromiseCanceledError } from 'vs/base/common/errors';
|
||||
import { ISearchService, QueryType } from 'vs/platform/search/common/search';
|
||||
import { IWorkspaceContextService, IWorkspace } from 'vs/platform/workspace/common/workspace';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { ICommonCodeEditor } from 'vs/editor/common/editorCommon';
|
||||
@@ -16,6 +15,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { Uri } from 'vscode';
|
||||
import { MainThreadWorkspaceShape } from './extHost.protocol';
|
||||
import { ITextModelResolverService } from 'vs/editor/common/services/resolverService';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
|
||||
export class MainThreadWorkspace extends MainThreadWorkspaceShape {
|
||||
|
||||
@@ -25,7 +25,7 @@ export class MainThreadWorkspace extends MainThreadWorkspaceShape {
|
||||
private _textFileService: ITextFileService;
|
||||
private _editorService: IWorkbenchEditorService;
|
||||
private _textModelResolverService: ITextModelResolverService;
|
||||
private _eventService: IEventService;
|
||||
private _fileService: IFileService;
|
||||
|
||||
constructor(
|
||||
@ISearchService searchService: ISearchService,
|
||||
@@ -33,7 +33,7 @@ export class MainThreadWorkspace extends MainThreadWorkspaceShape {
|
||||
@ITextFileService textFileService,
|
||||
@IWorkbenchEditorService editorService,
|
||||
@ITextModelResolverService textModelResolverService,
|
||||
@IEventService eventService
|
||||
@IFileService fileService: IFileService
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -41,7 +41,7 @@ export class MainThreadWorkspace extends MainThreadWorkspaceShape {
|
||||
this._workspace = contextService.getWorkspace();
|
||||
this._textFileService = textFileService;
|
||||
this._editorService = editorService;
|
||||
this._eventService = eventService;
|
||||
this._fileService = fileService;
|
||||
this._textModelResolverService = textModelResolverService;
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ export class MainThreadWorkspace extends MainThreadWorkspaceShape {
|
||||
}
|
||||
}
|
||||
|
||||
return bulkEdit(this._eventService, this._textModelResolverService, codeEditor, edits)
|
||||
return bulkEdit(this._fileService, this._textModelResolverService, codeEditor, edits)
|
||||
.then(() => true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import { IPartService, Position, ILayoutOptions, Parts } from 'vs/workbench/serv
|
||||
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
||||
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
|
||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IThemeService } from 'vs/workbench/services/themes/common/themeService';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
|
||||
@@ -85,7 +84,6 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
|
||||
},
|
||||
quickopen: QuickOpenController,
|
||||
@IStorageService private storageService: IStorageService,
|
||||
@IEventService eventService: IEventService,
|
||||
@IContextViewService private contextViewService: IContextViewService,
|
||||
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
|
||||
@IEditorGroupService private editorGroupService: IEditorGroupService,
|
||||
|
||||
@@ -18,7 +18,6 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IMessageService } from 'vs/platform/message/common/message';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
@@ -42,14 +41,13 @@ export class StringEditor extends BaseTextEditor {
|
||||
@IStorageService storageService: IStorageService,
|
||||
@IMessageService messageService: IMessageService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IEventService eventService: IEventService,
|
||||
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@IUntitledEditorService private untitledEditorService: IUntitledEditorService,
|
||||
@IEditorGroupService private editorGroupService: IEditorGroupService,
|
||||
@ITextFileService textFileService: ITextFileService
|
||||
) {
|
||||
super(StringEditor.ID, telemetryService, instantiationService, contextService, storageService, messageService, configurationService, eventService, editorService, themeService, textFileService);
|
||||
super(StringEditor.ID, telemetryService, instantiationService, contextService, storageService, messageService, configurationService, editorService, themeService, textFileService);
|
||||
|
||||
this.toUnbind.push(this.untitledEditorService.onDidChangeDirty(e => this.onUntitledDirtyChange(e)));
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { IMessageService } from 'vs/platform/message/common/message';
|
||||
@@ -61,14 +60,13 @@ export class TextDiffEditor extends BaseTextEditor {
|
||||
@IStorageService storageService: IStorageService,
|
||||
@IMessageService messageService: IMessageService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IEventService eventService: IEventService,
|
||||
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@IEditorGroupService private editorGroupService: IEditorGroupService,
|
||||
@ITextFileService textFileService: ITextFileService
|
||||
) {
|
||||
super(TextDiffEditor.ID, telemetryService, instantiationService, contextService, storageService, messageService, configurationService, eventService, editorService, themeService, textFileService);
|
||||
super(TextDiffEditor.ID, telemetryService, instantiationService, contextService, storageService, messageService, configurationService, editorService, themeService, textFileService);
|
||||
|
||||
this.textDiffEditorVisible = TextCompareEditorVisible.bindTo(contextKeyService);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import { IFilesConfiguration } from 'vs/platform/files/common/files';
|
||||
import { Position } from 'vs/platform/editor/common/editor';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IMessageService } from 'vs/platform/message/common/message';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
@@ -56,7 +55,6 @@ export abstract class BaseTextEditor extends BaseEditor {
|
||||
@IStorageService private _storageService: IStorageService,
|
||||
@IMessageService private _messageService: IMessageService,
|
||||
@IConfigurationService private configurationService: IConfigurationService,
|
||||
@IEventService private _eventService: IEventService,
|
||||
@IWorkbenchEditorService private _editorService: IWorkbenchEditorService,
|
||||
@IThemeService private themeService: IThemeService,
|
||||
@ITextFileService private textFileService: ITextFileService
|
||||
@@ -83,10 +81,6 @@ export abstract class BaseTextEditor extends BaseEditor {
|
||||
return this._messageService;
|
||||
}
|
||||
|
||||
public get eventService(): IEventService {
|
||||
return this._eventService;
|
||||
}
|
||||
|
||||
public get editorService() {
|
||||
return this._editorService;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import timer = require('vs/base/common/timer');
|
||||
import uri from 'vs/base/common/uri';
|
||||
import strings = require('vs/base/common/strings');
|
||||
import { IResourceInput } from 'vs/platform/editor/common/editor';
|
||||
import { EventService } from 'vs/platform/event/common/eventService';
|
||||
import { IWorkspace, WorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { WorkspaceConfigurationService } from 'vs/workbench/services/configuration/node/configurationService';
|
||||
import { ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||
@@ -131,10 +130,9 @@ function getWorkspace(workspacePath: string): TPromise<IWorkspace> {
|
||||
}
|
||||
|
||||
function openWorkbench(environment: IWindowConfiguration, workspace: IWorkspace, options: IOptions): TPromise<void> {
|
||||
const eventService = new EventService();
|
||||
const environmentService = new EnvironmentService(environment, environment.execPath);
|
||||
const contextService = new WorkspaceContextService(workspace);
|
||||
const configurationService = new WorkspaceConfigurationService(contextService, eventService, environmentService);
|
||||
const configurationService = new WorkspaceConfigurationService(contextService, environmentService);
|
||||
const timerService = new TimerService((<any>window).MonacoEnvironment.timers as IInitData, !contextService.getWorkspace());
|
||||
|
||||
// Since the configuration service is one of the core services that is used in so many places, we initialize it
|
||||
@@ -149,7 +147,6 @@ function openWorkbench(environment: IWindowConfiguration, workspace: IWorkspace,
|
||||
timerService.beforeWorkbenchOpen = new Date();
|
||||
const shell = new WorkbenchShell(document.body, workspace, {
|
||||
configurationService,
|
||||
eventService,
|
||||
contextService,
|
||||
environmentService,
|
||||
timerService
|
||||
|
||||
@@ -57,7 +57,6 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { IMarkerService } from 'vs/platform/markers/common/markers';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
@@ -99,7 +98,6 @@ import 'vs/platform/opener/browser/opener.contribution';
|
||||
*/
|
||||
export interface ICoreServices {
|
||||
contextService: IWorkspaceContextService;
|
||||
eventService: IEventService;
|
||||
configurationService: IConfigurationService;
|
||||
environmentService: IEnvironmentService;
|
||||
timerService: ITimerService;
|
||||
@@ -114,7 +112,6 @@ const currentWindow = remote.getCurrentWindow();
|
||||
export class WorkbenchShell {
|
||||
private storageService: IStorageService;
|
||||
private messageService: MessageService;
|
||||
private eventService: IEventService;
|
||||
private environmentService: IEnvironmentService;
|
||||
private contextViewService: ContextViewService;
|
||||
private threadService: MainThreadService;
|
||||
@@ -144,7 +141,6 @@ export class WorkbenchShell {
|
||||
this.options = options;
|
||||
|
||||
this.contextService = services.contextService;
|
||||
this.eventService = services.eventService;
|
||||
this.configurationService = services.configurationService;
|
||||
this.environmentService = services.environmentService;
|
||||
this.timerService = services.timerService;
|
||||
@@ -239,7 +235,6 @@ export class WorkbenchShell {
|
||||
const disposables = new Disposables();
|
||||
|
||||
const serviceCollection = new ServiceCollection();
|
||||
serviceCollection.set(IEventService, this.eventService);
|
||||
serviceCollection.set(IWorkspaceContextService, this.contextService);
|
||||
serviceCollection.set(IConfigurationService, this.configurationService);
|
||||
serviceCollection.set(IEnvironmentService, this.environmentService);
|
||||
|
||||
@@ -48,6 +48,7 @@ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storag
|
||||
import { ContextMenuService } from 'vs/workbench/services/contextview/electron-browser/contextmenuService';
|
||||
import { WorkbenchKeybindingService } from 'vs/workbench/services/keybinding/electron-browser/keybindingService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { WorkspaceConfigurationService } from 'vs/workbench/services/configuration/node/configurationService';
|
||||
import { IConfigurationEditingService } from 'vs/workbench/services/configuration/common/configurationEditing';
|
||||
import { ConfigurationEditingService } from 'vs/workbench/services/configuration/node/configurationEditingService';
|
||||
import { ContextKeyService } from 'vs/platform/contextkey/browser/contextKeyService';
|
||||
@@ -193,7 +194,7 @@ export class Workbench implements IPartService {
|
||||
@IStorageService private storageService: IStorageService,
|
||||
@ILifecycleService private lifecycleService: ILifecycleService,
|
||||
@IMessageService private messageService: IMessageService,
|
||||
@IConfigurationService private configurationService: IConfigurationService,
|
||||
@IConfigurationService private configurationService: WorkspaceConfigurationService,
|
||||
@ITelemetryService private telemetryService: ITelemetryService,
|
||||
@IEnvironmentService private environmentService: IEnvironmentService,
|
||||
@IWindowService private windowService: IWindowService
|
||||
@@ -463,7 +464,9 @@ export class Workbench implements IPartService {
|
||||
serviceCollection.set(IEditorGroupService, this.editorPart);
|
||||
|
||||
// File Service
|
||||
serviceCollection.set(IFileService, new SyncDescriptor(FileService));
|
||||
const fileService = this.instantiationService.createInstance(FileService);
|
||||
serviceCollection.set(IFileService, fileService);
|
||||
this.toDispose.push(fileService.onFileChanges(e => this.configurationService.handleWorkspaceFileEvents(e)));
|
||||
|
||||
// History
|
||||
serviceCollection.set(IHistoryService, new SyncDescriptor(HistoryService));
|
||||
|
||||
@@ -22,8 +22,7 @@ import { IMarkerService } from 'vs/platform/markers/common/markers';
|
||||
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { IExtensionService } from 'vs/platform/extensions/common/extensions';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { FileChangesEvent, FileChangeType, EventType } from 'vs/platform/files/common/files';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { FileChangesEvent, FileChangeType, IFileService } from 'vs/platform/files/common/files';
|
||||
import { IMessageService, CloseAction } from 'vs/platform/message/common/message';
|
||||
import { IWindowsService } from 'vs/platform/windows/common/windows';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
@@ -85,12 +84,12 @@ export class DebugService implements debug.IDebugService {
|
||||
@ITelemetryService private telemetryService: ITelemetryService,
|
||||
@IWorkspaceContextService private contextService: IWorkspaceContextService,
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
@IEventService eventService: IEventService,
|
||||
@ILifecycleService lifecycleService: ILifecycleService,
|
||||
@IInstantiationService private instantiationService: IInstantiationService,
|
||||
@IExtensionService private extensionService: IExtensionService,
|
||||
@IMarkerService private markerService: IMarkerService,
|
||||
@ITaskService private taskService: ITaskService,
|
||||
@IFileService private fileService: IFileService,
|
||||
@IConfigurationService private configurationService: IConfigurationService
|
||||
) {
|
||||
this.toDispose = [];
|
||||
@@ -107,11 +106,11 @@ export class DebugService implements debug.IDebugService {
|
||||
this.toDispose.push(this.model);
|
||||
this.viewModel = new ViewModel(this.storageService.get(DEBUG_SELECTED_CONFIG_NAME_KEY, StorageScope.WORKSPACE, null));
|
||||
|
||||
this.registerListeners(eventService, lifecycleService);
|
||||
this.registerListeners(lifecycleService);
|
||||
}
|
||||
|
||||
private registerListeners(eventService: IEventService, lifecycleService: ILifecycleService): void {
|
||||
this.toDispose.push(eventService.addListener2(EventType.FILE_CHANGES, (e: FileChangesEvent) => this.onFileChanges(e)));
|
||||
private registerListeners(lifecycleService: ILifecycleService): void {
|
||||
this.toDispose.push(this.fileService.onFileChanges(e => this.onFileChanges(e)));
|
||||
|
||||
if (this.taskService) {
|
||||
this.toDispose.push(this.taskService.addListener2(TaskServiceEvents.Active, (e: TaskEvent) => {
|
||||
|
||||
@@ -20,12 +20,11 @@ import { BinaryEditorModel } from 'vs/workbench/common/editor/binaryEditorModel'
|
||||
import { FileEditorInput } from 'vs/workbench/parts/files/common/editors/fileEditorInput';
|
||||
import { ExplorerViewlet } from 'vs/workbench/parts/files/browser/explorerViewlet';
|
||||
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
||||
import { IFileOperationResult, FileOperationResult, FileChangesEvent, EventType, IFileService } from 'vs/platform/files/common/files';
|
||||
import { IFileOperationResult, FileOperationResult, FileChangesEvent, IFileService } from 'vs/platform/files/common/files';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IHistoryService } from 'vs/workbench/services/history/common/history';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IMessageService, CancelAction } from 'vs/platform/message/common/message';
|
||||
@@ -50,16 +49,15 @@ export class TextFileEditor extends BaseTextEditor {
|
||||
@IHistoryService private historyService: IHistoryService,
|
||||
@IMessageService messageService: IMessageService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IEventService eventService: IEventService,
|
||||
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@IEditorGroupService private editorGroupService: IEditorGroupService,
|
||||
@ITextFileService textFileService: ITextFileService
|
||||
) {
|
||||
super(TextFileEditor.ID, telemetryService, instantiationService, contextService, storageService, messageService, configurationService, eventService, editorService, themeService, textFileService);
|
||||
super(TextFileEditor.ID, telemetryService, instantiationService, contextService, storageService, messageService, configurationService, editorService, themeService, textFileService);
|
||||
|
||||
// Clear view state for deleted files
|
||||
this.toUnbind.push(this.eventService.addListener2(EventType.FILE_CHANGES, (e: FileChangesEvent) => this.onFilesChanged(e)));
|
||||
this.toUnbind.push(this.fileService.onFileChanges(e => this.onFilesChanged(e)));
|
||||
}
|
||||
|
||||
private onFilesChanged(e: FileChangesEvent): void {
|
||||
|
||||
@@ -15,7 +15,7 @@ import URI from 'vs/base/common/uri';
|
||||
import errors = require('vs/base/common/errors');
|
||||
import { toErrorMessage } from 'vs/base/common/errorMessage';
|
||||
import strings = require('vs/base/common/strings');
|
||||
import { Event, EventType as CommonEventType } from 'vs/base/common/events';
|
||||
import { EventType as CommonEventType } from 'vs/base/common/events';
|
||||
import severity from 'vs/base/common/severity';
|
||||
import diagnostics = require('vs/base/common/diagnostics');
|
||||
import { Action, IAction } from 'vs/base/common/actions';
|
||||
@@ -24,8 +24,8 @@ import { ITree, IHighlightEvent } from 'vs/base/parts/tree/browser/tree';
|
||||
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { VIEWLET_ID } from 'vs/workbench/parts/files/common/files';
|
||||
import labels = require('vs/base/common/labels');
|
||||
import { LocalFileChangeEvent, ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IFileService, IFileStat, IImportResult } from 'vs/platform/files/common/files';
|
||||
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IFileService, IFileStat } from 'vs/platform/files/common/files';
|
||||
import { DiffEditorInput, toDiffLabel } from 'vs/workbench/common/editor/diffEditorInput';
|
||||
import { asFileEditorInput, getUntitledOrFileResource, IEditorIdentifier, EditorInput } from 'vs/workbench/common/editor';
|
||||
import { FileEditorInput } from 'vs/workbench/parts/files/common/editors/fileEditorInput';
|
||||
@@ -42,7 +42,6 @@ import { IQuickOpenService, IFilePickOpenEntry } from 'vs/platform/quickOpen/com
|
||||
import { IHistoryService } from 'vs/workbench/services/history/common/history';
|
||||
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
||||
import { Position, IResourceInput, IEditorInput } from 'vs/platform/editor/common/editor';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IInstantiationService, IConstructorSignature2 } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IMessageService, IMessageWithAction, IConfirmation, Severity, CancelAction } from 'vs/platform/message/common/message';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
@@ -72,8 +71,7 @@ export class BaseFileAction extends Action {
|
||||
@IWorkbenchEditorService private _editorService: IWorkbenchEditorService,
|
||||
@IFileService private _fileService: IFileService,
|
||||
@IMessageService private _messageService: IMessageService,
|
||||
@ITextFileService private _textFileService: ITextFileService,
|
||||
@IEventService private _eventService: IEventService
|
||||
@ITextFileService private _textFileService: ITextFileService
|
||||
) {
|
||||
super(id, label);
|
||||
|
||||
@@ -96,10 +94,6 @@ export class BaseFileAction extends Action {
|
||||
return this._fileService;
|
||||
}
|
||||
|
||||
public get eventService() {
|
||||
return this._eventService;
|
||||
}
|
||||
|
||||
public get textFileService() {
|
||||
return this._textFileService;
|
||||
}
|
||||
@@ -162,10 +156,9 @@ export class TriggerRenameFileAction extends BaseFileAction {
|
||||
@IFileService fileService: IFileService,
|
||||
@IMessageService messageService: IMessageService,
|
||||
@ITextFileService textFileService: ITextFileService,
|
||||
@IEventService eventService: IEventService,
|
||||
@IInstantiationService instantiationService: IInstantiationService
|
||||
) {
|
||||
super(TriggerRenameFileAction.ID, nls.localize('rename', "Rename"), contextService, editorService, fileService, messageService, textFileService, eventService);
|
||||
super(TriggerRenameFileAction.ID, nls.localize('rename', "Rename"), contextService, editorService, fileService, messageService, textFileService);
|
||||
|
||||
this.tree = tree;
|
||||
this.element = element;
|
||||
@@ -233,10 +226,9 @@ export abstract class BaseRenameAction extends BaseFileAction {
|
||||
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
|
||||
@IFileService fileService: IFileService,
|
||||
@IMessageService messageService: IMessageService,
|
||||
@ITextFileService textFileService: ITextFileService,
|
||||
@IEventService eventService: IEventService
|
||||
@ITextFileService textFileService: ITextFileService
|
||||
) {
|
||||
super(id, label, contextService, editorService, fileService, messageService, textFileService, eventService);
|
||||
super(id, label, contextService, editorService, fileService, messageService, textFileService);
|
||||
|
||||
this.element = element;
|
||||
}
|
||||
@@ -261,11 +253,7 @@ export abstract class BaseRenameAction extends BaseFileAction {
|
||||
}
|
||||
|
||||
// Call function and Emit Event through viewer
|
||||
const promise = this.runAction(name).then((stat: IFileStat) => {
|
||||
if (stat) {
|
||||
this.onSuccess(stat);
|
||||
}
|
||||
}, (error: any) => {
|
||||
const promise = this.runAction(name).then(null, (error: any) => {
|
||||
this.onError(error);
|
||||
});
|
||||
|
||||
@@ -289,18 +277,9 @@ export abstract class BaseRenameAction extends BaseFileAction {
|
||||
}
|
||||
|
||||
public abstract runAction(newName: string): TPromise<any>;
|
||||
|
||||
public onSuccess(stat: IFileStat): void {
|
||||
let before: IFileStat = null;
|
||||
if (!(this.element instanceof NewStatPlaceholder)) {
|
||||
before = this.element.clone(); // Clone element to not expose viewers element to listeners
|
||||
}
|
||||
|
||||
this.eventService.emit('files.internal:fileChanged', new LocalFileChangeEvent(before, stat));
|
||||
}
|
||||
}
|
||||
|
||||
export class RenameFileAction extends BaseRenameAction {
|
||||
class RenameFileAction extends BaseRenameAction {
|
||||
|
||||
public static ID = 'workbench.files.action.renameFile';
|
||||
|
||||
@@ -310,10 +289,9 @@ export class RenameFileAction extends BaseRenameAction {
|
||||
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
|
||||
@IFileService fileService: IFileService,
|
||||
@IMessageService messageService: IMessageService,
|
||||
@ITextFileService textFileService: ITextFileService,
|
||||
@IEventService eventService: IEventService
|
||||
@ITextFileService textFileService: ITextFileService
|
||||
) {
|
||||
super(RenameFileAction.ID, nls.localize('rename', "Rename"), element, contextService, editorService, fileService, messageService, textFileService, eventService);
|
||||
super(RenameFileAction.ID, nls.localize('rename', "Rename"), element, contextService, editorService, fileService, messageService, textFileService);
|
||||
|
||||
this._updateEnablement();
|
||||
}
|
||||
@@ -375,10 +353,9 @@ export class BaseNewAction extends BaseFileAction {
|
||||
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
|
||||
@IFileService fileService: IFileService,
|
||||
@IMessageService messageService: IMessageService,
|
||||
@ITextFileService textFileService: ITextFileService,
|
||||
@IEventService eventService: IEventService
|
||||
@ITextFileService textFileService: ITextFileService
|
||||
) {
|
||||
super(id, label, contextService, editorService, fileService, messageService, textFileService, eventService);
|
||||
super(id, label, contextService, editorService, fileService, messageService, textFileService);
|
||||
|
||||
if (element) {
|
||||
this.presetFolder = element.isDirectory ? element : element.parent;
|
||||
@@ -467,10 +444,9 @@ export class NewFileAction extends BaseNewAction {
|
||||
@IFileService fileService: IFileService,
|
||||
@IMessageService messageService: IMessageService,
|
||||
@ITextFileService textFileService: ITextFileService,
|
||||
@IEventService eventService: IEventService,
|
||||
@IInstantiationService instantiationService: IInstantiationService
|
||||
) {
|
||||
super('workbench.action.files.newFile', nls.localize('newFile', "New File"), tree, true, instantiationService.createInstance(CreateFileAction, element), null, contextService, editorService, fileService, messageService, textFileService, eventService);
|
||||
super('workbench.action.files.newFile', nls.localize('newFile', "New File"), tree, true, instantiationService.createInstance(CreateFileAction, element), null, contextService, editorService, fileService, messageService, textFileService);
|
||||
|
||||
this.class = 'explorer-action new-file';
|
||||
this._updateEnablement();
|
||||
@@ -488,10 +464,9 @@ export class NewFolderAction extends BaseNewAction {
|
||||
@IFileService fileService: IFileService,
|
||||
@IMessageService messageService: IMessageService,
|
||||
@ITextFileService textFileService: ITextFileService,
|
||||
@IEventService eventService: IEventService,
|
||||
@IInstantiationService instantiationService: IInstantiationService
|
||||
) {
|
||||
super('workbench.action.files.newFolder', nls.localize('newFolder', "New Folder"), tree, false, instantiationService.createInstance(CreateFolderAction, element), null, contextService, editorService, fileService, messageService, textFileService, eventService);
|
||||
super('workbench.action.files.newFolder', nls.localize('newFolder', "New Folder"), tree, false, instantiationService.createInstance(CreateFolderAction, element), null, contextService, editorService, fileService, messageService, textFileService);
|
||||
|
||||
this.class = 'explorer-action new-folder';
|
||||
this._updateEnablement();
|
||||
@@ -612,10 +587,9 @@ export class CreateFileAction extends BaseCreateAction {
|
||||
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
|
||||
@IFileService fileService: IFileService,
|
||||
@IMessageService messageService: IMessageService,
|
||||
@ITextFileService textFileService: ITextFileService,
|
||||
@IEventService eventService: IEventService
|
||||
@ITextFileService textFileService: ITextFileService
|
||||
) {
|
||||
super(CreateFileAction.ID, CreateFileAction.LABEL, element, contextService, editorService, fileService, messageService, textFileService, eventService);
|
||||
super(CreateFileAction.ID, CreateFileAction.LABEL, element, contextService, editorService, fileService, messageService, textFileService);
|
||||
|
||||
this._updateEnablement();
|
||||
}
|
||||
@@ -639,10 +613,9 @@ export class CreateFolderAction extends BaseCreateAction {
|
||||
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
|
||||
@IFileService fileService: IFileService,
|
||||
@IMessageService messageService: IMessageService,
|
||||
@ITextFileService textFileService: ITextFileService,
|
||||
@IEventService eventService: IEventService
|
||||
@ITextFileService textFileService: ITextFileService
|
||||
) {
|
||||
super(CreateFolderAction.ID, CreateFolderAction.LABEL, null, contextService, editorService, fileService, messageService, textFileService, eventService);
|
||||
super(CreateFolderAction.ID, CreateFolderAction.LABEL, null, contextService, editorService, fileService, messageService, textFileService);
|
||||
|
||||
this._updateEnablement();
|
||||
}
|
||||
@@ -669,10 +642,9 @@ export class BaseDeleteFileAction extends BaseFileAction {
|
||||
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
|
||||
@IFileService fileService: IFileService,
|
||||
@IMessageService messageService: IMessageService,
|
||||
@ITextFileService textFileService: ITextFileService,
|
||||
@IEventService eventService: IEventService
|
||||
@ITextFileService textFileService: ITextFileService
|
||||
) {
|
||||
super(id, label, contextService, editorService, fileService, messageService, textFileService, eventService);
|
||||
super(id, label, contextService, editorService, fileService, messageService, textFileService);
|
||||
|
||||
this.tree = tree;
|
||||
this.element = element;
|
||||
@@ -758,10 +730,6 @@ export class BaseDeleteFileAction extends BaseFileAction {
|
||||
}
|
||||
}
|
||||
|
||||
// Since a delete operation can take a while we want to emit the event proactively to avoid issues
|
||||
// with stale entries in the explorer tree.
|
||||
this.eventService.emit('files.internal:fileChanged', new LocalFileChangeEvent(this.element.clone(), null));
|
||||
|
||||
// Call function
|
||||
const servicePromise = this.fileService.del(this.element.resource, this.useTrash).then(() => {
|
||||
if (this.element.parent) {
|
||||
@@ -777,10 +745,6 @@ export class BaseDeleteFileAction extends BaseFileAction {
|
||||
|
||||
this.onErrorWithRetry(error, () => this.run(), extraAction);
|
||||
|
||||
// Since the delete failed, best we can do is to refresh the explorer from the root to show the current state of files.
|
||||
const event = new LocalFileChangeEvent(new FileStat(this.contextService.getWorkspace().resource, true, true), new FileStat(this.contextService.getWorkspace().resource, true, true));
|
||||
this.eventService.emit('files.internal:fileChanged', event);
|
||||
|
||||
// Focus back to tree
|
||||
this.tree.DOMFocus();
|
||||
});
|
||||
@@ -801,10 +765,9 @@ export class MoveFileToTrashAction extends BaseDeleteFileAction {
|
||||
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
|
||||
@IFileService fileService: IFileService,
|
||||
@IMessageService messageService: IMessageService,
|
||||
@ITextFileService textFileService: ITextFileService,
|
||||
@IEventService eventService: IEventService
|
||||
@ITextFileService textFileService: ITextFileService
|
||||
) {
|
||||
super(MoveFileToTrashAction.ID, nls.localize('delete', "Delete"), tree, element, true, contextService, editorService, fileService, messageService, textFileService, eventService);
|
||||
super(MoveFileToTrashAction.ID, nls.localize('delete', "Delete"), tree, element, true, contextService, editorService, fileService, messageService, textFileService);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -822,10 +785,9 @@ export class ImportFileAction extends BaseFileAction {
|
||||
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
|
||||
@IFileService fileService: IFileService,
|
||||
@IMessageService messageService: IMessageService,
|
||||
@ITextFileService textFileService: ITextFileService,
|
||||
@IEventService eventService: IEventService
|
||||
@ITextFileService textFileService: ITextFileService
|
||||
) {
|
||||
super(ImportFileAction.ID, nls.localize('importFiles', "Import Files"), contextService, editorService, fileService, messageService, textFileService, eventService);
|
||||
super(ImportFileAction.ID, nls.localize('importFiles', "Import Files"), contextService, editorService, fileService, messageService, textFileService);
|
||||
|
||||
this.tree = tree;
|
||||
this.element = element;
|
||||
@@ -897,19 +859,7 @@ export class ImportFileAction extends BaseFileAction {
|
||||
importPromisesFactory.push(() => {
|
||||
const sourceFile = URI.file(file.path);
|
||||
|
||||
return this.fileService.importFile(sourceFile, targetElement.resource).then((result: IImportResult) => {
|
||||
if (result.stat) {
|
||||
|
||||
// Emit Deleted Event if file gets replaced unless it is the same file
|
||||
const oldFile = targetNames[isLinux ? file.name : file.name.toLowerCase()];
|
||||
if (oldFile && oldFile.resource.fsPath !== result.stat.resource.fsPath) {
|
||||
this.eventService.emit('files.internal:fileChanged', new LocalFileChangeEvent(oldFile, null));
|
||||
}
|
||||
|
||||
// Emit Import Event
|
||||
this.eventService.emit('files.internal:fileChanged', new FileImportedEvent(result.stat, result.isNew, context.event));
|
||||
}
|
||||
}, (error: any) => {
|
||||
return this.fileService.importFile(sourceFile, targetElement.resource).then(null, (error: any) => {
|
||||
this.messageService.show(Severity.Error, error);
|
||||
});
|
||||
});
|
||||
@@ -929,33 +879,6 @@ export class ImportFileAction extends BaseFileAction {
|
||||
}
|
||||
}
|
||||
|
||||
/** File import event is emitted when a file is import into the workbench. */
|
||||
export class FileImportedEvent extends LocalFileChangeEvent {
|
||||
private isNew: boolean;
|
||||
|
||||
constructor(stat?: IFileStat, isNew?: boolean, originalEvent?: Event) {
|
||||
super(null, stat, originalEvent);
|
||||
|
||||
this.isNew = isNew;
|
||||
}
|
||||
|
||||
public gotAdded(): boolean {
|
||||
return this.isNew;
|
||||
}
|
||||
|
||||
public gotMoved(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
public gotUpdated(): boolean {
|
||||
return !this.isNew;
|
||||
}
|
||||
|
||||
public gotDeleted(): boolean {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Copy File/Folder
|
||||
let fileToCopy: FileStat;
|
||||
export class CopyFileAction extends BaseFileAction {
|
||||
@@ -970,10 +893,9 @@ export class CopyFileAction extends BaseFileAction {
|
||||
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
|
||||
@IFileService fileService: IFileService,
|
||||
@IMessageService messageService: IMessageService,
|
||||
@ITextFileService textFileService: ITextFileService,
|
||||
@IEventService eventService: IEventService
|
||||
@ITextFileService textFileService: ITextFileService
|
||||
) {
|
||||
super(CopyFileAction.ID, nls.localize('copyFile', "Copy"), contextService, editorService, fileService, messageService, textFileService, eventService);
|
||||
super(CopyFileAction.ID, nls.localize('copyFile', "Copy"), contextService, editorService, fileService, messageService, textFileService);
|
||||
|
||||
this.tree = tree;
|
||||
this.element = element;
|
||||
@@ -1011,10 +933,9 @@ export class PasteFileAction extends BaseFileAction {
|
||||
@IFileService fileService: IFileService,
|
||||
@IMessageService messageService: IMessageService,
|
||||
@ITextFileService textFileService: ITextFileService,
|
||||
@IEventService eventService: IEventService,
|
||||
@IInstantiationService private instantiationService: IInstantiationService
|
||||
) {
|
||||
super(PasteFileAction.ID, nls.localize('pasteFile', "Paste"), contextService, editorService, fileService, messageService, textFileService, eventService);
|
||||
super(PasteFileAction.ID, nls.localize('pasteFile', "Paste"), contextService, editorService, fileService, messageService, textFileService);
|
||||
|
||||
this.tree = tree;
|
||||
this.element = element;
|
||||
@@ -1076,10 +997,9 @@ export class DuplicateFileAction extends BaseFileAction {
|
||||
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
|
||||
@IFileService fileService: IFileService,
|
||||
@IMessageService messageService: IMessageService,
|
||||
@ITextFileService textFileService: ITextFileService,
|
||||
@IEventService eventService: IEventService
|
||||
@ITextFileService textFileService: ITextFileService
|
||||
) {
|
||||
super('workbench.files.action.duplicateFile', nls.localize('duplicateFile', "Duplicate"), contextService, editorService, fileService, messageService, textFileService, eventService);
|
||||
super('workbench.files.action.duplicateFile', nls.localize('duplicateFile', "Duplicate"), contextService, editorService, fileService, messageService, textFileService);
|
||||
|
||||
this.tree = tree;
|
||||
this.element = element;
|
||||
@@ -1094,10 +1014,8 @@ export class DuplicateFileAction extends BaseFileAction {
|
||||
this.tree.clearHighlight();
|
||||
}
|
||||
|
||||
// Copy File and emit event
|
||||
const result = this.fileService.copyFile(this.element.resource, this.findTarget()).then((stat: IFileStat) => {
|
||||
this.eventService.emit('files.internal:fileChanged', new LocalFileChangeEvent(null, stat));
|
||||
}, (error: any) => {
|
||||
// Copy File
|
||||
const result = this.fileService.copyFile(this.element.resource, this.findTarget()).then(null, (error: any) => {
|
||||
this.onError(error);
|
||||
});
|
||||
|
||||
|
||||
@@ -17,9 +17,8 @@ import { prepareActions } from 'vs/workbench/browser/actionBarRegistry';
|
||||
import { ITree } from 'vs/base/parts/tree/browser/tree';
|
||||
import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
|
||||
import { IFilesConfiguration } from 'vs/workbench/parts/files/common/files';
|
||||
import { LocalFileChangeEvent } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IFileStat, IResolveFileOptions, FileChangeType, FileChangesEvent, IFileChange, EventType as FileEventType, IFileService } from 'vs/platform/files/common/files';
|
||||
import { FileImportedEvent, RefreshViewExplorerAction, NewFolderAction, NewFileAction } from 'vs/workbench/parts/files/browser/fileActions';
|
||||
import { FileOperation, FileOperationEvent, IResolveFileOptions, FileChangeType, FileChangesEvent, IFileChange, IFileService } from 'vs/platform/files/common/files';
|
||||
import { RefreshViewExplorerAction, NewFolderAction, NewFileAction } from 'vs/workbench/parts/files/browser/fileActions';
|
||||
import { FileEditorInput } from 'vs/workbench/parts/files/common/editors/fileEditorInput';
|
||||
import { FileDragAndDrop, FileFilter, FileSorter, FileController, FileRenderer, FileDataSource, FileViewletState, FileAccessibilityProvider } from 'vs/workbench/parts/files/browser/views/explorerViewer';
|
||||
import lifecycle = require('vs/base/common/lifecycle');
|
||||
@@ -32,7 +31,6 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi
|
||||
import { IPartService } from 'vs/workbench/services/part/common/partService';
|
||||
import { IWorkspaceContextService, IWorkspace } from 'vs/platform/workspace/common/workspace';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IProgressService } from 'vs/platform/progress/common/progress';
|
||||
@@ -77,7 +75,6 @@ export class ExplorerView extends CollapsibleViewletView {
|
||||
@IContextMenuService contextMenuService: IContextMenuService,
|
||||
@IInstantiationService private instantiationService: IInstantiationService,
|
||||
@IEditorGroupService private editorGroupService: IEditorGroupService,
|
||||
@IEventService private eventService: IEventService,
|
||||
@IWorkspaceContextService private contextService: IWorkspaceContextService,
|
||||
@IProgressService private progressService: IProgressService,
|
||||
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
|
||||
@@ -341,8 +338,8 @@ export class ExplorerView extends CollapsibleViewletView {
|
||||
this.toDispose.push(lifecycle.toDisposable(() => renderer.dispose()));
|
||||
|
||||
// Update Viewer based on File Change Events
|
||||
this.toDispose.push(this.eventService.addListener2('files.internal:fileChanged', (e: LocalFileChangeEvent) => this.onLocalFileChange(e)));
|
||||
this.toDispose.push(this.eventService.addListener2(FileEventType.FILE_CHANGES, (e: FileChangesEvent) => this.onFileChanges(e)));
|
||||
this.toDispose.push(this.fileService.onAfterOperation(e => this.onFileOperation(e)));
|
||||
this.toDispose.push(this.fileService.onFileChanges(e => this.onFileChanges(e)));
|
||||
|
||||
// Update resource context based on focused element
|
||||
this.toDispose.push(this.explorerViewer.addListener2('focus', (e: { focus: FileStat }) => {
|
||||
@@ -360,15 +357,15 @@ export class ExplorerView extends CollapsibleViewletView {
|
||||
return DOM.getLargestChildWidth(parentNode, childNodes);
|
||||
}
|
||||
|
||||
private onLocalFileChange(e: LocalFileChangeEvent): void {
|
||||
private onFileOperation(e: FileOperationEvent): void {
|
||||
let modelElement: FileStat;
|
||||
let parent: FileStat;
|
||||
let parentResource: URI;
|
||||
let parentElement: FileStat;
|
||||
|
||||
// Add
|
||||
if (e.gotAdded()) {
|
||||
const addedElement = e.getAfter();
|
||||
if (e.operation === FileOperation.CREATE || e.operation === FileOperation.IMPORT || e.operation === FileOperation.COPY) {
|
||||
const addedElement = e.target;
|
||||
parentResource = URI.file(paths.dirname(addedElement.resource.fsPath));
|
||||
parentElement = this.getInput().find(parentResource);
|
||||
|
||||
@@ -397,7 +394,7 @@ export class ExplorerView extends CollapsibleViewletView {
|
||||
};
|
||||
|
||||
// For file imports, use a delayer to not refresh too many times when multiple files are imported
|
||||
if (e instanceof FileImportedEvent) {
|
||||
if (e.operation === FileOperation.IMPORT) {
|
||||
this.explorerImportDelayer.trigger(refreshPromise).done(null, errors.onUnexpectedError);
|
||||
}
|
||||
|
||||
@@ -409,23 +406,23 @@ export class ExplorerView extends CollapsibleViewletView {
|
||||
}
|
||||
|
||||
// Move (including Rename)
|
||||
else if (e.gotMoved()) {
|
||||
const oldElement = e.getBefore();
|
||||
const newElement = e.getAfter();
|
||||
else if (e.operation === FileOperation.MOVE) {
|
||||
const oldResource = e.resource;
|
||||
const newElement = e.target;
|
||||
|
||||
const oldParentResource = URI.file(paths.dirname(oldElement.resource.fsPath));
|
||||
const oldParentResource = URI.file(paths.dirname(oldResource.fsPath));
|
||||
const newParentResource = URI.file(paths.dirname(newElement.resource.fsPath));
|
||||
|
||||
// Only update focus if renamed/moved element is selected
|
||||
let updateFocus = false;
|
||||
const focus: FileStat = this.explorerViewer.getFocus();
|
||||
if (focus && focus.resource && focus.resource.toString() === oldElement.resource.toString()) {
|
||||
if (focus && focus.resource && focus.resource.toString() === oldResource.toString()) {
|
||||
updateFocus = true;
|
||||
}
|
||||
|
||||
// Handle Rename
|
||||
if (oldParentResource && newParentResource && oldParentResource.toString() === newParentResource.toString()) {
|
||||
modelElement = this.getInput().find(oldElement.resource);
|
||||
modelElement = this.getInput().find(oldResource);
|
||||
if (modelElement) {
|
||||
|
||||
// Rename File (Model)
|
||||
@@ -449,7 +446,7 @@ export class ExplorerView extends CollapsibleViewletView {
|
||||
else if (oldParentResource && newParentResource) {
|
||||
const oldParent = this.getInput().find(oldParentResource);
|
||||
const newParent = this.getInput().find(newParentResource);
|
||||
modelElement = this.getInput().find(oldElement.resource);
|
||||
modelElement = this.getInput().find(oldResource);
|
||||
|
||||
if (oldParent && newParent && modelElement) {
|
||||
|
||||
@@ -470,9 +467,8 @@ export class ExplorerView extends CollapsibleViewletView {
|
||||
}
|
||||
|
||||
// Delete
|
||||
else if (e.gotDeleted()) {
|
||||
const deletedElement = e.getBefore();
|
||||
modelElement = this.getInput().find(deletedElement.resource);
|
||||
else if (e.operation === FileOperation.DELETE) {
|
||||
modelElement = this.getInput().find(e.resource);
|
||||
if (modelElement && modelElement.parent) {
|
||||
parent = modelElement.parent;
|
||||
|
||||
@@ -487,23 +483,6 @@ export class ExplorerView extends CollapsibleViewletView {
|
||||
}, errors.onUnexpectedError);
|
||||
}
|
||||
}
|
||||
|
||||
// Imported which replaced an existing file
|
||||
else if (e instanceof FileImportedEvent) {
|
||||
const importedElement: IFileStat = (<FileImportedEvent>e).getAfter();
|
||||
parentResource = URI.file(paths.dirname(importedElement.resource.fsPath));
|
||||
parentElement = this.getInput().find(parentResource);
|
||||
|
||||
// Open it (pinned)
|
||||
if (parentElement) {
|
||||
this.explorerViewer.refresh(parentElement).then(() => this.editorService.openEditor({ resource: importedElement.resource, options: { pinned: true } })).done(null, errors.onUnexpectedError);
|
||||
}
|
||||
}
|
||||
|
||||
// Refresh if the event indicates that '/' got updated (from a place outside the explorer viewlet)
|
||||
else if (this.workspace && e.gotUpdated() && e.getAfter().resource.toString() === this.workspace.resource.toString() && !this.explorerViewer.getHighlight()) {
|
||||
this.refreshFromEvent();
|
||||
}
|
||||
}
|
||||
|
||||
private onFileChanges(e: FileChangesEvent): void {
|
||||
|
||||
@@ -25,8 +25,8 @@ import { FileLabel, IFileLabelOptions } from 'vs/workbench/browser/labels';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { ContributableActionProvider } from 'vs/workbench/browser/actionBarRegistry';
|
||||
import { IFilesConfiguration } from 'vs/workbench/parts/files/common/files';
|
||||
import { LocalFileChangeEvent, ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IFileOperationResult, FileOperationResult, IFileStat, IFileService } from 'vs/platform/files/common/files';
|
||||
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IFileOperationResult, FileOperationResult, IFileService } from 'vs/platform/files/common/files';
|
||||
import { DuplicateFileAction, ImportFileAction, PasteFileAction, keybindingForAction, IEditableData, IFileViewletState } from 'vs/workbench/parts/files/browser/fileActions';
|
||||
import { IDataSource, ITree, IElementCallback, IAccessibilityProvider, IRenderer, ContextMenuEvent, ISorter, IFilter, IDragAndDrop, IDragAndDropData, IDragOverReaction, DRAG_OVER_ACCEPT_BUBBLE_DOWN, DRAG_OVER_ACCEPT_BUBBLE_DOWN_COPY, DRAG_OVER_ACCEPT_BUBBLE_UP, DRAG_OVER_ACCEPT_BUBBLE_UP_COPY, DRAG_OVER_REJECT } from 'vs/base/parts/tree/browser/tree';
|
||||
import { DesktopDragAndDropData, ExternalElementsDragAndDropData } from 'vs/base/parts/tree/browser/treeDnd';
|
||||
@@ -41,7 +41,6 @@ import { IWorkspace, IWorkspaceContextService } from 'vs/platform/workspace/comm
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IContextViewService, IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IMessageService, IConfirmation, Severity } from 'vs/platform/message/common/message';
|
||||
import { IProgressService } from 'vs/platform/progress/common/progress';
|
||||
@@ -728,7 +727,6 @@ export class FileDragAndDrop implements IDragAndDrop {
|
||||
constructor(
|
||||
@IMessageService private messageService: IMessageService,
|
||||
@IWorkspaceContextService private contextService: IWorkspaceContextService,
|
||||
@IEventService private eventService: IEventService,
|
||||
@IProgressService private progressService: IProgressService,
|
||||
@IFileService private fileService: IFileService,
|
||||
@IConfigurationService private configurationService: IConfigurationService,
|
||||
@@ -917,12 +915,8 @@ export class FileDragAndDrop implements IDragAndDrop {
|
||||
const targetResource = URI.file(paths.join(target.resource.fsPath, source.name));
|
||||
let didHandleConflict = false;
|
||||
|
||||
const onMove = (result: IFileStat) => {
|
||||
this.eventService.emit('files.internal:fileChanged', new LocalFileChangeEvent(source.clone(), result));
|
||||
};
|
||||
|
||||
// Move File/Folder and emit event
|
||||
return this.fileService.moveFile(source.resource, targetResource).then(onMove, error => {
|
||||
// Move File/Folder
|
||||
return this.fileService.moveFile(source.resource, targetResource).then(null, error => {
|
||||
|
||||
// Conflict
|
||||
if ((<IFileOperationResult>error).fileOperationResult === FileOperationResult.FILE_MOVE_CONFLICT) {
|
||||
@@ -935,12 +929,7 @@ export class FileDragAndDrop implements IDragAndDrop {
|
||||
};
|
||||
|
||||
if (this.messageService.confirm(confirm)) {
|
||||
return this.fileService.moveFile(source.resource, targetResource, true).then(result => {
|
||||
const fakeTargetState = new FileStat(targetResource);
|
||||
this.eventService.emit('files.internal:fileChanged', new LocalFileChangeEvent(fakeTargetState, null));
|
||||
|
||||
onMove(result);
|
||||
}, (error) => {
|
||||
return this.fileService.moveFile(source.resource, targetResource, true).then(null, (error) => {
|
||||
this.messageService.show(Severity.Error, error);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -12,13 +12,12 @@ import { IEditor } from 'vs/editor/common/editorCommon';
|
||||
import { IEditor as IBaseEditor } from 'vs/platform/editor/common/editor';
|
||||
import { EditorInput, IEditorStacksModel, SideBySideEditorInput } from 'vs/workbench/common/editor';
|
||||
import { BINARY_FILE_EDITOR_ID } from 'vs/workbench/parts/files/common/files';
|
||||
import { LocalFileChangeEvent, ITextFileService, ModelState } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { FileChangeType, FileChangesEvent, EventType as CommonFileEventType } from 'vs/platform/files/common/files';
|
||||
import { ITextFileService, ModelState } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { FileOperationEvent, FileOperation, IFileService, FileChangeType, FileChangesEvent } from 'vs/platform/files/common/files';
|
||||
import { FileEditorInput } from 'vs/workbench/parts/files/common/editors/fileEditorInput';
|
||||
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
|
||||
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
|
||||
export class FileEditorTracker implements IWorkbenchContribution {
|
||||
@@ -31,11 +30,11 @@ export class FileEditorTracker implements IWorkbenchContribution {
|
||||
private toUnbind: IDisposable[];
|
||||
|
||||
constructor(
|
||||
@IEventService private eventService: IEventService,
|
||||
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
|
||||
@ITextFileService private textFileService: ITextFileService,
|
||||
@ILifecycleService private lifecycleService: ILifecycleService,
|
||||
@IEditorGroupService private editorGroupService: IEditorGroupService,
|
||||
@IFileService private fileService: IFileService
|
||||
) {
|
||||
this.toUnbind = [];
|
||||
this.stacks = editorGroupService.getStacksModel();
|
||||
@@ -49,34 +48,30 @@ export class FileEditorTracker implements IWorkbenchContribution {
|
||||
|
||||
private registerListeners(): void {
|
||||
|
||||
// Update editors from local changes and saves
|
||||
this.toUnbind.push(this.eventService.addListener2('files.internal:fileChanged', (e: LocalFileChangeEvent) => this.onLocalFileChange(e)));
|
||||
// Update editors from operation changes
|
||||
this.toUnbind.push(this.fileService.onAfterOperation(e => this.onFileOperation(e)));
|
||||
|
||||
// Update editors from disk changes
|
||||
this.toUnbind.push(this.eventService.addListener2(CommonFileEventType.FILE_CHANGES, (e: FileChangesEvent) => this.onFileChanges(e)));
|
||||
this.toUnbind.push(this.fileService.onFileChanges(e => this.onFileChanges(e)));
|
||||
|
||||
// Lifecycle
|
||||
this.lifecycleService.onShutdown(this.dispose, this);
|
||||
}
|
||||
|
||||
// Note: there is some duplication with the other file event handler below. Since we cannot always rely on the disk events
|
||||
// carrying all necessary data in all environments, we also use the local file events to make sure operations are handled.
|
||||
// carrying all necessary data in all environments, we also use the file operation events to make sure operations are handled.
|
||||
// In any case there is no guarantee if the local event is fired first or the disk one. Thus, code must handle the case
|
||||
// that the event ordering is random as well as might not carry all information needed.
|
||||
private onLocalFileChange(e: LocalFileChangeEvent): void {
|
||||
const movedTo = e.gotMoved() && e.getAfter() && e.getAfter().resource;
|
||||
private onFileOperation(e: FileOperationEvent): void {
|
||||
|
||||
// Handle moves specially when file is opened
|
||||
if (movedTo) {
|
||||
const before = e.getBefore();
|
||||
const after = e.getAfter();
|
||||
|
||||
this.handleMovedFileInOpenedEditors(before ? before.resource : null, after ? after.resource : null);
|
||||
if (e.operation === FileOperation.MOVE) {
|
||||
this.handleMovedFileInOpenedEditors(e.resource, e.target.resource);
|
||||
}
|
||||
|
||||
// Handle deletes
|
||||
if (e.gotDeleted() || movedTo) {
|
||||
this.handleDeletes(e.getBefore().resource, movedTo);
|
||||
if (e.operation === FileOperation.DELETE || e.operation === FileOperation.MOVE) {
|
||||
this.handleDeletes(e.resource, e.target ? e.target.resource : void 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import { isLinux, isWindows } from 'vs/base/common/platform';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { join } from 'vs/base/common/paths';
|
||||
import { validateFileName } from 'vs/workbench/parts/files/browser/fileActions';
|
||||
import { LocalFileChangeEvent } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { FileStat } from 'vs/workbench/parts/files/common/explorerViewModel';
|
||||
|
||||
function createStat(path, name, isFolder, hasChildren, size, mtime) {
|
||||
@@ -237,48 +236,6 @@ suite('Files - View Model', () => {
|
||||
assert(validateFileName(s, 'foo') === null);
|
||||
});
|
||||
|
||||
test('File Change Event (with stats)', function () {
|
||||
const d = new Date().toUTCString();
|
||||
const s1 = new FileStat(toResource('/path/to/sName'), false, false, 'sName', Date.now(), d);
|
||||
const s2 = new FileStat(toResource('/path/to/sName'), false, false, 'sName', Date.now(), d);
|
||||
const s3 = new FileStat(toResource('/path/to/sNameMoved'), false, false, 'sNameMoved', Date.now(), d);
|
||||
|
||||
// Got Added
|
||||
let event = new LocalFileChangeEvent(null, s1);
|
||||
assert(event.gotAdded());
|
||||
assert(!event.gotDeleted());
|
||||
assert(!event.gotUpdated());
|
||||
assert(!event.gotMoved());
|
||||
|
||||
// Got Removed
|
||||
event = new LocalFileChangeEvent(s1, null);
|
||||
assert(!event.gotAdded());
|
||||
assert(event.gotDeleted());
|
||||
assert(!event.gotUpdated());
|
||||
assert(!event.gotMoved());
|
||||
|
||||
// Got Moved
|
||||
event = new LocalFileChangeEvent(s3, s1);
|
||||
assert(!event.gotAdded());
|
||||
assert(!event.gotDeleted());
|
||||
assert(!event.gotUpdated());
|
||||
assert(event.gotMoved());
|
||||
|
||||
// Got Updated
|
||||
event = new LocalFileChangeEvent(s2, s1);
|
||||
assert(!event.gotAdded());
|
||||
assert(!event.gotDeleted());
|
||||
assert(event.gotUpdated());
|
||||
assert(!event.gotMoved());
|
||||
|
||||
// No Change
|
||||
event = new LocalFileChangeEvent(s1, s1);
|
||||
assert(!event.gotAdded());
|
||||
assert(!event.gotDeleted());
|
||||
assert(!event.gotUpdated());
|
||||
assert(!event.gotMoved());
|
||||
});
|
||||
|
||||
test('Merge Local with Disk', function () {
|
||||
const d = new Date().toUTCString();
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi
|
||||
import { workbenchInstantiationService, TestTextFileService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { EncodingMode } from 'vs/workbench/common/editor';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { FileOperationResult, IFileOperationResult } from 'vs/platform/files/common/files';
|
||||
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
|
||||
@@ -24,8 +23,7 @@ function toResource(path) {
|
||||
class ServiceAccessor {
|
||||
constructor(
|
||||
@IWorkbenchEditorService public editorService: IWorkbenchEditorService,
|
||||
@ITextFileService public textFileService: TestTextFileService,
|
||||
@IEventService public eventService: IEventService
|
||||
@ITextFileService public textFileService: TestTextFileService
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,38 +8,26 @@
|
||||
import * as assert from 'assert';
|
||||
import { FileEditorTracker } from 'vs/workbench/parts/files/common/editors/fileEditorTracker';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { join, basename } from 'vs/base/common/paths';
|
||||
import { join } from 'vs/base/common/paths';
|
||||
import { FileEditorInput } from 'vs/workbench/parts/files/common/editors/fileEditorInput';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { workbenchInstantiationService, TestTextFileService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { workbenchInstantiationService, TestTextFileService, TestFileService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
|
||||
import { EditorStacksModel } from 'vs/workbench/common/editor/editorStacksModel';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { ITextFileService, LocalFileChangeEvent } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { FileChangesEvent, FileChangeType, EventType } from 'vs/platform/files/common/files';
|
||||
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { FileOperation, FileOperationEvent, FileChangesEvent, FileChangeType, IFileService } from 'vs/platform/files/common/files';
|
||||
|
||||
function toResource(path) {
|
||||
return URI.file(join('C:\\', new Buffer(this.test.fullTitle()).toString('base64'), path));
|
||||
}
|
||||
|
||||
function toStat(resource: URI) {
|
||||
return {
|
||||
resource,
|
||||
isDirectory: false,
|
||||
hasChildren: false,
|
||||
name: basename(resource.fsPath),
|
||||
mtime: Date.now(),
|
||||
etag: 'etag'
|
||||
};
|
||||
}
|
||||
|
||||
class ServiceAccessor {
|
||||
constructor(
|
||||
@IWorkbenchEditorService public editorService: IWorkbenchEditorService,
|
||||
@IEditorGroupService public editorGroupService: IEditorGroupService,
|
||||
@ITextFileService public textFileService: TestTextFileService,
|
||||
@IEventService public eventService: IEventService
|
||||
@IFileService public fileService: TestFileService
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -68,7 +56,7 @@ suite('Files - FileEditorTracker', () => {
|
||||
|
||||
assert.ok(!input.isDisposed());
|
||||
|
||||
accessor.eventService.emit('files.internal:fileChanged', new LocalFileChangeEvent(toStat(resource)));
|
||||
accessor.fileService.fireAfterOperation(new FileOperationEvent(resource, FileOperation.DELETE));
|
||||
assert.ok(input.isDisposed());
|
||||
group.closeEditor(input);
|
||||
|
||||
@@ -77,15 +65,15 @@ suite('Files - FileEditorTracker', () => {
|
||||
|
||||
const other = toResource.call(this, '/foo/barfoo');
|
||||
|
||||
accessor.eventService.emit('files.internal:fileChanged', new LocalFileChangeEvent(toStat(other)));
|
||||
accessor.fileService.fireAfterOperation(new FileOperationEvent(other, FileOperation.DELETE));
|
||||
assert.ok(!input.isDisposed());
|
||||
|
||||
accessor.eventService.emit('files.internal:fileChanged', new LocalFileChangeEvent(toStat(parent)));
|
||||
accessor.fileService.fireAfterOperation(new FileOperationEvent(parent, FileOperation.DELETE));
|
||||
assert.ok(input.isDisposed());
|
||||
|
||||
// Move
|
||||
const to = toResource.call(this, '/foo/barfoo/change.js');
|
||||
accessor.eventService.emit('files.internal:fileChanged', new LocalFileChangeEvent(toStat(resource), toStat(to)));
|
||||
accessor.fileService.fireAfterOperation(new FileOperationEvent(resource, FileOperation.MOVE, to));
|
||||
assert.ok(input.isDisposed());
|
||||
});
|
||||
|
||||
@@ -103,7 +91,7 @@ suite('Files - FileEditorTracker', () => {
|
||||
|
||||
assert.ok(!input.isDisposed());
|
||||
|
||||
accessor.eventService.emit(EventType.FILE_CHANGES, new FileChangesEvent([{ resource, type: FileChangeType.DELETED }]));
|
||||
accessor.fileService.fireFileChanges(new FileChangesEvent([{ resource, type: FileChangeType.DELETED }]));
|
||||
assert.ok(input.isDisposed());
|
||||
group.closeEditor(input);
|
||||
|
||||
@@ -112,10 +100,10 @@ suite('Files - FileEditorTracker', () => {
|
||||
|
||||
const other = toResource.call(this, '/foo/barfoo');
|
||||
|
||||
accessor.eventService.emit(EventType.FILE_CHANGES, new FileChangesEvent([{ resource: other, type: FileChangeType.DELETED }]));
|
||||
accessor.fileService.fireFileChanges(new FileChangesEvent([{ resource: other, type: FileChangeType.DELETED }]));
|
||||
assert.ok(!input.isDisposed());
|
||||
|
||||
accessor.eventService.emit(EventType.FILE_CHANGES, new FileChangesEvent([{ resource: parent, type: FileChangeType.DELETED }]));
|
||||
accessor.fileService.fireFileChanges(new FileChangesEvent([{ resource: parent, type: FileChangeType.DELETED }]));
|
||||
assert.ok(input.isDisposed());
|
||||
});
|
||||
});
|
||||
@@ -1,46 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { LocalFileChangeEvent } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { FileImportedEvent } from 'vs/workbench/parts/files/browser/fileActions';
|
||||
|
||||
suite('Files - Events', () => {
|
||||
|
||||
test('File Change Event (simple)', function () {
|
||||
const origEvent: any = {};
|
||||
const oldValue: any = { foo: 'bar' };
|
||||
const newValue: any = { foo: 'foo' };
|
||||
const event = new LocalFileChangeEvent(oldValue, newValue, origEvent);
|
||||
|
||||
assert.strictEqual(event.originalEvent, origEvent);
|
||||
assert.strictEqual(event.oldValue, oldValue);
|
||||
assert.strictEqual(event.newValue, newValue);
|
||||
assert(event.time);
|
||||
});
|
||||
|
||||
test('File Upload Event', function () {
|
||||
const origEvent: any = {};
|
||||
const value: any = { foo: 'bar' };
|
||||
let event = new FileImportedEvent(value, true, origEvent);
|
||||
|
||||
assert.strictEqual(event.originalEvent, origEvent);
|
||||
assert.strictEqual(event.newValue, value);
|
||||
assert(event.time);
|
||||
assert(event.gotAdded());
|
||||
assert(!event.gotUpdated());
|
||||
assert(!event.gotMoved());
|
||||
assert(!event.gotDeleted());
|
||||
|
||||
event = new FileImportedEvent(value, false, origEvent);
|
||||
|
||||
assert(!event.gotAdded());
|
||||
assert(event.gotUpdated());
|
||||
assert(!event.gotMoved());
|
||||
assert(!event.gotDeleted());
|
||||
});
|
||||
});
|
||||
@@ -20,7 +20,6 @@ import platform = require('vs/base/common/platform');
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { IEditor } from 'vs/platform/editor/common/editor';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IFileService, IFileStat } from 'vs/platform/files/common/files';
|
||||
import { IMessageService, IConfirmation, IChoiceService } from 'vs/platform/message/common/message';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
@@ -308,15 +307,13 @@ export class GlobalStageAction extends BaseStageAction {
|
||||
|
||||
export abstract class BaseUndoAction extends GitAction {
|
||||
|
||||
private eventService: IEventService;
|
||||
private editorService: IWorkbenchEditorService;
|
||||
private messageService: IMessageService;
|
||||
private fileService: IFileService;
|
||||
private contextService: IWorkspaceContextService;
|
||||
|
||||
constructor(id: string, label: string, className: string, gitService: IGitService, eventService: IEventService, messageService: IMessageService, fileService: IFileService, editorService: IWorkbenchEditorService, contextService: IWorkspaceContextService) {
|
||||
constructor(id: string, label: string, className: string, gitService: IGitService, messageService: IMessageService, fileService: IFileService, editorService: IWorkbenchEditorService, contextService: IWorkspaceContextService) {
|
||||
super(id, label, className, gitService);
|
||||
this.eventService = eventService;
|
||||
this.editorService = editorService;
|
||||
this.messageService = messageService;
|
||||
this.fileService = fileService;
|
||||
@@ -325,7 +322,7 @@ export abstract class BaseUndoAction extends GitAction {
|
||||
}
|
||||
|
||||
protected isEnabled(): boolean {
|
||||
return super.isEnabled() && !!this.eventService && !!this.editorService && !!this.fileService;
|
||||
return super.isEnabled() && !!this.editorService && !!this.fileService;
|
||||
}
|
||||
|
||||
public run(context?: any): Promise {
|
||||
@@ -451,7 +448,6 @@ export abstract class BaseUndoAction extends GitAction {
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this.eventService = null;
|
||||
this.editorService = null;
|
||||
this.fileService = null;
|
||||
|
||||
@@ -461,8 +457,8 @@ export abstract class BaseUndoAction extends GitAction {
|
||||
|
||||
export class UndoAction extends BaseUndoAction {
|
||||
static ID = 'workbench.action.git.undo';
|
||||
constructor( @IGitService gitService: IGitService, @IEventService eventService: IEventService, @IMessageService messageService: IMessageService, @IFileService fileService: IFileService, @IWorkbenchEditorService editorService: IWorkbenchEditorService, @IWorkspaceContextService contextService: IWorkspaceContextService) {
|
||||
super(UndoAction.ID, nls.localize('undoChanges', "Clean"), 'git-action undo', gitService, eventService, messageService, fileService, editorService, contextService);
|
||||
constructor( @IGitService gitService: IGitService, @IMessageService messageService: IMessageService, @IFileService fileService: IFileService, @IWorkbenchEditorService editorService: IWorkbenchEditorService, @IWorkspaceContextService contextService: IWorkspaceContextService) {
|
||||
super(UndoAction.ID, nls.localize('undoChanges', "Clean"), 'git-action undo', gitService, messageService, fileService, editorService, contextService);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -470,8 +466,8 @@ export class GlobalUndoAction extends BaseUndoAction {
|
||||
|
||||
static ID = 'workbench.action.git.undoAll';
|
||||
|
||||
constructor( @IGitService gitService: IGitService, @IEventService eventService: IEventService, @IMessageService messageService: IMessageService, @IFileService fileService: IFileService, @IWorkbenchEditorService editorService: IWorkbenchEditorService, @IWorkspaceContextService contextService: IWorkspaceContextService) {
|
||||
super(GlobalUndoAction.ID, nls.localize('undoAllChanges', "Clean All"), 'git-action undo', gitService, eventService, messageService, fileService, editorService, contextService);
|
||||
constructor( @IGitService gitService: IGitService, @IMessageService messageService: IMessageService, @IFileService fileService: IFileService, @IWorkbenchEditorService editorService: IWorkbenchEditorService, @IWorkspaceContextService contextService: IWorkspaceContextService) {
|
||||
super(GlobalUndoAction.ID, nls.localize('undoAllChanges', "Clean All"), 'git-action undo', gitService, messageService, fileService, editorService, contextService);
|
||||
}
|
||||
|
||||
protected isEnabled(): boolean {
|
||||
|
||||
@@ -23,13 +23,12 @@ import { Model } from 'vs/workbench/parts/git/common/gitModel';
|
||||
import { NativeGitIndexStringEditorInput, GitIndexDiffEditorInput, GitWorkingTreeDiffEditorInput, GitDiffEditorInput } from 'vs/workbench/parts/git/browser/gitEditorInputs';
|
||||
import { GitOperation } from 'vs/workbench/parts/git/browser/gitOperations';
|
||||
import { TextFileModelChangeEvent, ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IFileService, EventType as FileEventType, FileChangesEvent, FileChangeType } from 'vs/platform/files/common/files';
|
||||
import { IFileService, FileChangesEvent, FileChangeType } from 'vs/platform/files/common/files';
|
||||
import { ThrottledDelayer, PeriodThrottledDelayer } from 'vs/base/common/async';
|
||||
import severity from 'vs/base/common/severity';
|
||||
import { IOutputService } from 'vs/workbench/parts/output/common/output';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IMessageService, CloseAction } from 'vs/platform/message/common/message';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
@@ -50,7 +49,6 @@ function toReadablePath(path: string): string {
|
||||
class EditorInputCache {
|
||||
private gitService: GitService;
|
||||
private fileService: IFileService;
|
||||
private eventService: IEventService;
|
||||
private instantiationService: IInstantiationService;
|
||||
private editorService: IWorkbenchEditorService;
|
||||
private editorGroupService: IEditorGroupService;
|
||||
@@ -61,14 +59,12 @@ class EditorInputCache {
|
||||
constructor(gitService: GitService,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@IFileService fileService: IFileService,
|
||||
@IEventService eventService: IEventService,
|
||||
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
|
||||
@IEditorGroupService editorGroupService: IEditorGroupService,
|
||||
@IWorkspaceContextService contextService: IWorkspaceContextService
|
||||
) {
|
||||
this.instantiationService = instantiationService;
|
||||
this.fileService = fileService;
|
||||
this.eventService = eventService;
|
||||
this.editorService = editorService;
|
||||
this.editorGroupService = editorGroupService;
|
||||
this.contextService = contextService;
|
||||
@@ -256,7 +252,6 @@ export class AutoFetcher implements IAutoFetcher, IDisposable {
|
||||
|
||||
private _state: AutoFetcherState;
|
||||
private gitService: GitService;
|
||||
private eventService: IEventService;
|
||||
private messageService: IMessageService;
|
||||
private configurationService: IConfigurationService;
|
||||
private instantiationService: IInstantiationService;
|
||||
@@ -266,7 +261,6 @@ export class AutoFetcher implements IAutoFetcher, IDisposable {
|
||||
private gitServiceStateDisposable: IDisposable;
|
||||
|
||||
constructor(gitService: GitService, // gitService passed as argument, not by injection
|
||||
@IEventService eventService: IEventService,
|
||||
@IMessageService messageService: IMessageService,
|
||||
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@@ -274,7 +268,6 @@ export class AutoFetcher implements IAutoFetcher, IDisposable {
|
||||
) {
|
||||
this._state = AutoFetcherState.Disabled;
|
||||
this.gitService = gitService;
|
||||
this.eventService = eventService;
|
||||
this.messageService = messageService;
|
||||
this.configurationService = configurationService;
|
||||
this.instantiationService = instantiationService;
|
||||
@@ -388,7 +381,6 @@ export class GitService extends EventEmitter
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
private eventService: IEventService;
|
||||
private contextService: IWorkspaceContextService;
|
||||
private messageService: IMessageService;
|
||||
private textFileService: ITextFileService;
|
||||
@@ -424,7 +416,7 @@ export class GitService extends EventEmitter
|
||||
constructor(
|
||||
raw: IRawGitService,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@IEventService eventService: IEventService,
|
||||
@IFileService private fileService: IFileService,
|
||||
@IMessageService messageService: IMessageService,
|
||||
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
|
||||
@IOutputService outputService: IOutputService,
|
||||
@@ -437,7 +429,6 @@ export class GitService extends EventEmitter
|
||||
super();
|
||||
|
||||
this.instantiationService = instantiationService;
|
||||
this.eventService = eventService;
|
||||
this.messageService = messageService;
|
||||
this.editorService = editorService;
|
||||
this.textFileService = textFileService;
|
||||
@@ -495,7 +486,7 @@ export class GitService extends EventEmitter
|
||||
}
|
||||
|
||||
private registerListeners(): void {
|
||||
this.toDispose.push(this.eventService.addListener2(FileEventType.FILE_CHANGES, (e) => this.onFileChanges(e)));
|
||||
this.toDispose.push(this.fileService.onFileChanges((e) => this.onFileChanges(e)));
|
||||
this.toDispose.push(this.textFileService.models.onModelSaved((e) => this.onTextFileChange(e)));
|
||||
this.toDispose.push(this.textFileService.models.onModelReverted((e) => this.onTextFileChange(e)));
|
||||
this.toDispose.push(this.configurationService.onDidUpdateConfiguration(() => {
|
||||
|
||||
@@ -24,7 +24,6 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
|
||||
import quickopen = require('vs/workbench/browser/quickopen');
|
||||
import 'vs/workbench/parts/git/browser/gitEditorContributions';
|
||||
import { IActivityBarService, ProgressBadge, NumberBadge } from 'vs/workbench/services/activity/common/activityBarService';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IMessageService } from 'vs/platform/message/common/message';
|
||||
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
@@ -36,7 +35,6 @@ export class StatusUpdater implements ext.IWorkbenchContribution {
|
||||
static ID = 'vs.git.statusUpdater';
|
||||
|
||||
private gitService: IGitService;
|
||||
private eventService: IEventService;
|
||||
private activityBarService: IActivityBarService;
|
||||
private messageService: IMessageService;
|
||||
private configurationService: IConfigurationService;
|
||||
@@ -45,13 +43,11 @@ export class StatusUpdater implements ext.IWorkbenchContribution {
|
||||
|
||||
constructor(
|
||||
@IGitService gitService: IGitService,
|
||||
@IEventService eventService: IEventService,
|
||||
@IActivityBarService activityBarService: IActivityBarService,
|
||||
@IMessageService messageService: IMessageService,
|
||||
@IConfigurationService configurationService: IConfigurationService
|
||||
) {
|
||||
this.gitService = gitService;
|
||||
this.eventService = eventService;
|
||||
this.activityBarService = activityBarService;
|
||||
this.messageService = messageService;
|
||||
this.configurationService = configurationService;
|
||||
|
||||
@@ -36,7 +36,6 @@ import { IEditorInput } from 'vs/platform/editor/common/editor';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IMessageService } from 'vs/platform/message/common/message';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
@@ -87,7 +86,6 @@ export class ChangesView extends EventEmitter.EventEmitter implements GitView.IV
|
||||
@IWorkspaceContextService contextService: IWorkspaceContextService,
|
||||
@IGitService gitService: IGitService,
|
||||
@IOutputService outputService: IOutputService,
|
||||
@IEventService eventService: IEventService,
|
||||
@IConfigurationService private configurationService: IConfigurationService
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -12,7 +12,6 @@ import { ITextFileService } from 'vs/workbench/services/textfile/common/textfile
|
||||
import { IOutputService } from 'vs/workbench/parts/output/common/output';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IMessageService } from 'vs/platform/message/common/message';
|
||||
@@ -26,6 +25,7 @@ import { spawn, exec } from 'child_process';
|
||||
import { join } from 'path';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { readdir } from 'vs/base/node/pfs';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
|
||||
interface IGit {
|
||||
path: string;
|
||||
@@ -196,7 +196,7 @@ export class ElectronGitService extends GitService {
|
||||
|
||||
constructor(
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@IEventService eventService: IEventService,
|
||||
@IFileService fileService: IFileService,
|
||||
@IMessageService messageService: IMessageService,
|
||||
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
|
||||
@IOutputService outputService: IOutputService,
|
||||
@@ -230,6 +230,6 @@ export class ElectronGitService extends GitService {
|
||||
}
|
||||
}
|
||||
|
||||
super(raw, instantiationService, eventService, messageService, editorService, outputService, textFileService, contextService, lifecycleService, storageService, configurationService);
|
||||
super(raw, instantiationService, fileService, messageService, editorService, outputService, textFileService, contextService, lifecycleService, storageService, configurationService);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import { IAction, Action } from 'vs/base/common/actions';
|
||||
import { IActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { IMarkerService } from 'vs/platform/markers/common/markers';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
|
||||
import { asFileEditorInput } from 'vs/workbench/common/editor';
|
||||
import { Panel } from 'vs/workbench/browser/panel';
|
||||
@@ -66,7 +65,6 @@ export class MarkersPanel extends Panel {
|
||||
@IMarkerService private markerService: IMarkerService,
|
||||
@IEditorGroupService private editorGroupService: IEditorGroupService,
|
||||
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
|
||||
@IEventService private eventService: IEventService,
|
||||
@IConfigurationService private configurationService: IConfigurationService,
|
||||
@IContextKeyService private contextKeyService: IContextKeyService,
|
||||
@ITelemetryService telemetryService: ITelemetryService
|
||||
|
||||
@@ -13,7 +13,6 @@ import { IEditorOptions } from 'vs/editor/common/editorCommon';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IMessageService } from 'vs/platform/message/common/message';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
@@ -43,7 +42,6 @@ export class OutputPanel extends StringEditor {
|
||||
@IStorageService storageService: IStorageService,
|
||||
@IMessageService messageService: IMessageService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IEventService eventService: IEventService,
|
||||
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@IOutputService private outputService: IOutputService,
|
||||
@@ -53,7 +51,7 @@ export class OutputPanel extends StringEditor {
|
||||
@ITextFileService textFileService: ITextFileService
|
||||
) {
|
||||
super(telemetryService, instantiationService, contextService, storageService,
|
||||
messageService, configurationService, eventService, editorService, themeService, untitledEditorService, editorGroupService, textFileService);
|
||||
messageService, configurationService, editorService, themeService, untitledEditorService, editorGroupService, textFileService);
|
||||
this.scopedInstantiationService = instantiationService;
|
||||
this.toDispose = [];
|
||||
}
|
||||
|
||||
@@ -45,7 +45,6 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IMessageService } from 'vs/platform/message/common/message';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
|
||||
@@ -114,7 +113,6 @@ export class DefaultPreferencesEditor extends BaseTextEditor {
|
||||
@IStorageService storageService: IStorageService,
|
||||
@IMessageService messageService: IMessageService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IEventService eventService: IEventService,
|
||||
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@IUntitledEditorService private untitledEditorService: IUntitledEditorService,
|
||||
@@ -123,7 +121,7 @@ export class DefaultPreferencesEditor extends BaseTextEditor {
|
||||
@IModeService private modeService: IModeService,
|
||||
@ITextFileService textFileService: ITextFileService
|
||||
) {
|
||||
super(DefaultPreferencesEditor.ID, telemetryService, instantiationService, contextService, storageService, messageService, configurationService, eventService, editorService, themeService, textFileService);
|
||||
super(DefaultPreferencesEditor.ID, telemetryService, instantiationService, contextService, storageService, messageService, configurationService, editorService, themeService, textFileService);
|
||||
this.delayedFilterLogging = new Delayer<void>(1000);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import * as winjs from 'vs/base/common/winjs.base';
|
||||
import * as ext from 'vs/workbench/common/contributions';
|
||||
import * as common from 'vs/editor/common/editorCommon';
|
||||
import * as widget from 'vs/editor/browser/codeEditor';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IMessageService } from 'vs/platform/message/common/message';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
@@ -196,7 +195,6 @@ export class DirtyDiffDecorator implements ext.IWorkbenchContribution {
|
||||
@IMessageService private messageService: IMessageService,
|
||||
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
|
||||
@IEditorGroupService editorGroupService: IEditorGroupService,
|
||||
@IEventService private eventService: IEventService,
|
||||
@IWorkspaceContextService private contextService: IWorkspaceContextService,
|
||||
@IInstantiationService private instantiationService: IInstantiationService
|
||||
) {
|
||||
|
||||
@@ -14,7 +14,6 @@ import { EditorInput } from 'vs/workbench/common/editor';
|
||||
import { IEditorService } from 'vs/platform/editor/common/editor';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { Match, FileMatch, FileMatchOrMatch, ISearchWorkbenchService } from 'vs/workbench/parts/search/common/searchModel';
|
||||
import { BulkEdit, IResourceEdit, createBulkEdit } from 'vs/editor/common/services/bulkEdit';
|
||||
import { IProgressRunner } from 'vs/platform/progress/common/progress';
|
||||
@@ -25,7 +24,7 @@ import { ITextModelResolverService, ITextModelContentProvider } from 'vs/editor/
|
||||
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||
import { IModel } from 'vs/editor/common/editorCommon';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
|
||||
export class ReplacePreviewContentProvider implements ITextModelContentProvider, IWorkbenchContribution {
|
||||
|
||||
@@ -87,7 +86,7 @@ export class ReplaceService implements IReplaceService {
|
||||
|
||||
constructor(
|
||||
@ITelemetryService private telemetryService: ITelemetryService,
|
||||
@IEventService private eventService: IEventService,
|
||||
@IFileService private fileService: IFileService,
|
||||
@IEditorService private editorService: IWorkbenchEditorService,
|
||||
@IInstantiationService private instantiationService: IInstantiationService,
|
||||
@ITextModelResolverService private textModelResolverService: ITextModelResolverService,
|
||||
@@ -100,7 +99,7 @@ export class ReplaceService implements IReplaceService {
|
||||
public replace(match: FileMatchOrMatch, progress?: IProgressRunner, resource?: URI): TPromise<any>
|
||||
public replace(arg: any, progress: IProgressRunner = null, resource: URI = null): TPromise<any> {
|
||||
|
||||
let bulkEdit: BulkEdit = createBulkEdit(this.eventService, this.textModelResolverService, null);
|
||||
let bulkEdit: BulkEdit = createBulkEdit(this.fileService, this.textModelResolverService, null);
|
||||
bulkEdit.progress(progress);
|
||||
|
||||
if (arg instanceof Match) {
|
||||
|
||||
@@ -27,7 +27,7 @@ import { Scope } from 'vs/workbench/common/memento';
|
||||
import { IPreferencesService } from 'vs/workbench/parts/preferences/common/preferences';
|
||||
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
|
||||
import { getOutOfWorkspaceEditorResources } from 'vs/workbench/common/editor';
|
||||
import { FileChangeType, FileChangesEvent, EventType as FileEventType } from 'vs/platform/files/common/files';
|
||||
import { FileChangeType, FileChangesEvent, IFileService } from 'vs/platform/files/common/files';
|
||||
import { Viewlet } from 'vs/workbench/browser/viewlet';
|
||||
import { Match, FileMatch, SearchModel, FileMatchOrMatch, IChangeEvent, ISearchWorkbenchService } from 'vs/workbench/parts/search/common/searchModel';
|
||||
import { getExcludes, QueryBuilder } from 'vs/workbench/parts/search/common/searchQuery';
|
||||
@@ -37,7 +37,6 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi
|
||||
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IMessageService } from 'vs/platform/message/common/message';
|
||||
import { IProgressService } from 'vs/platform/progress/common/progress';
|
||||
@@ -89,7 +88,7 @@ export class SearchViewlet extends Viewlet {
|
||||
|
||||
constructor(
|
||||
@ITelemetryService telemetryService: ITelemetryService,
|
||||
@IEventService private eventService: IEventService,
|
||||
@IFileService private fileService: IFileService,
|
||||
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
|
||||
@IEditorGroupService private editorGroupService: IEditorGroupService,
|
||||
@IProgressService private progressService: IProgressService,
|
||||
@@ -116,7 +115,7 @@ export class SearchViewlet extends Viewlet {
|
||||
this.queryBuilder = this.instantiationService.createInstance(QueryBuilder);
|
||||
this.viewletSettings = this.getMemento(storageService, Scope.WORKSPACE);
|
||||
|
||||
this.toUnbind.push(this.eventService.addListener2(FileEventType.FILE_CHANGES, (e) => this.onFilesChanged(e)));
|
||||
this.toUnbind.push(this.fileService.onFileChanges(e => this.onFilesChanged(e)));
|
||||
this.toUnbind.push(this.untitledEditorService.onDidChangeDirty(e => this.onUntitledDidChangeDirty(e)));
|
||||
this.toUnbind.push(this.configurationService.onDidUpdateConfiguration(e => this.onConfigurationUpdated(e.config)));
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ suite('CacheState', () => {
|
||||
const second = createCacheState(cache, first);
|
||||
second.load();
|
||||
const secondKey = cache.cacheKeys[1];
|
||||
var origErrorHandler = errors.errorHandler.getUnexpectedErrorHandler();
|
||||
const origErrorHandler = errors.errorHandler.getUnexpectedErrorHandler();
|
||||
try {
|
||||
errors.setUnexpectedErrorHandler(() => null);
|
||||
cache.loading[secondKey].error('loading failed');
|
||||
|
||||
@@ -30,13 +30,12 @@ import { Registry } from 'vs/platform/platform';
|
||||
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IEditor } from 'vs/platform/editor/common/editor';
|
||||
import { IMessageService } from 'vs/platform/message/common/message';
|
||||
import { IMarkerService, MarkerStatistics } from 'vs/platform/markers/common/markers';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IFileService, FileChangesEvent, FileChangeType, EventType as FileEventType } from 'vs/platform/files/common/files';
|
||||
import { IFileService, FileChangeType } from 'vs/platform/files/common/files';
|
||||
import { IExtensionService } from 'vs/platform/extensions/common/extensions';
|
||||
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
@@ -611,7 +610,6 @@ class TaskService extends EventEmitter implements ITaskService {
|
||||
private editorService: IWorkbenchEditorService;
|
||||
private contextService: IWorkspaceContextService;
|
||||
private textFileService: ITextFileService;
|
||||
private eventService: IEventService;
|
||||
private modelService: IModelService;
|
||||
private extensionService: IExtensionService;
|
||||
private quickOpenService: IQuickOpenService;
|
||||
@@ -629,7 +627,7 @@ class TaskService extends EventEmitter implements ITaskService {
|
||||
@IMessageService messageService: IMessageService, @IWorkbenchEditorService editorService: IWorkbenchEditorService,
|
||||
@IFileService fileService: IFileService, @IWorkspaceContextService contextService: IWorkspaceContextService,
|
||||
@ITelemetryService telemetryService: ITelemetryService, @ITextFileService textFileService: ITextFileService,
|
||||
@ILifecycleService lifecycleService: ILifecycleService, @IEventService eventService: IEventService,
|
||||
@ILifecycleService lifecycleService: ILifecycleService,
|
||||
@IModelService modelService: IModelService, @IExtensionService extensionService: IExtensionService,
|
||||
@IQuickOpenService quickOpenService: IQuickOpenService,
|
||||
@IEnvironmentService private environmentService: IEnvironmentService,
|
||||
@@ -646,7 +644,6 @@ class TaskService extends EventEmitter implements ITaskService {
|
||||
this.contextService = contextService;
|
||||
this.telemetryService = telemetryService;
|
||||
this.textFileService = textFileService;
|
||||
this.eventService = eventService;
|
||||
this.modelService = modelService;
|
||||
this.extensionService = extensionService;
|
||||
this.quickOpenService = quickOpenService;
|
||||
@@ -841,7 +838,7 @@ class TaskService extends EventEmitter implements ITaskService {
|
||||
if (executeResult.kind === TaskExecuteKind.Started) {
|
||||
if (executeResult.started.restartOnFileChanges) {
|
||||
let pattern = executeResult.started.restartOnFileChanges;
|
||||
this.fileChangesListener = this.eventService.addListener2(FileEventType.FILE_CHANGES, (event: FileChangesEvent) => {
|
||||
this.fileChangesListener = this.fileService.onFileChanges(event => {
|
||||
let needsRestart = event.changes.some((change) => {
|
||||
return (change.type === FileChangeType.ADDED || change.type === FileChangeType.DELETED) && !!match(pattern, change.resource.fsPath);
|
||||
});
|
||||
|
||||
@@ -49,7 +49,7 @@ const untitledBackupPath = path.join(workspaceBackupPath, 'untitled', crypto.cre
|
||||
|
||||
class TestBackupFileService extends BackupFileService {
|
||||
constructor(workspace: Uri, backupHome: string, workspacesJsonPath: string) {
|
||||
const fileService = new FileService(workspace.fsPath, { disableWatcher: true }, null);
|
||||
const fileService = new FileService(workspace.fsPath, { disableWatcher: true });
|
||||
const environmentService = new TestEnvironmentService(backupHome, workspacesJsonPath);
|
||||
const backupService: IBackupService = {
|
||||
_serviceBrand: null,
|
||||
|
||||
@@ -14,7 +14,6 @@ import { RunOnceScheduler } from 'vs/base/common/async';
|
||||
import collections = require('vs/base/common/collections');
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { readFile } from 'vs/base/node/pfs';
|
||||
import errors = require('vs/base/common/errors');
|
||||
@@ -22,7 +21,7 @@ import { IConfigFile, consolidate, newConfigFile } from 'vs/workbench/services/c
|
||||
import { IConfigurationServiceEvent, ConfigurationSource, getConfigurationValue } from 'vs/platform/configuration/common/configuration';
|
||||
import { ConfigurationService as BaseConfigurationService } from 'vs/platform/configuration/node/configurationService';
|
||||
import { IWorkspaceConfigurationValues, IWorkspaceConfigurationService, IWorkspaceConfigurationValue, CONFIG_DEFAULT_NAME, WORKSPACE_CONFIG_FOLDER_DEFAULT_NAME, WORKSPACE_STANDALONE_CONFIGURATIONS, WORKSPACE_CONFIG_DEFAULT_PATH } from 'vs/workbench/services/configuration/common/configuration';
|
||||
import { EventType as FileEventType, FileChangeType, FileChangesEvent } from 'vs/platform/files/common/files';
|
||||
import { FileChangeType, FileChangesEvent } from 'vs/platform/files/common/files';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
|
||||
interface IStat {
|
||||
@@ -64,7 +63,6 @@ export class WorkspaceConfigurationService implements IWorkspaceConfigurationSer
|
||||
|
||||
constructor(
|
||||
@IWorkspaceContextService private contextService: IWorkspaceContextService,
|
||||
@IEventService private eventService: IEventService,
|
||||
@IEnvironmentService environmentService: IEnvironmentService,
|
||||
private workspaceSettingsRootFolder: string = WORKSPACE_CONFIG_FOLDER_DEFAULT_NAME
|
||||
) {
|
||||
@@ -97,7 +95,6 @@ export class WorkspaceConfigurationService implements IWorkspaceConfigurationSer
|
||||
}
|
||||
|
||||
private registerListeners(): void {
|
||||
this.toDispose.push(this.eventService.addListener2(FileEventType.FILE_CHANGES, events => this.handleWorkspaceFileEvents(events)));
|
||||
this.toDispose.push(this.baseConfigurationService.onDidUpdateConfiguration(e => this.onBaseConfigurationChanged(e)));
|
||||
}
|
||||
|
||||
@@ -258,7 +255,7 @@ export class WorkspaceConfigurationService implements IWorkspaceConfigurationSer
|
||||
return this.bulkFetchFromWorkspacePromise.then(() => TPromise.join(this.workspaceFilePathToConfiguration));
|
||||
}
|
||||
|
||||
private handleWorkspaceFileEvents(event: FileChangesEvent): void {
|
||||
public handleWorkspaceFileEvents(event: FileChangesEvent): void {
|
||||
const events = event.changes;
|
||||
let affectedByChanges = false;
|
||||
|
||||
|
||||
+3
-5
@@ -17,12 +17,11 @@ import { parseArgs } from 'vs/platform/environment/node/argv';
|
||||
import { WorkspaceContextService, IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import extfs = require('vs/base/node/extfs');
|
||||
import { TestEventService, workbenchInstantiationService, TestTextFileService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { workbenchInstantiationService, TestTextFileService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import uuid = require('vs/base/common/uuid');
|
||||
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { WorkspaceConfigurationService } from 'vs/workbench/services/configuration/node/configurationService';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import utils = require('vs/workbench/services/files/test/node/utils');
|
||||
import { FileService } from 'vs/workbench/services/files/node/fileService';
|
||||
import { ConfigurationEditingService } from 'vs/workbench/services/configuration/node/configurationEditingService';
|
||||
import { ConfigurationTarget, IConfigurationEditingError, ConfigurationEditingErrorCode } from 'vs/workbench/services/configuration/common/configurationEditing';
|
||||
@@ -98,10 +97,9 @@ suite('WorkspaceConfigurationEditingService - Node', () => {
|
||||
function createServices(workspaceDir: string, globalSettingsFile: string, dirty?: boolean, noWorkspace?: boolean): TPromise<{ configurationService: WorkspaceConfigurationService, configurationEditingService: ConfigurationEditingService }> {
|
||||
const workspaceContextService = new WorkspaceContextService(noWorkspace ? null : { resource: URI.file(workspaceDir) });
|
||||
const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile);
|
||||
const configurationService = new WorkspaceConfigurationService(workspaceContextService, new TestEventService(), environmentService);
|
||||
const fileService = new FileService(noWorkspace ? null : workspaceDir, { disableWatcher: true });
|
||||
const configurationService = new WorkspaceConfigurationService(workspaceContextService, environmentService);
|
||||
const textFileService = workbenchInstantiationService().createInstance(TestDirtyTextFileService, dirty);
|
||||
const events = new utils.TestEventService();
|
||||
const fileService = new FileService(noWorkspace ? null : workspaceDir, { disableWatcher: true }, events);
|
||||
|
||||
return configurationService.initialize().then(() => {
|
||||
return {
|
||||
|
||||
@@ -16,12 +16,11 @@ import { WorkspaceContextService } from 'vs/platform/workspace/common/workspace'
|
||||
import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import { parseArgs } from 'vs/platform/environment/node/argv';
|
||||
import extfs = require('vs/base/node/extfs');
|
||||
import { TestEventService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import uuid = require('vs/base/common/uuid');
|
||||
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { WorkspaceConfigurationService } from 'vs/workbench/services/configuration/node/configurationService';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { EventType as FileEventType, FileChangeType, FileChangesEvent } from 'vs/platform/files/common/files';
|
||||
import { FileChangeType, FileChangesEvent } from 'vs/platform/files/common/files';
|
||||
|
||||
class SettingsTestEnvironmentService extends EnvironmentService {
|
||||
|
||||
@@ -49,7 +48,7 @@ suite('WorkspaceConfigurationService - Node', () => {
|
||||
function createService(workspaceDir: string, globalSettingsFile: string): TPromise<WorkspaceConfigurationService> {
|
||||
const workspaceContextService = new WorkspaceContextService({ resource: URI.file(workspaceDir) });
|
||||
const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile);
|
||||
const service = new WorkspaceConfigurationService(workspaceContextService, new TestEventService(), environmentService);
|
||||
const service = new WorkspaceConfigurationService(workspaceContextService, environmentService);
|
||||
|
||||
return service.initialize().then(() => service);
|
||||
}
|
||||
@@ -214,8 +213,7 @@ suite('WorkspaceConfigurationService - Node', () => {
|
||||
createWorkspace((workspaceDir, globalSettingsFile, cleanUp) => {
|
||||
const workspaceContextService = new WorkspaceContextService({ resource: URI.file(workspaceDir) });
|
||||
const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile);
|
||||
const eventService = new TestEventService();
|
||||
const service = new WorkspaceConfigurationService(workspaceContextService, eventService, environmentService);
|
||||
const service = new WorkspaceConfigurationService(workspaceContextService, environmentService);
|
||||
|
||||
return service.initialize().then(() => {
|
||||
service.onDidUpdateConfiguration(event => {
|
||||
@@ -232,7 +230,7 @@ suite('WorkspaceConfigurationService - Node', () => {
|
||||
fs.writeFileSync(settingsFile, '{ "testworkbench.editor.icons": true }');
|
||||
|
||||
const event = new FileChangesEvent([{ resource: URI.file(settingsFile), type: FileChangeType.ADDED }]);
|
||||
eventService.emit(FileEventType.FILE_CHANGES, event);
|
||||
service.handleWorkspaceFileEvents(event);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,10 +12,9 @@ import encoding = require('vs/base/node/encoding');
|
||||
import errors = require('vs/base/common/errors');
|
||||
import uri from 'vs/base/common/uri';
|
||||
import { asFileEditorInput } from 'vs/workbench/common/editor';
|
||||
import { IFileService, IFilesConfiguration, IResolveFileOptions, IFileStat, IContent, IStreamContent, IImportResult, IResolveContentOptions, IUpdateContentOptions } from 'vs/platform/files/common/files';
|
||||
import { FileOperation, FileOperationEvent, IFileService, IFilesConfiguration, IResolveFileOptions, IFileStat, IContent, IStreamContent, IImportResult, IResolveContentOptions, IUpdateContentOptions, FileChangesEvent } from 'vs/platform/files/common/files';
|
||||
import { FileService as NodeFileService, IFileServiceOptions, IEncodingOverride } from 'vs/workbench/services/files/node/fileService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
@@ -24,6 +23,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
|
||||
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
|
||||
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
|
||||
import { shell } from 'electron';
|
||||
|
||||
@@ -40,9 +40,11 @@ export class FileService implements IFileService {
|
||||
private toUnbind: IDisposable[];
|
||||
private activeOutOfWorkspaceWatchers: { [resource: string]: boolean; };
|
||||
|
||||
private _onFileChanges: Emitter<FileChangesEvent>;
|
||||
private _onAfterOperation: Emitter<FileOperationEvent>;
|
||||
|
||||
constructor(
|
||||
@IConfigurationService private configurationService: IConfigurationService,
|
||||
@IEventService private eventService: IEventService,
|
||||
@IWorkspaceContextService private contextService: IWorkspaceContextService,
|
||||
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
|
||||
@IEnvironmentService environmentService: IEnvironmentService,
|
||||
@@ -54,6 +56,12 @@ export class FileService implements IFileService {
|
||||
this.toUnbind = [];
|
||||
this.activeOutOfWorkspaceWatchers = Object.create(null);
|
||||
|
||||
this._onFileChanges = new Emitter<FileChangesEvent>();
|
||||
this.toUnbind.push(this._onFileChanges);
|
||||
|
||||
this._onAfterOperation = new Emitter<FileOperationEvent>();
|
||||
this.toUnbind.push(this._onAfterOperation);
|
||||
|
||||
const configuration = this.configurationService.getConfiguration<IFilesConfiguration>();
|
||||
|
||||
// adjust encodings
|
||||
@@ -79,12 +87,20 @@ export class FileService implements IFileService {
|
||||
|
||||
// create service
|
||||
const workspace = this.contextService.getWorkspace();
|
||||
this.raw = new NodeFileService(workspace ? workspace.resource.fsPath : void 0, fileServiceConfig, this.eventService);
|
||||
this.raw = new NodeFileService(workspace ? workspace.resource.fsPath : void 0, fileServiceConfig);
|
||||
|
||||
// Listeners
|
||||
this.registerListeners();
|
||||
}
|
||||
|
||||
public get onFileChanges(): Event<FileChangesEvent> {
|
||||
return this._onFileChanges.event;
|
||||
}
|
||||
|
||||
public get onAfterOperation(): Event<FileOperationEvent> {
|
||||
return this._onAfterOperation.event;
|
||||
}
|
||||
|
||||
private onFileServiceError(msg: any): void {
|
||||
errors.onUnexpectedError(msg);
|
||||
|
||||
@@ -111,6 +127,10 @@ export class FileService implements IFileService {
|
||||
|
||||
private registerListeners(): void {
|
||||
|
||||
// File events
|
||||
this.toUnbind.push(this.raw.onFileChanges(e => this._onFileChanges.fire(e)));
|
||||
this.toUnbind.push(this.raw.onAfterOperation(e => this._onAfterOperation.fire(e)));
|
||||
|
||||
// Config changes
|
||||
this.toUnbind.push(this.configurationService.onDidUpdateConfiguration(e => this.onConfigurationChange(e.config)));
|
||||
|
||||
@@ -222,12 +242,13 @@ export class FileService implements IFileService {
|
||||
}
|
||||
|
||||
const absolutePath = resource.fsPath;
|
||||
|
||||
const result = shell.moveItemToTrash(absolutePath);
|
||||
if (!result) {
|
||||
return TPromise.wrapError<void>(new Error(nls.localize('trashFailed', "Failed to move '{0}' to the trash", paths.basename(absolutePath))));
|
||||
}
|
||||
|
||||
this._onAfterOperation.fire(new FileOperationEvent(resource, FileOperation.DELETE));
|
||||
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import os = require('os');
|
||||
import crypto = require('crypto');
|
||||
import assert = require('assert');
|
||||
|
||||
import { IContent, IFileService, IResolveFileOptions, IResolveContentOptions, IFileStat, IStreamContent, IFileOperationResult, FileOperationResult, IBaseStat, IUpdateContentOptions, FileChangeType, EventType, IImportResult, MAX_FILE_SIZE } from 'vs/platform/files/common/files';
|
||||
import { FileOperation, FileOperationEvent, IContent, IFileService, IResolveFileOptions, IResolveContentOptions, IFileStat, IStreamContent, IFileOperationResult, FileOperationResult, IBaseStat, IUpdateContentOptions, FileChangeType, IImportResult, MAX_FILE_SIZE, FileChangesEvent } from 'vs/platform/files/common/files';
|
||||
import strings = require('vs/base/common/strings');
|
||||
import arrays = require('vs/base/common/arrays');
|
||||
import baseMime = require('vs/base/common/mime');
|
||||
@@ -24,6 +24,7 @@ import { nfcall, Limiter, ThrottledDelayer } from 'vs/base/common/async';
|
||||
import uri from 'vs/base/common/uri';
|
||||
import nls = require('vs/nls');
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
import { dispose, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
import pfs = require('vs/base/node/pfs');
|
||||
import encoding = require('vs/base/node/encoding');
|
||||
@@ -32,7 +33,7 @@ import flow = require('vs/base/node/flow');
|
||||
import { FileWatcher as UnixWatcherService } from 'vs/workbench/services/files/node/watcher/unix/watcherService';
|
||||
import { FileWatcher as WindowsWatcherService } from 'vs/workbench/services/files/node/watcher/win32/watcherService';
|
||||
import { toFileChangesEvent, normalize, IRawFileChange } from 'vs/workbench/services/files/node/watcher/common';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
|
||||
export interface IEncodingOverride {
|
||||
resource: uri;
|
||||
@@ -63,7 +64,7 @@ function etag(arg1: any, arg2?: any): string {
|
||||
mtime = (<fs.Stats>arg1).mtime.getTime();
|
||||
}
|
||||
|
||||
return '"' + crypto.createHash('sha1').update(String(size) + String(mtime)).digest('hex') + '"';
|
||||
return `"${crypto.createHash('sha1').update(String(size) + String(mtime)).digest('hex')}"`;
|
||||
}
|
||||
|
||||
export class FileService implements IFileService {
|
||||
@@ -78,13 +79,17 @@ export class FileService implements IFileService {
|
||||
private tmpPath: string;
|
||||
private options: IFileServiceOptions;
|
||||
|
||||
private workspaceWatcherToDispose: () => void;
|
||||
private _onFileChanges: Emitter<FileChangesEvent>;
|
||||
private _onAfterOperation: Emitter<FileOperationEvent>;
|
||||
|
||||
private toDispose: IDisposable[];
|
||||
|
||||
private activeFileChangesWatchers: { [resource: string]: fs.FSWatcher; };
|
||||
private fileChangesWatchDelayer: ThrottledDelayer<void>;
|
||||
private undeliveredRawFileChangesEvents: IRawFileChange[];
|
||||
|
||||
constructor(basePath: string, options: IFileServiceOptions, private eventEmitter: IEventService) {
|
||||
constructor(basePath: string, options: IFileServiceOptions) {
|
||||
this.toDispose = [];
|
||||
this.basePath = basePath ? paths.normalize(basePath) : void 0;
|
||||
|
||||
if (this.basePath && this.basePath.indexOf('\\\\') === 0 && strings.endsWith(this.basePath, paths.sep)) {
|
||||
@@ -102,6 +107,12 @@ export class FileService implements IFileService {
|
||||
this.options = options || Object.create(null);
|
||||
this.tmpPath = this.options.tmpDir || os.tmpdir();
|
||||
|
||||
this._onFileChanges = new Emitter<FileChangesEvent>();
|
||||
this.toDispose.push(this._onFileChanges);
|
||||
|
||||
this._onAfterOperation = new Emitter<FileOperationEvent>();
|
||||
this.toDispose.push(this._onAfterOperation);
|
||||
|
||||
if (!this.options.errorLogger) {
|
||||
this.options.errorLogger = console.error;
|
||||
}
|
||||
@@ -119,6 +130,14 @@ export class FileService implements IFileService {
|
||||
this.undeliveredRawFileChangesEvents = [];
|
||||
}
|
||||
|
||||
public get onFileChanges(): Event<FileChangesEvent> {
|
||||
return this._onFileChanges.event;
|
||||
}
|
||||
|
||||
public get onAfterOperation(): Event<FileOperationEvent> {
|
||||
return this._onAfterOperation.event;
|
||||
}
|
||||
|
||||
public updateOptions(options: IFileServiceOptions): void {
|
||||
if (options) {
|
||||
objects.mixin(this.options, options); // overwrite current options
|
||||
@@ -126,11 +145,11 @@ export class FileService implements IFileService {
|
||||
}
|
||||
|
||||
private setupWin32WorkspaceWatching(): void {
|
||||
this.workspaceWatcherToDispose = new WindowsWatcherService(this.basePath, this.options.watcherIgnoredPatterns, this.eventEmitter, this.options.errorLogger, this.options.verboseLogging).startWatching();
|
||||
this.toDispose.push(toDisposable(new WindowsWatcherService(this.basePath, this.options.watcherIgnoredPatterns, e => this._onFileChanges.fire(e), this.options.errorLogger, this.options.verboseLogging).startWatching()));
|
||||
}
|
||||
|
||||
private setupUnixWorkspaceWatching(): void {
|
||||
this.workspaceWatcherToDispose = new UnixWatcherService(this.basePath, this.options.watcherIgnoredPatterns, this.eventEmitter, this.options.errorLogger, this.options.verboseLogging).startWatching();
|
||||
this.toDispose.push(toDisposable(new UnixWatcherService(this.basePath, this.options.watcherIgnoredPatterns, e => this._onFileChanges.fire(e), this.options.errorLogger, this.options.verboseLogging).startWatching()));
|
||||
}
|
||||
|
||||
public resolveFile(resource: uri, options?: IResolveFileOptions): TPromise<IFileStat> {
|
||||
@@ -296,17 +315,31 @@ export class FileService implements IFileService {
|
||||
}
|
||||
|
||||
public createFile(resource: uri, content: string = ''): TPromise<IFileStat> {
|
||||
return this.updateContent(resource, content);
|
||||
|
||||
// Create file
|
||||
return this.updateContent(resource, content).then(result => {
|
||||
|
||||
// Events
|
||||
this._onAfterOperation.fire(new FileOperationEvent(resource, FileOperation.CREATE, result));
|
||||
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
public createFolder(resource: uri): TPromise<IFileStat> {
|
||||
|
||||
// 1.) create folder
|
||||
// 1.) Create folder
|
||||
const absolutePath = this.toAbsolutePath(resource);
|
||||
return pfs.mkdirp(absolutePath).then(() => {
|
||||
|
||||
// 2.) resolve
|
||||
return this.resolve(resource);
|
||||
// 2.) Resolve
|
||||
return this.resolve(resource).then(result => {
|
||||
|
||||
// Events
|
||||
this._onAfterOperation.fire(new FileOperationEvent(resource, FileOperation.CREATE, result));
|
||||
|
||||
return result;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -357,7 +390,13 @@ export class FileService implements IFileService {
|
||||
return this.doMoveOrCopyFile(sourcePath, targetPath, keepCopy, overwrite).then(() => {
|
||||
|
||||
// 2.) resolve
|
||||
return this.resolve(target);
|
||||
return this.resolve(target).then(result => {
|
||||
|
||||
// Events
|
||||
this._onAfterOperation.fire(new FileOperationEvent(source, keepCopy ? FileOperation.COPY : FileOperation.MOVE, result));
|
||||
|
||||
return result;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -418,7 +457,13 @@ export class FileService implements IFileService {
|
||||
return this.doMoveOrCopyFile(sourcePath, targetPath, true, true).then(exists => {
|
||||
|
||||
// 3.) resolve
|
||||
return this.resolve(targetResource).then(stat => <IImportResult>{ isNew: !exists, stat: stat });
|
||||
return this.resolve(targetResource).then(stat => {
|
||||
|
||||
// Events
|
||||
this._onAfterOperation.fire(new FileOperationEvent(source, FileOperation.IMPORT, stat));
|
||||
|
||||
return <IImportResult>{ isNew: !exists, stat: stat };
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -426,7 +471,11 @@ export class FileService implements IFileService {
|
||||
public del(resource: uri): TPromise<void> {
|
||||
const absolutePath = this.toAbsolutePath(resource);
|
||||
|
||||
return nfcall(extfs.del, absolutePath, this.tmpPath);
|
||||
return nfcall(extfs.del, absolutePath, this.tmpPath).then(() => {
|
||||
|
||||
// Events
|
||||
this._onAfterOperation.fire(new FileOperationEvent(resource, FileOperation.DELETE));
|
||||
});
|
||||
}
|
||||
|
||||
// Helpers
|
||||
@@ -653,7 +702,7 @@ export class FileService implements IFileService {
|
||||
const normalizedEvents = normalize(buffer);
|
||||
|
||||
// Emit
|
||||
this.eventEmitter.emit(EventType.FILE_CHANGES, toFileChangesEvent(normalizedEvents));
|
||||
this._onFileChanges.fire(toFileChangesEvent(normalizedEvents));
|
||||
|
||||
return TPromise.as(null);
|
||||
});
|
||||
@@ -679,10 +728,7 @@ export class FileService implements IFileService {
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
if (this.workspaceWatcherToDispose) {
|
||||
this.workspaceWatcherToDispose();
|
||||
this.workspaceWatcherToDispose = null;
|
||||
}
|
||||
this.toDispose = dispose(this.toDispose);
|
||||
|
||||
for (let key in this.activeFileChangesWatchers) {
|
||||
const watcher = this.activeFileChangesWatchers[key];
|
||||
|
||||
@@ -9,10 +9,9 @@ import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { getNextTickChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { Client } from 'vs/base/parts/ipc/node/ipc.cp';
|
||||
import uri from 'vs/base/common/uri';
|
||||
import { EventType } from 'vs/platform/files/common/files';
|
||||
import { toFileChangesEvent, IRawFileChange } from 'vs/workbench/services/files/node/watcher/common';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IWatcherChannel, WatcherChannelClient } from 'vs/workbench/services/files/node/watcher/unix/watcherIpc';
|
||||
import { FileChangesEvent } from 'vs/platform/files/common/files';
|
||||
|
||||
export class FileWatcher {
|
||||
private static MAX_RESTARTS = 5;
|
||||
@@ -23,7 +22,7 @@ export class FileWatcher {
|
||||
constructor(
|
||||
private basePath: string,
|
||||
private ignored: string[],
|
||||
private eventEmitter: IEventService,
|
||||
private onFileChanges: (changes: FileChangesEvent) => void,
|
||||
private errorLogger: (msg: string) => void,
|
||||
private verboseLogging: boolean
|
||||
) {
|
||||
@@ -80,7 +79,7 @@ export class FileWatcher {
|
||||
|
||||
// Emit through broadcast service
|
||||
if (events.length > 0) {
|
||||
this.eventEmitter.emit(EventType.FILE_CHANGES, toFileChangesEvent(events));
|
||||
this.onFileChanges(toFileChangesEvent(events));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,17 +5,16 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import { EventType } from 'vs/platform/files/common/files';
|
||||
import watcher = require('vs/workbench/services/files/node/watcher/common');
|
||||
import { IRawFileChange, toFileChangesEvent } from 'vs/workbench/services/files/node/watcher/common';
|
||||
import { OutOfProcessWin32FolderWatcher } from 'vs/workbench/services/files/node/watcher/win32/csharpWatcherService';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { FileChangesEvent } from 'vs/platform/files/common/files';
|
||||
|
||||
export class FileWatcher {
|
||||
|
||||
constructor(
|
||||
private basePath: string,
|
||||
private ignored: string[],
|
||||
private eventEmitter: IEventService,
|
||||
private onFileChanges: (changes: FileChangesEvent) => void,
|
||||
private errorLogger: (msg: string) => void,
|
||||
private verboseLogging: boolean
|
||||
) {
|
||||
@@ -33,11 +32,11 @@ export class FileWatcher {
|
||||
return () => watcher.dispose();
|
||||
}
|
||||
|
||||
private onRawFileEvents(events: watcher.IRawFileChange[]): void {
|
||||
private onRawFileEvents(events: IRawFileChange[]): void {
|
||||
|
||||
// Emit through broadcast service
|
||||
if (events.length > 0) {
|
||||
this.eventEmitter.emit(EventType.FILE_CHANGES, watcher.toFileChangesEvent(events));
|
||||
this.onFileChanges(toFileChangesEvent(events));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import assert = require('assert');
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { FileService, IEncodingOverride } from 'vs/workbench/services/files/node/fileService';
|
||||
import { EventType, FileChangesEvent, FileOperationResult, IFileOperationResult } from 'vs/platform/files/common/files';
|
||||
import { FileOperation, FileOperationEvent, FileChangesEvent, FileOperationResult, IFileOperationResult } from 'vs/platform/files/common/files';
|
||||
import { nfcall } from 'vs/base/common/async';
|
||||
import uri from 'vs/base/common/uri';
|
||||
import uuid = require('vs/base/common/uuid');
|
||||
@@ -22,7 +22,6 @@ import utils = require('vs/workbench/services/files/test/node/utils');
|
||||
import { onError } from 'vs/base/test/common/utils';
|
||||
|
||||
suite('FileService', () => {
|
||||
let events: utils.TestEventService;
|
||||
let service: FileService;
|
||||
let parentDir = path.join(os.tmpdir(), 'vsctests', 'service');
|
||||
let testDir: string;
|
||||
@@ -37,15 +36,13 @@ suite('FileService', () => {
|
||||
return onError(error, done);
|
||||
}
|
||||
|
||||
events = new utils.TestEventService();
|
||||
service = new FileService(testDir, { disableWatcher: true }, events);
|
||||
service = new FileService(testDir, { disableWatcher: true });
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
teardown((done) => {
|
||||
service.dispose();
|
||||
events.dispose();
|
||||
extfs.del(parentDir, os.tmpdir(), () => { }, done);
|
||||
});
|
||||
|
||||
@@ -64,22 +61,48 @@ suite('FileService', () => {
|
||||
});
|
||||
|
||||
test('createFile', function (done: () => void) {
|
||||
let contents = 'Hello World';
|
||||
service.createFile(uri.file(path.join(testDir, 'test.txt')), contents).done(s => {
|
||||
let event: FileOperationEvent;
|
||||
const toDispose = service.onAfterOperation(e => {
|
||||
event = e;
|
||||
});
|
||||
|
||||
const contents = 'Hello World';
|
||||
const resource = uri.file(path.join(testDir, 'test.txt'));
|
||||
service.createFile(resource, contents).done(s => {
|
||||
assert.equal(s.name, 'test.txt');
|
||||
assert.equal(fs.existsSync(s.resource.fsPath), true);
|
||||
assert.equal(fs.readFileSync(s.resource.fsPath), contents);
|
||||
|
||||
assert.ok(event);
|
||||
assert.equal(event.resource.fsPath, resource.fsPath);
|
||||
assert.equal(event.operation, FileOperation.CREATE);
|
||||
assert.equal(event.target.resource.fsPath, resource.fsPath);
|
||||
toDispose.dispose();
|
||||
|
||||
done();
|
||||
}, error => onError(error, done));
|
||||
});
|
||||
|
||||
test('createFolder', function (done: () => void) {
|
||||
let event: FileOperationEvent;
|
||||
const toDispose = service.onAfterOperation(e => {
|
||||
event = e;
|
||||
});
|
||||
|
||||
service.resolveFile(uri.file(testDir)).done(parent => {
|
||||
return service.createFolder(uri.file(path.join(parent.resource.fsPath, 'newFolder'))).then(f => {
|
||||
const resource = uri.file(path.join(parent.resource.fsPath, 'newFolder'));
|
||||
|
||||
return service.createFolder(resource).then(f => {
|
||||
assert.equal(f.name, 'newFolder');
|
||||
assert.equal(fs.existsSync(f.resource.fsPath), true);
|
||||
|
||||
assert.ok(event);
|
||||
assert.equal(event.resource.fsPath, resource.fsPath);
|
||||
assert.equal(event.operation, FileOperation.CREATE);
|
||||
assert.equal(event.target.resource.fsPath, resource.fsPath);
|
||||
assert.equal(event.target.isDirectory, true);
|
||||
toDispose.dispose();
|
||||
|
||||
done();
|
||||
});
|
||||
}, error => onError(error, done));
|
||||
@@ -106,77 +129,171 @@ suite('FileService', () => {
|
||||
});
|
||||
|
||||
test('renameFile', function (done: () => void) {
|
||||
service.resolveFile(uri.file(path.join(testDir, 'index.html'))).done(source => {
|
||||
let event: FileOperationEvent;
|
||||
const toDispose = service.onAfterOperation(e => {
|
||||
event = e;
|
||||
});
|
||||
|
||||
const resource = uri.file(path.join(testDir, 'index.html'));
|
||||
service.resolveFile(resource).done(source => {
|
||||
return service.rename(source.resource, 'other.html').then(renamed => {
|
||||
assert.equal(fs.existsSync(renamed.resource.fsPath), true);
|
||||
assert.equal(fs.existsSync(source.resource.fsPath), false);
|
||||
|
||||
assert.ok(event);
|
||||
assert.equal(event.resource.fsPath, resource.fsPath);
|
||||
assert.equal(event.operation, FileOperation.MOVE);
|
||||
assert.equal(event.target.resource.fsPath, renamed.resource.fsPath);
|
||||
toDispose.dispose();
|
||||
|
||||
done();
|
||||
});
|
||||
}, error => onError(error, done));
|
||||
});
|
||||
|
||||
test('renameFolder', function (done: () => void) {
|
||||
service.resolveFile(uri.file(path.join(testDir, 'deep'))).done(source => {
|
||||
let event: FileOperationEvent;
|
||||
const toDispose = service.onAfterOperation(e => {
|
||||
event = e;
|
||||
});
|
||||
|
||||
const resource = uri.file(path.join(testDir, 'deep'));
|
||||
service.resolveFile(resource).done(source => {
|
||||
return service.rename(source.resource, 'deeper').then(renamed => {
|
||||
assert.equal(fs.existsSync(renamed.resource.fsPath), true);
|
||||
assert.equal(fs.existsSync(source.resource.fsPath), false);
|
||||
|
||||
assert.ok(event);
|
||||
assert.equal(event.resource.fsPath, resource.fsPath);
|
||||
assert.equal(event.operation, FileOperation.MOVE);
|
||||
assert.equal(event.target.resource.fsPath, renamed.resource.fsPath);
|
||||
toDispose.dispose();
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('renameFile - MIX CASE', function (done: () => void) {
|
||||
service.resolveFile(uri.file(path.join(testDir, 'index.html'))).done(source => {
|
||||
let event: FileOperationEvent;
|
||||
const toDispose = service.onAfterOperation(e => {
|
||||
event = e;
|
||||
});
|
||||
|
||||
const resource = uri.file(path.join(testDir, 'index.html'));
|
||||
service.resolveFile(resource).done(source => {
|
||||
return service.rename(source.resource, 'INDEX.html').then(renamed => {
|
||||
assert.equal(fs.existsSync(renamed.resource.fsPath), true);
|
||||
assert.equal(path.basename(renamed.resource.fsPath), 'INDEX.html');
|
||||
|
||||
assert.ok(event);
|
||||
assert.equal(event.resource.fsPath, resource.fsPath);
|
||||
assert.equal(event.operation, FileOperation.MOVE);
|
||||
assert.equal(event.target.resource.fsPath, renamed.resource.fsPath);
|
||||
toDispose.dispose();
|
||||
|
||||
done();
|
||||
});
|
||||
}, error => onError(error, done));
|
||||
});
|
||||
|
||||
test('moveFile', function (done: () => void) {
|
||||
service.resolveFile(uri.file(path.join(testDir, 'index.html'))).done(source => {
|
||||
let event: FileOperationEvent;
|
||||
const toDispose = service.onAfterOperation(e => {
|
||||
event = e;
|
||||
});
|
||||
|
||||
const resource = uri.file(path.join(testDir, 'index.html'));
|
||||
service.resolveFile(resource).done(source => {
|
||||
return service.moveFile(source.resource, uri.file(path.join(testDir, 'other.html'))).then(renamed => {
|
||||
assert.equal(fs.existsSync(renamed.resource.fsPath), true);
|
||||
assert.equal(fs.existsSync(source.resource.fsPath), false);
|
||||
|
||||
assert.ok(event);
|
||||
assert.equal(event.resource.fsPath, resource.fsPath);
|
||||
assert.equal(event.operation, FileOperation.MOVE);
|
||||
assert.equal(event.target.resource.fsPath, renamed.resource.fsPath);
|
||||
toDispose.dispose();
|
||||
|
||||
done();
|
||||
});
|
||||
}, error => onError(error, done));
|
||||
});
|
||||
|
||||
test('move - FILE_MOVE_CONFLICT', function (done: () => void) {
|
||||
let event: FileOperationEvent;
|
||||
const toDispose = service.onAfterOperation(e => {
|
||||
event = e;
|
||||
});
|
||||
|
||||
service.resolveFile(uri.file(path.join(testDir, 'index.html'))).done(source => {
|
||||
return service.moveFile(source.resource, uri.file(path.join(testDir, 'binary.txt'))).then(null, (e: IFileOperationResult) => {
|
||||
assert.equal(e.fileOperationResult, FileOperationResult.FILE_MOVE_CONFLICT);
|
||||
|
||||
assert.ok(!event);
|
||||
toDispose.dispose();
|
||||
|
||||
done();
|
||||
});
|
||||
}, error => onError(error, done));
|
||||
});
|
||||
|
||||
test('moveFile - MIX CASE', function (done: () => void) {
|
||||
service.resolveFile(uri.file(path.join(testDir, 'index.html'))).done(source => {
|
||||
let event: FileOperationEvent;
|
||||
const toDispose = service.onAfterOperation(e => {
|
||||
event = e;
|
||||
});
|
||||
|
||||
const resource = uri.file(path.join(testDir, 'index.html'));
|
||||
service.resolveFile(resource).done(source => {
|
||||
return service.moveFile(source.resource, uri.file(path.join(testDir, 'INDEX.html'))).then(renamed => {
|
||||
assert.equal(fs.existsSync(renamed.resource.fsPath), true);
|
||||
assert.equal(path.basename(renamed.resource.fsPath), 'INDEX.html');
|
||||
|
||||
assert.ok(event);
|
||||
assert.equal(event.resource.fsPath, resource.fsPath);
|
||||
assert.equal(event.operation, FileOperation.MOVE);
|
||||
assert.equal(event.target.resource.fsPath, renamed.resource.fsPath);
|
||||
toDispose.dispose();
|
||||
|
||||
done();
|
||||
});
|
||||
}, error => onError(error, done));
|
||||
});
|
||||
|
||||
test('moveFile - overwrite folder with file', function (done: () => void) {
|
||||
let createEvent: FileOperationEvent;
|
||||
let moveEvent: FileOperationEvent;
|
||||
let deleteEvent: FileOperationEvent;
|
||||
const toDispose = service.onAfterOperation(e => {
|
||||
if (e.operation === FileOperation.CREATE) {
|
||||
createEvent = e;
|
||||
} else if (e.operation === FileOperation.DELETE) {
|
||||
deleteEvent = e;
|
||||
} else if (e.operation === FileOperation.MOVE) {
|
||||
moveEvent = e;
|
||||
}
|
||||
});
|
||||
|
||||
service.resolveFile(uri.file(testDir)).done(parent => {
|
||||
return service.createFolder(uri.file(path.join(parent.resource.fsPath, 'conway.js'))).then(f => {
|
||||
return service.moveFile(uri.file(path.join(testDir, 'deep', 'conway.js')), f.resource, true).then(moved => {
|
||||
const folderResource = uri.file(path.join(parent.resource.fsPath, 'conway.js'));
|
||||
return service.createFolder(folderResource).then(f => {
|
||||
const resource = uri.file(path.join(testDir, 'deep', 'conway.js'));
|
||||
return service.moveFile(resource, f.resource, true).then(moved => {
|
||||
assert.equal(fs.existsSync(moved.resource.fsPath), true);
|
||||
assert.ok(fs.statSync(moved.resource.fsPath).isFile);
|
||||
|
||||
assert.ok(createEvent);
|
||||
assert.ok(deleteEvent);
|
||||
assert.ok(moveEvent);
|
||||
|
||||
assert.equal(moveEvent.resource.fsPath, resource.fsPath);
|
||||
assert.equal(moveEvent.target.resource.fsPath, moved.resource.fsPath);
|
||||
|
||||
assert.equal(deleteEvent.resource.fsPath, folderResource.fsPath);
|
||||
|
||||
toDispose.dispose();
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -184,23 +301,61 @@ suite('FileService', () => {
|
||||
});
|
||||
|
||||
test('copyFile', function (done: () => void) {
|
||||
let event: FileOperationEvent;
|
||||
const toDispose = service.onAfterOperation(e => {
|
||||
event = e;
|
||||
});
|
||||
|
||||
service.resolveFile(uri.file(path.join(testDir, 'index.html'))).done(source => {
|
||||
return service.copyFile(source.resource, uri.file(path.join(testDir, 'other.html'))).then(renamed => {
|
||||
assert.equal(fs.existsSync(renamed.resource.fsPath), true);
|
||||
const resource = uri.file(path.join(testDir, 'other.html'));
|
||||
return service.copyFile(source.resource, resource).then(copied => {
|
||||
assert.equal(fs.existsSync(copied.resource.fsPath), true);
|
||||
assert.equal(fs.existsSync(source.resource.fsPath), true);
|
||||
|
||||
assert.ok(event);
|
||||
assert.equal(event.resource.fsPath, source.resource.fsPath);
|
||||
assert.equal(event.operation, FileOperation.COPY);
|
||||
assert.equal(event.target.resource.fsPath, copied.resource.fsPath);
|
||||
toDispose.dispose();
|
||||
|
||||
done();
|
||||
});
|
||||
}, error => onError(error, done));
|
||||
});
|
||||
|
||||
test('copyFile - overwrite folder with file', function (done: () => void) {
|
||||
let createEvent: FileOperationEvent;
|
||||
let copyEvent: FileOperationEvent;
|
||||
let deleteEvent: FileOperationEvent;
|
||||
const toDispose = service.onAfterOperation(e => {
|
||||
if (e.operation === FileOperation.CREATE) {
|
||||
createEvent = e;
|
||||
} else if (e.operation === FileOperation.DELETE) {
|
||||
deleteEvent = e;
|
||||
} else if (e.operation === FileOperation.COPY) {
|
||||
copyEvent = e;
|
||||
}
|
||||
});
|
||||
|
||||
service.resolveFile(uri.file(testDir)).done(parent => {
|
||||
return service.createFolder(uri.file(path.join(parent.resource.fsPath, 'conway.js'))).then(f => {
|
||||
return service.copyFile(uri.file(path.join(testDir, 'deep', 'conway.js')), f.resource, true).then(copied => {
|
||||
const folderResource = uri.file(path.join(parent.resource.fsPath, 'conway.js'));
|
||||
return service.createFolder(folderResource).then(f => {
|
||||
const resource = uri.file(path.join(testDir, 'deep', 'conway.js'));
|
||||
return service.copyFile(resource, f.resource, true).then(copied => {
|
||||
assert.equal(fs.existsSync(copied.resource.fsPath), true);
|
||||
assert.ok(fs.statSync(copied.resource.fsPath).isFile);
|
||||
|
||||
assert.ok(createEvent);
|
||||
assert.ok(deleteEvent);
|
||||
assert.ok(copyEvent);
|
||||
|
||||
assert.equal(copyEvent.resource.fsPath, resource.fsPath);
|
||||
assert.equal(copyEvent.target.resource.fsPath, copied.resource.fsPath);
|
||||
|
||||
assert.equal(deleteEvent.resource.fsPath, folderResource.fsPath);
|
||||
|
||||
toDispose.dispose();
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -208,11 +363,23 @@ suite('FileService', () => {
|
||||
});
|
||||
|
||||
test('importFile', function (done: () => void) {
|
||||
let event: FileOperationEvent;
|
||||
const toDispose = service.onAfterOperation(e => {
|
||||
event = e;
|
||||
});
|
||||
|
||||
service.resolveFile(uri.file(path.join(testDir, 'deep'))).done(target => {
|
||||
return service.importFile(uri.file(require.toUrl('./fixtures/service/index.html')), target.resource).then(res => {
|
||||
const resource = uri.file(require.toUrl('./fixtures/service/index.html'));
|
||||
return service.importFile(resource, target.resource).then(res => {
|
||||
assert.equal(res.isNew, true);
|
||||
assert.equal(fs.existsSync(res.stat.resource.fsPath), true);
|
||||
|
||||
assert.ok(event);
|
||||
assert.equal(event.resource.fsPath, resource.fsPath);
|
||||
assert.equal(event.operation, FileOperation.IMPORT);
|
||||
assert.equal(event.target.resource.fsPath, res.stat.resource.fsPath);
|
||||
toDispose.dispose();
|
||||
|
||||
done();
|
||||
});
|
||||
}, error => onError(error, done));
|
||||
@@ -237,13 +404,39 @@ suite('FileService', () => {
|
||||
});
|
||||
|
||||
test('importFile - overwrite folder with file', function (done: () => void) {
|
||||
let createEvent: FileOperationEvent;
|
||||
let importEvent: FileOperationEvent;
|
||||
let deleteEvent: FileOperationEvent;
|
||||
const toDispose = service.onAfterOperation(e => {
|
||||
if (e.operation === FileOperation.CREATE) {
|
||||
createEvent = e;
|
||||
} else if (e.operation === FileOperation.DELETE) {
|
||||
deleteEvent = e;
|
||||
} else if (e.operation === FileOperation.IMPORT) {
|
||||
importEvent = e;
|
||||
}
|
||||
});
|
||||
|
||||
service.resolveFile(uri.file(testDir)).done(parent => {
|
||||
return service.createFolder(uri.file(path.join(parent.resource.fsPath, 'conway.js'))).then(f => {
|
||||
return service.importFile(uri.file(path.join(testDir, 'deep', 'conway.js')), uri.file(testDir)).then(res => {
|
||||
const folderResource = uri.file(path.join(parent.resource.fsPath, 'conway.js'));
|
||||
return service.createFolder(folderResource).then(f => {
|
||||
const resource = uri.file(path.join(testDir, 'deep', 'conway.js'));
|
||||
return service.importFile(resource, uri.file(testDir)).then(res => {
|
||||
assert.equal(fs.existsSync(res.stat.resource.fsPath), true);
|
||||
assert.ok(fs.readdirSync(testDir).some(f => f === 'conway.js'));
|
||||
assert.ok(fs.statSync(res.stat.resource.fsPath).isFile);
|
||||
|
||||
assert.ok(createEvent);
|
||||
assert.ok(deleteEvent);
|
||||
assert.ok(importEvent);
|
||||
|
||||
assert.equal(importEvent.resource.fsPath, resource.fsPath);
|
||||
assert.equal(importEvent.target.resource.fsPath, res.stat.resource.fsPath);
|
||||
|
||||
assert.equal(deleteEvent.resource.fsPath, folderResource.fsPath);
|
||||
|
||||
toDispose.dispose();
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -261,20 +454,42 @@ suite('FileService', () => {
|
||||
});
|
||||
|
||||
test('deleteFile', function (done: () => void) {
|
||||
service.resolveFile(uri.file(path.join(testDir, 'deep', 'conway.js'))).done(source => {
|
||||
let event: FileOperationEvent;
|
||||
const toDispose = service.onAfterOperation(e => {
|
||||
event = e;
|
||||
});
|
||||
|
||||
const resource = uri.file(path.join(testDir, 'deep', 'conway.js'));
|
||||
service.resolveFile(resource).done(source => {
|
||||
return service.del(source.resource).then(() => {
|
||||
assert.equal(fs.existsSync(source.resource.fsPath), false);
|
||||
|
||||
assert.ok(event);
|
||||
assert.equal(event.resource.fsPath, resource.fsPath);
|
||||
assert.equal(event.operation, FileOperation.DELETE);
|
||||
toDispose.dispose();
|
||||
|
||||
done();
|
||||
});
|
||||
}, error => onError(error, done));
|
||||
});
|
||||
|
||||
test('deleteFolder', function (done: () => void) {
|
||||
service.resolveFile(uri.file(path.join(testDir, 'deep'))).done(source => {
|
||||
let event: FileOperationEvent;
|
||||
const toDispose = service.onAfterOperation(e => {
|
||||
event = e;
|
||||
});
|
||||
|
||||
const resource = uri.file(path.join(testDir, 'deep'));
|
||||
service.resolveFile(resource).done(source => {
|
||||
return service.del(source.resource).then(() => {
|
||||
assert.equal(fs.existsSync(source.resource.fsPath), false);
|
||||
|
||||
assert.ok(event);
|
||||
assert.equal(event.resource.fsPath, resource.fsPath);
|
||||
assert.equal(event.operation, FileOperation.DELETE);
|
||||
toDispose.dispose();
|
||||
|
||||
done();
|
||||
});
|
||||
}, error => onError(error, done));
|
||||
@@ -469,7 +684,7 @@ suite('FileService', () => {
|
||||
|
||||
service.watchFileChanges(toWatch);
|
||||
|
||||
events.addListener2(EventType.FILE_CHANGES, (e: FileChangesEvent) => {
|
||||
service.onFileChanges((e: FileChangesEvent) => {
|
||||
assert.ok(e);
|
||||
|
||||
service.unwatchFileChanges(toWatch);
|
||||
@@ -486,7 +701,7 @@ suite('FileService', () => {
|
||||
|
||||
service.watchFileChanges(toWatch);
|
||||
|
||||
events.addListener2(EventType.FILE_CHANGES, (e: FileChangesEvent) => {
|
||||
service.onFileChanges((e: FileChangesEvent) => {
|
||||
assert.ok(e);
|
||||
|
||||
service.unwatchFileChanges(toWatch);
|
||||
@@ -521,7 +736,7 @@ suite('FileService', () => {
|
||||
encoding: 'windows1252',
|
||||
encodingOverride: encodingOverride,
|
||||
disableWatcher: true
|
||||
}, null);
|
||||
});
|
||||
|
||||
_service.resolveContent(uri.file(path.join(testDir, 'index.html'))).done(c => {
|
||||
assert.equal(c.encoding, 'windows1252');
|
||||
@@ -547,7 +762,7 @@ suite('FileService', () => {
|
||||
|
||||
let _service = new FileService(_testDir, {
|
||||
disableWatcher: true
|
||||
}, null);
|
||||
});
|
||||
|
||||
extfs.copy(_sourceDir, _testDir, () => {
|
||||
fs.readFile(resource.fsPath, (error, data) => {
|
||||
|
||||
@@ -6,11 +6,6 @@
|
||||
'use strict';
|
||||
|
||||
import { IFileStat } from 'vs/platform/files/common/files';
|
||||
import { EventEmitter } from 'vs/base/common/eventEmitter';
|
||||
|
||||
export class TestEventService extends EventEmitter {
|
||||
_serviceBrand: any;
|
||||
}
|
||||
|
||||
export function getByName(root: IFileStat, name: string): IFileStat {
|
||||
for (let i = 0; i < root.children.length; i++) {
|
||||
|
||||
@@ -8,17 +8,20 @@
|
||||
import assert = require('assert');
|
||||
|
||||
import platform = require('vs/base/common/platform');
|
||||
import { FileChangeType, EventType, FileChangesEvent } from 'vs/platform/files/common/files';
|
||||
import { FileChangeType, FileChangesEvent } from 'vs/platform/files/common/files';
|
||||
import uri from 'vs/base/common/uri';
|
||||
import utils = require('vs/workbench/services/files/test/node/utils');
|
||||
import { IRawFileChange, toFileChangesEvent, normalize } from 'vs/workbench/services/files/node/watcher/common';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
|
||||
class TestFileWatcher {
|
||||
private eventEmitter: IEventService;
|
||||
private _onFileChanges: Emitter<FileChangesEvent>;
|
||||
|
||||
constructor(events: IEventService) {
|
||||
this.eventEmitter = events;
|
||||
constructor() {
|
||||
this._onFileChanges = new Emitter<FileChangesEvent>();
|
||||
}
|
||||
|
||||
public get onFileChanges(): Event<FileChangesEvent> {
|
||||
return this._onFileChanges.event;
|
||||
}
|
||||
|
||||
public report(changes: IRawFileChange[]): void {
|
||||
@@ -32,7 +35,7 @@ class TestFileWatcher {
|
||||
|
||||
// Emit through broadcast service
|
||||
if (normalizedEvents.length > 0) {
|
||||
this.eventEmitter.emit(EventType.FILE_CHANGES, toFileChangesEvent(normalizedEvents));
|
||||
this._onFileChanges.fire(toFileChangesEvent(normalizedEvents));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,20 +49,19 @@ enum Path {
|
||||
suite('Watcher', () => {
|
||||
|
||||
test('watching - simple add/update/delete', function (done: () => void) {
|
||||
var events = new utils.TestEventService();
|
||||
var watch = new TestFileWatcher(events);
|
||||
const watch = new TestFileWatcher();
|
||||
|
||||
var added = uri.file('/users/data/src/added.txt');
|
||||
var updated = uri.file('/users/data/src/updated.txt');
|
||||
var deleted = uri.file('/users/data/src/deleted.txt');
|
||||
const added = uri.file('/users/data/src/added.txt');
|
||||
const updated = uri.file('/users/data/src/updated.txt');
|
||||
const deleted = uri.file('/users/data/src/deleted.txt');
|
||||
|
||||
var raw: IRawFileChange[] = [
|
||||
const raw: IRawFileChange[] = [
|
||||
{ path: added.fsPath, type: FileChangeType.ADDED },
|
||||
{ path: updated.fsPath, type: FileChangeType.UPDATED },
|
||||
{ path: deleted.fsPath, type: FileChangeType.DELETED },
|
||||
];
|
||||
|
||||
events.addListener2(EventType.FILE_CHANGES, (e: FileChangesEvent) => {
|
||||
watch.onFileChanges(e => {
|
||||
assert.ok(e);
|
||||
assert.equal(e.changes.length, 3);
|
||||
assert.ok(e.contains(added, FileChangeType.ADDED));
|
||||
@@ -75,20 +77,19 @@ suite('Watcher', () => {
|
||||
let pathSpecs = platform.isWindows ? [Path.WINDOWS, Path.UNC] : [Path.UNIX];
|
||||
pathSpecs.forEach((p) => {
|
||||
test('watching - delete only reported for top level folder (' + p + ')', function (done: () => void) {
|
||||
var events = new utils.TestEventService();
|
||||
var watch = new TestFileWatcher(events);
|
||||
const watch = new TestFileWatcher();
|
||||
|
||||
var deletedFolderA = uri.file(p === Path.UNIX ? '/users/data/src/todelete1' : p === Path.WINDOWS ? 'C:\\users\\data\\src\\todelete1' : '\\\\localhost\\users\\data\\src\\todelete1');
|
||||
var deletedFolderB = uri.file(p === Path.UNIX ? '/users/data/src/todelete2' : p === Path.WINDOWS ? 'C:\\users\\data\\src\\todelete2' : '\\\\localhost\\users\\data\\src\\todelete2');
|
||||
var deletedFolderBF1 = uri.file(p === Path.UNIX ? '/users/data/src/todelete2/file.txt' : p === Path.WINDOWS ? 'C:\\users\\data\\src\\todelete2\\file.txt' : '\\\\localhost\\users\\data\\src\\todelete2\\file.txt');
|
||||
var deletedFolderBF2 = uri.file(p === Path.UNIX ? '/users/data/src/todelete2/more/test.txt' : p === Path.WINDOWS ? 'C:\\users\\data\\src\\todelete2\\more\\test.txt' : '\\\\localhost\\users\\data\\src\\todelete2\\more\\test.txt');
|
||||
var deletedFolderBF3 = uri.file(p === Path.UNIX ? '/users/data/src/todelete2/super/bar/foo.txt' : p === Path.WINDOWS ? 'C:\\users\\data\\src\\todelete2\\super\\bar\\foo.txt' : '\\\\localhost\\users\\data\\src\\todelete2\\super\\bar\\foo.txt');
|
||||
var deletedFileA = uri.file(p === Path.UNIX ? '/users/data/src/deleteme.txt' : p === Path.WINDOWS ? 'C:\\users\\data\\src\\deleteme.txt' : '\\\\localhost\\users\\data\\src\\deleteme.txt');
|
||||
const deletedFolderA = uri.file(p === Path.UNIX ? '/users/data/src/todelete1' : p === Path.WINDOWS ? 'C:\\users\\data\\src\\todelete1' : '\\\\localhost\\users\\data\\src\\todelete1');
|
||||
const deletedFolderB = uri.file(p === Path.UNIX ? '/users/data/src/todelete2' : p === Path.WINDOWS ? 'C:\\users\\data\\src\\todelete2' : '\\\\localhost\\users\\data\\src\\todelete2');
|
||||
const deletedFolderBF1 = uri.file(p === Path.UNIX ? '/users/data/src/todelete2/file.txt' : p === Path.WINDOWS ? 'C:\\users\\data\\src\\todelete2\\file.txt' : '\\\\localhost\\users\\data\\src\\todelete2\\file.txt');
|
||||
const deletedFolderBF2 = uri.file(p === Path.UNIX ? '/users/data/src/todelete2/more/test.txt' : p === Path.WINDOWS ? 'C:\\users\\data\\src\\todelete2\\more\\test.txt' : '\\\\localhost\\users\\data\\src\\todelete2\\more\\test.txt');
|
||||
const deletedFolderBF3 = uri.file(p === Path.UNIX ? '/users/data/src/todelete2/super/bar/foo.txt' : p === Path.WINDOWS ? 'C:\\users\\data\\src\\todelete2\\super\\bar\\foo.txt' : '\\\\localhost\\users\\data\\src\\todelete2\\super\\bar\\foo.txt');
|
||||
const deletedFileA = uri.file(p === Path.UNIX ? '/users/data/src/deleteme.txt' : p === Path.WINDOWS ? 'C:\\users\\data\\src\\deleteme.txt' : '\\\\localhost\\users\\data\\src\\deleteme.txt');
|
||||
|
||||
var addedFile = uri.file(p === Path.UNIX ? '/users/data/src/added.txt' : p === Path.WINDOWS ? 'C:\\users\\data\\src\\added.txt' : '\\\\localhost\\users\\data\\src\\added.txt');
|
||||
var updatedFile = uri.file(p === Path.UNIX ? '/users/data/src/updated.txt' : p === Path.WINDOWS ? 'C:\\users\\data\\src\\updated.txt' : '\\\\localhost\\users\\data\\src\\updated.txt');
|
||||
const addedFile = uri.file(p === Path.UNIX ? '/users/data/src/added.txt' : p === Path.WINDOWS ? 'C:\\users\\data\\src\\added.txt' : '\\\\localhost\\users\\data\\src\\added.txt');
|
||||
const updatedFile = uri.file(p === Path.UNIX ? '/users/data/src/updated.txt' : p === Path.WINDOWS ? 'C:\\users\\data\\src\\updated.txt' : '\\\\localhost\\users\\data\\src\\updated.txt');
|
||||
|
||||
var raw: IRawFileChange[] = [
|
||||
const raw: IRawFileChange[] = [
|
||||
{ path: deletedFolderA.fsPath, type: FileChangeType.DELETED },
|
||||
{ path: deletedFolderB.fsPath, type: FileChangeType.DELETED },
|
||||
{ path: deletedFolderBF1.fsPath, type: FileChangeType.DELETED },
|
||||
@@ -99,7 +100,7 @@ suite('Watcher', () => {
|
||||
{ path: updatedFile.fsPath, type: FileChangeType.UPDATED }
|
||||
];
|
||||
|
||||
events.addListener2(EventType.FILE_CHANGES, (e: FileChangesEvent) => {
|
||||
watch.onFileChanges(e => {
|
||||
assert.ok(e);
|
||||
assert.equal(e.changes.length, 5);
|
||||
|
||||
@@ -117,20 +118,19 @@ suite('Watcher', () => {
|
||||
});
|
||||
|
||||
test('watching - event normalization: ignore CREATE followed by DELETE', function (done: () => void) {
|
||||
var events = new utils.TestEventService();
|
||||
var watch = new TestFileWatcher(events);
|
||||
const watch = new TestFileWatcher();
|
||||
|
||||
var created = uri.file('/users/data/src/related');
|
||||
var deleted = uri.file('/users/data/src/related');
|
||||
var unrelated = uri.file('/users/data/src/unrelated');
|
||||
const created = uri.file('/users/data/src/related');
|
||||
const deleted = uri.file('/users/data/src/related');
|
||||
const unrelated = uri.file('/users/data/src/unrelated');
|
||||
|
||||
var raw: IRawFileChange[] = [
|
||||
const raw: IRawFileChange[] = [
|
||||
{ path: created.fsPath, type: FileChangeType.ADDED },
|
||||
{ path: deleted.fsPath, type: FileChangeType.DELETED },
|
||||
{ path: unrelated.fsPath, type: FileChangeType.UPDATED },
|
||||
];
|
||||
|
||||
events.addListener2(EventType.FILE_CHANGES, (e: FileChangesEvent) => {
|
||||
watch.onFileChanges(e => {
|
||||
assert.ok(e);
|
||||
assert.equal(e.changes.length, 1);
|
||||
|
||||
@@ -143,20 +143,19 @@ suite('Watcher', () => {
|
||||
});
|
||||
|
||||
test('watching - event normalization: flatten DELETE followed by CREATE into CHANGE', function (done: () => void) {
|
||||
var events = new utils.TestEventService();
|
||||
var watch = new TestFileWatcher(events);
|
||||
const watch = new TestFileWatcher();
|
||||
|
||||
var deleted = uri.file('/users/data/src/related');
|
||||
var created = uri.file('/users/data/src/related');
|
||||
var unrelated = uri.file('/users/data/src/unrelated');
|
||||
const deleted = uri.file('/users/data/src/related');
|
||||
const created = uri.file('/users/data/src/related');
|
||||
const unrelated = uri.file('/users/data/src/unrelated');
|
||||
|
||||
var raw: IRawFileChange[] = [
|
||||
const raw: IRawFileChange[] = [
|
||||
{ path: deleted.fsPath, type: FileChangeType.DELETED },
|
||||
{ path: created.fsPath, type: FileChangeType.ADDED },
|
||||
{ path: unrelated.fsPath, type: FileChangeType.UPDATED },
|
||||
];
|
||||
|
||||
events.addListener2(EventType.FILE_CHANGES, (e: FileChangesEvent) => {
|
||||
watch.onFileChanges(e => {
|
||||
assert.ok(e);
|
||||
assert.equal(e.changes.length, 2);
|
||||
|
||||
@@ -170,20 +169,19 @@ suite('Watcher', () => {
|
||||
});
|
||||
|
||||
test('watching - event normalization: ignore UPDATE when CREATE received', function (done: () => void) {
|
||||
var events = new utils.TestEventService();
|
||||
var watch = new TestFileWatcher(events);
|
||||
const watch = new TestFileWatcher();
|
||||
|
||||
var created = uri.file('/users/data/src/related');
|
||||
var updated = uri.file('/users/data/src/related');
|
||||
var unrelated = uri.file('/users/data/src/unrelated');
|
||||
const created = uri.file('/users/data/src/related');
|
||||
const updated = uri.file('/users/data/src/related');
|
||||
const unrelated = uri.file('/users/data/src/unrelated');
|
||||
|
||||
var raw: IRawFileChange[] = [
|
||||
const raw: IRawFileChange[] = [
|
||||
{ path: created.fsPath, type: FileChangeType.ADDED },
|
||||
{ path: updated.fsPath, type: FileChangeType.UPDATED },
|
||||
{ path: unrelated.fsPath, type: FileChangeType.UPDATED },
|
||||
];
|
||||
|
||||
events.addListener2(EventType.FILE_CHANGES, (e: FileChangesEvent) => {
|
||||
watch.onFileChanges(e => {
|
||||
assert.ok(e);
|
||||
assert.equal(e.changes.length, 2);
|
||||
|
||||
@@ -198,22 +196,21 @@ suite('Watcher', () => {
|
||||
});
|
||||
|
||||
test('watching - event normalization: apply DELETE', function (done: () => void) {
|
||||
var events = new utils.TestEventService();
|
||||
var watch = new TestFileWatcher(events);
|
||||
const watch = new TestFileWatcher();
|
||||
|
||||
var updated = uri.file('/users/data/src/related');
|
||||
var updated2 = uri.file('/users/data/src/related');
|
||||
var deleted = uri.file('/users/data/src/related');
|
||||
var unrelated = uri.file('/users/data/src/unrelated');
|
||||
const updated = uri.file('/users/data/src/related');
|
||||
const updated2 = uri.file('/users/data/src/related');
|
||||
const deleted = uri.file('/users/data/src/related');
|
||||
const unrelated = uri.file('/users/data/src/unrelated');
|
||||
|
||||
var raw: IRawFileChange[] = [
|
||||
const raw: IRawFileChange[] = [
|
||||
{ path: updated.fsPath, type: FileChangeType.UPDATED },
|
||||
{ path: updated2.fsPath, type: FileChangeType.UPDATED },
|
||||
{ path: unrelated.fsPath, type: FileChangeType.UPDATED },
|
||||
{ path: updated.fsPath, type: FileChangeType.DELETED }
|
||||
];
|
||||
|
||||
events.addListener2(EventType.FILE_CHANGES, (e: FileChangesEvent) => {
|
||||
watch.onFileChanges(e => {
|
||||
assert.ok(e);
|
||||
assert.equal(e.changes.length, 2);
|
||||
|
||||
|
||||
@@ -15,9 +15,8 @@ import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { IEditor as IBaseEditor, IEditorInput, ITextEditorOptions, IResourceInput } from 'vs/platform/editor/common/editor';
|
||||
import { EditorInput, IGroupEvent, IEditorRegistry, Extensions, asFileEditorInput, IEditorGroup } from 'vs/workbench/common/editor';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IHistoryService } from 'vs/workbench/services/history/common/history';
|
||||
import { FileChangesEvent, EventType, FileChangeType } from 'vs/platform/files/common/files';
|
||||
import { FileChangesEvent, IFileService, FileChangeType } from 'vs/platform/files/common/files';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
@@ -290,9 +289,9 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
|
||||
@IStorageService private storageService: IStorageService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@ILifecycleService private lifecycleService: ILifecycleService,
|
||||
@IEventService private eventService: IEventService,
|
||||
@IIntegrityService integrityService: IIntegrityService,
|
||||
@ITitleService titleService: ITitleService,
|
||||
@IFileService private fileService: IFileService,
|
||||
@IWindowService private windowService: IWindowService
|
||||
) {
|
||||
super(editorGroupService, editorService, contextService, configurationService, environmentService, integrityService, titleService);
|
||||
@@ -312,7 +311,7 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
|
||||
this.toUnbind.push(this.editorGroupService.getStacksModel().onEditorClosed(event => this.onEditorClosed(event)));
|
||||
|
||||
// File changes
|
||||
this.toUnbind.push(this.eventService.addListener2(EventType.FILE_CHANGES, (e: FileChangesEvent) => this.onFileChanges(e)));
|
||||
this.toUnbind.push(this.fileService.onFileChanges(e => this.onFileChanges(e)));
|
||||
}
|
||||
|
||||
private onFileChanges(e: FileChangesEvent): void {
|
||||
|
||||
@@ -10,11 +10,10 @@ import URI from 'vs/base/common/uri';
|
||||
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
|
||||
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
|
||||
import { ModelState, ITextFileEditorModel, LocalFileChangeEvent, ITextFileEditorModelManager, TextFileModelChangeEvent, StateChange } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { ModelState, ITextFileEditorModel, ITextFileEditorModelManager, TextFileModelChangeEvent, StateChange } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { FileChangesEvent, EventType as CommonFileEventType } from 'vs/platform/files/common/files';
|
||||
import { FileOperation, FileOperationEvent, FileChangesEvent, IFileService } from 'vs/platform/files/common/files';
|
||||
|
||||
export class TextFileEditorModelManager implements ITextFileEditorModelManager {
|
||||
|
||||
@@ -45,9 +44,9 @@ export class TextFileEditorModelManager implements ITextFileEditorModelManager {
|
||||
|
||||
constructor(
|
||||
@ILifecycleService private lifecycleService: ILifecycleService,
|
||||
@IEventService private eventService: IEventService,
|
||||
@IInstantiationService private instantiationService: IInstantiationService,
|
||||
@IEditorGroupService private editorGroupService: IEditorGroupService
|
||||
@IEditorGroupService private editorGroupService: IEditorGroupService,
|
||||
@IFileService private fileService: IFileService
|
||||
) {
|
||||
this.toUnbind = [];
|
||||
|
||||
@@ -83,8 +82,8 @@ export class TextFileEditorModelManager implements ITextFileEditorModelManager {
|
||||
this.toUnbind.push(this.editorGroupService.getStacksModel().onEditorClosed(() => this.onEditorClosed()));
|
||||
|
||||
// File changes
|
||||
this.toUnbind.push(this.eventService.addListener2('files.internal:fileChanged', (e: LocalFileChangeEvent) => this.onLocalFileChange(e)));
|
||||
this.toUnbind.push(this.eventService.addListener2(CommonFileEventType.FILE_CHANGES, (e: FileChangesEvent) => this.onFileChanges(e)));
|
||||
this.toUnbind.push(this.fileService.onAfterOperation(e => this.onFileOperation(e)));
|
||||
this.toUnbind.push(this.fileService.onFileChanges(e => this.onFileChanges(e)));
|
||||
|
||||
// Lifecycle
|
||||
this.lifecycleService.onShutdown(this.dispose, this);
|
||||
@@ -105,9 +104,9 @@ export class TextFileEditorModelManager implements ITextFileEditorModelManager {
|
||||
}
|
||||
}
|
||||
|
||||
private onLocalFileChange(e: LocalFileChangeEvent): void {
|
||||
if (e.gotMoved() || e.gotDeleted()) {
|
||||
this.disposeModelIfPossible(e.getBefore().resource); // dispose models of moved or deleted files
|
||||
private onFileOperation(e: FileOperationEvent): void {
|
||||
if (e.operation === FileOperation.MOVE || e.operation === FileOperation.DELETE) {
|
||||
this.disposeModelIfPossible(e.resource); // dispose models of moved or deleted files
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,11 +10,9 @@ import Event from 'vs/base/common/event';
|
||||
import { IRawText } from 'vs/editor/common/editorCommon';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IEncodingSupport, ConfirmResult } from 'vs/workbench/common/editor';
|
||||
import { IFileStat, IBaseStat, IResolveContentOptions } from 'vs/platform/files/common/files';
|
||||
import { IBaseStat, IResolveContentOptions } from 'vs/platform/files/common/files';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ITextEditorModel } from 'vs/editor/common/services/resolverService';
|
||||
import { Event as BaseEvent, PropertyChangeEvent } from 'vs/base/common/events';
|
||||
|
||||
|
||||
/**
|
||||
* The save error handler can be installed on the text text file editor model to install code that executes when save errors occur.
|
||||
@@ -46,60 +44,6 @@ export enum ModelState {
|
||||
ERROR
|
||||
}
|
||||
|
||||
/**
|
||||
* Local file change events are being emitted when a file is added, removed, moved or its contents got updated. These events
|
||||
* are being emitted from within the workbench and are not reflecting the truth on the disk file system. For that, please
|
||||
* use FileChangesEvent instead.
|
||||
*/
|
||||
export class LocalFileChangeEvent extends PropertyChangeEvent {
|
||||
|
||||
constructor(before?: IFileStat, after?: IFileStat, originalEvent?: BaseEvent) {
|
||||
super(null, before, after, originalEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the meta information of the file before the event occurred or null if the file is new.
|
||||
*/
|
||||
public getBefore(): IFileStat {
|
||||
return this.oldValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the meta information of the file after the event occurred or null if the file got deleted.
|
||||
*/
|
||||
public getAfter(): IFileStat {
|
||||
return this.newValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the file was added as a new file.
|
||||
*/
|
||||
public gotAdded(): boolean {
|
||||
return !this.oldValue && !!this.newValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the file was moved to a different path.
|
||||
*/
|
||||
public gotMoved(): boolean {
|
||||
return !!this.oldValue && !!this.newValue && this.oldValue.resource.toString() !== this.newValue.resource.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the files metadata was updated.
|
||||
*/
|
||||
public gotUpdated(): boolean {
|
||||
return !!this.oldValue && !!this.newValue && !this.gotMoved() && this.oldValue !== this.newValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the file was deleted.
|
||||
*/
|
||||
public gotDeleted(): boolean {
|
||||
return !!this.oldValue && !this.newValue;
|
||||
}
|
||||
}
|
||||
|
||||
export enum StateChange {
|
||||
DIRTY,
|
||||
SAVING,
|
||||
|
||||
@@ -10,7 +10,6 @@ import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { EncodingMode } from 'vs/workbench/common/editor';
|
||||
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { ITextFileService, ModelState, StateChange } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { workbenchInstantiationService, TestTextFileService, createFileInput } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { onError, toResource } from 'vs/base/test/common/utils';
|
||||
@@ -19,7 +18,7 @@ import { FileOperationResult, IFileOperationResult } from 'vs/platform/files/com
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
|
||||
class ServiceAccessor {
|
||||
constructor( @IEventService public eventService: IEventService, @ITextFileService public textFileService: TestTextFileService, @IModelService public modelService: IModelService) {
|
||||
constructor( @ITextFileService public textFileService: TestTextFileService, @IModelService public modelService: IModelService) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,10 +95,6 @@ suite('Files - TextFileEditorModel', () => {
|
||||
const model = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/index.txt'), 'utf8');
|
||||
assert.equal(model.getState(), ModelState.SAVED);
|
||||
|
||||
accessor.eventService.addListener2('files:internalFileChanged', () => {
|
||||
assert.ok(false);
|
||||
});
|
||||
|
||||
model.onDidStateChange(e => {
|
||||
assert.ok(e !== StateChange.DIRTY && e !== StateChange.SAVED);
|
||||
});
|
||||
|
||||
@@ -11,13 +11,11 @@ import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { TextFileEditorModelManager } from 'vs/workbench/services/textfile/common/textFileEditorModelManager';
|
||||
import { join, basename } from 'vs/base/common/paths';
|
||||
import { workbenchInstantiationService, TestEditorGroupService, createFileInput } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { workbenchInstantiationService, TestEditorGroupService, createFileInput, TestFileService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { onError } from 'vs/base/test/common/utils';
|
||||
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
|
||||
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { LocalFileChangeEvent } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { FileChangesEvent, EventType as CommonFileEventType, FileChangeType } from 'vs/platform/files/common/files';
|
||||
import { FileOperation, FileOperationEvent, FileChangesEvent, FileChangeType, IFileService } from 'vs/platform/files/common/files';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
|
||||
export class TestTextFileEditorModelManager extends TextFileEditorModelManager {
|
||||
@@ -27,19 +25,6 @@ export class TestTextFileEditorModelManager extends TextFileEditorModelManager {
|
||||
}
|
||||
}
|
||||
|
||||
class ServiceAccessor {
|
||||
constructor(
|
||||
@IEditorGroupService public editorGroupService: TestEditorGroupService,
|
||||
@IEventService public eventService: IEventService,
|
||||
@IModelService public modelService: IModelService
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
function toResource(path: string): URI {
|
||||
return URI.file(join('C:\\', path));
|
||||
}
|
||||
|
||||
function toStat(resource: URI) {
|
||||
return {
|
||||
resource,
|
||||
@@ -51,6 +36,19 @@ function toStat(resource: URI) {
|
||||
};
|
||||
}
|
||||
|
||||
class ServiceAccessor {
|
||||
constructor(
|
||||
@IEditorGroupService public editorGroupService: TestEditorGroupService,
|
||||
@IFileService public fileService: TestFileService,
|
||||
@IModelService public modelService: IModelService
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
function toResource(path: string): URI {
|
||||
return URI.file(join('C:\\', path));
|
||||
}
|
||||
|
||||
suite('Files - TextFileEditorModelManager', () => {
|
||||
|
||||
let instantiationService: IInstantiationService;
|
||||
@@ -191,8 +189,8 @@ suite('Files - TextFileEditorModelManager', () => {
|
||||
|
||||
assert.ok(!model.isDisposed());
|
||||
|
||||
// delete event (local)
|
||||
accessor.eventService.emit('files.internal:fileChanged', new LocalFileChangeEvent(toStat(resource)));
|
||||
// delete operation
|
||||
accessor.fileService.fireAfterOperation(new FileOperationEvent(resource, FileOperation.DELETE));
|
||||
|
||||
assert.ok(model.isDisposed());
|
||||
|
||||
@@ -212,8 +210,8 @@ suite('Files - TextFileEditorModelManager', () => {
|
||||
|
||||
assert.ok(!model.isDisposed());
|
||||
|
||||
// move event (local)
|
||||
accessor.eventService.emit('files.internal:fileChanged', new LocalFileChangeEvent(toStat(resource), toStat(toResource('/path/index_moved.txt'))));
|
||||
// move operation
|
||||
accessor.fileService.fireAfterOperation(new FileOperationEvent(resource, FileOperation.MOVE, toStat(toResource('/path/index_moved.txt'))));
|
||||
|
||||
assert.ok(model.isDisposed());
|
||||
assert.ok(!accessor.modelService.getModel(model.getResource()));
|
||||
@@ -232,7 +230,7 @@ suite('Files - TextFileEditorModelManager', () => {
|
||||
assert.ok(!model.isDisposed());
|
||||
|
||||
// delete event (watcher)
|
||||
accessor.eventService.emit(CommonFileEventType.FILE_CHANGES, new FileChangesEvent([{ resource, type: FileChangeType.DELETED }]));
|
||||
accessor.fileService.fireFileChanges(new FileChangesEvent([{ resource, type: FileChangeType.DELETED }]));
|
||||
|
||||
assert.ok(model.isDisposed());
|
||||
assert.ok(!accessor.modelService.getModel(model.getResource()));
|
||||
@@ -251,7 +249,7 @@ suite('Files - TextFileEditorModelManager', () => {
|
||||
assert.ok(!model.isDisposed());
|
||||
|
||||
// change event (watcher)
|
||||
accessor.eventService.emit(CommonFileEventType.FILE_CHANGES, new FileChangesEvent([{ resource, type: FileChangeType.UPDATED }]));
|
||||
accessor.fileService.fireFileChanges(new FileChangesEvent([{ resource, type: FileChangeType.UPDATED }]));
|
||||
|
||||
assert.ok(model.isDisposed());
|
||||
assert.ok(!accessor.modelService.getModel(model.getResource()));
|
||||
@@ -274,7 +272,7 @@ suite('Files - TextFileEditorModelManager', () => {
|
||||
return model.save().then(() => {
|
||||
|
||||
// change event (watcher)
|
||||
accessor.eventService.emit(CommonFileEventType.FILE_CHANGES, new FileChangesEvent([{ resource, type: FileChangeType.UPDATED }]));
|
||||
accessor.fileService.fireFileChanges(new FileChangesEvent([{ resource, type: FileChangeType.UPDATED }]));
|
||||
|
||||
assert.ok(!model.isDisposed());
|
||||
|
||||
|
||||
@@ -13,12 +13,11 @@ import { workbenchInstantiationService, TestTextFileService } from 'vs/workbench
|
||||
import { toResource } from 'vs/base/test/common/utils';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { ITextFileService, SaveReason } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { TextFileEditorModelManager } from 'vs/workbench/services/textfile/common/textFileEditorModelManager';
|
||||
|
||||
class ServiceAccessor {
|
||||
constructor( @IEventService public eventService: IEventService, @ITextFileService public textFileService: TestTextFileService, @IModelService public modelService: IModelService) {
|
||||
constructor( @ITextFileService public textFileService: TestTextFileService, @IModelService public modelService: IModelService) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import { IPartService } from 'vs/workbench/services/part/common/partService';
|
||||
import { TextModelResolverService } from 'vs/workbench/services/textmodelResolver/common/textModelResolverService';
|
||||
import { ITextModelResolverService } from 'vs/editor/common/services/resolverService';
|
||||
import { IEditorInput, IEditorOptions, Position, Direction, IEditor, IResourceInput } from 'vs/platform/editor/common/editor';
|
||||
import { IEventService } from 'vs/platform/event/common/event';
|
||||
import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
|
||||
import { IMessageService, IConfirmation } from 'vs/platform/message/common/message';
|
||||
import { IWorkspace, IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
@@ -34,7 +33,7 @@ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceColle
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
import { IEditorGroupService, GroupArrangement, GroupOrientation } from 'vs/workbench/services/group/common/groupService';
|
||||
import { TextFileService } from 'vs/workbench/services/textfile/common/textFileService';
|
||||
import { IFileService, IResolveContentOptions, IFileOperationResult } from 'vs/platform/files/common/files';
|
||||
import { FileOperationEvent, IFileService, IResolveContentOptions, IFileOperationResult, IFileStat, IImportResult, FileChangesEvent, IResolveFileOptions, IContent, IUpdateContentOptions, IStreamContent } from 'vs/platform/files/common/files';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl';
|
||||
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
|
||||
@@ -166,7 +165,6 @@ export class TestTextFileService extends TextFileService {
|
||||
|
||||
export function workbenchInstantiationService(): IInstantiationService {
|
||||
let instantiationService = new TestInstantiationService(new ServiceCollection([ILifecycleService, new TestLifecycleService()]));
|
||||
instantiationService.stub(IEventService, new TestEventService());
|
||||
instantiationService.stub(IWorkspaceContextService, new TestContextService(TestWorkspace));
|
||||
instantiationService.stub(IConfigurationService, new TestConfigurationService());
|
||||
instantiationService.stub(IUntitledEditorService, instantiationService.createInstance(UntitledEditorService));
|
||||
@@ -178,7 +176,7 @@ export function workbenchInstantiationService(): IInstantiationService {
|
||||
instantiationService.stub(IHistoryService, {});
|
||||
instantiationService.stub(IHistoryService, 'getHistory', []);
|
||||
instantiationService.stub(IModelService, instantiationService.createInstance(ModelServiceImpl));
|
||||
instantiationService.stub(IFileService, TestFileService);
|
||||
instantiationService.stub(IFileService, new TestFileService());
|
||||
instantiationService.stub(IBackupFileService, new TestBackupFileService());
|
||||
instantiationService.stub(ITelemetryService, NullTelemetryService);
|
||||
instantiationService.stub(IMessageService, new TestMessageService());
|
||||
@@ -292,10 +290,6 @@ export class TestPartService implements IPartService {
|
||||
public toggleZenMode(): void { }
|
||||
}
|
||||
|
||||
export class TestEventService extends EventEmitter implements IEventService {
|
||||
public _serviceBrand: any;
|
||||
}
|
||||
|
||||
export class TestStorageService extends EventEmitter implements IStorageService {
|
||||
public _serviceBrand: any;
|
||||
|
||||
@@ -505,8 +499,51 @@ export class TestEditorService implements IWorkbenchEditorService {
|
||||
}
|
||||
}
|
||||
|
||||
export const TestFileService = {
|
||||
resolveContent: function (resource) {
|
||||
export class TestFileService implements IFileService {
|
||||
|
||||
public _serviceBrand: any;
|
||||
|
||||
private _onFileChanges: Emitter<FileChangesEvent>;
|
||||
private _onAfterOperation: Emitter<FileOperationEvent>;
|
||||
|
||||
constructor() {
|
||||
this._onFileChanges = new Emitter<FileChangesEvent>();
|
||||
this._onAfterOperation = new Emitter<FileOperationEvent>();
|
||||
}
|
||||
|
||||
public get onFileChanges(): Event<FileChangesEvent> {
|
||||
return this._onFileChanges.event;
|
||||
}
|
||||
|
||||
public fireFileChanges(event: FileChangesEvent): void {
|
||||
this._onFileChanges.fire(event);
|
||||
}
|
||||
|
||||
public get onAfterOperation(): Event<FileOperationEvent> {
|
||||
return this._onAfterOperation.event;
|
||||
}
|
||||
|
||||
public fireAfterOperation(event: FileOperationEvent): void {
|
||||
this._onAfterOperation.fire(event);
|
||||
}
|
||||
|
||||
resolveFile(resource: URI, options?: IResolveFileOptions): TPromise<IFileStat> {
|
||||
return TPromise.as({
|
||||
resource,
|
||||
etag: Date.now().toString(),
|
||||
encoding: 'utf8',
|
||||
mtime: Date.now(),
|
||||
isDirectory: false,
|
||||
hasChildren: false,
|
||||
name: paths.basename(resource.fsPath)
|
||||
});
|
||||
}
|
||||
|
||||
existsFile(resource: URI): TPromise<boolean> {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
resolveContent(resource: URI, options?: IResolveContentOptions): TPromise<IContent> {
|
||||
return TPromise.as({
|
||||
resource: resource,
|
||||
value: 'Hello Html',
|
||||
@@ -515,19 +552,9 @@ export const TestFileService = {
|
||||
mtime: Date.now(),
|
||||
name: paths.basename(resource.fsPath)
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
resolveFile: function (resource) {
|
||||
return TPromise.as({
|
||||
resource: resource,
|
||||
etag: Date.now(),
|
||||
encoding: 'utf8',
|
||||
mtime: Date.now(),
|
||||
name: paths.basename(resource.fsPath)
|
||||
});
|
||||
},
|
||||
|
||||
resolveStreamContent: function (resource) {
|
||||
resolveStreamContent(resource: URI, options?: IResolveContentOptions): TPromise<IStreamContent> {
|
||||
return TPromise.as({
|
||||
resource: resource,
|
||||
value: {
|
||||
@@ -545,32 +572,76 @@ export const TestFileService = {
|
||||
mtime: Date.now(),
|
||||
name: paths.basename(resource.fsPath)
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
updateContent: function (res) {
|
||||
resolveContents(resources: URI[]): TPromise<IContent[]> {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
updateContent(resource: URI, value: string, options?: IUpdateContentOptions): TPromise<IFileStat> {
|
||||
return TPromise.timeout(1).then(() => {
|
||||
return {
|
||||
resource: res,
|
||||
resource,
|
||||
etag: 'index.txt',
|
||||
encoding: 'utf8',
|
||||
mtime: Date.now(),
|
||||
name: paths.basename(res.fsPath)
|
||||
isDirectory: false,
|
||||
hasChildren: false,
|
||||
name: paths.basename(resource.fsPath)
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
backupFile: function (resource: URI, content: string) {
|
||||
return TPromise.as(void 0);
|
||||
},
|
||||
|
||||
discardBackup: function (resource: URI) {
|
||||
return TPromise.as(void 0);
|
||||
},
|
||||
|
||||
discardBackups: function () {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
};
|
||||
|
||||
moveFile(source: URI, target: URI, overwrite?: boolean): TPromise<IFileStat> {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
copyFile(source: URI, target: URI, overwrite?: boolean): TPromise<IFileStat> {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
createFile(resource: URI, content?: string): TPromise<IFileStat> {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
createFolder(resource: URI): TPromise<IFileStat> {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
rename(resource: URI, newName: string): TPromise<IFileStat> {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
touchFile(resource: URI): TPromise<IFileStat> {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
del(resource: URI, useTrash?: boolean): TPromise<void> {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
importFile(source: URI, targetFolder: URI): TPromise<IImportResult> {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
watchFileChanges(resource: URI): void {
|
||||
}
|
||||
|
||||
unwatchFileChanges(resource: URI): void;
|
||||
unwatchFileChanges(fsPath: string): void;
|
||||
unwatchFileChanges(arg1: any): void {
|
||||
}
|
||||
|
||||
updateOptions(options: any): void {
|
||||
}
|
||||
|
||||
getEncoding(resource: URI): string {
|
||||
return 'utf8';
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
}
|
||||
}
|
||||
|
||||
export class TestBackupFileService implements IBackupFileService {
|
||||
public _serviceBrand: any;
|
||||
|
||||
Reference in New Issue
Block a user