Skip to content

Commit 4fed11f

Browse files
committed
Remove unused code (microsoft#38414)
1 parent 090d0ff commit 4fed11f

37 files changed

Lines changed: 142 additions & 464 deletions

src/vs/base/browser/dom.ts

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { TPromise } from 'vs/base/common/winjs.base';
99
import { TimeoutTimer } from 'vs/base/common/async';
1010
import { onUnexpectedError } from 'vs/base/common/errors';
1111
import { Disposable, IDisposable, dispose } from 'vs/base/common/lifecycle';
12-
import { isObject } from 'vs/base/common/types';
1312
import * as browser from 'vs/base/browser/browser';
1413
import { IKeyboardEvent, StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
1514
import { IMouseEvent, StandardMouseEvent } from 'vs/base/browser/mouseEvent';
@@ -23,31 +22,6 @@ export function clearNode(node: HTMLElement) {
2322
}
2423
}
2524

26-
/**
27-
* Calls JSON.Stringify with a replacer to break apart any circular references.
28-
* This prevents JSON.stringify from throwing the exception
29-
* "Uncaught TypeError: Converting circular structure to JSON"
30-
*/
31-
export function safeStringifyDOMAware(obj: any): string {
32-
let seen: any[] = [];
33-
return JSON.stringify(obj, (key, value) => {
34-
35-
// HTML elements are never going to serialize nicely
36-
if (value instanceof Element) {
37-
return '[Element]';
38-
}
39-
40-
if (isObject(value) || Array.isArray(value)) {
41-
if (seen.indexOf(value) !== -1) {
42-
return '[Circular]';
43-
} else {
44-
seen.push(value);
45-
}
46-
}
47-
return value;
48-
});
49-
}
50-
5125
export function isInDOM(node: Node): boolean {
5226
while (node) {
5327
if (node === document.body) {
@@ -58,7 +32,14 @@ export function isInDOM(node: Node): boolean {
5832
return false;
5933
}
6034

61-
const _manualClassList = new class {
35+
interface IDomClassList {
36+
hasClass(node: HTMLElement, className: string): boolean;
37+
addClass(node: HTMLElement, className: string): void;
38+
removeClass(node: HTMLElement, className: string): void;
39+
toggleClass(node: HTMLElement, className: string, shouldHaveIt?: boolean): void;
40+
}
41+
42+
const _manualClassList = new class implements IDomClassList {
6243

6344
private _lastStart: number;
6445
private _lastEnd: number;
@@ -160,7 +141,7 @@ const _manualClassList = new class {
160141
}
161142
};
162143

163-
const _nativeClassList = new class {
144+
const _nativeClassList = new class implements IDomClassList {
164145
hasClass(node: HTMLElement, className: string): boolean {
165146
return className && node.classList && node.classList.contains(className);
166147
}
@@ -186,7 +167,7 @@ const _nativeClassList = new class {
186167

187168
// In IE11 there is only partial support for `classList` which makes us keep our
188169
// custom implementation. Otherwise use the native implementation, see: http://caniuse.com/#search=classlist
189-
const _classList = browser.isIE ? _manualClassList : _nativeClassList;
170+
const _classList: IDomClassList = browser.isIE ? _manualClassList : _nativeClassList;
190171
export const hasClass: (node: HTMLElement, className: string) => boolean = _classList.hasClass.bind(_classList);
191172
export const addClass: (node: HTMLElement, className: string) => void = _classList.addClass.bind(_classList);
192173
export const removeClass: (node: HTMLElement, className: string) => void = _classList.removeClass.bind(_classList);

src/vs/base/browser/ui/scrollbar/scrollbarState.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,6 @@ export class ScrollbarState {
189189
return this._computedSliderPosition;
190190
}
191191

192-
public getSliderCenter(): number {
193-
return (this._computedSliderPosition + this._computedSliderSize / 2);
194-
}
195-
196192
/**
197193
* Compute a desired `scrollPosition` such that `offset` ends up in the center of the slider.
198194
* `offset` is based on the same coordinate system as the `sliderPosition`.

src/vs/base/common/worker/simpleWorker.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ export class SimpleWorkerClient<T> extends Disposable {
188188
private _onModuleLoaded: TPromise<string[]>;
189189
private _protocol: SimpleWorkerProtocol;
190190
private _lazyProxy: TPromise<T>;
191-
private _lastRequestTimestamp = -1;
192191

193192
constructor(workerFactory: IWorkerFactory, moduleId: string) {
194193
super();
@@ -270,14 +269,9 @@ export class SimpleWorkerClient<T> extends Disposable {
270269
return new ShallowCancelThenPromise(this._lazyProxy);
271270
}
272271

273-
public getLastRequestTimestamp(): number {
274-
return this._lastRequestTimestamp;
275-
}
276-
277272
private _request(method: string, args: any[]): TPromise<any> {
278273
return new TPromise<any>((c, e, p) => {
279274
this._onModuleLoaded.then(() => {
280-
this._lastRequestTimestamp = Date.now();
281275
this._protocol.sendMessage(method, args).then(c, e);
282276
}, e);
283277
}, () => {

src/vs/base/test/browser/dom.test.ts

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -85,75 +85,6 @@ suite('dom', () => {
8585
// }
8686
//});
8787

88-
test('safeStringify', function () {
89-
let obj1: any = {
90-
friend: null
91-
};
92-
93-
let obj2: any = {
94-
friend: null
95-
};
96-
97-
obj1.friend = obj2;
98-
obj2.friend = obj1;
99-
100-
let arr: any = [1];
101-
arr.push(arr);
102-
103-
let circular: any = {
104-
a: 42,
105-
b: null,
106-
c: [
107-
obj1, obj2
108-
],
109-
d: null
110-
};
111-
112-
arr.push(circular);
113-
circular.b = circular;
114-
circular.d = arr;
115-
116-
let result = dom.safeStringifyDOMAware(circular);
117-
118-
assert.deepEqual(JSON.parse(result), {
119-
a: 42,
120-
b: '[Circular]',
121-
c: [
122-
{
123-
friend: {
124-
friend: '[Circular]'
125-
}
126-
},
127-
'[Circular]'
128-
],
129-
d: [1, '[Circular]', '[Circular]']
130-
});
131-
});
132-
133-
test('safeStringify2', function () {
134-
let obj: any = {
135-
a: null,
136-
b: document.createElement('div'),
137-
c: null,
138-
d: 'string',
139-
e: 'string',
140-
f: 42,
141-
g: 42
142-
};
143-
144-
let result = dom.safeStringifyDOMAware(obj);
145-
146-
assert.deepEqual(JSON.parse(result), {
147-
a: null,
148-
b: '[Element]',
149-
c: null,
150-
d: 'string',
151-
e: 'string',
152-
f: 42,
153-
g: 42
154-
});
155-
});
156-
15788
suite('$', () => {
15889
test('should build simple nodes', () => {
15990
const div = $('div');

src/vs/base/test/browser/ui/scrollbar/scrollbarState.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ suite('ScrollbarState', () => {
2121
assert.equal(actual.isNeeded(), true);
2222
assert.equal(actual.getSliderSize(), 20);
2323
assert.equal(actual.getSliderPosition(), 249);
24-
assert.equal(actual.getSliderCenter(), 259);
2524

2625

2726
assert.equal(actual.getDesiredScrollPositionFromOffset(259), 32849);
@@ -33,7 +32,6 @@ suite('ScrollbarState', () => {
3332
assert.equal(actual.isNeeded(), true);
3433
assert.equal(actual.getSliderSize(), 20);
3534
assert.equal(actual.getSliderPosition(), 249);
36-
assert.equal(actual.getSliderCenter(), 259);
3735
});
3836

3937
test('inflates slider size with arrows', () => {
@@ -49,7 +47,6 @@ suite('ScrollbarState', () => {
4947
assert.equal(actual.isNeeded(), true);
5048
assert.equal(actual.getSliderSize(), 20);
5149
assert.equal(actual.getSliderPosition(), 230);
52-
assert.equal(actual.getSliderCenter(), 240);
5350

5451

5552
assert.equal(actual.getDesiredScrollPositionFromOffset(240 + 12), 32811);
@@ -61,6 +58,5 @@ suite('ScrollbarState', () => {
6158
assert.equal(actual.isNeeded(), true);
6259
assert.equal(actual.getSliderSize(), 20);
6360
assert.equal(actual.getSliderPosition(), 230);
64-
assert.equal(actual.getSliderCenter(), 240);
6561
});
6662
});

src/vs/editor/browser/controller/textAreaHandler.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -356,20 +356,6 @@ export class TextAreaHandler extends ViewPart {
356356
this._textAreaInput.focusTextArea();
357357
}
358358

359-
public setAriaActiveDescendant(id: string): void {
360-
if (id) {
361-
this.textArea.setAttribute('role', 'combobox');
362-
if (this.textArea.getAttribute('aria-activedescendant') !== id) {
363-
this.textArea.setAttribute('aria-haspopup', 'true');
364-
this.textArea.setAttribute('aria-activedescendant', id);
365-
}
366-
} else {
367-
this.textArea.setAttribute('role', 'textbox');
368-
this.textArea.removeAttribute('aria-activedescendant');
369-
this.textArea.removeAttribute('aria-haspopup');
370-
}
371-
}
372-
373359
// --- end view API
374360

375361
private _primaryCursorVisibleRange: HorizontalRange = null;

src/vs/editor/browser/controller/textAreaState.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,6 @@ export class TextAreaState {
4747
this.selectionEndPosition = selectionEndPosition;
4848
}
4949

50-
public equals(other: TextAreaState): boolean {
51-
if (other instanceof TextAreaState) {
52-
return (
53-
this.value === other.value
54-
&& this.selectionStart === other.selectionStart
55-
&& this.selectionEnd === other.selectionEnd
56-
&& Position.equals(this.selectionStartPosition, other.selectionStartPosition)
57-
&& Position.equals(this.selectionEndPosition, other.selectionEndPosition)
58-
);
59-
}
60-
return false;
61-
}
62-
6350
public toString(): string {
6451
return '[ <' + this.value + '>, selectionStart: ' + this.selectionStart + ', selectionEnd: ' + this.selectionEnd + ']';
6552
}

src/vs/editor/browser/editorBrowser.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -712,11 +712,6 @@ export interface ICodeEditor extends editorCommon.IEditor {
712712
*/
713713
getScrolledVisiblePosition(position: IPosition): { top: number; left: number; height: number; };
714714

715-
/**
716-
* @internal
717-
*/
718-
setAriaActiveDescendant(id: string): void;
719-
720715
/**
721716
* Apply the same font settings as the editor to `target`.
722717
*/
@@ -803,11 +798,6 @@ export interface IDiffEditor extends editorCommon.IEditor {
803798
* If the diff computation is not finished or the model is missing, will return null.
804799
*/
805800
getDiffLineInformationForModified(lineNumber: number): IDiffLineInformation;
806-
807-
/**
808-
* @see ICodeEditor.getValue
809-
*/
810-
getValue(options?: { preserveBOM: boolean; lineEnding: string; }): string;
811801
}
812802

813803
/**

src/vs/editor/browser/services/abstractCodeEditorService.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ export abstract class AbstractCodeEditorService implements ICodeEditorService {
4949
return this._onCodeEditorRemove.event;
5050
}
5151

52-
getCodeEditor(editorId: string): ICodeEditor {
53-
return this._codeEditors[editorId] || null;
54-
}
55-
5652
listCodeEditors(): ICodeEditor[] {
5753
return Object.keys(this._codeEditors).map(id => this._codeEditors[id]);
5854
}

src/vs/editor/browser/services/codeEditorService.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export interface ICodeEditorService {
2323

2424
addCodeEditor(editor: ICodeEditor): void;
2525
removeCodeEditor(editor: ICodeEditor): void;
26-
getCodeEditor(editorId: string): ICodeEditor;
2726
listCodeEditors(): ICodeEditor[];
2827

2928
addDiffEditor(editor: IDiffEditor): void;

0 commit comments

Comments
 (0)