Skip to content

Commit

Permalink
Mark most private static constants as private static readonly
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed Nov 20, 2017
1 parent 6663fcd commit d8e926b
Show file tree
Hide file tree
Showing 162 changed files with 365 additions and 365 deletions.
2 changes: 1 addition & 1 deletion extensions/git/src/autofetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { eventToPromise, filterEvent } from './util';

export class AutoFetcher {

private static Period = 3 * 60 * 1000 /* three minutes */;
private static readonly Period = 3 * 60 * 1000 /* three minutes */;

private _onDidChange = new EventEmitter<boolean>();
private onDidChange = this._onDidChange.event;
Expand Down
4 changes: 2 additions & 2 deletions src/vs/base/browser/touch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ interface TouchEvent extends Event {

export class Gesture implements IDisposable {

private static HOLD_DELAY = 700;
private static SCROLL_FRICTION = -0.005;
private static readonly HOLD_DELAY = 700;
private static readonly SCROLL_FRICTION = -0.005;

private targetElement: HTMLElement;
private callOnTarget: IDisposable[];
Expand Down
4 changes: 2 additions & 2 deletions src/vs/base/browser/ui/contextview/contextview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ function layout(view: ISize, around: IView, viewport: IView, anchorPosition: Anc

export class ContextView {

private static BUBBLE_UP_EVENTS = ['click', 'keydown', 'focus', 'blur'];
private static BUBBLE_DOWN_EVENTS = ['click'];
private static readonly BUBBLE_UP_EVENTS = ['click', 'keydown', 'focus', 'blur'];
private static readonly BUBBLE_DOWN_EVENTS = ['click'];

private $container: Builder;
private $view: Builder;
Expand Down
10 changes: 5 additions & 5 deletions src/vs/base/browser/ui/resourceviewer/resourceViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ function imageSrc(descriptor: IResourceDescriptor): string {
*/
export class ResourceViewer {

private static KB = 1024;
private static MB = ResourceViewer.KB * ResourceViewer.KB;
private static GB = ResourceViewer.MB * ResourceViewer.KB;
private static TB = ResourceViewer.GB * ResourceViewer.KB;
private static readonly KB = 1024;
private static readonly MB = ResourceViewer.KB * ResourceViewer.KB;
private static readonly GB = ResourceViewer.MB * ResourceViewer.KB;
private static readonly TB = ResourceViewer.GB * ResourceViewer.KB;

private static MAX_IMAGE_SIZE = ResourceViewer.MB; // showing images inline is memory intense, so we have a limit
private static readonly MAX_IMAGE_SIZE = ResourceViewer.MB; // showing images inline is memory intense, so we have a limit

public static show(
descriptor: IResourceDescriptor,
Expand Down
4 changes: 2 additions & 2 deletions src/vs/base/browser/ui/splitview/panelview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface IPanelStyles {

export abstract class Panel implements IView {

private static HEADER_SIZE = 22;
private static readonly HEADER_SIZE = 22;

protected _expanded: boolean;
private expandedSize: number | undefined = undefined;
Expand Down Expand Up @@ -226,7 +226,7 @@ interface IDndContext {

class PanelDraggable implements IDisposable {

private static DefaultDragOverBackgroundColor = new Color(new RGBA(128, 128, 128, 0.5));
private static readonly DefaultDragOverBackgroundColor = new Color(new RGBA(128, 128, 128, 0.5));

// see https://github.com/Microsoft/vscode/issues/14470
private dragOverCounter = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/common/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export interface EmitterOptions {
*/
export class Emitter<T> {

private static _noop = function () { };
private static readonly _noop = function () { };

private _event: Event<T>;
private _listeners: LinkedList<Listener>;
Expand Down
4 changes: 2 additions & 2 deletions src/vs/base/common/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ export class StringIterator implements IKeyIterator {

export class PathIterator implements IKeyIterator {

private static _fwd = '/'.charCodeAt(0);
private static _bwd = '\\'.charCodeAt(0);
private static readonly _fwd = '/'.charCodeAt(0);
private static readonly _bwd = '\\'.charCodeAt(0);

private _value: string;
private _from: number;
Expand Down
4 changes: 2 additions & 2 deletions src/vs/base/common/uuid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class ValueUUID implements UUID {

class V4UUID extends ValueUUID {

private static _chars = ['0', '1', '2', '3', '4', '5', '6', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
private static readonly _chars = ['0', '1', '2', '3', '4', '5', '6', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];

private static _timeHighBits = ['8', '9', 'a', 'b'];
private static readonly _timeHighBits = ['8', '9', 'a', 'b'];

private static _oneOf(array: string[]): string {
return array[Math.floor(array.length * Math.random())];
Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/node/processes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export abstract class AbstractProcess<TProgressData> {
// Default is to do nothing.
}

private static regexp = /^[^"].* .*[^"]/;
private static readonly regexp = /^[^"].* .*[^"]/;
private ensureQuotes(value: string) {
if (AbstractProcess.regexp.test(value)) {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/parts/ipc/node/ipc.net.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function generateRandomPipeName(): string {

export class Protocol implements IMessagePassingProtocol {

private static _headerLen = 17;
private static readonly _headerLen = 17;

private _onMessage = new Emitter<any>();

Expand Down
4 changes: 2 additions & 2 deletions src/vs/base/parts/quickopen/browser/quickOpenWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ const DEFAULT_INPUT_ARIA_LABEL = nls.localize('quickOpenAriaLabel', "Quick picke

export class QuickOpenWidget implements IModelProvider {

private static MAX_WIDTH = 600; // Max total width of quick open widget
private static MAX_ITEMS_HEIGHT = 20 * 22; // Max height of item list below input field
private static readonly MAX_WIDTH = 600; // Max total width of quick open widget
private static readonly MAX_ITEMS_HEIGHT = 20 * 22; // Max height of item list below input field

private isDisposed: boolean;
private options: IQuickOpenOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import product from 'vs/platform/node/product';

export class NodeCachedDataCleaner {

private static _DataMaxAge = product.nameLong.indexOf('Insiders') >= 0
private static readonly _DataMaxAge = product.nameLong.indexOf('Insiders') >= 0
? 1000 * 60 * 60 * 24 * 7 // roughly 1 week
: 1000 * 60 * 60 * 24 * 30 * 3; // roughly 3 months

Expand Down
2 changes: 1 addition & 1 deletion src/vs/code/electron-main/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import { touch } from 'vs/base/node/pfs';

export class CodeApplication {

private static APP_ICON_REFRESH_KEY = 'macOSAppIconRefresh3';
private static readonly APP_ICON_REFRESH_KEY = 'macOSAppIconRefresh3';

private toDispose: IDisposable[];
private windowsMainService: IWindowsMainService;
Expand Down
2 changes: 1 addition & 1 deletion src/vs/code/electron-main/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export interface IKeybinding {

export class KeybindingsResolver {

private static lastKnownKeybindingsMapStorageKey = 'lastKnownKeybindings';
private static readonly lastKnownKeybindingsMapStorageKey = 'lastKnownKeybindings';

private commandIds: Set<string>;
private keybindings: { [commandId: string]: IKeybinding };
Expand Down
2 changes: 1 addition & 1 deletion src/vs/code/electron-main/menus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const telemetryFrom = 'menu';

export class CodeMenu {

private static MAX_MENU_RECENT_ENTRIES = 10;
private static readonly MAX_MENU_RECENT_ENTRIES = 10;

private keys = [
'files.autoSave',
Expand Down
10 changes: 5 additions & 5 deletions src/vs/code/electron-main/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ export class CodeWindow implements ICodeWindow {
public static readonly themeStorageKey = 'theme';
public static readonly themeBackgroundStorageKey = 'themeBackground';

private static DEFAULT_BG_LIGHT = '#FFFFFF';
private static DEFAULT_BG_DARK = '#1E1E1E';
private static DEFAULT_BG_HC_BLACK = '#000000';
private static readonly DEFAULT_BG_LIGHT = '#FFFFFF';
private static readonly DEFAULT_BG_DARK = '#1E1E1E';
private static readonly DEFAULT_BG_HC_BLACK = '#000000';

private static MIN_WIDTH = 200;
private static MIN_HEIGHT = 120;
private static readonly MIN_WIDTH = 200;
private static readonly MIN_HEIGHT = 120;

private hiddenTitleBarStyle: boolean;
private showTimeoutHandle: any;
Expand Down
4 changes: 2 additions & 2 deletions src/vs/code/electron-main/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class WindowsManager implements IWindowsMainService {

_serviceBrand: any;

private static windowsStateStorageKey = 'windowsState';
private static readonly windowsStateStorageKey = 'windowsState';

private static WINDOWS: CodeWindow[] = [];

Expand Down Expand Up @@ -1582,7 +1582,7 @@ interface IInternalNativeOpenDialogOptions extends INativeOpenDialogOptions {

class FileDialog {

private static workingDirPickerStorageKey = 'pickerWorkingDir';
private static readonly workingDirPickerStorageKey = 'pickerWorkingDir';

constructor(
private environmentService: IEnvironmentService,
Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/browser/controller/mouseHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ class MouseDownOperation extends Disposable {

class MouseDownState {

private static CLEAR_MOUSE_DOWN_COUNT_TIME = 400; // ms
private static readonly CLEAR_MOUSE_DOWN_COUNT_TIME = 400; // ms

private _altKey: boolean;
public get altKey(): boolean { return this._altKey; }
Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/browser/controller/textAreaState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export class TextAreaState {
}

export class PagedScreenReaderStrategy {
private static _LINES_PER_PAGE = 10;
private static readonly _LINES_PER_PAGE = 10;

private static _getPageOfLine(lineNumber: number): number {
return Math.floor((lineNumber - 1) / PagedScreenReaderStrategy._LINES_PER_PAGE);
Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/browser/view/viewLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ class ViewLayerRenderer<T extends IVisibleLine> {
}
}

private static _sb = createStringBuilder(100000);
private static readonly _sb = createStringBuilder(100000);

private _finishRendering(ctx: IRendererContext<T>, domNodeIsEmpty: boolean, deltaTop: number[]): void {

Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/browser/viewParts/lines/viewLines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost<ViewLine>,
/**
* Adds this ammount of pixels to the right of lines (no-one wants to type near the edge of the viewport)
*/
private static HORIZONTAL_EXTRA_PX = 30;
private static readonly HORIZONTAL_EXTRA_PX = 30;

private readonly _linesContent: FastDomNode<HTMLElement>;
private readonly _textRangeRestingSpot: HTMLElement;
Expand Down
16 changes: 8 additions & 8 deletions src/vs/editor/browser/viewParts/selections/selections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ const isIEWithZoomingIssuesNearRoundedBorders = browser.isEdgeOrIE;

export class SelectionsOverlay extends DynamicViewOverlay {

private static SELECTION_CLASS_NAME = 'selected-text';
private static SELECTION_TOP_LEFT = 'top-left-radius';
private static SELECTION_BOTTOM_LEFT = 'bottom-left-radius';
private static SELECTION_TOP_RIGHT = 'top-right-radius';
private static SELECTION_BOTTOM_RIGHT = 'bottom-right-radius';
private static EDITOR_BACKGROUND_CLASS_NAME = 'monaco-editor-background';

private static ROUNDED_PIECE_WIDTH = 10;
private static readonly SELECTION_CLASS_NAME = 'selected-text';
private static readonly SELECTION_TOP_LEFT = 'top-left-radius';
private static readonly SELECTION_BOTTOM_LEFT = 'bottom-left-radius';
private static readonly SELECTION_TOP_RIGHT = 'top-right-radius';
private static readonly SELECTION_BOTTOM_RIGHT = 'bottom-right-radius';
private static readonly EDITOR_BACKGROUND_CLASS_NAME = 'monaco-editor-background';

private static readonly ROUNDED_PIECE_WIDTH = 10;

private _context: ViewContext;
private _lineHeight: number;
Expand Down
4 changes: 2 additions & 2 deletions src/vs/editor/browser/widget/diffEditorWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ let DIFF_EDITOR_ID = 0;

export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffEditor {

private static ONE_OVERVIEW_WIDTH = 15;
private static readonly ONE_OVERVIEW_WIDTH = 15;
public static readonly ENTIRE_DIFF_OVERVIEW_WIDTH = 30;
private static UPDATE_DIFF_DECORATIONS_DELAY = 200; // ms
private static readonly UPDATE_DIFF_DECORATIONS_DELAY = 200; // ms

private readonly _onDidDispose: Emitter<void> = this._register(new Emitter<void>());
public readonly onDidDispose: Event<void> = this._onDidDispose.event;
Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/common/model/editableTextModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ export class EditableTextModel extends TextModelWithDecorations implements edito
});
}

private static _DECORATION_OPTION = ModelDecorationOptions.register({
private static readonly _DECORATION_OPTION = ModelDecorationOptions.register({
stickiness: editorCommon.TrackedRangeStickiness.AlwaysGrowsWhenTypingAtEdges
});

Expand Down
6 changes: 3 additions & 3 deletions src/vs/editor/common/model/textModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export interface ITextModelCreationData {
}

export class TextModel extends Disposable implements editorCommon.ITextModel {
private static MODEL_SYNC_LIMIT = 50 * 1024 * 1024; // 50 MB
private static MODEL_TOKENIZATION_LIMIT = 20 * 1024 * 1024; // 20 MB
private static MANY_MANY_LINES = 300 * 1000; // 300K lines
private static readonly MODEL_SYNC_LIMIT = 50 * 1024 * 1024; // 50 MB
private static readonly MODEL_TOKENIZATION_LIMIT = 20 * 1024 * 1024; // 20 MB
private static readonly MANY_MANY_LINES = 300 * 1000; // 300K lines

public static DEFAULT_CREATION_OPTIONS: editorCommon.ITextModelCreationOptions = {
tabSize: EDITOR_MODEL_DEFAULTS.tabSize,
Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/common/model/textModelWithTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ModelTokensChangedEventBuilder {

export class TextModelWithTokens extends TextModel implements editorCommon.ITokenizedModel {

private static MODE_TOKENIZATION_FAILED_MSG = nls.localize('mode.tokenizationSupportFailed', "The mode has failed while tokenizing the input.");
private static readonly MODE_TOKENIZATION_FAILED_MSG = nls.localize('mode.tokenizationSupportFailed', "The mode has failed while tokenizing the input.");

private readonly _onDidChangeLanguage: Emitter<IModelLanguageChangedEvent> = this._register(new Emitter<IModelLanguageChangedEvent>());
public readonly onDidChangeLanguage: Event<IModelLanguageChangedEvent> = this._onDidChangeLanguage.event;
Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/common/services/editorSimpleWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ export abstract class BaseEditorSimpleWorker {

// ---- BEGIN minimal edits ---------------------------------------------------------------

private static _diffLimit = 10000;
private static readonly _diffLimit = 10000;

public computeMoreMinimalEdits(modelUrl: string, edits: TextEdit[]): TPromise<TextEdit[]> {
const model = this._getModel(modelUrl);
Expand Down
4 changes: 2 additions & 2 deletions src/vs/editor/contrib/bracketMatching/bracketMatching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class BracketsData {
}

export class BracketMatchingController extends Disposable implements editorCommon.IEditorContribution {
private static ID = 'editor.contrib.bracketMatchingController';
private static readonly ID = 'editor.contrib.bracketMatchingController';

public static get(editor: ICodeEditor): BracketMatchingController {
return editor.getContribution<BracketMatchingController>(BracketMatchingController.ID);
Expand Down Expand Up @@ -148,7 +148,7 @@ export class BracketMatchingController extends Disposable implements editorCommo
this._editor.revealRange(newSelections[0]);
}

private static _DECORATION_OPTIONS = ModelDecorationOptions.register({
private static readonly _DECORATION_OPTIONS = ModelDecorationOptions.register({
stickiness: editorCommon.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
className: 'bracket-match'
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { BracketMatchingController } from 'vs/editor/contrib/bracketMatching/bra
suite('bracket matching', () => {
class BracketMode extends MockMode {

private static _id = new LanguageIdentifier('bracketMode', 3);
private static readonly _id = new LanguageIdentifier('bracketMode', 3);

constructor() {
super(BracketMode._id);
Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/contrib/colorPicker/colorPickerWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ class HueStrip extends Strip {

export class ColorPickerWidget extends Widget {

private static ID = 'editor.contrib.colorPickerWidget';
private static readonly ID = 'editor.contrib.colorPickerWidget';

body: ColorPickerBody;

Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/contrib/contextmenu/contextmenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface IPosition {

export class ContextMenuController implements IEditorContribution {

private static ID = 'editor.contrib.contextmenu';
private static readonly ID = 'editor.contrib.contextmenu';

public static get(editor: ICodeEditor): ContextMenuController {
return editor.getContribution<ContextMenuController>(ContextMenuController.ID);
Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/contrib/cursorUndo/cursorUndo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CursorState {

export class CursorUndoController extends Disposable implements IEditorContribution {

private static ID = 'editor.contrib.cursorUndoController';
private static readonly ID = 'editor.contrib.cursorUndoController';

public static get(editor: ICodeEditor): CursorUndoController {
return editor.getContribution<CursorUndoController>(CursorUndoController.ID);
Expand Down
4 changes: 2 additions & 2 deletions src/vs/editor/contrib/dnd/dnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { ModelDecorationOptions } from 'vs/editor/common/model/textModelWithDeco

export class DragAndDropController implements editorCommon.IEditorContribution {

private static ID = 'editor.contrib.dragAndDrop';
private static readonly ID = 'editor.contrib.dragAndDrop';

private _editor: ICodeEditor;
private _toUnhook: IDisposable[];
Expand Down Expand Up @@ -161,7 +161,7 @@ export class DragAndDropController implements editorCommon.IEditorContribution {
this._mouseDown = false;
}

private static _DECORATION_OPTIONS = ModelDecorationOptions.register({
private static readonly _DECORATION_OPTIONS = ModelDecorationOptions.register({
className: 'dnd-target'
});

Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/contrib/find/findController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export interface IFindStartOptions {

export class CommonFindController extends Disposable implements editorCommon.IEditorContribution {

private static ID = 'editor.contrib.findController';
private static readonly ID = 'editor.contrib.findController';

protected _editor: ICodeEditor;
private _findWidgetVisible: IContextKey<boolean>;
Expand Down
Loading

0 comments on commit d8e926b

Please sign in to comment.