未验证 提交 1cba9117 编写于 作者: B Benjamin Pasero 提交者: GitHub

Strict init (#80190)

* strict init

* more strict props
上级 bdb28224
......@@ -27,11 +27,11 @@ export interface IIconLabelValueOptions {
}
class FastLabelNode {
private disposed: boolean;
private _textContent: string;
private _className: string;
private _title: string;
private _empty: boolean;
private disposed: boolean | undefined;
private _textContent: string | undefined;
private _className: string | undefined;
private _title: string | undefined;
private _empty: boolean | undefined;
constructor(private _element: HTMLElement) {
}
......@@ -89,7 +89,7 @@ export class IconLabel extends Disposable {
private domNode: FastLabelNode;
private labelDescriptionContainer: FastLabelNode;
private labelNode: FastLabelNode | HighlightedLabel;
private descriptionNode: FastLabelNode | HighlightedLabel;
private descriptionNode: FastLabelNode | HighlightedLabel | undefined;
private descriptionNodeFactory: () => FastLabelNode | HighlightedLabel;
constructor(container: HTMLElement, options?: IIconLabelCreationOptions) {
......
......@@ -36,8 +36,8 @@ const defaultOpts = {
export class ProgressBar extends Disposable {
private options: IProgressBarOptions;
private workedVal: number;
private element: HTMLElement;
private bit: HTMLElement;
private element!: HTMLElement;
private bit!: HTMLElement;
private totalWork: number | undefined;
private progressBarBackground: Color | undefined;
private showDelayedScheduler: RunOnceScheduler;
......@@ -232,4 +232,4 @@ export class ProgressBar extends Disposable {
this.bit.style.backgroundColor = background;
}
}
}
\ No newline at end of file
}
......@@ -42,11 +42,11 @@ export interface IConfigOptions<T> {
* - configurable defaults
*/
export class ConfigWatcher<T> extends Disposable implements IConfigWatcher<T> {
private cache: T;
private parseErrors: json.ParseError[];
private disposed: boolean;
private loaded: boolean;
private timeoutHandle: NodeJS.Timer | null;
private cache: T | undefined;
private parseErrors: json.ParseError[] | undefined;
private disposed: boolean | undefined;
private loaded: boolean | undefined;
private timeoutHandle: NodeJS.Timer | null | undefined;
private readonly _onDidUpdateConfiguration: Emitter<IConfigurationChangeEvent<T>>;
constructor(private _path: string, private options: IConfigOptions<T> = { defaultConfig: Object.create(null), onError: error => console.error(error) }) {
......@@ -62,7 +62,7 @@ export class ConfigWatcher<T> extends Disposable implements IConfigWatcher<T> {
}
get hasParseErrors(): boolean {
return this.parseErrors && this.parseErrors.length > 0;
return !!this.parseErrors && this.parseErrors.length > 0;
}
get onDidUpdateConfiguration(): Event<IConfigurationChangeEvent<T>> {
......@@ -161,7 +161,7 @@ export class ConfigWatcher<T> extends Disposable implements IConfigWatcher<T> {
if (!objects.equals(currentConfig, this.cache)) {
this.updateCache(currentConfig);
this._onDidUpdateConfiguration.fire({ config: this.cache });
this._onDidUpdateConfiguration.fire({ config: currentConfig });
}
if (callback) {
......@@ -173,7 +173,7 @@ export class ConfigWatcher<T> extends Disposable implements IConfigWatcher<T> {
getConfig(): T {
this.ensureLoaded();
return this.cache;
return this.cache!;
}
private ensureLoaded(): void {
......@@ -186,4 +186,4 @@ export class ConfigWatcher<T> extends Disposable implements IConfigWatcher<T> {
this.disposed = true;
super.dispose();
}
}
\ No newline at end of file
}
......@@ -420,8 +420,8 @@ export class SQLiteStorageDatabase implements IStorageDatabase {
}
class SQLiteStorageDatabaseLogger {
private readonly logTrace: (msg: string) => void;
private readonly logError: (error: string | Error) => void;
private readonly logTrace: ((msg: string) => void) | undefined;
private readonly logError: ((error: string | Error) => void) | undefined;
constructor(options?: ISQLiteStorageDatabaseLoggingOptions) {
if (options && typeof options.logTrace === 'function') {
......
......@@ -111,7 +111,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
private readonly _notificationService: INotificationService;
private _domNode!: HTMLElement;
private _cachedHeight: number | null;
private _cachedHeight: number | null = null;
private _findInput!: FindInput;
private _replaceInput!: ReplaceInput;
......
......@@ -441,7 +441,7 @@ export class Configuration {
return this._defaultConfiguration;
}
private _userConfiguration: ConfigurationModel | null;
private _userConfiguration: ConfigurationModel | null = null;
get userConfiguration(): ConfigurationModel {
if (!this._userConfiguration) {
this._userConfiguration = this._remoteUserConfiguration.isEmpty() ? this._localUserConfiguration : this._localUserConfiguration.merge(this._remoteUserConfiguration);
......
......@@ -24,8 +24,8 @@ export interface IContextMenuHandlerOptions {
}
export class ContextMenuHandler {
private focusToReturn: HTMLElement;
private block: HTMLElement | null;
private focusToReturn: HTMLElement | null = null;
private block: HTMLElement | null = null;
private options: IContextMenuHandlerOptions = { blockMouse: true };
constructor(
......
......@@ -38,7 +38,7 @@ export class DiskFileSystemProvider extends Disposable implements IFileSystemPro
onDidChangeCapabilities: Event<void> = Event.None;
protected _capabilities: FileSystemProviderCapabilities;
protected _capabilities: FileSystemProviderCapabilities | undefined;
get capabilities(): FileSystemProviderCapabilities {
if (!this._capabilities) {
this._capabilities =
......
......@@ -13,7 +13,7 @@ import { ThrottledDelayer } from 'vs/base/common/async';
import { join, basename } from 'vs/base/common/path';
export class FileWatcher extends Disposable {
private isDisposed: boolean;
private isDisposed: boolean | undefined;
private fileChangesDelayer: ThrottledDelayer<void> = this._register(new ThrottledDelayer<void>(CHANGE_BUFFER_DELAY * 2 /* sync on delay from underlying library */));
private fileChangesBuffer: IDiskFileChange[] = [];
......@@ -125,4 +125,4 @@ export class FileWatcher extends Disposable {
super.dispose();
}
}
\ No newline at end of file
}
......@@ -36,8 +36,8 @@ export class NsfwWatcherService implements IWatcherService {
private static readonly FS_EVENT_DELAY = 50; // aggregate and only emit events when changes have stopped for this duration (in ms)
private _pathWatchers: { [watchPath: string]: IPathWatcher } = {};
private _verboseLogging: boolean;
private enospcErrorLogged: boolean;
private _verboseLogging: boolean | undefined;
private enospcErrorLogged: boolean | undefined;
private _onWatchEvent = new Emitter<IDiskFileChange[]>();
readonly onWatchEvent = this._onWatchEvent.event;
......
......@@ -12,9 +12,10 @@ import { IWatcherRequest } from 'vs/platform/files/node/watcher/nsfw/watcher';
import { getPathFromAmdModule } from 'vs/base/common/amd';
export class FileWatcher extends Disposable {
private static readonly MAX_RESTARTS = 5;
private service: WatcherChannelClient;
private service: WatcherChannelClient | undefined;
private isDisposed: boolean;
private restartCounter: number;
......@@ -77,7 +78,7 @@ export class FileWatcher extends Disposable {
setVerboseLogging(verboseLogging: boolean): void {
this.verboseLogging = verboseLogging;
if (!this.isDisposed) {
if (!this.isDisposed && this.service) {
this.service.setVerboseLogging(verboseLogging);
}
}
......@@ -89,7 +90,9 @@ export class FileWatcher extends Disposable {
setFolders(folders: IWatcherRequest[]): void {
this.folders = folders;
this.service.setRoots(folders);
if (this.service) {
this.service.setRoots(folders);
}
}
dispose(): void {
......
......@@ -37,11 +37,11 @@ export class ChokidarWatcherService implements IWatcherService {
private _pollingInterval?: number;
private _usePolling?: boolean;
private _verboseLogging: boolean;
private _verboseLogging: boolean | undefined;
private spamCheckStartTime: number;
private spamWarningLogged: boolean;
private enospcErrorLogged: boolean;
private spamCheckStartTime: number | undefined;
private spamWarningLogged: boolean | undefined;
private enospcErrorLogged: boolean | undefined;
private _onWatchEvent = new Emitter<IDiskFileChange[]>();
readonly onWatchEvent = this._onWatchEvent.event;
......@@ -231,7 +231,7 @@ export class ChokidarWatcherService implements IWatcherService {
if (undeliveredFileEvents.length === 0) {
this.spamWarningLogged = false;
this.spamCheckStartTime = now;
} else if (!this.spamWarningLogged && this.spamCheckStartTime + ChokidarWatcherService.EVENT_SPAM_WARNING_THRESHOLD < now) {
} else if (!this.spamWarningLogged && typeof this.spamCheckStartTime === 'number' && this.spamCheckStartTime + ChokidarWatcherService.EVENT_SPAM_WARNING_THRESHOLD < now) {
this.spamWarningLogged = true;
this.warn(`Watcher is busy catching up with ${undeliveredFileEvents.length} file changes in 60 seconds. Latest changed path is "${event.path}"`);
}
......
......@@ -16,7 +16,7 @@ export class FileWatcher extends Disposable {
private isDisposed: boolean;
private restartCounter: number;
private service: WatcherChannelClient;
private service: WatcherChannelClient | undefined;
constructor(
private folders: IWatcherRequest[],
......@@ -81,13 +81,18 @@ export class FileWatcher extends Disposable {
setVerboseLogging(verboseLogging: boolean): void {
this.verboseLogging = verboseLogging;
this.service.setVerboseLogging(verboseLogging);
if (this.service) {
this.service.setVerboseLogging(verboseLogging);
}
}
setFolders(folders: IWatcherRequest[]): void {
this.folders = folders;
this.service.setRoots(folders);
if (this.service) {
this.service.setRoots(folders);
}
}
dispose(): void {
......
......@@ -139,10 +139,10 @@ export class LifecycleService extends Disposable implements ILifecycleService {
private oneTimeListenerTokenGenerator = 0;
private windowCounter = 0;
private pendingQuitPromise: Promise<boolean> | null;
private pendingQuitPromiseResolve: { (veto: boolean): void } | null;
private pendingQuitPromise: Promise<boolean> | null = null;
private pendingQuitPromiseResolve: { (veto: boolean): void } | null = null;
private pendingWillShutdownPromise: Promise<void> | null;
private pendingWillShutdownPromise: Promise<void> | null = null;
private _quitRequested = false;
get quitRequested(): boolean { return this._quitRequested; }
......
......@@ -152,7 +152,7 @@ export class GlobalStorageDatabaseChannelClient extends Disposable implements IS
private readonly _onDidChangeItemsExternal: Emitter<IStorageItemsChangeEvent> = this._register(new Emitter<IStorageItemsChangeEvent>());
readonly onDidChangeItemsExternal: Event<IStorageItemsChangeEvent> = this._onDidChangeItemsExternal.event;
private onDidChangeItemsOnMainListener: IDisposable;
private onDidChangeItemsOnMainListener: IDisposable | undefined;
constructor(private channel: IChannel) {
super();
......
......@@ -99,7 +99,7 @@ export class StorageMainService extends Disposable implements IStorageMainServic
private storage: IStorage;
private initializePromise: Promise<void>;
private initializePromise: Promise<void> | undefined;
constructor(
@ILogService private readonly logService: ILogService,
......
......@@ -21,7 +21,7 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
private readonly _proxy: ExtHostDebugServiceShape;
private readonly _toDispose = new DisposableStore();
private _breakpointEventsActive: boolean;
private _breakpointEventsActive: boolean | undefined;
private readonly _debugAdapters: Map<number, ExtensionHostDebugAdapter>;
private _debugAdaptersHandleCounter = 1;
private readonly _debugConfigurationProviders: Map<number, IDebugConfigurationProvider>;
......
......@@ -33,8 +33,8 @@ export abstract class Part extends Component implements ISerializableView {
get dimension(): Dimension { return this._dimension; }
private parent: HTMLElement;
private titleArea: HTMLElement | null;
private contentArea: HTMLElement | null;
private titleArea: HTMLElement | null = null;
private contentArea: HTMLElement | null = null;
private partLayout: PartLayout;
constructor(
......
......@@ -41,8 +41,8 @@ export abstract class BaseEditor extends Panel implements IEditor {
readonly onDidSizeConstraintsChange: Event<{ width: number; height: number; } | undefined> = Event.None;
protected _input: EditorInput | null;
protected _options: EditorOptions | null;
protected _input: EditorInput | null = null;
protected _options: EditorOptions | null = null;
private _group?: IEditorGroup;
......@@ -172,7 +172,7 @@ interface MapGroupToMemento<T> {
}
export class EditorMemento<T> implements IEditorMemento<T> {
private cache: LRUCache<string, MapGroupToMemento<T>>;
private cache: LRUCache<string, MapGroupToMemento<T>> | undefined;
private cleanedUp = false;
constructor(
......
......@@ -229,7 +229,7 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(ChangeEOLAction, Chang
registry.registerWorkbenchAction(new SyncActionDescriptor(ChangeEncodingAction, ChangeEncodingAction.ID, ChangeEncodingAction.LABEL), 'Change File Encoding');
export class QuickOpenActionContributor extends ActionBarContributor {
private openToSideActionInstance: OpenToSideFromQuickOpenAction;
private openToSideActionInstance: OpenToSideFromQuickOpenAction | undefined;
constructor(@IInstantiationService private readonly instantiationService: IInstantiationService) {
super();
......
......@@ -263,7 +263,10 @@ function registerDiffEditorCommands(): void {
const candidates = [editorService.activeControl, ...editorService.visibleControls].filter(e => e instanceof TextDiffEditor);
if (candidates.length > 0) {
next ? (<TextDiffEditor>candidates[0]).getDiffNavigator().next() : (<TextDiffEditor>candidates[0]).getDiffNavigator().previous();
const navigator = (<TextDiffEditor>candidates[0]).getDiffNavigator();
if (navigator) {
next ? navigator.next() : navigator.previous();
}
}
}
......
......@@ -35,11 +35,11 @@ export class EditorControl extends Disposable {
private _onDidSizeConstraintsChange = this._register(new Emitter<{ width: number; height: number; } | undefined>());
get onDidSizeConstraintsChange(): Event<{ width: number; height: number; } | undefined> { return this._onDidSizeConstraintsChange.event; }
private _activeControl: BaseEditor | null;
private _activeControl: BaseEditor | null = null;
private controls: BaseEditor[] = [];
private readonly activeControlDisposables = this._register(new DisposableStore());
private dimension: Dimension;
private dimension: Dimension | undefined;
private editorOperation: LongRunningOperation;
constructor(
......
......@@ -25,11 +25,11 @@ class DropOverlay extends Themable {
private static OVERLAY_ID = 'monaco-workbench-editor-drop-overlay';
private container: HTMLElement;
private overlay: HTMLElement;
private container!: HTMLElement;
private overlay!: HTMLElement;
private currentDropOperation?: IDropOperation;
private _disposed: boolean;
private currentDropOperation: IDropOperation | undefined;
private _disposed: boolean | undefined;
private cleanupOverlayScheduler: RunOnceScheduler;
......@@ -50,7 +50,7 @@ class DropOverlay extends Themable {
}
get disposed(): boolean {
return this._disposed;
return !!this._disposed;
}
private create(): void {
......
......@@ -40,7 +40,7 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor {
static readonly ID = TEXT_DIFF_EDITOR_ID;
private diffNavigator: DiffNavigator;
private diffNavigator: DiffNavigator | undefined;
private readonly diffNavigatorDisposables = this._register(new DisposableStore());
constructor(
......@@ -257,7 +257,7 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor {
super.clearInput();
}
getDiffNavigator(): DiffNavigator {
getDiffNavigator(): DiffNavigator | undefined {
return this.diffNavigator;
}
......
......@@ -57,7 +57,7 @@ export abstract class TitleControl extends Themable {
private currentPrimaryEditorActionIds: string[] = [];
private currentSecondaryEditorActionIds: string[] = [];
protected editorActionsToolbar: ToolBar;
private editorActionsToolbar: ToolBar;
private resourceContext: ResourceContextKey;
private editorPinnedContext: IContextKey<boolean>;
......
......@@ -39,7 +39,7 @@ export abstract class ViewContainerViewlet extends PanelViewlet implements IView
private readonly viewletState: MementoObject;
private didLayout = false;
private dimension: DOM.Dimension;
private dimension: DOM.Dimension | undefined;
private areExtensionsReady: boolean = false;
private readonly visibleViewsCountFromCache: number | undefined;
......
......@@ -41,7 +41,7 @@ export class SimpleUpdateService implements IUpdateService {
_serviceBrand: undefined;
onStateChange = Event.None;
state: State;
state!: State;
checkForUpdates(context: any): Promise<void> {
return Promise.resolve(undefined);
......
......@@ -16,7 +16,7 @@ export class DiffEditorInput extends SideBySideEditorInput {
static readonly ID = 'workbench.editors.diffEditorInput';
private cachedModel: DiffEditorModel | null;
private cachedModel: DiffEditorModel | null = null;
constructor(name: string, description: string | undefined, original: EditorInput, modified: EditorInput, private readonly forceOpenAsBinary?: boolean) {
super(name, description, original, modified);
......@@ -86,4 +86,4 @@ export class DiffEditorInput extends SideBySideEditorInput {
super.dispose();
}
}
\ No newline at end of file
}
......@@ -94,8 +94,8 @@ export class EditorGroup extends Disposable {
private mru: EditorInput[] = [];
private mapResourceToEditorCount: ResourceMap<number> = new ResourceMap<number>();
private preview: EditorInput | null; // editor in preview state
private active: EditorInput | null; // editor in active state
private preview: EditorInput | null = null; // editor in preview state
private active: EditorInput | null = null; // editor in active state
private editorOpenPositioning: 'left' | 'right' | 'first' | 'last';
private focusRecentEditorAfterClose: boolean;
......
......@@ -17,8 +17,8 @@ export class ResourceEditorInput extends EditorInput implements IModeSupport {
static readonly ID: string = 'workbench.editors.resourceEditorInput';
private cachedModel: ResourceEditorModel | null;
private modelReference: Promise<IReference<ITextEditorModel>> | null;
private cachedModel: ResourceEditorModel | null = null;
private modelReference: Promise<IReference<ITextEditorModel>> | null = null;
constructor(
private name: string,
......
......@@ -17,7 +17,7 @@ export class TextDiffEditorModel extends DiffEditorModel {
protected readonly _originalModel: BaseTextEditorModel;
protected readonly _modifiedModel: BaseTextEditorModel;
private _textDiffEditorModel: IDiffEditorModel | null;
private _textDiffEditorModel: IDiffEditorModel | null = null;
constructor(originalModel: BaseTextEditorModel, modifiedModel: BaseTextEditorModel) {
super(originalModel, modifiedModel);
......
......@@ -23,8 +23,8 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport
static readonly ID: string = 'workbench.editors.untitledEditorInput';
private cachedModel: UntitledEditorModel | null;
private modelResolve: Promise<UntitledEditorModel & IResolvedTextEditorModel> | null;
private cachedModel: UntitledEditorModel | null = null;
private modelResolve: Promise<UntitledEditorModel & IResolvedTextEditorModel> | null = null;
private readonly _onDidModelChangeContent: Emitter<void> = this._register(new Emitter<void>());
readonly onDidModelChangeContent: Event<void> = this._onDidModelChangeContent.event;
......
......@@ -33,7 +33,7 @@ export class FileEditorInput extends EditorInput implements IFileEditorInput {
private forceOpenAs: ForceOpenAs = ForceOpenAs.None;
private textModelReference: Promise<IReference<ITextEditorModel>> | null;
private textModelReference: Promise<IReference<ITextEditorModel>> | null = null;
private name: string;
/**
......
......@@ -58,7 +58,7 @@ export class Marker {
get resource(): URI { return this.marker.resource; }
get range(): IRange { return this.marker; }
private _lines: string[];
private _lines: string[] | undefined;
get lines(): string[] {
if (!this._lines) {
this._lines = this.marker.message.split(/\r\n|\r|\n/g);
......
......@@ -26,7 +26,7 @@ import { FOLDER_SETTINGS_PATH, IPreferencesService, USE_SPLIT_JSON_SETTING } fro
const schemaRegistry = Registry.as<JSONContributionRegistry.IJSONContributionRegistry>(JSONContributionRegistry.Extensions.JSONContribution);
export class PreferencesContribution implements IWorkbenchContribution {
private editorOpeningListener: IDisposable;
private editorOpeningListener: IDisposable | undefined;
private settingsListener: IDisposable;
constructor(
......
......@@ -217,8 +217,8 @@ class CommandPaletteEditorAction extends EditorAction {
}
abstract class BaseCommandEntry extends QuickOpenEntryGroup {
private description: string;
private alias: string;
private description: string | undefined;
private alias: string | undefined;
private labelLowercase: string;
private readonly keybindingAriaLabel?: string;
......@@ -258,7 +258,7 @@ abstract class BaseCommandEntry extends QuickOpenEntryGroup {
return this.labelLowercase;
}
getDescription(): string {
getDescription(): string | undefined {
return this.description;
}
......@@ -270,7 +270,7 @@ abstract class BaseCommandEntry extends QuickOpenEntryGroup {
return this.keybinding;
}
getDetail(): string {
getDetail(): string | undefined {
return this.alias;
}
......@@ -381,13 +381,13 @@ export class CommandsHandler extends QuickOpenHandler implements IDisposable {
static readonly ID = 'workbench.picker.commands';
private commandHistoryEnabled: boolean;
private commandHistoryEnabled: boolean | undefined;
private readonly commandsHistory: CommandsHistory;
private readonly disposables = new DisposableStore();
private readonly disposeOnClose = new DisposableStore();
private waitedForExtensionsRegistered: boolean;
private waitedForExtensionsRegistered: boolean | undefined;
constructor(
@IEditorService private readonly editorService: IEditorService,
......
......@@ -29,15 +29,15 @@ interface IConfiguration extends IWindowsConfiguration {
export class SettingsChangeRelauncher extends Disposable implements IWorkbenchContribution {
private titleBarStyle: 'native' | 'custom';
private nativeTabs: boolean;
private nativeFullScreen: boolean;
private clickThroughInactive: boolean;
private updateMode: string;
private enableCrashReporter: boolean;
private treeHorizontalScrolling: boolean;
private useGridLayout: boolean;
private debugConsoleWordWrap: boolean;
private titleBarStyle: 'native' | 'custom' | undefined;
private nativeTabs: boolean | undefined;
private nativeFullScreen: boolean | undefined;
private clickThroughInactive: boolean | undefined;
private updateMode: string | undefined;
private enableCrashReporter: boolean | undefined;
private treeHorizontalScrolling: boolean | undefined;
private useGridLayout: boolean | undefined;
private debugConsoleWordWrap: boolean | undefined;
constructor(
@IWindowsService private readonly windowsService: IWindowsService,
......
......@@ -114,7 +114,7 @@ export interface IOpenFileOptions {
export class OpenFileHandler extends QuickOpenHandler {
private options: IOpenFileOptions | undefined;
private queryBuilder: QueryBuilder;
private cacheState: CacheState;
private cacheState: CacheState | undefined;
constructor(
@IInstantiationService private readonly instantiationService: IInstantiationService,
......@@ -143,7 +143,7 @@ export class OpenFileHandler extends QuickOpenHandler {
}
// Do find results
return this.doFindResults(query, token, this.cacheState.cacheKey, maxSortedResults);
return this.doFindResults(query, token, this.cacheState ? this.cacheState.cacheKey : undefined, maxSortedResults);
}
private async doFindResults(query: IPreparedQuery, token: CancellationToken, cacheKey?: string, maxSortedResults?: number): Promise<FileQuickOpenModel> {
......@@ -246,7 +246,7 @@ export class OpenFileHandler extends QuickOpenHandler {
}
get isCacheLoaded(): boolean {
return this.cacheState && this.cacheState.isLoaded;
return !!this.cacheState && this.cacheState.isLoaded;
}
getGroupLabel(): string {
......@@ -279,14 +279,14 @@ export class CacheState {
private loadingPhase = LoadingPhase.Created;
private promise: Promise<void> | undefined;
constructor(cacheQuery: (cacheKey: string) => IFileQuery, private doLoad: (query: IFileQuery) => Promise<any>, private doDispose: (cacheKey: string) => Promise<void>, private previous: CacheState | null) {
constructor(cacheQuery: (cacheKey: string) => IFileQuery, private doLoad: (query: IFileQuery) => Promise<any>, private doDispose: (cacheKey: string) => Promise<void>, private previous: CacheState | undefined) {
this.query = cacheQuery(this._cacheKey);
if (this.previous) {
const current = objects.assign({}, this.query, { cacheKey: null });
const previous = objects.assign({}, this.previous.query, { cacheKey: null });
if (!objects.equals(current, previous)) {
this.previous.dispose();
this.previous = null;
this.previous = undefined;
}
}
}
......@@ -315,7 +315,7 @@ export class CacheState {
this.loadingPhase = LoadingPhase.Loaded;
if (this.previous) {
this.previous.dispose();
this.previous = null;
this.previous = undefined;
}
}, err => {
this.loadingPhase = LoadingPhase.Errored;
......@@ -337,7 +337,7 @@ export class CacheState {
}
if (this.previous) {
this.previous.dispose();
this.previous = null;
this.previous = undefined;
}
}
}
......@@ -91,7 +91,7 @@ const PyModulesToLookFor = [
export class WorkspaceStatsService implements IWorkspaceStatsService {
_serviceBrand: undefined;
private _tags: Tags;
private _tags: Tags | undefined;
constructor(
@IFileService private readonly fileService: IFileService,
......
......@@ -22,8 +22,7 @@ import { CancellationToken } from 'vs/base/common/cancellation';
export class TelemetryOptOut implements IWorkbenchContribution {
private static TELEMETRY_OPT_OUT_SHOWN = 'workbench.telemetryOptOutShown';
private privacyUrl: string;
private optOutUrl: string;
private privacyUrl: string | undefined;
constructor(
@IStorageService storageService: IStorageService,
......@@ -50,7 +49,6 @@ export class TelemetryOptOut implements IWorkbenchContribution {
}
storageService.store(TelemetryOptOut.TELEMETRY_OPT_OUT_SHOWN, true, StorageScope.GLOBAL);
this.optOutUrl = product.telemetryOptOutUrl;
this.privacyUrl = product.privacyStatementUrl || product.telemetryOptOutUrl;
if (experimentState && experimentState.state === ExperimentState.Run && telemetryService.isOptedIn) {
......@@ -58,15 +56,15 @@ export class TelemetryOptOut implements IWorkbenchContribution {
return;
}
const optOutNotice = localize('telemetryOptOut.optOutNotice', "Help improve VS Code by allowing Microsoft to collect usage data. Read our [privacy statement]({0}) and learn how to [opt out]({1}).", this.privacyUrl, this.optOutUrl);
const optInNotice = localize('telemetryOptOut.optInNotice', "Help improve VS Code by allowing Microsoft to collect usage data. Read our [privacy statement]({0}) and learn how to [opt in]({1}).", this.privacyUrl, this.optOutUrl);
const optOutNotice = localize('telemetryOptOut.optOutNotice', "Help improve VS Code by allowing Microsoft to collect usage data. Read our [privacy statement]({0}) and learn how to [opt out]({1}).", this.privacyUrl, product.telemetryOptOutUrl);
const optInNotice = localize('telemetryOptOut.optInNotice', "Help improve VS Code by allowing Microsoft to collect usage data. Read our [privacy statement]({0}) and learn how to [opt in]({1}).", this.privacyUrl, product.telemetryOptOutUrl);
notificationService.prompt(
Severity.Info,
telemetryService.isOptedIn ? optOutNotice : optInNotice,
[{
label: localize('telemetryOptOut.readMore', "Read More"),
run: () => openerService.open(URI.parse(this.optOutUrl))
run: () => openerService.open(URI.parse(product.telemetryOptOutUrl))
}],
{ sticky: true }
);
......
......@@ -70,12 +70,12 @@ const TextInputActions: IAction[] = [
export class ElectronWindow extends Disposable {
private touchBarMenu?: IMenu;
private touchBarUpdater: RunOnceScheduler;
private touchBarMenu: IMenu | undefined;
private touchBarUpdater: RunOnceScheduler | undefined;
private readonly touchBarDisposables = this._register(new DisposableStore());
private lastInstalledTouchedBar: ICommandAction[][];
private lastInstalledTouchedBar: ICommandAction[][] | undefined;
private previousConfiguredZoomLevel: number;
private previousConfiguredZoomLevel: number | undefined;
private addFoldersScheduler: RunOnceScheduler;
private pendingFoldersToAdd: URI[];
......@@ -406,7 +406,7 @@ export class ElectronWindow extends Disposable {
if (!this.touchBarMenu) {
this.touchBarMenu = this.editorService.invokeWithinEditorContext(accessor => this.menuService.createMenu(MenuId.TouchBarContext, accessor.get(IContextKeyService)));
this.touchBarDisposables.add(this.touchBarMenu);
this.touchBarDisposables.add(this.touchBarMenu.onDidChange(() => this.touchBarUpdater.schedule()));
this.touchBarDisposables.add(this.touchBarMenu.onDidChange(() => this.touchBarUpdater!.schedule()));
}
const actions: Array<MenuItemAction | Separator> = [];
......
......@@ -113,7 +113,7 @@ export class BackupFileService implements IBackupFileService {
@IWorkbenchEnvironmentService private environmentService: IWorkbenchEnvironmentService,
@IFileService protected fileService: IFileService
) {
this.initialize();
this.impl = this.initialize();
}
protected hashPath(resource: URI): string {
......@@ -122,13 +122,13 @@ export class BackupFileService implements IBackupFileService {
return hash(str).toString(16);
}
private initialize(): void {
private initialize(): IBackupFileService {
const backupWorkspaceResource = this.environmentService.configuration.backupWorkspaceResource;
if (backupWorkspaceResource) {
this.impl = new BackupFileServiceImpl(backupWorkspaceResource, this.hashPath, this.fileService);
} else {
this.impl = new InMemoryBackupFileService(this.hashPath);
return new BackupFileServiceImpl(backupWorkspaceResource, this.hashPath, this.fileService);
}
return new InMemoryBackupFileService(this.hashPath);
}
reinitialize(): void {
......
......@@ -60,7 +60,7 @@ class LocalStorageCredentialsProvider implements ICredentialsProvider {
static readonly CREDENTIALS_OPENED_KEY = 'credentials.provider';
private _credentials: ICredential[];
private _credentials: ICredential[] | undefined;
private get credentials(): ICredential[] {
if (!this._credentials) {
try {
......
......@@ -60,7 +60,7 @@ export class KeybindingsEditorInput extends EditorInput {
static readonly ID: string = 'workbench.input.keybindings';
readonly keybindingsModel: KeybindingsEditorModel;
searchOptions: IKeybindingsEditorSearchOptions | null;
searchOptions: IKeybindingsEditorSearchOptions | null = null;
constructor(@IInstantiationService instantiationService: IInstantiationService) {
super();
......
......@@ -106,6 +106,7 @@ export class TestContextService implements IWorkspaceContextService {
constructor(workspace: any = TestWorkspace, options: any = null) {
this.workspace = workspace;
this.options = options || Object.create(null);
this._onDidChangeWorkspaceName = new Emitter<void>();
this._onDidChangeWorkspaceFolders = new Emitter<IWorkspaceFoldersChangeEvent>();
this._onDidChangeWorkbenchState = new Emitter<WorkbenchState>();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册