提交 7e1a7742 编写于 作者: B Benjamin Pasero

let => const

上级 60211895
......@@ -86,7 +86,7 @@ export abstract class BaseEditor extends Panel implements IEditor {
public create(parent: Builder): void; // create is sync for editors
public create(parent: Builder): TPromise<void>;
public create(parent: Builder): TPromise<void> {
let res = super.create(parent);
const res = super.create(parent);
// Create Editor
this.createEditor(parent);
......@@ -105,7 +105,7 @@ export abstract class BaseEditor extends Panel implements IEditor {
public setVisible(visible: boolean, position?: Position): void; // setVisible is sync for editors
public setVisible(visible: boolean, position?: Position): TPromise<void>;
public setVisible(visible: boolean, position: Position = null): TPromise<void> {
let promise = super.setVisible(visible);
const promise = super.setVisible(visible);
// Propagate to Editor
this.setEditorVisible(visible, position);
......@@ -185,7 +185,7 @@ class EditorRegistry implements IEditorRegistry {
this.instantiationService = service;
for (let key in this.editorInputFactoryConstructors) {
let element = this.editorInputFactoryConstructors[key];
const element = this.editorInputFactoryConstructors[key];
this.createEditorInputFactory(key, element);
}
......@@ -193,7 +193,7 @@ class EditorRegistry implements IEditorRegistry {
}
private createEditorInputFactory(editorInputId: string, ctor: IConstructorSignature0<IEditorInputFactory>): void {
let instance = this.instantiationService.createInstance(ctor);
const instance = this.instantiationService.createInstance(ctor);
this.editorInputFactoryInstances[editorInputId] = instance;
}
......@@ -215,14 +215,14 @@ class EditorRegistry implements IEditorRegistry {
}
public getEditor(input: EditorInput): EditorDescriptor {
let findEditorDescriptors = (input: EditorInput, byInstanceOf?: boolean): EditorDescriptor[]=> {
let matchingDescriptors: EditorDescriptor[] = [];
const findEditorDescriptors = (input: EditorInput, byInstanceOf?: boolean): EditorDescriptor[]=> {
const matchingDescriptors: EditorDescriptor[] = [];
for (let i = 0; i < this.editors.length; i++) {
let editor = this.editors[i];
let inputDescriptors = <SyncDescriptor<EditorInput>[]>editor[INPUT_DESCRIPTORS_PROPERTY];
const editor = this.editors[i];
const inputDescriptors = <SyncDescriptor<EditorInput>[]>editor[INPUT_DESCRIPTORS_PROPERTY];
for (let j = 0; j < inputDescriptors.length; j++) {
let inputClass = inputDescriptors[j].ctor;
const inputClass = inputDescriptors[j].ctor;
// Direct check on constructor type (ignores prototype chain)
if (!byInstanceOf && (<any>input).constructor === inputClass) {
......@@ -250,11 +250,11 @@ class EditorRegistry implements IEditorRegistry {
return matchingDescriptors;
};
let descriptors = findEditorDescriptors(input);
const descriptors = findEditorDescriptors(input);
if (descriptors && descriptors.length > 0) {
// Ask the input for its preferred Editor
let preferredEditorId = input.getPreferredEditorId(descriptors.map(d => d.getId()));
const preferredEditorId = input.getPreferredEditorId(descriptors.map(d => d.getId()));
if (preferredEditorId) {
return this.getEditorById(preferredEditorId);
}
......@@ -268,7 +268,7 @@ class EditorRegistry implements IEditorRegistry {
public getEditorById(editorId: string): EditorDescriptor {
for (let i = 0; i < this.editors.length; i++) {
let editor = this.editors[i];
const editor = this.editors[i];
if (editor.getId() === editorId) {
return editor;
}
......@@ -286,10 +286,10 @@ class EditorRegistry implements IEditorRegistry {
}
public getEditorInputs(): any[] {
let inputClasses: any[] = [];
const inputClasses: any[] = [];
for (let i = 0; i < this.editors.length; i++) {
let editor = this.editors[i];
let editorInputDescriptors = <SyncDescriptor<EditorInput>[]>editor[INPUT_DESCRIPTORS_PROPERTY];
const editor = this.editors[i];
const editorInputDescriptors = <SyncDescriptor<EditorInput>[]>editor[INPUT_DESCRIPTORS_PROPERTY];
inputClasses.push(...editorInputDescriptors.map(descriptor=> descriptor.ctor));
}
......@@ -346,7 +346,7 @@ export class EditorInputActionContributor extends ActionBarContributor {
}
private createPositionArray(): any[] {
let array: any[] = [];
const array: any[] = [];
for (let i = 0; i < POSITIONS.length; i++) {
array[i] = {};
......@@ -371,7 +371,7 @@ export class EditorInputActionContributor extends ActionBarContributor {
private doClearInputsFromCache(cache: { [id: string]: IEditorInputAction[] }): void {
for (let key in cache) {
if (cache.hasOwnProperty(key)) {
let cachedActions = cache[key];
const cachedActions = cache[key];
cachedActions.forEach((action) => {
action.input = null;
action.position = null;
......@@ -412,9 +412,9 @@ export class EditorInputActionContributor extends ActionBarContributor {
this.clearInputsFromCache(context.position, true /* primary actions */);
// First consult cache
let editorInput = context.input;
let editorPosition = context.position;
let cachedActions = this.mapEditorInputActionContextToPrimaryActions[context.position][this.toId(context)];
const editorInput = context.input;
const editorPosition = context.position;
const cachedActions = this.mapEditorInputActionContextToPrimaryActions[context.position][this.toId(context)];
if (cachedActions) {
// Update the input field and position in all actions to indicate this change and return
......@@ -427,7 +427,7 @@ export class EditorInputActionContributor extends ActionBarContributor {
}
// Otherwise collect and keep in cache
let actions = this.getActionsForEditorInput(context);
const actions = this.getActionsForEditorInput(context);
actions.forEach((action) => {
action.input = editorInput;
action.position = editorPosition;
......@@ -470,9 +470,9 @@ export class EditorInputActionContributor extends ActionBarContributor {
this.clearInputsFromCache(context.position, false /* secondary actions */);
// First consult cache
let editorInput = context.input;
let editorPosition = context.position;
let cachedActions = this.mapEditorInputActionContextToSecondaryActions[context.position][this.toId(context)];
const editorInput = context.input;
const editorPosition = context.position;
const cachedActions = this.mapEditorInputActionContextToSecondaryActions[context.position][this.toId(context)];
if (cachedActions) {
// Update the input field and position in all actions to indicate this change and return
......@@ -485,7 +485,7 @@ export class EditorInputActionContributor extends ActionBarContributor {
}
// Otherwise collect and keep in cache
let actions = this.getSecondaryActionsForEditorInput(context);
const actions = this.getSecondaryActionsForEditorInput(context);
actions.forEach((action) => {
action.input = editorInput;
action.position = editorPosition;
......
......@@ -64,7 +64,7 @@ export class BinaryResourceDiffEditor extends BaseEditor implements IVerticalSas
public createEditor(parent: Builder): void {
// Left Container for Binary
let leftBinaryContainerElement = document.createElement('div');
const leftBinaryContainerElement = document.createElement('div');
leftBinaryContainerElement.className = 'binary-container';
this.leftBinaryContainer = $(leftBinaryContainerElement);
this.leftBinaryContainer.tabindex(0); // enable focus support from the editor part (do not remove)
......@@ -82,7 +82,7 @@ export class BinaryResourceDiffEditor extends BaseEditor implements IVerticalSas
this.sash.addListener2('reset', () => this.onSashReset());
// Right Container for Binary
let rightBinaryContainerElement = document.createElement('div');
const rightBinaryContainerElement = document.createElement('div');
rightBinaryContainerElement.className = 'binary-container';
this.rightBinaryContainer = $(rightBinaryContainerElement);
this.rightBinaryContainer.tabindex(0); // enable focus support from the editor part (do not remove)
......@@ -94,11 +94,11 @@ export class BinaryResourceDiffEditor extends BaseEditor implements IVerticalSas
}
public setInput(input: EditorInput, options: EditorOptions): TPromise<void> {
let oldInput = this.getInput();
const oldInput = this.getInput();
super.setInput(input, options);
// Detect options
let forceOpen = options && options.forceOpen;
const forceOpen = options && options.forceOpen;
// Same Input
if (!forceOpen && input.matches(oldInput)) {
......@@ -119,11 +119,11 @@ export class BinaryResourceDiffEditor extends BaseEditor implements IVerticalSas
}
// Render original
let original = <BinaryEditorModel>resolvedModel.originalModel;
const original = <BinaryEditorModel>resolvedModel.originalModel;
this.renderInput(original.getName(), original.getResource(), original.getSize(), original.getETag(), true);
// Render modified
let modified = <BinaryEditorModel>resolvedModel.modifiedModel;
const modified = <BinaryEditorModel>resolvedModel.modifiedModel;
this.renderInput(modified.getName(), modified.getResource(), modified.getSize(), modified.getETag(), false);
});
}
......@@ -138,8 +138,8 @@ export class BinaryResourceDiffEditor extends BaseEditor implements IVerticalSas
}
// Pass to ResourceViewer
let container = isOriginal ? this.leftBinaryContainer : this.rightBinaryContainer;
let scrollbar = isOriginal ? this.leftScrollbar : this.rightScrollbar;
const container = isOriginal ? this.leftBinaryContainer : this.rightBinaryContainer;
const scrollbar = isOriginal ? this.leftScrollbar : this.rightScrollbar;
ResourceViewer.show({ name, resource, size, etag }, container, scrollbar, (meta) => this.handleMetadataChanged(meta, isOriginal));
}
......@@ -172,14 +172,14 @@ export class BinaryResourceDiffEditor extends BaseEditor implements IVerticalSas
}
public layout(dimension: Dimension): void {
let oldDimension = this.dimension;
const oldDimension = this.dimension;
this.dimension = dimension;
// Calculate left hand container width based on sash move or fallback to 50% by default
if (!this.leftContainerWidth || !oldDimension) {
this.leftContainerWidth = this.dimension.width / 2;
} else {
let sashRatio = this.leftContainerWidth / oldDimension.width;
const sashRatio = this.leftContainerWidth / oldDimension.width;
this.leftContainerWidth = this.dimension.width * sashRatio;
}
......@@ -208,7 +208,7 @@ export class BinaryResourceDiffEditor extends BaseEditor implements IVerticalSas
private onSashDrag(e: ISashEvent): void {
// Update Widths and keep in bounds of MIN_CONTAINER_WIDTH for both sides
let newLeftContainerWidth = this.startLeftContainerWidth + e.currentX - e.startX;
const newLeftContainerWidth = this.startLeftContainerWidth + e.currentX - e.startX;
this.leftContainerWidth = Math.max(BinaryResourceDiffEditor.MIN_CONTAINER_WIDTH, newLeftContainerWidth);
if (this.dimension.width - this.leftContainerWidth < BinaryResourceDiffEditor.MIN_CONTAINER_WIDTH) {
this.leftContainerWidth = this.dimension.width - BinaryResourceDiffEditor.MIN_CONTAINER_WIDTH;
......
......@@ -49,7 +49,7 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor {
public createEditor(parent: Builder): void {
// Container for Binary
let binaryContainerElement = document.createElement('div');
const binaryContainerElement = document.createElement('div');
binaryContainerElement.className = 'binary-container';
this.binaryContainer = $(binaryContainerElement);
this.binaryContainer.tabindex(0); // enable focus support from the editor part (do not remove)
......@@ -60,11 +60,11 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor {
}
public setInput(input: EditorInput, options: EditorOptions): TPromise<void> {
let oldInput = this.getInput();
const oldInput = this.getInput();
super.setInput(input, options);
// Detect options
let forceOpen = options && options.forceOpen;
const forceOpen = options && options.forceOpen;
// Same Input
if (!forceOpen && input.matches(oldInput)) {
......@@ -85,7 +85,7 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor {
}
// Render Input
let model = <BinaryEditorModel>resolvedModel;
const model = <BinaryEditorModel>resolvedModel;
ResourceViewer.show({ name: model.getName(), resource: model.getResource(), size: model.getSize(), etag: model.getETag() }, this.binaryContainer, this.scrollbar, (meta) => this.handleMetadataChanged(meta));
return TPromise.as<void>(null);
......
......@@ -95,15 +95,15 @@ export class QuickOpenActionContributor extends ActionBarContributor {
}
public hasActions(context: any): boolean {
let entry = this.getEntry(context);
const entry = this.getEntry(context);
return !!entry;
}
public getActions(context: any): IAction[] {
let actions: Action[] = [];
const actions: Action[] = [];
let entry = this.getEntry(context);
const entry = this.getEntry(context);
if (entry) {
if (!this.openToSideActionInstance) {
this.openToSideActionInstance = this.instantiationService.createInstance(OpenToSideAction);
......
......@@ -120,8 +120,8 @@ export abstract class BaseEditorPicker extends QuickOpenHandler {
return true;
}
let resource = e.getResource();
let targetToMatch = resource ? labels.getPathLabel(e.getResource(), this.contextService) : e.getLabel();
const resource = e.getResource();
const targetToMatch = resource ? labels.getPathLabel(e.getResource(), this.contextService) : e.getLabel();
if (!scorer.matches(targetToMatch, normalizedSearchValueLowercase)) {
return false;
}
......
......@@ -69,17 +69,17 @@ export class StringEditor extends BaseTextEditor {
}
public setInput(input: EditorInput, options: EditorOptions): TPromise<void> {
let oldInput = this.getInput();
const oldInput = this.getInput();
super.setInput(input, options);
// Detect options
let forceOpen = options && options.forceOpen;
const forceOpen = options && options.forceOpen;
// Same Input
if (!forceOpen && input.matches(oldInput)) {
// TextOptions (avoiding instanceof here for a reason, do not change!)
let textOptions = <TextEditorOptions>options;
const textOptions = <TextEditorOptions>options;
if (textOptions && types.isFunction(textOptions.apply)) {
textOptions.apply(this.getControl());
}
......@@ -106,20 +106,20 @@ export class StringEditor extends BaseTextEditor {
}
// Set Editor Model
let textEditor = this.getControl();
let textEditorModel = (<BaseTextEditorModel>resolvedModel).textEditorModel;
const textEditor = this.getControl();
const textEditorModel = (<BaseTextEditorModel>resolvedModel).textEditorModel;
textEditor.setModel(textEditorModel);
// Apply Options from TextOptions
let optionsGotApplied = false;
let textOptions = <TextEditorOptions>options;
const textOptions = <TextEditorOptions>options;
if (textOptions && types.isFunction(textOptions.apply)) {
optionsGotApplied = textOptions.apply(textEditor);
}
// Otherwise restore View State
if (!optionsGotApplied && input instanceof UntitledEditorInput) {
let viewState = this.mapResourceToEditorViewState[input.getResource().toString()];
const viewState = this.mapResourceToEditorViewState[input.getResource().toString()];
if (viewState) {
textEditor.restoreViewState(viewState);
}
......@@ -131,16 +131,16 @@ export class StringEditor extends BaseTextEditor {
}
protected getCodeEditorOptions(): IEditorOptions {
let options = super.getCodeEditorOptions();
const options = super.getCodeEditorOptions();
let input = this.getInput();
let isUntitled = input instanceof UntitledEditorInput;
let isReadonly = !isUntitled; // all string editors are readonly except for the untitled one
const input = this.getInput();
const isUntitled = input instanceof UntitledEditorInput;
const isReadonly = !isUntitled; // all string editors are readonly except for the untitled one
options.readOnly = isReadonly;
let ariaLabel: string;
let inputName = input && input.getName();
const inputName = input && input.getName();
if (isReadonly) {
ariaLabel = inputName ? nls.localize('readonlyEditorWithInputAriaLabel', "{0}. Readonly text editor.", inputName) : nls.localize('readonlyEditorAriaLabel', "Readonly text editor.");
} else {
......@@ -157,12 +157,12 @@ export class StringEditor extends BaseTextEditor {
* If smart reveal is true will only reveal the last line if the line before last is visible #3351
*/
public revealLastLine(smartReveal = false): void {
let codeEditor = <ICodeEditor>this.getControl();
let model = codeEditor.getModel();
const codeEditor = <ICodeEditor>this.getControl();
const model = codeEditor.getModel();
const lineBeforeLastRevealed = codeEditor.getScrollTop() + codeEditor.getLayoutInfo().height >= codeEditor.getScrollHeight();
if (model && (!smartReveal || lineBeforeLastRevealed)) {
let lastLine = model.getLineCount();
const lastLine = model.getLineCount();
codeEditor.revealLine(lastLine);
}
}
......
......@@ -84,11 +84,11 @@ export class TextDiffEditor extends BaseTextEditor {
this.previousDiffAction = new NavigateAction(this, false);
// Support navigation within the diff editor by overriding the editor service within
let delegatingEditorService = this.instantiationService.createInstance(DelegatingWorkbenchEditorService, (input: EditorInput, options?: EditorOptions, arg3?: any) => {
const delegatingEditorService = this.instantiationService.createInstance(DelegatingWorkbenchEditorService, (input: EditorInput, options?: EditorOptions, arg3?: any) => {
// Check if arg4 is a position argument that differs from this editors position
if (types.isUndefinedOrNull(arg3) || arg3 === false || arg3 === this.position) {
let activeDiffInput = <DiffEditorInput>this.getInput();
const activeDiffInput = <DiffEditorInput>this.getInput();
if (input && options && activeDiffInput) {
// Input matches modified side of the diff editor: perform the action on modified side
......@@ -98,7 +98,7 @@ export class TextDiffEditor extends BaseTextEditor {
// Input matches original side of the diff editor: perform the action on original side
else if (input.matches(activeDiffInput.originalInput)) {
let originalEditor = this.getControl().getOriginalEditor();
const originalEditor = this.getControl().getOriginalEditor();
if (options instanceof TextEditorOptions) {
(<TextEditorOptions>options).apply(originalEditor);
......@@ -112,23 +112,23 @@ export class TextDiffEditor extends BaseTextEditor {
});
// Create a special child of instantiator that will delegate all calls to openEditor() to the same diff editor if the input matches with the modified one
let diffEditorInstantiator = this.instantiationService.createChild(new ServiceCollection([IWorkbenchEditorService, delegatingEditorService]));
const diffEditorInstantiator = this.instantiationService.createChild(new ServiceCollection([IWorkbenchEditorService, delegatingEditorService]));
return diffEditorInstantiator.createInstance(DiffEditorWidget, parent.getHTMLElement(), this.getCodeEditorOptions());
}
public setInput(input: EditorInput, options: EditorOptions): TPromise<void> {
let oldInput = this.getInput();
const oldInput = this.getInput();
super.setInput(input, options);
// Detect options
let forceOpen = options && options.forceOpen;
const forceOpen = options && options.forceOpen;
// Same Input
if (!forceOpen && input.matches(oldInput)) {
// TextOptions (avoiding instanceof here for a reason, do not change!)
let textOptions = <TextEditorOptions>options;
const textOptions = <TextEditorOptions>options;
if (textOptions && types.isFunction(textOptions.apply)) {
textOptions.apply(<IDiffEditor>this.getControl());
}
......@@ -155,13 +155,13 @@ export class TextDiffEditor extends BaseTextEditor {
}
// Editor
let diffEditor = <IDiffEditor>this.getControl();
const diffEditor = <IDiffEditor>this.getControl();
diffEditor.setModel((<TextDiffEditorModel>resolvedModel).textDiffEditorModel);
// Respect text diff editor options
let autoRevealFirstChange = true;
if (options instanceof TextDiffEditorOptions) {
let textDiffOptions = (<TextDiffEditorOptions>options);
const textDiffOptions = (<TextDiffEditorOptions>options);
autoRevealFirstChange = !types.isUndefinedOrNull(textDiffOptions.autoRevealFirstChange) ? textDiffOptions.autoRevealFirstChange : autoRevealFirstChange;
}
......@@ -195,10 +195,10 @@ export class TextDiffEditor extends BaseTextEditor {
private openAsBinary(input: EditorInput, options: EditorOptions): boolean {
if (input instanceof DiffEditorInput) {
let originalInput = input.originalInput;
let modifiedInput = input.modifiedInput;
const originalInput = input.originalInput;
const modifiedInput = input.modifiedInput;
let binaryDiffInput = new DiffEditorInput(input.getName(), input.getDescription(), originalInput, modifiedInput, true);
const binaryDiffInput = new DiffEditorInput(input.getName(), input.getDescription(), originalInput, modifiedInput, true);
this.editorService.openEditor(binaryDiffInput, options, this.position).done(null, onUnexpectedError);
......@@ -209,17 +209,17 @@ export class TextDiffEditor extends BaseTextEditor {
}
protected getCodeEditorOptions(): IEditorOptions {
let options: IDiffEditorOptions = super.getCodeEditorOptions();
const options: IDiffEditorOptions = super.getCodeEditorOptions();
let input = this.input;
const input = this.input;
if (input instanceof DiffEditorInput) {
let modifiedInput = input.modifiedInput;
let readOnly = modifiedInput instanceof StringEditorInput || modifiedInput instanceof ResourceEditorInput;
const modifiedInput = input.modifiedInput;
const readOnly = modifiedInput instanceof StringEditorInput || modifiedInput instanceof ResourceEditorInput;
options.readOnly = readOnly;
let ariaLabel: string;
let inputName = input && input.getName();
const inputName = input && input.getName();
if (readOnly) {
ariaLabel = inputName ? nls.localize('readonlyEditorWithInputAriaLabel', "{0}. Readonly text compare editor.", inputName) : nls.localize('readonlyEditorAriaLabel', "Readonly text compare editor.");
} else {
......@@ -236,7 +236,7 @@ export class TextDiffEditor extends BaseTextEditor {
private isFileBinaryError(error: Error): boolean;
private isFileBinaryError(error: any): boolean {
if (types.isArray(error)) {
let errors = <Error[]>error;
const errors = <Error[]>error;
return errors.some((e) => this.isFileBinaryError(e));
}
......@@ -275,16 +275,16 @@ export class TextDiffEditor extends BaseTextEditor {
}
public getSecondaryActions(): IAction[] {
let actions = super.getSecondaryActions();
const actions = super.getSecondaryActions();
const control = this.getControl();
let inlineModeActive = control && !control.renderSideBySide;
let inlineLabel = nls.localize('inlineDiffLabel', "Switch to Inline View");
let sideBySideLabel = nls.localize('sideBySideDiffLabel', "Switch to Side by Side View");
const inlineLabel = nls.localize('inlineDiffLabel', "Switch to Inline View");
const sideBySideLabel = nls.localize('sideBySideDiffLabel', "Switch to Side by Side View");
// Action to toggle editor mode from inline to side by side
let toggleEditorModeAction = new Action('toggle.diff.editorMode', inlineModeActive ? sideBySideLabel : inlineLabel, null, true, () => {
const toggleEditorModeAction = new Action('toggle.diff.editorMode', inlineModeActive ? sideBySideLabel : inlineLabel, null, true, () => {
this.getControl().updateOptions(<IDiffEditorOptions>{
renderSideBySide: inlineModeActive
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册