mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
Enable no-var-keyword tslint rule
This commit is contained in:
parent
3f8579f96a
commit
5cc00861fc
|
@ -295,8 +295,8 @@ export function expandEmmetAbbreviation(args: any): Thenable<boolean | undefined
|
|||
|
||||
let selectionsInReverseOrder = editor.selections.slice(0);
|
||||
selectionsInReverseOrder.sort((a, b) => {
|
||||
var posA = a.isReversed ? a.anchor : a.active;
|
||||
var posB = b.isReversed ? b.anchor : b.active;
|
||||
const posA = a.isReversed ? a.anchor : a.active;
|
||||
const posB = b.isReversed ? b.anchor : b.active;
|
||||
return posA.compareTo(posB) * -1;
|
||||
});
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ export interface HTMLDocumentRegions {
|
|||
getImportedScripts(): string[];
|
||||
}
|
||||
|
||||
export var CSS_STYLE_RULE = '__';
|
||||
export const CSS_STYLE_RULE = '__';
|
||||
|
||||
interface EmbeddedRegion { languageId: string | undefined; start: number; end: number; attributeValue?: boolean; }
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ export function getHTMLMode(htmlLanguageService: HTMLLanguageService, workspace:
|
|||
}
|
||||
|
||||
function merge(src: any, dst: any): any {
|
||||
for (var key in src) {
|
||||
for (const key in src) {
|
||||
if (src.hasOwnProperty(key)) {
|
||||
dst[key] = src[key];
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ export interface LanguageModeRange extends Range {
|
|||
|
||||
export function getLanguageModes(supportedLanguages: { [languageId: string]: boolean; }, workspace: Workspace, customTags?: ITagSet, customAttributes?: IAttributeSet): LanguageModes {
|
||||
|
||||
var htmlLanguageService = getHTMLLanguageService({
|
||||
const htmlLanguageService = getHTMLLanguageService({
|
||||
customTags,
|
||||
customAttributes
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
export function pushAll<T>(to: T[], from: T[]) {
|
||||
if (from) {
|
||||
for (var i = 0; i < from.length; i++) {
|
||||
for (let i = 0; i < from.length; i++) {
|
||||
to.push(from[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ export function endsWith(haystack: string, needle: string): boolean {
|
|||
}
|
||||
|
||||
export function repeat(value: string, count: number) {
|
||||
var s = '';
|
||||
let s = '';
|
||||
while (count > 0) {
|
||||
if ((count & 1) === 1) {
|
||||
s += value;
|
||||
|
|
|
@ -180,7 +180,7 @@ let formatterRegistration: Thenable<Disposable> | null = null;
|
|||
|
||||
// The settings have changed. Is send on server activation as well.
|
||||
connection.onDidChangeConfiguration((change) => {
|
||||
var settings = <Settings>change.settings;
|
||||
let settings = <Settings>change.settings;
|
||||
configureHttpRequests(settings.http && settings.http.proxy, settings.http && settings.http.proxyStrictSSL);
|
||||
|
||||
jsonConfigurationSettings = settings.json && settings.json.schemas;
|
||||
|
@ -233,7 +233,7 @@ function updateConfiguration() {
|
|||
schemas: new Array<SchemaConfiguration>()
|
||||
};
|
||||
if (schemaAssociations) {
|
||||
for (var pattern in schemaAssociations) {
|
||||
for (const pattern in schemaAssociations) {
|
||||
const association = schemaAssociations[pattern];
|
||||
if (Array.isArray(association)) {
|
||||
association.forEach(uri => {
|
||||
|
|
|
@ -12,7 +12,7 @@ import throttle = require('lodash.throttle');
|
|||
|
||||
declare var acquireVsCodeApi: any;
|
||||
|
||||
var scrollDisabled = true;
|
||||
let scrollDisabled = true;
|
||||
const marker = new ActiveLineMarker();
|
||||
const settings = getSettings();
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ export class Delayer<T> {
|
|||
}).then(() => {
|
||||
this.completionPromise = null;
|
||||
this.onSuccess = null;
|
||||
var result = this.task!();
|
||||
let result = this.task!();
|
||||
this.task = null;
|
||||
return result;
|
||||
});
|
||||
|
|
|
@ -91,8 +91,7 @@ export default class DocumentMergeConflictTracker implements vscode.Disposable,
|
|||
return false;
|
||||
}
|
||||
|
||||
var task = this.cache.get(key);
|
||||
|
||||
const task = this.cache.get(key);
|
||||
if (!task) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ export default class MergeDecorator implements vscode.Disposable {
|
|||
}
|
||||
|
||||
private applyDecorationsFromEvent(eventDocument: vscode.TextDocument) {
|
||||
for (var i = 0; i < vscode.window.visibleTextEditors.length; i++) {
|
||||
for (let i = 0; i < vscode.window.visibleTextEditors.length; i++) {
|
||||
if (vscode.window.visibleTextEditors[i].document === eventDocument) {
|
||||
// Attempt to apply
|
||||
this.applyDecorations(vscode.window.visibleTextEditors[i]);
|
||||
|
|
|
@ -343,7 +343,7 @@ export function startDebugging(scriptName: string, protocol: string, port: numbe
|
|||
export type StringMap = { [s: string]: string; };
|
||||
|
||||
async function findAllScripts(buffer: string): Promise<StringMap> {
|
||||
var scripts: StringMap = {};
|
||||
let scripts: StringMap = {};
|
||||
let script: string | undefined = undefined;
|
||||
let inScripts = false;
|
||||
|
||||
|
@ -380,7 +380,7 @@ async function findAllScripts(buffer: string): Promise<StringMap> {
|
|||
}
|
||||
|
||||
export function findAllScriptRanges(buffer: string): Map<string, [number, number, string]> {
|
||||
var scripts: Map<string, [number, number, string]> = new Map();
|
||||
let scripts: Map<string, [number, number, string]> = new Map();
|
||||
let script: string | undefined = undefined;
|
||||
let offset: number;
|
||||
let length: number;
|
||||
|
@ -469,8 +469,8 @@ export async function getScripts(packageJsonUri: Uri): Promise<StringMap | undef
|
|||
}
|
||||
|
||||
try {
|
||||
var contents = await readFile(packageJson);
|
||||
var json = findAllScripts(contents);//JSON.parse(contents);
|
||||
let contents = await readFile(packageJson);
|
||||
let json = findAllScripts(contents);//JSON.parse(contents);
|
||||
return json;
|
||||
} catch (e) {
|
||||
let localizedParseError = localize('npm.parseError', 'Npm task detection: failed to parse the file {0}', packageJsonUri.fsPath);
|
||||
|
|
|
@ -17,8 +17,8 @@ export default class PHPCompletionItemProvider implements CompletionItemProvider
|
|||
return Promise.resolve(result);
|
||||
}
|
||||
|
||||
var range = document.getWordRangeAtPosition(position);
|
||||
var prefix = range ? document.getText(range) : '';
|
||||
let range = document.getWordRangeAtPosition(position);
|
||||
let prefix = range ? document.getText(range) : '';
|
||||
if (!range) {
|
||||
range = new Range(position, position);
|
||||
}
|
||||
|
@ -31,9 +31,9 @@ export default class PHPCompletionItemProvider implements CompletionItemProvider
|
|||
}
|
||||
}
|
||||
|
||||
var added: any = {};
|
||||
var createNewProposal = function (kind: CompletionItemKind, name: string, entry: phpGlobals.IEntry | null): CompletionItem {
|
||||
var proposal: CompletionItem = new CompletionItem(name);
|
||||
let added: any = {};
|
||||
let createNewProposal = function (kind: CompletionItemKind, name: string, entry: phpGlobals.IEntry | null): CompletionItem {
|
||||
let proposal: CompletionItem = new CompletionItem(name);
|
||||
proposal.kind = kind;
|
||||
if (entry) {
|
||||
if (entry.description) {
|
||||
|
@ -46,7 +46,7 @@ export default class PHPCompletionItemProvider implements CompletionItemProvider
|
|||
return proposal;
|
||||
};
|
||||
|
||||
var matches = (name: string) => {
|
||||
let matches = (name: string) => {
|
||||
return prefix.length === 0 || name.length >= prefix.length && name.substr(0, prefix.length) === prefix;
|
||||
};
|
||||
|
||||
|
@ -62,47 +62,47 @@ export default class PHPCompletionItemProvider implements CompletionItemProvider
|
|||
}
|
||||
}
|
||||
|
||||
for (var globalvariables in phpGlobals.globalvariables) {
|
||||
for (let globalvariables in phpGlobals.globalvariables) {
|
||||
if (phpGlobals.globalvariables.hasOwnProperty(globalvariables) && matches(globalvariables)) {
|
||||
added[globalvariables] = true;
|
||||
result.push(createNewProposal(CompletionItemKind.Variable, globalvariables, phpGlobals.globalvariables[globalvariables]));
|
||||
}
|
||||
}
|
||||
for (var globalfunctions in phpGlobalFunctions.globalfunctions) {
|
||||
for (let globalfunctions in phpGlobalFunctions.globalfunctions) {
|
||||
if (phpGlobalFunctions.globalfunctions.hasOwnProperty(globalfunctions) && matches(globalfunctions)) {
|
||||
added[globalfunctions] = true;
|
||||
result.push(createNewProposal(CompletionItemKind.Function, globalfunctions, phpGlobalFunctions.globalfunctions[globalfunctions]));
|
||||
}
|
||||
}
|
||||
for (var compiletimeconstants in phpGlobals.compiletimeconstants) {
|
||||
for (let compiletimeconstants in phpGlobals.compiletimeconstants) {
|
||||
if (phpGlobals.compiletimeconstants.hasOwnProperty(compiletimeconstants) && matches(compiletimeconstants)) {
|
||||
added[compiletimeconstants] = true;
|
||||
result.push(createNewProposal(CompletionItemKind.Field, compiletimeconstants, phpGlobals.compiletimeconstants[compiletimeconstants]));
|
||||
}
|
||||
}
|
||||
for (var keywords in phpGlobals.keywords) {
|
||||
for (let keywords in phpGlobals.keywords) {
|
||||
if (phpGlobals.keywords.hasOwnProperty(keywords) && matches(keywords)) {
|
||||
added[keywords] = true;
|
||||
result.push(createNewProposal(CompletionItemKind.Keyword, keywords, phpGlobals.keywords[keywords]));
|
||||
}
|
||||
}
|
||||
|
||||
var text = document.getText();
|
||||
let text = document.getText();
|
||||
if (prefix[0] === '$') {
|
||||
var variableMatch = /\$([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)/g;
|
||||
var match: RegExpExecArray | null = null;
|
||||
let variableMatch = /\$([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)/g;
|
||||
let match: RegExpExecArray | null = null;
|
||||
while (match = variableMatch.exec(text)) {
|
||||
var word = match[0];
|
||||
let word = match[0];
|
||||
if (!added[word]) {
|
||||
added[word] = true;
|
||||
result.push(createNewProposal(CompletionItemKind.Variable, word, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
var functionMatch = /function\s+([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)\s*\(/g;
|
||||
var match2: RegExpExecArray | null = null;
|
||||
let functionMatch = /function\s+([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)\s*\(/g;
|
||||
let match2: RegExpExecArray | null = null;
|
||||
while (match2 = functionMatch.exec(text)) {
|
||||
var word2 = match2[1];
|
||||
let word2 = match2[1];
|
||||
if (!added[word2]) {
|
||||
added[word2] = true;
|
||||
result.push(createNewProposal(CompletionItemKind.Function, word2, null));
|
||||
|
|
|
@ -23,7 +23,7 @@ export default class PHPHoverProvider implements HoverProvider {
|
|||
|
||||
let name = document.getText(wordRange);
|
||||
|
||||
var entry = phpGlobalFunctions.globalfunctions[name] || phpGlobals.compiletimeconstants[name] || phpGlobals.globalvariables[name] || phpGlobals.keywords[name];
|
||||
let entry = phpGlobalFunctions.globalfunctions[name] || phpGlobals.compiletimeconstants[name] || phpGlobals.globalvariables[name] || phpGlobals.keywords[name];
|
||||
if (entry && entry.description) {
|
||||
let signature = name + (entry.signature || '');
|
||||
let contents: MarkedString[] = [textToMarkedString(entry.description), { language: 'php', value: signature }];
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import { IEntries } from './phpGlobals';
|
||||
|
||||
export var globalfunctions: IEntries = {
|
||||
export const globalfunctions: IEntries = {
|
||||
debug_backtrace: {
|
||||
description: 'Generates a backtrace',
|
||||
signature: '([ int $options = DEBUG_BACKTRACE_PROVIDE_OBJECT [, int $limit = 0 ]]): array'
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
export interface IEntry { description?: string; signature?: string; }
|
||||
export interface IEntries { [name: string]: IEntry; }
|
||||
|
||||
export var globalvariables: IEntries = {
|
||||
export const globalvariables: IEntries = {
|
||||
$GLOBALS: {
|
||||
description: 'An associative array containing references to all variables which are currently defined in the global scope of the script. The variable names are the keys of the array.',
|
||||
},
|
||||
|
@ -55,7 +55,7 @@ export var globalvariables: IEntries = {
|
|||
description: 'Refers to the current object',
|
||||
},
|
||||
};
|
||||
export var compiletimeconstants: IEntries = {
|
||||
export const compiletimeconstants: IEntries = {
|
||||
__CLASS__: {
|
||||
description: 'The class name. (Added in PHP 4.3.0) As of PHP 5 this constant returns the class name as it was declared (case-sensitive). In PHP 4 its value is always lowercased.',
|
||||
},
|
||||
|
@ -159,7 +159,7 @@ export var compiletimeconstants: IEntries = {
|
|||
description: 'The default algorithm to use for hashing if no algorithm is provided. This may change in newer PHP releases when newer, stronger hashing algorithms are supported.',
|
||||
},
|
||||
};
|
||||
export var keywords: IEntries = {
|
||||
export const keywords: IEntries = {
|
||||
define: {
|
||||
description: 'Defines a named constant at runtime.',
|
||||
signature: '( string $name , mixed $value [, bool $case_insensitive = false ] ): bool'
|
||||
|
|
|
@ -7,27 +7,27 @@ import { SignatureHelpProvider, SignatureHelp, SignatureInformation, Cancellatio
|
|||
import phpGlobals = require('./phpGlobals');
|
||||
import phpGlobalFunctions = require('./phpGlobalFunctions');
|
||||
|
||||
var _NL = '\n'.charCodeAt(0);
|
||||
var _TAB = '\t'.charCodeAt(0);
|
||||
var _WSB = ' '.charCodeAt(0);
|
||||
var _LBracket = '['.charCodeAt(0);
|
||||
var _RBracket = ']'.charCodeAt(0);
|
||||
var _LCurly = '{'.charCodeAt(0);
|
||||
var _RCurly = '}'.charCodeAt(0);
|
||||
var _LParent = '('.charCodeAt(0);
|
||||
var _RParent = ')'.charCodeAt(0);
|
||||
var _Comma = ','.charCodeAt(0);
|
||||
var _Quote = '\''.charCodeAt(0);
|
||||
var _DQuote = '"'.charCodeAt(0);
|
||||
var _USC = '_'.charCodeAt(0);
|
||||
var _a = 'a'.charCodeAt(0);
|
||||
var _z = 'z'.charCodeAt(0);
|
||||
var _A = 'A'.charCodeAt(0);
|
||||
var _Z = 'Z'.charCodeAt(0);
|
||||
var _0 = '0'.charCodeAt(0);
|
||||
var _9 = '9'.charCodeAt(0);
|
||||
const _NL = '\n'.charCodeAt(0);
|
||||
const _TAB = '\t'.charCodeAt(0);
|
||||
const _WSB = ' '.charCodeAt(0);
|
||||
const _LBracket = '['.charCodeAt(0);
|
||||
const _RBracket = ']'.charCodeAt(0);
|
||||
const _LCurly = '{'.charCodeAt(0);
|
||||
const _RCurly = '}'.charCodeAt(0);
|
||||
const _LParent = '('.charCodeAt(0);
|
||||
const _RParent = ')'.charCodeAt(0);
|
||||
const _Comma = ','.charCodeAt(0);
|
||||
const _Quote = '\''.charCodeAt(0);
|
||||
const _DQuote = '"'.charCodeAt(0);
|
||||
const _USC = '_'.charCodeAt(0);
|
||||
const _a = 'a'.charCodeAt(0);
|
||||
const _z = 'z'.charCodeAt(0);
|
||||
const _A = 'A'.charCodeAt(0);
|
||||
const _Z = 'Z'.charCodeAt(0);
|
||||
const _0 = '0'.charCodeAt(0);
|
||||
const _9 = '9'.charCodeAt(0);
|
||||
|
||||
var BOF = 0;
|
||||
const BOF = 0;
|
||||
|
||||
|
||||
class BackwardIterator {
|
||||
|
@ -58,7 +58,7 @@ class BackwardIterator {
|
|||
this.lineNumber = -1;
|
||||
return BOF;
|
||||
}
|
||||
var ch = this.line.charCodeAt(this.offset);
|
||||
let ch = this.line.charCodeAt(this.offset);
|
||||
this.offset--;
|
||||
return ch;
|
||||
}
|
||||
|
@ -74,27 +74,27 @@ export default class PHPSignatureHelpProvider implements SignatureHelpProvider {
|
|||
return null;
|
||||
}
|
||||
|
||||
var iterator = new BackwardIterator(document, position.character - 1, position.line);
|
||||
let iterator = new BackwardIterator(document, position.character - 1, position.line);
|
||||
|
||||
var paramCount = this.readArguments(iterator);
|
||||
let paramCount = this.readArguments(iterator);
|
||||
if (paramCount < 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var ident = this.readIdent(iterator);
|
||||
let ident = this.readIdent(iterator);
|
||||
if (!ident) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var entry = phpGlobalFunctions.globalfunctions[ident] || phpGlobals.keywords[ident];
|
||||
let entry = phpGlobalFunctions.globalfunctions[ident] || phpGlobals.keywords[ident];
|
||||
if (!entry || !entry.signature) {
|
||||
return null;
|
||||
}
|
||||
var paramsString = entry.signature.substring(0, entry.signature.lastIndexOf(')') + 1);
|
||||
let paramsString = entry.signature.substring(0, entry.signature.lastIndexOf(')') + 1);
|
||||
let signatureInfo = new SignatureInformation(ident + paramsString, entry.description);
|
||||
|
||||
var re = /\w*\s+\&?\$[\w_\.]+|void/g;
|
||||
var match: RegExpExecArray | null = null;
|
||||
let re = /\w*\s+\&?\$[\w_\.]+|void/g;
|
||||
let match: RegExpExecArray | null = null;
|
||||
while ((match = re.exec(paramsString)) !== null) {
|
||||
signatureInfo.parameters.push({ label: match[0], documentation: '' });
|
||||
}
|
||||
|
@ -106,12 +106,12 @@ export default class PHPSignatureHelpProvider implements SignatureHelpProvider {
|
|||
}
|
||||
|
||||
private readArguments(iterator: BackwardIterator): number {
|
||||
var parentNesting = 0;
|
||||
var bracketNesting = 0;
|
||||
var curlyNesting = 0;
|
||||
var paramCount = 0;
|
||||
let parentNesting = 0;
|
||||
let bracketNesting = 0;
|
||||
let curlyNesting = 0;
|
||||
let paramCount = 0;
|
||||
while (iterator.hasNext()) {
|
||||
var ch = iterator.next();
|
||||
let ch = iterator.next();
|
||||
switch (ch) {
|
||||
case _LParent:
|
||||
parentNesting--;
|
||||
|
@ -153,10 +153,10 @@ export default class PHPSignatureHelpProvider implements SignatureHelpProvider {
|
|||
}
|
||||
|
||||
private readIdent(iterator: BackwardIterator): string {
|
||||
var identStarted = false;
|
||||
var ident = '';
|
||||
let identStarted = false;
|
||||
let ident = '';
|
||||
while (iterator.hasNext()) {
|
||||
var ch = iterator.next();
|
||||
let ch = iterator.next();
|
||||
if (!identStarted && (ch === _WSB || ch === _TAB || ch === _NL)) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -44,10 +44,10 @@ export class Throttler<T> {
|
|||
this.queuedPromiseFactory = promiseFactory;
|
||||
|
||||
if (!this.queuedPromise) {
|
||||
var onComplete = () => {
|
||||
let onComplete = () => {
|
||||
this.queuedPromise = null;
|
||||
|
||||
var result = this.queue(this.queuedPromiseFactory!);
|
||||
let result = this.queue(this.queuedPromiseFactory!);
|
||||
this.queuedPromiseFactory = null;
|
||||
|
||||
return result;
|
||||
|
@ -127,7 +127,7 @@ export class Delayer<T> {
|
|||
this.completionPromise = null;
|
||||
this.onResolve = null;
|
||||
|
||||
var result = this.task!();
|
||||
let result = this.task!();
|
||||
this.task = null;
|
||||
|
||||
return result;
|
||||
|
|
|
@ -23,20 +23,20 @@ export class LineDecoder {
|
|||
}
|
||||
|
||||
public write(buffer: Buffer): string[] {
|
||||
var result: string[] = [];
|
||||
var value = this.remaining
|
||||
let result: string[] = [];
|
||||
let value = this.remaining
|
||||
? this.remaining + this.stringDecoder.write(buffer)
|
||||
: this.stringDecoder.write(buffer);
|
||||
|
||||
if (value.length < 1) {
|
||||
return result;
|
||||
}
|
||||
var start = 0;
|
||||
var ch: number;
|
||||
let start = 0;
|
||||
let ch: number;
|
||||
while (start < value.length && ((ch = value.charCodeAt(start)) === 13 || ch === 10)) {
|
||||
start++;
|
||||
}
|
||||
var idx = start;
|
||||
let idx = start;
|
||||
while (idx < value.length) {
|
||||
ch = value.charCodeAt(idx);
|
||||
if (ch === 13 || ch === 10) {
|
||||
|
|
|
@ -81,6 +81,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
|||
this.pathSeparator = path.sep;
|
||||
this.lastStart = Date.now();
|
||||
|
||||
// tslint:disable-next-line: no-var-keyword
|
||||
var p = new Promise<void>((resolve, reject) => {
|
||||
this._onReady = { promise: p, resolve, reject };
|
||||
});
|
||||
|
|
|
@ -35,7 +35,7 @@ export class Delayer<T> {
|
|||
}).then(() => {
|
||||
this.completionPromise = null;
|
||||
this.onSuccess = null;
|
||||
var result = this.task && this.task();
|
||||
const result = this.task && this.task();
|
||||
this.task = null;
|
||||
return result;
|
||||
});
|
||||
|
|
|
@ -482,9 +482,9 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
|
|||
return;
|
||||
}
|
||||
|
||||
var diff = this.dragAndDropMouseY - viewTop;
|
||||
var scrollDiff = 0;
|
||||
var upperLimit = this.renderHeight - 35;
|
||||
let diff = this.dragAndDropMouseY - viewTop;
|
||||
let scrollDiff = 0;
|
||||
let upperLimit = this.renderHeight - 35;
|
||||
|
||||
if (diff < 35) {
|
||||
scrollDiff = Math.max(-14, 0.2 * (diff - 35));
|
||||
|
|
|
@ -498,7 +498,7 @@ export function shuffle<T>(array: T[], _seed?: number): void {
|
|||
// Seeded random number generator in JS. Modified from:
|
||||
// https://stackoverflow.com/questions/521295/seeding-the-random-number-generator-in-javascript
|
||||
rand = () => {
|
||||
var x = Math.sin(seed++) * 179426549; // throw away most significant digits and reduce any potential bias
|
||||
const x = Math.sin(seed++) * 179426549; // throw away most significant digits and reduce any potential bias
|
||||
return x - Math.floor(x);
|
||||
};
|
||||
} else {
|
||||
|
|
|
@ -79,7 +79,7 @@ export class Lock {
|
|||
}
|
||||
|
||||
public run(item: Item, fn: () => Promise<any>): Promise<any> {
|
||||
var lock = this.getLock(item);
|
||||
let lock = this.getLock(item);
|
||||
|
||||
if (lock) {
|
||||
return new Promise((c, e) => {
|
||||
|
@ -89,7 +89,7 @@ export class Lock {
|
|||
});
|
||||
}
|
||||
|
||||
var result: Promise<any>;
|
||||
let result: Promise<any>;
|
||||
|
||||
return new Promise((c, e) => {
|
||||
|
||||
|
@ -97,7 +97,7 @@ export class Lock {
|
|||
return e(new Error('Item is disposed.'));
|
||||
}
|
||||
|
||||
var lock = this.locks[item.id] = new LockData(item);
|
||||
let lock = this.locks[item.id] = new LockData(item);
|
||||
|
||||
result = fn().then((r) => {
|
||||
delete this.locks[item.id];
|
||||
|
@ -111,10 +111,10 @@ export class Lock {
|
|||
}
|
||||
|
||||
private getLock(item: Item): LockData {
|
||||
var key: string;
|
||||
let key: string;
|
||||
|
||||
for (key in this.locks) {
|
||||
var lock = this.locks[key];
|
||||
let lock = this.locks[key];
|
||||
|
||||
if (item.intersects(lock.item)) {
|
||||
return lock;
|
||||
|
@ -346,7 +346,7 @@ export class Item {
|
|||
}
|
||||
|
||||
public reveal(relativeTop: number | null = null): void {
|
||||
var eventData: IItemRevealEvent = { item: this, relativeTop: relativeTop };
|
||||
let eventData: IItemRevealEvent = { item: this, relativeTop: relativeTop };
|
||||
this._onDidReveal.fire(eventData);
|
||||
}
|
||||
|
||||
|
@ -355,13 +355,13 @@ export class Item {
|
|||
return Promise.resolve(false);
|
||||
}
|
||||
|
||||
var result = this.lock.run(this, () => {
|
||||
let result = this.lock.run(this, () => {
|
||||
if (this.isExpanded() || !this.doesHaveChildren) {
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
|
||||
var eventData: IItemExpandEvent = { item: this };
|
||||
var result: Promise<any>;
|
||||
let eventData: IItemExpandEvent = { item: this };
|
||||
let result: Promise<any>;
|
||||
this._onExpand.fire(eventData);
|
||||
|
||||
if (this.needsChildrenRefresh) {
|
||||
|
@ -393,7 +393,7 @@ export class Item {
|
|||
|
||||
public collapse(recursive: boolean = false): Promise<any> {
|
||||
if (recursive) {
|
||||
var collapseChildrenPromise = Promise.resolve(null);
|
||||
let collapseChildrenPromise = Promise.resolve(null);
|
||||
this.forEachChild((child) => {
|
||||
collapseChildrenPromise = collapseChildrenPromise.then(() => child.collapse(true));
|
||||
});
|
||||
|
@ -406,7 +406,7 @@ export class Item {
|
|||
}
|
||||
|
||||
return this.lock.run(this, () => {
|
||||
var eventData: IItemCollapseEvent = { item: this };
|
||||
let eventData: IItemCollapseEvent = { item: this };
|
||||
this._onCollapse.fire(eventData);
|
||||
this._setExpanded(false);
|
||||
this._onDidCollapse.fire(eventData);
|
||||
|
@ -417,13 +417,13 @@ export class Item {
|
|||
}
|
||||
|
||||
public addTrait(trait: string): void {
|
||||
var eventData: IItemTraitEvent = { item: this, trait: trait };
|
||||
let eventData: IItemTraitEvent = { item: this, trait: trait };
|
||||
this.traits[trait] = true;
|
||||
this._onDidAddTrait.fire(eventData);
|
||||
}
|
||||
|
||||
public removeTrait(trait: string): void {
|
||||
var eventData: IItemTraitEvent = { item: this, trait: trait };
|
||||
let eventData: IItemTraitEvent = { item: this, trait: trait };
|
||||
delete this.traits[trait];
|
||||
this._onDidRemoveTrait.fire(eventData);
|
||||
}
|
||||
|
@ -433,8 +433,8 @@ export class Item {
|
|||
}
|
||||
|
||||
public getAllTraits(): string[] {
|
||||
var result: string[] = [];
|
||||
var trait: string;
|
||||
let result: string[] = [];
|
||||
let trait: string;
|
||||
for (trait in this.traits) {
|
||||
if (this.traits.hasOwnProperty(trait) && this.traits[trait]) {
|
||||
result.push(trait);
|
||||
|
@ -461,11 +461,11 @@ export class Item {
|
|||
|
||||
this.needsChildrenRefresh = false;
|
||||
|
||||
var doRefresh = () => {
|
||||
var eventData: IItemChildrenRefreshEvent = { item: this, isNested: safe };
|
||||
let doRefresh = () => {
|
||||
let eventData: IItemChildrenRefreshEvent = { item: this, isNested: safe };
|
||||
this._onRefreshChildren.fire(eventData);
|
||||
|
||||
var childrenPromise: Promise<any>;
|
||||
let childrenPromise: Promise<any>;
|
||||
if (this.doesHaveChildren) {
|
||||
childrenPromise = this.context.dataSource.getChildren(this.context.tree, this.element);
|
||||
} else {
|
||||
|
@ -484,16 +484,16 @@ export class Item {
|
|||
elements = !elements ? [] : elements.slice(0);
|
||||
elements = this.sort(elements);
|
||||
|
||||
var staleItems: IItemMap = {};
|
||||
let staleItems: IItemMap = {};
|
||||
while (this.firstChild !== null) {
|
||||
staleItems[this.firstChild.id] = this.firstChild;
|
||||
this.removeChild(this.firstChild);
|
||||
}
|
||||
|
||||
for (var i = 0, len = elements.length; i < len; i++) {
|
||||
var element = elements[i];
|
||||
var id = this.context.dataSource.getId(this.context.tree, element);
|
||||
var item = staleItems[id] || new Item(id, this.registry, this.context, this.lock, element);
|
||||
for (let i = 0, len = elements.length; i < len; i++) {
|
||||
let element = elements[i];
|
||||
let id = this.context.dataSource.getId(this.context.tree, element);
|
||||
let item = staleItems[id] || new Item(id, this.registry, this.context, this.lock, element);
|
||||
item.element = element;
|
||||
if (recursive) {
|
||||
item.needsChildrenRefresh = recursive;
|
||||
|
@ -502,7 +502,7 @@ export class Item {
|
|||
this.addChild(item);
|
||||
}
|
||||
|
||||
for (var staleItemId in staleItems) {
|
||||
for (let staleItemId in staleItems) {
|
||||
if (staleItems.hasOwnProperty(staleItemId)) {
|
||||
staleItems[staleItemId].dispose();
|
||||
}
|
||||
|
@ -559,8 +559,8 @@ export class Item {
|
|||
}
|
||||
|
||||
public getHierarchy(): Item[] {
|
||||
var result: Item[] = [];
|
||||
var node: Item = this;
|
||||
let result: Item[] = [];
|
||||
let node: Item = this;
|
||||
|
||||
do {
|
||||
result.push(node);
|
||||
|
@ -582,9 +582,9 @@ export class Item {
|
|||
}
|
||||
|
||||
private addChild(item: Item, afterItem: Item = this.lastChild): void {
|
||||
var isEmpty = this.firstChild === null;
|
||||
var atHead = afterItem === null;
|
||||
var atTail = afterItem === this.lastChild;
|
||||
let isEmpty = this.firstChild === null;
|
||||
let atHead = afterItem === null;
|
||||
let atTail = afterItem === this.lastChild;
|
||||
|
||||
if (isEmpty) {
|
||||
this.firstChild = this.lastChild = item;
|
||||
|
@ -611,8 +611,8 @@ export class Item {
|
|||
}
|
||||
|
||||
private removeChild(item: Item): void {
|
||||
var isFirstChild = this.firstChild === item;
|
||||
var isLastChild = this.lastChild === item;
|
||||
let isFirstChild = this.firstChild === item;
|
||||
let isLastChild = this.lastChild === item;
|
||||
|
||||
if (isFirstChild && isLastChild) {
|
||||
this.firstChild = this.lastChild = null;
|
||||
|
@ -632,7 +632,7 @@ export class Item {
|
|||
}
|
||||
|
||||
private forEachChild(fn: (child: Item) => void): void {
|
||||
var child = this.firstChild, next: Item;
|
||||
let child = this.firstChild, next: Item;
|
||||
while (child) {
|
||||
next = child.next;
|
||||
fn(child);
|
||||
|
@ -641,7 +641,7 @@ export class Item {
|
|||
}
|
||||
|
||||
private mapEachChild<T>(fn: (child: Item) => T): T[] {
|
||||
var result: T[] = [];
|
||||
let result: T[] = [];
|
||||
this.forEachChild((child) => {
|
||||
result.push(fn(child));
|
||||
});
|
||||
|
@ -794,7 +794,7 @@ export class TreeNavigator implements INavigator<Item> {
|
|||
public previous(): Item {
|
||||
if (this.item) {
|
||||
do {
|
||||
var previous = TreeNavigator.lastDescendantOf(this.item.previous);
|
||||
let previous = TreeNavigator.lastDescendantOf(this.item.previous);
|
||||
if (previous) {
|
||||
this.item = previous;
|
||||
} else if (this.item.parent && this.item.parent !== this.start && this.item.parent.isVisible()) {
|
||||
|
@ -809,7 +809,7 @@ export class TreeNavigator implements INavigator<Item> {
|
|||
|
||||
public parent(): Item {
|
||||
if (this.item) {
|
||||
var parent = this.item.parent;
|
||||
let parent = this.item.parent;
|
||||
if (parent && parent !== this.start && parent.isVisible()) {
|
||||
this.item = parent;
|
||||
} else {
|
||||
|
@ -831,17 +831,17 @@ export class TreeNavigator implements INavigator<Item> {
|
|||
}
|
||||
|
||||
function getRange(one: Item, other: Item): Item[] {
|
||||
var oneHierarchy = one.getHierarchy();
|
||||
var otherHierarchy = other.getHierarchy();
|
||||
var length = arrays.commonPrefixLength(oneHierarchy, otherHierarchy);
|
||||
var item = oneHierarchy[length - 1];
|
||||
var nav = item.getNavigator();
|
||||
let oneHierarchy = one.getHierarchy();
|
||||
let otherHierarchy = other.getHierarchy();
|
||||
let length = arrays.commonPrefixLength(oneHierarchy, otherHierarchy);
|
||||
let item = oneHierarchy[length - 1];
|
||||
let nav = item.getNavigator();
|
||||
|
||||
var oneIndex: number | null = null;
|
||||
var otherIndex: number | null = null;
|
||||
let oneIndex: number | null = null;
|
||||
let otherIndex: number | null = null;
|
||||
|
||||
var index = 0;
|
||||
var result: Item[] = [];
|
||||
let index = 0;
|
||||
let result: Item[] = [];
|
||||
|
||||
while (item && (oneIndex === null || otherIndex === null)) {
|
||||
result.push(item);
|
||||
|
@ -861,8 +861,8 @@ function getRange(one: Item, other: Item): Item[] {
|
|||
return [];
|
||||
}
|
||||
|
||||
var min = Math.min(oneIndex, otherIndex);
|
||||
var max = Math.max(oneIndex, otherIndex);
|
||||
let min = Math.min(oneIndex, otherIndex);
|
||||
let max = Math.max(oneIndex, otherIndex);
|
||||
return result.slice(min, max + 1);
|
||||
}
|
||||
|
||||
|
@ -930,7 +930,7 @@ export class TreeModel {
|
|||
}
|
||||
|
||||
public setInput(element: any): Promise<any> {
|
||||
var eventData: IInputEvent = { item: this.input };
|
||||
let eventData: IInputEvent = { item: this.input };
|
||||
this._onSetInput.fire(eventData);
|
||||
|
||||
this.setSelection([]);
|
||||
|
@ -965,7 +965,7 @@ export class TreeModel {
|
|||
this.registryDisposable = this.registry
|
||||
.onDidDisposeItem(item => item.getAllTraits().forEach(trait => delete this.traitsToItems[trait][item.id]));
|
||||
|
||||
var id = this.context.dataSource.getId(this.context.tree, element);
|
||||
let id = this.context.dataSource.getId(this.context.tree, element);
|
||||
this.input = new RootItem(id, this.registry, this.context, this.lock, element);
|
||||
eventData = { item: this.input };
|
||||
this._onDidSetInput.fire(eventData);
|
||||
|
@ -977,13 +977,13 @@ export class TreeModel {
|
|||
}
|
||||
|
||||
public refresh(element: any = null, recursive: boolean = true): Promise<any> {
|
||||
var item = this.getItem(element);
|
||||
let item = this.getItem(element);
|
||||
|
||||
if (!item) {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
var eventData: IRefreshEvent = { item: item, recursive: recursive };
|
||||
let eventData: IRefreshEvent = { item: item, recursive: recursive };
|
||||
this._onRefresh.fire(eventData);
|
||||
return item.refresh(recursive).then(() => {
|
||||
this._onDidRefresh.fire(eventData);
|
||||
|
@ -991,7 +991,7 @@ export class TreeModel {
|
|||
}
|
||||
|
||||
public expand(element: any): Promise<any> {
|
||||
var item = this.getItem(element);
|
||||
let item = this.getItem(element);
|
||||
|
||||
if (!item) {
|
||||
return Promise.resolve(false);
|
||||
|
@ -1004,8 +1004,8 @@ export class TreeModel {
|
|||
if (!elements) {
|
||||
elements = [];
|
||||
|
||||
var item: Item;
|
||||
var nav = this.getNavigator();
|
||||
let item: Item;
|
||||
let nav = this.getNavigator();
|
||||
|
||||
while (item = nav.next()) {
|
||||
elements.push(item);
|
||||
|
@ -1024,7 +1024,7 @@ export class TreeModel {
|
|||
const elementsToDelay: any[] = [];
|
||||
|
||||
for (const element of elements) {
|
||||
var item = this.getItem(element);
|
||||
let item = this.getItem(element);
|
||||
|
||||
if (item) {
|
||||
elementsToExpand.push(element);
|
||||
|
@ -1042,15 +1042,15 @@ export class TreeModel {
|
|||
}
|
||||
|
||||
private __expandAll(elements: any[]): Promise<any> {
|
||||
var promises = [];
|
||||
for (var i = 0, len = elements.length; i < len; i++) {
|
||||
let promises = [];
|
||||
for (let i = 0, len = elements.length; i < len; i++) {
|
||||
promises.push(this.expand(elements[i]));
|
||||
}
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
public collapse(element: any, recursive: boolean = false): Promise<any> {
|
||||
var item = this.getItem(element);
|
||||
let item = this.getItem(element);
|
||||
|
||||
if (!item) {
|
||||
return Promise.resolve(false);
|
||||
|
@ -1064,8 +1064,8 @@ export class TreeModel {
|
|||
elements = [this.input];
|
||||
recursive = true;
|
||||
}
|
||||
var promises = [];
|
||||
for (var i = 0, len = elements.length; i < len; i++) {
|
||||
let promises = [];
|
||||
for (let i = 0, len = elements.length; i < len; i++) {
|
||||
promises.push(this.collapse(elements[i], recursive));
|
||||
}
|
||||
return Promise.all(promises);
|
||||
|
@ -1076,15 +1076,15 @@ export class TreeModel {
|
|||
}
|
||||
|
||||
public toggleExpansionAll(elements: any[]): Promise<any> {
|
||||
var promises = [];
|
||||
for (var i = 0, len = elements.length; i < len; i++) {
|
||||
let promises = [];
|
||||
for (let i = 0, len = elements.length; i < len; i++) {
|
||||
promises.push(this.toggleExpansion(elements[i]));
|
||||
}
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
public isExpanded(element: any): boolean {
|
||||
var item = this.getItem(element);
|
||||
let item = this.getItem(element);
|
||||
|
||||
if (!item) {
|
||||
return false;
|
||||
|
@ -1094,9 +1094,9 @@ export class TreeModel {
|
|||
}
|
||||
|
||||
public getExpandedElements(): any[] {
|
||||
var result: any[] = [];
|
||||
var item: Item;
|
||||
var nav = this.getNavigator();
|
||||
let result: any[] = [];
|
||||
let item: Item;
|
||||
let nav = this.getNavigator();
|
||||
|
||||
while (item = nav.next()) {
|
||||
if (item.isExpanded()) {
|
||||
|
@ -1109,7 +1109,7 @@ export class TreeModel {
|
|||
|
||||
public reveal(element: any, relativeTop: number | null = null): Promise<any> {
|
||||
return this.resolveUnknownParentChain(element).then((chain: any[]) => {
|
||||
var result = Promise.resolve(null);
|
||||
let result = Promise.resolve(null);
|
||||
|
||||
chain.forEach((e) => {
|
||||
result = result.then(() => this.expand(e));
|
||||
|
@ -1117,7 +1117,7 @@ export class TreeModel {
|
|||
|
||||
return result;
|
||||
}).then(() => {
|
||||
var item = this.getItem(element);
|
||||
let item = this.getItem(element);
|
||||
|
||||
if (item) {
|
||||
return item.reveal(relativeTop);
|
||||
|
@ -1140,17 +1140,17 @@ export class TreeModel {
|
|||
|
||||
public setHighlight(element?: any, eventPayload?: any): void {
|
||||
this.setTraits('highlighted', element ? [element] : []);
|
||||
var eventData: _.IHighlightEvent = { highlight: this.getHighlight(), payload: eventPayload };
|
||||
let eventData: _.IHighlightEvent = { highlight: this.getHighlight(), payload: eventPayload };
|
||||
this._onDidHighlight.fire(eventData);
|
||||
}
|
||||
|
||||
public getHighlight(includeHidden?: boolean): any {
|
||||
var result = this.getElementsWithTrait('highlighted', includeHidden);
|
||||
let result = this.getElementsWithTrait('highlighted', includeHidden);
|
||||
return result.length === 0 ? null : result[0];
|
||||
}
|
||||
|
||||
public isHighlighted(element: any): boolean {
|
||||
var item = this.getItem(element);
|
||||
let item = this.getItem(element);
|
||||
|
||||
if (!item) {
|
||||
return false;
|
||||
|
@ -1164,8 +1164,8 @@ export class TreeModel {
|
|||
}
|
||||
|
||||
public selectRange(fromElement: any, toElement: any, eventPayload?: any): void {
|
||||
var fromItem = this.getItem(fromElement);
|
||||
var toItem = this.getItem(toElement);
|
||||
let fromItem = this.getItem(fromElement);
|
||||
let toItem = this.getItem(toElement);
|
||||
|
||||
if (!fromItem || !toItem) {
|
||||
return;
|
||||
|
@ -1175,8 +1175,8 @@ export class TreeModel {
|
|||
}
|
||||
|
||||
public deselectRange(fromElement: any, toElement: any, eventPayload?: any): void {
|
||||
var fromItem = this.getItem(fromElement);
|
||||
var toItem = this.getItem(toElement);
|
||||
let fromItem = this.getItem(fromElement);
|
||||
let toItem = this.getItem(toElement);
|
||||
|
||||
if (!fromItem || !toItem) {
|
||||
return;
|
||||
|
@ -1187,7 +1187,7 @@ export class TreeModel {
|
|||
|
||||
public selectAll(elements: any[], eventPayload?: any): void {
|
||||
this.addTraits('selected', elements);
|
||||
var eventData: _.ISelectionEvent = { selection: this.getSelection(), payload: eventPayload };
|
||||
let eventData: _.ISelectionEvent = { selection: this.getSelection(), payload: eventPayload };
|
||||
this._onDidSelect.fire(eventData);
|
||||
}
|
||||
|
||||
|
@ -1197,24 +1197,24 @@ export class TreeModel {
|
|||
|
||||
public deselectAll(elements: any[], eventPayload?: any): void {
|
||||
this.removeTraits('selected', elements);
|
||||
var eventData: _.ISelectionEvent = { selection: this.getSelection(), payload: eventPayload };
|
||||
let eventData: _.ISelectionEvent = { selection: this.getSelection(), payload: eventPayload };
|
||||
this._onDidSelect.fire(eventData);
|
||||
}
|
||||
|
||||
public setSelection(elements: any[], eventPayload?: any): void {
|
||||
this.setTraits('selected', elements);
|
||||
var eventData: _.ISelectionEvent = { selection: this.getSelection(), payload: eventPayload };
|
||||
let eventData: _.ISelectionEvent = { selection: this.getSelection(), payload: eventPayload };
|
||||
this._onDidSelect.fire(eventData);
|
||||
}
|
||||
|
||||
public toggleSelection(element: any, eventPayload?: any): void {
|
||||
this.toggleTrait('selected', element);
|
||||
var eventData: _.ISelectionEvent = { selection: this.getSelection(), payload: eventPayload };
|
||||
let eventData: _.ISelectionEvent = { selection: this.getSelection(), payload: eventPayload };
|
||||
this._onDidSelect.fire(eventData);
|
||||
}
|
||||
|
||||
public isSelected(element: any): boolean {
|
||||
var item = this.getItem(element);
|
||||
let item = this.getItem(element);
|
||||
|
||||
if (!item) {
|
||||
return false;
|
||||
|
@ -1228,12 +1228,12 @@ export class TreeModel {
|
|||
}
|
||||
|
||||
public selectNext(count: number = 1, clearSelection: boolean = true, eventPayload?: any): void {
|
||||
var selection = this.getSelection();
|
||||
var item: Item = selection.length > 0 ? selection[0] : this.input;
|
||||
var nextItem: Item;
|
||||
var nav = this.getNavigator(item, false);
|
||||
let selection = this.getSelection();
|
||||
let item: Item = selection.length > 0 ? selection[0] : this.input;
|
||||
let nextItem: Item;
|
||||
let nav = this.getNavigator(item, false);
|
||||
|
||||
for (var i = 0; i < count; i++) {
|
||||
for (let i = 0; i < count; i++) {
|
||||
nextItem = nav.next();
|
||||
if (!nextItem) {
|
||||
break;
|
||||
|
@ -1249,7 +1249,7 @@ export class TreeModel {
|
|||
}
|
||||
|
||||
public selectPrevious(count: number = 1, clearSelection: boolean = true, eventPayload?: any): void {
|
||||
var selection = this.getSelection(),
|
||||
let selection = this.getSelection(),
|
||||
item: Item | null = null,
|
||||
previousItem: Item | null = null;
|
||||
|
||||
|
@ -1266,7 +1266,7 @@ export class TreeModel {
|
|||
item = selection[0];
|
||||
let nav = this.getNavigator(item, false);
|
||||
|
||||
for (var i = 0; i < count; i++) {
|
||||
for (let i = 0; i < count; i++) {
|
||||
previousItem = nav.previous();
|
||||
if (!previousItem) {
|
||||
break;
|
||||
|
@ -1283,10 +1283,10 @@ export class TreeModel {
|
|||
}
|
||||
|
||||
public selectParent(eventPayload?: any, clearSelection: boolean = true): void {
|
||||
var selection = this.getSelection();
|
||||
var item: Item = selection.length > 0 ? selection[0] : this.input;
|
||||
var nav = this.getNavigator(item, false);
|
||||
var parent = nav.parent();
|
||||
let selection = this.getSelection();
|
||||
let item: Item = selection.length > 0 ? selection[0] : this.input;
|
||||
let nav = this.getNavigator(item, false);
|
||||
let parent = nav.parent();
|
||||
|
||||
if (parent) {
|
||||
if (clearSelection) {
|
||||
|
@ -1299,12 +1299,12 @@ export class TreeModel {
|
|||
|
||||
public setFocus(element?: any, eventPayload?: any): void {
|
||||
this.setTraits('focused', element ? [element] : []);
|
||||
var eventData: _.IFocusEvent = { focus: this.getFocus(), payload: eventPayload };
|
||||
let eventData: _.IFocusEvent = { focus: this.getFocus(), payload: eventPayload };
|
||||
this._onDidFocus.fire(eventData);
|
||||
}
|
||||
|
||||
public isFocused(element: any): boolean {
|
||||
var item = this.getItem(element);
|
||||
let item = this.getItem(element);
|
||||
|
||||
if (!item) {
|
||||
return false;
|
||||
|
@ -1314,16 +1314,16 @@ export class TreeModel {
|
|||
}
|
||||
|
||||
public getFocus(includeHidden?: boolean): any {
|
||||
var result = this.getElementsWithTrait('focused', includeHidden);
|
||||
let result = this.getElementsWithTrait('focused', includeHidden);
|
||||
return result.length === 0 ? null : result[0];
|
||||
}
|
||||
|
||||
public focusNext(count: number = 1, eventPayload?: any): void {
|
||||
var item: Item = this.getFocus() || this.input;
|
||||
var nextItem: Item;
|
||||
var nav = this.getNavigator(item, false);
|
||||
let item: Item = this.getFocus() || this.input;
|
||||
let nextItem: Item;
|
||||
let nav = this.getNavigator(item, false);
|
||||
|
||||
for (var i = 0; i < count; i++) {
|
||||
for (let i = 0; i < count; i++) {
|
||||
nextItem = nav.next();
|
||||
if (!nextItem) {
|
||||
break;
|
||||
|
@ -1335,11 +1335,11 @@ export class TreeModel {
|
|||
}
|
||||
|
||||
public focusPrevious(count: number = 1, eventPayload?: any): void {
|
||||
var item: Item = this.getFocus() || this.input;
|
||||
var previousItem: Item;
|
||||
var nav = this.getNavigator(item, false);
|
||||
let item: Item = this.getFocus() || this.input;
|
||||
let previousItem: Item;
|
||||
let nav = this.getNavigator(item, false);
|
||||
|
||||
for (var i = 0; i < count; i++) {
|
||||
for (let i = 0; i < count; i++) {
|
||||
previousItem = nav.previous();
|
||||
if (!previousItem) {
|
||||
break;
|
||||
|
@ -1351,9 +1351,9 @@ export class TreeModel {
|
|||
}
|
||||
|
||||
public focusParent(eventPayload?: any): void {
|
||||
var item: Item = this.getFocus() || this.input;
|
||||
var nav = this.getNavigator(item, false);
|
||||
var parent = nav.parent();
|
||||
let item: Item = this.getFocus() || this.input;
|
||||
let nav = this.getNavigator(item, false);
|
||||
let parent = nav.parent();
|
||||
|
||||
if (parent) {
|
||||
this.setFocus(parent, eventPayload);
|
||||
|
@ -1376,10 +1376,10 @@ export class TreeModel {
|
|||
}
|
||||
|
||||
public focusNth(index: number, eventPayload?: any, from?: any): void {
|
||||
var navItem = this.getParent(from);
|
||||
var nav = this.getNavigator(navItem);
|
||||
var item = nav.first();
|
||||
for (var i = 0; i < index; i++) {
|
||||
let navItem = this.getParent(from);
|
||||
let nav = this.getNavigator(navItem);
|
||||
let item = nav.first();
|
||||
for (let i = 0; i < index; i++) {
|
||||
item = nav.next();
|
||||
}
|
||||
|
||||
|
@ -1389,12 +1389,12 @@ export class TreeModel {
|
|||
}
|
||||
|
||||
public focusLast(eventPayload?: any, from?: any): void {
|
||||
var navItem = this.getParent(from);
|
||||
var item: Item;
|
||||
let navItem = this.getParent(from);
|
||||
let item: Item;
|
||||
if (from) {
|
||||
item = navItem.lastChild;
|
||||
} else {
|
||||
var nav = this.getNavigator(navItem);
|
||||
let nav = this.getNavigator(navItem);
|
||||
item = nav.last();
|
||||
}
|
||||
|
||||
|
@ -1405,7 +1405,7 @@ export class TreeModel {
|
|||
|
||||
private getParent(from?: any): Item {
|
||||
if (from) {
|
||||
var fromItem = this.getItem(from);
|
||||
let fromItem = this.getItem(from);
|
||||
if (fromItem && fromItem.parent) {
|
||||
return fromItem.parent;
|
||||
}
|
||||
|
@ -1431,9 +1431,9 @@ export class TreeModel {
|
|||
}
|
||||
|
||||
public addTraits(trait: string, elements: any[]): void {
|
||||
var items: IItemMap = this.traitsToItems[trait] || <IItemMap>{};
|
||||
var item: Item;
|
||||
for (var i = 0, len = elements.length; i < len; i++) {
|
||||
let items: IItemMap = this.traitsToItems[trait] || <IItemMap>{};
|
||||
let item: Item;
|
||||
for (let i = 0, len = elements.length; i < len; i++) {
|
||||
item = this.getItem(elements[i]);
|
||||
|
||||
if (item) {
|
||||
|
@ -1445,9 +1445,9 @@ export class TreeModel {
|
|||
}
|
||||
|
||||
public removeTraits(trait: string, elements: any[]): void {
|
||||
var items: IItemMap = this.traitsToItems[trait] || <IItemMap>{};
|
||||
var item: Item;
|
||||
var id: string;
|
||||
let items: IItemMap = this.traitsToItems[trait] || <IItemMap>{};
|
||||
let item: Item;
|
||||
let id: string;
|
||||
|
||||
if (elements.length === 0) {
|
||||
for (id in items) {
|
||||
|
@ -1460,7 +1460,7 @@ export class TreeModel {
|
|||
delete this.traitsToItems[trait];
|
||||
|
||||
} else {
|
||||
for (var i = 0, len = elements.length; i < len; i++) {
|
||||
for (let i = 0, len = elements.length; i < len; i++) {
|
||||
item = this.getItem(elements[i]);
|
||||
|
||||
if (item) {
|
||||
|
@ -1472,12 +1472,12 @@ export class TreeModel {
|
|||
}
|
||||
|
||||
public hasTrait(trait: string, element: any): boolean {
|
||||
var item = this.getItem(element);
|
||||
let item = this.getItem(element);
|
||||
return item && item.hasTrait(trait);
|
||||
}
|
||||
|
||||
private toggleTrait(trait: string, element: any): void {
|
||||
var item = this.getItem(element);
|
||||
let item = this.getItem(element);
|
||||
|
||||
if (!item) {
|
||||
return;
|
||||
|
@ -1494,8 +1494,8 @@ export class TreeModel {
|
|||
if (elements.length === 0) {
|
||||
this.removeTraits(trait, elements);
|
||||
} else {
|
||||
var items: { [id: string]: Item; } = {};
|
||||
var item: Item;
|
||||
let items: { [id: string]: Item; } = {};
|
||||
let item: Item;
|
||||
|
||||
for (let i = 0, len = elements.length; i < len; i++) {
|
||||
item = this.getItem(elements[i]);
|
||||
|
@ -1505,9 +1505,9 @@ export class TreeModel {
|
|||
}
|
||||
}
|
||||
|
||||
var traitItems: IItemMap = this.traitsToItems[trait] || <IItemMap>{};
|
||||
var itemsToRemoveTrait: Item[] = [];
|
||||
var id: string;
|
||||
let traitItems: IItemMap = this.traitsToItems[trait] || <IItemMap>{};
|
||||
let itemsToRemoveTrait: Item[] = [];
|
||||
let id: string;
|
||||
|
||||
for (id in traitItems) {
|
||||
if (traitItems.hasOwnProperty(id)) {
|
||||
|
@ -1538,9 +1538,9 @@ export class TreeModel {
|
|||
}
|
||||
|
||||
private getElementsWithTrait(trait: string, includeHidden: boolean): any[] {
|
||||
var elements = [];
|
||||
var items = this.traitsToItems[trait] || {};
|
||||
var id: string;
|
||||
let elements = [];
|
||||
let items = this.traitsToItems[trait] || {};
|
||||
let id: string;
|
||||
for (id in items) {
|
||||
if (items.hasOwnProperty(id) && (items[id].isVisible() || includeHidden)) {
|
||||
elements.push(items[id].getElement());
|
||||
|
|
|
@ -48,13 +48,13 @@ export class RowCache implements Lifecycle.IDisposable {
|
|||
}
|
||||
|
||||
public alloc(templateId: string): IRow {
|
||||
var result = this.cache(templateId).pop();
|
||||
let result = this.cache(templateId).pop();
|
||||
|
||||
if (!result) {
|
||||
var content = document.createElement('div');
|
||||
let content = document.createElement('div');
|
||||
content.className = 'content';
|
||||
|
||||
var row = document.createElement('div');
|
||||
let row = document.createElement('div');
|
||||
row.appendChild(content);
|
||||
|
||||
let templateData: any = null;
|
||||
|
@ -195,7 +195,7 @@ export class ViewItem implements IViewItem {
|
|||
return;
|
||||
}
|
||||
|
||||
var classes = ['monaco-tree-row'];
|
||||
let classes = ['monaco-tree-row'];
|
||||
classes.push.apply(classes, Object.keys(this._styles));
|
||||
|
||||
if (this.model.hasChildren()) {
|
||||
|
@ -240,7 +240,7 @@ export class ViewItem implements IViewItem {
|
|||
(<HTMLElement>this.row.element.firstElementChild).style.paddingLeft = this.context.options.twistiePixels + 'px';
|
||||
}
|
||||
|
||||
var uri = this.context.dnd.getDragURI(this.context.tree, this.model.getElement());
|
||||
let uri = this.context.dnd.getDragURI(this.context.tree, this.model.getElement());
|
||||
|
||||
if (uri !== this.uri) {
|
||||
if (this.unbindDragStart) {
|
||||
|
@ -362,7 +362,7 @@ class RootViewItem extends ViewItem {
|
|||
return;
|
||||
}
|
||||
|
||||
var classes = ['monaco-tree-wrapper'];
|
||||
let classes = ['monaco-tree-wrapper'];
|
||||
classes.push.apply(classes, Object.keys(this._styles));
|
||||
|
||||
if (this.model.hasChildren()) {
|
||||
|
@ -544,7 +544,7 @@ export class TreeView extends HeightMap {
|
|||
this.rowsContainer.className += ' show-twisties';
|
||||
}
|
||||
|
||||
var focusTracker = DOM.trackFocus(this.domNode);
|
||||
let focusTracker = DOM.trackFocus(this.domNode);
|
||||
this.viewListeners.push(focusTracker.onDidFocus(() => this.onFocus()));
|
||||
this.viewListeners.push(focusTracker.onDidBlur(() => this.onBlur()));
|
||||
this.viewListeners.push(focusTracker);
|
||||
|
@ -572,7 +572,7 @@ export class TreeView extends HeightMap {
|
|||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
|
||||
var result = { translationY: event.translationY, translationX: event.translationX };
|
||||
let result = { translationY: event.translationY, translationX: event.translationX };
|
||||
|
||||
if (lastEvent) {
|
||||
result.translationY += lastEvent.translationY;
|
||||
|
@ -694,12 +694,12 @@ export class TreeView extends HeightMap {
|
|||
}
|
||||
|
||||
private render(scrollTop: number, viewHeight: number, scrollLeft: number, viewWidth: number, scrollWidth: number): void {
|
||||
var i: number;
|
||||
var stop: number;
|
||||
let i: number;
|
||||
let stop: number;
|
||||
|
||||
var renderTop = scrollTop;
|
||||
var renderBottom = scrollTop + viewHeight;
|
||||
var thisRenderBottom = this.lastRenderTop + this.lastRenderHeight;
|
||||
let renderTop = scrollTop;
|
||||
let renderBottom = scrollTop + viewHeight;
|
||||
let thisRenderBottom = this.lastRenderTop + this.lastRenderHeight;
|
||||
|
||||
// when view scrolls down, start rendering from the renderBottom
|
||||
for (i = this.indexAfter(renderBottom) - 1, stop = this.indexAt(Math.max(thisRenderBottom, renderTop)); i >= stop; i--) {
|
||||
|
@ -721,7 +721,7 @@ export class TreeView extends HeightMap {
|
|||
this.removeItemFromDOM(<ViewItem>this.itemAtIndex(i));
|
||||
}
|
||||
|
||||
var topItem = this.itemAtIndex(this.indexAt(renderTop));
|
||||
let topItem = this.itemAtIndex(this.indexAt(renderTop));
|
||||
|
||||
if (topItem) {
|
||||
this.rowsContainer.style.top = (topItem.top - renderTop) + 'px';
|
||||
|
@ -793,15 +793,15 @@ export class TreeView extends HeightMap {
|
|||
}
|
||||
|
||||
public focusNextPage(eventPayload?: any): void {
|
||||
var lastPageIndex = this.indexAt(this.scrollTop + this.viewHeight);
|
||||
let lastPageIndex = this.indexAt(this.scrollTop + this.viewHeight);
|
||||
lastPageIndex = lastPageIndex === 0 ? 0 : lastPageIndex - 1;
|
||||
var lastPageElement = this.itemAtIndex(lastPageIndex).model.getElement();
|
||||
var currentlyFocusedElement = this.model.getFocus();
|
||||
let lastPageElement = this.itemAtIndex(lastPageIndex).model.getElement();
|
||||
let currentlyFocusedElement = this.model.getFocus();
|
||||
|
||||
if (currentlyFocusedElement !== lastPageElement) {
|
||||
this.model.setFocus(lastPageElement, eventPayload);
|
||||
} else {
|
||||
var previousScrollTop = this.scrollTop;
|
||||
let previousScrollTop = this.scrollTop;
|
||||
this.scrollTop += this.viewHeight;
|
||||
|
||||
if (this.scrollTop !== previousScrollTop) {
|
||||
|
@ -815,7 +815,7 @@ export class TreeView extends HeightMap {
|
|||
}
|
||||
|
||||
public focusPreviousPage(eventPayload?: any): void {
|
||||
var firstPageIndex: number;
|
||||
let firstPageIndex: number;
|
||||
|
||||
if (this.scrollTop === 0) {
|
||||
firstPageIndex = this.indexAt(this.scrollTop);
|
||||
|
@ -823,13 +823,13 @@ export class TreeView extends HeightMap {
|
|||
firstPageIndex = this.indexAfter(this.scrollTop - 1);
|
||||
}
|
||||
|
||||
var firstPageElement = this.itemAtIndex(firstPageIndex).model.getElement();
|
||||
var currentlyFocusedElement = this.model.getFocus();
|
||||
let firstPageElement = this.itemAtIndex(firstPageIndex).model.getElement();
|
||||
let currentlyFocusedElement = this.model.getFocus();
|
||||
|
||||
if (currentlyFocusedElement !== firstPageElement) {
|
||||
this.model.setFocus(firstPageElement, eventPayload);
|
||||
} else {
|
||||
var previousScrollTop = this.scrollTop;
|
||||
let previousScrollTop = this.scrollTop;
|
||||
this.scrollTop -= this.viewHeight;
|
||||
|
||||
if (this.scrollTop !== previousScrollTop) {
|
||||
|
@ -893,7 +893,7 @@ export class TreeView extends HeightMap {
|
|||
// Events
|
||||
|
||||
private onClearingInput(e: Model.IInputEvent): void {
|
||||
var item = <Model.Item>e.item;
|
||||
let item = <Model.Item>e.item;
|
||||
if (item) {
|
||||
this.onRemoveItems(new MappedIterator(item.getNavigator(), item => item && item.id));
|
||||
this.onRowsChanged();
|
||||
|
@ -906,8 +906,8 @@ export class TreeView extends HeightMap {
|
|||
}
|
||||
|
||||
private onItemChildrenRefreshing(e: Model.IItemChildrenRefreshEvent): void {
|
||||
var item = <Model.Item>e.item;
|
||||
var viewItem = this.items[item.id];
|
||||
let item = <Model.Item>e.item;
|
||||
let viewItem = this.items[item.id];
|
||||
|
||||
if (viewItem && this.context.options.showLoading) {
|
||||
viewItem.loadingTimer = setTimeout(() => {
|
||||
|
@ -917,9 +917,9 @@ export class TreeView extends HeightMap {
|
|||
}
|
||||
|
||||
if (!e.isNested) {
|
||||
var childrenIds: string[] = [];
|
||||
var navigator = item.getNavigator();
|
||||
var childItem: Model.Item;
|
||||
let childrenIds: string[] = [];
|
||||
let navigator = item.getNavigator();
|
||||
let childItem: Model.Item;
|
||||
|
||||
while (childItem = navigator.next()) {
|
||||
childrenIds.push(childItem.id);
|
||||
|
@ -930,8 +930,8 @@ export class TreeView extends HeightMap {
|
|||
}
|
||||
|
||||
private onItemChildrenRefreshed(e: Model.IItemChildrenRefreshEvent): void {
|
||||
var item = <Model.Item>e.item;
|
||||
var viewItem = this.items[item.id];
|
||||
let item = <Model.Item>e.item;
|
||||
let viewItem = this.items[item.id];
|
||||
|
||||
if (viewItem) {
|
||||
if (viewItem.loadingTimer) {
|
||||
|
@ -943,10 +943,10 @@ export class TreeView extends HeightMap {
|
|||
}
|
||||
|
||||
if (!e.isNested) {
|
||||
var previousChildrenIds = this.refreshingPreviousChildrenIds[item.id];
|
||||
var afterModelItems: Model.Item[] = [];
|
||||
var navigator = item.getNavigator();
|
||||
var childItem: Model.Item;
|
||||
let previousChildrenIds = this.refreshingPreviousChildrenIds[item.id];
|
||||
let afterModelItems: Model.Item[] = [];
|
||||
let navigator = item.getNavigator();
|
||||
let childItem: Model.Item;
|
||||
|
||||
while (childItem = navigator.next()) {
|
||||
afterModelItems.push(childItem);
|
||||
|
@ -976,7 +976,7 @@ export class TreeView extends HeightMap {
|
|||
// of the elements has changed
|
||||
doToInsertItemsAlreadyExist = diff.some(d => {
|
||||
if (d.modifiedLength > 0) {
|
||||
for (var i = d.modifiedStart, len = d.modifiedStart + d.modifiedLength; i < len; i++) {
|
||||
for (let i = d.modifiedStart, len = d.modifiedStart + d.modifiedLength; i < len; i++) {
|
||||
if (this.items.hasOwnProperty(afterModelItems[i].id)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -1025,20 +1025,20 @@ export class TreeView extends HeightMap {
|
|||
}
|
||||
|
||||
private onItemExpanding(e: Model.IItemExpandEvent): void {
|
||||
var viewItem = this.items[e.item.id];
|
||||
let viewItem = this.items[e.item.id];
|
||||
if (viewItem) {
|
||||
viewItem.expanded = true;
|
||||
}
|
||||
}
|
||||
|
||||
private onItemExpanded(e: Model.IItemExpandEvent): void {
|
||||
var item = <Model.Item>e.item;
|
||||
var viewItem = this.items[item.id];
|
||||
let item = <Model.Item>e.item;
|
||||
let viewItem = this.items[item.id];
|
||||
if (viewItem) {
|
||||
viewItem.expanded = true;
|
||||
|
||||
var height = this.onInsertItems(item.getNavigator(), item.id);
|
||||
var scrollTop = this.scrollTop;
|
||||
let height = this.onInsertItems(item.getNavigator(), item.id);
|
||||
let scrollTop = this.scrollTop;
|
||||
|
||||
if (viewItem.top + viewItem.height <= this.scrollTop) {
|
||||
scrollTop += height;
|
||||
|
@ -1049,8 +1049,8 @@ export class TreeView extends HeightMap {
|
|||
}
|
||||
|
||||
private onItemCollapsing(e: Model.IItemCollapseEvent): void {
|
||||
var item = <Model.Item>e.item;
|
||||
var viewItem = this.items[item.id];
|
||||
let item = <Model.Item>e.item;
|
||||
let viewItem = this.items[item.id];
|
||||
if (viewItem) {
|
||||
viewItem.expanded = false;
|
||||
this.onRemoveItems(new MappedIterator(item.getNavigator(), item => item && item.id));
|
||||
|
@ -1075,7 +1075,7 @@ export class TreeView extends HeightMap {
|
|||
|
||||
public getRelativeTop(item: Model.Item): number {
|
||||
if (item && item.isVisible()) {
|
||||
var viewItem = this.items[item.id];
|
||||
let viewItem = this.items[item.id];
|
||||
if (viewItem) {
|
||||
return (viewItem.top - this.scrollTop) / (this.viewHeight - viewItem.height);
|
||||
}
|
||||
|
@ -1084,20 +1084,20 @@ export class TreeView extends HeightMap {
|
|||
}
|
||||
|
||||
private onItemReveal(e: Model.IItemRevealEvent): void {
|
||||
var item = <Model.Item>e.item;
|
||||
var relativeTop = <number>e.relativeTop;
|
||||
var viewItem = this.items[item.id];
|
||||
let item = <Model.Item>e.item;
|
||||
let relativeTop = <number>e.relativeTop;
|
||||
let viewItem = this.items[item.id];
|
||||
if (viewItem) {
|
||||
if (relativeTop !== null) {
|
||||
relativeTop = relativeTop < 0 ? 0 : relativeTop;
|
||||
relativeTop = relativeTop > 1 ? 1 : relativeTop;
|
||||
|
||||
// y = mx + b
|
||||
var m = viewItem.height - this.viewHeight;
|
||||
let m = viewItem.height - this.viewHeight;
|
||||
this.scrollTop = m * relativeTop + viewItem.top;
|
||||
} else {
|
||||
var viewItemBottom = viewItem.top + viewItem.height;
|
||||
var wrapperBottom = this.scrollTop + this.viewHeight;
|
||||
let viewItemBottom = viewItem.top + viewItem.height;
|
||||
let wrapperBottom = this.scrollTop + this.viewHeight;
|
||||
|
||||
if (viewItem.top < this.scrollTop) {
|
||||
this.scrollTop = viewItem.top;
|
||||
|
@ -1109,9 +1109,9 @@ export class TreeView extends HeightMap {
|
|||
}
|
||||
|
||||
private onItemAddTrait(e: Model.IItemTraitEvent): void {
|
||||
var item = <Model.Item>e.item;
|
||||
var trait = <string>e.trait;
|
||||
var viewItem = this.items[item.id];
|
||||
let item = <Model.Item>e.item;
|
||||
let trait = <string>e.trait;
|
||||
let viewItem = this.items[item.id];
|
||||
if (viewItem) {
|
||||
viewItem.addClass(trait);
|
||||
}
|
||||
|
@ -1129,9 +1129,9 @@ export class TreeView extends HeightMap {
|
|||
}
|
||||
|
||||
private onItemRemoveTrait(e: Model.IItemTraitEvent): void {
|
||||
var item = <Model.Item>e.item;
|
||||
var trait = <string>e.trait;
|
||||
var viewItem = this.items[item.id];
|
||||
let item = <Model.Item>e.item;
|
||||
let trait = <string>e.trait;
|
||||
let viewItem = this.items[item.id];
|
||||
if (viewItem) {
|
||||
viewItem.removeClass(trait);
|
||||
}
|
||||
|
@ -1198,8 +1198,8 @@ export class TreeView extends HeightMap {
|
|||
return;
|
||||
}
|
||||
|
||||
var event = new Mouse.StandardMouseEvent(e);
|
||||
var item = this.getItemAround(event.target);
|
||||
let event = new Mouse.StandardMouseEvent(e);
|
||||
let item = this.getItemAround(event.target);
|
||||
|
||||
if (!item) {
|
||||
return;
|
||||
|
@ -1222,8 +1222,8 @@ export class TreeView extends HeightMap {
|
|||
return;
|
||||
}
|
||||
|
||||
var event = new Mouse.StandardMouseEvent(e);
|
||||
var item = this.getItemAround(event.target);
|
||||
let event = new Mouse.StandardMouseEvent(e);
|
||||
let item = this.getItemAround(event.target);
|
||||
|
||||
if (!item) {
|
||||
return;
|
||||
|
@ -1242,13 +1242,13 @@ export class TreeView extends HeightMap {
|
|||
return;
|
||||
}
|
||||
|
||||
var event = new Mouse.StandardMouseEvent(e);
|
||||
let event = new Mouse.StandardMouseEvent(e);
|
||||
|
||||
if (event.ctrlKey && Platform.isNative && Platform.isMacintosh) {
|
||||
return;
|
||||
}
|
||||
|
||||
var item = this.getItemAround(event.target);
|
||||
let item = this.getItemAround(event.target);
|
||||
|
||||
if (!item) {
|
||||
return;
|
||||
|
@ -1266,13 +1266,13 @@ export class TreeView extends HeightMap {
|
|||
return;
|
||||
}
|
||||
|
||||
var event = new Mouse.StandardMouseEvent(e);
|
||||
let event = new Mouse.StandardMouseEvent(e);
|
||||
|
||||
if (event.ctrlKey && Platform.isNative && Platform.isMacintosh) {
|
||||
return;
|
||||
}
|
||||
|
||||
var item = this.getItemAround(event.target);
|
||||
let item = this.getItemAround(event.target);
|
||||
|
||||
if (!item) {
|
||||
return;
|
||||
|
@ -1282,7 +1282,7 @@ export class TreeView extends HeightMap {
|
|||
}
|
||||
|
||||
private onTap(e: Touch.GestureEvent): void {
|
||||
var item = this.getItemAround(<HTMLElement>e.initialTarget);
|
||||
let item = this.getItemAround(<HTMLElement>e.initialTarget);
|
||||
|
||||
if (!item) {
|
||||
return;
|
||||
|
@ -1301,31 +1301,31 @@ export class TreeView extends HeightMap {
|
|||
private onContextMenu(keyboardEvent: KeyboardEvent): void;
|
||||
private onContextMenu(mouseEvent: MouseEvent): void;
|
||||
private onContextMenu(event: KeyboardEvent | MouseEvent): void {
|
||||
var resultEvent: _.ContextMenuEvent;
|
||||
var element: any;
|
||||
let resultEvent: _.ContextMenuEvent;
|
||||
let element: any;
|
||||
|
||||
if (event instanceof KeyboardEvent || this.didJustPressContextMenuKey) {
|
||||
this.didJustPressContextMenuKey = false;
|
||||
|
||||
var keyboardEvent = new Keyboard.StandardKeyboardEvent(<KeyboardEvent>event);
|
||||
let keyboardEvent = new Keyboard.StandardKeyboardEvent(<KeyboardEvent>event);
|
||||
element = this.model.getFocus();
|
||||
|
||||
var position: DOM.IDomNodePagePosition;
|
||||
let position: DOM.IDomNodePagePosition;
|
||||
|
||||
if (!element) {
|
||||
element = this.model.getInput();
|
||||
position = DOM.getDomNodePagePosition(this.inputItem.element);
|
||||
} else {
|
||||
var id = this.context.dataSource.getId(this.context.tree, element);
|
||||
var viewItem = this.items[id];
|
||||
let id = this.context.dataSource.getId(this.context.tree, element);
|
||||
let viewItem = this.items[id];
|
||||
position = DOM.getDomNodePagePosition(viewItem.element);
|
||||
}
|
||||
|
||||
resultEvent = new _.KeyboardContextMenuEvent(position.left + position.width, position.top, keyboardEvent);
|
||||
|
||||
} else {
|
||||
var mouseEvent = new Mouse.StandardMouseEvent(<MouseEvent>event);
|
||||
var item = this.getItemAround(mouseEvent.target);
|
||||
let mouseEvent = new Mouse.StandardMouseEvent(<MouseEvent>event);
|
||||
let item = this.getItemAround(mouseEvent.target);
|
||||
|
||||
if (!item) {
|
||||
return;
|
||||
|
@ -1339,7 +1339,7 @@ export class TreeView extends HeightMap {
|
|||
}
|
||||
|
||||
private onKeyDown(e: KeyboardEvent): void {
|
||||
var event = new Keyboard.StandardKeyboardEvent(e);
|
||||
let event = new Keyboard.StandardKeyboardEvent(e);
|
||||
|
||||
this.didJustPressContextMenuKey = event.keyCode === KeyCode.ContextMenu || (event.shiftKey && event.keyCode === KeyCode.F10);
|
||||
|
||||
|
@ -1369,9 +1369,9 @@ export class TreeView extends HeightMap {
|
|||
return;
|
||||
}
|
||||
|
||||
var element = item.model.getElement();
|
||||
var selection = this.model.getSelection();
|
||||
var elements: any[];
|
||||
let element = item.model.getElement();
|
||||
let selection = this.model.getSelection();
|
||||
let elements: any[];
|
||||
|
||||
if (selection.indexOf(element) > -1) {
|
||||
elements = selection;
|
||||
|
@ -1405,7 +1405,7 @@ export class TreeView extends HeightMap {
|
|||
}
|
||||
|
||||
private setupDragAndDropScrollInterval(): void {
|
||||
var viewTop = DOM.getTopLeftOffset(this.wrapper).top;
|
||||
let viewTop = DOM.getTopLeftOffset(this.wrapper).top;
|
||||
|
||||
if (!this.dragAndDropScrollInterval) {
|
||||
this.dragAndDropScrollInterval = window.setInterval(() => {
|
||||
|
@ -1413,9 +1413,9 @@ export class TreeView extends HeightMap {
|
|||
return;
|
||||
}
|
||||
|
||||
var diff = this.dragAndDropMouseY - viewTop;
|
||||
var scrollDiff = 0;
|
||||
var upperLimit = this.viewHeight - 35;
|
||||
let diff = this.dragAndDropMouseY - viewTop;
|
||||
let scrollDiff = 0;
|
||||
let upperLimit = this.viewHeight - 35;
|
||||
|
||||
if (diff < 35) {
|
||||
scrollDiff = Math.max(-14, 0.2 * (diff - 35));
|
||||
|
@ -1452,9 +1452,9 @@ export class TreeView extends HeightMap {
|
|||
}
|
||||
|
||||
private onDragOver(e: DragEvent): boolean {
|
||||
var event = new Mouse.DragMouseEvent(e);
|
||||
let event = new Mouse.DragMouseEvent(e);
|
||||
|
||||
var viewItem = this.getItemAround(event.target);
|
||||
let viewItem = this.getItemAround(event.target);
|
||||
|
||||
if (!viewItem || (event.posx === 0 && event.posy === 0 && event.browserEvent.type === DOM.EventType.DRAG_LEAVE)) {
|
||||
// dragging outside of tree
|
||||
|
@ -1495,9 +1495,9 @@ export class TreeView extends HeightMap {
|
|||
|
||||
this.currentDragAndDropData.update(event);
|
||||
|
||||
var element: any;
|
||||
var item: Model.Item = viewItem.model;
|
||||
var reaction: _.IDragOverReaction;
|
||||
let element: any;
|
||||
let item: Model.Item = viewItem.model;
|
||||
let reaction: _.IDragOverReaction;
|
||||
|
||||
// check the bubble up behavior
|
||||
do {
|
||||
|
@ -1516,7 +1516,7 @@ export class TreeView extends HeightMap {
|
|||
return false;
|
||||
}
|
||||
|
||||
var canDrop = reaction && reaction.accept;
|
||||
let canDrop = reaction && reaction.accept;
|
||||
|
||||
if (canDrop) {
|
||||
this.currentDropElement = item.getElement();
|
||||
|
@ -1529,7 +1529,7 @@ export class TreeView extends HeightMap {
|
|||
// item is the model item where drop() should be called
|
||||
|
||||
// can be null
|
||||
var currentDropTarget = item.id === this.inputItem.id ? this.inputItem : this.items[item.id];
|
||||
let currentDropTarget = item.id === this.inputItem.id ? this.inputItem : this.items[item.id];
|
||||
|
||||
if (this.shouldInvalidateDropReaction || this.currentDropTarget !== currentDropTarget || !reactionEquals(this.currentDropElementReaction, reaction)) {
|
||||
this.shouldInvalidateDropReaction = false;
|
||||
|
@ -1552,8 +1552,8 @@ export class TreeView extends HeightMap {
|
|||
}
|
||||
|
||||
if (reaction.bubble === _.DragOverBubble.BUBBLE_DOWN) {
|
||||
var nav = item.getNavigator();
|
||||
var child: Model.Item;
|
||||
let nav = item.getNavigator();
|
||||
let child: Model.Item;
|
||||
while (child = nav.next()) {
|
||||
viewItem = this.items[child.id];
|
||||
if (viewItem) {
|
||||
|
@ -1579,7 +1579,7 @@ export class TreeView extends HeightMap {
|
|||
|
||||
private onDrop(e: DragEvent): void {
|
||||
if (this.currentDropElement) {
|
||||
var event = new Mouse.DragMouseEvent(e);
|
||||
let event = new Mouse.DragMouseEvent(e);
|
||||
event.preventDefault();
|
||||
this.currentDragAndDropData.update(event);
|
||||
this.context.dnd.drop(this.context.tree, this.currentDragAndDropData, this.currentDropElement, event);
|
||||
|
@ -1630,7 +1630,7 @@ export class TreeView extends HeightMap {
|
|||
}
|
||||
|
||||
// Circumvent IE11 breaking change in e.pointerType & TypeScript's stale definitions
|
||||
var pointerType = event.pointerType;
|
||||
let pointerType = event.pointerType;
|
||||
if (pointerType === ((<any>event).MSPOINTER_TYPE_MOUSE || 'mouse')) {
|
||||
this.lastPointerType = 'mouse';
|
||||
return;
|
||||
|
@ -1658,8 +1658,8 @@ export class TreeView extends HeightMap {
|
|||
// DOM changes
|
||||
|
||||
private insertItemInDOM(item: ViewItem): void {
|
||||
var elementAfter: HTMLElement | null = null;
|
||||
var itemAfter = <ViewItem>this.itemAfter(item);
|
||||
let elementAfter: HTMLElement | null = null;
|
||||
let itemAfter = <ViewItem>this.itemAfter(item);
|
||||
|
||||
if (itemAfter && itemAfter.element) {
|
||||
elementAfter = itemAfter.element;
|
||||
|
@ -1683,7 +1683,7 @@ export class TreeView extends HeightMap {
|
|||
}
|
||||
|
||||
private getItemAround(element: HTMLElement): ViewItem {
|
||||
var candidate: ViewItem = this.inputItem;
|
||||
let candidate: ViewItem = this.inputItem;
|
||||
do {
|
||||
if ((<any>element)[TreeView.BINDING]) {
|
||||
candidate = (<any>element)[TreeView.BINDING];
|
||||
|
|
|
@ -24,16 +24,16 @@ export class HeightMap {
|
|||
}
|
||||
|
||||
public getContentHeight(): number {
|
||||
var last = this.heightMap[this.heightMap.length - 1];
|
||||
let last = this.heightMap[this.heightMap.length - 1];
|
||||
return !last ? 0 : last.top + last.height;
|
||||
}
|
||||
|
||||
public onInsertItems(iterator: INextIterator<Item>, afterItemId: string | null = null): number {
|
||||
var item: Item;
|
||||
var viewItem: IViewItem;
|
||||
var i: number, j: number;
|
||||
var totalSize: number;
|
||||
var sizeDiff = 0;
|
||||
let item: Item;
|
||||
let viewItem: IViewItem;
|
||||
let i: number, j: number;
|
||||
let totalSize: number;
|
||||
let sizeDiff = 0;
|
||||
|
||||
if (afterItemId === null) {
|
||||
i = 0;
|
||||
|
@ -50,9 +50,9 @@ export class HeightMap {
|
|||
totalSize = viewItem.top + viewItem.height;
|
||||
}
|
||||
|
||||
var boundSplice = this.heightMap.splice.bind(this.heightMap, i, 0);
|
||||
let boundSplice = this.heightMap.splice.bind(this.heightMap, i, 0);
|
||||
|
||||
var itemsToInsert: IViewItem[] = [];
|
||||
let itemsToInsert: IViewItem[] = [];
|
||||
|
||||
while (item = iterator.next()) {
|
||||
viewItem = this.createViewItem(item);
|
||||
|
@ -88,11 +88,11 @@ export class HeightMap {
|
|||
|
||||
// Contiguous items
|
||||
public onRemoveItems(iterator: INextIterator<string>): void {
|
||||
var itemId: string;
|
||||
var viewItem: IViewItem;
|
||||
var startIndex: number | null = null;
|
||||
var i: number;
|
||||
var sizeDiff = 0;
|
||||
let itemId: string;
|
||||
let viewItem: IViewItem;
|
||||
let startIndex: number | null = null;
|
||||
let i: number;
|
||||
let sizeDiff = 0;
|
||||
|
||||
while (itemId = iterator.next()) {
|
||||
i = this.indexes[itemId];
|
||||
|
@ -131,17 +131,17 @@ export class HeightMap {
|
|||
}
|
||||
|
||||
public onRefreshItemSet(items: Item[]): void {
|
||||
var sortedItems = items.sort((a, b) => this.indexes[a.id] - this.indexes[b.id]);
|
||||
let sortedItems = items.sort((a, b) => this.indexes[a.id] - this.indexes[b.id]);
|
||||
this.onRefreshItems(new ArrayIterator(sortedItems));
|
||||
}
|
||||
|
||||
// Ordered, but not necessarily contiguous items
|
||||
public onRefreshItems(iterator: INextIterator<Item>): void {
|
||||
var item: Item;
|
||||
var viewItem: IViewItem;
|
||||
var newHeight: number;
|
||||
var i: number, j: number | null = null;
|
||||
var cummDiff = 0;
|
||||
let item: Item;
|
||||
let viewItem: IViewItem;
|
||||
let newHeight: number;
|
||||
let i: number, j: number | null = null;
|
||||
let cummDiff = 0;
|
||||
|
||||
while (item = iterator.next()) {
|
||||
i = this.indexes[item.id];
|
||||
|
@ -186,16 +186,16 @@ export class HeightMap {
|
|||
public withItemsInRange(start: number, end: number, fn: (item: string) => void): void {
|
||||
start = this.indexAt(start);
|
||||
end = this.indexAt(end);
|
||||
for (var i = start; i <= end; i++) {
|
||||
for (let i = start; i <= end; i++) {
|
||||
fn(this.heightMap[i].model.id);
|
||||
}
|
||||
}
|
||||
|
||||
public indexAt(position: number): number {
|
||||
var left = 0;
|
||||
var right = this.heightMap.length;
|
||||
var center: number;
|
||||
var item: IViewItem;
|
||||
let left = 0;
|
||||
let right = this.heightMap.length;
|
||||
let center: number;
|
||||
let item: IViewItem;
|
||||
|
||||
// Binary search
|
||||
while (left < right) {
|
||||
|
|
|
@ -105,7 +105,7 @@ class EventCounter {
|
|||
}
|
||||
}
|
||||
|
||||
var SAMPLE: any = {
|
||||
const SAMPLE: any = {
|
||||
ONE: { id: 'one' },
|
||||
|
||||
AB: {
|
||||
|
@ -179,8 +179,8 @@ class TestDataSource implements _.IDataSource {
|
|||
}
|
||||
|
||||
suite('TreeModel', () => {
|
||||
var model: model.TreeModel;
|
||||
var counter: EventCounter;
|
||||
let model: model.TreeModel;
|
||||
let counter: EventCounter;
|
||||
|
||||
setup(() => {
|
||||
counter = new EventCounter();
|
||||
|
@ -313,7 +313,7 @@ suite('TreeModel', () => {
|
|||
return model.setInput(SAMPLE.AB).then(() => {
|
||||
return model.expandAll(['a', 'c']).then(() => {
|
||||
// going internals
|
||||
var r = (<any>model).registry;
|
||||
const r = (<any>model).registry;
|
||||
|
||||
assert(r.getItem('a').intersects(r.getItem('a')));
|
||||
assert(r.getItem('a').intersects(r.getItem('aa')));
|
||||
|
@ -331,8 +331,8 @@ suite('TreeModel', () => {
|
|||
});
|
||||
|
||||
suite('TreeModel - TreeNavigator', () => {
|
||||
var model: model.TreeModel;
|
||||
var counter: EventCounter;
|
||||
let model: model.TreeModel;
|
||||
let counter: EventCounter;
|
||||
|
||||
setup(() => {
|
||||
counter = new EventCounter();
|
||||
|
@ -348,7 +348,7 @@ suite('TreeModel - TreeNavigator', () => {
|
|||
|
||||
test('next()', () => {
|
||||
return model.setInput(SAMPLE.AB).then(() => {
|
||||
var nav = model.getNavigator();
|
||||
const nav = model.getNavigator();
|
||||
assert.equal(nav.next()!.id, 'a');
|
||||
assert.equal(nav.next()!.id, 'b');
|
||||
assert.equal(nav.next()!.id, 'c');
|
||||
|
@ -358,7 +358,7 @@ suite('TreeModel - TreeNavigator', () => {
|
|||
|
||||
test('previous()', () => {
|
||||
return model.setInput(SAMPLE.AB).then(() => {
|
||||
var nav = model.getNavigator();
|
||||
const nav = model.getNavigator();
|
||||
|
||||
nav.next();
|
||||
nav.next();
|
||||
|
@ -373,7 +373,7 @@ suite('TreeModel - TreeNavigator', () => {
|
|||
test('parent()', () => {
|
||||
return model.setInput(SAMPLE.AB).then(() => {
|
||||
return model.expandAll([{ id: 'a' }, { id: 'c' }]).then(() => {
|
||||
var nav = model.getNavigator();
|
||||
const nav = model.getNavigator();
|
||||
|
||||
assert.equal(nav.next()!.id, 'a');
|
||||
assert.equal(nav.next()!.id, 'aa');
|
||||
|
@ -397,7 +397,7 @@ suite('TreeModel - TreeNavigator', () => {
|
|||
|
||||
test('next() - scoped', () => {
|
||||
return model.setInput(SAMPLE.AB).then(() => {
|
||||
var nav = model.getNavigator(SAMPLE.AB.children[0]);
|
||||
const nav = model.getNavigator(SAMPLE.AB.children[0]);
|
||||
return model.expand({ id: 'a' }).then(() => {
|
||||
assert.equal(nav.next()!.id, 'aa');
|
||||
assert.equal(nav.next()!.id, 'ab');
|
||||
|
@ -408,7 +408,7 @@ suite('TreeModel - TreeNavigator', () => {
|
|||
|
||||
test('previous() - scoped', () => {
|
||||
return model.setInput(SAMPLE.AB).then(() => {
|
||||
var nav = model.getNavigator(SAMPLE.AB.children[0]);
|
||||
const nav = model.getNavigator(SAMPLE.AB.children[0]);
|
||||
return model.expand({ id: 'a' }).then(() => {
|
||||
assert.equal(nav.next()!.id, 'aa');
|
||||
assert.equal(nav.next()!.id, 'ab');
|
||||
|
@ -421,7 +421,7 @@ suite('TreeModel - TreeNavigator', () => {
|
|||
test('parent() - scoped', () => {
|
||||
return model.setInput(SAMPLE.AB).then(() => {
|
||||
return model.expandAll([{ id: 'a' }, { id: 'c' }]).then(() => {
|
||||
var nav = model.getNavigator(SAMPLE.AB.children[0]);
|
||||
const nav = model.getNavigator(SAMPLE.AB.children[0]);
|
||||
|
||||
assert.equal(nav.next()!.id, 'aa');
|
||||
assert.equal(nav.next()!.id, 'ab');
|
||||
|
@ -432,7 +432,7 @@ suite('TreeModel - TreeNavigator', () => {
|
|||
|
||||
test('next() - non sub tree only', () => {
|
||||
return model.setInput(SAMPLE.AB).then(() => {
|
||||
var nav = model.getNavigator(SAMPLE.AB.children[0], false);
|
||||
const nav = model.getNavigator(SAMPLE.AB.children[0], false);
|
||||
return model.expand({ id: 'a' }).then(() => {
|
||||
assert.equal(nav.next()!.id, 'aa');
|
||||
assert.equal(nav.next()!.id, 'ab');
|
||||
|
@ -445,7 +445,7 @@ suite('TreeModel - TreeNavigator', () => {
|
|||
|
||||
test('previous() - non sub tree only', () => {
|
||||
return model.setInput(SAMPLE.AB).then(() => {
|
||||
var nav = model.getNavigator(SAMPLE.AB.children[0], false);
|
||||
const nav = model.getNavigator(SAMPLE.AB.children[0], false);
|
||||
return model.expand({ id: 'a' }).then(() => {
|
||||
assert.equal(nav.next()!.id, 'aa');
|
||||
assert.equal(nav.next()!.id, 'ab');
|
||||
|
@ -463,7 +463,7 @@ suite('TreeModel - TreeNavigator', () => {
|
|||
test('parent() - non sub tree only', () => {
|
||||
return model.setInput(SAMPLE.AB).then(() => {
|
||||
return model.expandAll([{ id: 'a' }, { id: 'c' }]).then(() => {
|
||||
var nav = model.getNavigator(SAMPLE.AB.children[0], false);
|
||||
const nav = model.getNavigator(SAMPLE.AB.children[0], false);
|
||||
|
||||
assert.equal(nav.next()!.id, 'aa');
|
||||
assert.equal(nav.next()!.id, 'ab');
|
||||
|
@ -477,7 +477,7 @@ suite('TreeModel - TreeNavigator', () => {
|
|||
return model.setInput(SAMPLE.DEEP).then(() => {
|
||||
return model.expand(SAMPLE.DEEP.children[0]).then(() => {
|
||||
return model.expand(SAMPLE.DEEP.children[0].children[0]).then(() => {
|
||||
var nav = model.getNavigator(SAMPLE.DEEP.children[0].children[0]);
|
||||
const nav = model.getNavigator(SAMPLE.DEEP.children[0].children[0]);
|
||||
assert.equal(nav.next()!.id, 'xa');
|
||||
assert.equal(nav.next()!.id, 'xb');
|
||||
assert.equal(nav.next() && false, null);
|
||||
|
@ -490,7 +490,7 @@ suite('TreeModel - TreeNavigator', () => {
|
|||
return model.setInput(SAMPLE.DEEP).then(() => {
|
||||
return model.expand(SAMPLE.DEEP.children[0]).then(() => {
|
||||
return model.expand(SAMPLE.DEEP.children[0].children[0]).then(() => {
|
||||
var nav = model.getNavigator(SAMPLE.DEEP.children[0].children[0]);
|
||||
const nav = model.getNavigator(SAMPLE.DEEP.children[0].children[0]);
|
||||
assert.equal(nav.next()!.id, 'xa');
|
||||
assert.equal(nav.next()!.id, 'xb');
|
||||
assert.equal(nav.previous()!.id, 'xa');
|
||||
|
@ -511,8 +511,8 @@ suite('TreeModel - TreeNavigator', () => {
|
|||
});
|
||||
|
||||
suite('TreeModel - Expansion', () => {
|
||||
var model: model.TreeModel;
|
||||
var counter: EventCounter;
|
||||
let model: model.TreeModel;
|
||||
let counter: EventCounter;
|
||||
|
||||
setup(() => {
|
||||
counter = new EventCounter();
|
||||
|
@ -530,13 +530,13 @@ suite('TreeModel - Expansion', () => {
|
|||
return model.setInput(SAMPLE.AB).then(() => {
|
||||
counter.listen(model.onExpandItem, (e) => {
|
||||
assert.equal(e.item.id, 'a');
|
||||
var nav = model.getNavigator(e.item);
|
||||
const nav = model.getNavigator(e.item);
|
||||
assert.equal(nav.next() && false, null);
|
||||
});
|
||||
|
||||
counter.listen(model.onDidExpandItem, (e) => {
|
||||
assert.equal(e.item.id, 'a');
|
||||
var nav = model.getNavigator(e.item);
|
||||
const nav = model.getNavigator(e.item);
|
||||
assert.equal(nav.next()!.id, 'aa');
|
||||
assert.equal(nav.next()!.id, 'ab');
|
||||
assert.equal(nav.next() && false, null);
|
||||
|
@ -544,7 +544,7 @@ suite('TreeModel - Expansion', () => {
|
|||
|
||||
assert(!model.isExpanded(SAMPLE.AB.children[0]));
|
||||
|
||||
var nav = model.getNavigator();
|
||||
let nav = model.getNavigator();
|
||||
assert.equal(nav.next()!.id, 'a');
|
||||
assert.equal(nav.next()!.id, 'b');
|
||||
assert.equal(nav.next()!.id, 'c');
|
||||
|
@ -563,7 +563,7 @@ suite('TreeModel - Expansion', () => {
|
|||
assert.equal(nav.next()!.id, 'c');
|
||||
assert.equal(nav.next() && false, null);
|
||||
|
||||
var expandedElements = model.getExpandedElements();
|
||||
const expandedElements = model.getExpandedElements();
|
||||
assert.equal(expandedElements.length, 1);
|
||||
assert.equal(expandedElements[0].id, 'a');
|
||||
|
||||
|
@ -626,18 +626,18 @@ suite('TreeModel - Expansion', () => {
|
|||
|
||||
assert(!model.isExpanded(SAMPLE.AB.children[0]));
|
||||
|
||||
var nav = model.getNavigator();
|
||||
let nav = model.getNavigator();
|
||||
assert.equal(nav.next()!.id, 'a');
|
||||
assert.equal(nav.next()!.id, 'b');
|
||||
assert.equal(nav.next()!.id, 'c');
|
||||
assert.equal(nav.next() && false, null);
|
||||
|
||||
var f: () => void = counter.listen(model.onRefreshItemChildren, (e) => {
|
||||
const f: () => void = counter.listen(model.onRefreshItemChildren, (e) => {
|
||||
assert.equal(e.item.id, 'a');
|
||||
f();
|
||||
});
|
||||
|
||||
var g: () => void = counter.listen(model.onDidRefreshItemChildren, (e) => {
|
||||
const g: () => void = counter.listen(model.onDidRefreshItemChildren, (e) => {
|
||||
assert.equal(e.item.id, 'a');
|
||||
g();
|
||||
});
|
||||
|
@ -661,7 +661,7 @@ suite('TreeModel - Expansion', () => {
|
|||
test('top level collapsed', () => {
|
||||
return model.setInput(SAMPLE.AB).then(() => {
|
||||
return model.collapseAll([{ id: 'a' }, { id: 'b' }, { id: 'c' }]).then(() => {
|
||||
var nav = model.getNavigator();
|
||||
const nav = model.getNavigator();
|
||||
assert.equal(nav.next()!.id, 'a');
|
||||
assert.equal(nav.next()!.id, 'b');
|
||||
assert.equal(nav.next()!.id, 'c');
|
||||
|
@ -712,9 +712,9 @@ class TestFilter implements _.IFilter {
|
|||
}
|
||||
|
||||
suite('TreeModel - Filter', () => {
|
||||
var model: model.TreeModel;
|
||||
var counter: EventCounter;
|
||||
var filter: TestFilter;
|
||||
let model: model.TreeModel;
|
||||
let counter: EventCounter;
|
||||
let filter: TestFilter;
|
||||
|
||||
setup(() => {
|
||||
counter = new EventCounter();
|
||||
|
@ -734,7 +734,7 @@ suite('TreeModel - Filter', () => {
|
|||
return model.setInput(SAMPLE.AB).then(() => {
|
||||
|
||||
return model.expandAll([{ id: 'a' }, { id: 'c' }]).then(() => {
|
||||
var nav = model.getNavigator();
|
||||
const nav = model.getNavigator();
|
||||
assert.equal(nav.next()!.id, 'a');
|
||||
assert.equal(nav.next()!.id, 'aa');
|
||||
assert.equal(nav.next()!.id, 'ab');
|
||||
|
@ -759,7 +759,7 @@ suite('TreeModel - Filter', () => {
|
|||
|
||||
return model.setInput(SAMPLE.AB).then(() => {
|
||||
return model.refresh().then(() => {
|
||||
var nav = model.getNavigator();
|
||||
const nav = model.getNavigator();
|
||||
assert.equal(nav.next() && false, null);
|
||||
});
|
||||
});
|
||||
|
@ -772,7 +772,7 @@ suite('TreeModel - Filter', () => {
|
|||
return model.setInput(SAMPLE.AB).then(() => {
|
||||
return model.expand({ id: 'a' }).then(() => {
|
||||
|
||||
var nav = model.getNavigator();
|
||||
const nav = model.getNavigator();
|
||||
assert.equal(nav.next()!.id, 'a');
|
||||
assert.equal(nav.next()!.id, 'aa');
|
||||
assert.equal(nav.next()!.id, 'ab');
|
||||
|
@ -789,7 +789,7 @@ suite('TreeModel - Filter', () => {
|
|||
|
||||
return model.setInput(SAMPLE.AB).then(() => {
|
||||
return model.expand({ id: 'a' }).then(() => {
|
||||
var nav = model.getNavigator();
|
||||
const nav = model.getNavigator();
|
||||
assert.equal(nav.next()!.id, 'a');
|
||||
assert.equal(nav.next()!.id, 'aa');
|
||||
assert.equal(nav.next()!.id, 'b');
|
||||
|
@ -806,7 +806,7 @@ suite('TreeModel - Filter', () => {
|
|||
return model.setInput(SAMPLE.AB).then(() => {
|
||||
return model.expand({ id: 'c' }).then(() => {
|
||||
|
||||
var nav = model.getNavigator();
|
||||
const nav = model.getNavigator();
|
||||
assert.equal(nav.next()!.id, 'b');
|
||||
assert.equal(nav.next()!.id, 'c');
|
||||
assert.equal(nav.next()!.id, 'ca');
|
||||
|
@ -826,7 +826,7 @@ suite('TreeModel - Filter', () => {
|
|||
return model.setInput(SAMPLE.AB).then(() => {
|
||||
return model.expand({ id: 'c' }).then(() => {
|
||||
|
||||
var nav = model.getNavigator();
|
||||
const nav = model.getNavigator();
|
||||
assert.equal(nav.next()!.id, 'b');
|
||||
assert.equal(nav.next()!.id, 'c');
|
||||
assert.equal(nav.next()!.id, 'ca');
|
||||
|
@ -844,7 +844,7 @@ suite('TreeModel - Filter', () => {
|
|||
filter.fn = (e) => e.id !== 'b';
|
||||
|
||||
return model.setInput(SAMPLE.AB).then(() => {
|
||||
var nav = model.getNavigator({ id: 'c' }, false);
|
||||
const nav = model.getNavigator({ id: 'c' }, false);
|
||||
assert.equal(nav.previous()!.id, 'a');
|
||||
assert.equal(nav.previous() && false, null);
|
||||
});
|
||||
|
@ -852,8 +852,8 @@ suite('TreeModel - Filter', () => {
|
|||
});
|
||||
|
||||
suite('TreeModel - Traits', () => {
|
||||
var model: model.TreeModel;
|
||||
var counter: EventCounter;
|
||||
let model: model.TreeModel;
|
||||
let counter: EventCounter;
|
||||
|
||||
setup(() => {
|
||||
counter = new EventCounter();
|
||||
|
@ -1126,7 +1126,7 @@ class DynamicModel implements _.IDataSource {
|
|||
|
||||
public getChildren(tree, element): Promise<any> {
|
||||
this._onGetChildren.fire(element);
|
||||
var result = this.promiseFactory ? this.promiseFactory() : Promise.resolve(null);
|
||||
const result = this.promiseFactory ? this.promiseFactory() : Promise.resolve(null);
|
||||
return result.then(() => {
|
||||
this._onDidGetChildren.fire(element);
|
||||
return Promise.resolve(this.data[element]);
|
||||
|
@ -1139,9 +1139,9 @@ class DynamicModel implements _.IDataSource {
|
|||
}
|
||||
|
||||
suite('TreeModel - Dynamic data model', () => {
|
||||
var model: model.TreeModel;
|
||||
var dataModel: DynamicModel;
|
||||
var counter: EventCounter;
|
||||
let model: model.TreeModel;
|
||||
let dataModel: DynamicModel;
|
||||
let counter: EventCounter;
|
||||
|
||||
setup(() => {
|
||||
counter = new EventCounter();
|
||||
|
@ -1167,8 +1167,8 @@ suite('TreeModel - Dynamic data model', () => {
|
|||
return model.expandAll(['grandfather', 'father', 'son']).then(() => {
|
||||
dataModel.removeChild('grandfather', 'father');
|
||||
|
||||
var items = ['baby', 'son', 'daughter', 'father'];
|
||||
var times = 0;
|
||||
const items = ['baby', 'son', 'daughter', 'father'];
|
||||
let times = 0;
|
||||
counter.listen(model.onDidDisposeItem, item => {
|
||||
assert.equal(items[times++], item.id);
|
||||
});
|
||||
|
@ -1187,7 +1187,7 @@ suite('TreeModel - Dynamic data model', () => {
|
|||
dataModel.addChild('root', 'mega');
|
||||
|
||||
return model.setInput('root').then(() => {
|
||||
var nav = model.getNavigator();
|
||||
let nav = model.getNavigator();
|
||||
assert.equal(nav.next()!.id, 'super');
|
||||
assert.equal(nav.next()!.id, 'hyper');
|
||||
assert.equal(nav.next()!.id, 'mega');
|
||||
|
@ -1237,7 +1237,7 @@ suite('TreeModel - Dynamic data model', () => {
|
|||
|
||||
return model.expand('super').then(() => {
|
||||
|
||||
var nav = model.getNavigator();
|
||||
let nav = model.getNavigator();
|
||||
assert.equal(nav.next()!.id, 'super');
|
||||
assert.equal(nav.next()!.id, 'apples');
|
||||
assert.equal(nav.next()!.id, 'bananas');
|
||||
|
@ -1274,8 +1274,8 @@ suite('TreeModel - Dynamic data model', () => {
|
|||
return model.setInput('root').then(() => {
|
||||
return model.expand('grandfather').then(() => {
|
||||
return model.collapse('father').then(() => {
|
||||
var times = 0;
|
||||
var listener = dataModel.onGetChildren((element) => {
|
||||
let times = 0;
|
||||
let listener = dataModel.onGetChildren((element) => {
|
||||
times++;
|
||||
assert.equal(element, 'grandfather');
|
||||
});
|
||||
|
@ -1309,7 +1309,7 @@ suite('TreeModel - Dynamic data model', () => {
|
|||
return model.expand('father').then(() => {
|
||||
return model.expand('mother').then(() => {
|
||||
|
||||
var nav = model.getNavigator();
|
||||
let nav = model.getNavigator();
|
||||
assert.equal(nav.next()!.id, 'father');
|
||||
assert.equal(nav.next()!.id, 'son');
|
||||
assert.equal(nav.next()!.id, 'mother');
|
||||
|
@ -1323,16 +1323,16 @@ suite('TreeModel - Dynamic data model', () => {
|
|||
|
||||
dataModel.promiseFactory = () => { return timeout(0); };
|
||||
|
||||
var getTimes = 0;
|
||||
var gotTimes = 0;
|
||||
var getListener = dataModel.onGetChildren((element) => { getTimes++; });
|
||||
var gotListener = dataModel.onDidGetChildren((element) => { gotTimes++; });
|
||||
let getTimes = 0;
|
||||
let gotTimes = 0;
|
||||
const getListener = dataModel.onGetChildren((element) => { getTimes++; });
|
||||
const gotListener = dataModel.onDidGetChildren((element) => { gotTimes++; });
|
||||
|
||||
var p1 = model.refresh('father');
|
||||
const p1 = model.refresh('father');
|
||||
assert.equal(getTimes, 1);
|
||||
assert.equal(gotTimes, 0);
|
||||
|
||||
var p2 = model.refresh('mother');
|
||||
const p2 = model.refresh('mother');
|
||||
assert.equal(getTimes, 2);
|
||||
assert.equal(gotTimes, 0);
|
||||
|
||||
|
@ -1363,22 +1363,22 @@ suite('TreeModel - Dynamic data model', () => {
|
|||
return model.setInput('root').then(() => {
|
||||
return model.expand('grandfather').then(() => {
|
||||
return model.expand('father').then(() => {
|
||||
var nav = model.getNavigator();
|
||||
let nav = model.getNavigator();
|
||||
assert.equal(nav.next()!.id, 'grandfather');
|
||||
assert.equal(nav.next()!.id, 'father');
|
||||
assert.equal(nav.next()!.id, 'son');
|
||||
assert.equal(nav.next() && false, null);
|
||||
|
||||
var refreshTimes = 0;
|
||||
let refreshTimes = 0;
|
||||
counter.listen(model.onDidRefreshItem, (e) => { refreshTimes++; });
|
||||
|
||||
var getTimes = 0;
|
||||
var getListener = dataModel.onGetChildren((element) => { getTimes++; });
|
||||
let getTimes = 0;
|
||||
const getListener = dataModel.onGetChildren((element) => { getTimes++; });
|
||||
|
||||
var gotTimes = 0;
|
||||
var gotListener = dataModel.onDidGetChildren((element) => { gotTimes++; });
|
||||
let gotTimes = 0;
|
||||
const gotListener = dataModel.onDidGetChildren((element) => { gotTimes++; });
|
||||
|
||||
var p1Completes: Array<(value?: any) => void> = [];
|
||||
const p1Completes: Array<(value?: any) => void> = [];
|
||||
dataModel.promiseFactory = () => { return new Promise((c) => { p1Completes.push(c); }); };
|
||||
|
||||
model.refresh('grandfather').then(() => {
|
||||
|
@ -1395,9 +1395,9 @@ suite('TreeModel - Dynamic data model', () => {
|
|||
assert.equal(getTimes, 2);
|
||||
assert.equal(gotTimes, 1);
|
||||
|
||||
var p2Complete;
|
||||
let p2Complete;
|
||||
dataModel.promiseFactory = () => { return new Promise((c) => { p2Complete = c; }); };
|
||||
var p2 = model.refresh('father');
|
||||
const p2 = model.refresh('father');
|
||||
|
||||
// same situation still
|
||||
assert.equal(refreshTimes, 3); // (+1) second father refresh
|
||||
|
@ -1529,7 +1529,7 @@ suite('TreeModel - Dynamic data model', () => {
|
|||
// delay expansions and refreshes
|
||||
dataModel.promiseFactory = () => { return timeout(0); };
|
||||
|
||||
var promises: Promise<any>[] = [];
|
||||
const promises: Promise<any>[] = [];
|
||||
|
||||
promises.push(model.expand('father'));
|
||||
dataModel.removeChild('root', 'father');
|
||||
|
@ -1549,7 +1549,7 @@ suite('TreeModel - Dynamic data model', () => {
|
|||
});
|
||||
|
||||
suite('TreeModel - bugs', () => {
|
||||
var counter: EventCounter;
|
||||
let counter: EventCounter;
|
||||
|
||||
setup(() => {
|
||||
counter = new EventCounter();
|
||||
|
@ -1580,10 +1580,10 @@ suite('TreeModel - bugs', () => {
|
|||
let listeners = <any>[];
|
||||
|
||||
// helpers
|
||||
var getGetRootChildren = (children: string[], millis = 0) => () => timeout(millis).then(() => children);
|
||||
var getRootChildren = getGetRootChildren(['homer', 'bart', 'lisa', 'marge', 'maggie'], 0);
|
||||
var getGetBartChildren = (millis = 0) => () => timeout(millis).then(() => ['milhouse', 'nelson']);
|
||||
var getBartChildren = getGetBartChildren(0);
|
||||
const getGetRootChildren = (children: string[], millis = 0) => () => timeout(millis).then(() => children);
|
||||
let getRootChildren = getGetRootChildren(['homer', 'bart', 'lisa', 'marge', 'maggie'], 0);
|
||||
const getGetBartChildren = (millis = 0) => () => timeout(millis).then(() => ['milhouse', 'nelson']);
|
||||
const getBartChildren = getGetBartChildren(0);
|
||||
|
||||
// item expanding should not exist!
|
||||
counter.listen(model.onExpandItem, () => { assert(false, 'should never receive item:expanding event'); });
|
||||
|
@ -1595,14 +1595,14 @@ suite('TreeModel - bugs', () => {
|
|||
getRootChildren = getGetRootChildren(['homer', 'lisa', 'marge', 'maggie'], 10);
|
||||
|
||||
// refresh root
|
||||
var p1 = model.refresh('root', true).then(() => {
|
||||
const p1 = model.refresh('root', true).then(() => {
|
||||
assert(true);
|
||||
}, () => {
|
||||
assert(false, 'should never reach this');
|
||||
});
|
||||
|
||||
// at the same time, try to expand bart!
|
||||
var p2 = model.expand('bart').then(() => {
|
||||
const p2 = model.expand('bart').then(() => {
|
||||
assert(false, 'should never reach this');
|
||||
}, () => {
|
||||
assert(true, 'bart should fail to expand since he was removed meanwhile');
|
||||
|
|
|
@ -17,9 +17,9 @@ function makeItem(id, height): any {
|
|||
}
|
||||
|
||||
function makeItems(...args: any[]) {
|
||||
var r: any[] = [];
|
||||
let r: any[] = [];
|
||||
|
||||
for (var i = 0; i < args.length; i += 2) {
|
||||
for (let i = 0; i < args.length; i += 2) {
|
||||
r.push(makeItem(args[i], args[i + 1]));
|
||||
}
|
||||
|
||||
|
@ -27,8 +27,8 @@ function makeItems(...args: any[]) {
|
|||
}
|
||||
|
||||
function makeNavigator(...args: any[]): any {
|
||||
var items = makeItems.apply(null, args);
|
||||
var i = 0;
|
||||
let items = makeItems.apply(null, args);
|
||||
let i = 0;
|
||||
|
||||
return {
|
||||
next: function () {
|
||||
|
@ -50,7 +50,7 @@ class TestHeightMap extends HeightMap {
|
|||
}
|
||||
|
||||
suite('TreeView - HeightMap', () => {
|
||||
var rangeMap: HeightMap;
|
||||
let rangeMap: HeightMap;
|
||||
|
||||
setup(() => {
|
||||
rangeMap = new TestHeightMap();
|
||||
|
@ -76,7 +76,7 @@ suite('TreeView - HeightMap', () => {
|
|||
});
|
||||
|
||||
test('onInsertItems at beginning', () => {
|
||||
var navigator = makeNavigator('x', 4, 'y', 20, 'z', 8);
|
||||
let navigator = makeNavigator('x', 4, 'y', 20, 'z', 8);
|
||||
rangeMap.onInsertItems(navigator);
|
||||
|
||||
assert.equal(rangeMap.itemAt(0), 'x');
|
||||
|
@ -97,7 +97,7 @@ suite('TreeView - HeightMap', () => {
|
|||
});
|
||||
|
||||
test('onInsertItems in middle', () => {
|
||||
var navigator = makeNavigator('x', 4, 'y', 20, 'z', 8);
|
||||
let navigator = makeNavigator('x', 4, 'y', 20, 'z', 8);
|
||||
rangeMap.onInsertItems(navigator, 'a');
|
||||
|
||||
assert.equal(rangeMap.itemAt(0), 'a');
|
||||
|
@ -118,7 +118,7 @@ suite('TreeView - HeightMap', () => {
|
|||
});
|
||||
|
||||
test('onInsertItems at end', () => {
|
||||
var navigator = makeNavigator('x', 4, 'y', 20, 'z', 8);
|
||||
let navigator = makeNavigator('x', 4, 'y', 20, 'z', 8);
|
||||
rangeMap.onInsertItems(navigator, 'd');
|
||||
|
||||
assert.equal(rangeMap.itemAt(0), 'a');
|
||||
|
@ -171,7 +171,7 @@ suite('TreeView - HeightMap', () => {
|
|||
});
|
||||
|
||||
test('onRefreshItems at beginning', () => {
|
||||
var navigator = makeNavigator('a', 1, 'b', 1);
|
||||
let navigator = makeNavigator('a', 1, 'b', 1);
|
||||
rangeMap.onRefreshItems(navigator);
|
||||
|
||||
assert.equal(rangeMap.itemAt(0), 'a');
|
||||
|
@ -184,7 +184,7 @@ suite('TreeView - HeightMap', () => {
|
|||
});
|
||||
|
||||
test('onRefreshItems in middle', () => {
|
||||
var navigator = makeNavigator('b', 40, 'c', 4);
|
||||
let navigator = makeNavigator('b', 40, 'c', 4);
|
||||
rangeMap.onRefreshItems(navigator);
|
||||
|
||||
assert.equal(rangeMap.itemAt(0), 'a');
|
||||
|
@ -199,7 +199,7 @@ suite('TreeView - HeightMap', () => {
|
|||
});
|
||||
|
||||
test('onRefreshItems at end', () => {
|
||||
var navigator = makeNavigator('d', 22);
|
||||
let navigator = makeNavigator('d', 22);
|
||||
rangeMap.onRefreshItems(navigator);
|
||||
|
||||
assert.equal(rangeMap.itemAt(0), 'a');
|
||||
|
@ -214,8 +214,8 @@ suite('TreeView - HeightMap', () => {
|
|||
});
|
||||
|
||||
test('withItemsInRange', () => {
|
||||
var i = 0;
|
||||
var itemsInRange = ['a', 'b'];
|
||||
let i = 0;
|
||||
let itemsInRange = ['a', 'b'];
|
||||
rangeMap.withItemsInRange(2, 27, function (item) { assert.equal(item, itemsInRange[i++]); });
|
||||
assert.equal(i, itemsInRange.length);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import { renderMarkdown, renderText, renderFormattedText } from 'vs/base/browser
|
|||
|
||||
suite('HtmlContent', () => {
|
||||
test('render simple element', () => {
|
||||
var result: HTMLElement = renderText('testing');
|
||||
let result: HTMLElement = renderText('testing');
|
||||
|
||||
assert.strictEqual(result.nodeType, document.ELEMENT_NODE);
|
||||
assert.strictEqual(result.textContent, 'testing');
|
||||
|
@ -16,7 +16,7 @@ suite('HtmlContent', () => {
|
|||
});
|
||||
|
||||
test('render element with class', () => {
|
||||
var result: HTMLElement = renderText('testing', {
|
||||
let result: HTMLElement = renderText('testing', {
|
||||
className: 'testClass'
|
||||
});
|
||||
assert.strictEqual(result.nodeType, document.ELEMENT_NODE);
|
||||
|
@ -24,7 +24,7 @@ suite('HtmlContent', () => {
|
|||
});
|
||||
|
||||
test('simple formatting', () => {
|
||||
var result: HTMLElement = renderFormattedText('**bold**');
|
||||
let result: HTMLElement = renderFormattedText('**bold**');
|
||||
assert.strictEqual(result.children.length, 1);
|
||||
assert.strictEqual(result.firstChild!.textContent, 'bold');
|
||||
assert.strictEqual((<HTMLElement>result.firstChild).tagName, 'B');
|
||||
|
@ -38,18 +38,18 @@ suite('HtmlContent', () => {
|
|||
});
|
||||
|
||||
test('no formatting', () => {
|
||||
var result: HTMLElement = renderFormattedText('this is just a string');
|
||||
let result: HTMLElement = renderFormattedText('this is just a string');
|
||||
assert.strictEqual(result.innerHTML, 'this is just a string');
|
||||
});
|
||||
|
||||
test('preserve newlines', () => {
|
||||
var result: HTMLElement = renderFormattedText('line one\nline two');
|
||||
let result: HTMLElement = renderFormattedText('line one\nline two');
|
||||
assert.strictEqual(result.innerHTML, 'line one<br>line two');
|
||||
});
|
||||
|
||||
test('action', () => {
|
||||
var callbackCalled = false;
|
||||
var result: HTMLElement = renderFormattedText('[[action]]', {
|
||||
let callbackCalled = false;
|
||||
let result: HTMLElement = renderFormattedText('[[action]]', {
|
||||
actionHandler: {
|
||||
callback(content) {
|
||||
assert.strictEqual(content, '0');
|
||||
|
@ -60,15 +60,15 @@ suite('HtmlContent', () => {
|
|||
});
|
||||
assert.strictEqual(result.innerHTML, '<a href="#">action</a>');
|
||||
|
||||
var event: MouseEvent = <any>document.createEvent('MouseEvent');
|
||||
let event: MouseEvent = <any>document.createEvent('MouseEvent');
|
||||
event.initEvent('click', true, true);
|
||||
result.firstChild!.dispatchEvent(event);
|
||||
assert.strictEqual(callbackCalled, true);
|
||||
});
|
||||
|
||||
test('fancy action', () => {
|
||||
var callbackCalled = false;
|
||||
var result: HTMLElement = renderFormattedText('__**[[action]]**__', {
|
||||
let callbackCalled = false;
|
||||
let result: HTMLElement = renderFormattedText('__**[[action]]**__', {
|
||||
actionHandler: {
|
||||
callback(content) {
|
||||
assert.strictEqual(content, '0');
|
||||
|
@ -79,14 +79,14 @@ suite('HtmlContent', () => {
|
|||
});
|
||||
assert.strictEqual(result.innerHTML, '<i><b><a href="#">action</a></b></i>');
|
||||
|
||||
var event: MouseEvent = <any>document.createEvent('MouseEvent');
|
||||
let event: MouseEvent = <any>document.createEvent('MouseEvent');
|
||||
event.initEvent('click', true, true);
|
||||
result.firstChild!.firstChild!.firstChild!.dispatchEvent(event);
|
||||
assert.strictEqual(callbackCalled, true);
|
||||
});
|
||||
|
||||
test('escaped formatting', () => {
|
||||
var result: HTMLElement = renderFormattedText('\\*\\*bold\\*\\*');
|
||||
let result: HTMLElement = renderFormattedText('\\*\\*bold\\*\\*');
|
||||
assert.strictEqual(result.children.length, 0);
|
||||
assert.strictEqual(result.innerHTML, '**bold**');
|
||||
});
|
||||
|
@ -111,15 +111,15 @@ suite('HtmlContent', () => {
|
|||
assert.strictEqual(result.innerHTML, imageFromMarked);
|
||||
});
|
||||
test('image width from title params', () => {
|
||||
var result: HTMLElement = renderMarkdown({ value: `![image](someimageurl|width=100 'caption')` });
|
||||
let result: HTMLElement = renderMarkdown({ value: `![image](someimageurl|width=100 'caption')` });
|
||||
assert.strictEqual(result.innerHTML, `<p><img src="someimageurl" alt="image" title="caption" width="100"></p>`);
|
||||
});
|
||||
test('image height from title params', () => {
|
||||
var result: HTMLElement = renderMarkdown({ value: `![image](someimageurl|height=100 'caption')` });
|
||||
let result: HTMLElement = renderMarkdown({ value: `![image](someimageurl|height=100 'caption')` });
|
||||
assert.strictEqual(result.innerHTML, `<p><img src="someimageurl" alt="image" title="caption" height="100"></p>`);
|
||||
});
|
||||
test('image width and height from title params', () => {
|
||||
var result: HTMLElement = renderMarkdown({ value: `![image](someimageurl|height=200,width=100 'caption')` });
|
||||
let result: HTMLElement = renderMarkdown({ value: `![image](someimageurl|height=200,width=100 'caption')` });
|
||||
assert.strictEqual(result.innerHTML, `<p><img src="someimageurl" alt="image" title="caption" width="100" height="200"></p>`);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -8,7 +8,7 @@ import { RangeMap, groupIntersect, consolidate } from 'vs/base/browser/ui/list/r
|
|||
import { Range } from 'vs/base/common/range';
|
||||
|
||||
suite('RangeMap', () => {
|
||||
var rangeMap: RangeMap;
|
||||
let rangeMap: RangeMap;
|
||||
|
||||
setup(() => {
|
||||
rangeMap = new RangeMap();
|
||||
|
|
|
@ -22,15 +22,15 @@ class StringDiffSequence implements ISequence {
|
|||
|
||||
function createArray<T>(length: number, value: T): T[] {
|
||||
const r: T[] = [];
|
||||
for (var i = 0; i < length; i++) {
|
||||
for (let i = 0; i < length; i++) {
|
||||
r[i] = value;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
function maskBasedSubstring(str: string, mask: boolean[]): string {
|
||||
var r = '';
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
let r = '';
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
if (mask[i]) {
|
||||
r += str.charAt(i);
|
||||
}
|
||||
|
@ -39,10 +39,10 @@ function maskBasedSubstring(str: string, mask: boolean[]): string {
|
|||
}
|
||||
|
||||
function assertAnswer(originalStr: string, modifiedStr: string, changes: IDiffChange[], answerStr: string, onlyLength: boolean = false): void {
|
||||
var originalMask = createArray(originalStr.length, true);
|
||||
var modifiedMask = createArray(modifiedStr.length, true);
|
||||
let originalMask = createArray(originalStr.length, true);
|
||||
let modifiedMask = createArray(modifiedStr.length, true);
|
||||
|
||||
var i, j, change;
|
||||
let i, j, change;
|
||||
for (i = 0; i < changes.length; i++) {
|
||||
change = changes[i];
|
||||
|
||||
|
@ -59,8 +59,8 @@ function assertAnswer(originalStr: string, modifiedStr: string, changes: IDiffCh
|
|||
}
|
||||
}
|
||||
|
||||
var originalAnswer = maskBasedSubstring(originalStr, originalMask);
|
||||
var modifiedAnswer = maskBasedSubstring(modifiedStr, modifiedMask);
|
||||
let originalAnswer = maskBasedSubstring(originalStr, originalMask);
|
||||
let modifiedAnswer = maskBasedSubstring(modifiedStr, modifiedMask);
|
||||
|
||||
if (onlyLength) {
|
||||
assert.equal(originalAnswer.length, answerStr.length);
|
||||
|
@ -72,14 +72,14 @@ function assertAnswer(originalStr: string, modifiedStr: string, changes: IDiffCh
|
|||
}
|
||||
|
||||
function lcsInnerTest(Algorithm: any, originalStr: string, modifiedStr: string, answerStr: string, onlyLength: boolean = false): void {
|
||||
var diff = new Algorithm(new StringDiffSequence(originalStr), new StringDiffSequence(modifiedStr));
|
||||
var changes = diff.ComputeDiff();
|
||||
let diff = new Algorithm(new StringDiffSequence(originalStr), new StringDiffSequence(modifiedStr));
|
||||
let changes = diff.ComputeDiff();
|
||||
assertAnswer(originalStr, modifiedStr, changes, answerStr, onlyLength);
|
||||
}
|
||||
|
||||
function stringPower(str: string, power: number): string {
|
||||
var r = str;
|
||||
for (var i = 0; i < power; i++) {
|
||||
let r = str;
|
||||
for (let i = 0; i < power; i++) {
|
||||
r += r;
|
||||
}
|
||||
return r;
|
||||
|
@ -87,7 +87,7 @@ function stringPower(str: string, power: number): string {
|
|||
|
||||
function lcsTest(Algorithm: any, originalStr: string, modifiedStr: string, answerStr: string) {
|
||||
lcsInnerTest(Algorithm, originalStr, modifiedStr, answerStr);
|
||||
for (var i = 2; i <= 5; i++) {
|
||||
for (let i = 2; i <= 5; i++) {
|
||||
lcsInnerTest(Algorithm, stringPower(originalStr, i), stringPower(modifiedStr, i), stringPower(answerStr, i), true);
|
||||
}
|
||||
}
|
||||
|
@ -116,14 +116,14 @@ suite('Diff', () => {
|
|||
|
||||
suite('Diff - Ported from VS', () => {
|
||||
test('using continue processing predicate to quit early', function () {
|
||||
var left = 'abcdef';
|
||||
var right = 'abxxcyyydzzzzezzzzzzzzzzzzzzzzzzzzf';
|
||||
let left = 'abcdef';
|
||||
let right = 'abxxcyyydzzzzezzzzzzzzzzzzzzzzzzzzf';
|
||||
|
||||
// We use a long non-matching portion at the end of the right-side string, so the backwards tracking logic
|
||||
// doesn't get there first.
|
||||
var predicateCallCount = 0;
|
||||
let predicateCallCount = 0;
|
||||
|
||||
var diff = new LcsDiff(new StringDiffSequence(left), new StringDiffSequence(right), function (leftIndex, leftSequence, longestMatchSoFar) {
|
||||
let diff = new LcsDiff(new StringDiffSequence(left), new StringDiffSequence(right), function (leftIndex, leftSequence, longestMatchSoFar) {
|
||||
assert.equal(predicateCallCount, 0);
|
||||
|
||||
predicateCallCount++;
|
||||
|
@ -134,7 +134,7 @@ suite('Diff - Ported from VS', () => {
|
|||
// cancel processing
|
||||
return false;
|
||||
});
|
||||
var changes = diff.ComputeDiff(true);
|
||||
let changes = diff.ComputeDiff(true);
|
||||
|
||||
assert.equal(predicateCallCount, 1);
|
||||
|
||||
|
@ -170,11 +170,11 @@ suite('Diff - Ported from VS', () => {
|
|||
|
||||
|
||||
// Cancel *one iteration* after the second match ('d')
|
||||
var hitSecondMatch = false;
|
||||
let hitSecondMatch = false;
|
||||
diff = new LcsDiff(new StringDiffSequence(left), new StringDiffSequence(right), function (leftIndex, leftSequence, longestMatchSoFar) {
|
||||
assert(longestMatchSoFar <= 2); // We never see a match of length > 2
|
||||
|
||||
var hitYet = hitSecondMatch;
|
||||
let hitYet = hitSecondMatch;
|
||||
hitSecondMatch = longestMatchSoFar > 1;
|
||||
// Continue processing as long as there hasn't been a match made.
|
||||
return !hitYet;
|
||||
|
|
|
@ -9,23 +9,23 @@ import {
|
|||
import { getParseErrorMessage } from 'vs/base/common/jsonErrorMessages';
|
||||
|
||||
function assertKinds(text: string, ...kinds: SyntaxKind[]): void {
|
||||
var scanner = createScanner(text);
|
||||
var kind: SyntaxKind;
|
||||
let scanner = createScanner(text);
|
||||
let kind: SyntaxKind;
|
||||
while ((kind = scanner.scan()) !== SyntaxKind.EOF) {
|
||||
assert.equal(kind, kinds.shift());
|
||||
}
|
||||
assert.equal(kinds.length, 0);
|
||||
}
|
||||
function assertScanError(text: string, expectedKind: SyntaxKind, scanError: ScanError): void {
|
||||
var scanner = createScanner(text);
|
||||
let scanner = createScanner(text);
|
||||
scanner.scan();
|
||||
assert.equal(scanner.getToken(), expectedKind);
|
||||
assert.equal(scanner.getTokenError(), scanError);
|
||||
}
|
||||
|
||||
function assertValidParse(input: string, expected: any, options?: ParseOptions): void {
|
||||
var errors: ParseError[] = [];
|
||||
var actual = parse(input, errors, options);
|
||||
let errors: ParseError[] = [];
|
||||
let actual = parse(input, errors, options);
|
||||
|
||||
if (errors.length !== 0) {
|
||||
assert(false, getParseErrorMessage(errors[0].error));
|
||||
|
@ -34,16 +34,16 @@ function assertValidParse(input: string, expected: any, options?: ParseOptions):
|
|||
}
|
||||
|
||||
function assertInvalidParse(input: string, expected: any, options?: ParseOptions): void {
|
||||
var errors: ParseError[] = [];
|
||||
var actual = parse(input, errors, options);
|
||||
let errors: ParseError[] = [];
|
||||
let actual = parse(input, errors, options);
|
||||
|
||||
assert(errors.length > 0);
|
||||
assert.deepEqual(actual, expected);
|
||||
}
|
||||
|
||||
function assertTree(input: string, expected: any, expectedErrors: number[] = [], options?: ParseOptions): void {
|
||||
var errors: ParseError[] = [];
|
||||
var actual = parseTree(input, errors, options);
|
||||
let errors: ParseError[] = [];
|
||||
let actual = parseTree(input, errors, options);
|
||||
|
||||
assert.deepEqual(errors.map(e => e.error, expected), expectedErrors);
|
||||
let checkParent = (node: Node) => {
|
||||
|
|
|
@ -9,14 +9,14 @@ suite('JSON - formatter', () => {
|
|||
|
||||
function format(content: string, expected: string, insertSpaces = true) {
|
||||
let range: Formatter.Range | undefined = undefined;
|
||||
var rangeStart = content.indexOf('|');
|
||||
var rangeEnd = content.lastIndexOf('|');
|
||||
const rangeStart = content.indexOf('|');
|
||||
const rangeEnd = content.lastIndexOf('|');
|
||||
if (rangeStart !== -1 && rangeEnd !== -1) {
|
||||
content = content.substring(0, rangeStart) + content.substring(rangeStart + 1, rangeEnd) + content.substring(rangeEnd + 1);
|
||||
range = { offset: rangeStart, length: rangeEnd - rangeStart };
|
||||
}
|
||||
|
||||
var edits = Formatter.format(content, range, { tabSize: 2, insertSpaces: insertSpaces, eol: '\n' });
|
||||
const edits = Formatter.format(content, range, { tabSize: 2, insertSpaces: insertSpaces, eol: '\n' });
|
||||
|
||||
let lastEditOffset = content.length;
|
||||
for (let i = edits.length - 1; i >= 0; i--) {
|
||||
|
@ -32,11 +32,11 @@ suite('JSON - formatter', () => {
|
|||
}
|
||||
|
||||
test('object - single property', () => {
|
||||
var content = [
|
||||
const content = [
|
||||
'{"x" : 1}'
|
||||
].join('\n');
|
||||
|
||||
var expected = [
|
||||
const expected = [
|
||||
'{',
|
||||
' "x": 1',
|
||||
'}'
|
||||
|
@ -45,11 +45,11 @@ suite('JSON - formatter', () => {
|
|||
format(content, expected);
|
||||
});
|
||||
test('object - multiple properties', () => {
|
||||
var content = [
|
||||
const content = [
|
||||
'{"x" : 1, "y" : "foo", "z" : true}'
|
||||
].join('\n');
|
||||
|
||||
var expected = [
|
||||
const expected = [
|
||||
'{',
|
||||
' "x": 1,',
|
||||
' "y": "foo",',
|
||||
|
@ -60,11 +60,11 @@ suite('JSON - formatter', () => {
|
|||
format(content, expected);
|
||||
});
|
||||
test('object - no properties ', () => {
|
||||
var content = [
|
||||
const content = [
|
||||
'{"x" : { }, "y" : {}}'
|
||||
].join('\n');
|
||||
|
||||
var expected = [
|
||||
const expected = [
|
||||
'{',
|
||||
' "x": {},',
|
||||
' "y": {}',
|
||||
|
@ -74,11 +74,11 @@ suite('JSON - formatter', () => {
|
|||
format(content, expected);
|
||||
});
|
||||
test('object - nesting', () => {
|
||||
var content = [
|
||||
const content = [
|
||||
'{"x" : { "y" : { "z" : { }}, "a": true}}'
|
||||
].join('\n');
|
||||
|
||||
var expected = [
|
||||
const expected = [
|
||||
'{',
|
||||
' "x": {',
|
||||
' "y": {',
|
||||
|
@ -93,11 +93,11 @@ suite('JSON - formatter', () => {
|
|||
});
|
||||
|
||||
test('array - single items', () => {
|
||||
var content = [
|
||||
const content = [
|
||||
'["[]"]'
|
||||
].join('\n');
|
||||
|
||||
var expected = [
|
||||
const expected = [
|
||||
'[',
|
||||
' "[]"',
|
||||
']'
|
||||
|
@ -107,11 +107,11 @@ suite('JSON - formatter', () => {
|
|||
});
|
||||
|
||||
test('array - multiple items', () => {
|
||||
var content = [
|
||||
const content = [
|
||||
'[true,null,1.2]'
|
||||
].join('\n');
|
||||
|
||||
var expected = [
|
||||
const expected = [
|
||||
'[',
|
||||
' true,',
|
||||
' null,',
|
||||
|
@ -123,11 +123,11 @@ suite('JSON - formatter', () => {
|
|||
});
|
||||
|
||||
test('array - no items', () => {
|
||||
var content = [
|
||||
const content = [
|
||||
'[ ]'
|
||||
].join('\n');
|
||||
|
||||
var expected = [
|
||||
const expected = [
|
||||
'[]'
|
||||
].join('\n');
|
||||
|
||||
|
@ -135,11 +135,11 @@ suite('JSON - formatter', () => {
|
|||
});
|
||||
|
||||
test('array - nesting', () => {
|
||||
var content = [
|
||||
const content = [
|
||||
'[ [], [ [ {} ], "a" ] ]'
|
||||
].join('\n');
|
||||
|
||||
var expected = [
|
||||
const expected = [
|
||||
'[',
|
||||
' [],',
|
||||
' [',
|
||||
|
@ -155,11 +155,11 @@ suite('JSON - formatter', () => {
|
|||
});
|
||||
|
||||
test('syntax errors', () => {
|
||||
var content = [
|
||||
const content = [
|
||||
'[ null 1.2 ]'
|
||||
].join('\n');
|
||||
|
||||
var expected = [
|
||||
const expected = [
|
||||
'[',
|
||||
' null 1.2',
|
||||
']',
|
||||
|
@ -169,7 +169,7 @@ suite('JSON - formatter', () => {
|
|||
});
|
||||
|
||||
test('empty lines', () => {
|
||||
var content = [
|
||||
const content = [
|
||||
'{',
|
||||
'"a": true,',
|
||||
'',
|
||||
|
@ -177,7 +177,7 @@ suite('JSON - formatter', () => {
|
|||
'}',
|
||||
].join('\n');
|
||||
|
||||
var expected = [
|
||||
const expected = [
|
||||
'{',
|
||||
'\t"a": true,',
|
||||
'\t"b": true',
|
||||
|
@ -187,14 +187,14 @@ suite('JSON - formatter', () => {
|
|||
format(content, expected, false);
|
||||
});
|
||||
test('single line comment', () => {
|
||||
var content = [
|
||||
const content = [
|
||||
'[ ',
|
||||
'//comment',
|
||||
'"foo", "bar"',
|
||||
'] '
|
||||
].join('\n');
|
||||
|
||||
var expected = [
|
||||
const expected = [
|
||||
'[',
|
||||
' //comment',
|
||||
' "foo",',
|
||||
|
@ -205,14 +205,14 @@ suite('JSON - formatter', () => {
|
|||
format(content, expected);
|
||||
});
|
||||
test('block line comment', () => {
|
||||
var content = [
|
||||
const content = [
|
||||
'[{',
|
||||
' /*comment*/ ',
|
||||
'"foo" : true',
|
||||
'}] '
|
||||
].join('\n');
|
||||
|
||||
var expected = [
|
||||
const expected = [
|
||||
'[',
|
||||
' {',
|
||||
' /*comment*/',
|
||||
|
@ -224,13 +224,13 @@ suite('JSON - formatter', () => {
|
|||
format(content, expected);
|
||||
});
|
||||
test('single line comment on same line', () => {
|
||||
var content = [
|
||||
const content = [
|
||||
' { ',
|
||||
' "a": {}// comment ',
|
||||
' } '
|
||||
].join('\n');
|
||||
|
||||
var expected = [
|
||||
const expected = [
|
||||
'{',
|
||||
' "a": {} // comment ',
|
||||
'}',
|
||||
|
@ -239,12 +239,12 @@ suite('JSON - formatter', () => {
|
|||
format(content, expected);
|
||||
});
|
||||
test('single line comment on same line 2', () => {
|
||||
var content = [
|
||||
const content = [
|
||||
'{ //comment',
|
||||
'}'
|
||||
].join('\n');
|
||||
|
||||
var expected = [
|
||||
const expected = [
|
||||
'{ //comment',
|
||||
'}'
|
||||
].join('\n');
|
||||
|
@ -252,13 +252,13 @@ suite('JSON - formatter', () => {
|
|||
format(content, expected);
|
||||
});
|
||||
test('block comment on same line', () => {
|
||||
var content = [
|
||||
const content = [
|
||||
'{ "a": {}, /*comment*/ ',
|
||||
' /*comment*/ "b": {}, ',
|
||||
' "c": {/*comment*/} } ',
|
||||
].join('\n');
|
||||
|
||||
var expected = [
|
||||
const expected = [
|
||||
'{',
|
||||
' "a": {}, /*comment*/',
|
||||
' /*comment*/ "b": {},',
|
||||
|
@ -270,14 +270,14 @@ suite('JSON - formatter', () => {
|
|||
});
|
||||
|
||||
test('block comment on same line advanced', () => {
|
||||
var content = [
|
||||
const content = [
|
||||
' { "d": [',
|
||||
' null',
|
||||
' ] /*comment*/',
|
||||
' ,"e": /*comment*/ [null] }',
|
||||
].join('\n');
|
||||
|
||||
var expected = [
|
||||
const expected = [
|
||||
'{',
|
||||
' "d": [',
|
||||
' null',
|
||||
|
@ -292,12 +292,12 @@ suite('JSON - formatter', () => {
|
|||
});
|
||||
|
||||
test('multiple block comments on same line', () => {
|
||||
var content = [
|
||||
const content = [
|
||||
'{ "a": {} /*comment*/, /*comment*/ ',
|
||||
' /*comment*/ "b": {} /*comment*/ } '
|
||||
].join('\n');
|
||||
|
||||
var expected = [
|
||||
const expected = [
|
||||
'{',
|
||||
' "a": {} /*comment*/, /*comment*/',
|
||||
' /*comment*/ "b": {} /*comment*/',
|
||||
|
@ -307,12 +307,12 @@ suite('JSON - formatter', () => {
|
|||
format(content, expected);
|
||||
});
|
||||
test('multiple mixed comments on same line', () => {
|
||||
var content = [
|
||||
const content = [
|
||||
'[ /*comment*/ /*comment*/ // comment ',
|
||||
']'
|
||||
].join('\n');
|
||||
|
||||
var expected = [
|
||||
const expected = [
|
||||
'[ /*comment*/ /*comment*/ // comment ',
|
||||
']'
|
||||
].join('\n');
|
||||
|
@ -321,13 +321,13 @@ suite('JSON - formatter', () => {
|
|||
});
|
||||
|
||||
test('range', () => {
|
||||
var content = [
|
||||
const content = [
|
||||
'{ "a": {},',
|
||||
'|"b": [null, null]|',
|
||||
'} '
|
||||
].join('\n');
|
||||
|
||||
var expected = [
|
||||
const expected = [
|
||||
'{ "a": {},',
|
||||
'"b": [',
|
||||
' null,',
|
||||
|
@ -340,14 +340,14 @@ suite('JSON - formatter', () => {
|
|||
});
|
||||
|
||||
test('range with existing indent', () => {
|
||||
var content = [
|
||||
const content = [
|
||||
'{ "a": {},',
|
||||
' |"b": [null],',
|
||||
'"c": {}',
|
||||
'}|'
|
||||
].join('\n');
|
||||
|
||||
var expected = [
|
||||
const expected = [
|
||||
'{ "a": {},',
|
||||
' "b": [',
|
||||
' null',
|
||||
|
@ -360,14 +360,14 @@ suite('JSON - formatter', () => {
|
|||
});
|
||||
|
||||
test('range with existing indent - tabs', () => {
|
||||
var content = [
|
||||
const content = [
|
||||
'{ "a": {},',
|
||||
'| "b": [null], ',
|
||||
'"c": {}',
|
||||
'} | '
|
||||
].join('\n');
|
||||
|
||||
var expected = [
|
||||
const expected = [
|
||||
'{ "a": {},',
|
||||
'\t"b": [',
|
||||
'\t\tnull',
|
||||
|
@ -381,7 +381,7 @@ suite('JSON - formatter', () => {
|
|||
|
||||
|
||||
test('block comment none-line breaking symbols', () => {
|
||||
var content = [
|
||||
const content = [
|
||||
'{ "a": [ 1',
|
||||
'/* comment */',
|
||||
', 2',
|
||||
|
@ -394,7 +394,7 @@ suite('JSON - formatter', () => {
|
|||
'}'
|
||||
].join('\n');
|
||||
|
||||
var expected = [
|
||||
const expected = [
|
||||
'{',
|
||||
' "a": [',
|
||||
' 1',
|
||||
|
@ -413,7 +413,7 @@ suite('JSON - formatter', () => {
|
|||
format(content, expected);
|
||||
});
|
||||
test('line comment after none-line breaking symbols', () => {
|
||||
var content = [
|
||||
const content = [
|
||||
'{ "a":',
|
||||
'// comment',
|
||||
'null,',
|
||||
|
@ -424,7 +424,7 @@ suite('JSON - formatter', () => {
|
|||
'}'
|
||||
].join('\n');
|
||||
|
||||
var expected = [
|
||||
const expected = [
|
||||
'{',
|
||||
' "a":',
|
||||
' // comment',
|
||||
|
|
|
@ -20,9 +20,9 @@ suite('Marshalling', () => {
|
|||
});
|
||||
|
||||
test('URI', () => {
|
||||
let value = URI.from({ scheme: 'file', authority: 'server', path: '/shares/c#files', query: 'q', fragment: 'f' });
|
||||
let raw = stringify(value);
|
||||
let clone = <URI>parse(raw);
|
||||
const value = URI.from({ scheme: 'file', authority: 'server', path: '/shares/c#files', query: 'q', fragment: 'f' });
|
||||
const raw = stringify(value);
|
||||
const clone = <URI>parse(raw);
|
||||
|
||||
assert.equal(value.scheme, clone.scheme);
|
||||
assert.equal(value.authority, clone.authority);
|
||||
|
@ -32,7 +32,7 @@ suite('Marshalling', () => {
|
|||
});
|
||||
|
||||
test('Bug 16793:# in folder name => mirror models get out of sync', () => {
|
||||
var uri1 = URI.file('C:\\C#\\file.txt');
|
||||
const uri1 = URI.file('C:\\C#\\file.txt');
|
||||
assert.equal(parse(stringify(uri1)).toString(), uri1.toString());
|
||||
});
|
||||
});
|
|
@ -73,15 +73,15 @@ suite('URI', () => {
|
|||
assert.equal(URI.from({ scheme: 'http', authority: 'a-test-site.com', path: '/', query: '', fragment: 'test=true' }).toString(true), 'http://a-test-site.com/#test=true');
|
||||
assert.equal(URI.from({ scheme: 'http', path: '/api/files/test.me', query: 't=1234' }).toString(true), 'http:/api/files/test.me?t=1234');
|
||||
|
||||
var value = URI.parse('file://shares/pröjects/c%23/#l12');
|
||||
const value = URI.parse('file://shares/pröjects/c%23/#l12');
|
||||
assert.equal(value.authority, 'shares');
|
||||
assert.equal(value.path, '/pröjects/c#/');
|
||||
assert.equal(value.fragment, 'l12');
|
||||
assert.equal(value.toString(), 'file://shares/pr%C3%B6jects/c%23/#l12');
|
||||
assert.equal(value.toString(true), 'file://shares/pröjects/c%23/#l12');
|
||||
|
||||
var uri2 = URI.parse(value.toString(true));
|
||||
var uri3 = URI.parse(value.toString());
|
||||
const uri2 = URI.parse(value.toString(true));
|
||||
const uri3 = URI.parse(value.toString());
|
||||
assert.equal(uri2.authority, uri3.authority);
|
||||
assert.equal(uri2.path, uri3.path);
|
||||
assert.equal(uri2.query, uri3.query);
|
||||
|
@ -130,7 +130,7 @@ suite('URI', () => {
|
|||
});
|
||||
|
||||
test('parse', () => {
|
||||
var value = URI.parse('http:/api/files/test.me?t=1234');
|
||||
let value = URI.parse('http:/api/files/test.me?t=1234');
|
||||
assert.equal(value.scheme, 'http');
|
||||
assert.equal(value.authority, '');
|
||||
assert.equal(value.path, '/api/files/test.me');
|
||||
|
@ -238,7 +238,7 @@ suite('URI', () => {
|
|||
|
||||
test('URI#file, win-speciale', () => {
|
||||
if (isWindows) {
|
||||
var value = URI.file('c:\\test\\drive');
|
||||
let value = URI.file('c:\\test\\drive');
|
||||
assert.equal(value.path, '/c:/test/drive');
|
||||
assert.equal(value.toString(), 'file:///c%3A/test/drive');
|
||||
|
||||
|
@ -298,7 +298,7 @@ suite('URI', () => {
|
|||
|
||||
test('URI#file, always slash', () => {
|
||||
|
||||
var value = URI.file('a.file');
|
||||
let value = URI.file('a.file');
|
||||
assert.equal(value.scheme, 'file');
|
||||
assert.equal(value.authority, '');
|
||||
assert.equal(value.path, '/a.file');
|
||||
|
@ -312,12 +312,12 @@ suite('URI', () => {
|
|||
});
|
||||
|
||||
test('URI.toString, only scheme and query', () => {
|
||||
var value = URI.parse('stuff:?qüery');
|
||||
const value = URI.parse('stuff:?qüery');
|
||||
assert.equal(value.toString(), 'stuff:?q%C3%BCery');
|
||||
});
|
||||
|
||||
test('URI#toString, upper-case percent espaces', () => {
|
||||
var value = URI.parse('file://sh%c3%a4res/path');
|
||||
const value = URI.parse('file://sh%c3%a4res/path');
|
||||
assert.equal(value.toString(), 'file://sh%C3%A4res/path');
|
||||
});
|
||||
|
||||
|
@ -328,12 +328,12 @@ suite('URI', () => {
|
|||
|
||||
test('URI#toString, escape all the bits', () => {
|
||||
|
||||
var value = URI.file('/Users/jrieken/Code/_samples/18500/Mödel + Other Thîngß/model.js');
|
||||
const value = URI.file('/Users/jrieken/Code/_samples/18500/Mödel + Other Thîngß/model.js');
|
||||
assert.equal(value.toString(), 'file:///Users/jrieken/Code/_samples/18500/M%C3%B6del%20%2B%20Other%20Th%C3%AEng%C3%9F/model.js');
|
||||
});
|
||||
|
||||
test('URI#toString, don\'t encode port', () => {
|
||||
var value = URI.parse('http://localhost:8080/far');
|
||||
let value = URI.parse('http://localhost:8080/far');
|
||||
assert.equal(value.toString(), 'http://localhost:8080/far');
|
||||
|
||||
value = URI.from({ scheme: 'http', authority: 'löcalhost:8080', path: '/far', query: undefined, fragment: undefined });
|
||||
|
@ -341,7 +341,7 @@ suite('URI', () => {
|
|||
});
|
||||
|
||||
test('URI#toString, user information in authority', () => {
|
||||
var value = URI.parse('http://foo:bar@localhost/far');
|
||||
let value = URI.parse('http://foo:bar@localhost/far');
|
||||
assert.equal(value.toString(), 'http://foo:bar@localhost/far');
|
||||
|
||||
value = URI.parse('http://foo@localhost/far');
|
||||
|
@ -359,11 +359,11 @@ suite('URI', () => {
|
|||
|
||||
test('correctFileUriToFilePath2', () => {
|
||||
|
||||
var test = (input: string, expected: string) => {
|
||||
const test = (input: string, expected: string) => {
|
||||
expected = normalize(expected, true);
|
||||
var value = URI.parse(input);
|
||||
const value = URI.parse(input);
|
||||
assert.equal(value.fsPath, expected, 'Result for ' + input);
|
||||
var value2 = URI.file(value.fsPath);
|
||||
const value2 = URI.file(value.fsPath);
|
||||
assert.equal(value2.fsPath, expected, 'Result for ' + input);
|
||||
assert.equal(value.toString(), value2.toString());
|
||||
};
|
||||
|
@ -431,7 +431,7 @@ suite('URI', () => {
|
|||
|
||||
test('URI - (de)serialize', function () {
|
||||
|
||||
var values = [
|
||||
const values = [
|
||||
URI.parse('http://localhost:8080/far'),
|
||||
URI.file('c:\\test with %25\\c#code'),
|
||||
URI.file('\\\\shäres\\path\\c#\\plugin.json'),
|
||||
|
|
|
@ -7,16 +7,16 @@ import * as uuid from 'vs/base/common/uuid';
|
|||
|
||||
suite('UUID', () => {
|
||||
test('generation', () => {
|
||||
var asHex = uuid.v4().asHex();
|
||||
const asHex = uuid.v4().asHex();
|
||||
assert.equal(asHex.length, 36);
|
||||
assert.equal(asHex[14], '4');
|
||||
assert.ok(asHex[19] === '8' || asHex[19] === '9' || asHex[19] === 'a' || asHex[19] === 'b');
|
||||
});
|
||||
|
||||
test('parse', () => {
|
||||
var id = uuid.v4();
|
||||
var asHext = id.asHex();
|
||||
var id2 = uuid.parse(asHext);
|
||||
const id = uuid.v4();
|
||||
const asHext = id.asHex();
|
||||
const id2 = uuid.parse(asHext);
|
||||
assert.equal(id.asHex(), id2.asHex());
|
||||
});
|
||||
});
|
||||
|
|
|
@ -8,7 +8,7 @@ import { createMonacoBaseAPI } from 'vs/editor/common/standalone/standaloneBase'
|
|||
import { createMonacoEditorAPI } from 'vs/editor/standalone/browser/standaloneEditor';
|
||||
import { createMonacoLanguagesAPI } from 'vs/editor/standalone/browser/standaloneLanguages';
|
||||
|
||||
var global: any = self;
|
||||
const global: any = self;
|
||||
|
||||
// Set defaults for standalone editor
|
||||
(<any>EDITOR_DEFAULTS).wrappingIndent = WrappingIndent.None;
|
||||
|
|
|
@ -6,7 +6,7 @@ import * as assert from 'assert';
|
|||
import { Graph } from 'vs/platform/instantiation/common/graph';
|
||||
|
||||
suite('Graph', () => {
|
||||
var graph: Graph<string>;
|
||||
let graph: Graph<string>;
|
||||
|
||||
setup(() => {
|
||||
graph = new Graph<string>(s => s);
|
||||
|
@ -34,7 +34,7 @@ suite('Graph', () => {
|
|||
|
||||
test('root', () => {
|
||||
graph.insertEdge('1', '2');
|
||||
var roots = graph.roots();
|
||||
let roots = graph.roots();
|
||||
assert.equal(roots.length, 1);
|
||||
assert.equal(roots[0].data, '2');
|
||||
|
||||
|
@ -48,7 +48,7 @@ suite('Graph', () => {
|
|||
graph.insertEdge('1', '3');
|
||||
graph.insertEdge('3', '4');
|
||||
|
||||
var roots = graph.roots();
|
||||
let roots = graph.roots();
|
||||
assert.equal(roots.length, 2);
|
||||
assert(['2', '4'].every(n => roots.some(node => node.data === n)));
|
||||
});
|
||||
|
|
|
@ -73,9 +73,9 @@ class TestableLogService extends AbstractLogService implements ILogService {
|
|||
}
|
||||
|
||||
suite('AIAdapter', () => {
|
||||
var appInsightsMock: AppInsightsMock;
|
||||
var adapter: AppInsightsAppender;
|
||||
var prefix = 'prefix';
|
||||
let appInsightsMock: AppInsightsMock;
|
||||
let adapter: AppInsightsAppender;
|
||||
let prefix = 'prefix';
|
||||
|
||||
|
||||
setup(() => {
|
||||
|
@ -107,33 +107,33 @@ suite('AIAdapter', () => {
|
|||
});
|
||||
|
||||
test('property limits', () => {
|
||||
var reallyLongPropertyName = 'abcdefghijklmnopqrstuvwxyz';
|
||||
let reallyLongPropertyName = 'abcdefghijklmnopqrstuvwxyz';
|
||||
for (let i = 0; i < 6; i++) {
|
||||
reallyLongPropertyName += 'abcdefghijklmnopqrstuvwxyz';
|
||||
}
|
||||
assert(reallyLongPropertyName.length > 150);
|
||||
|
||||
var reallyLongPropertyValue = 'abcdefghijklmnopqrstuvwxyz012345678901234567890123';
|
||||
let reallyLongPropertyValue = 'abcdefghijklmnopqrstuvwxyz012345678901234567890123';
|
||||
for (let i = 0; i < 21; i++) {
|
||||
reallyLongPropertyValue += 'abcdefghijklmnopqrstuvwxyz012345678901234567890123';
|
||||
}
|
||||
assert(reallyLongPropertyValue.length > 1024);
|
||||
|
||||
var data = Object.create(null);
|
||||
let data = Object.create(null);
|
||||
data[reallyLongPropertyName] = '1234';
|
||||
data['reallyLongPropertyValue'] = reallyLongPropertyValue;
|
||||
adapter.log('testEvent', data);
|
||||
|
||||
assert.equal(appInsightsMock.events.length, 1);
|
||||
|
||||
for (var prop in appInsightsMock.events[0].properties!) {
|
||||
for (let prop in appInsightsMock.events[0].properties!) {
|
||||
assert(prop.length < 150);
|
||||
assert(appInsightsMock.events[0].properties![prop].length < 1024);
|
||||
}
|
||||
});
|
||||
|
||||
test('Different data types', () => {
|
||||
var date = new Date();
|
||||
let date = new Date();
|
||||
adapter.log('testEvent', { favoriteDate: date, likeRed: false, likeBlue: true, favoriteNumber: 1, favoriteColor: 'blue', favoriteCars: ['bmw', 'audi', 'ford'] });
|
||||
|
||||
assert.equal(appInsightsMock.events.length, 1);
|
||||
|
|
|
@ -189,7 +189,7 @@ export class ReviewZoneWidget extends ZoneWidget {
|
|||
}
|
||||
|
||||
protected _fillHead(container: HTMLElement): void {
|
||||
var titleElement = dom.append(this._headElement, dom.$('.review-title'));
|
||||
let titleElement = dom.append(this._headElement, dom.$('.review-title'));
|
||||
|
||||
this._headingLabel = dom.append(titleElement, dom.$('span.filename'));
|
||||
this.createThreadLabel();
|
||||
|
@ -286,7 +286,7 @@ export class ReviewZoneWidget extends ZoneWidget {
|
|||
|
||||
this._localToDispose.push(this.editor.onMouseDown(e => this.onEditorMouseDown(e)));
|
||||
this._localToDispose.push(this.editor.onMouseUp(e => this.onEditorMouseUp(e)));
|
||||
var headHeight = Math.ceil(this.editor.getConfiguration().lineHeight * 1.2);
|
||||
let headHeight = Math.ceil(this.editor.getConfiguration().lineHeight * 1.2);
|
||||
this._headElement.style.height = `${headHeight}px`;
|
||||
this._headElement.style.lineHeight = this._headElement.style.height;
|
||||
|
||||
|
|
|
@ -656,7 +656,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|||
});
|
||||
|
||||
export function getOuterEditor(accessor: ServicesAccessor): ICodeEditor {
|
||||
let editor = accessor.get(ICodeEditorService).getFocusedCodeEditor();
|
||||
const editor = accessor.get(ICodeEditorService).getFocusedCodeEditor();
|
||||
if (editor instanceof EmbeddedCodeEditorWidget) {
|
||||
return editor.getParentEditor();
|
||||
}
|
||||
|
@ -664,13 +664,12 @@ export function getOuterEditor(accessor: ServicesAccessor): ICodeEditor {
|
|||
}
|
||||
|
||||
function closeReviewPanel(accessor: ServicesAccessor, args: any) {
|
||||
var outerEditor = getOuterEditor(accessor);
|
||||
const outerEditor = getOuterEditor(accessor);
|
||||
if (!outerEditor) {
|
||||
return;
|
||||
}
|
||||
|
||||
let controller = ReviewController.get(outerEditor);
|
||||
|
||||
const controller = ReviewController.get(outerEditor);
|
||||
if (!controller) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -10,12 +10,9 @@
|
|||
"no-eval": true,
|
||||
"no-sparse-arrays": true,
|
||||
"no-string-throw": true,
|
||||
"no-unbound-method": [
|
||||
true,
|
||||
"ignore-static"
|
||||
],
|
||||
"no-unsafe-finally": true,
|
||||
"no-unused-expression": true,
|
||||
"no-var-keyword": true,
|
||||
"curly": true,
|
||||
"class-name": true,
|
||||
"label-position": true,
|
||||
|
|
Loading…
Reference in a new issue