diff --git a/configs/base.tsconfig.json b/configs/base.tsconfig.json index f0b6da7ec7930..ad7945da3b92d 100644 --- a/configs/base.tsconfig.json +++ b/configs/base.tsconfig.json @@ -8,7 +8,7 @@ "noEmitOnError": false, "noImplicitThis": true, "noUnusedLocals": true, - "strictNullChecks": true, + "strict": true, "experimentalDecorators": true, "emitDecoratorMetadata": true, "downlevelIteration": true, diff --git a/dev-packages/application-package/src/application-package.ts b/dev-packages/application-package/src/application-package.ts index a0fa5f8c3599f..dbf1b8e670203 100644 --- a/dev-packages/application-package/src/application-package.ts +++ b/dev-packages/application-package/src/application-package.ts @@ -24,12 +24,12 @@ import deepmerge = require('deepmerge'); // eslint-disable-next-line @typescript-eslint/no-explicit-any export type ApplicationLog = (message?: any, ...optionalParams: any[]) => void; -export class ApplicationPackageOptions { - readonly projectPath: string; - readonly log?: ApplicationLog; - readonly error?: ApplicationLog; - readonly registry?: NpmRegistry; - readonly appTarget?: ApplicationProps.Target; +export interface ApplicationPackageOptions { + readonly projectPath: string + readonly log?: ApplicationLog + readonly error?: ApplicationLog + readonly registry?: NpmRegistry + readonly appTarget?: ApplicationProps.Target } export type ApplicationModuleResolver = (modulePath: string) => string; diff --git a/dev-packages/application-package/src/extension-package-collector.ts b/dev-packages/application-package/src/extension-package-collector.ts index db0e0c16a0839..54786e76b4b59 100644 --- a/dev-packages/application-package/src/extension-package-collector.ts +++ b/dev-packages/application-package/src/extension-package-collector.ts @@ -28,7 +28,7 @@ export class ExtensionPackageCollector { protected readonly resolveModule: (modulePath: string) => string ) { } - protected root: NodePackage; + protected root?: NodePackage; collect(pck: NodePackage): ReadonlyArray { this.root = pck; this.collectPackages(pck); @@ -73,7 +73,7 @@ export class ExtensionPackageCollector { if (RawExtensionPackage.is(pck)) { const parent = this.parent; const version = pck.version; - const transitive = !(name in this.root.dependencies!); + const transitive = !(name in this.root!.dependencies!); pck.installed = { packagePath, version, parent, transitive }; pck.version = versionRange; const extensionPackage = this.extensionPackageFactory(pck, { alias: name }); diff --git a/dev-packages/application-package/src/npm-registry.ts b/dev-packages/application-package/src/npm-registry.ts index 2210cee75c619..63184a6ac10d4 100644 --- a/dev-packages/application-package/src/npm-registry.ts +++ b/dev-packages/application-package/src/npm-registry.ts @@ -84,7 +84,7 @@ export class NpmRegistryOptions { /** * Default: false. */ - readonly watchChanges: boolean; + readonly watchChanges: boolean = false; } export class NpmRegistry { diff --git a/examples/api-samples/src/browser/file-watching/sample-file-watching-contribution.ts b/examples/api-samples/src/browser/file-watching/sample-file-watching-contribution.ts index 0a6b66dd31907..d3c16ed699c76 100644 --- a/examples/api-samples/src/browser/file-watching/sample-file-watching-contribution.ts +++ b/examples/api-samples/src/browser/file-watching/sample-file-watching-contribution.ts @@ -50,19 +50,19 @@ const FileWatchingPreferencesSchema: PreferenceSchema = { @injectable() class SampleFileWatchingContribution implements FrontendApplicationContribution { - protected verbose: boolean; + protected verbose: boolean = false; @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @inject(FileWatchingPreferences) - protected readonly fileWatchingPreferences: FileWatchingPreferences; + protected readonly fileWatchingPreferences!: FileWatchingPreferences; @postConstruct() protected postConstruct(): void { diff --git a/examples/api-samples/src/browser/label/sample-dynamic-label-provider-command-contribution.ts b/examples/api-samples/src/browser/label/sample-dynamic-label-provider-command-contribution.ts index d00011441a746..4e71e104f488a 100644 --- a/examples/api-samples/src/browser/label/sample-dynamic-label-provider-command-contribution.ts +++ b/examples/api-samples/src/browser/label/sample-dynamic-label-provider-command-contribution.ts @@ -32,7 +32,7 @@ export namespace ExampleLabelProviderCommands { export class SampleDynamicLabelProviderCommandContribution implements FrontendApplicationContribution, CommandContribution { @inject(SampleDynamicLabelProviderContribution) - protected readonly labelProviderContribution: SampleDynamicLabelProviderContribution; + protected readonly labelProviderContribution!: SampleDynamicLabelProviderContribution; initialize(): void { } diff --git a/examples/api-samples/src/browser/menu/sample-menu-contribution.ts b/examples/api-samples/src/browser/menu/sample-menu-contribution.ts index 4d01947f635ea..6566fb828e11e 100644 --- a/examples/api-samples/src/browser/menu/sample-menu-contribution.ts +++ b/examples/api-samples/src/browser/menu/sample-menu-contribution.ts @@ -39,10 +39,10 @@ const SampleQuickInputCommand: Command = { export class SampleCommandContribution implements CommandContribution { @inject(QuickInputService) - protected readonly quickInputService: QuickInputService; + protected readonly quickInputService!: QuickInputService; @inject(MessageService) - protected readonly messageService: MessageService; + protected readonly messageService!: MessageService; registerCommands(commands: CommandRegistry): void { commands.registerCommand(SampleCommand, { diff --git a/examples/api-samples/src/browser/output/sample-output-channel-with-severity.ts b/examples/api-samples/src/browser/output/sample-output-channel-with-severity.ts index d34f5a6183806..682d3f117649e 100644 --- a/examples/api-samples/src/browser/output/sample-output-channel-with-severity.ts +++ b/examples/api-samples/src/browser/output/sample-output-channel-with-severity.ts @@ -21,7 +21,7 @@ import { OutputChannelManager, OutputChannelSeverity } from '@theia/output/lib/b export class SampleOutputChannelWithSeverity implements FrontendApplicationContribution { @inject(OutputChannelManager) - protected readonly outputChannelManager: OutputChannelManager; + protected readonly outputChannelManager!: OutputChannelManager; public onStart(): void { const channel = this.outputChannelManager.getChannel('API Sample: my test channel'); channel.appendLine('hello info1'); // showed without color diff --git a/examples/api-samples/src/browser/view/sample-unclosable-view-contribution.ts b/examples/api-samples/src/browser/view/sample-unclosable-view-contribution.ts index 254981a1284b9..95cf108f8261d 100644 --- a/examples/api-samples/src/browser/view/sample-unclosable-view-contribution.ts +++ b/examples/api-samples/src/browser/view/sample-unclosable-view-contribution.ts @@ -33,7 +33,7 @@ export class SampleUnclosableViewContribution extends AbstractViewContribution implements TabBarToolbarContribution { - private edits: monaco.editor.ResourceEdit[]; + private edits?: monaco.editor.ResourceEdit[]; @inject(QuickViewService) @optional() - protected readonly quickView: QuickViewService; + protected readonly quickView?: QuickViewService; constructor(private readonly bulkEditService: MonacoBulkEditService) { super({ diff --git a/packages/bulk-edit/src/browser/bulk-edit-tree-label-provider.ts b/packages/bulk-edit/src/browser/bulk-edit-tree-label-provider.ts index 0d0ce62bba9e1..e9c432152be44 100644 --- a/packages/bulk-edit/src/browser/bulk-edit-tree-label-provider.ts +++ b/packages/bulk-edit/src/browser/bulk-edit-tree-label-provider.ts @@ -24,13 +24,13 @@ import { WorkspaceService } from '@theia/workspace/lib/browser'; export class BulkEditTreeLabelProvider implements LabelProviderContribution { @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(TreeLabelProvider) - protected readonly treeLabelProvider: TreeLabelProvider; + protected readonly treeLabelProvider!: TreeLabelProvider; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; canHandle(element: object): number { return BulkEditInfoNode.is(element) ? diff --git a/packages/bulk-edit/src/browser/bulk-edit-tree/bulk-edit-tree-model.ts b/packages/bulk-edit/src/browser/bulk-edit-tree/bulk-edit-tree-model.ts index 286e8142f2196..7540e7a15c3e4 100644 --- a/packages/bulk-edit/src/browser/bulk-edit-tree/bulk-edit-tree-model.ts +++ b/packages/bulk-edit/src/browser/bulk-edit-tree/bulk-edit-tree-model.ts @@ -20,8 +20,8 @@ import { TreeModelImpl, OpenerService, open, TreeNode } from '@theia/core/lib/br @injectable() export class BulkEditTreeModel extends TreeModelImpl { - @inject(BulkEditTree) protected readonly tree: BulkEditTree; - @inject(OpenerService) protected readonly openerService: OpenerService; + @inject(BulkEditTree) protected readonly tree!: BulkEditTree; + @inject(OpenerService) protected readonly openerService!: OpenerService; protected doOpenNode(node: TreeNode): void { if (BulkEditNode.is(node)) { diff --git a/packages/bulk-edit/src/browser/bulk-edit-tree/bulk-edit-tree-widget.tsx b/packages/bulk-edit/src/browser/bulk-edit-tree/bulk-edit-tree-widget.tsx index 93a4f53434039..c65d6affcb04d 100644 --- a/packages/bulk-edit/src/browser/bulk-edit-tree/bulk-edit-tree-widget.tsx +++ b/packages/bulk-edit/src/browser/bulk-edit-tree/bulk-edit-tree-widget.tsx @@ -37,13 +37,13 @@ export class BulkEditTreeWidget extends TreeWidget { private editorWidgets: EditorWidget[] = []; @inject(FileResourceResolver) - protected readonly fileResourceResolver: FileResourceResolver; + protected readonly fileResourceResolver!: FileResourceResolver; @inject(EditorManager) - protected readonly editorManager: EditorManager; + protected readonly editorManager!: EditorManager; @inject(QuickViewService) @optional() - protected readonly quickView: QuickViewService; + protected readonly quickView?: QuickViewService; constructor( @inject(TreeProps) readonly treeProps: TreeProps, @@ -185,7 +185,7 @@ export class BulkEditTreeWidget extends TreeWidget { let lines: string[] = []; if (bulkEditInfoNode?.fileContents) { lines = bulkEditInfoNode.fileContents.split('\n'); - bulkEditInfoNode.children.map((node: BulkEditNode) => { + (bulkEditInfoNode.children as BulkEditNode[]).map(node => { if (node.bulkEdit && ('textEdit' in node.bulkEdit)) { const startLineNum = node.bulkEdit.textEdit.range.startLineNumber; if (lines.length > startLineNum) { diff --git a/packages/bulk-edit/src/browser/bulk-edit-tree/bulk-edit-tree.ts b/packages/bulk-edit/src/browser/bulk-edit-tree/bulk-edit-tree.ts index 9ba5e29ee29dd..aee3638810606 100644 --- a/packages/bulk-edit/src/browser/bulk-edit-tree/bulk-edit-tree.ts +++ b/packages/bulk-edit/src/browser/bulk-edit-tree/bulk-edit-tree.ts @@ -39,7 +39,7 @@ export class BulkEditTree extends TreeImpl { bulkEditInfos = edits .map(edit => this.getResourcePath(edit)) .filter((path, index, arr) => path && arr.indexOf(path) === index) - .map((path: string) => this.createBulkEditInfo(path, new URI(path), fileContentsMap.get(path))) + .map(path => this.createBulkEditInfo(path as string, new URI(path), fileContentsMap.get(path as string))) .filter(Boolean); if (bulkEditInfos.length > 0) { diff --git a/packages/callhierarchy/src/browser/callhierarchy-contribution.ts b/packages/callhierarchy/src/browser/callhierarchy-contribution.ts index 4495ccd25386c..d4791f7b9ef81 100644 --- a/packages/callhierarchy/src/browser/callhierarchy-contribution.ts +++ b/packages/callhierarchy/src/browser/callhierarchy-contribution.ts @@ -36,8 +36,8 @@ export namespace CallHierarchyCommands { @injectable() export class CallHierarchyContribution extends AbstractViewContribution { - @inject(CurrentEditorAccess) protected readonly editorAccess: CurrentEditorAccess; - @inject(CallHierarchyServiceProvider) protected readonly callHierarchyServiceProvider: CallHierarchyServiceProvider; + @inject(CurrentEditorAccess) protected readonly editorAccess!: CurrentEditorAccess; + @inject(CallHierarchyServiceProvider) protected readonly callHierarchyServiceProvider!: CallHierarchyServiceProvider; constructor() { super({ widgetId: CALLHIERARCHY_ID, diff --git a/packages/callhierarchy/src/browser/callhierarchy-service.ts b/packages/callhierarchy/src/browser/callhierarchy-service.ts index 9f58452ba1346..625c5c2186830 100644 --- a/packages/callhierarchy/src/browser/callhierarchy-service.ts +++ b/packages/callhierarchy/src/browser/callhierarchy-service.ts @@ -37,7 +37,7 @@ export interface CallHierarchyService { export class CallHierarchyServiceProvider { @inject(ContributionProvider) @named(CallHierarchyService) - protected readonly contributions: ContributionProvider; + protected readonly contributions!: ContributionProvider; private services: CallHierarchyService[] = []; diff --git a/packages/callhierarchy/src/browser/callhierarchy-tree/callhierarchy-tree-model.ts b/packages/callhierarchy/src/browser/callhierarchy-tree/callhierarchy-tree-model.ts index 24ca06b7d64f9..42afced0a36f8 100644 --- a/packages/callhierarchy/src/browser/callhierarchy-tree/callhierarchy-tree-model.ts +++ b/packages/callhierarchy/src/browser/callhierarchy-tree/callhierarchy-tree-model.ts @@ -27,8 +27,8 @@ export class CallHierarchyTreeModel extends TreeModelImpl { private _languageId: string | undefined; - @inject(CallHierarchyTree) protected readonly tree: CallHierarchyTree; - @inject(CallHierarchyServiceProvider) protected readonly callHierarchyServiceProvider: CallHierarchyServiceProvider; + @inject(CallHierarchyTree) protected readonly tree!: CallHierarchyTree; + @inject(CallHierarchyServiceProvider) protected readonly callHierarchyServiceProvider!: CallHierarchyServiceProvider; getTree(): CallHierarchyTree { return this.tree; diff --git a/packages/callhierarchy/src/browser/current-editor-access.ts b/packages/callhierarchy/src/browser/current-editor-access.ts index b66a8e4c8ea11..c58d2c2250af0 100644 --- a/packages/callhierarchy/src/browser/current-editor-access.ts +++ b/packages/callhierarchy/src/browser/current-editor-access.ts @@ -24,7 +24,7 @@ import { Location } from '@theia/core/shared/vscode-languageserver-types'; @injectable() export class CurrentEditorAccess { - @inject(EditorManager) protected readonly editorManager: EditorManager; + @inject(EditorManager) protected readonly editorManager!: EditorManager; getSelection(): Location | undefined { const activeEditor = this.getCurrentEditor(); diff --git a/packages/callhierarchy/src/common/glob.ts b/packages/callhierarchy/src/common/glob.ts index 5b90d3eadf5de..f39f32ea83a25 100644 --- a/packages/callhierarchy/src/common/glob.ts +++ b/packages/callhierarchy/src/common/glob.ts @@ -588,6 +588,7 @@ function parsedExpression(expression: IExpression, options: IGlobOptions): Parse if (!parsedPatterns.some(parsedPattern => (parsedPattern).requiresSiblings!)) { if (n === 1) { + // @ts-expect-error TS2322 return parsedPatterns[0]; } @@ -618,6 +619,7 @@ function parsedExpression(expression: IExpression, options: IGlobOptions): Parse resultExpression.allPaths = allPaths; } + // @ts-expect-error TS2322 return resultExpression; } @@ -655,6 +657,7 @@ function parsedExpression(expression: IExpression, options: IGlobOptions): Parse resultExpression.allPaths = allPaths; } + // @ts-expect-error TS2322 return resultExpression; } diff --git a/packages/console/src/browser/console-contribution.ts b/packages/console/src/browser/console-contribution.ts index 8012cb307627d..f5c6419001765 100644 --- a/packages/console/src/browser/console-contribution.ts +++ b/packages/console/src/browser/console-contribution.ts @@ -53,7 +53,7 @@ export namespace ConsoleContextMenu { export class ConsoleContribution implements FrontendApplicationContribution, CommandContribution, KeybindingContribution, MenuContribution { @inject(ConsoleManager) - protected readonly manager: ConsoleManager; + protected readonly manager!: ConsoleManager; initialize(): void { } diff --git a/packages/console/src/browser/console-keybinding-contexts.ts b/packages/console/src/browser/console-keybinding-contexts.ts index 4fdfb6ffc4dd3..19885f477082d 100644 --- a/packages/console/src/browser/console-keybinding-contexts.ts +++ b/packages/console/src/browser/console-keybinding-contexts.ts @@ -49,7 +49,7 @@ export class ConsoleInputFocusContext implements KeybindingContext { readonly id: string = ConsoleKeybindingContexts.consoleInputFocus; @inject(ConsoleManager) - protected readonly manager: ConsoleManager; + protected readonly manager!: ConsoleManager; isEnabled(): boolean { const console = this.manager.activeConsole; diff --git a/packages/console/src/browser/console-manager.ts b/packages/console/src/browser/console-manager.ts index ac99185f9155d..98fd5c09cfd91 100644 --- a/packages/console/src/browser/console-manager.ts +++ b/packages/console/src/browser/console-manager.ts @@ -22,7 +22,7 @@ import { ConsoleWidget } from './console-widget'; export class ConsoleManager { @inject(ApplicationShell) - protected readonly shell: ApplicationShell; + protected readonly shell!: ApplicationShell; get activeConsole(): ConsoleWidget | undefined { const widget = this.shell.activeWidget; diff --git a/packages/console/src/browser/console-session.ts b/packages/console/src/browser/console-session.ts index 4469db82388da..374eabb49ab5d 100644 --- a/packages/console/src/browser/console-session.ts +++ b/packages/console/src/browser/console-session.ts @@ -39,7 +39,7 @@ export abstract class ConsoleSession extends TreeSource { protected selectedSeverity?: Severity; protected readonly selectionEmitter: Emitter = new Emitter(); readonly onSelectionChange = this.selectionEmitter.event; - id: string; + abstract id: string; get severity(): Severity | undefined { return this.selectedSeverity; diff --git a/packages/console/src/browser/console-widget.ts b/packages/console/src/browser/console-widget.ts index 7c677135be2c7..44b896bac01dd 100644 --- a/packages/console/src/browser/console-widget.ts +++ b/packages/console/src/browser/console-widget.ts @@ -60,21 +60,21 @@ export class ConsoleWidget extends BaseWidget implements StatefulWidget { } @inject(ConsoleOptions) - protected readonly options: ConsoleOptions; + protected readonly options!: ConsoleOptions; @inject(ConsoleContentWidget) - readonly content: ConsoleContentWidget; + readonly content!: ConsoleContentWidget; @inject(ConsoleHistory) - protected readonly history: ConsoleHistory; + protected readonly history!: ConsoleHistory; @inject(ConsoleSessionManager) - protected readonly sessionManager: ConsoleSessionManager; + protected readonly sessionManager!: ConsoleSessionManager; @inject(MonacoEditorProvider) - protected readonly editorProvider: MonacoEditorProvider; + protected readonly editorProvider!: MonacoEditorProvider; - protected _input: MonacoEditor; + protected _input!: MonacoEditor; constructor() { super(); diff --git a/packages/core/src/browser/about-dialog.tsx b/packages/core/src/browser/about-dialog.tsx index e05cec5836a5c..0ed35288d4fad 100644 --- a/packages/core/src/browser/about-dialog.tsx +++ b/packages/core/src/browser/about-dialog.tsx @@ -26,17 +26,16 @@ export const ABOUT_CONTENT_CLASS = 'theia-aboutDialog'; export const ABOUT_EXTENSIONS_CLASS = 'theia-aboutExtensions'; @injectable() -export class AboutDialogProps extends DialogProps { +export abstract class AboutDialogProps extends DialogProps { } @injectable() export class AboutDialog extends ReactDialog { - protected applicationInfo: ApplicationInfo | undefined; + protected applicationInfo?: ApplicationInfo; protected extensionsInfos: ExtensionInfo[] = []; - protected readonly okButton: HTMLButtonElement; @inject(ApplicationServer) - protected readonly appServer: ApplicationServer; + protected readonly appServer!: ApplicationServer; constructor( @inject(AboutDialogProps) protected readonly props: AboutDialogProps diff --git a/packages/core/src/browser/authentication-service.ts b/packages/core/src/browser/authentication-service.ts index 9b995d9978ffa..f14e306771d21 100644 --- a/packages/core/src/browser/authentication-service.ts +++ b/packages/core/src/browser/authentication-service.ts @@ -117,9 +117,9 @@ export class AuthenticationServiceImpl implements AuthenticationService { new Emitter<{ providerId: string, label: string, event: AuthenticationSessionsChangeEvent }>(); readonly onDidChangeSessions: Event<{ providerId: string, label: string, event: AuthenticationSessionsChangeEvent }> = this.onDidChangeSessionsEmitter.event; - @inject(MenuModelRegistry) protected readonly menus: MenuModelRegistry; - @inject(CommandRegistry) protected readonly commands: CommandRegistry; - @inject(StorageService) protected readonly storageService: StorageService; + @inject(MenuModelRegistry) protected readonly menus!: MenuModelRegistry; + @inject(CommandRegistry) protected readonly commands!: CommandRegistry; + @inject(StorageService) protected readonly storageService!: StorageService; @postConstruct() init(): void { @@ -160,7 +160,7 @@ export class AuthenticationServiceImpl implements AuthenticationService { } }); this.commands.registerCommand(this.noAccountsCommand, { - execute: () => {}, + execute: () => { }, isEnabled: () => false }); } diff --git a/packages/core/src/browser/breadcrumbs/breadcrumb-popup-container.ts b/packages/core/src/browser/breadcrumbs/breadcrumb-popup-container.ts index c5036bb4f8f86..687113a4c6d3b 100644 --- a/packages/core/src/browser/breadcrumbs/breadcrumb-popup-container.ts +++ b/packages/core/src/browser/breadcrumbs/breadcrumb-popup-container.ts @@ -38,9 +38,9 @@ export const BreadcrumbID = Symbol('BreadcrumbID'); */ @injectable() export class BreadcrumbPopupContainer implements Disposable { - @inject(RendererHost) protected readonly parent: RendererHost; - @inject(BreadcrumbID) public readonly breadcrumbId: BreadcrumbID; - @inject(Coordinate) protected readonly position: Coordinate; + @inject(RendererHost) protected readonly parent!: RendererHost; + @inject(BreadcrumbID) public readonly breadcrumbId!: BreadcrumbID; + @inject(Coordinate) protected readonly position!: Coordinate; protected onDidDisposeEmitter = new Emitter(); protected toDispose: DisposableCollection = new DisposableCollection(this.onDidDisposeEmitter); @@ -48,12 +48,12 @@ export class BreadcrumbPopupContainer implements Disposable { return this.onDidDisposeEmitter.event; } - protected _container: HTMLElement; + protected _container!: HTMLElement; get container(): HTMLElement { return this._container; } - protected _isOpen: boolean; + protected _isOpen!: boolean; get isOpen(): boolean { return this._isOpen; } diff --git a/packages/core/src/browser/breadcrumbs/breadcrumbs-renderer.tsx b/packages/core/src/browser/breadcrumbs/breadcrumbs-renderer.tsx index 30129fbc95e13..b7e4b175625a1 100644 --- a/packages/core/src/browser/breadcrumbs/breadcrumbs-renderer.tsx +++ b/packages/core/src/browser/breadcrumbs/breadcrumbs-renderer.tsx @@ -36,16 +36,16 @@ interface Cancelable { export class BreadcrumbsRenderer extends ReactRenderer { @inject(BreadcrumbsService) - protected readonly breadcrumbsService: BreadcrumbsService; + protected readonly breadcrumbsService!: BreadcrumbsService; @inject(BreadcrumbRenderer) - protected readonly breadcrumbRenderer: BreadcrumbRenderer; + protected readonly breadcrumbRenderer!: BreadcrumbRenderer; @inject(CorePreferences) - protected readonly corePreferences: CorePreferences; + protected readonly corePreferences!: CorePreferences; @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; protected readonly onDidChangeActiveStateEmitter = new Emitter(); get onDidChangeActiveState(): Event { diff --git a/packages/core/src/browser/breadcrumbs/breadcrumbs-service.ts b/packages/core/src/browser/breadcrumbs/breadcrumbs-service.ts index d4b527a28437c..d2263eb61fca7 100644 --- a/packages/core/src/browser/breadcrumbs/breadcrumbs-service.ts +++ b/packages/core/src/browser/breadcrumbs/breadcrumbs-service.ts @@ -25,13 +25,13 @@ import { BreadcrumbsContribution, Styles, Breadcrumb } from './breadcrumbs-const export class BreadcrumbsService { @inject(ContributionProvider) @named(BreadcrumbsContribution) - protected readonly contributions: ContributionProvider; + protected readonly contributions!: ContributionProvider; - @inject(BreadcrumbPopupContainerFactory) protected readonly breadcrumbPopupContainerFactory: BreadcrumbPopupContainerFactory; + @inject(BreadcrumbPopupContainerFactory) protected readonly breadcrumbPopupContainerFactory!: BreadcrumbPopupContainerFactory; protected hasSubscribed = false; - protected popupsOverlayContainer: HTMLDivElement; + protected popupsOverlayContainer!: HTMLDivElement; protected readonly onDidChangeBreadcrumbsEmitter = new Emitter(); diff --git a/packages/core/src/browser/browser-clipboard-service.ts b/packages/core/src/browser/browser-clipboard-service.ts index d5fd8e745606f..b9f7c79745ff1 100644 --- a/packages/core/src/browser/browser-clipboard-service.ts +++ b/packages/core/src/browser/browser-clipboard-service.ts @@ -35,10 +35,10 @@ export interface NavigatorPermissions { export class BrowserClipboardService implements ClipboardService { @inject(MessageService) - protected readonly messageService: MessageService; + protected readonly messageService!: MessageService; @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; async readText(): Promise { let permission; diff --git a/packages/core/src/browser/color-application-contribution.ts b/packages/core/src/browser/color-application-contribution.ts index 548708459bb47..d1570104b014f 100644 --- a/packages/core/src/browser/color-application-contribution.ts +++ b/packages/core/src/browser/color-application-contribution.ts @@ -34,10 +34,10 @@ export class ColorApplicationContribution implements FrontendApplicationContribu readonly onDidChange = this.onDidChangeEmitter.event; @inject(ColorRegistry) - protected readonly colors: ColorRegistry; + protected readonly colors!: ColorRegistry; @inject(ContributionProvider) @named(ColorContribution) - protected readonly colorContributions: ContributionProvider; + protected readonly colorContributions!: ContributionProvider; private static themeBackgroundId = 'theme.background'; diff --git a/packages/core/src/browser/command-open-handler.ts b/packages/core/src/browser/command-open-handler.ts index fc45c0ba3e308..da337e8664c4b 100644 --- a/packages/core/src/browser/command-open-handler.ts +++ b/packages/core/src/browser/command-open-handler.ts @@ -25,7 +25,7 @@ export class CommandOpenHandler implements OpenHandler { readonly id = 'command'; @inject(CommandService) - protected readonly commands: CommandService; + protected readonly commands!: CommandService; canHandle(uri: URI): number { return uri.scheme === 'command' ? 500 : -1; diff --git a/packages/core/src/browser/common-frontend-contribution.ts b/packages/core/src/browser/common-frontend-contribution.ts index 2a7cff8376298..4c87c61274208 100644 --- a/packages/core/src/browser/common-frontend-contribution.ts +++ b/packages/core/src/browser/common-frontend-contribution.ts @@ -310,43 +310,43 @@ export class CommonFrontendContribution implements FrontendApplicationContributi ) { } @inject(ContextKeyService) - protected readonly contextKeyService: ContextKeyService; + protected readonly contextKeyService!: ContextKeyService; @inject(ResourceContextKey) - protected readonly resourceContextKey: ResourceContextKey; + protected readonly resourceContextKey!: ResourceContextKey; @inject(CommandRegistry) - protected readonly commandRegistry: CommandRegistry; + protected readonly commandRegistry!: CommandRegistry; @inject(StorageService) - protected readonly storageService: StorageService; + protected readonly storageService!: StorageService; @inject(QuickInputService) @optional() - protected readonly quickInputService: QuickInputService; + protected readonly quickInputService?: QuickInputService; @inject(IconThemeService) - protected readonly iconThemes: IconThemeService; + protected readonly iconThemes!: IconThemeService; @inject(ThemeService) - protected readonly themeService: ThemeService; + protected readonly themeService!: ThemeService; @inject(CorePreferences) - protected readonly preferences: CorePreferences; + protected readonly preferences!: CorePreferences; @inject(PreferenceService) - protected readonly preferenceService: PreferenceService; + protected readonly preferenceService!: PreferenceService; @inject(ClipboardService) - protected readonly clipboardService: ClipboardService; + protected readonly clipboardService!: ClipboardService; @inject(EncodingRegistry) - protected readonly encodingRegistry: EncodingRegistry; + protected readonly encodingRegistry!: EncodingRegistry; @inject(EnvVariablesServer) - protected readonly environments: EnvVariablesServer; + protected readonly environments!: EnvVariablesServer; @inject(AuthenticationService) - protected readonly authenticationService: AuthenticationService; + protected readonly authenticationService!: AuthenticationService; async configure(app: FrontendApplication): Promise { const configDirUri = await this.environments.getConfigDirUri(); diff --git a/packages/core/src/browser/connection-status-service.ts b/packages/core/src/browser/connection-status-service.ts index 31986f8ea18f2..2242a1b045eea 100644 --- a/packages/core/src/browser/connection-status-service.ts +++ b/packages/core/src/browser/connection-status-service.ts @@ -57,7 +57,7 @@ export enum ConnectionStatus { } @injectable() -export class ConnectionStatusOptions { +export abstract class ConnectionStatusOptions { static DEFAULT: ConnectionStatusOptions = { offlineTimeout: 5000, @@ -66,7 +66,7 @@ export class ConnectionStatusOptions { /** * Timeout in milliseconds before the application is considered offline. Must be a positive integer. */ - readonly offlineTimeout: number; + abstract readonly offlineTimeout: number; } @@ -83,7 +83,7 @@ export abstract class AbstractConnectionStatusService implements ConnectionStatu protected connectionStatus: ConnectionStatus = ConnectionStatus.ONLINE; @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; constructor(@inject(ConnectionStatusOptions) @optional() protected readonly options: ConnectionStatusOptions = ConnectionStatusOptions.DEFAULT) { } @@ -119,8 +119,8 @@ export class FrontendConnectionStatusService extends AbstractConnectionStatusSer private scheduledPing: number | undefined; - @inject(WebSocketConnectionProvider) protected readonly wsConnectionProvider: WebSocketConnectionProvider; - @inject(PingService) protected readonly pingService: PingService; + @inject(WebSocketConnectionProvider) protected readonly wsConnectionProvider!: WebSocketConnectionProvider; + @inject(PingService) protected readonly pingService!: PingService; constructor(@inject(ConnectionStatusOptions) @optional() protected readonly options: ConnectionStatusOptions = ConnectionStatusOptions.DEFAULT) { super(options); diff --git a/packages/core/src/browser/dialogs.ts b/packages/core/src/browser/dialogs.ts index 45be8358f8e18..8fcf8a1e176ad 100644 --- a/packages/core/src/browser/dialogs.ts +++ b/packages/core/src/browser/dialogs.ts @@ -21,8 +21,8 @@ import { Widget, BaseWidget, Message, addKeyListener, codiconArray } from './wid import { FrontendApplicationContribution } from './frontend-application'; @injectable() -export class DialogProps { - readonly title: string; +export abstract class DialogProps { + abstract readonly title: string; /** * Determines the maximum width of the dialog in pixels. * Default value is undefined, which would result in the css property 'max-width: none' being applied to the dialog. @@ -347,8 +347,8 @@ export abstract class AbstractDialog extends BaseWidget { } @injectable() -export class ConfirmDialogProps extends DialogProps { - readonly msg: string | HTMLElement; +export abstract class ConfirmDialogProps extends DialogProps { + abstract readonly msg: string | HTMLElement; readonly cancel?: string; readonly ok?: string; } @@ -389,7 +389,7 @@ export class ConfirmDialog extends AbstractDialog { } @injectable() -export class SingleTextInputDialogProps extends DialogProps { +export abstract class SingleTextInputDialogProps extends DialogProps { readonly confirmButtonLabel?: string; readonly initialValue?: string; readonly initialSelectionRange?: { diff --git a/packages/core/src/browser/encoding-registry.ts b/packages/core/src/browser/encoding-registry.ts index 6edbc7fd6b99e..7f3033226bf37 100644 --- a/packages/core/src/browser/encoding-registry.ts +++ b/packages/core/src/browser/encoding-registry.ts @@ -40,10 +40,10 @@ export class EncodingRegistry { protected readonly encodingOverrides: EncodingOverride[] = []; @inject(CorePreferences) - protected readonly preferences: CorePreferences; + protected readonly preferences!: CorePreferences; @inject(EncodingService) - protected readonly encodingService: EncodingService; + protected readonly encodingService!: EncodingService; registerOverride(override: EncodingOverride): Disposable { this.encodingOverrides.push(override); diff --git a/packages/core/src/browser/endpoint.ts b/packages/core/src/browser/endpoint.ts index 3cc6957eb0a39..2ac15c2912a9a 100644 --- a/packages/core/src/browser/endpoint.ts +++ b/packages/core/src/browser/endpoint.ts @@ -123,10 +123,10 @@ export namespace Endpoint { // Necessary for running tests with dependency on TS lib on node // FIXME figure out how to mock with ts-node - export class Location { - host: string; - pathname: string; - search: string; - protocol: string; + export abstract class Location { + abstract host: string; + abstract pathname: string; + abstract search: string; + abstract protocol: string; } } diff --git a/packages/core/src/browser/frontend-application-module.ts b/packages/core/src/browser/frontend-application-module.ts index 8cedce2ce5df2..ed1fc929cc1aa 100644 --- a/packages/core/src/browser/frontend-application-module.ts +++ b/packages/core/src/browser/frontend-application-module.ts @@ -257,8 +257,8 @@ export const frontendApplicationModule = new ContainerModule((bind, unbind, isBo bind(QuickHelpService).toSelf().inSingletonScope(); bind(QuickAccessContribution).toService(QuickHelpService); - bind(QuickPickService).to(QuickPickServiceImpl).inSingletonScope().onActivation(({ container }, quickPickService: QuickPickService) => { - WebSocketConnectionProvider.createProxy(container, quickPickServicePath, quickPickService); + bind(QuickPickService).to(QuickPickServiceImpl).inSingletonScope().onActivation((ctx, quickPickService) => { + WebSocketConnectionProvider.createProxy(ctx.container, quickPickServicePath, quickPickService); return quickPickService; }); diff --git a/packages/core/src/browser/frontend-application-state.ts b/packages/core/src/browser/frontend-application-state.ts index b8992dd898b7f..fd10c0a56641c 100644 --- a/packages/core/src/browser/frontend-application-state.ts +++ b/packages/core/src/browser/frontend-application-state.ts @@ -31,7 +31,7 @@ export type FrontendApplicationState = export class FrontendApplicationStateService { @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; private _state: FrontendApplicationState = 'init'; diff --git a/packages/core/src/browser/frontend-application.ts b/packages/core/src/browser/frontend-application.ts index 567d4c32f3549..6f92a71246355 100644 --- a/packages/core/src/browser/frontend-application.ts +++ b/packages/core/src/browser/frontend-application.ts @@ -96,13 +96,13 @@ export abstract class DefaultFrontendApplicationContribution implements Frontend export class FrontendApplication { @inject(CorePreferences) - protected readonly corePreferences: CorePreferences; + protected readonly corePreferences!: CorePreferences; @inject(WindowService) - protected readonly windowsService: WindowService; + protected readonly windowsService!: WindowService; @inject(TooltipService) - protected readonly tooltipService: TooltipService; + protected readonly tooltipService!: TooltipService; constructor( @inject(CommandRegistry) protected readonly commands: CommandRegistry, diff --git a/packages/core/src/browser/http-open-handler.ts b/packages/core/src/browser/http-open-handler.ts index dfd2d6cfe78d7..7707e8412e4dd 100644 --- a/packages/core/src/browser/http-open-handler.ts +++ b/packages/core/src/browser/http-open-handler.ts @@ -30,10 +30,10 @@ export class HttpOpenHandler implements OpenHandler { readonly id = 'http'; @inject(WindowService) - protected readonly windowService: WindowService; + protected readonly windowService!: WindowService; @inject(ExternalUriService) - protected readonly externalUriService: ExternalUriService; + protected readonly externalUriService!: ExternalUriService; canHandle(uri: URI, options?: HttpOpenHandlerOptions): number { return ((options && options.openExternal) || uri.scheme.startsWith('http') || uri.scheme.startsWith('mailto')) ? 500 : 0; diff --git a/packages/core/src/browser/icon-theme-contribution.ts b/packages/core/src/browser/icon-theme-contribution.ts index a82fe083d3288..31cca926868b2 100644 --- a/packages/core/src/browser/icon-theme-contribution.ts +++ b/packages/core/src/browser/icon-theme-contribution.ts @@ -30,10 +30,10 @@ export interface IconThemeContribution { export class IconThemeApplicationContribution implements FrontendApplicationContribution { @inject(IconThemeService) - protected readonly iconThemes: IconThemeService; + protected readonly iconThemes!: IconThemeService; @inject(ContributionProvider) @named(IconThemeContribution) - protected readonly iconThemeContributions: ContributionProvider; + protected readonly iconThemeContributions!: ContributionProvider; async onStart(): Promise { for (const contribution of this.iconThemeContributions.getContributions()) { diff --git a/packages/core/src/browser/icon-theme-service.ts b/packages/core/src/browser/icon-theme-service.ts index b46ae09074782..ca0ba18ce16ae 100644 --- a/packages/core/src/browser/icon-theme-service.ts +++ b/packages/core/src/browser/icon-theme-service.ts @@ -90,7 +90,7 @@ export class IconThemeService { } @inject(NoneIconTheme) - protected readonly noneIconTheme: NoneIconTheme; + protected readonly noneIconTheme!: NoneIconTheme; protected readonly onDidChangeCurrentEmitter = new Emitter(); readonly onDidChangeCurrent = this.onDidChangeCurrentEmitter.event; diff --git a/packages/core/src/browser/json-schema-store.ts b/packages/core/src/browser/json-schema-store.ts index 6b040a26c8531..a529e47c2a369 100644 --- a/packages/core/src/browser/json-schema-store.ts +++ b/packages/core/src/browser/json-schema-store.ts @@ -39,7 +39,7 @@ export interface JsonSchemaContribution { export class JsonSchemaStore implements FrontendApplicationContribution { @inject(ContributionProvider) @named(JsonSchemaContribution) - protected readonly contributions: ContributionProvider; + protected readonly contributions!: ContributionProvider; protected readonly _schemas = new Deferred(); get schemas(): Promise { @@ -120,4 +120,3 @@ export namespace DefaultJsonSchemaContribution { schema: any; } } - diff --git a/packages/core/src/browser/keybinding.ts b/packages/core/src/browser/keybinding.ts index d76fadcf4fa47..9881b0fe5c103 100644 --- a/packages/core/src/browser/keybinding.ts +++ b/packages/core/src/browser/keybinding.ts @@ -103,28 +103,28 @@ export class KeybindingRegistry { protected readonly keymaps: ScopedKeybinding[][] = [...Array(KeybindingScope.length)].map(() => []); @inject(CorePreferences) - protected readonly corePreferences: CorePreferences; + protected readonly corePreferences!: CorePreferences; @inject(KeyboardLayoutService) - protected readonly keyboardLayoutService: KeyboardLayoutService; + protected readonly keyboardLayoutService!: KeyboardLayoutService; @inject(ContributionProvider) @named(KeybindingContext) - protected readonly contextProvider: ContributionProvider; + protected readonly contextProvider!: ContributionProvider; @inject(CommandRegistry) - protected readonly commandRegistry: CommandRegistry; + protected readonly commandRegistry!: CommandRegistry; @inject(ContributionProvider) @named(KeybindingContribution) - protected readonly contributions: ContributionProvider; + protected readonly contributions!: ContributionProvider; @inject(StatusBar) - protected readonly statusBar: StatusBar; + protected readonly statusBar!: StatusBar; @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(ContextKeyService) - protected readonly whenContextService: ContextKeyService; + protected readonly whenContextService!: ContextKeyService; async onStart(): Promise { await this.keyboardLayoutService.initialize(); diff --git a/packages/core/src/browser/keyboard/browser-keyboard-frontend-contribution.ts b/packages/core/src/browser/keyboard/browser-keyboard-frontend-contribution.ts index ccfd14bf67d1d..bf9606e9dfa04 100644 --- a/packages/core/src/browser/keyboard/browser-keyboard-frontend-contribution.ts +++ b/packages/core/src/browser/keyboard/browser-keyboard-frontend-contribution.ts @@ -38,10 +38,10 @@ export namespace KeyboardCommands { export class BrowserKeyboardFrontendContribution implements CommandContribution { @inject(BrowserKeyboardLayoutProvider) - protected readonly layoutProvider: BrowserKeyboardLayoutProvider; + protected readonly layoutProvider!: BrowserKeyboardLayoutProvider; @inject(QuickInputService) @optional() - protected readonly quickInputService: QuickInputService; + protected readonly quickInputService?: QuickInputService; registerCommands(commandRegistry: CommandRegistry): void { commandRegistry.registerCommand(KeyboardCommands.CHOOSE_KEYBOARD_LAYOUT, { diff --git a/packages/core/src/browser/keyboard/browser-keyboard-layout-provider.ts b/packages/core/src/browser/keyboard/browser-keyboard-layout-provider.ts index c8673caa2c767..41af1c3e85668 100644 --- a/packages/core/src/browser/keyboard/browser-keyboard-layout-provider.ts +++ b/packages/core/src/browser/keyboard/browser-keyboard-layout-provider.ts @@ -30,10 +30,10 @@ export type KeyboardLayoutSource = 'navigator.keyboard' | 'user-choice' | 'press export class BrowserKeyboardLayoutProvider implements KeyboardLayoutProvider, KeyboardLayoutChangeNotifier, KeyValidator { @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(LocalStorageService) - protected readonly storageService: LocalStorageService; + protected readonly storageService!: LocalStorageService; protected readonly initialized = new Deferred(); protected readonly nativeLayoutChanged = new Emitter(); diff --git a/packages/core/src/browser/keyboard/keyboard-layout-service.ts b/packages/core/src/browser/keyboard/keyboard-layout-service.ts index 74cf7e0d38a0a..35756f56eb7f5 100644 --- a/packages/core/src/browser/keyboard/keyboard-layout-service.ts +++ b/packages/core/src/browser/keyboard/keyboard-layout-service.ts @@ -40,10 +40,10 @@ export interface KeyboardLayout { export class KeyboardLayoutService { @inject(KeyboardLayoutProvider) - protected readonly layoutProvider: KeyboardLayoutProvider; + protected readonly layoutProvider!: KeyboardLayoutProvider; @inject(KeyboardLayoutChangeNotifier) - protected readonly layoutChangeNotifier: KeyboardLayoutChangeNotifier; + protected readonly layoutChangeNotifier!: KeyboardLayoutChangeNotifier; @inject(KeyValidator) @optional() protected readonly keyValidator?: KeyValidator; diff --git a/packages/core/src/browser/label-provider.ts b/packages/core/src/browser/label-provider.ts index cc4aef51b5eef..0120503850d69 100644 --- a/packages/core/src/browser/label-provider.ts +++ b/packages/core/src/browser/label-provider.ts @@ -121,7 +121,7 @@ export class DefaultUriLabelProviderContribution implements LabelProviderContrib protected formatters: ResourceLabelFormatter[] = []; protected readonly onDidChangeEmitter = new Emitter(); protected homePath: string | undefined; - @inject(EnvVariablesServer) protected readonly envVariablesServer: EnvVariablesServer; + @inject(EnvVariablesServer) protected readonly envVariablesServer!: EnvVariablesServer; @postConstruct() init(): void { @@ -282,7 +282,7 @@ export class LabelProvider implements FrontendApplicationContribution { protected readonly onDidChangeEmitter = new Emitter(); @inject(ContributionProvider) @named(LabelProviderContribution) - protected readonly contributionProvider: ContributionProvider; + protected readonly contributionProvider!: ContributionProvider; /** * Start listening to contributions. diff --git a/packages/core/src/browser/menu/browser-menu-plugin.ts b/packages/core/src/browser/menu/browser-menu-plugin.ts index f393a301264c0..4f3e765928b86 100644 --- a/packages/core/src/browser/menu/browser-menu-plugin.ts +++ b/packages/core/src/browser/menu/browser-menu-plugin.ts @@ -39,22 +39,22 @@ export abstract class MenuBarWidget extends MenuBar { export class BrowserMainMenuFactory implements MenuWidgetFactory { @inject(ContextKeyService) - protected readonly contextKeyService: ContextKeyService; + protected readonly contextKeyService!: ContextKeyService; @inject(ContextMenuContext) - protected readonly context: ContextMenuContext; + protected readonly context!: ContextMenuContext; @inject(CommandRegistry) - protected readonly commandRegistry: CommandRegistry; + protected readonly commandRegistry!: CommandRegistry; @inject(CorePreferences) - protected readonly corePreferences: CorePreferences; + protected readonly corePreferences!: CorePreferences; @inject(KeybindingRegistry) - protected readonly keybindingRegistry: KeybindingRegistry; + protected readonly keybindingRegistry!: KeybindingRegistry; @inject(MenuModelRegistry) - protected readonly menuProvider: MenuModelRegistry; + protected readonly menuProvider!: MenuModelRegistry; createMenuBar(): MenuBarWidget { const menuBar = new DynamicMenuBarWidget(); @@ -219,12 +219,12 @@ export class DynamicMenuBarWidget extends MenuBarWidget { } -export class MenuServices { - readonly commandRegistry: CommandRegistry; - readonly keybindingRegistry: KeybindingRegistry; - readonly contextKeyService: ContextKeyService; - readonly context: ContextMenuContext; - readonly menuWidgetFactory: MenuWidgetFactory; +export abstract class MenuServices { + abstract readonly commandRegistry: CommandRegistry; + abstract readonly keybindingRegistry: KeybindingRegistry; + abstract readonly contextKeyService: ContextKeyService; + abstract readonly context: ContextMenuContext; + abstract readonly menuWidgetFactory: MenuWidgetFactory; } export interface MenuWidgetFactory { @@ -370,10 +370,10 @@ export class DynamicMenuWidget extends MenuWidget { export class BrowserMenuBarContribution implements FrontendApplicationContribution { @inject(ApplicationShell) - protected readonly shell: ApplicationShell; + protected readonly shell!: ApplicationShell; @inject(PreferenceService) - protected readonly preferenceService: PreferenceService; + protected readonly preferenceService!: PreferenceService; constructor( @inject(BrowserMainMenuFactory) protected readonly factory: BrowserMainMenuFactory diff --git a/packages/core/src/browser/messaging/ws-connection-provider.ts b/packages/core/src/browser/messaging/ws-connection-provider.ts index 572929d382c0c..181a4b34aae70 100644 --- a/packages/core/src/browser/messaging/ws-connection-provider.ts +++ b/packages/core/src/browser/messaging/ws-connection-provider.ts @@ -23,7 +23,7 @@ import { AbstractConnectionProvider } from '../../common/messaging/abstract-conn import { v4 as uuid } from 'uuid'; decorate(injectable(), JsonRpcProxyFactory); -decorate(unmanaged(), JsonRpcProxyFactory, 0); +decorate(unmanaged() as ParameterDecorator, JsonRpcProxyFactory, 0); export interface WebSocketOptions { /** @@ -78,10 +78,10 @@ export class WebSocketConnectionProvider extends AbstractConnectionProvider MessageService; + protected readonly messageService!: () => MessageService; @inject(HttpFallbackOptions) @optional() - protected readonly httpFallbackOptions: HttpFallbackOptions | undefined; + protected readonly httpFallbackOptions?: HttpFallbackOptions | undefined; protected readonly socket: ReconnectingWebSocket; protected useHttpFallback = false; diff --git a/packages/core/src/browser/preferences/preference-configurations.ts b/packages/core/src/browser/preferences/preference-configurations.ts index 46feed84bfd36..01000f6cee467 100644 --- a/packages/core/src/browser/preferences/preference-configurations.ts +++ b/packages/core/src/browser/preferences/preference-configurations.ts @@ -32,7 +32,7 @@ export function bindPreferenceConfigurations(bind: interfaces.Bind): void { export class PreferenceConfigurations { @inject(ContributionProvider) @named(PreferenceConfiguration) - protected readonly provider: ContributionProvider; + protected readonly provider!: ContributionProvider; /* prefer Theia over VS Code by default */ getPaths(): string[] { diff --git a/packages/core/src/browser/preferences/preference-contribution.ts b/packages/core/src/browser/preferences/preference-contribution.ts index f30b0f906ee33..a952cc767cb78 100644 --- a/packages/core/src/browser/preferences/preference-contribution.ts +++ b/packages/core/src/browser/preferences/preference-contribution.ts @@ -102,10 +102,10 @@ export class PreferenceSchemaProvider extends PreferenceProvider { protected readonly folderSchema: PreferenceDataSchema = { properties: {}, patternProperties: {} }; @inject(ContributionProvider) @named(PreferenceContribution) - protected readonly preferenceContributions: ContributionProvider; + protected readonly preferenceContributions!: ContributionProvider; @inject(PreferenceConfigurations) - protected readonly configurations: PreferenceConfigurations; + protected readonly configurations!: PreferenceConfigurations; protected readonly onDidPreferenceSchemaChangedEmitter = new Emitter(); readonly onDidPreferenceSchemaChanged: Event = this.onDidPreferenceSchemaChangedEmitter.event; diff --git a/packages/core/src/browser/preferences/preference-provider.ts b/packages/core/src/browser/preferences/preference-provider.ts index 17479c52251b2..5c81d93b12ed4 100644 --- a/packages/core/src/browser/preferences/preference-provider.ts +++ b/packages/core/src/browser/preferences/preference-provider.ts @@ -57,7 +57,7 @@ export interface PreferenceResolveResult { @injectable() export abstract class PreferenceProvider implements Disposable { - @inject(PreferenceLanguageOverrideService) protected readonly preferenceOverrideService: PreferenceLanguageOverrideService; + @inject(PreferenceLanguageOverrideService) protected readonly preferenceOverrideService!: PreferenceLanguageOverrideService; protected readonly onDidPreferencesChangedEmitter = new Emitter(); readonly onDidPreferencesChanged: Event = this.onDidPreferencesChangedEmitter.event; diff --git a/packages/core/src/browser/preferences/preference-service.ts b/packages/core/src/browser/preferences/preference-service.ts index df9929f1275c2..c93c88095123f 100644 --- a/packages/core/src/browser/preferences/preference-service.ts +++ b/packages/core/src/browser/preferences/preference-service.ts @@ -286,16 +286,16 @@ export class PreferenceServiceImpl implements PreferenceService { protected readonly toDispose = new DisposableCollection(this.onPreferenceChangedEmitter, this.onPreferencesChangedEmitter); @inject(PreferenceSchemaProvider) - protected readonly schema: PreferenceSchemaProvider; + protected readonly schema!: PreferenceSchemaProvider; @inject(PreferenceProviderProvider) - protected readonly providerProvider: PreferenceProviderProvider; + protected readonly providerProvider!: PreferenceProviderProvider; @inject(PreferenceConfigurations) - protected readonly configurations: PreferenceConfigurations; + protected readonly configurations!: PreferenceConfigurations; @inject(PreferenceLanguageOverrideService) - protected readonly preferenceOverrideService: PreferenceLanguageOverrideService; + protected readonly preferenceOverrideService!: PreferenceLanguageOverrideService; protected readonly preferenceProviders = new Map(); diff --git a/packages/core/src/browser/progress-bar.ts b/packages/core/src/browser/progress-bar.ts index f5aa67c1e9959..515d552251739 100644 --- a/packages/core/src/browser/progress-bar.ts +++ b/packages/core/src/browser/progress-bar.ts @@ -23,10 +23,10 @@ import { ProgressBarOptions } from './progress-bar-factory'; export class ProgressBar implements Disposable { @inject(ProgressLocationService) - protected readonly progressLocationService: ProgressLocationService; + protected readonly progressLocationService!: ProgressLocationService; @inject(ProgressBarOptions) - protected readonly options: ProgressBarOptions; + protected readonly options!: ProgressBarOptions; protected readonly toDispose = new DisposableCollection(); dispose(): void { diff --git a/packages/core/src/browser/progress-client.ts b/packages/core/src/browser/progress-client.ts index 4ef2fa3a53fa7..842b9d0a158fc 100644 --- a/packages/core/src/browser/progress-client.ts +++ b/packages/core/src/browser/progress-client.ts @@ -25,10 +25,10 @@ import { ProgressLocationService } from './progress-location-service'; export class DispatchingProgressClient implements ProgressClient { @inject(ProgressStatusBarItem) - protected statusBarItem: ProgressStatusBarItem; + protected statusBarItem!: ProgressStatusBarItem; @inject(ProgressLocationService) - protected locationService: ProgressLocationService; + protected locationService!: ProgressLocationService; showProgress(progressId: string, message: ProgressMessage, cancellationToken: CancellationToken): Promise { const locationId = this.getLocationId(message); diff --git a/packages/core/src/browser/progress-status-bar-item.ts b/packages/core/src/browser/progress-status-bar-item.ts index 3393178cdbcab..77d06a014e930 100644 --- a/packages/core/src/browser/progress-status-bar-item.ts +++ b/packages/core/src/browser/progress-status-bar-item.ts @@ -27,7 +27,7 @@ export class ProgressStatusBarItem implements ProgressClient { protected readonly id = 'theia-progress-status-bar-item'; @inject(StatusBar) - protected readonly statusBar: StatusBar; + protected readonly statusBar!: StatusBar; protected messagesByProgress = new Map(); diff --git a/packages/core/src/browser/quick-input/quick-command-frontend-contribution.ts b/packages/core/src/browser/quick-input/quick-command-frontend-contribution.ts index 99a2ffd6a8427..a094f50fbf5bd 100644 --- a/packages/core/src/browser/quick-input/quick-command-frontend-contribution.ts +++ b/packages/core/src/browser/quick-input/quick-command-frontend-contribution.ts @@ -24,10 +24,10 @@ import { QuickInputService } from './quick-input-service'; export class QuickCommandFrontendContribution implements CommandContribution, KeybindingContribution, MenuContribution { @inject(QuickInputService) @optional() - protected readonly quickInputService: QuickInputService; + protected readonly quickInputService?: QuickInputService; @inject(QuickCommandService) @optional() - protected readonly quickCommandService: QuickCommandService; + protected readonly quickCommandService?: QuickCommandService; registerCommands(commands: CommandRegistry): void { commands.registerCommand(quickCommand, { diff --git a/packages/core/src/browser/quick-input/quick-command-service.ts b/packages/core/src/browser/quick-input/quick-command-service.ts index 49963538a5935..674836b69f270 100644 --- a/packages/core/src/browser/quick-input/quick-command-service.ts +++ b/packages/core/src/browser/quick-input/quick-command-service.ts @@ -38,19 +38,19 @@ export class QuickCommandService implements QuickAccessContribution, QuickAccess static PREFIX = '>'; @inject(ContextKeyService) - protected readonly contextKeyService: ContextKeyService; + protected readonly contextKeyService!: ContextKeyService; @inject(CommandRegistry) - protected readonly commandRegistry: CommandRegistry; + protected readonly commandRegistry!: CommandRegistry; @inject(CorePreferences) - protected readonly corePreferences: CorePreferences; + protected readonly corePreferences!: CorePreferences; @inject(QuickAccessRegistry) - protected readonly quickAccessRegistry: QuickAccessRegistry; + protected readonly quickAccessRegistry!: QuickAccessRegistry; @inject(KeybindingRegistry) - protected readonly keybindingRegistry: KeybindingRegistry; + protected readonly keybindingRegistry!: KeybindingRegistry; // The list of exempted commands not to be displayed in the recently used list. readonly exemptedCommands: Command[] = [ diff --git a/packages/core/src/browser/quick-input/quick-help-service.ts b/packages/core/src/browser/quick-input/quick-help-service.ts index eebc28d1c729f..c6b2f9bfda6b9 100644 --- a/packages/core/src/browser/quick-input/quick-help-service.ts +++ b/packages/core/src/browser/quick-input/quick-help-service.ts @@ -24,10 +24,10 @@ export class QuickHelpService implements QuickAccessProvider, QuickAccessContrib static PREFIX = '?'; @inject(QuickAccessRegistry) - protected quickAccessRegistry: QuickAccessRegistry; + protected quickAccessRegistry!: QuickAccessRegistry; @inject(QuickInputService) - protected quickInputService: QuickInputService; + protected quickInputService!: QuickInputService; getPicks(filter: string, token: CancellationToken): (QuickPickItem | QuickPickSeparator)[] { const { editorProviders, globalProviders } = this.getQuickAccessProviders(); diff --git a/packages/core/src/browser/quick-input/quick-input-frontend-contribution.ts b/packages/core/src/browser/quick-input/quick-input-frontend-contribution.ts index 8c61eca25d34f..1a9572c1f8dd4 100644 --- a/packages/core/src/browser/quick-input/quick-input-frontend-contribution.ts +++ b/packages/core/src/browser/quick-input/quick-input-frontend-contribution.ts @@ -23,7 +23,7 @@ import { QuickAccessContribution } from './quick-access'; export class QuickInputFrontendContribution implements FrontendApplicationContribution { @inject(ContributionProvider) @named(QuickAccessContribution) - protected readonly contributionProvider: ContributionProvider; + protected readonly contributionProvider!: ContributionProvider; onStart(): void { this.contributionProvider.getContributions().forEach(contrib => { diff --git a/packages/core/src/browser/quick-input/quick-pick-service-impl.ts b/packages/core/src/browser/quick-input/quick-pick-service-impl.ts index 5065482fb1909..24789bd8c571c 100644 --- a/packages/core/src/browser/quick-input/quick-pick-service-impl.ts +++ b/packages/core/src/browser/quick-input/quick-pick-service-impl.ts @@ -23,7 +23,7 @@ import { QuickInputService, QuickPickItem, QuickInputButtonHandle, QuickPick, Qu export class QuickPickServiceImpl implements QuickPickService { @inject(QuickInputService) @optional() - protected readonly quickInputService: QuickInputService; + protected readonly quickInputService?: QuickInputService; private readonly onDidHideEmitter = new Emitter(); readonly onDidHide = this.onDidHideEmitter.event; @@ -44,9 +44,12 @@ export class QuickPickServiceImpl implements QuickPickService { readonly onDidTriggerButton = this.onDidTriggerButtonEmitter.event; // eslint-disable-next-line @typescript-eslint/no-explicit-any - private items: Array = []; + private items: any[] = []; - async show(items: Array, options?: QuickPickOptions): Promise { + async show(items: T[], options?: QuickPickOptions): Promise { + if (!this.quickInputService) { + throw new Error('QuickPickServiceImpl.quickInputServiceImpl is not set'); + } this.items = items; const opts = Object.assign({}, options, { onDidAccept: () => this.onDidAcceptEmitter.fire(), @@ -56,7 +59,7 @@ export class QuickPickServiceImpl implements QuickPickService { onDidHide: () => this.onDidHideEmitter.fire(), onDidTriggerButton: (btn: QuickInputButtonHandle) => this.onDidTriggerButtonEmitter.fire(btn), }); - return this.quickInputService?.showQuickPick(this.items, opts); + return this.quickInputService.showQuickPick(this.items, opts); } hide(): void { diff --git a/packages/core/src/browser/quick-input/quick-view-service.ts b/packages/core/src/browser/quick-input/quick-view-service.ts index 6328ac0770797..4ebd2e2296ea3 100644 --- a/packages/core/src/browser/quick-input/quick-view-service.ts +++ b/packages/core/src/browser/quick-input/quick-view-service.ts @@ -34,10 +34,10 @@ export class QuickViewService implements QuickAccessContribution, QuickAccessPro private hiddenItemLabels = new Set(); @inject(QuickAccessRegistry) - protected readonly quickAccessRegistry: QuickAccessRegistry; + protected readonly quickAccessRegistry!: QuickAccessRegistry; @inject(ContextKeyService) - protected readonly contextKexService: ContextKeyService; + protected readonly contextKexService!: ContextKeyService; registerItem(item: QuickViewItem): Disposable { const quickOpenItem = { diff --git a/packages/core/src/browser/resource-context-key.ts b/packages/core/src/browser/resource-context-key.ts index 31948c9070890..6e80a35927338 100644 --- a/packages/core/src/browser/resource-context-key.ts +++ b/packages/core/src/browser/resource-context-key.ts @@ -24,18 +24,18 @@ import { LanguageService } from './language-service'; export class ResourceContextKey { @inject(LanguageService) - protected readonly languages: LanguageService; + protected readonly languages!: LanguageService; @inject(ContextKeyService) - protected readonly contextKeyService: ContextKeyService; + protected readonly contextKeyService!: ContextKeyService; - protected resource: ContextKey; - protected resourceSchemeKey: ContextKey; - protected resourceFileName: ContextKey; - protected resourceExtname: ContextKey; - protected resourceLangId: ContextKey; - protected resourceDirName: ContextKey; - protected resourcePath: ContextKey; + protected resource!: ContextKey; + protected resourceSchemeKey!: ContextKey; + protected resourceFileName!: ContextKey; + protected resourceExtname!: ContextKey; + protected resourceLangId!: ContextKey; + protected resourceDirName!: ContextKey; + protected resourcePath!: ContextKey; @postConstruct() protected init(): void { diff --git a/packages/core/src/browser/shell/application-shell-mouse-tracker.ts b/packages/core/src/browser/shell/application-shell-mouse-tracker.ts index 99f40307a235b..018b37ebb41d8 100644 --- a/packages/core/src/browser/shell/application-shell-mouse-tracker.ts +++ b/packages/core/src/browser/shell/application-shell-mouse-tracker.ts @@ -33,7 +33,7 @@ import { addEventListener, Widget } from '../widgets'; export class ApplicationShellMouseTracker implements FrontendApplicationContribution { @inject(ApplicationShell) - protected readonly applicationShell: ApplicationShell; + protected readonly applicationShell!: ApplicationShell; protected readonly toDispose = new DisposableCollection(); protected readonly toDisposeOnActiveChange = new DisposableCollection(); diff --git a/packages/core/src/browser/shell/application-shell.ts b/packages/core/src/browser/shell/application-shell.ts index e5e6885662e1a..afc15ae3e3333 100644 --- a/packages/core/src/browser/shell/application-shell.ts +++ b/packages/core/src/browser/shell/application-shell.ts @@ -186,7 +186,7 @@ export class ApplicationShell extends Widget { private dragState?: WidgetDragState; @inject(ContextKeyService) - protected readonly contextKeyService: ContextKeyService; + protected readonly contextKeyService!: ContextKeyService; protected readonly onDidAddWidgetEmitter = new Emitter(); readonly onDidAddWidget = this.onDidAddWidgetEmitter.event; diff --git a/packages/core/src/browser/shell/shell-layout-restorer.ts b/packages/core/src/browser/shell/shell-layout-restorer.ts index d8af37ad78df8..36d723e7bbc69 100644 --- a/packages/core/src/browser/shell/shell-layout-restorer.ts +++ b/packages/core/src/browser/shell/shell-layout-restorer.ts @@ -123,7 +123,7 @@ export class ShellLayoutRestorer implements CommandContribution { protected shouldStoreLayout: boolean = true; @inject(ContributionProvider) @named(ApplicationShellLayoutMigration) - protected readonly migrations: ContributionProvider; + protected readonly migrations!: ContributionProvider; constructor( @inject(WidgetManager) protected widgetManager: WidgetManager, diff --git a/packages/core/src/browser/shell/side-panel-handler.ts b/packages/core/src/browser/shell/side-panel-handler.ts index 2d5a3ebacccce..214408a878f6c 100644 --- a/packages/core/src/browser/shell/side-panel-handler.ts +++ b/packages/core/src/browser/shell/side-panel-handler.ts @@ -66,33 +66,33 @@ export class SidePanelHandler { * accordingly in the tab bar, and the panel is hidden by setting that property to `null`. The * tab bar itself remains visible as long as there is at least one widget. */ - tabBar: SideTabBar; + tabBar!: SideTabBar; /** * The menu placed on the sidebar top. * Displayed as icons. * Open menus when on clicks. */ - topMenu: SidebarMenuWidget; + topMenu!: SidebarMenuWidget; /** * The menu placed on the sidebar bottom. * Displayed as icons. * Open menus when on clicks. */ - bottomMenu: SidebarMenuWidget; + bottomMenu!: SidebarMenuWidget; /** * A tool bar, which displays a title and widget specific command buttons. */ - toolBar: SidePanelToolbar; + toolBar!: SidePanelToolbar; /** * The widget container is a dock panel in `single-document` mode, which means that the panel * cannot be split. */ - dockPanel: TheiaDockPanel; + dockPanel!: TheiaDockPanel; /** * The panel that contains the tab bar and the dock panel. This one is hidden whenever the dock * panel is empty. */ - container: Panel; + container!: Panel; /** * The current state of the side panel. */ @@ -106,22 +106,22 @@ export class SidePanelHandler { * The shell area where the panel is placed. This property should not be modified directly, but * only by calling `create`. */ - protected side: 'left' | 'right'; + protected side!: 'left' | 'right'; /** * Options that control the behavior of the side panel. */ - protected options: SidePanel.Options; + protected options!: SidePanel.Options; - @inject(TabBarToolbarRegistry) protected tabBarToolBarRegistry: TabBarToolbarRegistry; - @inject(TabBarToolbarFactory) protected tabBarToolBarFactory: () => TabBarToolbar; - @inject(TabBarRendererFactory) protected tabBarRendererFactory: () => TabBarRenderer; - @inject(SidebarTopMenuWidgetFactory) protected sidebarTopWidgetFactory: () => SidebarTopMenuWidget; - @inject(SidebarBottomMenuWidgetFactory) protected sidebarBottomWidgetFactory: () => SidebarBottomMenuWidget; - @inject(SplitPositionHandler) protected splitPositionHandler: SplitPositionHandler; - @inject(FrontendApplicationStateService) protected readonly applicationStateService: FrontendApplicationStateService; + @inject(TabBarToolbarRegistry) protected tabBarToolBarRegistry!: TabBarToolbarRegistry; + @inject(TabBarToolbarFactory) protected tabBarToolBarFactory!: () => TabBarToolbar; + @inject(TabBarRendererFactory) protected tabBarRendererFactory!: () => TabBarRenderer; + @inject(SidebarTopMenuWidgetFactory) protected sidebarTopWidgetFactory!: () => SidebarTopMenuWidget; + @inject(SidebarBottomMenuWidgetFactory) protected sidebarBottomWidgetFactory!: () => SidebarBottomMenuWidget; + @inject(SplitPositionHandler) protected splitPositionHandler!: SplitPositionHandler; + @inject(FrontendApplicationStateService) protected readonly applicationStateService!: FrontendApplicationStateService; @inject(ContextMenuRenderer) - protected readonly contextMenuRenderer: ContextMenuRenderer; + protected readonly contextMenuRenderer!: ContextMenuRenderer; /** * Create the side bar and dock panel widgets. diff --git a/packages/core/src/browser/shell/sidebar-menu-widget.tsx b/packages/core/src/browser/shell/sidebar-menu-widget.tsx index 18726a1182a44..0a49384bfb625 100644 --- a/packages/core/src/browser/shell/sidebar-menu-widget.tsx +++ b/packages/core/src/browser/shell/sidebar-menu-widget.tsx @@ -42,7 +42,7 @@ export class SidebarMenuWidget extends ReactWidget { protected readonly menus: SidebarMenu[]; @inject(ContextMenuRenderer) - protected readonly contextMenuRenderer: ContextMenuRenderer; + protected readonly contextMenuRenderer!: ContextMenuRenderer; constructor() { super(); diff --git a/packages/core/src/browser/shell/tab-bar-decorator.ts b/packages/core/src/browser/shell/tab-bar-decorator.ts index af246575a0115..3b60208fd4612 100644 --- a/packages/core/src/browser/shell/tab-bar-decorator.ts +++ b/packages/core/src/browser/shell/tab-bar-decorator.ts @@ -51,7 +51,7 @@ export class TabBarDecoratorService implements FrontendApplicationContribution { readonly onDidChangeDecorations = this.onDidChangeDecorationsEmitter.event; @inject(ContributionProvider) @named(TabBarDecorator) - protected readonly contributions: ContributionProvider; + protected readonly contributions!: ContributionProvider; initialize(): void { this.contributions.getContributions().map(decorator => decorator.onDidChangeDecorations(this.fireDidChangeDecorations)); diff --git a/packages/core/src/browser/shell/tab-bar-toolbar.tsx b/packages/core/src/browser/shell/tab-bar-toolbar.tsx index 5d9968b732e11..71450aba38522 100644 --- a/packages/core/src/browser/shell/tab-bar-toolbar.tsx +++ b/packages/core/src/browser/shell/tab-bar-toolbar.tsx @@ -158,9 +158,9 @@ export namespace TabBarToolbarItem { /** * Compares the items by `priority` in ascending. Undefined priorities will be treated as `0`. */ - export const PRIORITY_COMPARATOR = (left: TabBarToolbarItem, right: TabBarToolbarItem) => { + export const PRIORITY_COMPARATOR = (left: TabBarToolbarItem | ReactTabBarToolbarItem, right: TabBarToolbarItem | ReactTabBarToolbarItem) => { // The navigation group is special as it will always be sorted to the top/beginning of a menu. - const compareGroup = (leftGroup: string | undefined = 'navigation', rightGroup: string | undefined = 'navigation') => { + const compareGroup = (leftGroup: string = 'navigation', rightGroup: string = 'navigation') => { if (leftGroup === 'navigation') { return rightGroup === 'navigation' ? 0 : -1; } @@ -192,14 +192,14 @@ export class TabBarToolbarRegistry implements FrontendApplicationContribution { protected items: Map = new Map(); @inject(CommandRegistry) - protected readonly commandRegistry: CommandRegistry; + protected readonly commandRegistry!: CommandRegistry; @inject(ContextKeyService) - protected readonly contextKeyService: ContextKeyService; + protected readonly contextKeyService!: ContextKeyService; @inject(ContributionProvider) @named(TabBarToolbarContribution) - protected readonly contributionProvider: ContributionProvider; + protected readonly contributionProvider!: ContributionProvider; protected readonly onDidChangeEmitter = new Emitter(); readonly onDidChange: Event = this.onDidChangeEmitter.event; @@ -284,19 +284,19 @@ export class TabBarToolbar extends ReactWidget { protected more = new Map(); @inject(CommandRegistry) - protected readonly commands: CommandRegistry; + protected readonly commands!: CommandRegistry; @inject(LabelParser) - protected readonly labelParser: LabelParser; + protected readonly labelParser!: LabelParser; @inject(MenuModelRegistry) - protected readonly menus: MenuModelRegistry; + protected readonly menus!: MenuModelRegistry; @inject(ContextMenuRenderer) - protected readonly contextMenuRenderer: ContextMenuRenderer; + protected readonly contextMenuRenderer!: ContextMenuRenderer; @inject(TabBarToolbarRegistry) - protected readonly toolbarRegistry: TabBarToolbarRegistry; + protected readonly toolbarRegistry!: TabBarToolbarRegistry; constructor() { super(); diff --git a/packages/core/src/browser/shell/tab-bars.ts b/packages/core/src/browser/shell/tab-bars.ts index e289cfcc8c00a..d82e32f78a758 100644 --- a/packages/core/src/browser/shell/tab-bars.ts +++ b/packages/core/src/browser/shell/tab-bars.ts @@ -583,11 +583,11 @@ export class ScrollableTabBar extends TabBar { */ export class ToolbarAwareTabBar extends ScrollableTabBar { - protected contentContainer: HTMLElement; + protected contentContainer?: HTMLElement; protected toolbar: TabBarToolbar | undefined; - protected breadcrumbsContainer: HTMLElement; + protected breadcrumbsContainer?: HTMLElement; protected readonly breadcrumbsRenderer: BreadcrumbsRenderer; - protected topRow: HTMLElement; + protected topRow?: HTMLElement; constructor( protected readonly tabBarToolbarRegistry: TabBarToolbarRegistry, @@ -641,7 +641,7 @@ export class ToolbarAwareTabBar extends ScrollableTabBar { if (this.toolbar.isAttached) { Widget.detach(this.toolbar); } - Widget.attach(this.toolbar, this.topRow); + Widget.attach(this.toolbar, this.topRow!); if (this.breadcrumbsContainer) { this.node.appendChild(this.breadcrumbsContainer); } diff --git a/packages/core/src/browser/shell/view-contribution.ts b/packages/core/src/browser/shell/view-contribution.ts index 3aa1ca58a0998..827959d9754c4 100644 --- a/packages/core/src/browser/shell/view-contribution.ts +++ b/packages/core/src/browser/shell/view-contribution.ts @@ -56,11 +56,11 @@ export function bindViewContribution>(bi @injectable() export abstract class AbstractViewContribution implements CommandContribution, MenuContribution, KeybindingContribution { - @inject(WidgetManager) protected readonly widgetManager: WidgetManager; - @inject(ApplicationShell) protected readonly shell: ApplicationShell; + @inject(WidgetManager) protected readonly widgetManager!: WidgetManager; + @inject(ApplicationShell) protected readonly shell!: ApplicationShell; @inject(QuickViewService) @optional() - protected readonly quickView: QuickViewService; + protected readonly quickView?: QuickViewService; readonly toggleCommand?: Command; diff --git a/packages/core/src/browser/storage-service.ts b/packages/core/src/browser/storage-service.ts index 704f41e65603e..82fbbbfa4dfca 100644 --- a/packages/core/src/browser/storage-service.ts +++ b/packages/core/src/browser/storage-service.ts @@ -14,7 +14,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 ********************************************************************************/ -import { inject, injectable, postConstruct } from 'inversify'; +import { inject, injectable } from 'inversify'; import { ILogger } from '../common/logger'; import { MessageService } from '../common/message-service'; import { WindowService } from './window/window-service'; @@ -47,17 +47,16 @@ interface LocalStorage { export class LocalStorageService implements StorageService { private storage: LocalStorage; - @inject(ILogger) protected logger: ILogger; - @inject(MessageService) protected readonly messageService: MessageService; - @inject(WindowService) protected readonly windowService: WindowService; + @inject(ILogger) protected logger!: ILogger; + @inject(MessageService) protected readonly messageService!: MessageService; + @inject(WindowService) protected readonly windowService!: WindowService; - @postConstruct() - protected init(): void { + constructor() { if (typeof window !== 'undefined' && window.localStorage) { this.storage = window.localStorage; this.testLocalStorage(); } else { - this.logger.warn(log => log("The browser doesn't support localStorage. state will not be persisted across sessions.")); + console.warn("The browser doesn't support localStorage. state will not be persisted across sessions."); this.storage = {}; } } diff --git a/packages/core/src/browser/tooltip-service.tsx b/packages/core/src/browser/tooltip-service.tsx index 79874bf008587..796a8a5e0d07a 100644 --- a/packages/core/src/browser/tooltip-service.tsx +++ b/packages/core/src/browser/tooltip-service.tsx @@ -51,7 +51,7 @@ const DELAY_PREFERENCE = 'workbench.hover.delay'; export class TooltipServiceImpl extends ReactRenderer implements TooltipService { @inject(CorePreferences) - protected readonly corePreferences: CorePreferences; + protected readonly corePreferences!: CorePreferences; public readonly tooltipId: string; protected rendered = false; diff --git a/packages/core/src/browser/tree/tree-expansion.ts b/packages/core/src/browser/tree/tree-expansion.ts index a74e6aaf5e2da..96fece7c7b02e 100644 --- a/packages/core/src/browser/tree/tree-expansion.ts +++ b/packages/core/src/browser/tree/tree-expansion.ts @@ -81,7 +81,7 @@ export namespace ExpandableTreeNode { @injectable() export class TreeExpansionServiceImpl implements TreeExpansionService { - @inject(Tree) protected readonly tree: Tree; + @inject(Tree) protected readonly tree!: Tree; protected readonly onExpansionChangedEmitter = new Emitter(); @postConstruct() diff --git a/packages/core/src/browser/tree/tree-iterator.ts b/packages/core/src/browser/tree/tree-iterator.ts index dd8470fd9459f..c2e2d44b5f447 100644 --- a/packages/core/src/browser/tree/tree-iterator.ts +++ b/packages/core/src/browser/tree/tree-iterator.ts @@ -128,7 +128,7 @@ export class TopDownTreeIterator extends AbstractTreeIterator { protected iterator(root: TreeNode): IterableIterator { const doNext = this.doNext.bind(this); return (function* (): IterableIterator { - let next = root; + let next: TreeNode | undefined = root; while (next) { yield next; next = doNext(next); @@ -168,7 +168,7 @@ export class BottomUpTreeIterator extends AbstractTreeIterator { protected iterator(root: TreeNode): IterableIterator { const doNext = this.doNext.bind(this); return (function* (): IterableIterator { - let next = root; + let next: TreeNode | undefined = root; while (next) { yield next; next = doNext(next); diff --git a/packages/core/src/browser/tree/tree-model.ts b/packages/core/src/browser/tree/tree-model.ts index 2d1535812656b..109ee85c3e212 100644 --- a/packages/core/src/browser/tree/tree-model.ts +++ b/packages/core/src/browser/tree/tree-model.ts @@ -139,12 +139,12 @@ export interface TreeModel extends Tree, TreeSelectionService, TreeExpansionServ @injectable() export class TreeModelImpl implements TreeModel, SelectionProvider>> { - @inject(ILogger) protected readonly logger: ILogger; - @inject(Tree) protected readonly tree: Tree; - @inject(TreeSelectionService) protected readonly selectionService: TreeSelectionService; - @inject(TreeExpansionService) protected readonly expansionService: TreeExpansionService; - @inject(TreeNavigationService) protected readonly navigationService: TreeNavigationService; - @inject(TreeSearch) protected readonly treeSearch: TreeSearch; + @inject(ILogger) protected readonly logger!: ILogger; + @inject(Tree) protected readonly tree!: Tree; + @inject(TreeSelectionService) protected readonly selectionService!: TreeSelectionService; + @inject(TreeExpansionService) protected readonly expansionService!: TreeExpansionService; + @inject(TreeNavigationService) protected readonly navigationService!: TreeNavigationService; + @inject(TreeSearch) protected readonly treeSearch!: TreeSearch; protected readonly onChangedEmitter = new Emitter(); protected readonly onOpenNodeEmitter = new Emitter(); diff --git a/packages/core/src/browser/tree/tree-search.ts b/packages/core/src/browser/tree/tree-search.ts index 6b691334f65fb..43faadfaad645 100644 --- a/packages/core/src/browser/tree/tree-search.ts +++ b/packages/core/src/browser/tree/tree-search.ts @@ -27,13 +27,13 @@ import { LabelProvider } from '../label-provider'; export class TreeSearch implements Disposable { @inject(Tree) - protected readonly tree: Tree; + protected readonly tree!: Tree; @inject(FuzzySearch) - protected readonly fuzzySearch: FuzzySearch; + protected readonly fuzzySearch!: FuzzySearch; @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; protected readonly disposables = new DisposableCollection(); protected readonly filteredNodesEmitter = new Emitter>>(); diff --git a/packages/core/src/browser/tree/tree-selection-impl.ts b/packages/core/src/browser/tree/tree-selection-impl.ts index 337a8a3c9aa73..b0b31afc92619 100644 --- a/packages/core/src/browser/tree/tree-selection-impl.ts +++ b/packages/core/src/browser/tree/tree-selection-impl.ts @@ -24,10 +24,10 @@ import { TreeSelectionService, SelectableTreeNode, TreeSelection } from './tree- export class TreeSelectionServiceImpl implements TreeSelectionService { @inject(Tree) - protected readonly tree: Tree; + protected readonly tree!: Tree; protected readonly onSelectionChangedEmitter = new Emitter>>(); - protected state: TreeSelectionState; + protected state!: TreeSelectionState; @postConstruct() protected init(): void { diff --git a/packages/core/src/browser/tree/tree-view-welcome-widget.tsx b/packages/core/src/browser/tree/tree-view-welcome-widget.tsx index 8c7f873466957..606b481fdfd11 100644 --- a/packages/core/src/browser/tree/tree-view-welcome-widget.tsx +++ b/packages/core/src/browser/tree/tree-view-welcome-widget.tsx @@ -52,13 +52,13 @@ type LinkedTextItem = string | ILink; export class TreeViewWelcomeWidget extends TreeWidget { @inject(CommandRegistry) - protected readonly commands: CommandRegistry; + protected readonly commands!: CommandRegistry; @inject(ContextKeyService) - protected readonly contextService: ContextKeyService; + protected readonly contextService!: ContextKeyService; @inject(WindowService) - protected readonly windowService: WindowService; + protected readonly windowService!: WindowService; protected viewWelcomeNodes: React.ReactNode[] = []; protected defaultItem: IItem | undefined; diff --git a/packages/core/src/browser/tree/tree-widget.tsx b/packages/core/src/browser/tree/tree-widget.tsx index ddf274b31d13b..fcba5fdd8ee3c 100644 --- a/packages/core/src/browser/tree/tree-widget.tsx +++ b/packages/core/src/browser/tree/tree-widget.tsx @@ -155,26 +155,26 @@ export namespace TreeWidget { @injectable() export class TreeWidget extends ReactWidget implements StatefulWidget { - protected searchBox: SearchBox; - protected searchHighlights: Map; + protected searchBox!: SearchBox; + protected searchHighlights = new Map(); @inject(TreeDecoratorService) - protected readonly decoratorService: TreeDecoratorService; + protected readonly decoratorService!: TreeDecoratorService; @inject(TreeSearch) - protected readonly treeSearch: TreeSearch; + protected readonly treeSearch!: TreeSearch; @inject(SearchBoxFactory) - protected readonly searchBoxFactory: SearchBoxFactory; + protected readonly searchBoxFactory!: SearchBoxFactory; protected decorations: Map = new Map(); @inject(SelectionService) - protected readonly selectionService: SelectionService; + protected readonly selectionService!: SelectionService; @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(CorePreferences) - protected readonly corePreferences: CorePreferences; + protected readonly corePreferences!: CorePreferences; protected shouldScrollToRow = true; diff --git a/packages/core/src/browser/tree/tree.spec.ts b/packages/core/src/browser/tree/tree.spec.ts index 547ac7e96ed94..d99550a541b45 100644 --- a/packages/core/src/browser/tree/tree.spec.ts +++ b/packages/core/src/browser/tree/tree.spec.ts @@ -221,8 +221,7 @@ describe('Tree', () => { } function assertTreeNode(expectation: string, node: TreeNode): void { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - assert.deepStrictEqual(expectation, JSON.stringify(node, (key: keyof CompositeTreeNode, value: any) => { + assert.deepStrictEqual(expectation, JSON.stringify(node, (key, value) => { if (key === 'parent' || key === 'previousSibling' || key === 'nextSibling') { return value && value.id; } @@ -231,12 +230,10 @@ describe('Tree', () => { } function createTreeModel(): TreeModel { - const container = createTreeTestContainer(); - return container.get(TreeModel); + return createTreeTestContainer().get(TreeModel); } function retrieveNode(id: string): Readonly { - const readonlyNode: Readonly = model.getNode(id) as T; - return readonlyNode; + return model.getNode(id) as Readonly; } }); diff --git a/packages/core/src/browser/view-container.ts b/packages/core/src/browser/view-container.ts index 9e77644502195..79a9fbeaaf1cc 100644 --- a/packages/core/src/browser/view-container.ts +++ b/packages/core/src/browser/view-container.ts @@ -47,8 +47,8 @@ export interface ViewContainerTitleOptions { } @injectable() -export class ViewContainerIdentifier { - id: string; +export abstract class ViewContainerIdentifier { + abstract id: string; progressLocationId?: string; } @@ -71,7 +71,7 @@ export namespace DescriptionWidget { @injectable() export class ViewContainer extends BaseWidget implements StatefulWidget, ApplicationShell.TrackableWidgetProvider, TabBarDelegator { - protected panel: SplitPanel; + protected panel!: SplitPanel; protected currentPart: ViewContainerPart | undefined; @@ -81,43 +81,43 @@ export class ViewContainer extends BaseWidget implements StatefulWidget, Applica disableDNDBetweenContainers = false; @inject(FrontendApplicationStateService) - protected readonly applicationStateService: FrontendApplicationStateService; + protected readonly applicationStateService!: FrontendApplicationStateService; @inject(ContextMenuRenderer) - protected readonly contextMenuRenderer: ContextMenuRenderer; + protected readonly contextMenuRenderer!: ContextMenuRenderer; @inject(CommandRegistry) - protected readonly commandRegistry: CommandRegistry; + protected readonly commandRegistry!: CommandRegistry; @inject(MenuModelRegistry) - protected readonly menuRegistry: MenuModelRegistry; + protected readonly menuRegistry!: MenuModelRegistry; @inject(WidgetManager) - protected readonly widgetManager: WidgetManager; + protected readonly widgetManager!: WidgetManager; @inject(SplitPositionHandler) - protected readonly splitPositionHandler: SplitPositionHandler; + protected readonly splitPositionHandler!: SplitPositionHandler; @inject(ViewContainerIdentifier) - readonly options: ViewContainerIdentifier; + readonly options!: ViewContainerIdentifier; @inject(TabBarToolbarRegistry) - protected readonly toolbarRegistry: TabBarToolbarRegistry; + protected readonly toolbarRegistry!: TabBarToolbarRegistry; @inject(TabBarToolbarFactory) - protected readonly toolbarFactory: TabBarToolbarFactory; + protected readonly toolbarFactory!: TabBarToolbarFactory; protected readonly onDidChangeTrackableWidgetsEmitter = new Emitter(); readonly onDidChangeTrackableWidgets = this.onDidChangeTrackableWidgetsEmitter.event; @inject(ProgressBarFactory) - protected readonly progressBarFactory: ProgressBarFactory; + protected readonly progressBarFactory!: ProgressBarFactory; @inject(ApplicationShell) - protected readonly shell: ApplicationShell; + protected readonly shell!: ApplicationShell; @inject(TabBarDecoratorService) - protected readonly decoratorService: TabBarDecoratorService; + protected readonly decoratorService!: TabBarDecoratorService; @postConstruct() protected init(): void { @@ -907,7 +907,7 @@ export class ViewContainerPart extends BaseWidget { protected readonly toolbar: TabBarToolbar; - protected _collapsed: boolean; + protected _collapsed: boolean = false; uncollapsedSize: number | undefined; animatedSize: number | undefined; diff --git a/packages/core/src/browser/widget-manager.ts b/packages/core/src/browser/widget-manager.ts index e00c7e6cb82dd..808a1e86899d2 100644 --- a/packages/core/src/browser/widget-manager.ts +++ b/packages/core/src/browser/widget-manager.ts @@ -111,16 +111,16 @@ export interface DidCreateWidgetEvent { @injectable() export class WidgetManager { - protected _cachedFactories: Map; + protected _cachedFactories?: Map; protected readonly widgets = new Map(); protected readonly widgetPromises = new Map>(); protected readonly pendingWidgetPromises = new Map>(); @inject(ContributionProvider) @named(WidgetFactory) - protected readonly factoryProvider: ContributionProvider; + protected readonly factoryProvider!: ContributionProvider; @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; protected readonly onWillCreateWidgetEmitter = new Emitter(); /** diff --git a/packages/core/src/browser/widget-open-handler.ts b/packages/core/src/browser/widget-open-handler.ts index b2f73ff7f0d66..18a226715593d 100644 --- a/packages/core/src/browser/widget-open-handler.ts +++ b/packages/core/src/browser/widget-open-handler.ts @@ -46,10 +46,10 @@ export interface WidgetOpenerOptions extends OpenerOptions { export abstract class WidgetOpenHandler implements OpenHandler { @inject(ApplicationShell) - protected readonly shell: ApplicationShell; + protected readonly shell!: ApplicationShell; @inject(WidgetManager) - protected readonly widgetManager: WidgetManager; + protected readonly widgetManager!: WidgetManager; protected readonly onCreatedEmitter = new Emitter(); /** diff --git a/packages/core/src/browser/widgets/widget.ts b/packages/core/src/browser/widgets/widget.ts index 60ecbbd20e6cc..eeea431574013 100644 --- a/packages/core/src/browser/widgets/widget.ts +++ b/packages/core/src/browser/widgets/widget.ts @@ -25,7 +25,7 @@ import { KeyCode, KeysOrKeyCodes } from '../keyboard/keys'; import PerfectScrollbar from 'perfect-scrollbar'; decorate(injectable(), Widget); -decorate(unmanaged(), Widget, 0); +decorate(unmanaged() as ParameterDecorator, Widget, 0); export * from '@phosphor/widgets'; export * from '@phosphor/messaging'; @@ -254,10 +254,11 @@ export type EventListenerOrEventListenerObject( element: HTMLElement, type: K, listener: EventListenerOrEventListenerObject, useCapture?: boolean ): Disposable { - element.addEventListener(type, listener, useCapture); - return Disposable.create(() => - element.removeEventListener(type, listener, useCapture) - ); + // The DOM API typings don't seem to take a specific listener as described in this function. + element.addEventListener(type, listener as EventListenerOrEventListenerObject, useCapture); + return Disposable.create(() => { + element.removeEventListener(type, listener as EventListenerOrEventListenerObject, useCapture); + }); } export function addKeyListener( diff --git a/packages/core/src/browser/window-contribution.ts b/packages/core/src/browser/window-contribution.ts index 998f4feb247a7..244e07145f317 100644 --- a/packages/core/src/browser/window-contribution.ts +++ b/packages/core/src/browser/window-contribution.ts @@ -33,7 +33,7 @@ export namespace WindowCommands { export class WindowContribution implements CommandContribution, KeybindingContribution, MenuContribution { @inject(WindowService) - protected windowService: WindowService; + protected windowService!: WindowService; registerCommands(commands: CommandRegistry): void { commands.registerCommand(WindowCommands.NEW_WINDOW, { diff --git a/packages/core/src/browser/window/default-window-service.spec.ts b/packages/core/src/browser/window/default-window-service.spec.ts index 8656a5601086f..71d8d605ea462 100644 --- a/packages/core/src/browser/window/default-window-service.spec.ts +++ b/packages/core/src/browser/window/default-window-service.spec.ts @@ -17,7 +17,7 @@ import { Container } from 'inversify'; import { ContributionProvider } from '../../common'; import { CorePreferences } from '../core-preferences'; -import { FrontendApplicationContribution } from '../frontend-application'; +import { FrontendApplication, FrontendApplicationContribution } from '../frontend-application'; import { DefaultWindowService } from './default-window-service'; import assert = require('assert'); @@ -32,7 +32,9 @@ describe('DefaultWindowService', () => { } function setupWindowService(confirmExit: CorePreferences['application.confirmExit'], frontendContributions: FrontendApplicationContribution[]): DefaultWindowService { const container = new Container(); - container.bind(DefaultWindowService).toSelf().inSingletonScope(); + container.bind(DefaultWindowService).to(class extends DefaultWindowService { + registerUnloadListeners(): void { /** Don't call the DOM APIs in the tests */ } + }).inSingletonScope(); container.bind>>(ContributionProvider) .toConstantValue({ getContributions: () => frontendContributions, @@ -42,7 +44,16 @@ describe('DefaultWindowService', () => { .toConstantValue({ 'application.confirmExit': confirmExit, }); - return container.get(DefaultWindowService); + const windowService = container.get(DefaultWindowService); + // Quick hack here: Instead of providing a fully mocked FrontendApplication, + // we'll pass a pseudo object that throws if you try to access fields on it. + // eslint-disable-next-line no-null/no-null + windowService.onStart(new Proxy(Object.create(null), { + get: (target, property, receiver) => { + throw new Error(`${property.toString()} is not implemented`); + } + })); + return windowService; } it('onWillStop should be called on every contribution (never)', () => { const frontendContributions: TestFrontendApplicationContribution[] = [ diff --git a/packages/core/src/browser/window/default-window-service.ts b/packages/core/src/browser/window/default-window-service.ts index c170d64277caf..42c347128aa3f 100644 --- a/packages/core/src/browser/window/default-window-service.ts +++ b/packages/core/src/browser/window/default-window-service.ts @@ -25,7 +25,7 @@ import { DEFAULT_WINDOW_HASH } from '../../common/window'; @injectable() export class DefaultWindowService implements WindowService, FrontendApplicationContribution { - protected frontendApplication: FrontendApplication; + protected frontendApplication?: FrontendApplication; protected onUnloadEmitter = new Emitter(); get onUnload(): Event { @@ -33,11 +33,11 @@ export class DefaultWindowService implements WindowService, FrontendApplicationC } @inject(CorePreferences) - protected readonly corePreferences: CorePreferences; + protected readonly corePreferences!: CorePreferences; @inject(ContributionProvider) @named(FrontendApplicationContribution) - protected readonly contributions: ContributionProvider; + protected readonly contributions!: ContributionProvider; onStart(app: FrontendApplication): void { this.frontendApplication = app; @@ -54,6 +54,9 @@ export class DefaultWindowService implements WindowService, FrontendApplicationC } canUnload(): boolean { + if (!this.frontendApplication) { + throw new Error('DefaultWindowService.frontendApplication is not set'); + } const confirmExit = this.corePreferences['application.confirmExit']; let preventUnload = confirmExit === 'always'; for (const contribution of this.contributions.getContributions()) { diff --git a/packages/core/src/common/cancellation.ts b/packages/core/src/common/cancellation.ts index a0af2f373e0ce..842bca7c9b93a 100644 --- a/packages/core/src/common/cancellation.ts +++ b/packages/core/src/common/cancellation.ts @@ -87,7 +87,7 @@ class MutableToken implements CancellationToken { export class CancellationTokenSource { - private _token: CancellationToken; + private _token?: CancellationToken; get token(): CancellationToken { if (!this._token) { diff --git a/packages/core/src/common/event.ts b/packages/core/src/common/event.ts index b72d94f1fd3be..3d4b74b1f281c 100644 --- a/packages/core/src/common/event.ts +++ b/packages/core/src/common/event.ts @@ -151,7 +151,7 @@ export class Emitter { private static _noop = function (): void { }; - private _event: Event; + private _event?: Event; protected _callbacks: CallbackList | undefined; private _disposed = false; @@ -176,7 +176,7 @@ export class Emitter { this._options.onFirstListenerAdd(this); } this._callbacks.add(listener, thisArgs); - const removeMaxListenersCheck = this.checkMaxListeners(this._event.maxListeners); + const removeMaxListenersCheck = this.checkMaxListeners(this._event!.maxListeners); const result: Disposable = { dispose: () => { diff --git a/packages/core/src/common/messaging/proxy-factory.ts b/packages/core/src/common/messaging/proxy-factory.ts index 504e8dc2260b8..432831534079a 100644 --- a/packages/core/src/common/messaging/proxy-factory.ts +++ b/packages/core/src/common/messaging/proxy-factory.ts @@ -100,8 +100,8 @@ export class JsonRpcProxyFactory implements ProxyHandler { protected readonly onDidOpenConnectionEmitter = new Emitter(); protected readonly onDidCloseConnectionEmitter = new Emitter(); - protected connectionPromiseResolve: (connection: MessageConnection) => void; - protected connectionPromise: Promise; + protected connectionPromiseResolve!: (connection: MessageConnection) => void; + protected connectionPromise!: Promise; /** * Build a new JsonRpcProxyFactory. diff --git a/packages/core/src/common/path.ts b/packages/core/src/common/path.ts index b2613bc31e164..e2f793d381239 100644 --- a/packages/core/src/common/path.ts +++ b/packages/core/src/common/path.ts @@ -114,7 +114,7 @@ export class Path { readonly name: string; readonly ext: string; - private _dir: Path; + private _dir?: Path; private readonly raw: string; /** diff --git a/packages/core/src/common/progress-service.ts b/packages/core/src/common/progress-service.ts index a7ecfeb67a8a0..69e022f3b29d7 100644 --- a/packages/core/src/common/progress-service.ts +++ b/packages/core/src/common/progress-service.ts @@ -27,8 +27,8 @@ import { MessageService } from './message-service'; @injectable() export class ProgressService { - @inject(ProgressClient) protected readonly client: ProgressClient; - @inject(MessageService) protected readonly messageService: MessageService; + @inject(ProgressClient) protected readonly client!: ProgressClient; + @inject(MessageService) protected readonly messageService!: MessageService; async showProgress(message: ProgressMessage, onDidCancel?: () => void): Promise { if (this.shouldDelegate(message)) { diff --git a/packages/core/src/common/promise-util.ts b/packages/core/src/common/promise-util.ts index 958da2e8bd48e..423212b817a90 100644 --- a/packages/core/src/common/promise-util.ts +++ b/packages/core/src/common/promise-util.ts @@ -22,8 +22,8 @@ import { CancellationToken, cancelled } from './cancellation'; */ export class Deferred { state: 'resolved' | 'rejected' | 'unresolved' = 'unresolved'; - resolve: (value?: T) => void; - reject: (err?: any) => void; // eslint-disable-line @typescript-eslint/no-explicit-any + resolve!: (value?: T) => void; + reject!: (err?: any) => void; // eslint-disable-line @typescript-eslint/no-explicit-any promise = new Promise((resolve, reject) => { this.resolve = result => { diff --git a/packages/core/src/electron-browser/menu/electron-context-menu-renderer.ts b/packages/core/src/electron-browser/menu/electron-context-menu-renderer.ts index 792b40386c997..8bd9c196d53e9 100644 --- a/packages/core/src/electron-browser/menu/electron-context-menu-renderer.ts +++ b/packages/core/src/electron-browser/menu/electron-context-menu-renderer.ts @@ -46,7 +46,7 @@ export namespace ElectronTextInputContextMenu { export class ElectronTextInputContextMenuContribution implements FrontendApplicationContribution, MenuContribution { @inject(ContextMenuRenderer) - protected readonly contextMenuRenderer: ContextMenuRenderer; + protected readonly contextMenuRenderer!: ContextMenuRenderer; onStart(): void { window.document.addEventListener('contextmenu', event => { @@ -80,10 +80,10 @@ export class ElectronTextInputContextMenuContribution implements FrontendApplica export class ElectronContextMenuRenderer extends BrowserContextMenuRenderer { @inject(ContextMenuContext) - protected readonly context: ContextMenuContext; + protected readonly context!: ContextMenuContext; @inject(PreferenceService) - protected readonly preferenceService: PreferenceService; + protected readonly preferenceService!: PreferenceService; protected useNativeStyle: boolean = true; diff --git a/packages/core/src/electron-browser/menu/electron-menu-contribution.ts b/packages/core/src/electron-browser/menu/electron-menu-contribution.ts index 912c5657536a0..5686c872aa23f 100644 --- a/packages/core/src/electron-browser/menu/electron-menu-contribution.ts +++ b/packages/core/src/electron-browser/menu/electron-menu-contribution.ts @@ -82,7 +82,7 @@ export namespace ElectronMenus { export class ElectronMenuContribution extends BrowserMenuBarContribution implements FrontendApplicationContribution, CommandContribution, MenuContribution, KeybindingContribution { @inject(FrontendApplicationStateService) - protected readonly stateService: FrontendApplicationStateService; + protected readonly stateService!: FrontendApplicationStateService; protected titleBarStyleChangeFlag = false; protected titleBarStyle?: string; diff --git a/packages/core/src/electron-browser/window/electron-window-service.ts b/packages/core/src/electron-browser/window/electron-window-service.ts index 95a9e85d09028..e0a527926e938 100644 --- a/packages/core/src/electron-browser/window/electron-window-service.ts +++ b/packages/core/src/electron-browser/window/electron-window-service.ts @@ -35,10 +35,10 @@ export class ElectronWindowService extends DefaultWindowService { protected closeOnUnload: boolean = false; @inject(ElectronMainWindowService) - protected readonly delegate: ElectronMainWindowService; + protected readonly delegate!: ElectronMainWindowService; @inject(ElectronWindowPreferences) - protected readonly electronWindowPreferences: ElectronWindowPreferences; + protected readonly electronWindowPreferences!: ElectronWindowPreferences; openNewWindow(url: string, { external }: NewWindowOptions = {}): undefined { this.delegate.openNewWindow(url, { external }); diff --git a/packages/core/src/electron-main/electron-main-application.ts b/packages/core/src/electron-main/electron-main-application.ts index 3812c742717a8..7f1f46822418e 100644 --- a/packages/core/src/electron-main/electron-main-application.ts +++ b/packages/core/src/electron-main/electron-main-application.ts @@ -163,19 +163,19 @@ export class ElectronMainApplication { @inject(ContributionProvider) @named(ElectronMainApplicationContribution) - protected readonly contributions: ContributionProvider; + protected readonly contributions!: ContributionProvider; @inject(ElectronMainApplicationGlobals) - protected readonly globals: ElectronMainApplicationGlobals; + protected readonly globals!: ElectronMainApplicationGlobals; @inject(ElectronMainProcessArgv) - protected processArgv: ElectronMainProcessArgv; + protected processArgv!: ElectronMainProcessArgv; @inject(ElectronSecurityTokenService) - protected electronSecurityTokenService: ElectronSecurityTokenService; + protected electronSecurityTokenService!: ElectronSecurityTokenService; @inject(ElectronSecurityToken) - protected readonly electronSecurityToken: ElectronSecurityToken; + protected readonly electronSecurityToken!: ElectronSecurityToken; protected readonly electronStore = new Storage(); diff --git a/packages/core/src/electron-main/electron-main-window-service-impl.ts b/packages/core/src/electron-main/electron-main-window-service-impl.ts index 2b13a8725cc67..f8d4363f53285 100644 --- a/packages/core/src/electron-main/electron-main-window-service-impl.ts +++ b/packages/core/src/electron-main/electron-main-window-service-impl.ts @@ -24,7 +24,7 @@ import { NewWindowOptions } from '../common/window'; export class ElectronMainWindowServiceImpl implements ElectronMainWindowService { @inject(ElectronMainApplication) - protected readonly app: ElectronMainApplication; + protected readonly app!: ElectronMainApplication; openNewWindow(url: string, { external }: NewWindowOptions): undefined { if (external) { diff --git a/packages/core/src/electron-main/electron-security-token-service.ts b/packages/core/src/electron-main/electron-security-token-service.ts index cfbbca7641f7d..fa0fa780397ef 100644 --- a/packages/core/src/electron-main/electron-security-token-service.ts +++ b/packages/core/src/electron-main/electron-security-token-service.ts @@ -22,7 +22,7 @@ import { ElectronSecurityToken } from '../electron-common/electron-token'; export class ElectronSecurityTokenService { @inject(ElectronSecurityToken) - protected readonly electronSecurityToken: ElectronSecurityToken; + protected readonly electronSecurityToken!: ElectronSecurityToken; async setElectronSecurityTokenCookie(url: string): Promise { await session.defaultSession.cookies.set({ diff --git a/packages/core/src/electron-main/messaging/electron-messaging-contribution.ts b/packages/core/src/electron-main/messaging/electron-messaging-contribution.ts index 83d96347bde9a..89ec271fa7c44 100644 --- a/packages/core/src/electron-main/messaging/electron-messaging-contribution.ts +++ b/packages/core/src/electron-main/messaging/electron-messaging-contribution.ts @@ -38,10 +38,10 @@ import { ElectronMessagingService } from './electron-messaging-service'; export class ElectronMessagingContribution implements ElectronMainApplicationContribution, ElectronMessagingService { @inject(ContributionProvider) @named(ElectronMessagingService.Contribution) - protected readonly messagingContributions: ContributionProvider; + protected readonly messagingContributions!: ContributionProvider; @inject(ContributionProvider) @named(ElectronConnectionHandler) - protected readonly connectionHandlers: ContributionProvider; + protected readonly connectionHandlers!: ContributionProvider; protected readonly channelHandlers = new MessagingContribution.ConnectionHandlers(); protected readonly windowChannels = new Map>(); diff --git a/packages/core/src/electron-node/token/electron-token-backend-contribution.ts b/packages/core/src/electron-node/token/electron-token-backend-contribution.ts index 495f4e55edfff..4f75996779355 100644 --- a/packages/core/src/electron-node/token/electron-token-backend-contribution.ts +++ b/packages/core/src/electron-node/token/electron-token-backend-contribution.ts @@ -27,7 +27,7 @@ import { ElectronTokenValidator } from './electron-token-validator'; export class ElectronTokenBackendContribution implements BackendApplicationContribution { @inject(ElectronTokenValidator) - protected readonly tokenValidator: ElectronTokenValidator; + protected readonly tokenValidator!: ElectronTokenValidator; configure(app: express.Application): void { app.use(this.expressMiddleware.bind(this)); diff --git a/packages/core/src/electron-node/token/electron-token-messaging-contribution.ts b/packages/core/src/electron-node/token/electron-token-messaging-contribution.ts index 97876c46469fa..8d5cc9743d1e6 100644 --- a/packages/core/src/electron-node/token/electron-token-messaging-contribution.ts +++ b/packages/core/src/electron-node/token/electron-token-messaging-contribution.ts @@ -28,7 +28,7 @@ import { ElectronTokenValidator } from './electron-token-validator'; export class ElectronMessagingContribution extends MessagingContribution { @inject(ElectronTokenValidator) - protected readonly tokenValidator: ElectronTokenValidator; + protected readonly tokenValidator!: ElectronTokenValidator; /** * Only allow token-bearers. diff --git a/packages/core/src/electron-node/token/electron-token-validator.ts b/packages/core/src/electron-node/token/electron-token-validator.ts index 3fd9d4d9c6623..764a3dc44ab29 100644 --- a/packages/core/src/electron-node/token/electron-token-validator.ts +++ b/packages/core/src/electron-node/token/electron-token-validator.ts @@ -28,7 +28,7 @@ import { WsRequestValidatorContribution } from '../../node/ws-request-validators @injectable() export class ElectronTokenValidator implements WsRequestValidatorContribution { - protected electronSecurityToken: ElectronSecurityToken; + protected electronSecurityToken!: ElectronSecurityToken; @postConstruct() protected postConstruct(): void { diff --git a/packages/core/src/node/application-server.ts b/packages/core/src/node/application-server.ts index a23086a17790f..3ceac4235b55a 100644 --- a/packages/core/src/node/application-server.ts +++ b/packages/core/src/node/application-server.ts @@ -23,7 +23,7 @@ import { OS } from '../common/os'; export class ApplicationServerImpl implements ApplicationServer { @inject(ApplicationPackage) - protected readonly applicationPackage: ApplicationPackage; + protected readonly applicationPackage!: ApplicationPackage; getExtensionsInfos(): Promise { const extensions = this.applicationPackage.extensionPackages; diff --git a/packages/core/src/node/backend-application.ts b/packages/core/src/node/backend-application.ts index 8e50774a19181..e9ad597353a12 100644 --- a/packages/core/src/node/backend-application.ts +++ b/packages/core/src/node/backend-application.ts @@ -101,12 +101,13 @@ export interface BackendApplicationContribution { @injectable() export class BackendApplicationCliContribution implements CliContribution { - port: number; - hostname: string | undefined; - ssl: boolean | undefined; - cert: string | undefined; - certkey: string | undefined; - projectPath: string; + projectPath: string = this.appProjectPath(); + + port?: number; + hostname?: string; + ssl?: boolean; + cert?: string; + certkey?: string; configure(conf: yargs.Argv): void { conf.option('port', { alias: 'p', description: 'The port the backend server listens on.', type: 'number', default: DEFAULT_PORT }); @@ -114,7 +115,7 @@ export class BackendApplicationCliContribution implements CliContribution { conf.option('ssl', { description: 'Use SSL (HTTPS), cert and certkey must also be set', type: 'boolean', default: DEFAULT_SSL }); conf.option('cert', { description: 'Path to SSL certificate.', type: 'string' }); conf.option('certkey', { description: 'Path to SSL certificate key.', type: 'string' }); - conf.option(APP_PROJECT_PATH, { description: 'Sets the application project directory', default: this.appProjectPath() }); + conf.option(APP_PROJECT_PATH, { description: 'Sets the application project directory' }); } setArguments(args: yargs.Arguments): void { @@ -123,7 +124,10 @@ export class BackendApplicationCliContribution implements CliContribution { this.ssl = args.ssl as boolean; this.cert = args.cert as string; this.certkey = args.certkey as string; - this.projectPath = args[APP_PROJECT_PATH] as string; + const projectPath = args[APP_PROJECT_PATH] as string | undefined; + if (projectPath) { + this.projectPath = projectPath; + } } protected appProjectPath(): string { @@ -147,10 +151,10 @@ export class BackendApplication { protected readonly app: express.Application = express(); @inject(ApplicationPackage) - protected readonly applicationPackage: ApplicationPackage; + protected readonly applicationPackage!: ApplicationPackage; @inject(ProcessUtils) - protected readonly processUtils: ProcessUtils; + protected readonly processUtils!: ProcessUtils; private readonly _performanceObserver: PerformanceObserver; diff --git a/packages/core/src/node/console-logger-server.ts b/packages/core/src/node/console-logger-server.ts index 33d83d1d67759..8ccf930618584 100644 --- a/packages/core/src/node/console-logger-server.ts +++ b/packages/core/src/node/console-logger-server.ts @@ -25,10 +25,10 @@ export class ConsoleLoggerServer implements ILoggerServer { protected client: ILoggerClient | undefined = undefined; @inject(LoggerWatcher) - protected watcher: LoggerWatcher; + protected watcher!: LoggerWatcher; @inject(LogLevelCliContribution) - protected cli: LogLevelCliContribution; + protected cli!: LogLevelCliContribution; @postConstruct() protected init(): void { diff --git a/packages/core/src/node/hosting/ws-origin-validator.ts b/packages/core/src/node/hosting/ws-origin-validator.ts index a72eeb7ba1d66..5635e2f4b7f56 100644 --- a/packages/core/src/node/hosting/ws-origin-validator.ts +++ b/packages/core/src/node/hosting/ws-origin-validator.ts @@ -24,7 +24,7 @@ import { BackendApplicationHosts } from './backend-application-hosts'; export class WsOriginValidator implements WsRequestValidatorContribution { @inject(BackendApplicationHosts) - protected readonly backendApplicationHosts: BackendApplicationHosts; + protected readonly backendApplicationHosts!: BackendApplicationHosts; allowWsUpgrade(request: http.IncomingMessage): boolean { if (!this.backendApplicationHosts.hasKnownHosts() || !request.headers.origin) { diff --git a/packages/core/src/node/i18n/localization-backend-contribution.ts b/packages/core/src/node/i18n/localization-backend-contribution.ts index 18c85d888c9d6..7564b9902f29f 100644 --- a/packages/core/src/node/i18n/localization-backend-contribution.ts +++ b/packages/core/src/node/i18n/localization-backend-contribution.ts @@ -24,10 +24,10 @@ import { LocalizationProvider } from './localization-provider'; export class LocalizationBackendContribution implements BackendApplicationContribution { @inject(LocalizationRegistry) - protected readonly localizationRegistry: LocalizationRegistry; + protected readonly localizationRegistry!: LocalizationRegistry; @inject(LocalizationProvider) - protected readonly localizationProvider: LocalizationProvider; + protected readonly localizationProvider!: LocalizationProvider; async initialize(): Promise { await this.localizationRegistry.initialize(); diff --git a/packages/core/src/node/i18n/localization-contribution.ts b/packages/core/src/node/i18n/localization-contribution.ts index 6af4632a9f602..b0078855e175d 100644 --- a/packages/core/src/node/i18n/localization-contribution.ts +++ b/packages/core/src/node/i18n/localization-contribution.ts @@ -30,10 +30,10 @@ export interface LocalizationContribution { export class LocalizationRegistry { @inject(LocalizationProvider) - protected readonly localizationProvider: LocalizationProvider; + protected readonly localizationProvider!: LocalizationProvider; @inject(ContributionProvider) @named(LocalizationContribution) - protected readonly contributions: ContributionProvider; + protected readonly contributions!: ContributionProvider; async initialize(): Promise { await Promise.all(this.contributions.getContributions().map( diff --git a/packages/core/src/node/messaging/http-websocket-adapter.ts b/packages/core/src/node/messaging/http-websocket-adapter.ts index 64607e21b416b..b8043f8304077 100644 --- a/packages/core/src/node/messaging/http-websocket-adapter.ts +++ b/packages/core/src/node/messaging/http-websocket-adapter.ts @@ -28,7 +28,7 @@ export const DEFAULT_HTTP_WEBSOCKET_ADAPTER_TIMEOUT = 4000; export class HttpWebsocketAdapter { @inject(HttpWebsocketAdapterTimeout) - protected readonly adapterTimeout: number; + protected readonly adapterTimeout!: number; readyState: number = ws.OPEN; alive: boolean = true; @@ -52,28 +52,22 @@ export class HttpWebsocketAdapter { return this.deferredMessageHandler.promise; } - protected _onerror: (error: Error) => void; - protected _onclose: (code?: number, reason?: string) => void; - protected _onmessage: (data: string) => void; + protected _onerror?: (error: Error) => void; + protected _onclose?: (code?: number, reason?: string) => void; + protected _onmessage?: (data: string) => void; onerror(error: Error): void { - if (this._onerror) { - this._onerror(error); - } + this._onerror?.(error); } onclose(code?: number, reason?: string): void { this.readyState = ws.CLOSING; - if (this._onclose) { - this._onclose(code, reason); - } + this._onclose?.(code, reason); this.readyState = ws.CLOSED; } onmessage(data: string): void { - if (this._onmessage) { - this._onmessage(data); - } + this._onmessage?.(data); } send(data: unknown): void { diff --git a/packages/core/src/node/messaging/ipc-connection-provider.ts b/packages/core/src/node/messaging/ipc-connection-provider.ts index 35e1ead239e44..38d78c4bd9c67 100644 --- a/packages/core/src/node/messaging/ipc-connection-provider.ts +++ b/packages/core/src/node/messaging/ipc-connection-provider.ts @@ -38,7 +38,7 @@ export type IPCConnectionOptions = Partial & { export class IPCConnectionProvider { @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; listen(options: IPCConnectionOptions, acceptor: (connection: MessageConnection) => void): Disposable { return this.doListen({ diff --git a/packages/core/src/node/messaging/messaging-contribution.ts b/packages/core/src/node/messaging/messaging-contribution.ts index 4182244c8f46f..1442ef2cab05e 100644 --- a/packages/core/src/node/messaging/messaging-contribution.ts +++ b/packages/core/src/node/messaging/messaging-contribution.ts @@ -43,24 +43,24 @@ export const MessagingContainer = Symbol('MessagingContainer'); export class MessagingContribution implements BackendApplicationContribution, MessagingService { @inject(MessagingContainer) - protected readonly container: interfaces.Container; + protected readonly container!: interfaces.Container; @inject(ContributionProvider) @named(ConnectionContainerModule) - protected readonly connectionModules: ContributionProvider; + protected readonly connectionModules!: ContributionProvider; @inject(ContributionProvider) @named(MessagingService.Contribution) - protected readonly contributions: ContributionProvider; + protected readonly contributions!: ContributionProvider; @inject(WsRequestValidator) - protected readonly wsRequestValidator: WsRequestValidator; + protected readonly wsRequestValidator!: WsRequestValidator; @inject(MessagingListener) - protected readonly messagingListener: MessagingListener; + protected readonly messagingListener!: MessagingListener; @inject(HttpWebsocketAdapterFactory) - protected readonly httpWebsocketAdapterFactory: () => HttpWebsocketAdapter; + protected readonly httpWebsocketAdapterFactory!: () => HttpWebsocketAdapter; - protected webSocketServer: ws.Server | undefined; + protected webSocketServer?: ws.Server; protected readonly wsHandlers = new MessagingContribution.ConnectionHandlers(); protected readonly channelHandlers = new MessagingContribution.ConnectionHandlers(); protected readonly httpWebsocketAdapters = new Map(); @@ -92,7 +92,7 @@ export class MessagingContribution implements BackendApplicationContribution, Me } ws(spec: string, callback: (params: MessagingService.PathParams, socket: ws) => void): void { - this.wsHandlers.push(spec, callback); + this.wsHandlers.push(spec, (params, connection) => callback(params, connection as ws)); } protected checkAliveTimeout = 30000; @@ -114,22 +114,22 @@ export class MessagingContribution implements BackendApplicationContribution, Me this.handleConnection(socket, request); }); setInterval(() => { - this.webSocketServer!.clients.forEach((socket: CheckAliveWS) => { + for (const socket of this.webSocketServer!.clients as Set) { if (socket.alive === false) { socket.terminate(); return; } socket.alive = false; socket.ping(); - }); - this.httpWebsocketAdapters.forEach((adapter, id) => { + }; + for (const [id, adapter] of this.httpWebsocketAdapters) { if (adapter.alive === false) { this.httpWebsocketAdapters.delete(id); adapter.onclose(); return; } adapter.alive = false; - }); + }; }, this.checkAliveTimeout); } diff --git a/packages/core/src/node/messaging/messaging-listeners.ts b/packages/core/src/node/messaging/messaging-listeners.ts index 4804418b2adda..3c68ed2bd7d1f 100644 --- a/packages/core/src/node/messaging/messaging-listeners.ts +++ b/packages/core/src/node/messaging/messaging-listeners.ts @@ -41,7 +41,7 @@ export interface MessagingListenerContribution { export class MessagingListener { @inject(ContributionProvider) @named(MessagingListenerContribution) - protected readonly messagingListenerContributions: ContributionProvider; + protected readonly messagingListenerContributions!: ContributionProvider; /** * Notify all the subscribed `MessagingListenerContribution`s that the Websocket was upgraded. diff --git a/packages/core/src/node/ws-request-validators.ts b/packages/core/src/node/ws-request-validators.ts index 51fb24f391503..fb33d2faf747e 100644 --- a/packages/core/src/node/ws-request-validators.ts +++ b/packages/core/src/node/ws-request-validators.ts @@ -38,7 +38,7 @@ export interface WsRequestValidatorContribution { export class WsRequestValidator { @inject(ContributionProvider) @named(WsRequestValidatorContribution) - protected readonly requestValidators: ContributionProvider; + protected readonly requestValidators!: ContributionProvider; /** * Ask all bound `WsRequestValidatorContributions` if the WebSocket connection should be allowed or not. diff --git a/packages/debug/src/browser/breakpoint/breakpoint-manager.ts b/packages/debug/src/browser/breakpoint/breakpoint-manager.ts index 6bb22bfabf6f7..5894bf9727a55 100644 --- a/packages/debug/src/browser/breakpoint/breakpoint-manager.ts +++ b/packages/debug/src/browser/breakpoint/breakpoint-manager.ts @@ -41,7 +41,7 @@ export class BreakpointManager extends MarkerManager { protected readonly owner = 'breakpoint'; @inject(StorageService) - protected readonly storage: StorageService; + protected readonly storage!: StorageService; getKind(): string { return BREAKPOINT_KIND; diff --git a/packages/debug/src/browser/console/debug-console-contribution.tsx b/packages/debug/src/browser/console/debug-console-contribution.tsx index b3c01fff87ab5..e4e0ae94e834c 100644 --- a/packages/debug/src/browser/console/debug-console-contribution.tsx +++ b/packages/debug/src/browser/console/debug-console-contribution.tsx @@ -48,13 +48,13 @@ export namespace DebugConsoleCommands { export class DebugConsoleContribution extends AbstractViewContribution implements TabBarToolbarContribution { @inject(ConsoleSessionManager) - protected consoleSessionManager: ConsoleSessionManager; + protected consoleSessionManager!: ConsoleSessionManager; @inject(DebugConsoleSessionFactory) - protected debugConsoleSessionFactory: DebugConsoleSessionFactory; + protected debugConsoleSessionFactory!: DebugConsoleSessionFactory; @inject(DebugSessionManager) - protected debugSessionManager: DebugSessionManager; + protected debugSessionManager!: DebugSessionManager; constructor() { super({ diff --git a/packages/debug/src/browser/console/debug-console-session.ts b/packages/debug/src/browser/console/debug-console-session.ts index bbf93519ffd66..e81e0ccbacda7 100644 --- a/packages/debug/src/browser/console/debug-console-session.ts +++ b/packages/debug/src/browser/console/debug-console-session.ts @@ -35,20 +35,26 @@ export class DebugConsoleSession extends ConsoleSession { protected items: ConsoleItem[] = []; - protected _debugSession: DebugSession; + protected _debugSession?: DebugSession; // content buffer for [append](#append) method protected uncompletedItemContent: string | undefined; protected readonly completionKinds = new Map(); + get id(): string { + return this.debugSession.id; + } + get debugSession(): DebugSession { + if (this._debugSession === undefined) { + throw new Error('DebugConsoleSession._debugSession is not set'); + } return this._debugSession; } set debugSession(value: DebugSession) { this._debugSession = value; - this.id = value.id; } @postConstruct() diff --git a/packages/debug/src/browser/debug-configuration-manager.ts b/packages/debug/src/browser/debug-configuration-manager.ts index 8ef41fb4d4c88..82b9774ef7b3f 100644 --- a/packages/debug/src/browser/debug-configuration-manager.ts +++ b/packages/debug/src/browser/debug-configuration-manager.ts @@ -45,28 +45,31 @@ export interface WillProvideDebugConfiguration extends WaitUntilEvent { export class DebugConfigurationManager { @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @inject(EditorManager) - protected readonly editorManager: EditorManager; + protected readonly editorManager!: EditorManager; @inject(DebugService) - protected readonly debug: DebugService; + protected readonly debug!: DebugService; @inject(QuickPickService) - protected readonly quickPickService: QuickPickService; + protected readonly quickPickService!: QuickPickService; @inject(ContextKeyService) - protected readonly contextKeyService: ContextKeyService; + protected readonly contextKeyService!: ContextKeyService; @inject(MonacoTextModelService) - protected readonly textModelService: MonacoTextModelService; + protected readonly textModelService!: MonacoTextModelService; @inject(PreferenceService) - protected readonly preferences: PreferenceService; + protected readonly preferences!: PreferenceService; @inject(PreferenceConfigurations) - protected readonly preferenceConfigurations: PreferenceConfigurations; + protected readonly preferenceConfigurations!: PreferenceConfigurations; @inject(WorkspaceVariableContribution) - protected readonly workspaceVariables: WorkspaceVariableContribution; + protected readonly workspaceVariables!: WorkspaceVariableContribution; + + @inject(StorageService) + protected readonly storage!: StorageService; protected readonly onDidChangeEmitter = new Emitter(); readonly onDidChange: Event = this.onDidChangeEmitter.event; @@ -79,9 +82,9 @@ export class DebugConfigurationManager { return this.onWillProvideDynamicDebugConfigurationEmitter.event; } - protected debugConfigurationTypeKey: ContextKey; + protected debugConfigurationTypeKey!: ContextKey; - protected initialized: Promise; + protected initialized!: Promise; @postConstruct() protected async init(): Promise { @@ -346,9 +349,6 @@ export class DebugConfigurationManager { return selectedItem?.value; } - @inject(StorageService) - protected readonly storage: StorageService; - async load(): Promise { await this.initialized; const data = await this.storage.getData('debug.configurations', {}); diff --git a/packages/debug/src/browser/debug-configuration-model.ts b/packages/debug/src/browser/debug-configuration-model.ts index 1e7a2bba0cb82..ec54d1e21bd3e 100644 --- a/packages/debug/src/browser/debug-configuration-model.ts +++ b/packages/debug/src/browser/debug-configuration-model.ts @@ -22,7 +22,7 @@ import { PreferenceService } from '@theia/core/lib/browser/preferences/preferenc export class DebugConfigurationModel implements Disposable { - protected json: DebugConfigurationModel.JsonContent; + protected json!: DebugConfigurationModel.JsonContent; protected readonly onDidChangeEmitter = new Emitter(); readonly onDidChange: Event = this.onDidChangeEmitter.event; diff --git a/packages/debug/src/browser/debug-frontend-application-contribution.ts b/packages/debug/src/browser/debug-frontend-application-contribution.ts index d9b7757c8bb5e..b6e5a4f416e12 100644 --- a/packages/debug/src/browser/debug-frontend-application-contribution.ts +++ b/packages/debug/src/browser/debug-frontend-application-contribution.ts @@ -411,43 +411,43 @@ ThemeService.get().onDidColorThemeChange(() => updateTheme()); export class DebugFrontendApplicationContribution extends AbstractViewContribution implements TabBarToolbarContribution, ColorContribution { @inject(DebugService) - protected readonly debug: DebugService; + protected readonly debug!: DebugService; @inject(DebugSessionManager) - protected readonly manager: DebugSessionManager; + protected readonly manager!: DebugSessionManager; @inject(DebugConfigurationManager) - protected readonly configurations: DebugConfigurationManager; + protected readonly configurations!: DebugConfigurationManager; @inject(BreakpointManager) - protected readonly breakpointManager: BreakpointManager; + protected readonly breakpointManager!: BreakpointManager; @inject(ApplicationShell) - protected readonly shell: ApplicationShell; + protected readonly shell!: ApplicationShell; @inject(DebugSessionWidgetFactory) - protected readonly sessionWidgetFactory: DebugSessionWidgetFactory; + protected readonly sessionWidgetFactory!: DebugSessionWidgetFactory; @inject(DebugEditorService) - protected readonly editors: DebugEditorService; + protected readonly editors!: DebugEditorService; @inject(DebugConsoleContribution) - protected readonly console: DebugConsoleContribution; + protected readonly console!: DebugConsoleContribution; @inject(DebugSchemaUpdater) - protected readonly schemaUpdater: DebugSchemaUpdater; + protected readonly schemaUpdater!: DebugSchemaUpdater; @inject(DebugPreferences) - protected readonly preference: DebugPreferences; + protected readonly preference!: DebugPreferences; @inject(DebugWatchManager) - protected readonly watchManager: DebugWatchManager; + protected readonly watchManager!: DebugWatchManager; @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(EditorManager) - protected readonly editorManager: EditorManager; + protected readonly editorManager!: EditorManager; constructor() { super({ diff --git a/packages/debug/src/browser/debug-keybinding-contexts.ts b/packages/debug/src/browser/debug-keybinding-contexts.ts index df20615cb1f56..e907e6bf60ad9 100644 --- a/packages/debug/src/browser/debug-keybinding-contexts.ts +++ b/packages/debug/src/browser/debug-keybinding-contexts.ts @@ -36,7 +36,7 @@ export class InDebugModeContext implements KeybindingContext { readonly id: string = DebugKeybindingContexts.inDebugMode; @inject(DebugSessionManager) - protected readonly manager: DebugSessionManager; + protected readonly manager!: DebugSessionManager; isEnabled(): boolean { return this.manager.inDebugMode; @@ -50,7 +50,7 @@ export class BreakpointWidgetInputFocusContext implements KeybindingContext { readonly id: string = DebugKeybindingContexts.breakpointWidgetInputFocus; @inject(DebugEditorService) - protected readonly editors: DebugEditorService; + protected readonly editors!: DebugEditorService; isEnabled(): boolean { const model = this.editors.model; diff --git a/packages/debug/src/browser/debug-prefix-configuration.ts b/packages/debug/src/browser/debug-prefix-configuration.ts index 52d95ca8c4dcf..0d6376a995bc6 100644 --- a/packages/debug/src/browser/debug-prefix-configuration.ts +++ b/packages/debug/src/browser/debug-prefix-configuration.ts @@ -33,31 +33,31 @@ export class DebugPrefixConfiguration implements CommandContribution, CommandHan static readonly PREFIX = 'debug '; @inject(CommandRegistry) - protected readonly commandRegistry: CommandRegistry; + protected readonly commandRegistry!: CommandRegistry; @inject(DebugSessionManager) - protected readonly debugSessionManager: DebugSessionManager; + protected readonly debugSessionManager!: DebugSessionManager; @inject(DebugPreferences) - protected readonly preference: DebugPreferences; + protected readonly preference!: DebugPreferences; @inject(DebugConfigurationManager) - protected readonly debugConfigurationManager: DebugConfigurationManager; + protected readonly debugConfigurationManager!: DebugConfigurationManager; @inject(QuickInputService) @optional() - protected readonly quickInputService: QuickInputService; + protected readonly quickInputService?: QuickInputService; @inject(QuickAccessRegistry) - protected readonly quickAccessRegistry: QuickAccessRegistry; + protected readonly quickAccessRegistry!: QuickAccessRegistry; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(StatusBar) - protected readonly statusBar: StatusBar; + protected readonly statusBar!: StatusBar; readonly statusBarId = 'select-run-debug-statusbar-item'; diff --git a/packages/debug/src/browser/debug-resource.ts b/packages/debug/src/browser/debug-resource.ts index f91d6df27ca11..e66c09cf38fef 100644 --- a/packages/debug/src/browser/debug-resource.ts +++ b/packages/debug/src/browser/debug-resource.ts @@ -47,7 +47,7 @@ export class DebugResource implements Resource { export class DebugResourceResolver implements ResourceResolver { @inject(DebugSessionManager) - protected readonly manager: DebugSessionManager; + protected readonly manager!: DebugSessionManager; resolve(uri: URI): DebugResource { if (uri.scheme !== DebugSource.SCHEME) { diff --git a/packages/debug/src/browser/debug-schema-updater.ts b/packages/debug/src/browser/debug-schema-updater.ts index 9d680f0e43e35..af434c7fa3093 100644 --- a/packages/debug/src/browser/debug-schema-updater.ts +++ b/packages/debug/src/browser/debug-schema-updater.ts @@ -29,9 +29,9 @@ export class DebugSchemaUpdater implements JsonSchemaContribution { protected readonly uri = new URI(launchSchemaId); - @inject(InMemoryResources) protected readonly inmemoryResources: InMemoryResources; - @inject(WorkspaceService) protected readonly workspaceService: WorkspaceService; - @inject(DebugService) protected readonly debug: DebugService; + @inject(InMemoryResources) protected readonly inmemoryResources!: InMemoryResources; + @inject(WorkspaceService) protected readonly workspaceService!: WorkspaceService; + @inject(DebugService) protected readonly debug!: DebugService; @postConstruct() protected init(): void { diff --git a/packages/debug/src/browser/debug-session-connection.ts b/packages/debug/src/browser/debug-session-connection.ts index fd8a109436208..c4103cd6f274d 100644 --- a/packages/debug/src/browser/debug-session-connection.ts +++ b/packages/debug/src/browser/debug-session-connection.ts @@ -115,6 +115,10 @@ export class DebugSessionConnection implements Disposable { private sequence = 1; + protected allThreadsContinued = true; + + protected readonly emitters = new Map>(); + protected readonly pendingRequests = new Map void>(); protected readonly connection: Promise; @@ -164,7 +168,6 @@ export class DebugSessionConnection implements Disposable { } } - protected allThreadsContinued = true; async sendRequest(command: K, args: DebugRequestTypes[K][0]): Promise { const result = await this.doSendRequest(command, args); if (command === 'next' || command === 'stepIn' || @@ -209,12 +212,12 @@ export class DebugSessionConnection implements Disposable { }); } })); - this.pendingRequests.set(request.seq, (response: K) => { + this.pendingRequests.set(request.seq, response => { onDispose.dispose(); if (!response.success) { result.reject(response); } else { - result.resolve(response); + result.resolve(response as K); } }); @@ -284,7 +287,7 @@ export class DebugSessionConnection implements Disposable { if (event.event === 'continued') { this.allThreadsContinued = (event).body.allThreadsContinued === false ? false : true; } - if (standardDebugEvents.has(event.event)) { + if (this.isDebugEvent(event.event)) { this.doFire(event.event, event); } else { this.onDidCustomEventEmitter.fire(event); @@ -294,22 +297,25 @@ export class DebugSessionConnection implements Disposable { } } - protected readonly emitters = new Map>(); - on(kind: K, listener: (e: DebugEventTypes[K]) => any): Disposable { + on(kind: K, listener: (e: DebugEventTypes[K]) => void): Disposable { return this.getEmitter(kind).event(listener); } + protected fire(kind: K, e: DebugEventTypes[K]): void { this.doFire(kind, e); } - protected doFire(kind: string, e: DebugProtocol.Event | DebugExitEvent): void { + + protected doFire(kind: K, e: DebugEventTypes[K]): void { this.getEmitter(kind).fire(e); } - protected getEmitter(kind: string): Emitter { - const emitter = this.emitters.get(kind) || this.newEmitter(); + + protected getEmitter(kind: K): Emitter { + const emitter = this.emitters.get(kind) || this.newEmitter(); this.emitters.set(kind, emitter); return emitter; } - protected newEmitter(): Emitter { + + protected newEmitter(): Emitter { const emitter = new Emitter(); this.checkDisposed(); this.toDispose.push(emitter); @@ -328,4 +334,7 @@ export class DebugSessionConnection implements Disposable { }); } + protected isDebugEvent(event: string): event is keyof DebugEventTypes { + return standardDebugEvents.has(event); + } } diff --git a/packages/debug/src/browser/debug-session-contribution.ts b/packages/debug/src/browser/debug-session-contribution.ts index 87685405dcbbb..b3c4a308042bf 100644 --- a/packages/debug/src/browser/debug-session-contribution.ts +++ b/packages/debug/src/browser/debug-session-contribution.ts @@ -67,7 +67,7 @@ export class DebugSessionContributionRegistryImpl implements DebugSessionContrib protected readonly contribs = new Map(); @inject(ContributionProvider) @named(DebugSessionContribution) - protected readonly contributions: ContributionProvider; + protected readonly contributions!: ContributionProvider; @postConstruct() protected init(): void { @@ -96,25 +96,25 @@ export interface DebugSessionFactory { @injectable() export class DefaultDebugSessionFactory implements DebugSessionFactory { @inject(WebSocketConnectionProvider) - protected readonly connectionProvider: WebSocketConnectionProvider; + protected readonly connectionProvider!: WebSocketConnectionProvider; @inject(TerminalService) - protected readonly terminalService: TerminalService; + protected readonly terminalService!: TerminalService; @inject(EditorManager) - protected readonly editorManager: EditorManager; + protected readonly editorManager!: EditorManager; @inject(BreakpointManager) - protected readonly breakpoints: BreakpointManager; + protected readonly breakpoints!: BreakpointManager; @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(MessageClient) - protected readonly messages: MessageClient; + protected readonly messages!: MessageClient; @inject(OutputChannelManager) - protected readonly outputChannelManager: OutputChannelManager; + protected readonly outputChannelManager!: OutputChannelManager; @inject(DebugPreferences) - protected readonly debugPreferences: DebugPreferences; + protected readonly debugPreferences!: DebugPreferences; @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; @inject(ContributionProvider) @named(DebugContribution) - protected readonly debugContributionProvider: ContributionProvider; + protected readonly debugContributionProvider!: ContributionProvider; get(sessionId: string, options: DebugSessionOptions, parentSession?: DebugSession): DebugSession { const connection = new DebugSessionConnection( diff --git a/packages/debug/src/browser/debug-session-manager.ts b/packages/debug/src/browser/debug-session-manager.ts index cef3a59a4b22e..8e32c1ab726c8 100644 --- a/packages/debug/src/browser/debug-session-manager.ts +++ b/packages/debug/src/browser/debug-session-manager.ts @@ -103,49 +103,49 @@ export class DebugSessionManager { } @inject(DebugSessionFactory) - protected readonly debugSessionFactory: DebugSessionFactory; + protected readonly debugSessionFactory!: DebugSessionFactory; @inject(DebugService) - protected readonly debug: DebugService; + protected readonly debug!: DebugService; @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(EditorManager) - protected readonly editorManager: EditorManager; + protected readonly editorManager!: EditorManager; @inject(BreakpointManager) - protected readonly breakpoints: BreakpointManager; + protected readonly breakpoints!: BreakpointManager; @inject(VariableResolverService) - protected readonly variableResolver: VariableResolverService; + protected readonly variableResolver!: VariableResolverService; @inject(DebugSessionContributionRegistry) - protected readonly sessionContributionRegistry: DebugSessionContributionRegistry; + protected readonly sessionContributionRegistry!: DebugSessionContributionRegistry; @inject(MessageService) - protected readonly messageService: MessageService; + protected readonly messageService!: MessageService; @inject(ProgressService) - protected readonly progressService: ProgressService; + protected readonly progressService!: ProgressService; @inject(ContextKeyService) - protected readonly contextKeyService: ContextKeyService; + protected readonly contextKeyService!: ContextKeyService; @inject(TaskService) - protected readonly taskService: TaskService; + protected readonly taskService!: TaskService; @inject(DebugConfigurationManager) - protected readonly debugConfigurationManager: DebugConfigurationManager; + protected readonly debugConfigurationManager!: DebugConfigurationManager; @inject(QuickOpenTask) - protected readonly quickOpenTask: QuickOpenTask; + protected readonly quickOpenTask!: QuickOpenTask; @inject(ApplicationShell) - protected readonly shell: ApplicationShell; + protected readonly shell!: ApplicationShell; - protected debugTypeKey: ContextKey; - protected inDebugModeKey: ContextKey; + protected debugTypeKey!: ContextKey; + protected inDebugModeKey!: ContextKey; @postConstruct() protected init(): void { diff --git a/packages/debug/src/browser/debug-session.tsx b/packages/debug/src/browser/debug-session.tsx index ed5a580554e94..a7ef8708b4cbd 100644 --- a/packages/debug/src/browser/debug-session.tsx +++ b/packages/debug/src/browser/debug-session.tsx @@ -79,7 +79,7 @@ export class DebugSession implements CompositeTreeElement { protected readonly fileService: FileService, protected readonly debugContributionProvider: ContributionProvider ) { - this.connection.onRequest('runInTerminal', (request: DebugProtocol.RunInTerminalRequest) => this.runInTerminal(request)); + this.connection.onRequest('runInTerminal', request => this.runInTerminal(request as DebugProtocol.RunInTerminalRequest)); this.registerDebugContributions(options.configuration.type, this.connection); if (parentSession) { diff --git a/packages/debug/src/browser/debug-tab-bar-decorator.ts b/packages/debug/src/browser/debug-tab-bar-decorator.ts index 9dfa94bec388d..9659ffb36db0a 100644 --- a/packages/debug/src/browser/debug-tab-bar-decorator.ts +++ b/packages/debug/src/browser/debug-tab-bar-decorator.ts @@ -31,7 +31,7 @@ export class DebugTabBarDecorator implements TabBarDecorator { protected toDispose = new DisposableCollection(); @inject(DebugSessionManager) - protected readonly debugSessionManager: DebugSessionManager; + protected readonly debugSessionManager!: DebugSessionManager; @postConstruct() protected init(): void { diff --git a/packages/debug/src/browser/debug-watch-manager.ts b/packages/debug/src/browser/debug-watch-manager.ts index 9d054e37024d2..bb94bf5bbb482 100644 --- a/packages/debug/src/browser/debug-watch-manager.ts +++ b/packages/debug/src/browser/debug-watch-manager.ts @@ -22,7 +22,7 @@ import { StorageService } from '@theia/core/lib/browser/storage-service'; export class DebugWatchManager { @inject(StorageService) - protected readonly storage: StorageService; + protected readonly storage!: StorageService; protected readonly onDidChangeEmitter = new Emitter(); readonly onDidChange = this.onDidChangeEmitter.event; diff --git a/packages/debug/src/browser/editor/debug-breakpoint-widget.tsx b/packages/debug/src/browser/editor/debug-breakpoint-widget.tsx index 9b3c2968319a8..23cf968fe35b2 100644 --- a/packages/debug/src/browser/editor/debug-breakpoint-widget.tsx +++ b/packages/debug/src/browser/editor/debug-breakpoint-widget.tsx @@ -39,14 +39,14 @@ export type ShowDebugBreakpointOptions = DebugSourceBreakpoint | { export class DebugBreakpointWidget implements Disposable { @inject(DebugEditor) - readonly editor: DebugEditor; + readonly editor!: DebugEditor; @inject(MonacoEditorProvider) - protected readonly editorProvider: MonacoEditorProvider; + protected readonly editorProvider!: MonacoEditorProvider; - protected selectNode: HTMLDivElement; + protected selectNode!: HTMLDivElement; - protected zone: MonacoEditorZoneWidget; + protected zone!: MonacoEditorZoneWidget; protected readonly toDispose = new DisposableCollection(); diff --git a/packages/debug/src/browser/editor/debug-editor-model.ts b/packages/debug/src/browser/editor/debug-editor-model.ts index 032d6f0f51534..79e136bcf6e18 100644 --- a/packages/debug/src/browser/editor/debug-editor-model.ts +++ b/packages/debug/src/browser/editor/debug-editor-model.ts @@ -53,7 +53,7 @@ export class DebugEditorModel implements Disposable { protected readonly toDispose = new DisposableCollection(); protected readonly toDisposeOnUpdate = new DisposableCollection(); - protected uri: URI; + protected uri!: URI; protected breakpointDecorations: string[] = []; protected breakpointRanges = new Map(); @@ -66,31 +66,31 @@ export class DebugEditorModel implements Disposable { protected updatingDecorations = false; @inject(DebugHoverWidget) - readonly hover: DebugHoverWidget; + readonly hover!: DebugHoverWidget; @inject(DebugEditor) - readonly editor: DebugEditor; + readonly editor!: DebugEditor; @inject(BreakpointManager) - readonly breakpoints: BreakpointManager; + readonly breakpoints!: BreakpointManager; @inject(DebugSessionManager) - readonly sessions: DebugSessionManager; + readonly sessions!: DebugSessionManager; @inject(ContextMenuRenderer) - readonly contextMenu: ContextMenuRenderer; + readonly contextMenu!: ContextMenuRenderer; @inject(DebugBreakpointWidget) - readonly breakpointWidget: DebugBreakpointWidget; + readonly breakpointWidget!: DebugBreakpointWidget; @inject(DebugExceptionWidget) - readonly exceptionWidget: DebugExceptionWidget; + readonly exceptionWidget!: DebugExceptionWidget; @inject(DebugInlineValueDecorator) - readonly inlineValueDecorator: DebugInlineValueDecorator; + readonly inlineValueDecorator!: DebugInlineValueDecorator; @inject(MonacoConfigurationService) - readonly configurationService: monaco.services.IConfigurationService; + readonly configurationService!: monaco.services.IConfigurationService; @postConstruct() protected init(): void { diff --git a/packages/debug/src/browser/editor/debug-editor-service.ts b/packages/debug/src/browser/editor/debug-editor-service.ts index 9d69e5f5a936d..52d9e8879d4b9 100644 --- a/packages/debug/src/browser/editor/debug-editor-service.ts +++ b/packages/debug/src/browser/editor/debug-editor-service.ts @@ -29,19 +29,19 @@ import { DebugBreakpointWidget } from './debug-breakpoint-widget'; export class DebugEditorService { @inject(EditorManager) - protected readonly editors: EditorManager; + protected readonly editors!: EditorManager; @inject(BreakpointManager) - protected readonly breakpoints: BreakpointManager; + protected readonly breakpoints!: BreakpointManager; @inject(DebugSessionManager) - protected readonly sessionManager: DebugSessionManager; + protected readonly sessionManager!: DebugSessionManager; @inject(ContextMenuRenderer) - protected readonly contextMenu: ContextMenuRenderer; + protected readonly contextMenu!: ContextMenuRenderer; @inject(DebugEditorModelFactory) - protected readonly factory: DebugEditorModelFactory; + protected readonly factory!: DebugEditorModelFactory; protected readonly models = new Map(); diff --git a/packages/debug/src/browser/editor/debug-exception-widget.tsx b/packages/debug/src/browser/editor/debug-exception-widget.tsx index 830f52be3c483..3e2086269ba46 100644 --- a/packages/debug/src/browser/editor/debug-exception-widget.tsx +++ b/packages/debug/src/browser/editor/debug-exception-widget.tsx @@ -48,9 +48,9 @@ export class DebugExceptionMonacoEditorZoneWidget extends MonacoEditorZoneWidget export class DebugExceptionWidget implements Disposable { @inject(DebugEditor) - readonly editor: DebugEditor; + readonly editor!: DebugEditor; - protected zone: MonacoEditorZoneWidget; + protected zone!: MonacoEditorZoneWidget; protected readonly toDispose = new DisposableCollection(); diff --git a/packages/debug/src/browser/editor/debug-hover-source.tsx b/packages/debug/src/browser/editor/debug-hover-source.tsx index e13acc6821ec9..760be6c6bd3c8 100644 --- a/packages/debug/src/browser/editor/debug-hover-source.tsx +++ b/packages/debug/src/browser/editor/debug-hover-source.tsx @@ -24,7 +24,7 @@ import { injectable, inject } from '@theia/core/shared/inversify'; export class DebugHoverSource extends TreeSource { @inject(DebugSessionManager) - protected readonly sessions: DebugSessionManager; + protected readonly sessions!: DebugSessionManager; protected _expression: ExpressionItem | DebugVariable | undefined; get expression(): ExpressionItem | DebugVariable | undefined { diff --git a/packages/debug/src/browser/editor/debug-hover-widget.ts b/packages/debug/src/browser/editor/debug-hover-widget.ts index ff651139835a8..cf851b5ce3462 100644 --- a/packages/debug/src/browser/editor/debug-hover-widget.ts +++ b/packages/debug/src/browser/editor/debug-hover-widget.ts @@ -59,16 +59,16 @@ export class DebugHoverWidget extends SourceTreeWidget implements monaco.editor. protected readonly toDispose = new DisposableCollection(); @inject(DebugEditor) - protected readonly editor: DebugEditor; + protected readonly editor!: DebugEditor; @inject(DebugSessionManager) - protected readonly sessions: DebugSessionManager; + protected readonly sessions!: DebugSessionManager; @inject(DebugHoverSource) - protected readonly hoverSource: DebugHoverSource; + protected readonly hoverSource!: DebugHoverSource; @inject(DebugExpressionProvider) - protected readonly expressionProvider: DebugExpressionProvider; + protected readonly expressionProvider!: DebugExpressionProvider; allowEditorOverflow = true; diff --git a/packages/debug/src/browser/editor/debug-inline-value-decorator.ts b/packages/debug/src/browser/editor/debug-inline-value-decorator.ts index 0ee08b0bd4c4e..c95b5559d3ab8 100644 --- a/packages/debug/src/browser/editor/debug-inline-value-decorator.ts +++ b/packages/debug/src/browser/editor/debug-inline-value-decorator.ts @@ -56,10 +56,10 @@ const enum StandardTokenType { export class DebugInlineValueDecorator implements FrontendApplicationContribution { @inject(MonacoEditorService) - protected readonly editorService: MonacoEditorService; + protected readonly editorService!: MonacoEditorService; @inject(DebugPreferences) - protected readonly preferences: DebugPreferences; + protected readonly preferences!: DebugPreferences; protected enabled = false; protected wordToLineNumbersMap: Map | undefined = new Map(); // TODO: can we get rid of this field? diff --git a/packages/debug/src/browser/model/debug-breakpoint.tsx b/packages/debug/src/browser/model/debug-breakpoint.tsx index b4be6f5dab1db..03da3c4e39476 100644 --- a/packages/debug/src/browser/model/debug-breakpoint.tsx +++ b/packages/debug/src/browser/model/debug-breakpoint.tsx @@ -29,15 +29,15 @@ export class DebugBreakpointData { } export class DebugBreakpointOptions { - readonly labelProvider: LabelProvider; - readonly breakpoints: BreakpointManager; - readonly editorManager: EditorManager; + readonly labelProvider!: LabelProvider; + readonly breakpoints!: BreakpointManager; + readonly editorManager!: EditorManager; readonly session?: DebugSession; } export class DebugBreakpointDecoration { - readonly className: string; - readonly message: string[]; + readonly className!: string; + readonly message!: string[]; } export abstract class DebugBreakpoint extends DebugBreakpointOptions implements TreeElement { diff --git a/packages/debug/src/browser/model/debug-source-breakpoint.tsx b/packages/debug/src/browser/model/debug-source-breakpoint.tsx index d4d90e55ba836..07ce14235dc8b 100644 --- a/packages/debug/src/browser/model/debug-source-breakpoint.tsx +++ b/packages/debug/src/browser/model/debug-source-breakpoint.tsx @@ -26,7 +26,7 @@ import { DebugSource } from './debug-source'; import { DebugBreakpoint, DebugBreakpointOptions, DebugBreakpointData, DebugBreakpointDecoration } from './debug-breakpoint'; export class DebugSourceBreakpointData extends DebugBreakpointData { - readonly origins: SourceBreakpoint[]; + readonly origins: SourceBreakpoint[] = []; } export class DebugSourceBreakpoint extends DebugBreakpoint implements TreeElement { diff --git a/packages/debug/src/browser/model/debug-source.ts b/packages/debug/src/browser/model/debug-source.ts index 9d8a8286757c1..b5b441b614c4f 100644 --- a/packages/debug/src/browser/model/debug-source.ts +++ b/packages/debug/src/browser/model/debug-source.ts @@ -21,8 +21,8 @@ import { DebugProtocol } from 'vscode-debugprotocol/lib/debugProtocol'; import { DebugSession } from '../debug-session'; import { URI as Uri } from '@theia/core/shared/vscode-uri'; -export class DebugSourceData { - readonly raw: DebugProtocol.Source; +export abstract class DebugSourceData { + readonly raw: DebugProtocol.Source = {}; } export class DebugSource extends DebugSourceData { diff --git a/packages/debug/src/browser/model/debug-stack-frame.tsx b/packages/debug/src/browser/model/debug-stack-frame.tsx index 594a8945b3607..2dc806e89955a 100644 --- a/packages/debug/src/browser/model/debug-stack-frame.tsx +++ b/packages/debug/src/browser/model/debug-stack-frame.tsx @@ -31,12 +31,14 @@ import { RecursivePartial } from '@theia/core'; import { DebugSession } from '../debug-session'; import { DebugThread } from './debug-thread'; -export class DebugStackFrameData { - readonly raw: DebugProtocol.StackFrame; +export abstract class DebugStackFrameData { + abstract readonly raw: DebugProtocol.StackFrame; } export class DebugStackFrame extends DebugStackFrameData implements TreeElement { + protected _raw?: DebugProtocol.StackFrame; + constructor( readonly thread: DebugThread, readonly session: DebugSession @@ -44,6 +46,17 @@ export class DebugStackFrame extends DebugStackFrameData implements TreeElement super(); } + get raw(): DebugProtocol.StackFrame { + if (this._raw === undefined) { + throw new Error('DebugStackFrame._raw is not set'); + } + return this._raw; + } + + set raw(value) { + this._raw = value; + } + get id(): string { return this.session.id + ':' + this.thread.id + ':' + this.raw.id; } diff --git a/packages/debug/src/browser/model/debug-thread.tsx b/packages/debug/src/browser/model/debug-thread.tsx index fe8d8eebad704..b87c80c27b92e 100644 --- a/packages/debug/src/browser/model/debug-thread.tsx +++ b/packages/debug/src/browser/model/debug-thread.tsx @@ -26,9 +26,9 @@ export type StoppedDetails = DebugProtocol.StoppedEvent['body'] & { totalFrames?: number }; -export class DebugThreadData { - readonly raw: DebugProtocol.Thread; - readonly stoppedDetails: StoppedDetails | undefined; +export abstract class DebugThreadData { + abstract readonly raw: DebugProtocol.Thread; + readonly stoppedDetails?: StoppedDetails; } export interface DebugExceptionInfo { @@ -39,6 +39,8 @@ export interface DebugExceptionInfo { export class DebugThread extends DebugThreadData implements TreeElement { + protected _raw?: DebugProtocol.Thread; + protected readonly onDidChangedEmitter = new Emitter(); readonly onDidChanged: Event = this.onDidChangedEmitter.event; @@ -48,6 +50,13 @@ export class DebugThread extends DebugThreadData implements TreeElement { super(); } + get raw(): DebugProtocol.Thread { + if (this._raw === undefined) { + throw new Error('DebugThread._raw is not set'); + } + return this._raw; + } + get id(): string { return this.session.id + ':' + this.raw.id; } diff --git a/packages/debug/src/browser/view/debug-breakpoints-source.tsx b/packages/debug/src/browser/view/debug-breakpoints-source.tsx index 3c13be47aad10..0bcfaf91fbb26 100644 --- a/packages/debug/src/browser/view/debug-breakpoints-source.tsx +++ b/packages/debug/src/browser/view/debug-breakpoints-source.tsx @@ -24,10 +24,10 @@ import { DebugExceptionBreakpoint } from './debug-exception-breakpoint'; export class DebugBreakpointsSource extends TreeSource { @inject(DebugViewModel) - protected readonly model: DebugViewModel; + protected readonly model!: DebugViewModel; @inject(BreakpointManager) - protected readonly breakpoints: BreakpointManager; + protected readonly breakpoints!: BreakpointManager; @postConstruct() protected init(): void { diff --git a/packages/debug/src/browser/view/debug-breakpoints-widget.ts b/packages/debug/src/browser/view/debug-breakpoints-widget.ts index 8e4789b712f4a..e1bdd7d0563a5 100644 --- a/packages/debug/src/browser/view/debug-breakpoints-widget.ts +++ b/packages/debug/src/browser/view/debug-breakpoints-widget.ts @@ -46,13 +46,13 @@ export class DebugBreakpointsWidget extends SourceTreeWidget { } @inject(DebugViewModel) - protected readonly viewModel: DebugViewModel; + protected readonly viewModel!: DebugViewModel; @inject(BreakpointManager) - protected readonly breakpoints: BreakpointManager; + protected readonly breakpoints!: BreakpointManager; @inject(DebugBreakpointsSource) - protected readonly breakpointsSource: DebugBreakpointsSource; + protected readonly breakpointsSource!: DebugBreakpointsSource; @postConstruct() protected init(): void { diff --git a/packages/debug/src/browser/view/debug-configuration-widget.tsx b/packages/debug/src/browser/view/debug-configuration-widget.tsx index 689b44a546c5f..0f50abe817fc7 100644 --- a/packages/debug/src/browser/view/debug-configuration-widget.tsx +++ b/packages/debug/src/browser/view/debug-configuration-widget.tsx @@ -33,22 +33,22 @@ import { nls } from '@theia/core/lib/common/nls'; export class DebugConfigurationWidget extends ReactWidget { @inject(CommandRegistry) - protected readonly commandRegistry: CommandRegistry; + protected readonly commandRegistry!: CommandRegistry; @inject(DebugViewModel) - protected readonly viewModel: DebugViewModel; + protected readonly viewModel!: DebugViewModel; @inject(DebugConfigurationManager) - protected readonly manager: DebugConfigurationManager; + protected readonly manager!: DebugConfigurationManager; @inject(DebugSessionManager) - protected readonly sessionManager: DebugSessionManager; + protected readonly sessionManager!: DebugSessionManager; @inject(DebugConsoleContribution) - protected readonly debugConsole: DebugConsoleContribution; + protected readonly debugConsole!: DebugConsoleContribution; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @postConstruct() protected init(): void { diff --git a/packages/debug/src/browser/view/debug-session-widget.ts b/packages/debug/src/browser/view/debug-session-widget.ts index 8fc55607e8fe6..9ef88877ecc1a 100644 --- a/packages/debug/src/browser/view/debug-session-widget.ts +++ b/packages/debug/src/browser/view/debug-session-widget.ts @@ -55,31 +55,31 @@ export class DebugSessionWidget extends BaseWidget implements StatefulWidget, Ap return DebugSessionWidget.createContainer(parent, options).get(DebugSessionWidget); } - protected viewContainer: ViewContainer; + protected viewContainer!: ViewContainer; @inject(ViewContainer.Factory) - protected readonly viewContainerFactory: ViewContainer.Factory; + protected readonly viewContainerFactory!: ViewContainer.Factory; @inject(DebugViewModel) - readonly model: DebugViewModel; + readonly model!: DebugViewModel; @inject(DebugToolBar) - protected readonly toolbar: DebugToolBar; + protected readonly toolbar!: DebugToolBar; @inject(DebugThreadsWidget) - protected readonly threads: DebugThreadsWidget; + protected readonly threads!: DebugThreadsWidget; @inject(DebugStackFramesWidget) - protected readonly stackFrames: DebugStackFramesWidget; + protected readonly stackFrames!: DebugStackFramesWidget; @inject(DebugVariablesWidget) - protected readonly variables: DebugVariablesWidget; + protected readonly variables!: DebugVariablesWidget; @inject(DebugWatchWidget) - protected readonly watch: DebugWatchWidget; + protected readonly watch!: DebugWatchWidget; @inject(DebugBreakpointsWidget) - protected readonly breakpoints: DebugBreakpointsWidget; + protected readonly breakpoints!: DebugBreakpointsWidget; @postConstruct() protected init(): void { diff --git a/packages/debug/src/browser/view/debug-stack-frames-source.tsx b/packages/debug/src/browser/view/debug-stack-frames-source.tsx index 08144a316058e..d6b8c077af849 100644 --- a/packages/debug/src/browser/view/debug-stack-frames-source.tsx +++ b/packages/debug/src/browser/view/debug-stack-frames-source.tsx @@ -25,7 +25,7 @@ import debounce = require('p-debounce'); export class DebugStackFramesSource extends TreeSource { @inject(DebugViewModel) - protected readonly model: DebugViewModel; + protected readonly model!: DebugViewModel; @postConstruct() protected init(): void { diff --git a/packages/debug/src/browser/view/debug-stack-frames-widget.ts b/packages/debug/src/browser/view/debug-stack-frames-widget.ts index e8b79dd532eb8..11c999dd85b30 100644 --- a/packages/debug/src/browser/view/debug-stack-frames-widget.ts +++ b/packages/debug/src/browser/view/debug-stack-frames-widget.ts @@ -44,13 +44,13 @@ export class DebugStackFramesWidget extends SourceTreeWidget { } @inject(DebugStackFramesSource) - protected readonly frames: DebugStackFramesSource; + protected readonly frames!: DebugStackFramesSource; @inject(DebugViewModel) - protected readonly viewModel: DebugViewModel; + protected readonly viewModel!: DebugViewModel; @inject(DebugCallStackItemTypeKey) - protected readonly debugCallStackItemTypeKey: DebugCallStackItemTypeKey; + protected readonly debugCallStackItemTypeKey!: DebugCallStackItemTypeKey; @postConstruct() protected init(): void { diff --git a/packages/debug/src/browser/view/debug-threads-source.tsx b/packages/debug/src/browser/view/debug-threads-source.tsx index a2c0737018670..4b3b2fb3e2e93 100644 --- a/packages/debug/src/browser/view/debug-threads-source.tsx +++ b/packages/debug/src/browser/view/debug-threads-source.tsx @@ -22,7 +22,7 @@ import { DebugViewModel } from './debug-view-model'; export class DebugThreadsSource extends TreeSource { @inject(DebugViewModel) - protected readonly model: DebugViewModel; + protected readonly model!: DebugViewModel; @postConstruct() protected init(): void { diff --git a/packages/debug/src/browser/view/debug-threads-widget.ts b/packages/debug/src/browser/view/debug-threads-widget.ts index a2c77930e1d6b..775f5280f923d 100644 --- a/packages/debug/src/browser/view/debug-threads-widget.ts +++ b/packages/debug/src/browser/view/debug-threads-widget.ts @@ -48,13 +48,13 @@ export class DebugThreadsWidget extends SourceTreeWidget { } @inject(DebugThreadsSource) - protected readonly threads: DebugThreadsSource; + protected readonly threads!: DebugThreadsSource; @inject(DebugViewModel) - protected readonly viewModel: DebugViewModel; + protected readonly viewModel!: DebugViewModel; @inject(DebugCallStackItemTypeKey) - protected readonly debugCallStackItemTypeKey: DebugCallStackItemTypeKey; + protected readonly debugCallStackItemTypeKey!: DebugCallStackItemTypeKey; @postConstruct() protected init(): void { diff --git a/packages/debug/src/browser/view/debug-toolbar-widget.tsx b/packages/debug/src/browser/view/debug-toolbar-widget.tsx index 1c536945a6660..b4f56d74c7f45 100644 --- a/packages/debug/src/browser/view/debug-toolbar-widget.tsx +++ b/packages/debug/src/browser/view/debug-toolbar-widget.tsx @@ -27,7 +27,7 @@ import { nls } from '@theia/core/lib/common/nls'; export class DebugToolBar extends ReactWidget { @inject(DebugViewModel) - protected readonly model: DebugViewModel; + protected readonly model!: DebugViewModel; @postConstruct() protected init(): void { diff --git a/packages/debug/src/browser/view/debug-variables-source.ts b/packages/debug/src/browser/view/debug-variables-source.ts index 3923207c8a1ff..ff5000cb80731 100644 --- a/packages/debug/src/browser/view/debug-variables-source.ts +++ b/packages/debug/src/browser/view/debug-variables-source.ts @@ -24,7 +24,7 @@ import debounce = require('p-debounce'); export class DebugVariablesSource extends TreeSource { @inject(DebugViewModel) - protected readonly model: DebugViewModel; + protected readonly model!: DebugViewModel; @postConstruct() protected init(): void { diff --git a/packages/debug/src/browser/view/debug-variables-widget.ts b/packages/debug/src/browser/view/debug-variables-widget.ts index 1832057826e09..fc3828f897b50 100644 --- a/packages/debug/src/browser/view/debug-variables-widget.ts +++ b/packages/debug/src/browser/view/debug-variables-widget.ts @@ -43,10 +43,10 @@ export class DebugVariablesWidget extends SourceTreeWidget { } @inject(DebugViewModel) - protected readonly viewModel: DebugViewModel; + protected readonly viewModel!: DebugViewModel; @inject(DebugVariablesSource) - protected readonly variables: DebugVariablesSource; + protected readonly variables!: DebugVariablesSource; @postConstruct() protected init(): void { diff --git a/packages/debug/src/browser/view/debug-view-model.ts b/packages/debug/src/browser/view/debug-view-model.ts index f2b3ba47da829..8b30c8f68a44c 100644 --- a/packages/debug/src/browser/view/debug-view-model.ts +++ b/packages/debug/src/browser/view/debug-view-model.ts @@ -63,13 +63,13 @@ export class DebugViewModel implements Disposable { ); @inject(DebugViewOptions) - protected readonly options: DebugViewOptions; + protected readonly options!: DebugViewOptions; @inject(DebugSessionManager) - protected readonly manager: DebugSessionManager; + protected readonly manager!: DebugSessionManager; @inject(DebugWatchManager) - protected readonly watch: DebugWatchManager; + protected readonly watch!: DebugWatchManager; protected readonly _sessions = new Set(); get sessions(): IterableIterator { diff --git a/packages/debug/src/browser/view/debug-watch-source.ts b/packages/debug/src/browser/view/debug-watch-source.ts index 68f910567cc51..24498d00a1ebb 100644 --- a/packages/debug/src/browser/view/debug-watch-source.ts +++ b/packages/debug/src/browser/view/debug-watch-source.ts @@ -24,7 +24,7 @@ import debounce = require('p-debounce'); export class DebugWatchSource extends TreeSource { @inject(DebugViewModel) - protected readonly model: DebugViewModel; + protected readonly model!: DebugViewModel; @postConstruct() protected init(): void { diff --git a/packages/debug/src/browser/view/debug-watch-widget.ts b/packages/debug/src/browser/view/debug-watch-widget.ts index 464ce23a156c0..189c2149abe2b 100644 --- a/packages/debug/src/browser/view/debug-watch-widget.ts +++ b/packages/debug/src/browser/view/debug-watch-widget.ts @@ -43,10 +43,10 @@ export class DebugWatchWidget extends SourceTreeWidget { } @inject(DebugViewModel) - readonly viewModel: DebugViewModel; + readonly viewModel!: DebugViewModel; @inject(DebugWatchSource) - protected readonly variables: DebugWatchSource; + protected readonly variables!: DebugWatchSource; @postConstruct() protected init(): void { diff --git a/packages/debug/src/browser/view/debug-widget.ts b/packages/debug/src/browser/view/debug-widget.ts index 529df050885b5..160f1543f6cce 100644 --- a/packages/debug/src/browser/view/debug-widget.ts +++ b/packages/debug/src/browser/view/debug-widget.ts @@ -42,19 +42,19 @@ export class DebugWidget extends BaseWidget implements StatefulWidget, Applicati static LABEL = nls.localizeByDefault('Debug'); @inject(DebugViewModel) - readonly model: DebugViewModel; + readonly model!: DebugViewModel; @inject(DebugSessionManager) - readonly sessionManager: DebugSessionManager; + readonly sessionManager!: DebugSessionManager; @inject(DebugConfigurationWidget) - protected readonly toolbar: DebugConfigurationWidget; + protected readonly toolbar!: DebugConfigurationWidget; @inject(DebugSessionWidget) - protected readonly sessionWidget: DebugSessionWidget; + protected readonly sessionWidget!: DebugSessionWidget; @inject(ProgressBarFactory) - protected readonly progressBarFactory: ProgressBarFactory; + protected readonly progressBarFactory!: ProgressBarFactory; @postConstruct() protected init(): void { diff --git a/packages/debug/src/node/debug-adapter-contribution-registry.ts b/packages/debug/src/node/debug-adapter-contribution-registry.ts index 5e1d0111ae61e..96c0bd556a033 100644 --- a/packages/debug/src/node/debug-adapter-contribution-registry.ts +++ b/packages/debug/src/node/debug-adapter-contribution-registry.ts @@ -29,7 +29,7 @@ import { IJSONSchema, IJSONSchemaSnippet } from '@theia/core/lib/common/json-sch export class DebugAdapterContributionRegistry { @inject(ContributionProvider) @named(DebugAdapterContribution) - protected readonly contributions: ContributionProvider; + protected readonly contributions!: ContributionProvider; protected *getContributions(debugType: string): IterableIterator { for (const contribution of this.contributions.getContributions()) { if (contribution.type === debugType || contribution.type === '*' || debugType === '*') { diff --git a/packages/debug/src/node/debug-adapter-factory.ts b/packages/debug/src/node/debug-adapter-factory.ts index ccf4dee8023ee..7a6753a1c9b8d 100644 --- a/packages/debug/src/node/debug-adapter-factory.ts +++ b/packages/debug/src/node/debug-adapter-factory.ts @@ -50,9 +50,9 @@ import { Disposable } from '@theia/core/lib/common/disposable'; @injectable() export class LaunchBasedDebugAdapterFactory implements DebugAdapterFactory { @inject(RawProcessFactory) - protected readonly processFactory: RawProcessFactory; + protected readonly processFactory!: RawProcessFactory; @inject(ProcessManager) - protected readonly processManager: ProcessManager; + protected readonly processManager!: ProcessManager; start(executable: DebugAdapterExecutable): CommunicationProvider { const process = this.childProcess(executable); diff --git a/packages/debug/src/node/debug-adapter-session-manager.ts b/packages/debug/src/node/debug-adapter-session-manager.ts index 0121e5eed6b6b..0d5a2f46fc73a 100644 --- a/packages/debug/src/node/debug-adapter-session-manager.ts +++ b/packages/debug/src/node/debug-adapter-session-manager.ts @@ -31,14 +31,14 @@ export class DebugAdapterSessionManager implements MessagingService.Contribution protected readonly sessions = new Map(); @inject(DebugAdapterSessionFactory) - protected readonly debugAdapterSessionFactory: DebugAdapterSessionFactory; + protected readonly debugAdapterSessionFactory!: DebugAdapterSessionFactory; @inject(DebugAdapterFactory) - protected readonly debugAdapterFactory: DebugAdapterFactory; + protected readonly debugAdapterFactory!: DebugAdapterFactory; configure(service: MessagingService): void { - service.wsChannel(`${DebugAdapterPath}/:id`, ({ id }: { id: string }, channel) => { - const session = this.find(id); + service.wsChannel(`${DebugAdapterPath}/:id`, (params, channel) => { + const session = this.find(params.id); if (!session) { channel.close(); return; diff --git a/packages/debug/src/node/debug-service-impl.ts b/packages/debug/src/node/debug-service-impl.ts index 5d893298845b5..a74104e17bfa7 100644 --- a/packages/debug/src/node/debug-service-impl.ts +++ b/packages/debug/src/node/debug-service-impl.ts @@ -29,10 +29,10 @@ import { DebugAdapterContributionRegistry } from './debug-adapter-contribution-r export class DebugServiceImpl implements DebugService { @inject(DebugAdapterSessionManager) - protected readonly sessionManager: DebugAdapterSessionManager; + protected readonly sessionManager!: DebugAdapterSessionManager; @inject(DebugAdapterContributionRegistry) - protected readonly registry: DebugAdapterContributionRegistry; + protected readonly registry!: DebugAdapterContributionRegistry; dispose(): void { this.terminateDebugSession(); diff --git a/packages/editor-preview/src/browser/editor-preview-contribution.ts b/packages/editor-preview/src/browser/editor-preview-contribution.ts index 1b39d849991bc..0bbf2fc7fcd97 100644 --- a/packages/editor-preview/src/browser/editor-preview-contribution.ts +++ b/packages/editor-preview/src/browser/editor-preview-contribution.ts @@ -30,7 +30,7 @@ export namespace EditorPreviewCommands { @injectable() export class EditorPreviewContribution implements CommandContribution, MenuContribution, KeybindingContribution { - @inject(ApplicationShell) protected readonly shell: ApplicationShell; + @inject(ApplicationShell) protected readonly shell!: ApplicationShell; registerCommands(registry: CommandRegistry): void { registry.registerCommand(EditorPreviewCommands.PIN_PREVIEW_COMMAND, { diff --git a/packages/editor-preview/src/browser/editor-preview-manager.ts b/packages/editor-preview/src/browser/editor-preview-manager.ts index af88b69d8f5cb..8e955501a1f4f 100644 --- a/packages/editor-preview/src/browser/editor-preview-manager.ts +++ b/packages/editor-preview/src/browser/editor-preview-manager.ts @@ -27,8 +27,8 @@ import { FrontendApplicationStateService } from '@theia/core/lib/browser/fronten export class EditorPreviewManager extends EditorManager { readonly id = EditorPreviewWidgetFactory.ID; - @inject(EditorPreviewPreferences) protected readonly preferences: EditorPreviewPreferences; - @inject(FrontendApplicationStateService) protected readonly stateService: FrontendApplicationStateService; + @inject(EditorPreviewPreferences) protected readonly preferences!: EditorPreviewPreferences; + @inject(FrontendApplicationStateService) protected readonly stateService!: FrontendApplicationStateService; protected currentPreview: EditorPreviewWidget | undefined; protected toDisposeOnPreviewChange = new DisposableCollection(); @@ -41,7 +41,8 @@ export class EditorPreviewManager extends EditorManager { protected init(): void { super.init(); // All editors are created, but not all are opened. This sets up the logic to swap previews when the editor is attached. - this.onCreated((widget: EditorPreviewWidget) => { + this.onCreated(created => { + const widget = created as EditorPreviewWidget; if (this.layoutIsSet && widget.isPreview) { const oneTimeDisposable = widget.onDidChangeVisibility(() => { const { currentPreview } = this; diff --git a/packages/editor-preview/src/browser/editor-preview-tree-decorator.ts b/packages/editor-preview/src/browser/editor-preview-tree-decorator.ts index fff937c5d0bcf..7961a7a128cb4 100644 --- a/packages/editor-preview/src/browser/editor-preview-tree-decorator.ts +++ b/packages/editor-preview/src/browser/editor-preview-tree-decorator.ts @@ -34,8 +34,8 @@ import { EditorPreviewManager } from './editor-preview-manager'; @injectable() export class EditorPreviewTreeDecorator implements TreeDecorator, FrontendApplicationContribution { - @inject(EditorPreviewManager) protected readonly editorPreviewManager: EditorPreviewManager; - @inject(ApplicationShell) protected readonly shell: ApplicationShell; + @inject(EditorPreviewManager) protected readonly editorPreviewManager!: EditorPreviewManager; + @inject(ApplicationShell) protected readonly shell!: ApplicationShell; readonly id = 'theia-open-editors-file-decorator'; protected decorationsMap = new Map(); diff --git a/packages/editor/src/browser/editor-command.ts b/packages/editor/src/browser/editor-command.ts index 7c5489465975a..e77b60d70a93c 100644 --- a/packages/editor/src/browser/editor-command.ts +++ b/packages/editor/src/browser/editor-command.ts @@ -205,30 +205,30 @@ export class EditorCommandContribution implements CommandContribution { public static readonly AUTOSAVE_PREFERENCE: string = 'editor.autoSave'; @inject(ApplicationShell) - protected readonly shell: ApplicationShell; + protected readonly shell!: ApplicationShell; @inject(PreferenceService) - protected readonly preferencesService: PreferenceService; + protected readonly preferencesService!: PreferenceService; @inject(EditorPreferences) - protected readonly editorPreferences: EditorPreferences; + protected readonly editorPreferences!: EditorPreferences; @inject(QuickInputService) @optional() - protected readonly quickInputService: QuickInputService; + protected readonly quickInputService?: QuickInputService; - @inject(MessageService) protected readonly messageService: MessageService; + @inject(MessageService) protected readonly messageService!: MessageService; @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(LanguageService) - protected readonly languages: LanguageService; + protected readonly languages!: LanguageService; @inject(EditorManager) - protected readonly editorManager: EditorManager; + protected readonly editorManager!: EditorManager; @inject(ResourceProvider) - protected readonly resourceProvider: ResourceProvider; + protected readonly resourceProvider!: ResourceProvider; @postConstruct() protected init(): void { diff --git a/packages/editor/src/browser/editor-contribution.ts b/packages/editor/src/browser/editor-contribution.ts index c48e4a5c4de4f..5248069c34c18 100644 --- a/packages/editor/src/browser/editor-contribution.ts +++ b/packages/editor/src/browser/editor-contribution.ts @@ -30,15 +30,15 @@ import { nls } from '@theia/core/lib/common/nls'; @injectable() export class EditorContribution implements FrontendApplicationContribution, CommandContribution, KeybindingContribution { - @inject(StatusBar) protected readonly statusBar: StatusBar; - @inject(EditorManager) protected readonly editorManager: EditorManager; - @inject(LanguageService) protected readonly languages: LanguageService; + @inject(StatusBar) protected readonly statusBar!: StatusBar; + @inject(EditorManager) protected readonly editorManager!: EditorManager; + @inject(LanguageService) protected readonly languages!: LanguageService; @inject(ContextKeyService) - protected readonly contextKeyService: ContextKeyService; + protected readonly contextKeyService!: ContextKeyService; @inject(QuickInputService) @optional() - protected readonly quickInputService: QuickInputService; + protected readonly quickInputService?: QuickInputService; onStart(): void { this.initEditorContextKeys(); diff --git a/packages/editor/src/browser/editor-keybinding-contexts.ts b/packages/editor/src/browser/editor-keybinding-contexts.ts index 76be2c55a8078..253e53ee4b450 100644 --- a/packages/editor/src/browser/editor-keybinding-contexts.ts +++ b/packages/editor/src/browser/editor-keybinding-contexts.ts @@ -44,7 +44,7 @@ export class EditorTextFocusContext implements KeybindingContext { readonly id: string = EditorKeybindingContexts.editorTextFocus; @inject(EditorManager) - protected readonly editorManager: EditorManager; + protected readonly editorManager!: EditorManager; isEnabled(): boolean { return !!this.getEditor(); diff --git a/packages/editor/src/browser/editor-manager.ts b/packages/editor/src/browser/editor-manager.ts index 010735e7241bb..ca70597e92ec9 100644 --- a/packages/editor/src/browser/editor-manager.ts +++ b/packages/editor/src/browser/editor-manager.ts @@ -313,7 +313,7 @@ export class EditorManager extends NavigatableWidgetOpenHandler { export abstract class EditorAccess { @inject(EditorManager) - protected readonly editorManager: EditorManager; + protected readonly editorManager!: EditorManager; /** * The URI of the underlying document from the editor. diff --git a/packages/editor/src/browser/editor-navigation-contribution.ts b/packages/editor/src/browser/editor-navigation-contribution.ts index b42c8547732c2..687dc16e68f0a 100644 --- a/packages/editor/src/browser/editor-navigation-contribution.ts +++ b/packages/editor/src/browser/editor-navigation-contribution.ts @@ -38,22 +38,22 @@ export class EditorNavigationContribution implements Disposable, FrontendApplica protected readonly toDisposePerCurrentEditor = new DisposableCollection(); @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(EditorManager) - protected readonly editorManager: EditorManager; + protected readonly editorManager!: EditorManager; @inject(NavigationLocationService) - protected readonly locationStack: NavigationLocationService; + protected readonly locationStack!: NavigationLocationService; @inject(StorageService) - protected readonly storageService: StorageService; + protected readonly storageService!: StorageService; @inject(PreferenceService) - protected readonly preferenceService: PreferenceService; + protected readonly preferenceService!: PreferenceService; @inject(CommandRegistry) - protected readonly commandRegistry: CommandRegistry; + protected readonly commandRegistry!: CommandRegistry; @postConstruct() protected init(): void { diff --git a/packages/editor/src/browser/editor-variable-contribution.ts b/packages/editor/src/browser/editor-variable-contribution.ts index 3d447e0244ca8..92ce63afc1265 100644 --- a/packages/editor/src/browser/editor-variable-contribution.ts +++ b/packages/editor/src/browser/editor-variable-contribution.ts @@ -23,7 +23,7 @@ import { EditorManager } from './editor-manager'; export class EditorVariableContribution implements VariableContribution { @inject(EditorManager) - protected readonly editorManager: EditorManager; + protected readonly editorManager!: EditorManager; registerVariables(variables: VariableRegistry): void { variables.registerVariable({ diff --git a/packages/editor/src/browser/editor-widget-factory.ts b/packages/editor/src/browser/editor-widget-factory.ts index a29f337992a61..d278b2b2ca291 100644 --- a/packages/editor/src/browser/editor-widget-factory.ts +++ b/packages/editor/src/browser/editor-widget-factory.ts @@ -35,13 +35,13 @@ export class EditorWidgetFactory implements WidgetFactory { readonly id = EditorWidgetFactory.ID; @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(TextEditorProvider) - protected readonly editorProvider: TextEditorProvider; + protected readonly editorProvider!: TextEditorProvider; @inject(SelectionService) - protected readonly selectionService: SelectionService; + protected readonly selectionService!: SelectionService; createWidget(options: NavigatableWidgetOptions): Promise { const uri = new URI(options.uri); diff --git a/packages/editor/src/browser/navigation/navigation-location-service.ts b/packages/editor/src/browser/navigation/navigation-location-service.ts index c9b754d8e1390..cc7b7b7c3a913 100644 --- a/packages/editor/src/browser/navigation/navigation-location-service.ts +++ b/packages/editor/src/browser/navigation/navigation-location-service.ts @@ -34,16 +34,16 @@ export class NavigationLocationService { private static readonly MAX_RECENTLY_CLOSED_EDITORS = 20; @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(OpenerService) - protected readonly openerService: OpenerService; + protected readonly openerService!: OpenerService; @inject(NavigationLocationUpdater) - protected readonly updater: NavigationLocationUpdater; + protected readonly updater!: NavigationLocationUpdater; @inject(NavigationLocationSimilarity) - protected readonly similarity: NavigationLocationSimilarity; + protected readonly similarity!: NavigationLocationSimilarity; protected pointer = -1; protected stack: NavigationLocation[] = []; diff --git a/packages/editor/src/browser/quick-editor-service.ts b/packages/editor/src/browser/quick-editor-service.ts index 143070f126ffb..db8b98f438777 100644 --- a/packages/editor/src/browser/quick-editor-service.ts +++ b/packages/editor/src/browser/quick-editor-service.ts @@ -28,16 +28,16 @@ export class QuickEditorService implements QuickAccessContribution, QuickAccessP static PREFIX = 'edt '; @inject(OpenerService) - protected readonly openerService: OpenerService; + protected readonly openerService!: OpenerService; @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(QuickAccessRegistry) - protected readonly quickAccessRegistry: QuickAccessRegistry; + protected readonly quickAccessRegistry!: QuickAccessRegistry; @inject(EditorManager) - protected readonly editorManager: EditorManager; + protected readonly editorManager!: EditorManager; registerQuickAccessProvider(): void { this.quickAccessRegistry.registerQuickAccessProvider({ diff --git a/packages/external-terminal/src/electron-browser/external-terminal-contribution.ts b/packages/external-terminal/src/electron-browser/external-terminal-contribution.ts index 539e1fdec913f..1b42500bc1f7d 100644 --- a/packages/external-terminal/src/electron-browser/external-terminal-contribution.ts +++ b/packages/external-terminal/src/electron-browser/external-terminal-contribution.ts @@ -36,25 +36,25 @@ export namespace ExternalTerminalCommands { export class ExternalTerminalFrontendContribution implements CommandContribution, KeybindingContribution { @inject(EditorManager) - protected readonly editorManager: EditorManager; + protected readonly editorManager!: EditorManager; @inject(EnvVariablesServer) - protected readonly envVariablesServer: EnvVariablesServer; + protected readonly envVariablesServer!: EnvVariablesServer; @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(QuickPickService) - protected readonly quickPickService: QuickPickService; + protected readonly quickPickService!: QuickPickService; @inject(ExternalTerminalService) - protected readonly externalTerminalService: ExternalTerminalService; + protected readonly externalTerminalService!: ExternalTerminalService; @inject(ExternalTerminalPreferenceService) - protected readonly externalTerminalPreferences: ExternalTerminalPreferenceService; + protected readonly externalTerminalPreferences!: ExternalTerminalPreferenceService; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; registerCommands(commands: CommandRegistry): void { commands.registerCommand(ExternalTerminalCommands.OPEN_NATIVE_CONSOLE, { diff --git a/packages/external-terminal/src/electron-browser/external-terminal-preference.ts b/packages/external-terminal/src/electron-browser/external-terminal-preference.ts index ef94da7292974..02fadbbdbdcc8 100644 --- a/packages/external-terminal/src/electron-browser/external-terminal-preference.ts +++ b/packages/external-terminal/src/electron-browser/external-terminal-preference.ts @@ -49,13 +49,13 @@ export function bindExternalTerminalPreferences(bind: interfaces.Bind): void { export class ExternalTerminalPreferenceService { @inject(ExternalTerminalPreferences) - protected readonly preferences: ExternalTerminalPreferences; + protected readonly preferences!: ExternalTerminalPreferences; @inject(PreferenceSchemaProvider) - protected readonly preferenceSchemaProvider: PreferenceSchemaProvider; + protected readonly preferenceSchemaProvider!: PreferenceSchemaProvider; @inject(ExternalTerminalSchemaPromise) - protected readonly promisedSchema: ExternalTerminalSchemaPromise; + protected readonly promisedSchema!: ExternalTerminalSchemaPromise; @postConstruct() protected init(): void { diff --git a/packages/external-terminal/src/electron-node/linux-external-terminal-service.ts b/packages/external-terminal/src/electron-node/linux-external-terminal-service.ts index 764d094942f78..fb8f6451de895 100644 --- a/packages/external-terminal/src/electron-node/linux-external-terminal-service.ts +++ b/packages/external-terminal/src/electron-node/linux-external-terminal-service.ts @@ -29,7 +29,7 @@ import { ExternalTerminalService, ExternalTerminalConfiguration } from '../commo @injectable() export class LinuxExternalTerminalService implements ExternalTerminalService { - protected DEFAULT_TERMINAL_LINUX_READY: Promise; + protected DEFAULT_TERMINAL_LINUX_READY?: Promise; async openTerminal(configuration: ExternalTerminalConfiguration, cwd: string): Promise { await this.spawnTerminal(configuration, FileUri.fsPath(cwd)); diff --git a/packages/external-terminal/src/electron-node/windows-external-terminal-service.ts b/packages/external-terminal/src/electron-node/windows-external-terminal-service.ts index 8fc87e303990c..8243892945052 100644 --- a/packages/external-terminal/src/electron-node/windows-external-terminal-service.ts +++ b/packages/external-terminal/src/electron-node/windows-external-terminal-service.ts @@ -29,7 +29,7 @@ import { ExternalTerminalService, ExternalTerminalConfiguration } from '../commo @injectable() export class WindowsExternalTerminalService implements ExternalTerminalService { protected readonly CMD = 'cmd.exe'; - protected DEFAULT_TERMINAL_WINDOWS: string; + protected DEFAULT_TERMINAL_WINDOWS?: string; async openTerminal(configuration: ExternalTerminalConfiguration, cwd: string): Promise { await this.spawnTerminal(configuration, FileUri.fsPath(cwd)); diff --git a/packages/file-search/src/browser/quick-file-open-contribution.ts b/packages/file-search/src/browser/quick-file-open-contribution.ts index f084d80315001..0ad560e07941a 100644 --- a/packages/file-search/src/browser/quick-file-open-contribution.ts +++ b/packages/file-search/src/browser/quick-file-open-contribution.ts @@ -26,7 +26,7 @@ import { nls } from '@theia/core/lib/common/nls'; export class QuickFileOpenFrontendContribution implements QuickAccessContribution, CommandContribution, KeybindingContribution, MenuContribution { @inject(QuickFileOpenService) - protected readonly quickFileOpenService: QuickFileOpenService; + protected readonly quickFileOpenService!: QuickFileOpenService; registerCommands(commands: CommandRegistry): void { commands.registerCommand(quickFileOpen, { diff --git a/packages/file-search/src/browser/quick-file-open.ts b/packages/file-search/src/browser/quick-file-open.ts index e2f0da6509aba..a72132589794d 100644 --- a/packages/file-search/src/browser/quick-file-open.ts +++ b/packages/file-search/src/browser/quick-file-open.ts @@ -47,25 +47,25 @@ export class QuickFileOpenService implements QuickAccessProvider { static readonly PREFIX = ''; @inject(KeybindingRegistry) - protected readonly keybindingRegistry: KeybindingRegistry; + protected readonly keybindingRegistry!: KeybindingRegistry; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @inject(OpenerService) - protected readonly openerService: OpenerService; + protected readonly openerService!: OpenerService; @inject(QuickInputService) @optional() - protected readonly quickInputService: QuickInputService; + protected readonly quickInputService?: QuickInputService; @inject(QuickAccessRegistry) - protected readonly quickAccessRegistry: QuickAccessRegistry; + protected readonly quickAccessRegistry!: QuickAccessRegistry; @inject(FileSearchService) - protected readonly fileSearchService: FileSearchService; + protected readonly fileSearchService!: FileSearchService; @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(NavigationLocationService) - protected readonly navigationLocationService: NavigationLocationService; + protected readonly navigationLocationService!: NavigationLocationService; @inject(MessageService) - protected readonly messageService: MessageService; + protected readonly messageService!: MessageService; @inject(FileSystemPreferences) - protected readonly fsPreferences: FileSystemPreferences; + protected readonly fsPreferences!: FileSystemPreferences; registerQuickAccessProvider(): void { this.quickAccessRegistry.registerQuickAccessProvider({ diff --git a/packages/filesystem/src/browser/breadcrumbs/filepath-breadcrumbs-container.ts b/packages/filesystem/src/browser/breadcrumbs/filepath-breadcrumbs-container.ts index 3c47fd0064cc5..0ccf171bb3071 100644 --- a/packages/filesystem/src/browser/breadcrumbs/filepath-breadcrumbs-container.ts +++ b/packages/filesystem/src/browser/breadcrumbs/filepath-breadcrumbs-container.ts @@ -37,7 +37,7 @@ export function createFileTreeBreadcrumbsWidget(parent: interfaces.Container): B export class BreadcrumbsFileTreeWidget extends FileTreeWidget { @inject(OpenerService) - protected readonly openerService: OpenerService; + protected readonly openerService!: OpenerService; constructor( @inject(TreeProps) readonly props: TreeProps, diff --git a/packages/filesystem/src/browser/breadcrumbs/filepath-breadcrumbs-contribution.ts b/packages/filesystem/src/browser/breadcrumbs/filepath-breadcrumbs-contribution.ts index 7663cd01ddb35..34ec96d0fe34c 100644 --- a/packages/filesystem/src/browser/breadcrumbs/filepath-breadcrumbs-contribution.ts +++ b/packages/filesystem/src/browser/breadcrumbs/filepath-breadcrumbs-contribution.ts @@ -34,13 +34,13 @@ export interface FilepathBreadcrumbClassNameFactory { export class FilepathBreadcrumbsContribution implements BreadcrumbsContribution { @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(FileService) - protected readonly fileSystem: FileService; + protected readonly fileSystem!: FileService; @inject(BreadcrumbsFileTreeWidget) - protected readonly breadcrumbsFileTreeWidget: BreadcrumbsFileTreeWidget; + protected readonly breadcrumbsFileTreeWidget!: BreadcrumbsFileTreeWidget; protected readonly onDidChangeBreadcrumbsEmitter = new Emitter(); get onDidChangeBreadcrumbs(): Event { diff --git a/packages/filesystem/src/browser/download/file-download-command-contribution.ts b/packages/filesystem/src/browser/download/file-download-command-contribution.ts index 952a8eae32bac..c2e8e65ad0e06 100644 --- a/packages/filesystem/src/browser/download/file-download-command-contribution.ts +++ b/packages/filesystem/src/browser/download/file-download-command-contribution.ts @@ -28,10 +28,10 @@ import { CommonCommands } from '@theia/core/lib/browser'; export class FileDownloadCommandContribution implements CommandContribution { @inject(FileDownloadService) - protected readonly downloadService: FileDownloadService; + protected readonly downloadService!: FileDownloadService; @inject(SelectionService) - protected readonly selectionService: SelectionService; + protected readonly selectionService!: SelectionService; registerCommands(registry: CommandRegistry): void { registry.registerCommand( diff --git a/packages/filesystem/src/browser/download/file-download-service.ts b/packages/filesystem/src/browser/download/file-download-service.ts index 8c66f5a23ebf2..37fa8c8355340 100644 --- a/packages/filesystem/src/browser/download/file-download-service.ts +++ b/packages/filesystem/src/browser/download/file-download-service.ts @@ -29,10 +29,10 @@ export class FileDownloadService { protected downloadCounter: number = 0; @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(MessageService) - protected readonly messageService: MessageService; + protected readonly messageService!: MessageService; protected handleCopy(event: ClipboardEvent, downloadUrl: string): void { if (downloadUrl && event.clipboardData) { diff --git a/packages/filesystem/src/browser/file-dialog/file-dialog-model.ts b/packages/filesystem/src/browser/file-dialog/file-dialog-model.ts index 6fb2a7062d867..de9ea1cd53537 100644 --- a/packages/filesystem/src/browser/file-dialog/file-dialog-model.ts +++ b/packages/filesystem/src/browser/file-dialog/file-dialog-model.ts @@ -24,7 +24,7 @@ import { FileDialogTree } from './file-dialog-tree'; @injectable() export class FileDialogModel extends FileTreeModel { - @inject(FileDialogTree) readonly tree: FileDialogTree; + @inject(FileDialogTree) readonly tree!: FileDialogTree; protected readonly onDidOpenFileEmitter = new Emitter(); protected _initialLocation: URI | undefined; private _disableFileSelection: boolean = false; diff --git a/packages/filesystem/src/browser/file-dialog/file-dialog-service.ts b/packages/filesystem/src/browser/file-dialog/file-dialog-service.ts index 5a0d15045fb7f..889bced706d65 100644 --- a/packages/filesystem/src/browser/file-dialog/file-dialog-service.ts +++ b/packages/filesystem/src/browser/file-dialog/file-dialog-service.ts @@ -39,14 +39,14 @@ export interface FileDialogService { export class DefaultFileDialogService implements FileDialogService { @inject(EnvVariablesServer) - protected readonly environments: EnvVariablesServer; + protected readonly environments!: EnvVariablesServer; @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; - @inject(OpenFileDialogFactory) protected readonly openFileDialogFactory: OpenFileDialogFactory; - @inject(LabelProvider) protected readonly labelProvider: LabelProvider; - @inject(SaveFileDialogFactory) protected readonly saveFileDialogFactory: SaveFileDialogFactory; + @inject(OpenFileDialogFactory) protected readonly openFileDialogFactory!: OpenFileDialogFactory; + @inject(LabelProvider) protected readonly labelProvider!: LabelProvider; + @inject(SaveFileDialogFactory) protected readonly saveFileDialogFactory!: SaveFileDialogFactory; async showOpenDialog(props: OpenFileDialogProps & { canSelectMany: true }, folder?: FileStat): Promise | undefined>; async showOpenDialog(props: OpenFileDialogProps, folder?: FileStat): Promise; diff --git a/packages/filesystem/src/browser/file-dialog/file-dialog.ts b/packages/filesystem/src/browser/file-dialog/file-dialog.ts index 9b91cd7d2cc92..c09b61f8e1716 100644 --- a/packages/filesystem/src/browser/file-dialog/file-dialog.ts +++ b/packages/filesystem/src/browser/file-dialog/file-dialog.ts @@ -56,7 +56,7 @@ export const FILENAME_TEXTFIELD_CLASS = 'theia-FileNameTextField'; export const CONTROL_PANEL_CLASS = 'theia-ControlPanel'; export const TOOLBAR_ITEM_TRANSFORM_TIMEOUT = 100; -export class FileDialogProps extends DialogProps { +export abstract class FileDialogProps extends DialogProps { /** * A set of file filters that are used by the dialog. Each entry is a human readable label, @@ -73,7 +73,7 @@ export class FileDialogProps extends DialogProps { } @injectable() -export class OpenFileDialogProps extends FileDialogProps { +export abstract class OpenFileDialogProps extends FileDialogProps { /** * A human-readable string for the accept button. @@ -98,7 +98,7 @@ export class OpenFileDialogProps extends FileDialogProps { } @injectable() -export class SaveFileDialogProps extends FileDialogProps { +export abstract class SaveFileDialogProps extends FileDialogProps { /** * A human-readable string for the accept button. @@ -114,17 +114,17 @@ export class SaveFileDialogProps extends FileDialogProps { export abstract class FileDialog extends AbstractDialog { - protected back: HTMLSpanElement; - protected forward: HTMLSpanElement; - protected home: HTMLSpanElement; - protected up: HTMLSpanElement; - protected locationListRenderer: LocationListRenderer; - protected treeFiltersRenderer: FileDialogTreeFiltersRenderer | undefined; - protected treePanel: Panel; + protected back!: HTMLSpanElement; + protected forward!: HTMLSpanElement; + protected home!: HTMLSpanElement; + protected up!: HTMLSpanElement; + protected locationListRenderer!: LocationListRenderer; + protected treePanel!: Panel; + protected treeFiltersRenderer?: FileDialogTreeFiltersRenderer; - @inject(FileDialogWidget) readonly widget: FileDialogWidget; - @inject(LocationListRendererFactory) readonly locationListFactory: LocationListRendererFactory; - @inject(FileDialogTreeFiltersRendererFactory) readonly treeFiltersFactory: FileDialogTreeFiltersRendererFactory; + @inject(FileDialogWidget) readonly widget!: FileDialogWidget; + @inject(LocationListRendererFactory) readonly locationListFactory!: LocationListRendererFactory; + @inject(FileDialogTreeFiltersRendererFactory) readonly treeFiltersFactory!: FileDialogTreeFiltersRendererFactory; constructor( @inject(FileDialogProps) readonly props: FileDialogProps @@ -338,7 +338,7 @@ export class SaveFileDialog extends FileDialog { protected fileNameField: HTMLInputElement | undefined; @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; constructor(@inject(SaveFileDialogProps) readonly props: SaveFileDialogProps) { super(props); diff --git a/packages/filesystem/src/browser/file-resource.ts b/packages/filesystem/src/browser/file-resource.ts index 0511fdb31c575..6252f7170ffc5 100644 --- a/packages/filesystem/src/browser/file-resource.ts +++ b/packages/filesystem/src/browser/file-resource.ts @@ -292,10 +292,10 @@ export class FileResource implements Resource { export class FileResourceResolver implements ResourceResolver { @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; async resolve(uri: URI): Promise { let stat; diff --git a/packages/filesystem/src/browser/file-service.ts b/packages/filesystem/src/browser/file-service.ts index e1f89905565a9..6319d498e3b5e 100644 --- a/packages/filesystem/src/browser/file-service.ts +++ b/packages/filesystem/src/browser/file-service.ts @@ -273,25 +273,25 @@ export class FileService { private readonly BUFFER_SIZE = 64 * 1024; @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(FileSystemPreferences) - protected readonly preferences: FileSystemPreferences; + protected readonly preferences!: FileSystemPreferences; @inject(ProgressService) - protected readonly progressService: ProgressService; + protected readonly progressService!: ProgressService; @inject(EncodingRegistry) - protected readonly encodingRegistry: EncodingRegistry; + protected readonly encodingRegistry!: EncodingRegistry; @inject(EncodingService) - protected readonly encodingService: EncodingService; + protected readonly encodingService!: EncodingService; @inject(ContributionProvider) @named(FileServiceContribution) - protected readonly contributions: ContributionProvider; + protected readonly contributions!: ContributionProvider; @inject(FileSystemWatcherErrorHandler) - protected readonly watcherErrorHandler: FileSystemWatcherErrorHandler; + protected readonly watcherErrorHandler!: FileSystemWatcherErrorHandler; @postConstruct() protected init(): void { diff --git a/packages/filesystem/src/browser/file-tree/file-tree-label-provider.ts b/packages/filesystem/src/browser/file-tree/file-tree-label-provider.ts index 5ca221e03af33..055d1ce7badf2 100644 --- a/packages/filesystem/src/browser/file-tree/file-tree-label-provider.ts +++ b/packages/filesystem/src/browser/file-tree/file-tree-label-provider.ts @@ -23,10 +23,10 @@ import { TreeLabelProvider } from '@theia/core/lib/browser/tree/tree-label-provi export class FileTreeLabelProvider implements LabelProviderContribution { @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(TreeLabelProvider) - protected readonly treeLabelProvider: TreeLabelProvider; + protected readonly treeLabelProvider!: TreeLabelProvider; canHandle(element: object): number { return FileStatNode.is(element) ? diff --git a/packages/filesystem/src/browser/file-tree/file-tree-model.ts b/packages/filesystem/src/browser/file-tree/file-tree-model.ts index aa320027c2510..647762774767a 100644 --- a/packages/filesystem/src/browser/file-tree/file-tree-model.ts +++ b/packages/filesystem/src/browser/file-tree/file-tree-model.ts @@ -29,16 +29,16 @@ import { FileSystemUtils } from '../../common'; @injectable() export class FileTreeModel extends TreeModelImpl implements LocationService { - @inject(LabelProvider) protected readonly labelProvider: LabelProvider; + @inject(LabelProvider) protected readonly labelProvider!: LabelProvider; @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; @inject(MessageService) - protected readonly messageService: MessageService; + protected readonly messageService!: MessageService; @inject(EnvVariablesServer) - protected readonly environments: EnvVariablesServer; + protected readonly environments!: EnvVariablesServer; @postConstruct() protected init(): void { diff --git a/packages/filesystem/src/browser/file-tree/file-tree-widget.tsx b/packages/filesystem/src/browser/file-tree/file-tree-widget.tsx index 2300015220af4..0ca78dcd61755 100644 --- a/packages/filesystem/src/browser/file-tree/file-tree-widget.tsx +++ b/packages/filesystem/src/browser/file-tree/file-tree-widget.tsx @@ -38,10 +38,10 @@ export class FileTreeWidget extends TreeViewWelcomeWidget { protected readonly toCancelNodeExpansion = new DisposableCollection(); @inject(FileUploadService) - protected readonly uploadService: FileUploadService; + protected readonly uploadService!: FileUploadService; @inject(IconThemeService) - protected readonly iconThemeService: IconThemeService; + protected readonly iconThemeService!: IconThemeService; constructor( @inject(TreeProps) readonly props: TreeProps, diff --git a/packages/filesystem/src/browser/file-tree/file-tree.ts b/packages/filesystem/src/browser/file-tree/file-tree.ts index 8f5cb9e673a46..938844c2ab091 100644 --- a/packages/filesystem/src/browser/file-tree/file-tree.ts +++ b/packages/filesystem/src/browser/file-tree/file-tree.ts @@ -29,10 +29,10 @@ import { FileService } from '../file-service'; export class FileTree extends TreeImpl { @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; @inject(MessageService) - protected readonly messagingService: MessageService; + protected readonly messagingService!: MessageService; async resolveChildren(parent: CompositeTreeNode): Promise { if (FileStatNode.is(parent)) { diff --git a/packages/filesystem/src/browser/file-upload-service.ts b/packages/filesystem/src/browser/file-upload-service.ts index 5ec856dc2f42f..f55d53db95438 100644 --- a/packages/filesystem/src/browser/file-upload-service.ts +++ b/packages/filesystem/src/browser/file-upload-service.ts @@ -52,17 +52,17 @@ export class FileUploadService { static TARGET = 'target'; static UPLOAD = 'upload'; - protected uploadForm: FileUploadService.Form; + protected uploadForm!: FileUploadService.Form; protected deferredUpload?: Deferred; @inject(MessageService) - protected readonly messageService: MessageService; + protected readonly messageService!: MessageService; @inject(FileSystemPreferences) - protected fileSystemPreferences: FileSystemPreferences; + protected fileSystemPreferences!: FileSystemPreferences; @inject(FileService) - protected fileService: FileService; + protected fileService!: FileService; get maxConcurrentUploads(): number { const maxConcurrentUploads = this.fileSystemPreferences['files.maxConcurrentUploads']; @@ -284,7 +284,8 @@ export class FileUploadService { token.onCancellationRequested(() => xhr.abort()); const upload = new Promise((resolve, reject) => { this.registerEvents(xhr.upload, unregister => ({ - progress: (event: ProgressEvent) => { + progress: e => { + const event = e as ProgressEvent; if (event.total === event.loaded) { unregister(); resolve(); diff --git a/packages/filesystem/src/browser/filesystem-frontend-contribution.ts b/packages/filesystem/src/browser/filesystem-frontend-contribution.ts index 693761f5a577b..ca5f70baa0cc5 100644 --- a/packages/filesystem/src/browser/filesystem-frontend-contribution.ts +++ b/packages/filesystem/src/browser/filesystem-frontend-contribution.ts @@ -54,28 +54,28 @@ export interface NavigatableWidgetMoveSnapshot { export class FileSystemFrontendContribution implements FrontendApplicationContribution, CommandContribution { @inject(ApplicationShell) - protected readonly shell: ApplicationShell; + protected readonly shell!: ApplicationShell; @inject(WidgetManager) - protected readonly widgetManager: WidgetManager; + protected readonly widgetManager!: WidgetManager; @inject(MimeService) - protected readonly mimeService: MimeService; + protected readonly mimeService!: MimeService; @inject(FileSystemPreferences) - protected readonly preferences: FileSystemPreferences; + protected readonly preferences!: FileSystemPreferences; @inject(CorePreferences) - protected readonly corePreferences: CorePreferences; + protected readonly corePreferences!: CorePreferences; @inject(SelectionService) - protected readonly selectionService: SelectionService; + protected readonly selectionService!: SelectionService; @inject(FileUploadService) - protected readonly uploadService: FileUploadService; + protected readonly uploadService!: FileUploadService; @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; protected onDidChangeEditorFileEmitter = new Emitter<{ editor: NavigatableWidget, type: FileChangeType }>(); readonly onDidChangeEditorFile = this.onDidChangeEditorFileEmitter.event; diff --git a/packages/filesystem/src/browser/filesystem-watcher-error-handler.ts b/packages/filesystem/src/browser/filesystem-watcher-error-handler.ts index 0506710a0ec6a..cc5d2cf896728 100644 --- a/packages/filesystem/src/browser/filesystem-watcher-error-handler.ts +++ b/packages/filesystem/src/browser/filesystem-watcher-error-handler.ts @@ -22,8 +22,8 @@ import { WindowService } from '@theia/core/lib/browser/window/window-service'; @injectable() export class FileSystemWatcherErrorHandler { - @inject(MessageService) protected readonly messageService: MessageService; - @inject(WindowService) protected readonly windowService: WindowService; + @inject(MessageService) protected readonly messageService!: MessageService; + @inject(WindowService) protected readonly windowService!: WindowService; protected watchHandlesExhausted: boolean = false; diff --git a/packages/filesystem/src/browser/filesystem-watcher.ts b/packages/filesystem/src/browser/filesystem-watcher.ts index 46203784eb017..82506570db1ef 100644 --- a/packages/filesystem/src/browser/filesystem-watcher.ts +++ b/packages/filesystem/src/browser/filesystem-watcher.ts @@ -192,7 +192,7 @@ export class FileSystemWatcher implements Disposable { readonly onDidMove = this.fileMoveEmitter.onDid; @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; @postConstruct() protected init(): void { diff --git a/packages/filesystem/src/browser/location/location-renderer.tsx b/packages/filesystem/src/browser/location/location-renderer.tsx index e703b7c3248d8..390bf15516276 100644 --- a/packages/filesystem/src/browser/location/location-renderer.tsx +++ b/packages/filesystem/src/browser/location/location-renderer.tsx @@ -80,15 +80,15 @@ export interface LocationListRendererOptions { @injectable() export class LocationListRenderer extends ReactRenderer { - @inject(FileService) protected readonly fileService: FileService; - @inject(EnvVariablesServer) protected readonly variablesServer: EnvVariablesServer; + @inject(FileService) protected readonly fileService!: FileService; + @inject(EnvVariablesServer) protected readonly variablesServer!: EnvVariablesServer; - protected directoryCache: ResolvedDirectoryCache; + protected directoryCache?: ResolvedDirectoryCache; protected service: LocationService; protected toDisposeOnNewCache = new DisposableCollection(); protected _drives: URI[] | undefined; protected _doShowTextInput = false; - protected homeDir: string; + protected homeDir!: string; get doShowTextInput(): boolean { return this._doShowTextInput; @@ -100,7 +100,7 @@ export class LocationListRenderer extends ReactRenderer { } } protected lastUniqueTextInputLocation: URI | undefined; - protected previousAutocompleteMatch: string; + protected previousAutocompleteMatch?: string; protected doAttemptAutocomplete = true; constructor( @@ -304,7 +304,7 @@ export class LocationListRenderer extends ReactRenderer { } protected trySuggestDirectory(e: React.ChangeEvent): void { - if (this.doAttemptAutocomplete) { + if (this.directoryCache && this.doAttemptAutocomplete) { const inputElement = e.currentTarget; const { value } = inputElement; if ((value.startsWith('/') || value.startsWith('~/')) && value.slice(-1) !== '/') { diff --git a/packages/filesystem/src/browser/remote-file-service-contribution.ts b/packages/filesystem/src/browser/remote-file-service-contribution.ts index 5bd48b423ee09..e5c556cd2ea66 100644 --- a/packages/filesystem/src/browser/remote-file-service-contribution.ts +++ b/packages/filesystem/src/browser/remote-file-service-contribution.ts @@ -22,7 +22,7 @@ import { RemoteFileSystemProvider } from '../common/remote-file-system-provider' export class RemoteFileServiceContribution implements FileServiceContribution { @inject(RemoteFileSystemProvider) - protected readonly provider: RemoteFileSystemProvider; + protected readonly provider!: RemoteFileSystemProvider; registerFileSystemProviders(service: FileService): void { const registering = this.provider.ready.then(() => diff --git a/packages/filesystem/src/common/remote-file-system-provider.ts b/packages/filesystem/src/common/remote-file-system-provider.ts index f1d9391e9031f..4c2a9eed3a7a5 100644 --- a/packages/filesystem/src/common/remote-file-system-provider.ts +++ b/packages/filesystem/src/common/remote-file-system-provider.ts @@ -153,7 +153,7 @@ export class RemoteFileSystemProvider implements Required, D * Wrapped remote filesystem. */ @inject(RemoteFileSystemServer) - protected readonly server: JsonRpcProxy; + protected readonly server!: JsonRpcProxy; @postConstruct() protected init(): void { @@ -350,7 +350,7 @@ export class FileSystemProviderServer implements RemoteFileSystemServer { * Wrapped file system provider. */ @inject(FileSystemProvider) - protected readonly provider: FileSystemProvider & Partial; + protected readonly provider!: FileSystemProvider & Partial; @postConstruct() protected init(): void { diff --git a/packages/filesystem/src/electron-browser/file-dialog/electron-file-dialog-service.ts b/packages/filesystem/src/electron-browser/file-dialog/electron-file-dialog-service.ts index 8d432a4f019ff..183b7306aec99 100644 --- a/packages/filesystem/src/electron-browser/file-dialog/electron-file-dialog-service.ts +++ b/packages/filesystem/src/electron-browser/file-dialog/electron-file-dialog-service.ts @@ -41,7 +41,7 @@ import { FileUri } from '@theia/core/lib/node/file-uri'; @injectable() export class ElectronFileDialogService extends DefaultFileDialogService { - @inject(MessageService) protected readonly messageService: MessageService; + @inject(MessageService) protected readonly messageService!: MessageService; async showOpenDialog(props: OpenFileDialogProps & { canSelectMany: true }, folder?: FileStat): Promise | undefined>; async showOpenDialog(props: OpenFileDialogProps, folder?: FileStat): Promise; diff --git a/packages/filesystem/src/node/disk-file-system-provider.ts b/packages/filesystem/src/node/disk-file-system-provider.ts index 46961a84aaf55..6bb298fed30ec 100644 --- a/packages/filesystem/src/node/disk-file-system-provider.ts +++ b/packages/filesystem/src/node/disk-file-system-provider.ts @@ -103,10 +103,10 @@ export class DiskFileSystemProvider implements Disposable, ); @inject(FileSystemWatcherServer) - protected readonly watcher: FileSystemWatcherServer; + protected readonly watcher!: FileSystemWatcherServer; @inject(EncodingService) - protected readonly encodingService: EncodingService; + protected readonly encodingService!: EncodingService; @postConstruct() protected init(): void { diff --git a/packages/filesystem/src/node/download/file-download-cache.ts b/packages/filesystem/src/node/download/file-download-cache.ts index 2ed1da44cf195..d1139a1353a6e 100644 --- a/packages/filesystem/src/node/download/file-download-cache.ts +++ b/packages/filesystem/src/node/download/file-download-cache.ts @@ -29,7 +29,7 @@ export interface DownloadStorageItem { export class FileDownloadCache { @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; protected readonly downloads = new Map(); protected readonly expireTimeInMinutes: number = 1; diff --git a/packages/filesystem/src/node/download/file-download-endpoint.ts b/packages/filesystem/src/node/download/file-download-endpoint.ts index 0eb631e24cb99..b3e1f61c6bbd9 100644 --- a/packages/filesystem/src/node/download/file-download-endpoint.ts +++ b/packages/filesystem/src/node/download/file-download-endpoint.ts @@ -31,15 +31,15 @@ export class FileDownloadEndpoint implements BackendApplicationContribution { @inject(FileDownloadHandler) @named(FileDownloadHandler.SINGLE) - protected readonly singleFileDownloadHandler: FileDownloadHandler; + protected readonly singleFileDownloadHandler!: FileDownloadHandler; @inject(FileDownloadHandler) @named(FileDownloadHandler.MULTI) - protected readonly multiFileDownloadHandler: FileDownloadHandler; + protected readonly multiFileDownloadHandler!: FileDownloadHandler; @inject(FileDownloadHandler) @named(FileDownloadHandler.DOWNLOAD_LINK) - protected readonly downloadLinkHandler: FileDownloadHandler; + protected readonly downloadLinkHandler!: FileDownloadHandler; configure(app: Application): void { const router = Router(); diff --git a/packages/filesystem/src/node/download/file-download-handler.ts b/packages/filesystem/src/node/download/file-download-handler.ts index 7960294f57154..a9b949a006b95 100644 --- a/packages/filesystem/src/node/download/file-download-handler.ts +++ b/packages/filesystem/src/node/download/file-download-handler.ts @@ -40,13 +40,13 @@ interface PrepareDownloadOptions { export abstract class FileDownloadHandler { @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(DirectoryArchiver) - protected readonly directoryArchiver: DirectoryArchiver; + protected readonly directoryArchiver!: DirectoryArchiver; @inject(FileDownloadCache) - protected readonly fileDownloadCache: FileDownloadCache; + protected readonly fileDownloadCache!: FileDownloadCache; public abstract handle(request: Request, response: Response): Promise; diff --git a/packages/filesystem/src/node/filesystem-watcher-client.ts b/packages/filesystem/src/node/filesystem-watcher-client.ts index 7a9ce1fc3a5ee..d4127d4368a87 100644 --- a/packages/filesystem/src/node/filesystem-watcher-client.ts +++ b/packages/filesystem/src/node/filesystem-watcher-client.ts @@ -39,10 +39,10 @@ export class FileSystemWatcherServerClient implements FileSystemWatcherServer { protected readonly clientId = FileSystemWatcherServerClient.clientIdSequence++; @inject(FileSystemWatcherServiceDispatcher) - protected readonly watcherDispatcher: FileSystemWatcherServiceDispatcher; + protected readonly watcherDispatcher!: FileSystemWatcherServiceDispatcher; @inject(FileSystemWatcherService) - protected readonly watcherService: FileSystemWatcherService; + protected readonly watcherService!: FileSystemWatcherService; async watchFileChanges(uri: string, options?: WatchOptions): Promise { const watcherId = await this.watcherService.watchFileChanges(this.clientId, uri, options); diff --git a/packages/getting-started/src/browser/getting-started-contribution.ts b/packages/getting-started/src/browser/getting-started-contribution.ts index 97382bfa1d5a7..4cad6be11eeac 100644 --- a/packages/getting-started/src/browser/getting-started-contribution.ts +++ b/packages/getting-started/src/browser/getting-started-contribution.ts @@ -33,10 +33,10 @@ export const GettingStartedCommand = { export class GettingStartedContribution extends AbstractViewContribution implements FrontendApplicationContribution { @inject(FrontendApplicationStateService) - protected readonly stateService: FrontendApplicationStateService; + protected readonly stateService!: FrontendApplicationStateService; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; constructor() { super({ diff --git a/packages/getting-started/src/browser/getting-started-widget.tsx b/packages/getting-started/src/browser/getting-started-widget.tsx index b331ee005a9c1..00492327a3012 100644 --- a/packages/getting-started/src/browser/getting-started-widget.tsx +++ b/packages/getting-started/src/browser/getting-started-widget.tsx @@ -80,22 +80,22 @@ export class GettingStartedWidget extends ReactWidget { protected readonly pluginUrl = 'https://www.theia-ide.org/docs/authoring_plugins'; @inject(ApplicationServer) - protected readonly appServer: ApplicationServer; + protected readonly appServer!: ApplicationServer; @inject(CommandRegistry) - protected readonly commandRegistry: CommandRegistry; + protected readonly commandRegistry!: CommandRegistry; @inject(EnvVariablesServer) - protected readonly environments: EnvVariablesServer; + protected readonly environments!: EnvVariablesServer; @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(WindowService) - protected readonly windowService: WindowService; + protected readonly windowService!: WindowService; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @postConstruct() protected async init(): Promise { diff --git a/packages/git/src/browser/blame/blame-contribution.ts b/packages/git/src/browser/blame/blame-contribution.ts index 506f8b6f6d94b..246c7af4e7681 100644 --- a/packages/git/src/browser/blame/blame-contribution.ts +++ b/packages/git/src/browser/blame/blame-contribution.ts @@ -40,13 +40,13 @@ export namespace BlameCommands { export class BlameContribution implements CommandContribution, KeybindingContribution, MenuContribution { @inject(EditorManager) - protected readonly editorManager: EditorManager; + protected readonly editorManager!: EditorManager; @inject(BlameDecorator) - protected readonly decorator: BlameDecorator; + protected readonly decorator!: BlameDecorator; @inject(BlameManager) - protected readonly blameManager: BlameManager; + protected readonly blameManager!: BlameManager; registerCommands(commands: CommandRegistry): void { commands.registerCommand(BlameCommands.TOGGLE_GIT_ANNOTATIONS, { @@ -160,10 +160,10 @@ export class BlameContribution implements CommandContribution, KeybindingContrib export class BlameAnnotationsKeybindingContext extends EditorTextFocusContext { @inject(BlameContribution) - protected readonly blameContribution: BlameContribution; + protected readonly blameContribution!: BlameContribution; @inject(StrictEditorTextFocusContext) - protected readonly base: StrictEditorTextFocusContext; + protected readonly base!: StrictEditorTextFocusContext; id = BlameAnnotationsKeybindingContext.showsBlameAnnotations; diff --git a/packages/git/src/browser/blame/blame-decorator.ts b/packages/git/src/browser/blame/blame-decorator.ts index be3d3fb6667d3..65a2f8ec16aa5 100644 --- a/packages/git/src/browser/blame/blame-decorator.ts +++ b/packages/git/src/browser/blame/blame-decorator.ts @@ -25,7 +25,7 @@ import URI from '@theia/core/lib/common/uri'; export class BlameDecorator implements monaco.languages.HoverProvider { @inject(EditorManager) - protected readonly editorManager: EditorManager; + protected readonly editorManager!: EditorManager; protected registerHoverProvider(uri: string): Disposable { return monaco.languages.registerHoverProvider([{ pattern: new URI(uri).path.toString() }], this); diff --git a/packages/git/src/browser/blame/blame-manager.ts b/packages/git/src/browser/blame/blame-manager.ts index 1a68be6564c8c..52beaf2af905c 100644 --- a/packages/git/src/browser/blame/blame-manager.ts +++ b/packages/git/src/browser/blame/blame-manager.ts @@ -23,10 +23,10 @@ import URI from '@theia/core/lib/common/uri'; export class BlameManager { @inject(Git) - protected readonly git: Git; + protected readonly git!: Git; @inject(GitRepositoryTracker) - protected readonly repositoryTracker: GitRepositoryTracker; + protected readonly repositoryTracker!: GitRepositoryTracker; isBlameable(uri: string): boolean { return !!this.repositoryTracker.getPath(new URI(uri)); diff --git a/packages/git/src/browser/diff/git-diff-contribution.ts b/packages/git/src/browser/diff/git-diff-contribution.ts index d6bc711401921..43d0309de252d 100644 --- a/packages/git/src/browser/diff/git-diff-contribution.ts +++ b/packages/git/src/browser/diff/git-diff-contribution.ts @@ -81,16 +81,16 @@ export namespace ScmNavigatorMoreToolbarGroups { export class GitDiffContribution extends AbstractViewContribution implements TabBarToolbarContribution { @inject(EditorManager) - protected readonly editorManager: EditorManager; + protected readonly editorManager!: EditorManager; @inject(CommandRegistry) - protected readonly commandRegistry: CommandRegistry; + protected readonly commandRegistry!: CommandRegistry; @inject(FileNavigatorContribution) - protected readonly fileNavigatorContribution: FileNavigatorContribution; + protected readonly fileNavigatorContribution!: FileNavigatorContribution; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; constructor( @inject(SelectionService) protected readonly selectionService: SelectionService, diff --git a/packages/git/src/browser/diff/git-diff-header-widget.tsx b/packages/git/src/browser/diff/git-diff-header-widget.tsx index 67e5652841d28..382ebca2e7125 100644 --- a/packages/git/src/browser/diff/git-diff-header-widget.tsx +++ b/packages/git/src/browser/diff/git-diff-header-widget.tsx @@ -28,17 +28,14 @@ import * as React from '@theia/core/shared/react'; @injectable() export class GitDiffHeaderWidget extends ReactWidget implements StatefulWidget { - @inject(KeybindingRegistry) protected readonly keybindings: KeybindingRegistry; - @inject(ScmService) protected readonly scmService: ScmService; - @inject(LabelProvider) protected readonly labelProvider: LabelProvider; - @inject(ScmFileChangeLabelProvider) protected readonly scmLabelProvider: ScmFileChangeLabelProvider; + @inject(KeybindingRegistry) protected readonly keybindings!: KeybindingRegistry; + @inject(ScmService) protected readonly scmService!: ScmService; + @inject(LabelProvider) protected readonly labelProvider!: LabelProvider; + @inject(ScmFileChangeLabelProvider) protected readonly scmLabelProvider!: ScmFileChangeLabelProvider; - protected options: Git.Options.Diff; + protected options?: Git.Options.Diff; - protected authorAvatar: string; - - constructor( - ) { + constructor() { super(); this.id = 'git-diff-header'; this.title.closable = true; @@ -96,7 +93,7 @@ export class GitDiffHeaderWidget extends ReactWidget implements StatefulWidget { }); } protected renderPath(): React.ReactNode { - if (this.options.uri) { + if (this.options && this.options.uri) { const path = this.scmLabelProvider.relativePath(this.options.uri); if (path.length > 0) { return '/' + path; @@ -136,11 +133,11 @@ export class GitDiffHeaderWidget extends ReactWidget implements StatefulWidget { } protected get toRevision(): string | undefined { - return this.options.range && this.options.range.toRevision; + return this.options?.range?.toRevision; } protected get fromRevision(): string | number | undefined { - return this.options.range && this.options.range.fromRevision; + return this.options?.range?.fromRevision; } storeState(): object { diff --git a/packages/git/src/browser/diff/git-diff-tree-model.tsx b/packages/git/src/browser/diff/git-diff-tree-model.tsx index 58a363d2c46fa..d0426347ff5f7 100644 --- a/packages/git/src/browser/diff/git-diff-tree-model.tsx +++ b/packages/git/src/browser/diff/git-diff-tree-model.tsx @@ -28,11 +28,11 @@ import { GitResourceOpener } from './git-resource-opener'; @injectable() export class GitDiffTreeModel extends ScmTreeModel { - @inject(Git) protected readonly git: Git; - @inject(ScmService) protected readonly scmService: ScmService; - @inject(GitResourceOpener) protected readonly resourceOpener: GitResourceOpener; + @inject(Git) protected readonly git!: Git; + @inject(ScmService) protected readonly scmService!: ScmService; + @inject(GitResourceOpener) protected readonly resourceOpener!: GitResourceOpener; - protected diffOptions: Git.Options.Diff; + protected diffOptions: Git.Options.Diff = {}; protected _groups: ScmResourceGroup[] = []; diff --git a/packages/git/src/browser/diff/git-diff-widget.tsx b/packages/git/src/browser/diff/git-diff-widget.tsx index f03a728c51bc7..a15f6675ecac8 100644 --- a/packages/git/src/browser/diff/git-diff-widget.tsx +++ b/packages/git/src/browser/diff/git-diff-widget.tsx @@ -35,17 +35,17 @@ export class GitDiffWidget extends BaseWidget implements StatefulWidget { protected readonly GIT_DIFF_TITLE = 'Diff'; - @inject(GitRepositoryProvider) protected readonly repositoryProvider: GitRepositoryProvider; - @inject(DiffNavigatorProvider) protected readonly diffNavigatorProvider: DiffNavigatorProvider; - @inject(EditorManager) protected readonly editorManager: EditorManager; - @inject(GitWatcher) protected readonly gitWatcher: GitWatcher; - @inject(GitDiffHeaderWidget) protected readonly diffHeaderWidget: GitDiffHeaderWidget; - @inject(ScmTreeWidget) protected readonly resourceWidget: ScmTreeWidget; - @inject(GitDiffTreeModel) protected readonly model: GitDiffTreeModel; - @inject(ScmService) protected readonly scmService: ScmService; - @inject(ScmPreferences) protected readonly scmPreferences: ScmPreferences; - - protected panel: Panel; + @inject(GitRepositoryProvider) protected readonly repositoryProvider!: GitRepositoryProvider; + @inject(DiffNavigatorProvider) protected readonly diffNavigatorProvider!: DiffNavigatorProvider; + @inject(EditorManager) protected readonly editorManager!: EditorManager; + @inject(GitWatcher) protected readonly gitWatcher!: GitWatcher; + @inject(GitDiffHeaderWidget) protected readonly diffHeaderWidget!: GitDiffHeaderWidget; + @inject(ScmTreeWidget) protected readonly resourceWidget!: ScmTreeWidget; + @inject(GitDiffTreeModel) protected readonly model!: GitDiffTreeModel; + @inject(ScmService) protected readonly scmService!: ScmService; + @inject(ScmPreferences) protected readonly scmPreferences!: ScmPreferences; + + protected panel!: Panel; constructor() { super(); diff --git a/packages/git/src/browser/diff/git-opener-in-primary-area.ts b/packages/git/src/browser/diff/git-opener-in-primary-area.ts index efc08941a58a9..0de4228604d31 100644 --- a/packages/git/src/browser/diff/git-opener-in-primary-area.ts +++ b/packages/git/src/browser/diff/git-opener-in-primary-area.ts @@ -21,7 +21,7 @@ import URI from '@theia/core/lib/common/uri'; @injectable() export class GitOpenerInPrimaryArea implements GitResourceOpener { - @inject(EditorManager) protected readonly editorManager: EditorManager; + @inject(EditorManager) protected readonly editorManager!: EditorManager; async open(changeUri: URI): Promise { await this.editorManager.open(changeUri, { mode: 'reveal' }); diff --git a/packages/git/src/browser/dirty-diff/dirty-diff-manager.ts b/packages/git/src/browser/dirty-diff/dirty-diff-manager.ts index ca686e1338876..c171b2d470915 100644 --- a/packages/git/src/browser/dirty-diff/dirty-diff-manager.ts +++ b/packages/git/src/browser/dirty-diff/dirty-diff-manager.ts @@ -39,19 +39,19 @@ export class DirtyDiffManager { readonly onDirtyDiffUpdate: Event = this.onDirtyDiffUpdateEmitter.event; @inject(Git) - protected readonly git: Git; + protected readonly git!: Git; @inject(GitRepositoryTracker) - protected readonly repositoryTracker: GitRepositoryTracker; + protected readonly repositoryTracker!: GitRepositoryTracker; @inject(GitResourceResolver) - protected readonly gitResourceResolver: GitResourceResolver; + protected readonly gitResourceResolver!: GitResourceResolver; @inject(EditorManager) - protected readonly editorManager: EditorManager; + protected readonly editorManager!: EditorManager; @inject(GitPreferences) - protected readonly preferences: GitPreferences; + protected readonly preferences!: GitPreferences; @postConstruct() protected async initialize(): Promise { @@ -132,7 +132,7 @@ export class DirtyDiffModel implements Disposable { protected toDispose = new DisposableCollection(); protected enabled = true; - protected staged: boolean; + protected staged: boolean = false; protected previousContent: ContentLines | undefined; protected currentContent: ContentLines | undefined; diff --git a/packages/git/src/browser/git-contribution.ts b/packages/git/src/browser/git-contribution.ts index b508290d14b30..7f27c263ca116 100644 --- a/packages/git/src/browser/git-contribution.ts +++ b/packages/git/src/browser/git-contribution.ts @@ -267,19 +267,19 @@ export class GitContribution implements CommandContribution, MenuContribution, T protected toDispose = new DisposableCollection(); - @inject(EditorManager) protected readonly editorManager: EditorManager; - @inject(GitQuickOpenService) protected readonly quickOpenService: GitQuickOpenService; - @inject(GitRepositoryTracker) protected readonly repositoryTracker: GitRepositoryTracker; - @inject(GitSyncService) protected readonly syncService: GitSyncService; - @inject(WorkspaceService) protected readonly workspaceService: WorkspaceService; - @inject(GitRepositoryProvider) protected readonly repositoryProvider: GitRepositoryProvider; - @inject(Git) protected readonly git: Git; - @inject(GitErrorHandler) protected readonly gitErrorHandler: GitErrorHandler; - @inject(CommandRegistry) protected readonly commands: CommandRegistry; - @inject(ProgressService) protected readonly progressService: ProgressService; - @inject(GitPreferences) protected readonly gitPreferences: GitPreferences; - @inject(DecorationsService) protected readonly decorationsService: DecorationsService; - @inject(GitDecorationProvider) protected readonly gitDecorationProvider: GitDecorationProvider; + @inject(EditorManager) protected readonly editorManager!: EditorManager; + @inject(GitQuickOpenService) protected readonly quickOpenService!: GitQuickOpenService; + @inject(GitRepositoryTracker) protected readonly repositoryTracker!: GitRepositoryTracker; + @inject(GitSyncService) protected readonly syncService!: GitSyncService; + @inject(WorkspaceService) protected readonly workspaceService!: WorkspaceService; + @inject(GitRepositoryProvider) protected readonly repositoryProvider!: GitRepositoryProvider; + @inject(Git) protected readonly git!: Git; + @inject(GitErrorHandler) protected readonly gitErrorHandler!: GitErrorHandler; + @inject(CommandRegistry) protected readonly commands!: CommandRegistry; + @inject(ProgressService) protected readonly progressService!: ProgressService; + @inject(GitPreferences) protected readonly gitPreferences!: GitPreferences; + @inject(DecorationsService) protected readonly decorationsService!: DecorationsService; + @inject(GitDecorationProvider) protected readonly gitDecorationProvider!: GitDecorationProvider; onStart(): void { this.updateStatusBar(); diff --git a/packages/git/src/browser/git-error-handler.ts b/packages/git/src/browser/git-error-handler.ts index 3585ee2fd5266..ffc34cead80d2 100644 --- a/packages/git/src/browser/git-error-handler.ts +++ b/packages/git/src/browser/git-error-handler.ts @@ -20,7 +20,7 @@ import { MessageService } from '@theia/core'; @injectable() export class GitErrorHandler { - @inject(MessageService) protected readonly messageService: MessageService; + @inject(MessageService) protected readonly messageService!: MessageService; // eslint-disable-next-line @typescript-eslint/no-explicit-any public handleError(error: any): void { diff --git a/packages/git/src/browser/git-quick-open-service.ts b/packages/git/src/browser/git-quick-open-service.ts index 11ef547f80e1b..df8cb0343959c 100644 --- a/packages/git/src/browser/git-quick-open-service.ts +++ b/packages/git/src/browser/git-quick-open-service.ts @@ -39,16 +39,16 @@ export enum GitAction { @injectable() export class GitQuickOpenService { - @inject(GitErrorHandler) protected readonly gitErrorHandler: GitErrorHandler; - @inject(ProgressService) protected readonly progressService: ProgressService; - @inject(LabelProvider) protected readonly labelProvider: LabelProvider; + @inject(GitErrorHandler) protected readonly gitErrorHandler!: GitErrorHandler; + @inject(ProgressService) protected readonly progressService!: ProgressService; + @inject(LabelProvider) protected readonly labelProvider!: LabelProvider; - @inject(Git) protected readonly git: Git; - @inject(GitRepositoryProvider) protected readonly repositoryProvider: GitRepositoryProvider; - @inject(QuickInputService) @optional() protected readonly quickInputService: QuickInputService; - @inject(MessageService) protected readonly messageService: MessageService; - @inject(WorkspaceService) protected readonly workspaceService: WorkspaceService; - @inject(FileService) protected readonly fileService: FileService; + @inject(Git) protected readonly git!: Git; + @inject(GitRepositoryProvider) protected readonly repositoryProvider!: GitRepositoryProvider; + @inject(QuickInputService) @optional() protected readonly quickInputService?: QuickInputService; + @inject(MessageService) protected readonly messageService!: MessageService; + @inject(WorkspaceService) protected readonly workspaceService!: WorkspaceService; + @inject(FileService) protected readonly fileService!: FileService; async clone(url?: string, folder?: string, branch?: string): Promise { return this.withProgress(async () => { @@ -539,13 +539,13 @@ export class GitQuickOpenService { }); } - protected withProgress(fn: (...arg: In[]) => Promise): Promise { + protected withProgress(fn: (...arg: A) => Promise): Promise { return this.progressService.withProgress('', 'scm', fn); } - protected readonly wrapWithProgress = (fn: (...args: In[]) => Promise) => this.doWrapWithProgress(fn); - protected doWrapWithProgress(fn: (...args: In[]) => Promise): (...args: In[]) => Promise { - return (...args: In[]) => this.withProgress(() => fn(...args)); + protected readonly wrapWithProgress = (fn: (...args: A) => Promise) => this.doWrapWithProgress(fn); + protected doWrapWithProgress(fn: (...args: A) => Promise): (...args: A) => Promise { + return (...args) => this.withProgress(() => fn(...args)); } } @@ -553,15 +553,14 @@ class GitQuickPickItem implements QuickPickItem { readonly execute?: () => void; constructor( public label: string, - execute?: (item: QuickPickItem) => void, + execute?: (item: GitQuickPickItem) => void, public readonly ref?: T, public description?: string, public alwaysShow = true, - public sortByLabel = false) { - this.execute = execute ? createExecFunction(execute, this) : undefined; + public sortByLabel = false + ) { + if (execute) { + this.execute = () => execute(this); + } } } - -function createExecFunction(f: (item: QuickPickItem) => void, item: QuickPickItem): () => void { - return () => { f(item); }; -} diff --git a/packages/git/src/browser/git-repository-provider.ts b/packages/git/src/browser/git-repository-provider.ts index 3ca8eef3b65b0..dc646a8c03544 100644 --- a/packages/git/src/browser/git-repository-provider.ts +++ b/packages/git/src/browser/git-repository-provider.ts @@ -39,18 +39,18 @@ export class GitRepositoryProvider { protected readonly allRepoStorageKey = 'theia-git-all-repositories'; @inject(GitScmProvider.Factory) - protected readonly scmProviderFactory: GitScmProvider.Factory; + protected readonly scmProviderFactory!: GitScmProvider.Factory; @inject(GitCommitMessageValidator) - protected readonly commitMessageValidator: GitCommitMessageValidator; + protected readonly commitMessageValidator!: GitCommitMessageValidator; - @inject(Git) protected readonly git: Git; - @inject(WorkspaceService) protected readonly workspaceService: WorkspaceService; - @inject(ScmService) protected readonly scmService: ScmService; - @inject(StorageService) protected readonly storageService: StorageService; + @inject(Git) protected readonly git!: Git; + @inject(WorkspaceService) protected readonly workspaceService!: WorkspaceService; + @inject(ScmService) protected readonly scmService!: ScmService; + @inject(StorageService) protected readonly storageService!: StorageService; @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; @postConstruct() protected async initialize(): Promise { diff --git a/packages/git/src/browser/git-scm-provider.ts b/packages/git/src/browser/git-scm-provider.ts index d8000649ca96f..1948537565343 100644 --- a/packages/git/src/browser/git-scm-provider.ts +++ b/packages/git/src/browser/git-scm-provider.ts @@ -36,14 +36,18 @@ import { ScmInput } from '@theia/scm/lib/browser/scm-input'; import { nls } from '@theia/core/lib/common/nls'; @injectable() -export class GitScmProviderOptions { - repository: Repository; +export abstract class GitScmProviderOptions { + abstract repository: Repository; } @injectable() export class GitScmProvider implements ScmProvider { - public input: ScmInput; + public input?: ScmInput; + + protected state = GitScmProvider.initState(); + protected _amendSupport!: GitAmendSupport; + protected _statusBarCommands?: ScmCommand[]; protected readonly onDidChangeEmitter = new Emitter(); readonly onDidChange = this.onDidChangeEmitter.event; @@ -64,25 +68,25 @@ export class GitScmProvider implements ScmProvider { ); @inject(EditorManager) - protected readonly editorManager: EditorManager; + protected readonly editorManager!: EditorManager; @inject(GitErrorHandler) - protected readonly gitErrorHandler: GitErrorHandler; + protected readonly gitErrorHandler!: GitErrorHandler; @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; @inject(Git) - protected readonly git: Git; + protected readonly git!: Git; @inject(CommandService) - protected readonly commands: CommandService; + protected readonly commands!: CommandService; @inject(GitScmProviderOptions) - protected readonly options: GitScmProviderOptions; + protected readonly options!: GitScmProviderOptions; @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; readonly id = 'git'; readonly label = nls.localize('vscode.git/package/displayName', 'Git'); @@ -103,7 +107,6 @@ export class GitScmProvider implements ScmProvider { return this.repository.localUri; } - protected _amendSupport: GitAmendSupport; get amendSupport(): GitAmendSupport { return this._amendSupport; } @@ -116,7 +119,6 @@ export class GitScmProvider implements ScmProvider { }; } - protected _statusBarCommands: ScmCommand[] | undefined; get statusBarCommands(): ScmCommand[] | undefined { return this._statusBarCommands; } @@ -125,8 +127,6 @@ export class GitScmProvider implements ScmProvider { this.onDidChangeStatusBarCommandsEmitter.fire(statusBarCommands); } - protected state = GitScmProvider.initState(); - get groups(): ScmResourceGroup[] { return this.state.groups; } @@ -164,12 +164,13 @@ export class GitScmProvider implements ScmProvider { state.groups.push(this.createGroup('index', nls.localize('vscode.git/repository/staged changes', 'Staged changes'), state.stagedChanges, true)); state.groups.push(this.createGroup('workingTree', nls.localize('vscode.git/repository/changes', 'Changes'), state.unstagedChanges, false)); this.state = state; - if (status && status.branch) { - this.input.placeholder = nls.localize('vscode.git/repository/commitMessageWithHeadLabel', 'Message (press {0} to commit on {1})', '{0}', status.branch); - } else { - this.input.placeholder = nls.localize('vscode.git/repository/commitMessage', 'Message (press {0} to commit)'); + if (this.input) { + if (status && status.branch) { + this.input.placeholder = nls.localize('vscode.git/repository/commitMessageWithHeadLabel', 'Message (press {0} to commit on {1})', '{0}', status.branch); + } else { + this.input.placeholder = nls.localize('vscode.git/repository/commitMessage', 'Message (press {0} to commit)'); + } } - this.fireDidChange(); } diff --git a/packages/git/src/browser/git-sync-service.ts b/packages/git/src/browser/git-sync-service.ts index e5cdc2f32af3d..eccf9e9db3814 100644 --- a/packages/git/src/browser/git-sync-service.ts +++ b/packages/git/src/browser/git-sync-service.ts @@ -25,19 +25,19 @@ import { GitErrorHandler } from './git-error-handler'; export class GitSyncService { @inject(Git) - protected readonly git: Git; + protected readonly git!: Git; @inject(GitRepositoryTracker) - protected readonly repositoryTracker: GitRepositoryTracker; + protected readonly repositoryTracker!: GitRepositoryTracker; @inject(MessageService) - protected readonly messageService: MessageService; + protected readonly messageService!: MessageService; @inject(GitErrorHandler) - protected readonly gitErrorHandler: GitErrorHandler; + protected readonly gitErrorHandler!: GitErrorHandler; @inject(QuickInputService) @optional() - protected readonly quickInputService: QuickInputService; + protected readonly quickInputService?: QuickInputService; protected readonly onDidChangeEmitter = new Emitter(); readonly onDidChange: Event = this.onDidChangeEmitter.event; @@ -121,12 +121,9 @@ export class GitSyncService { warning: `This action will override commits in '${upstreamBranch}'.`, detail: 'force-push' }]; - const selectedCWD = await this.quickInputService?.showQuickPick(methods, { placeholder: 'Select current working directory for new terminal' }); - if (await this.confirm('Synchronize Changes', methods.find(({ detail }) => detail === selectedCWD.detail)!.warning)) { - return (selectedCWD.detail as GitSyncService.SyncMethod); - } else { - return (undefined); + if (selectedCWD && await this.confirm('Synchronize Changes', methods.find(({ detail }) => detail === selectedCWD.detail)!.warning)) { + return selectedCWD.detail as GitSyncService.SyncMethod; } } @@ -158,13 +155,16 @@ export class GitSyncService { } } protected async getRemote(repository: Repository, branch: string): Promise { + if (!this.quickInputService) { + return; + } const remotes = await this.git.remote(repository); if (remotes.length === 0) { this.messageService.warn('Your repository has no remotes configured to publish to.'); } - - const selectedRemote = await this.quickInputService?.showQuickPick(remotes.map(remote => ({ label: remote })), - { placeholder: `Pick a remote to publish the branch ${branch} to:` }); + const selectedRemote = await this.quickInputService.showQuickPick(remotes.map(remote => ({ label: remote })), { + placeholder: `Pick a remote to publish the branch ${branch} to:` + }); return selectedRemote.label; } diff --git a/packages/git/src/browser/history/git-commit-detail-header-widget.tsx b/packages/git/src/browser/history/git-commit-detail-header-widget.tsx index 20cb5b8bf8e6e..a492b4a091b9f 100644 --- a/packages/git/src/browser/history/git-commit-detail-header-widget.tsx +++ b/packages/git/src/browser/history/git-commit-detail-header-widget.tsx @@ -24,12 +24,12 @@ import * as React from '@theia/core/shared/react'; @injectable() export class GitCommitDetailHeaderWidget extends ReactWidget { - @inject(KeybindingRegistry) protected readonly keybindings: KeybindingRegistry; - @inject(ScmAvatarService) protected readonly avatarService: ScmAvatarService; + @inject(KeybindingRegistry) protected readonly keybindings!: KeybindingRegistry; + @inject(ScmAvatarService) protected readonly avatarService!: ScmAvatarService; protected options: Git.Options.Diff; - protected authorAvatar: string; + protected authorAvatar?: string; constructor( @inject(GitCommitDetailWidgetOptions) protected readonly commitDetailOptions: GitCommitDetailWidgetOptions diff --git a/packages/git/src/browser/history/git-commit-detail-widget.tsx b/packages/git/src/browser/history/git-commit-detail-widget.tsx index b3edfa2e92e68..2cb1e4cf0fc98 100644 --- a/packages/git/src/browser/history/git-commit-detail-widget.tsx +++ b/packages/git/src/browser/history/git-commit-detail-widget.tsx @@ -31,13 +31,13 @@ import { ScmPreferences } from '@theia/scm/lib/browser/scm-preferences'; @injectable() export class GitCommitDetailWidget extends BaseWidget implements StatefulWidget { - protected panel: Panel; + protected panel!: Panel; - @inject(ScmService) protected readonly scmService: ScmService; - @inject(GitCommitDetailHeaderWidget) protected readonly commitDetailHeaderWidget: GitCommitDetailHeaderWidget; - @inject(ScmTreeWidget) protected readonly resourceWidget: ScmTreeWidget; - @inject(GitDiffTreeModel) protected readonly model: GitDiffTreeModel; - @inject(ScmPreferences) protected readonly scmPreferences: ScmPreferences; + @inject(ScmService) protected readonly scmService!: ScmService; + @inject(GitCommitDetailHeaderWidget) protected readonly commitDetailHeaderWidget!: GitCommitDetailHeaderWidget; + @inject(ScmTreeWidget) protected readonly resourceWidget!: ScmTreeWidget; + @inject(GitDiffTreeModel) protected readonly model!: GitDiffTreeModel; + @inject(ScmPreferences) protected readonly scmPreferences!: ScmPreferences; set viewMode(mode: 'tree' | 'list') { this.resourceWidget.viewMode = mode; diff --git a/packages/git/src/browser/history/git-history-support.ts b/packages/git/src/browser/history/git-history-support.ts index 3d73b9ee75fa3..83ad05f2f821a 100644 --- a/packages/git/src/browser/history/git-history-support.ts +++ b/packages/git/src/browser/history/git-history-support.ts @@ -25,9 +25,9 @@ import { GitRepositoryTracker } from '../git-repository-tracker'; @injectable() export class GitHistorySupport implements ScmHistorySupport { - @inject(GitScmProvider) protected readonly provider: GitScmProvider; - @inject(Git) protected readonly git: Git; - @inject(GitRepositoryTracker) protected readonly repositoryTracker: GitRepositoryTracker; + @inject(GitScmProvider) protected readonly provider!: GitScmProvider; + @inject(Git) protected readonly git!: Git; + @inject(GitRepositoryTracker) protected readonly repositoryTracker!: GitRepositoryTracker; async getCommitHistory(options?: HistoryWidgetOptions): Promise { const repository = this.provider.repository; diff --git a/packages/git/src/browser/history/git-opener-in-secondary-area.ts b/packages/git/src/browser/history/git-opener-in-secondary-area.ts index 4b5e51fdf69b7..c971e7e436749 100644 --- a/packages/git/src/browser/history/git-opener-in-secondary-area.ts +++ b/packages/git/src/browser/history/git-opener-in-secondary-area.ts @@ -22,14 +22,16 @@ import URI from '@theia/core/lib/common/uri'; @injectable() export class GitOpenerInSecondaryArea implements GitResourceOpener { - @inject(EditorManager) protected readonly editorManager: EditorManager; - protected refWidget: Widget; + protected ref: Widget | undefined; + protected refWidget?: Widget; + + @inject(EditorManager) protected readonly editorManager!: EditorManager; + setRefWidget(refWidget: Widget): void { this.refWidget = refWidget; } - protected ref: Widget | undefined; async open(changeUri: URI): Promise { const ref = this.ref; const widget = await this.editorManager.open(changeUri, { diff --git a/packages/git/src/common/git-prompt.ts b/packages/git/src/common/git-prompt.ts index eff81bdaccdc7..bd898cfcc86b6 100644 --- a/packages/git/src/common/git-prompt.ts +++ b/packages/git/src/common/git-prompt.ts @@ -30,7 +30,7 @@ export interface GitPromptServerProxy extends JsonRpcProxy { export class GitPrompt implements GitPromptClient, Disposable { @inject(GitPromptServer) - protected readonly server: GitPromptServer; + protected readonly server!: GitPromptServer; protected readonly toDispose = new DisposableCollection(); @@ -160,7 +160,7 @@ export interface GitPromptClient { export class GitPromptServerImpl implements GitPromptServer { @inject(GitPromptServerProxy) - protected readonly proxy: GitPromptServerProxy; + protected readonly proxy!: GitPromptServerProxy; setClient(client: GitPromptClient): void { this.proxy.setClient(client); diff --git a/packages/git/src/electron-browser/prompt/git-quick-open-prompt.ts b/packages/git/src/electron-browser/prompt/git-quick-open-prompt.ts index 3e0ddffa91c92..c038dd8c5bc46 100644 --- a/packages/git/src/electron-browser/prompt/git-quick-open-prompt.ts +++ b/packages/git/src/electron-browser/prompt/git-quick-open-prompt.ts @@ -23,7 +23,7 @@ import { GitPrompt } from '../../common/git-prompt'; export class GitQuickOpenPrompt extends GitPrompt { @inject(QuickInputService) @optional() - protected readonly quickInputService: QuickInputService; + protected readonly quickInputService?: QuickInputService; protected readonly queue = new PQueue({ autoStart: true, concurrency: 1 }); diff --git a/packages/git/src/electron-node/askpass/askpass.ts b/packages/git/src/electron-node/askpass/askpass.ts index 4c6cc15ad85e9..c3127758e97c8 100644 --- a/packages/git/src/electron-node/askpass/askpass.ts +++ b/packages/git/src/electron-node/askpass/askpass.ts @@ -58,12 +58,12 @@ export interface Address { export class Askpass implements Disposable { @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(DugiteGitPromptServer) - protected readonly promptServer: DugiteGitPromptServer; + protected readonly promptServer!: DugiteGitPromptServer; - protected server: http.Server; + protected server!: http.Server; protected serverAddress: Address | undefined; protected ready = new Deferred(); diff --git a/packages/git/src/electron-node/env/electron-git-env-provider.ts b/packages/git/src/electron-node/env/electron-git-env-provider.ts index be113be8f9e75..e65a5f4ec537a 100644 --- a/packages/git/src/electron-node/env/electron-git-env-provider.ts +++ b/packages/git/src/electron-node/env/electron-git-env-provider.ts @@ -28,7 +28,7 @@ import { Askpass } from '../askpass/askpass'; export class ElectronGitEnvProvider extends DefaultGitEnvProvider { @inject(Askpass) - protected readonly askpass: Askpass; + protected readonly askpass!: Askpass; protected _env: Object | undefined; @postConstruct() diff --git a/packages/git/src/node/dugite-git.ts b/packages/git/src/node/dugite-git.ts index b09bd248a24f5..a4e9b53382f81 100644 --- a/packages/git/src/node/dugite-git.ts +++ b/packages/git/src/node/dugite-git.ts @@ -141,7 +141,7 @@ export class CommitDetailsParser extends OutputParser { CommitPlaceholders.BODY]; @inject(NameStatusParser) - protected readonly nameStatusParser: NameStatusParser; + protected readonly nameStatusParser!: NameStatusParser; parse(repositoryUri: string, input: string | string[], delimiter: string = CommitDetailsParser.COMMIT_CHUNK_DELIMITER): CommitWithChanges[] { const chunks = this.split(input, delimiter); @@ -289,31 +289,31 @@ export class DugiteGit implements Git { protected readonly limit = 1000; @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(GitLocator) - protected readonly locator: GitLocator; + protected readonly locator!: GitLocator; @inject(GitRepositoryManager) - protected readonly manager: GitRepositoryManager; + protected readonly manager!: GitRepositoryManager; @inject(NameStatusParser) - protected readonly nameStatusParser: NameStatusParser; + protected readonly nameStatusParser!: NameStatusParser; @inject(CommitDetailsParser) - protected readonly commitDetailsParser: CommitDetailsParser; + protected readonly commitDetailsParser!: CommitDetailsParser; @inject(GitBlameParser) - protected readonly blameParser: GitBlameParser; + protected readonly blameParser!: GitBlameParser; @inject(GitExecProvider) - protected readonly execProvider: GitExecProvider; + protected readonly execProvider!: GitExecProvider; @inject(GitEnvProvider) - protected readonly envProvider: GitEnvProvider; + protected readonly envProvider!: GitEnvProvider; @inject(GitInit) - protected readonly gitInit: GitInit; + protected readonly gitInit!: GitInit; protected ready: Deferred = new Deferred(); protected gitEnv: Deferred = new Deferred(); diff --git a/packages/git/src/node/git-locator/git-locator-client.ts b/packages/git/src/node/git-locator/git-locator-client.ts index b64022c2a2806..70463bfd7361a 100644 --- a/packages/git/src/node/git-locator/git-locator-client.ts +++ b/packages/git/src/node/git-locator/git-locator-client.ts @@ -26,7 +26,7 @@ export class GitLocatorClient implements GitLocator { protected readonly toDispose = new DisposableCollection(); @inject(IPCConnectionProvider) - protected readonly ipcConnectionProvider: IPCConnectionProvider; + protected readonly ipcConnectionProvider!: IPCConnectionProvider; dispose(): void { this.toDispose.dispose(); diff --git a/packages/git/src/node/git-repository-manager.ts b/packages/git/src/node/git-repository-manager.ts index 34cd2e014c940..96885b9f7848d 100644 --- a/packages/git/src/node/git-repository-manager.ts +++ b/packages/git/src/node/git-repository-manager.ts @@ -23,7 +23,7 @@ import { GitRepositoryWatcher, GitRepositoryWatcherFactory } from './git-reposit export class GitRepositoryManager { @inject(GitRepositoryWatcherFactory) - protected readonly watcherFactory: GitRepositoryWatcherFactory; + protected readonly watcherFactory!: GitRepositoryWatcherFactory; protected readonly watchers = new ReferenceCollection( repository => this.watcherFactory({ repository }) ); diff --git a/packages/git/src/node/git-repository-watcher.ts b/packages/git/src/node/git-repository-watcher.ts index 4ff1ec4a0907c..0cf1a48f0767a 100644 --- a/packages/git/src/node/git-repository-watcher.ts +++ b/packages/git/src/node/git-repository-watcher.ts @@ -24,8 +24,8 @@ export const GitRepositoryWatcherFactory = Symbol('GitRepositoryWatcherFactory') export type GitRepositoryWatcherFactory = (options: GitRepositoryWatcherOptions) => GitRepositoryWatcher; @injectable() -export class GitRepositoryWatcherOptions { - readonly repository: Repository; +export abstract class GitRepositoryWatcherOptions { + abstract readonly repository: Repository; } @injectable() @@ -35,13 +35,13 @@ export class GitRepositoryWatcher implements Disposable { readonly onGitStatusChanged: Event = this.onGitStatusChangedEmitter.event; @inject(Git) - protected readonly git: Git; + protected readonly git!: Git; @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(GitRepositoryWatcherOptions) - protected readonly options: GitRepositoryWatcherOptions; + protected readonly options!: GitRepositoryWatcherOptions; @postConstruct() protected init(): void { diff --git a/packages/git/src/node/init/git-init.ts b/packages/git/src/node/init/git-init.ts index a9a2512d68db0..9551e4f4dabfe 100644 --- a/packages/git/src/node/init/git-init.ts +++ b/packages/git/src/node/init/git-init.ts @@ -46,10 +46,10 @@ export class DefaultGitInit implements GitInit { protected readonly toDispose = new DisposableCollection(); @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(MessageService) - protected readonly messages: MessageService; + protected readonly messages!: MessageService; async init(): Promise { const { env } = process; diff --git a/packages/keymaps/src/browser/keybindings-widget.tsx b/packages/keymaps/src/browser/keybindings-widget.tsx index 30b9b2d8ceab8..88c8dcb488c75 100644 --- a/packages/keymaps/src/browser/keybindings-widget.tsx +++ b/packages/keymaps/src/browser/keybindings-widget.tsx @@ -61,13 +61,13 @@ export interface CellData { export class KeybindingWidget extends ReactWidget { @inject(CommandRegistry) - protected readonly commandRegistry: CommandRegistry; + protected readonly commandRegistry!: CommandRegistry; @inject(KeybindingRegistry) - protected readonly keybindingRegistry: KeybindingRegistry; + protected readonly keybindingRegistry!: KeybindingRegistry; @inject(KeymapsService) - protected readonly keymapsService: KeymapsService; + protected readonly keymapsService!: KeymapsService; static readonly ID = 'keybindings.view.widget'; static readonly LABEL = 'Keyboard Shortcuts'; diff --git a/packages/keymaps/src/browser/keymaps-frontend-contribution.ts b/packages/keymaps/src/browser/keymaps-frontend-contribution.ts index 59820a2edb245..2e8644e7fa944 100644 --- a/packages/keymaps/src/browser/keymaps-frontend-contribution.ts +++ b/packages/keymaps/src/browser/keymaps-frontend-contribution.ts @@ -55,7 +55,7 @@ export namespace KeymapsCommands { export class KeymapsFrontendContribution extends AbstractViewContribution implements CommandContribution, MenuContribution, TabBarToolbarContribution { @inject(KeymapsService) - protected readonly keymaps: KeymapsService; + protected readonly keymaps!: KeymapsService; constructor() { super({ diff --git a/packages/keymaps/src/browser/keymaps-service.ts b/packages/keymaps/src/browser/keymaps-service.ts index 9217594c9bfde..3539829b614e1 100644 --- a/packages/keymaps/src/browser/keymaps-service.ts +++ b/packages/keymaps/src/browser/keymaps-service.ts @@ -32,19 +32,19 @@ import { MessageService } from '@theia/core/lib/common/message-service'; export class KeymapsService { @inject(MonacoWorkspace) - protected readonly workspace: MonacoWorkspace; + protected readonly workspace!: MonacoWorkspace; @inject(MonacoTextModelService) - protected readonly textModelService: MonacoTextModelService; + protected readonly textModelService!: MonacoTextModelService; @inject(KeybindingRegistry) - protected readonly keybindingRegistry: KeybindingRegistry; + protected readonly keybindingRegistry!: KeybindingRegistry; @inject(OpenerService) - protected readonly opener: OpenerService; + protected readonly opener!: OpenerService; @inject(MessageService) - protected readonly messageService: MessageService; + protected readonly messageService!: MessageService; protected readonly changeKeymapEmitter = new Emitter(); readonly onDidChangeKeymaps = this.changeKeymapEmitter.event; diff --git a/packages/markers/src/browser/marker-manager.ts b/packages/markers/src/browser/marker-manager.ts index bafa6c540af39..12229e2fc0cad 100644 --- a/packages/markers/src/browser/marker-manager.ts +++ b/packages/markers/src/browser/marker-manager.ts @@ -117,7 +117,7 @@ export abstract class MarkerManager { protected readonly onDidChangeMarkersEmitter = new Emitter(); @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; @postConstruct() protected init(): void { diff --git a/packages/markers/src/browser/marker-tree-label-provider.ts b/packages/markers/src/browser/marker-tree-label-provider.ts index 538b21e07cd2b..55d1d3343414b 100644 --- a/packages/markers/src/browser/marker-tree-label-provider.ts +++ b/packages/markers/src/browser/marker-tree-label-provider.ts @@ -24,13 +24,13 @@ import { WorkspaceService } from '@theia/workspace/lib/browser'; export class MarkerTreeLabelProvider implements LabelProviderContribution { @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(TreeLabelProvider) - protected readonly treeLabelProvider: TreeLabelProvider; + protected readonly treeLabelProvider!: TreeLabelProvider; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; canHandle(element: object): number { return MarkerInfoNode.is(element) ? diff --git a/packages/markers/src/browser/marker-tree-model.ts b/packages/markers/src/browser/marker-tree-model.ts index 24abe001f8fd5..d8ae9a316b913 100644 --- a/packages/markers/src/browser/marker-tree-model.ts +++ b/packages/markers/src/browser/marker-tree-model.ts @@ -21,7 +21,7 @@ import { TreeModelImpl, OpenerService, open, TreeNode, OpenerOptions } from '@th @injectable() export class MarkerTreeModel extends TreeModelImpl { - @inject(OpenerService) protected readonly openerService: OpenerService; + @inject(OpenerService) protected readonly openerService!: OpenerService; protected doOpenNode(node: TreeNode): void { if (MarkerNode.is(node)) { diff --git a/packages/markers/src/browser/problem/problem-contribution.ts b/packages/markers/src/browser/problem/problem-contribution.ts index bfb5c5c8efee2..158174babd199 100644 --- a/packages/markers/src/browser/problem/problem-contribution.ts +++ b/packages/markers/src/browser/problem/problem-contribution.ts @@ -61,9 +61,9 @@ export namespace ProblemsCommands { @injectable() export class ProblemContribution extends AbstractViewContribution implements FrontendApplicationContribution, TabBarToolbarContribution { - @inject(ProblemManager) protected readonly problemManager: ProblemManager; - @inject(StatusBar) protected readonly statusBar: StatusBar; - @inject(SelectionService) protected readonly selectionService: SelectionService; + @inject(ProblemManager) protected readonly problemManager!: ProblemManager; + @inject(StatusBar) protected readonly statusBar!: StatusBar; + @inject(SelectionService) protected readonly selectionService!: SelectionService; constructor() { super({ diff --git a/packages/markers/src/browser/problem/problem-decorator.ts b/packages/markers/src/browser/problem/problem-decorator.ts index 5501c10f3cc8b..e8aec08523505 100644 --- a/packages/markers/src/browser/problem/problem-decorator.ts +++ b/packages/markers/src/browser/problem/problem-decorator.ts @@ -36,9 +36,9 @@ import { WidgetDecoration } from '@theia/core/lib/browser/widget-decoration'; export class ProblemDecorator implements TreeDecorator { @inject(ProblemPreferences) - protected problemPreferences: ProblemPreferences; - @inject(WorkspaceService) protected readonly workspaceService: WorkspaceService; - @inject(LabelProvider) protected readonly labelProvider: LabelProvider; + protected problemPreferences!: ProblemPreferences; + @inject(WorkspaceService) protected readonly workspaceService!: WorkspaceService; + @inject(LabelProvider) protected readonly labelProvider!: LabelProvider; readonly id = 'theia-problem-decorator'; diff --git a/packages/markers/src/browser/problem/problem-tabbar-decorator.ts b/packages/markers/src/browser/problem/problem-tabbar-decorator.ts index cc59201e24046..9075a41ff79bb 100644 --- a/packages/markers/src/browser/problem/problem-tabbar-decorator.ts +++ b/packages/markers/src/browser/problem/problem-tabbar-decorator.ts @@ -33,10 +33,10 @@ export class ProblemTabBarDecorator implements TabBarDecorator { protected readonly emitter = new Emitter(); @inject(ProblemPreferences) - protected readonly preferences: ProblemPreferences; + protected readonly preferences!: ProblemPreferences; @inject(ProblemManager) - protected readonly problemManager: ProblemManager; + protected readonly problemManager!: ProblemManager; @postConstruct() protected init(): void { diff --git a/packages/markers/src/browser/problem/problem-tree-model.ts b/packages/markers/src/browser/problem/problem-tree-model.ts index 4bf70d0278889..7c241c57a9406 100644 --- a/packages/markers/src/browser/problem/problem-tree-model.ts +++ b/packages/markers/src/browser/problem/problem-tree-model.ts @@ -87,7 +87,7 @@ export class ProblemTree extends MarkerTree { @injectable() export class ProblemTreeModel extends MarkerTreeModel { - @inject(ProblemManager) protected readonly problemManager: ProblemManager; + @inject(ProblemManager) protected readonly problemManager!: ProblemManager; protected getOpenerOptionsByMarker(node: MarkerNode): OpenerOptions | undefined { if (ProblemMarker.is(node.marker)) { diff --git a/packages/markers/src/browser/problem/problem-widget-tab-bar-decorator.ts b/packages/markers/src/browser/problem/problem-widget-tab-bar-decorator.ts index b888260bd8ec5..db1024a21a0b2 100644 --- a/packages/markers/src/browser/problem/problem-widget-tab-bar-decorator.ts +++ b/packages/markers/src/browser/problem/problem-widget-tab-bar-decorator.ts @@ -28,7 +28,7 @@ export class ProblemWidgetTabBarDecorator implements TabBarDecorator { protected readonly emitter = new Emitter(); @inject(ProblemManager) - protected readonly problemManager: ProblemManager; + protected readonly problemManager!: ProblemManager; @postConstruct() protected init(): void { diff --git a/packages/markers/src/browser/problem/problem-widget.tsx b/packages/markers/src/browser/problem/problem-widget.tsx index ff49aa6d7cd75..fe23c2881b1d3 100644 --- a/packages/markers/src/browser/problem/problem-widget.tsx +++ b/packages/markers/src/browser/problem/problem-widget.tsx @@ -37,10 +37,10 @@ export class ProblemWidget extends TreeWidget { protected readonly toDisposeOnCurrentWidgetChanged = new DisposableCollection(); @inject(ProblemPreferences) - protected readonly preferences: ProblemPreferences; + protected readonly preferences!: ProblemPreferences; @inject(ApplicationShell) - protected readonly shell: ApplicationShell; + protected readonly shell!: ApplicationShell; constructor( @inject(ProblemManager) protected readonly problemManager: ProblemManager, diff --git a/packages/messages/src/browser/notifications-contribution.ts b/packages/messages/src/browser/notifications-contribution.ts index aa8f495107b23..973792123f07d 100644 --- a/packages/messages/src/browser/notifications-contribution.ts +++ b/packages/messages/src/browser/notifications-contribution.ts @@ -33,13 +33,13 @@ export class NotificationsContribution implements FrontendApplicationContributio protected readonly id = 'theia-notification-center'; @inject(NotificationManager) - protected readonly manager: NotificationManager; + protected readonly manager!: NotificationManager; @inject(NotificationsRenderer) - protected readonly notificationsRenderer: NotificationsRenderer; // required for initialization + protected readonly notificationsRenderer!: NotificationsRenderer; // required for initialization @inject(StatusBar) - protected readonly statusBar: StatusBar; + protected readonly statusBar!: StatusBar; onStart(_app: FrontendApplication): void { this.createStatusBarItem(); @@ -179,7 +179,7 @@ export class NotificationsContribution implements FrontendApplicationContributio export class NotificationsKeybindingContext implements KeybindingContext { @inject(NotificationManager) - protected readonly manager: NotificationManager; + protected readonly manager!: NotificationManager; readonly id = NotificationsKeybindingContext.notificationsVisible; isEnabled(_arg: Keybinding): boolean { diff --git a/packages/messages/src/browser/notifications-manager.ts b/packages/messages/src/browser/notifications-manager.ts index 7b5fc90f892ab..4f72e8dacfca1 100644 --- a/packages/messages/src/browser/notifications-manager.ts +++ b/packages/messages/src/browser/notifications-manager.ts @@ -52,16 +52,16 @@ export namespace Notification { export class NotificationManager extends MessageClient { @inject(NotificationPreferences) - protected readonly preferences: NotificationPreferences; + protected readonly preferences!: NotificationPreferences; @inject(ContextKeyService) - protected readonly contextKeyService: ContextKeyService; + protected readonly contextKeyService!: ContextKeyService; @inject(OpenerService) - protected readonly openerService: OpenerService; + protected readonly openerService!: OpenerService; @inject(NotificationContentRenderer) - protected readonly contentRenderer: NotificationContentRenderer; + protected readonly contentRenderer!: NotificationContentRenderer; protected readonly onUpdatedEmitter = new Emitter(); readonly onUpdated = this.onUpdatedEmitter.event; @@ -80,8 +80,8 @@ export class NotificationManager extends MessageClient { protected readonly notifications = new Map(); protected readonly toasts = new Map(); - protected notificationToastsVisibleKey: ContextKey; - protected notificationCenterVisibleKey: ContextKey; + protected notificationToastsVisibleKey!: ContextKey; + protected notificationCenterVisibleKey!: ContextKey; @postConstruct() protected async init(): Promise { diff --git a/packages/messages/src/browser/notifications-renderer.tsx b/packages/messages/src/browser/notifications-renderer.tsx index f92d722550d09..5d42107549095 100644 --- a/packages/messages/src/browser/notifications-renderer.tsx +++ b/packages/messages/src/browser/notifications-renderer.tsx @@ -26,13 +26,13 @@ import { NotificationToastsComponent } from './notification-toasts-component'; export class NotificationsRenderer { @inject(ApplicationShell) - protected readonly shell: ApplicationShell; + protected readonly shell!: ApplicationShell; @inject(NotificationManager) - protected readonly manager: NotificationManager; + protected readonly manager!: NotificationManager; @inject(CorePreferences) - protected readonly corePreferences: CorePreferences; + protected readonly corePreferences!: CorePreferences; @postConstruct() protected init(): void { @@ -40,7 +40,7 @@ export class NotificationsRenderer { this.render(); } - protected container: HTMLDivElement; + protected container!: HTMLDivElement; protected createOverlayContainer(): void { this.container = window.document.createElement('div'); this.container.className = 'theia-notifications-overlay'; diff --git a/packages/metrics/src/node/extensions-metrics-contribution.ts b/packages/metrics/src/node/extensions-metrics-contribution.ts index a4e54bf32f465..94e5337c79f33 100644 --- a/packages/metrics/src/node/extensions-metrics-contribution.ts +++ b/packages/metrics/src/node/extensions-metrics-contribution.ts @@ -25,7 +25,7 @@ export class ExtensionMetricsContribution implements MetricsContribution { private metrics: string = ''; @inject(ApplicationPackage) - protected readonly applicationPackage: ApplicationPackage; + protected readonly applicationPackage!: ApplicationPackage; getMetrics(): string { return this.metrics; diff --git a/packages/mini-browser/src/browser/environment/mini-browser-environment.ts b/packages/mini-browser/src/browser/environment/mini-browser-environment.ts index d70b3a9869177..5d0a9241f5fab 100644 --- a/packages/mini-browser/src/browser/environment/mini-browser-environment.ts +++ b/packages/mini-browser/src/browser/environment/mini-browser-environment.ts @@ -28,11 +28,11 @@ import { MiniBrowserEndpoint } from '../../common/mini-browser-endpoint'; @injectable() export class MiniBrowserEnvironment implements FrontendApplicationContribution { - protected _hostPatternPromise: Promise; + protected _hostPatternPromise!: Promise; protected _hostPattern?: string; @inject(EnvVariablesServer) - protected environment: EnvVariablesServer; + protected environment!: EnvVariablesServer; @postConstruct() protected postConstruct(): void { diff --git a/packages/mini-browser/src/browser/location-mapper-service.ts b/packages/mini-browser/src/browser/location-mapper-service.ts index 1322341154204..2d12c0985748b 100644 --- a/packages/mini-browser/src/browser/location-mapper-service.ts +++ b/packages/mini-browser/src/browser/location-mapper-service.ts @@ -49,7 +49,7 @@ export class LocationMapperService { @inject(ContributionProvider) @named(LocationMapper) - protected readonly contributions: ContributionProvider; + protected readonly contributions!: ContributionProvider; async map(location: string): Promise { const contributions = await this.prioritize(location); @@ -129,7 +129,7 @@ export class LocationWithoutSchemeMapper implements LocationMapper { export class FileLocationMapper implements LocationMapper { @inject(MiniBrowserEnvironment) - protected miniBrowserEnvironment: MiniBrowserEnvironment; + protected miniBrowserEnvironment!: MiniBrowserEnvironment; canHandle(location: string): MaybePromise { return location.startsWith('file://') ? 1 : 0; diff --git a/packages/mini-browser/src/browser/mini-browser-content.ts b/packages/mini-browser/src/browser/mini-browser-content.ts index 14f778b30ff78..fd318d3e2f3ac 100644 --- a/packages/mini-browser/src/browser/mini-browser-content.ts +++ b/packages/mini-browser/src/browser/mini-browser-content.ts @@ -163,22 +163,22 @@ export type MiniBrowserContentFactory = (props: MiniBrowserProps) => MiniBrowser export class MiniBrowserContent extends BaseWidget { @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(WindowService) - protected readonly windowService: WindowService; + protected readonly windowService!: WindowService; @inject(LocationMapperService) - protected readonly locationMapper: LocationMapperService; + protected readonly locationMapper!: LocationMapperService; @inject(KeybindingRegistry) - protected readonly keybindings: KeybindingRegistry; + protected readonly keybindings!: KeybindingRegistry; @inject(ApplicationShellMouseTracker) - protected readonly mouseTracker: ApplicationShellMouseTracker; + protected readonly mouseTracker!: ApplicationShellMouseTracker; @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; protected readonly submitInputEmitter = new Emitter(); protected readonly navigateBackEmitter = new Emitter(); @@ -196,7 +196,7 @@ export class MiniBrowserContent extends BaseWidget { // XXX It is a hack. Instead of loading the PDF in an iframe we use `PDFObject` to render it in a div. protected readonly pdfContainer: HTMLElement; - protected frameLoadTimeout: number; + protected frameLoadTimeout?: number; protected readonly initialHistoryLength: number; protected readonly toDisposeOnGo = new DisposableCollection(); diff --git a/packages/mini-browser/src/browser/mini-browser-frontend-security-warnings.ts b/packages/mini-browser/src/browser/mini-browser-frontend-security-warnings.ts index 3f8c33ace2b03..a021be874dcbe 100644 --- a/packages/mini-browser/src/browser/mini-browser-frontend-security-warnings.ts +++ b/packages/mini-browser/src/browser/mini-browser-frontend-security-warnings.ts @@ -27,13 +27,13 @@ import { MiniBrowserEnvironment } from './environment/mini-browser-environment'; export class MiniBrowserFrontendSecurityWarnings implements FrontendApplicationContribution { @inject(WindowService) - protected windowService: WindowService; + protected windowService!: WindowService; @inject(MessageService) - protected messageService: MessageService; + protected messageService!: MessageService; @inject(MiniBrowserEnvironment) - protected miniBrowserEnvironment: MiniBrowserEnvironment; + protected miniBrowserEnvironment!: MiniBrowserEnvironment; initialize(): void { this.checkHostPattern(); diff --git a/packages/mini-browser/src/browser/mini-browser-open-handler.ts b/packages/mini-browser/src/browser/mini-browser-open-handler.ts index 323eca779fde7..b0f32097fa8f6 100644 --- a/packages/mini-browser/src/browser/mini-browser-open-handler.ts +++ b/packages/mini-browser/src/browser/mini-browser-open-handler.ts @@ -86,19 +86,19 @@ export class MiniBrowserOpenHandler extends NavigatableWidgetOpenHandler { diff --git a/packages/mini-browser/src/browser/mini-browser.ts b/packages/mini-browser/src/browser/mini-browser.ts index 5b9538d65d137..0679e3d59ca87 100644 --- a/packages/mini-browser/src/browser/mini-browser.ts +++ b/packages/mini-browser/src/browser/mini-browser.ts @@ -25,8 +25,8 @@ import { MiniBrowserProps, MiniBrowserContentFactory } from './mini-browser-cont export { MiniBrowserProps }; @injectable() -export class MiniBrowserOptions { - uri: URI; +export abstract class MiniBrowserOptions { + abstract uri: URI; } @injectable() @@ -36,10 +36,10 @@ export class MiniBrowser extends BaseWidget implements NavigatableWidget, Statef static ICON = codicon('globe'); @inject(MiniBrowserOptions) - protected readonly options: MiniBrowserOptions; + protected readonly options!: MiniBrowserOptions; @inject(MiniBrowserContentFactory) - protected readonly createContent: MiniBrowserContentFactory; + protected readonly createContent!: MiniBrowserContentFactory; @postConstruct() protected init(): void { diff --git a/packages/mini-browser/src/electron-browser/environment/electron-mini-browser-environment.ts b/packages/mini-browser/src/electron-browser/environment/electron-mini-browser-environment.ts index 7fa7760dd5316..30195fd51333e 100644 --- a/packages/mini-browser/src/electron-browser/environment/electron-mini-browser-environment.ts +++ b/packages/mini-browser/src/electron-browser/environment/electron-mini-browser-environment.ts @@ -24,7 +24,7 @@ import { MiniBrowserEnvironment } from '../../browser/environment/mini-browser-e export class ElectronMiniBrowserEnvironment extends MiniBrowserEnvironment { @inject(ElectronSecurityToken) - protected readonly electronSecurityToken: ElectronSecurityToken; + protected readonly electronSecurityToken!: ElectronSecurityToken; getEndpoint(uuid: string, hostname?: string): Endpoint { const endpoint = super.getEndpoint(uuid, hostname); diff --git a/packages/mini-browser/src/electron-main/mini-browser-electron-main-contribution.ts b/packages/mini-browser/src/electron-main/mini-browser-electron-main-contribution.ts index 371e983fd9e65..9b8c7cd9db1a9 100644 --- a/packages/mini-browser/src/electron-main/mini-browser-electron-main-contribution.ts +++ b/packages/mini-browser/src/electron-main/mini-browser-electron-main-contribution.ts @@ -28,7 +28,7 @@ import { MiniBrowserEndpoint } from '../common/mini-browser-endpoint'; export class MiniBrowserElectronMainContribution implements ElectronMainApplicationContribution { @inject(ElectronSecurityTokenService) - protected readonly electronSecurityTokenService: ElectronSecurityTokenService; + protected readonly electronSecurityTokenService!: ElectronSecurityTokenService; async onStart(app: ElectronMainApplication): Promise { const url = this.getMiniBrowserEndpoint(await app.backendPort); diff --git a/packages/mini-browser/src/node/mini-browser-endpoint.ts b/packages/mini-browser/src/node/mini-browser-endpoint.ts index 559fbdc48429c..bffa215b0d114 100644 --- a/packages/mini-browser/src/node/mini-browser-endpoint.ts +++ b/packages/mini-browser/src/node/mini-browser-endpoint.ts @@ -80,14 +80,14 @@ export class MiniBrowserEndpoint implements BackendApplicationContribution, Mini */ static HANDLE_PATH = '/mini-browser/'; - private attachRequestHandlerPromise: Promise; + private attachRequestHandlerPromise?: Promise; @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(ContributionProvider) @named(MiniBrowserEndpointHandler) - protected readonly contributions: ContributionProvider; + protected readonly contributions!: ContributionProvider; protected readonly handlers: Map = new Map(); @@ -105,6 +105,7 @@ export class MiniBrowserEndpoint implements BackendApplicationContribution, Mini } } })); + // Assumes `configure` was called before. await this.attachRequestHandlerPromise; } diff --git a/packages/mini-browser/src/node/mini-browser-ws-validator.ts b/packages/mini-browser/src/node/mini-browser-ws-validator.ts index 7756e1108094d..89bcccc10c04f 100644 --- a/packages/mini-browser/src/node/mini-browser-ws-validator.ts +++ b/packages/mini-browser/src/node/mini-browser-ws-validator.ts @@ -26,7 +26,7 @@ import { MiniBrowserEndpoint } from '../common/mini-browser-endpoint'; @injectable() export class MiniBrowserWsRequestValidator implements WsRequestValidatorContribution { - protected miniBrowserHostRe: RegExp; + protected miniBrowserHostRe!: RegExp; protected serveSameOrigin: boolean = false; diff --git a/packages/monaco/src/browser/monaco-bulk-edit-service.ts b/packages/monaco/src/browser/monaco-bulk-edit-service.ts index cb03235b59f0a..fec9c48de8cf8 100644 --- a/packages/monaco/src/browser/monaco-bulk-edit-service.ts +++ b/packages/monaco/src/browser/monaco-bulk-edit-service.ts @@ -21,7 +21,7 @@ import { MonacoWorkspace } from './monaco-workspace'; export class MonacoBulkEditService implements monaco.editor.IBulkEditService { @inject(MonacoWorkspace) - protected readonly workspace: MonacoWorkspace; + protected readonly workspace!: MonacoWorkspace; private _previewHandler?: monaco.editor.IBulkEditPreviewHandler; diff --git a/packages/monaco/src/browser/monaco-command-registry.ts b/packages/monaco/src/browser/monaco-command-registry.ts index f78e942aeb1ed..3f87a5bb8a093 100644 --- a/packages/monaco/src/browser/monaco-command-registry.ts +++ b/packages/monaco/src/browser/monaco-command-registry.ts @@ -30,11 +30,11 @@ export interface MonacoEditorCommandHandler { export class MonacoCommandRegistry { @inject(MonacoEditorProvider) - protected readonly monacoEditors: MonacoEditorProvider; + protected readonly monacoEditors!: MonacoEditorProvider; - @inject(CommandRegistry) protected readonly commands: CommandRegistry; + @inject(CommandRegistry) protected readonly commands!: CommandRegistry; - @inject(SelectionService) protected readonly selectionService: SelectionService; + @inject(SelectionService) protected readonly selectionService!: SelectionService; validate(command: string): string | undefined { return this.commands.commandIds.indexOf(command) !== -1 ? command : undefined; diff --git a/packages/monaco/src/browser/monaco-command.ts b/packages/monaco/src/browser/monaco-command.ts index bfb63e75da258..1e47c3e19b3a5 100644 --- a/packages/monaco/src/browser/monaco-command.ts +++ b/packages/monaco/src/browser/monaco-command.ts @@ -50,31 +50,31 @@ export namespace MonacoCommands { export class MonacoEditorCommandHandlers implements CommandContribution { @inject(MonacoCommandRegistry) - protected readonly monacoCommandRegistry: MonacoCommandRegistry; + protected readonly monacoCommandRegistry!: MonacoCommandRegistry; @inject(CommandRegistry) - protected readonly commandRegistry: CommandRegistry; + protected readonly commandRegistry!: CommandRegistry; @inject(ProtocolToMonacoConverter) - protected readonly p2m: ProtocolToMonacoConverter; + protected readonly p2m!: ProtocolToMonacoConverter; @inject(QuickInputService) @optional() - protected readonly quickInputService: QuickInputService; + protected readonly quickInputService?: QuickInputService; @inject(MonacoEditorService) - protected readonly codeEditorService: MonacoEditorService; + protected readonly codeEditorService!: MonacoEditorService; @inject(MonacoTextModelService) - protected readonly textModelService: MonacoTextModelService; + protected readonly textModelService!: MonacoTextModelService; @inject(monaco.contextKeyService.ContextKeyService) - protected readonly contextKeyService: monaco.contextKeyService.ContextKeyService; + protected readonly contextKeyService!: monaco.contextKeyService.ContextKeyService; @inject(ApplicationShell) - protected readonly shell: ApplicationShell; + protected readonly shell!: ApplicationShell; @inject(EditorManager) - protected editorManager: EditorManager; + protected editorManager!: EditorManager; registerCommands(): void { this.registerMonacoCommands(); @@ -230,10 +230,10 @@ export class MonacoEditorCommandHandlers implements CommandContribution { protected configureEol(editor: MonacoEditor): void { const items = ['LF', 'CRLF'].map(lineEnding => - ({ - label: lineEnding, - execute: () => this.setEol(editor, lineEnding) - }) + ({ + label: lineEnding, + execute: () => this.setEol(editor, lineEnding) + }) ); this.quickInputService?.showQuickPick(items, { placeholder: nls.localizeByDefault('Select End of Line Sequence') }); } @@ -260,14 +260,14 @@ export class MonacoEditorCommandHandlers implements CommandContribution { const { tabSize } = model.getOptions(); const sizes = Array.from(Array(8), (_, x) => x + 1); const tabSizeOptions = sizes.map(size => - ({ - label: size === tabSize ? size + ' ' + nls.localizeByDefault('Configured Tab Size') : size.toString(), - // eslint-disable-next-line @typescript-eslint/no-explicit-any - execute: () => model.updateOptions({ - tabSize: size || tabSize, - insertSpaces: useSpaces + ({ + label: size === tabSize ? size + ' ' + nls.localizeByDefault('Configured Tab Size') : size.toString(), + // eslint-disable-next-line @typescript-eslint/no-explicit-any + execute: () => model.updateOptions({ + tabSize: size || tabSize, + insertSpaces: useSpaces + }) }) - }) ); this.quickInputService?.showQuickPick(tabSizeOptions, { placeholder: nls.localizeByDefault('Select Tab Size for Current File') }); } diff --git a/packages/monaco/src/browser/monaco-context-key-service.ts b/packages/monaco/src/browser/monaco-context-key-service.ts index e4f2e1a8b866f..aee18f1ce9d21 100644 --- a/packages/monaco/src/browser/monaco-context-key-service.ts +++ b/packages/monaco/src/browser/monaco-context-key-service.ts @@ -21,7 +21,7 @@ import { ContextKeyService, ContextKey } from '@theia/core/lib/browser/context-k export class MonacoContextKeyService extends ContextKeyService { @inject(monaco.contextKeyService.ContextKeyService) - protected readonly contextKeyService: monaco.contextKeyService.ContextKeyService; + protected readonly contextKeyService!: monaco.contextKeyService.ContextKeyService; @postConstruct() protected init(): void { diff --git a/packages/monaco/src/browser/monaco-diff-editor.ts b/packages/monaco/src/browser/monaco-diff-editor.ts index 45819e2bda2c7..35e42b79cce83 100644 --- a/packages/monaco/src/browser/monaco-diff-editor.ts +++ b/packages/monaco/src/browser/monaco-diff-editor.ts @@ -33,7 +33,8 @@ export namespace MonacoDiffEditor { } export class MonacoDiffEditor extends MonacoEditor { - protected _diffEditor: IStandaloneDiffEditor; + // Assigned when `MonacoEditor` calls `create`. + protected _diffEditor!: IStandaloneDiffEditor; protected _diffNavigator: DiffNavigator; constructor( diff --git a/packages/monaco/src/browser/monaco-editor-model.ts b/packages/monaco/src/browser/monaco-editor-model.ts index c3a2e58ebbcfe..8fef348182267 100644 --- a/packages/monaco/src/browser/monaco-editor-model.ts +++ b/packages/monaco/src/browser/monaco-editor-model.ts @@ -53,9 +53,9 @@ export class MonacoEditorModel implements ITextEditorModel, TextEditorDocument { /* @deprecated there is no general save timeout, each participant should introduce a sensible timeout */ readonly onWillSaveLoopTimeOut = 1500; - protected bufferSavedVersionId: number; + protected bufferSavedVersionId?: number; - protected model: monaco.editor.IModel; + protected _model?: monaco.editor.IModel; protected readonly resolveModel: Promise; protected readonly toDispose = new DisposableCollection(); @@ -102,6 +102,13 @@ export class MonacoEditorModel implements ITextEditorModel, TextEditorDocument { ); } + get model(): monaco.editor.IModel { + if (!this._model) { + throw new Error('MonacoEditorModel._model is not set'); + } + return this._model; + } + dispose(): void { this.toDispose.dispose(); } @@ -162,7 +169,7 @@ export class MonacoEditorModel implements ITextEditorModel, TextEditorDocument { firstLine = value.getFirstLineText(1000); } const languageSelection = monaco.services.StaticServices.modeService.get().createByFilepathOrFirstLine(uri, firstLine); - this.model = monaco.services.StaticServices.modelService.get().createModel(value, languageSelection, uri); + this._model = monaco.services.StaticServices.modelService.get().createModel(value, languageSelection, uri); this.resourceVersion = this.resource.version; this.updateSavedVersionId(); this.toDispose.push(this.model); diff --git a/packages/monaco/src/browser/monaco-editor-provider.ts b/packages/monaco/src/browser/monaco-editor-provider.ts index 28b825ed5bb4b..eb4949228df4f 100644 --- a/packages/monaco/src/browser/monaco-editor-provider.ts +++ b/packages/monaco/src/browser/monaco-editor-provider.ts @@ -54,25 +54,25 @@ export class MonacoEditorProvider { @inject(ContributionProvider) @named(MonacoEditorFactory) - protected readonly factories: ContributionProvider; + protected readonly factories!: ContributionProvider; @inject(MonacoBulkEditService) - protected readonly bulkEditService: MonacoBulkEditService; + protected readonly bulkEditService!: MonacoBulkEditService; @inject(MonacoEditorServices) - protected readonly services: MonacoEditorServices; + protected readonly services!: MonacoEditorServices; @inject(KeybindingRegistry) - protected readonly keybindingRegistry: KeybindingRegistry; + protected readonly keybindingRegistry!: KeybindingRegistry; @inject(OpenerService) - protected readonly openerService: OpenerService; + protected readonly openerService!: OpenerService; @inject(FileSystemPreferences) - protected readonly filePreferences: FileSystemPreferences; + protected readonly filePreferences!: FileSystemPreferences; @inject(MonacoQuickInputImplementation) - protected readonly quickInputService: MonacoQuickInputImplementation; + protected readonly quickInputService!: MonacoQuickInputImplementation; protected _current: MonacoEditor | undefined; /** diff --git a/packages/monaco/src/browser/monaco-editor-service.ts b/packages/monaco/src/browser/monaco-editor-service.ts index 733acaf3c21f2..e836addb290c2 100644 --- a/packages/monaco/src/browser/monaco-editor-service.ts +++ b/packages/monaco/src/browser/monaco-editor-service.ts @@ -34,19 +34,19 @@ export class MonacoEditorService extends monaco.services.CodeEditorServiceImpl { public static readonly ENABLE_PREVIEW_PREFERENCE: string = 'editor.enablePreview'; @inject(OpenerService) - protected readonly openerService: OpenerService; + protected readonly openerService!: OpenerService; @inject(MonacoToProtocolConverter) - protected readonly m2p: MonacoToProtocolConverter; + protected readonly m2p!: MonacoToProtocolConverter; @inject(ApplicationShell) - protected readonly shell: ApplicationShell; + protected readonly shell!: ApplicationShell; @inject(EditorManager) - protected readonly editors: EditorManager; + protected readonly editors!: EditorManager; @inject(PreferenceService) - protected readonly preferencesService: PreferenceService; + protected readonly preferencesService!: PreferenceService; constructor() { super(undefined, monaco.services.StaticServices.standaloneThemeService.get()); diff --git a/packages/monaco/src/browser/monaco-editor.ts b/packages/monaco/src/browser/monaco-editor.ts index 0499900857db8..6cf2b7c9e8107 100644 --- a/packages/monaco/src/browser/monaco-editor.ts +++ b/packages/monaco/src/browser/monaco-editor.ts @@ -53,13 +53,13 @@ import IBoxSizing = ElementExt.IBoxSizing; export class MonacoEditorServices { @inject(MonacoToProtocolConverter) - protected readonly m2p: MonacoToProtocolConverter; + protected readonly m2p!: MonacoToProtocolConverter; @inject(ProtocolToMonacoConverter) - protected readonly p2m: ProtocolToMonacoConverter; + protected readonly p2m!: ProtocolToMonacoConverter; @inject(ContextKeyService) - protected readonly contextKeyService: ContextKeyService; + protected readonly contextKeyService!: ContextKeyService; constructor(@unmanaged() services: MonacoEditorServices) { Object.assign(this, services); @@ -73,7 +73,8 @@ export class MonacoEditor extends MonacoEditorServices implements TextEditor { protected readonly autoSizing: boolean; protected readonly minHeight: number; protected readonly maxHeight: number; - protected editor: IStandaloneCodeEditor; + // Assigned in `create`. + protected editor!: IStandaloneCodeEditor; protected readonly onCursorPositionChangedEmitter = new Emitter(); protected readonly onSelectionChangedEmitter = new Emitter(); @@ -95,7 +96,7 @@ export class MonacoEditor extends MonacoEditorServices implements TextEditor { readonly document: MonacoEditorModel, readonly node: HTMLElement, services: MonacoEditorServices, - options?: MonacoEditor.IOptions, + options: MonacoEditor.IOptions = {}, override?: IEditorOverrideServices ) { super(services); diff --git a/packages/monaco/src/browser/monaco-formatting-conflicts.ts b/packages/monaco/src/browser/monaco-formatting-conflicts.ts index d2d36c38d468f..7eed2ae202bf5 100644 --- a/packages/monaco/src/browser/monaco-formatting-conflicts.ts +++ b/packages/monaco/src/browser/monaco-formatting-conflicts.ts @@ -27,16 +27,16 @@ const PREFERENCE_NAME = 'editor.defaultFormatter'; export class MonacoFormattingConflictsContribution implements FrontendApplicationContribution { @inject(MonacoQuickInputService) - protected readonly monacoQuickInputService: MonacoQuickInputService; + protected readonly monacoQuickInputService!: MonacoQuickInputService; @inject(PreferenceService) - protected readonly preferenceService: PreferenceService; + protected readonly preferenceService!: PreferenceService; @inject(PreferenceLanguageOverrideService) - protected readonly preferenceSchema: PreferenceLanguageOverrideService; + protected readonly preferenceSchema!: PreferenceLanguageOverrideService; @inject(EditorManager) - protected readonly editorManager: EditorManager; + protected readonly editorManager!: EditorManager; async initialize(): Promise { monaco.format.FormattingConflicts.setFormatterSelector(( diff --git a/packages/monaco/src/browser/monaco-frontend-application-contribution.ts b/packages/monaco/src/browser/monaco-frontend-application-contribution.ts index b38ec291e9ba5..b9e14ff5cdf6f 100644 --- a/packages/monaco/src/browser/monaco-frontend-application-contribution.ts +++ b/packages/monaco/src/browser/monaco-frontend-application-contribution.ts @@ -22,10 +22,10 @@ import { MonacoSnippetSuggestProvider } from './monaco-snippet-suggest-provider' export class MonacoFrontendApplicationContribution implements FrontendApplicationContribution { @inject(MonacoSnippetSuggestProvider) - protected readonly snippetSuggestProvider: MonacoSnippetSuggestProvider; + protected readonly snippetSuggestProvider!: MonacoSnippetSuggestProvider; @inject(PreferenceSchemaProvider) - protected readonly preferenceSchema: PreferenceSchemaProvider; + protected readonly preferenceSchema!: PreferenceSchemaProvider; async initialize(): Promise { monaco.suggest.setSnippetSuggestSupport(this.snippetSuggestProvider); diff --git a/packages/monaco/src/browser/monaco-keybinding.ts b/packages/monaco/src/browser/monaco-keybinding.ts index d508c1f8a8a03..d85b1f9c54598 100644 --- a/packages/monaco/src/browser/monaco-keybinding.ts +++ b/packages/monaco/src/browser/monaco-keybinding.ts @@ -25,7 +25,7 @@ import { MonacoResolvedKeybinding } from './monaco-resolved-keybinding'; export class MonacoKeybindingContribution implements KeybindingContribution { @inject(MonacoCommandRegistry) - protected readonly commands: MonacoCommandRegistry; + protected readonly commands!: MonacoCommandRegistry; registerKeybindings(registry: KeybindingRegistry): void { const defaultKeybindings = monaco.keybindings.KeybindingsRegistry.getDefaultKeybindings(); diff --git a/packages/monaco/src/browser/monaco-languages.ts b/packages/monaco/src/browser/monaco-languages.ts index 4e7e55d8d9838..db298c95bd2df 100644 --- a/packages/monaco/src/browser/monaco-languages.ts +++ b/packages/monaco/src/browser/monaco-languages.ts @@ -38,8 +38,8 @@ export class MonacoLanguages implements LanguageService { protected readonly makers = new Map(); - @inject(ProblemManager) protected readonly problemManager: ProblemManager; - @inject(ProtocolToMonacoConverter) protected readonly p2m: ProtocolToMonacoConverter; + @inject(ProblemManager) protected readonly problemManager!: ProblemManager; + @inject(ProtocolToMonacoConverter) protected readonly p2m!: ProtocolToMonacoConverter; @postConstruct() protected init(): void { diff --git a/packages/monaco/src/browser/monaco-outline-contribution.ts b/packages/monaco/src/browser/monaco-outline-contribution.ts index c8cdbe3b10943..07d7a5f25f2f8 100644 --- a/packages/monaco/src/browser/monaco-outline-contribution.ts +++ b/packages/monaco/src/browser/monaco-outline-contribution.ts @@ -37,8 +37,8 @@ export class MonacoOutlineContribution implements FrontendApplicationContributio protected roots: MonacoOutlineSymbolInformationNode[] | undefined; protected canUpdateOutline: boolean = true; - @inject(OutlineViewService) protected readonly outlineViewService: OutlineViewService; - @inject(EditorManager) protected readonly editorManager: EditorManager; + @inject(OutlineViewService) protected readonly outlineViewService!: OutlineViewService; + @inject(EditorManager) protected readonly editorManager!: EditorManager; onStart(app: FrontendApplication): void { diff --git a/packages/monaco/src/browser/monaco-quick-access-registry.ts b/packages/monaco/src/browser/monaco-quick-access-registry.ts index 80a843ad8dd48..0b142f95298dd 100644 --- a/packages/monaco/src/browser/monaco-quick-access-registry.ts +++ b/packages/monaco/src/browser/monaco-quick-access-registry.ts @@ -41,14 +41,14 @@ class TheiaQuickAccessDescriptor implements monaco.quickInput.IQuickAccessProvid @injectable() export class MonacoQuickAccessRegistry implements QuickAccessRegistry { @inject(KeybindingRegistry) - protected readonly keybindingRegistry: KeybindingRegistry; + protected readonly keybindingRegistry!: KeybindingRegistry; private get monacoRegistry(): monaco.quickInput.IQuickAccessRegistry { return monaco.platform.Registry.as('workbench.contributions.quickaccess'); } registerQuickAccessProvider(descriptor: QuickAccessProviderDescriptor): Disposable { - const toMonacoPick = (item: QuickPickItem): monaco.quickInput.Pick => { + const toMonacoPick = (item: QuickPickItem | QuickPickSeparator): monaco.quickInput.Pick => { if (QuickPickSeparator.is(item)) { return item; } else { diff --git a/packages/monaco/src/browser/monaco-quick-input-service.ts b/packages/monaco/src/browser/monaco-quick-input-service.ts index 0da742ee100db..928a3b8c0e7b8 100644 --- a/packages/monaco/src/browser/monaco-quick-input-service.ts +++ b/packages/monaco/src/browser/monaco-quick-input-service.ts @@ -27,14 +27,14 @@ import { MonacoResolvedKeybinding } from './monaco-resolved-keybinding'; @injectable() export class MonacoQuickInputImplementation implements monaco.quickInput.IQuickInputService { - controller: monaco.quickInput.QuickInputController; + controller!: monaco.quickInput.QuickInputController; quickAccess: monaco.quickInput.IQuickAccessController; @inject(monaco.contextKeyService.ContextKeyService) - protected readonly contextKeyService: monaco.contextKeyService.ContextKeyService; + protected readonly contextKeyService!: monaco.contextKeyService.ContextKeyService; - protected container: HTMLElement; - private quickInputList: monaco.list.List; + protected container!: HTMLElement; + private quickInputList?: monaco.list.List; get backButton(): monaco.quickInput.IQuickInputButton { return this.controller.backButton; } get onShow(): Event { return this.controller.onShow; } @@ -63,7 +63,7 @@ export class MonacoQuickInputImplementation implements monaco.quickInput.IQuickI open(filter: string): void { this.quickAccess.show(filter); setTimeout(() => { - this.quickInputList.focusNth(0); + this.quickInputList?.focusNth(0); }, 300); } @@ -162,10 +162,10 @@ export class MonacoQuickInputImplementation implements monaco.quickInput.IQuickI @injectable() export class MonacoQuickInputService implements QuickInputService { @inject(MonacoQuickInputImplementation) - private monacoService: MonacoQuickInputImplementation; + private monacoService!: MonacoQuickInputImplementation; @inject(KeybindingRegistry) - protected readonly keybindingRegistry: KeybindingRegistry; + protected readonly keybindingRegistry!: KeybindingRegistry; get backButton(): QuickInputButton { return this.monacoService.backButton; @@ -494,4 +494,3 @@ export class MonacoQuickPickItem implements monaco.quic } } } - diff --git a/packages/monaco/src/browser/monaco-snippet-suggest-provider.ts b/packages/monaco/src/browser/monaco-snippet-suggest-provider.ts index ef8deec4a59ce..1d4a22ffdd37a 100644 --- a/packages/monaco/src/browser/monaco-snippet-suggest-provider.ts +++ b/packages/monaco/src/browser/monaco-snippet-suggest-provider.ts @@ -31,7 +31,7 @@ export class MonacoSnippetSuggestProvider implements monaco.languages.Completion private static readonly _maxPrefix = 10000; @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; protected readonly snippets = new Map(); protected readonly pendingSnippets = new Map[]>(); diff --git a/packages/monaco/src/browser/monaco-text-model-service.ts b/packages/monaco/src/browser/monaco-text-model-service.ts index 2aae7719525cc..18bccd2569533 100644 --- a/packages/monaco/src/browser/monaco-text-model-service.ts +++ b/packages/monaco/src/browser/monaco-text-model-service.ts @@ -52,23 +52,23 @@ export class MonacoTextModelService implements monaco.editor.ITextModelService { ); @inject(ResourceProvider) - protected readonly resourceProvider: ResourceProvider; + protected readonly resourceProvider!: ResourceProvider; @inject(EditorPreferences) - protected readonly editorPreferences: EditorPreferences; + protected readonly editorPreferences!: EditorPreferences; @inject(MonacoToProtocolConverter) - protected readonly m2p: MonacoToProtocolConverter; + protected readonly m2p!: MonacoToProtocolConverter; @inject(ProtocolToMonacoConverter) - protected readonly p2m: ProtocolToMonacoConverter; + protected readonly p2m!: ProtocolToMonacoConverter; @inject(ContributionProvider) @named(MonacoEditorModelFactory) - protected readonly factories: ContributionProvider; + protected readonly factories!: ContributionProvider; @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(ApplicationServer) protected readonly applicationServer!: ApplicationServer; diff --git a/packages/monaco/src/browser/monaco-theming-service.ts b/packages/monaco/src/browser/monaco-theming-service.ts index 4e38a3409246d..42d2bb2a3abc4 100644 --- a/packages/monaco/src/browser/monaco-theming-service.ts +++ b/packages/monaco/src/browser/monaco-theming-service.ts @@ -59,7 +59,7 @@ export interface MonacoThemeJson { export class MonacoThemingService { @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; register(theme: MonacoTheme, pending: { [uri: string]: Promise } = {}): Disposable { const toDispose = new DisposableCollection(Disposable.create(() => { /* mark as not disposed */ })); diff --git a/packages/monaco/src/browser/monaco-workspace.ts b/packages/monaco/src/browser/monaco-workspace.ts index a24325bc45757..3e934fbf1c2c5 100644 --- a/packages/monaco/src/browser/monaco-workspace.ts +++ b/packages/monaco/src/browser/monaco-workspace.ts @@ -77,7 +77,7 @@ export interface WorkspaceFolder { @injectable() export class MonacoWorkspace { - protected resolveReady: () => void; + protected resolveReady!: () => void; readonly ready = new Promise(resolve => { this.resolveReady = resolve; }); @@ -98,19 +98,19 @@ export class MonacoWorkspace { readonly onDidSaveTextDocument = this.onDidSaveTextDocumentEmitter.event; @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; @inject(FileSystemPreferences) - protected readonly filePreferences: FileSystemPreferences; + protected readonly filePreferences!: FileSystemPreferences; @inject(MonacoTextModelService) - protected readonly textModelService: MonacoTextModelService; + protected readonly textModelService!: MonacoTextModelService; @inject(EditorManager) - protected readonly editorManager: EditorManager; + protected readonly editorManager!: EditorManager; @inject(ProblemManager) - protected readonly problems: ProblemManager; + protected readonly problems!: ProblemManager; @postConstruct() protected init(): void { diff --git a/packages/monaco/src/browser/textmate/monaco-textmate-service.ts b/packages/monaco/src/browser/textmate/monaco-textmate-service.ts index 185494517cb54..78a3e1effbc88 100644 --- a/packages/monaco/src/browser/textmate/monaco-textmate-service.ts +++ b/packages/monaco/src/browser/textmate/monaco-textmate-service.ts @@ -37,28 +37,35 @@ export class MonacoTextmateService implements FrontendApplicationContribution { protected readonly _activatedLanguages = new Set(); - protected grammarRegistry: Registry; + protected _grammarRegistry?: Registry; @inject(ContributionProvider) @named(LanguageGrammarDefinitionContribution) - protected readonly grammarProviders: ContributionProvider; + protected readonly grammarProviders!: ContributionProvider; @inject(TextmateRegistry) - protected readonly textmateRegistry: TextmateRegistry; + protected readonly textmateRegistry!: TextmateRegistry; @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(OnigasmPromise) - protected readonly onigasmPromise: OnigasmPromise; + protected readonly onigasmPromise!: OnigasmPromise; @inject(ThemeService) - protected readonly themeService: ThemeService; + protected readonly themeService!: ThemeService; @inject(MonacoThemeRegistry) - protected readonly monacoThemeRegistry: MonacoThemeRegistry; + protected readonly monacoThemeRegistry!: MonacoThemeRegistry; @inject(EditorPreferences) - protected readonly preferences: EditorPreferences; + protected readonly preferences!: EditorPreferences; + + get grammarRegistry(): Registry { + if (!this._grammarRegistry) { + throw new Error('MonacoTextmateService._grammarRegistry is not set'); + } + return this._grammarRegistry; + } initialize(): void { if (!isBasicWasmSupported) { @@ -74,7 +81,7 @@ export class MonacoTextmateService implements FrontendApplicationContribution { } } - this.grammarRegistry = new Registry({ + this._grammarRegistry = new Registry({ getOnigLib: () => this.onigasmPromise, theme: this.monacoThemeRegistry.getThemeData(this.currentEditorTheme), loadGrammar: async (scopeName: string) => { diff --git a/packages/monaco/src/browser/workspace-symbol-command.ts b/packages/monaco/src/browser/workspace-symbol-command.ts index 579139883bb1e..4e00fac939ebe 100644 --- a/packages/monaco/src/browser/workspace-symbol-command.ts +++ b/packages/monaco/src/browser/workspace-symbol-command.ts @@ -37,12 +37,12 @@ export class WorkspaceSymbolCommand implements QuickAccessProvider, CommandContr label: 'Go to Symbol in Workspace...' }); - @inject(MonacoLanguages) protected readonly languages: MonacoLanguages; - @inject(OpenerService) protected readonly openerService: OpenerService; - @inject(QuickInputService) protected quickInputService: QuickInputService; - @inject(QuickAccessRegistry) protected quickAccessRegistry: QuickAccessRegistry; - @inject(SelectionService) protected selectionService: SelectionService; - @inject(LabelProvider) protected readonly labelProvider: LabelProvider; + @inject(MonacoLanguages) protected readonly languages!: MonacoLanguages; + @inject(OpenerService) protected readonly openerService!: OpenerService; + @inject(QuickInputService) protected quickInputService!: QuickInputService; + @inject(QuickAccessRegistry) protected quickAccessRegistry!: QuickAccessRegistry; + @inject(SelectionService) protected selectionService!: SelectionService; + @inject(LabelProvider) protected readonly labelProvider!: LabelProvider; isEnabled(): boolean { return this.languages.workspaceSymbolProviders !== undefined; diff --git a/packages/navigator/src/browser/navigator-context-key-service.ts b/packages/navigator/src/browser/navigator-context-key-service.ts index 004331ab7235a..b6c3c2af1bb4f 100644 --- a/packages/navigator/src/browser/navigator-context-key-service.ts +++ b/packages/navigator/src/browser/navigator-context-key-service.ts @@ -21,26 +21,26 @@ import { ContextKeyService, ContextKey } from '@theia/core/lib/browser/context-k export class NavigatorContextKeyService { @inject(ContextKeyService) - protected readonly contextKeyService: ContextKeyService; + protected readonly contextKeyService!: ContextKeyService; - protected _explorerViewletVisible: ContextKey; + protected _explorerViewletVisible!: ContextKey; get explorerViewletVisible(): ContextKey { return this._explorerViewletVisible; } - protected _explorerViewletFocus: ContextKey; + protected _explorerViewletFocus!: ContextKey; /** True if Explorer view has keyboard focus. */ get explorerViewletFocus(): ContextKey { return this._explorerViewletFocus; } - protected _filesExplorerFocus: ContextKey; + protected _filesExplorerFocus!: ContextKey; /** True if File Explorer section has keyboard focus. */ get filesExplorerFocus(): ContextKey { return this._filesExplorerFocus; } - protected _explorerResourceIsFolder: ContextKey; + protected _explorerResourceIsFolder!: ContextKey; get explorerResourceIsFolder(): ContextKey { return this._explorerResourceIsFolder; } diff --git a/packages/navigator/src/browser/navigator-contribution.ts b/packages/navigator/src/browser/navigator-contribution.ts index 10736bf0351a8..c68019c95fae9 100644 --- a/packages/navigator/src/browser/navigator-contribution.ts +++ b/packages/navigator/src/browser/navigator-contribution.ts @@ -171,31 +171,31 @@ export const FILE_NAVIGATOR_TOGGLE_COMMAND_ID = 'fileNavigator:toggle'; export class FileNavigatorContribution extends AbstractViewContribution implements FrontendApplicationContribution, TabBarToolbarContribution { @inject(ClipboardService) - protected readonly clipboardService: ClipboardService; + protected readonly clipboardService!: ClipboardService; @inject(CommandRegistry) - protected readonly commandRegistry: CommandRegistry; + protected readonly commandRegistry!: CommandRegistry; @inject(TabBarToolbarRegistry) - protected readonly tabbarToolbarRegistry: TabBarToolbarRegistry; + protected readonly tabbarToolbarRegistry!: TabBarToolbarRegistry; @inject(NavigatorContextKeyService) - protected readonly contextKeyService: NavigatorContextKeyService; + protected readonly contextKeyService!: NavigatorContextKeyService; @inject(MenuModelRegistry) - protected readonly menuRegistry: MenuModelRegistry; + protected readonly menuRegistry!: MenuModelRegistry; @inject(NavigatorDiff) - protected readonly navigatorDiff: NavigatorDiff; + protected readonly navigatorDiff!: NavigatorDiff; @inject(PreferenceService) - protected readonly preferenceService: PreferenceService; + protected readonly preferenceService!: PreferenceService; @inject(SelectionService) - protected readonly selectionService: SelectionService; + protected readonly selectionService!: SelectionService; @inject(WorkspaceCommandContribution) - protected readonly workspaceCommandContribution: WorkspaceCommandContribution; + protected readonly workspaceCommandContribution!: WorkspaceCommandContribution; constructor( @inject(FileNavigatorPreferences) protected readonly fileNavigatorPreferences: FileNavigatorPreferences, diff --git a/packages/navigator/src/browser/navigator-diff.ts b/packages/navigator/src/browser/navigator-diff.ts index dec03067ec27f..f5bb93c82924a 100644 --- a/packages/navigator/src/browser/navigator-diff.ts +++ b/packages/navigator/src/browser/navigator-diff.ts @@ -41,16 +41,16 @@ export namespace NavigatorDiffCommands { @injectable() export class NavigatorDiff { @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; @inject(OpenerService) - protected openerService: OpenerService; + protected openerService!: OpenerService; @inject(MessageService) - protected readonly notifications: MessageService; + protected readonly notifications!: MessageService; @inject(SelectionService) - protected readonly selectionService: SelectionService; + protected readonly selectionService!: SelectionService; constructor( ) { @@ -65,7 +65,7 @@ export class NavigatorDiff { this._isFirstFileSelected = true; } - protected _isFirstFileSelected: boolean; + protected _isFirstFileSelected!: boolean; get isFirstFileSelected(): boolean { return this._isFirstFileSelected; } diff --git a/packages/navigator/src/browser/navigator-filter.ts b/packages/navigator/src/browser/navigator-filter.ts index 3adca742686ad..016121cc882b5 100644 --- a/packages/navigator/src/browser/navigator-filter.ts +++ b/packages/navigator/src/browser/navigator-filter.ts @@ -30,11 +30,11 @@ import { FileNavigatorPreferences, FileNavigatorConfiguration } from './navigato export class FileNavigatorFilter { protected readonly emitter: Emitter = new Emitter(); - protected filterPredicate: FileNavigatorFilter.Predicate; - protected showHiddenFiles: boolean; + protected filterPredicate!: FileNavigatorFilter.Predicate; + protected showHiddenFiles: boolean = false; @inject(FileSystemPreferences) - protected readonly filesPreferences: FileSystemPreferences; + protected readonly filesPreferences!: FileSystemPreferences; constructor( @inject(FileNavigatorPreferences) protected readonly preferences: FileNavigatorPreferences diff --git a/packages/navigator/src/browser/navigator-keybinding-context.ts b/packages/navigator/src/browser/navigator-keybinding-context.ts index f8a415848a7d0..7beae9d45ed0a 100644 --- a/packages/navigator/src/browser/navigator-keybinding-context.ts +++ b/packages/navigator/src/browser/navigator-keybinding-context.ts @@ -28,7 +28,7 @@ export class NavigatorActiveContext implements KeybindingContext { readonly id: string = NavigatorKeybindingContexts.navigatorActive; @inject(ApplicationShell) - protected readonly applicationShell: ApplicationShell; + protected readonly applicationShell!: ApplicationShell; isEnabled(): boolean { return this.applicationShell.activeWidget instanceof FileNavigatorWidget; diff --git a/packages/navigator/src/browser/navigator-model.ts b/packages/navigator/src/browser/navigator-model.ts index f890a318e845b..cea2f4fa1df55 100644 --- a/packages/navigator/src/browser/navigator-model.ts +++ b/packages/navigator/src/browser/navigator-model.ts @@ -28,13 +28,13 @@ import { Disposable } from '@theia/core/lib/common/disposable'; @injectable() export class FileNavigatorModel extends FileTreeModel { - @inject(OpenerService) protected readonly openerService: OpenerService; - @inject(FileNavigatorTree) protected readonly tree: FileNavigatorTree; - @inject(WorkspaceService) protected readonly workspaceService: WorkspaceService; - @inject(FrontendApplicationStateService) protected readonly applicationState: FrontendApplicationStateService; + @inject(OpenerService) protected readonly openerService!: OpenerService; + @inject(FileNavigatorTree) protected readonly tree!: FileNavigatorTree; + @inject(WorkspaceService) protected readonly workspaceService!: WorkspaceService; + @inject(FrontendApplicationStateService) protected readonly applicationState!: FrontendApplicationStateService; @inject(ProgressService) - protected readonly progressService: ProgressService; + protected readonly progressService!: ProgressService; @postConstruct() protected init(): void { diff --git a/packages/navigator/src/browser/navigator-tab-bar-decorator.ts b/packages/navigator/src/browser/navigator-tab-bar-decorator.ts index 7a9466df4951d..31814a45e1fbd 100644 --- a/packages/navigator/src/browser/navigator-tab-bar-decorator.ts +++ b/packages/navigator/src/browser/navigator-tab-bar-decorator.ts @@ -25,7 +25,7 @@ import { OpenEditorsWidget } from './open-editors-widget/navigator-open-editors- @injectable() export class NavigatorTabBarDecorator implements TabBarDecorator, FrontendApplicationContribution { readonly id = 'theia-navigator-tabbar-decorator'; - protected applicationShell: ApplicationShell; + protected applicationShell?: ApplicationShell; protected readonly emitter = new Emitter(); private readonly toDispose = new DisposableCollection(); @@ -58,6 +58,9 @@ export class NavigatorTabBarDecorator implements TabBarDecorator, FrontendApplic } protected getDirtyEditorsCount(): number { + if (!this.applicationShell) { + throw new Error('NavigatorTabBarDecorator.applicationShell is not set'); + } return this.applicationShell.widgets.filter(widget => Saveable.isDirty(widget)).length; } diff --git a/packages/navigator/src/browser/navigator-tree.ts b/packages/navigator/src/browser/navigator-tree.ts index 9cdaa99989774..504b009031746 100644 --- a/packages/navigator/src/browser/navigator-tree.ts +++ b/packages/navigator/src/browser/navigator-tree.ts @@ -24,7 +24,7 @@ import { FileNavigatorFilter } from './navigator-filter'; @injectable() export class FileNavigatorTree extends FileTree { - @inject(FileNavigatorFilter) protected readonly filter: FileNavigatorFilter; + @inject(FileNavigatorFilter) protected readonly filter!: FileNavigatorFilter; @postConstruct() protected init(): void { diff --git a/packages/navigator/src/browser/navigator-widget-factory.ts b/packages/navigator/src/browser/navigator-widget-factory.ts index aa864c4d4cf32..b621d774aaf7b 100644 --- a/packages/navigator/src/browser/navigator-widget-factory.ts +++ b/packages/navigator/src/browser/navigator-widget-factory.ts @@ -57,8 +57,8 @@ export class NavigatorWidgetFactory implements WidgetFactory { }; @inject(ViewContainer.Factory) - protected readonly viewContainerFactory: ViewContainer.Factory; - @inject(WidgetManager) protected readonly widgetManager: WidgetManager; + protected readonly viewContainerFactory!: ViewContainer.Factory; + @inject(WidgetManager) protected readonly widgetManager!: WidgetManager; async createWidget(): Promise { const viewContainer = this.viewContainerFactory({ diff --git a/packages/navigator/src/browser/navigator-widget.tsx b/packages/navigator/src/browser/navigator-widget.tsx index 9faccb4dbfbe1..8ce15e046035b 100644 --- a/packages/navigator/src/browser/navigator-widget.tsx +++ b/packages/navigator/src/browser/navigator-widget.tsx @@ -40,12 +40,12 @@ export const CLASS = 'theia-Files'; @injectable() export class FileNavigatorWidget extends FileTreeWidget { - @inject(CorePreferences) protected readonly corePreferences: CorePreferences; + @inject(CorePreferences) protected readonly corePreferences!: CorePreferences; @inject(NavigatorContextKeyService) - protected readonly contextKeyService: NavigatorContextKeyService; + protected readonly contextKeyService!: NavigatorContextKeyService; - @inject(OpenerService) protected readonly openerService: OpenerService; + @inject(OpenerService) protected readonly openerService!: OpenerService; constructor( @inject(TreeProps) readonly props: TreeProps, diff --git a/packages/navigator/src/browser/open-editors-widget/navigator-deleted-editor-decorator.ts b/packages/navigator/src/browser/open-editors-widget/navigator-deleted-editor-decorator.ts index 5e0a8c9973438..9547339a3d4ae 100644 --- a/packages/navigator/src/browser/open-editors-widget/navigator-deleted-editor-decorator.ts +++ b/packages/navigator/src/browser/open-editors-widget/navigator-deleted-editor-decorator.ts @@ -24,9 +24,9 @@ import { FileChangeType, FileStatNode } from '@theia/filesystem/lib/browser'; export class NavigatorDeletedEditorDecorator implements TreeDecorator { @inject(FileSystemFrontendContribution) - protected readonly fileSystemContribution: FileSystemFrontendContribution; + protected readonly fileSystemContribution!: FileSystemFrontendContribution; @inject(ApplicationShell) - protected readonly shell: ApplicationShell; + protected readonly shell!: ApplicationShell; readonly id = 'theia-deleted-editor-decorator'; protected readonly onDidChangeDecorationsEmitter = new Emitter(); diff --git a/packages/navigator/src/browser/open-editors-widget/navigator-open-editors-tree-model.ts b/packages/navigator/src/browser/open-editors-widget/navigator-open-editors-tree-model.ts index ec11ca3399359..0d83ca50dc034 100644 --- a/packages/navigator/src/browser/open-editors-widget/navigator-open-editors-tree-model.ts +++ b/packages/navigator/src/browser/open-editors-widget/navigator-open-editors-tree-model.ts @@ -48,9 +48,9 @@ export class OpenEditorsModel extends FileTreeModel { static GROUP_NODE_ID_PREFIX = 'group-node'; static AREA_NODE_ID_PREFIX = 'area-node'; - @inject(ApplicationShell) protected readonly applicationShell: ApplicationShell; - @inject(WorkspaceService) protected readonly workspaceService: WorkspaceService; - @inject(OpenerService) protected readonly openerService: OpenerService; + @inject(ApplicationShell) protected readonly applicationShell!: ApplicationShell; + @inject(WorkspaceService) protected readonly workspaceService!: WorkspaceService; + @inject(OpenerService) protected readonly openerService!: OpenerService; protected toDisposeOnPreviewWidgetReplaced = new DisposableCollection(); // Returns the collection of editors belonging to a tabbar group in the main area diff --git a/packages/navigator/src/browser/open-editors-widget/navigator-open-editors-widget.tsx b/packages/navigator/src/browser/open-editors-widget/navigator-open-editors-widget.tsx index 7f463f5c19b6a..d1b2fe4ce7b06 100644 --- a/packages/navigator/src/browser/open-editors-widget/navigator-open-editors-widget.tsx +++ b/packages/navigator/src/browser/open-editors-widget/navigator-open-editors-widget.tsx @@ -54,8 +54,8 @@ export class OpenEditorsWidget extends FileTreeWidget { static ID = 'theia-open-editors-widget'; static LABEL = nls.localizeByDefault('Open Editors'); - @inject(ApplicationShell) protected readonly applicationShell: ApplicationShell; - @inject(CommandService) protected readonly commandService: CommandService; + @inject(ApplicationShell) protected readonly applicationShell!: ApplicationShell; + @inject(CommandService) protected readonly commandService!: CommandService; static createContainer(parent: interfaces.Container): Container { const child = createFileTreeContainer(parent); diff --git a/packages/outline-view/src/browser/outline-breadcrumbs-contribution.tsx b/packages/outline-view/src/browser/outline-breadcrumbs-contribution.tsx index 17d70c733aad0..11d8669a47821 100644 --- a/packages/outline-view/src/browser/outline-breadcrumbs-contribution.tsx +++ b/packages/outline-view/src/browser/outline-breadcrumbs-contribution.tsx @@ -29,7 +29,7 @@ export interface BreadcrumbPopupOutlineViewFactory { (): BreadcrumbPopupOutlineView; } export class BreadcrumbPopupOutlineView extends OutlineViewWidget { - @inject(OpenerService) protected readonly openerService: OpenerService; + @inject(OpenerService) protected readonly openerService!: OpenerService; protected handleClickEvent(node: TreeNode | undefined, event: React.MouseEvent): void { if (UriSelection.is(node) && OutlineSymbolInformationNode.hasRange(node)) { @@ -49,18 +49,18 @@ export class BreadcrumbPopupOutlineView extends OutlineViewWidget { @injectable() export class OutlineBreadcrumbsContribution implements BreadcrumbsContribution { @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(OutlineViewService) - protected readonly outlineViewService: OutlineViewService; + protected readonly outlineViewService!: OutlineViewService; @inject(BreadcrumbsService) - protected readonly breadcrumbsService: BreadcrumbsService; + protected readonly breadcrumbsService!: BreadcrumbsService; @inject(BreadcrumbPopupOutlineViewFactory) - protected readonly outlineFactory: BreadcrumbPopupOutlineViewFactory; + protected readonly outlineFactory!: BreadcrumbPopupOutlineViewFactory; - protected outlineView: BreadcrumbPopupOutlineView; + protected outlineView!: BreadcrumbPopupOutlineView; readonly type = OutlineBreadcrumbType; readonly priority: number = 200; diff --git a/packages/outline-view/src/browser/outline-view-tree-model.ts b/packages/outline-view/src/browser/outline-view-tree-model.ts index 759d92ed5f7f7..e73353bd362f8 100644 --- a/packages/outline-view/src/browser/outline-view-tree-model.ts +++ b/packages/outline-view/src/browser/outline-view-tree-model.ts @@ -20,7 +20,7 @@ import { CompositeTreeNode, TreeModelImpl, TreeExpansionService, ExpandableTreeN @injectable() export class OutlineViewTreeModel extends TreeModelImpl { - @inject(TreeExpansionService) protected readonly expansionService: TreeExpansionService; + @inject(TreeExpansionService) protected readonly expansionService!: TreeExpansionService; /** * Handle the expansion of the tree node. diff --git a/packages/output/src/browser/output-channel.ts b/packages/output/src/browser/output-channel.ts index 06fdff5b5231b..c27afeb2159f3 100644 --- a/packages/output/src/browser/output-channel.ts +++ b/packages/output/src/browser/output-channel.ts @@ -30,10 +30,10 @@ import { OutputPreferences } from './output-preferences'; export class OutputChannelManager implements Disposable, ResourceResolver { @inject(MonacoTextModelService) - protected readonly textModelService: MonacoTextModelService; + protected readonly textModelService!: MonacoTextModelService; @inject(OutputPreferences) - protected readonly preferences: OutputPreferences; + protected readonly preferences!: OutputPreferences; protected readonly channels = new Map(); protected readonly resources = new Map(); diff --git a/packages/output/src/browser/output-contribution.ts b/packages/output/src/browser/output-contribution.ts index a498f243f4bb5..bcfe4d949754e 100644 --- a/packages/output/src/browser/output-contribution.ts +++ b/packages/output/src/browser/output-contribution.ts @@ -34,19 +34,19 @@ import { nls } from '@theia/core/lib/common/nls'; export class OutputContribution extends AbstractViewContribution implements OpenHandler { @inject(ClipboardService) - protected readonly clipboardService: ClipboardService; + protected readonly clipboardService!: ClipboardService; @inject(CommandService) - protected readonly commandService: CommandService; + protected readonly commandService!: CommandService; @inject(OutputChannelManager) - protected readonly outputChannelManager: OutputChannelManager; + protected readonly outputChannelManager!: OutputChannelManager; @inject(OpenerService) - protected readonly openerService: OpenerService; + protected readonly openerService!: OpenerService; @inject(QuickPickService) - protected readonly quickPickService: QuickPickService; + protected readonly quickPickService!: QuickPickService; readonly id: string = `${OutputWidget.ID}-opener`; diff --git a/packages/output/src/browser/output-editor-factory.ts b/packages/output/src/browser/output-editor-factory.ts index 9130510bfda2a..724cc5b75d95f 100644 --- a/packages/output/src/browser/output-editor-factory.ts +++ b/packages/output/src/browser/output-editor-factory.ts @@ -27,10 +27,10 @@ import { OutputContextMenuService } from './output-context-menu'; export class OutputEditorFactory implements MonacoEditorFactory { @inject(MonacoEditorServices) - protected readonly services: MonacoEditorServices; + protected readonly services!: MonacoEditorServices; @inject(OutputContextMenuService) - protected readonly contextMenuService: MonacoContextMenuService; + protected readonly contextMenuService!: MonacoContextMenuService; readonly scheme: string = OutputUri.SCHEME; diff --git a/packages/output/src/browser/output-editor-model-factory.ts b/packages/output/src/browser/output-editor-model-factory.ts index 40c759bdfbe24..5d3b166c50999 100644 --- a/packages/output/src/browser/output-editor-model-factory.ts +++ b/packages/output/src/browser/output-editor-model-factory.ts @@ -26,10 +26,10 @@ import { ProtocolToMonacoConverter } from '@theia/monaco/lib/browser/protocol-to export class OutputEditorModelFactory implements MonacoEditorModelFactory { @inject(MonacoToProtocolConverter) - protected readonly m2p: MonacoToProtocolConverter; + protected readonly m2p!: MonacoToProtocolConverter; @inject(ProtocolToMonacoConverter) - protected readonly p2m: ProtocolToMonacoConverter; + protected readonly p2m!: ProtocolToMonacoConverter; readonly scheme: string = OutputUri.SCHEME; diff --git a/packages/output/src/browser/output-toolbar-contribution.tsx b/packages/output/src/browser/output-toolbar-contribution.tsx index 7b6956afe90a7..b87e4b680b25f 100644 --- a/packages/output/src/browser/output-toolbar-contribution.tsx +++ b/packages/output/src/browser/output-toolbar-contribution.tsx @@ -28,10 +28,10 @@ import { nls } from '@theia/core/lib/common/nls'; export class OutputToolbarContribution implements TabBarToolbarContribution { @inject(OutputChannelManager) - protected readonly outputChannelManager: OutputChannelManager; + protected readonly outputChannelManager!: OutputChannelManager; @inject(OutputContribution) - protected readonly outputContribution: OutputContribution; + protected readonly outputContribution!: OutputContribution; protected readonly onOutputWidgetStateChangedEmitter = new Emitter(); protected readonly onOutputWidgetStateChanged = this.onOutputWidgetStateChangedEmitter.event; diff --git a/packages/output/src/browser/output-widget.ts b/packages/output/src/browser/output-widget.ts index e42271041d307..63b0eb8e6d80d 100644 --- a/packages/output/src/browser/output-widget.ts +++ b/packages/output/src/browser/output-widget.ts @@ -36,13 +36,13 @@ export class OutputWidget extends BaseWidget implements StatefulWidget { static readonly LABEL = nls.localizeByDefault('Output'); @inject(SelectionService) - protected readonly selectionService: SelectionService; + protected readonly selectionService!: SelectionService; @inject(MonacoEditorProvider) - protected readonly editorProvider: MonacoEditorProvider; + protected readonly editorProvider!: MonacoEditorProvider; @inject(OutputChannelManager) - protected readonly outputChannelManager: OutputChannelManager; + protected readonly outputChannelManager!: OutputChannelManager; protected _state: OutputWidget.State = { locked: false }; protected readonly editorContainer: DockPanel; diff --git a/packages/plugin-dev/src/browser/hosted-plugin-controller.ts b/packages/plugin-dev/src/browser/hosted-plugin-controller.ts index 18bb1ee41cf34..6bfeb4680e26b 100644 --- a/packages/plugin-dev/src/browser/hosted-plugin-controller.ts +++ b/packages/plugin-dev/src/browser/hosted-plugin-controller.ts @@ -40,35 +40,35 @@ export class HostedPluginController implements FrontendApplicationContribution { public static readonly HOSTED_PLUGIN_FAILED = 'hosted-plugin-failed'; @inject(StatusBar) - protected readonly statusBar: StatusBar; + protected readonly statusBar!: StatusBar; @inject(FrontendApplicationStateService) - protected readonly frontendApplicationStateService: FrontendApplicationStateService; + protected readonly frontendApplicationStateService!: FrontendApplicationStateService; @inject(HostedPluginServer) - protected readonly hostedPluginServer: HostedPluginServer; + protected readonly hostedPluginServer!: HostedPluginServer; @inject(HostedPluginManagerClient) - protected readonly hostedPluginManagerClient: HostedPluginManagerClient; + protected readonly hostedPluginManagerClient!: HostedPluginManagerClient; @inject(ConnectionStatusService) - protected readonly connectionStatusService: ConnectionStatusService; + protected readonly connectionStatusService!: ConnectionStatusService; @inject(HostedPluginLogViewer) - protected readonly hostedPluginLogViewer: HostedPluginLogViewer; + protected readonly hostedPluginLogViewer!: HostedPluginLogViewer; @inject(HostedPluginPreferences) - protected readonly hostedPluginPreferences: HostedPluginPreferences; + protected readonly hostedPluginPreferences!: HostedPluginPreferences; @inject(PreferenceServiceImpl) - protected readonly preferenceService: PreferenceServiceImpl; + protected readonly preferenceService!: PreferenceServiceImpl; @inject(MessageService) - protected readonly messageService: MessageService; + protected readonly messageService!: MessageService; private pluginState: HostedInstanceState = HostedInstanceState.STOPPED; // used only for displaying Running instead of Watching in status bar if run of watcher fails - private watcherSuccess: boolean; + private watcherSuccess: boolean = false; private entry: StatusBarEntry | undefined; public initialize(): void { diff --git a/packages/plugin-dev/src/browser/hosted-plugin-frontend-contribution.ts b/packages/plugin-dev/src/browser/hosted-plugin-frontend-contribution.ts index ce4c3161dfda9..db524b665f5c8 100644 --- a/packages/plugin-dev/src/browser/hosted-plugin-frontend-contribution.ts +++ b/packages/plugin-dev/src/browser/hosted-plugin-frontend-contribution.ts @@ -22,7 +22,7 @@ import { HostedPluginManagerClient, HostedPluginCommands } from './hosted-plugin export class HostedPluginFrontendContribution implements CommandContribution { @inject(HostedPluginManagerClient) - protected readonly hostedPluginManagerClient: HostedPluginManagerClient; + protected readonly hostedPluginManagerClient!: HostedPluginManagerClient; registerCommands(commands: CommandRegistry): void { commands.registerCommand(HostedPluginCommands.START, { diff --git a/packages/plugin-dev/src/browser/hosted-plugin-informer.ts b/packages/plugin-dev/src/browser/hosted-plugin-informer.ts index 1943f877a9860..5f3c79f38c224 100644 --- a/packages/plugin-dev/src/browser/hosted-plugin-informer.ts +++ b/packages/plugin-dev/src/browser/hosted-plugin-informer.ts @@ -37,22 +37,22 @@ export class HostedPluginInformer implements FrontendApplicationContribution { public static readonly DEVELOPMENT_HOST_OFFLINE = 'development-host-offline'; - private entry: StatusBarEntry; + private entry?: StatusBarEntry; @inject(StatusBar) - protected readonly statusBar: StatusBar; + protected readonly statusBar!: StatusBar; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @inject(HostedPluginServer) - protected readonly hostedPluginServer: HostedPluginServer; + protected readonly hostedPluginServer!: HostedPluginServer; @inject(ConnectionStatusService) - protected readonly connectionStatusService: ConnectionStatusService; + protected readonly connectionStatusService!: ConnectionStatusService; @inject(FrontendApplicationStateService) - protected readonly frontendApplicationStateService: FrontendApplicationStateService; + protected readonly frontendApplicationStateService!: FrontendApplicationStateService; public initialize(): void { this.workspaceService.roots.then(roots => { @@ -79,6 +79,9 @@ export class HostedPluginInformer implements FrontendApplicationContribution { } private updateStatusBarElement(): void { + if (!this.entry) { + throw new Error('HostedPluginInformer.entry is not set'); + } if (this.connectionStatusService.currentStatus === ConnectionStatus.OFFLINE) { this.entry.className = HostedPluginInformer.DEVELOPMENT_HOST_OFFLINE; } else { diff --git a/packages/plugin-dev/src/browser/hosted-plugin-log-viewer.ts b/packages/plugin-dev/src/browser/hosted-plugin-log-viewer.ts index fe910607e2787..534a3646acfd8 100644 --- a/packages/plugin-dev/src/browser/hosted-plugin-log-viewer.ts +++ b/packages/plugin-dev/src/browser/hosted-plugin-log-viewer.ts @@ -25,13 +25,13 @@ export class HostedPluginLogViewer { public static OUTPUT_CHANNEL_NAME = 'hosted-instance-log'; @inject(HostedPluginWatcher) - protected readonly watcher: HostedPluginWatcher; + protected readonly watcher!: HostedPluginWatcher; @inject(OutputChannelManager) - protected readonly outputChannelManager: OutputChannelManager; + protected readonly outputChannelManager!: OutputChannelManager; @inject(OutputContribution) - protected readonly outputContribution: OutputContribution; + protected readonly outputContribution!: OutputContribution; - protected channel: OutputChannel; + protected channel!: OutputChannel; showLogConsole(): void { this.outputContribution.openView({ reveal: true }).then(view => { diff --git a/packages/plugin-dev/src/browser/hosted-plugin-manager-client.ts b/packages/plugin-dev/src/browser/hosted-plugin-manager-client.ts index 9d1af379a4e40..e6fa8c8e814c8 100644 --- a/packages/plugin-dev/src/browser/hosted-plugin-manager-client.ts +++ b/packages/plugin-dev/src/browser/hosted-plugin-manager-client.ts @@ -89,9 +89,9 @@ export interface HostedInstanceData { */ @injectable() export class HostedPluginManagerClient { - private openNewTabAskDialog: OpenHostedInstanceLinkDialog; + private openNewTabAskDialog!: OpenHostedInstanceLinkDialog; - private connection: DebugSessionConnection; + private connection?: DebugSessionConnection; // path to the plugin on the file system protected pluginLocation: URI | undefined; @@ -108,25 +108,25 @@ export class HostedPluginManagerClient { } @inject(HostedPluginServer) - protected readonly hostedPluginServer: HostedPluginServer; + protected readonly hostedPluginServer!: HostedPluginServer; @inject(MessageService) - protected readonly messageService: MessageService; + protected readonly messageService!: MessageService; @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(WindowService) - protected readonly windowService: WindowService; + protected readonly windowService!: WindowService; @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; @inject(EnvVariablesServer) - protected readonly environments: EnvVariablesServer; + protected readonly environments!: EnvVariablesServer; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @inject(DebugSessionManager) - protected readonly debugSessionManager: DebugSessionManager; + protected readonly debugSessionManager!: DebugSessionManager; @inject(HostedPluginPreferences) - protected readonly hostedPluginPreferences: HostedPluginPreferences; + protected readonly hostedPluginPreferences!: HostedPluginPreferences; @inject(FileDialogService) - protected readonly fileDialogService: FileDialogService; + protected readonly fileDialogService!: FileDialogService; @postConstruct() protected async init(): Promise { @@ -299,7 +299,7 @@ export class HostedPluginManagerClient { register(configType: string, connection: DebugSessionConnection): void { if (configType === 'pwa-extensionHost') { this.connection = connection; - this.connection.onRequest('launchVSCode', (request: LaunchVSCodeRequest) => this.launchVSCode(request)); + this.connection.onRequest('launchVSCode', request => this.launchVSCode(request as LaunchVSCodeRequest)); // eslint-disable-next-line @typescript-eslint/no-explicit-any this.connection.on('exited', async (args: any) => { @@ -328,10 +328,12 @@ export class HostedPluginManagerClient { } protected async launchVSCode({ arguments: { args } }: LaunchVSCodeRequest): Promise { + if (!this.connection) { + throw new Error('HostedPluginManagerClient.connection is not set'); + } let result = {}; let instanceURI; - - const sessions = this.debugSessionManager.sessions.filter(session => session.id !== this.connection.sessionId); + const sessions = this.debugSessionManager.sessions.filter(session => session.id !== this.connection!.sessionId); /* if `launchVSCode` is invoked and sessions do not exist - it means that `start` debug was invoked. if `launchVSCode` is invoked and sessions do exist - it means that `restartSessions()` was invoked, @@ -386,9 +388,8 @@ export class HostedPluginManagerClient { class OpenHostedInstanceLinkDialog extends AbstractDialog { protected readonly windowService: WindowService; protected readonly openButton: HTMLButtonElement; - protected readonly messageNode: HTMLDivElement; protected readonly linkNode: HTMLAnchorElement; - value: string; + protected _value?: string; constructor(windowService: WindowService) { super({ @@ -410,8 +411,15 @@ class OpenHostedInstanceLinkDialog extends AbstractDialog { this.openButton = this.appendAcceptButton('Open'); } + get value(): string { + if (this._value === undefined) { + throw new Error('OpenHostedInstanceLinkDialog._value is not set'); + } + return this._value; + } + showOpenNewTabAskDialog(uri: string): void { - this.value = uri; + this._value = uri; this.linkNode.innerHTML = uri; this.linkNode.href = uri; diff --git a/packages/plugin-dev/src/node/hosted-instance-manager.ts b/packages/plugin-dev/src/node/hosted-instance-manager.ts index 52119ce8a99c2..79339b08f68b5 100644 --- a/packages/plugin-dev/src/node/hosted-instance-manager.ts +++ b/packages/plugin-dev/src/node/hosted-instance-manager.ts @@ -98,20 +98,20 @@ const PROCESS_OPTIONS = { @injectable() export abstract class AbstractHostedInstanceManager implements HostedInstanceManager { - protected hostedInstanceProcess: cp.ChildProcess; + protected hostedInstanceProcess?: cp.ChildProcess; protected isPluginRunning: boolean = false; - protected instanceUri: URI; - protected pluginUri: URI; - protected instanceOptions: object; + protected instanceUri?: URI; + protected pluginUri?: URI; + protected instanceOptions?: object; @inject(HostedPluginSupport) - protected readonly hostedPluginSupport: HostedPluginSupport; + protected readonly hostedPluginSupport!: HostedPluginSupport; @inject(MetadataScanner) - protected readonly metadata: MetadataScanner; + protected readonly metadata!: MetadataScanner; @inject(HostedPluginProcess) - protected readonly hostedPluginProcess: HostedPluginProcess; + protected readonly hostedPluginProcess!: HostedPluginProcess; isRunning(): boolean { return this.isPluginRunning; @@ -158,7 +158,7 @@ export abstract class AbstractHostedInstanceManager implements HostedInstanceMan } terminate(): void { - if (this.isPluginRunning) { + if (this.checkPluginRunning()) { this.hostedPluginProcess.killProcessTree(this.hostedInstanceProcess.pid); this.hostedPluginSupport.sendLog({ data: 'Hosted instance has been terminated', type: LogType.Info }); this.isPluginRunning = false; @@ -168,14 +168,14 @@ export abstract class AbstractHostedInstanceManager implements HostedInstanceMan } getInstanceURI(): URI { - if (this.isPluginRunning) { + if (this.checkPluginRunning()) { return this.instanceUri; } throw new Error('Hosted plugin instance is not running.'); } getPluginURI(): URI { - if (this.isPluginRunning) { + if (this.checkPluginRunning()) { return this.pluginUri; } throw new Error('Hosted plugin instance is not running.'); @@ -194,9 +194,7 @@ export abstract class AbstractHostedInstanceManager implements HostedInstanceMan * @param resolve resolve function if ok * @param reject reject function if error */ - private async pingLoop(remainingCount: number, - resolve: (value?: void | PromiseLike | undefined | Error) => void, - reject: (value?: void | PromiseLike | undefined | Error) => void): Promise { + private async pingLoop(remainingCount: number, resolve: () => void, reject: (value: Error) => void): Promise { const isOK = await this.ping(); if (isOK) { resolve(); @@ -214,7 +212,7 @@ export abstract class AbstractHostedInstanceManager implements HostedInstanceMan */ private async ping(): Promise { return new Promise((resolve, reject) => { - const url = this.instanceUri.toString(); + const url = this.instanceUri!.toString(); request.head(url, this.instanceOptions).on('response', res => { // Wait that the status is OK resolve(res.statusCode === 200); @@ -287,7 +285,7 @@ export abstract class AbstractHostedInstanceManager implements HostedInstanceMan const line = data.toString(); const match = THEIA_INSTANCE_REGEX.exec(line); if (match) { - this.hostedInstanceProcess.stdout!.removeListener('data', outputListener); + this.hostedInstanceProcess!.stdout!.removeListener('data', outputListener); started = true; resolve(new URI(match[1])); } @@ -339,12 +337,20 @@ export abstract class AbstractHostedInstanceManager implements HostedInstanceMan }); } + protected checkPluginRunning(): this is this & { + hostedInstanceProcess: cp.ChildProcess + instanceUri: URI + pluginUri: URI + instanceOptions: object + } { + return this.isPluginRunning; + } } @injectable() export class NodeHostedPluginRunner extends AbstractHostedInstanceManager { @inject(ContributionProvider) @named(Symbol.for(HostedPluginUriPostProcessorSymbolName)) - protected readonly uriPostProcessors: ContributionProvider; + protected readonly uriPostProcessors!: ContributionProvider; protected async postProcessInstanceUri(uri: URI): Promise { for (const uriPostProcessor of this.uriPostProcessors.getContributions()) { diff --git a/packages/plugin-dev/src/node/hosted-plugin-reader.ts b/packages/plugin-dev/src/node/hosted-plugin-reader.ts index 46686c52ea659..0ce2c15d19594 100644 --- a/packages/plugin-dev/src/node/hosted-plugin-reader.ts +++ b/packages/plugin-dev/src/node/hosted-plugin-reader.ts @@ -26,12 +26,12 @@ import { HostedPluginDeployerHandler } from '@theia/plugin-ext/lib/hosted/node/h export class HostedPluginReader implements BackendApplicationContribution { @inject(PluginReaderHosted) - protected pluginReader: PluginReaderHosted; + protected pluginReader!: PluginReaderHosted; private readonly hostedPlugin = new Deferred(); @inject(HostedPluginDeployerHandler) - protected deployerHandler: HostedPluginDeployerHandler; + protected deployerHandler!: HostedPluginDeployerHandler; async initialize(): Promise { this.pluginReader.getPluginMetadata(process.env.HOSTED_PLUGIN) diff --git a/packages/plugin-dev/src/node/hosted-plugin-service.ts b/packages/plugin-dev/src/node/hosted-plugin-service.ts index faea180764647..b82b0eb6313dc 100644 --- a/packages/plugin-dev/src/node/hosted-plugin-service.ts +++ b/packages/plugin-dev/src/node/hosted-plugin-service.ts @@ -29,16 +29,16 @@ import { DebugPluginConfiguration } from '@theia/debug/lib/browser/debug-contrib export class HostedPluginServerImpl implements HostedPluginServer { @inject(HostedPluginsManager) - protected readonly hostedPluginsManager: HostedPluginsManager; + protected readonly hostedPluginsManager!: HostedPluginsManager; @inject(HostedInstanceManager) - protected readonly hostedInstanceManager: HostedInstanceManager; + protected readonly hostedInstanceManager!: HostedInstanceManager; @inject(HostedPluginReader) - private readonly reader: HostedPluginReader; + private readonly reader!: HostedPluginReader; @inject(HostedPluginSupport) - private readonly hostedPlugin: HostedPluginSupport; + private readonly hostedPlugin!: HostedPluginSupport; dispose(): void { // Terminate the hosted instance if it is currently running. diff --git a/packages/plugin-dev/src/node/hosted-plugins-manager.ts b/packages/plugin-dev/src/node/hosted-plugins-manager.ts index e6643cb6a2d9b..b450dc23836c0 100644 --- a/packages/plugin-dev/src/node/hosted-plugins-manager.ts +++ b/packages/plugin-dev/src/node/hosted-plugins-manager.ts @@ -53,7 +53,7 @@ export interface HostedPluginsManager { export class HostedPluginsManagerImpl implements HostedPluginsManager { @inject(HostedPluginSupport) - protected readonly hostedPluginSupport: HostedPluginSupport; + protected readonly hostedPluginSupport!: HostedPluginSupport; protected watchCompilationRegistry: Map; @@ -80,11 +80,15 @@ export class HostedPluginsManagerImpl implements HostedPluginsManager { } private killProcessTree(parentPid: number): void { - processTree(parentPid, (err: Error, childProcesses: Array) => { - childProcesses.forEach((p: processTree.PS) => { - process.kill(parseInt(p.PID)); - }); - process.kill(parentPid); + processTree(parentPid, (err, childProcesses) => { + if (err) { + console.error(err); + } else { + for (const p of childProcesses) { + process.kill(parseInt(p.PID)); + } + process.kill(parentPid); + } }); } diff --git a/packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts b/packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts index 488101a3a91ad..06c8fbfe17c52 100755 --- a/packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts +++ b/packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts @@ -104,39 +104,39 @@ export namespace VscodeCommands { @injectable() export class PluginVscodeCommandsContribution implements CommandContribution { @inject(CommandService) - protected readonly commandService: CommandService; + protected readonly commandService!: CommandService; @inject(ContextKeyService) - protected readonly contextKeyService: ContextKeyService; + protected readonly contextKeyService!: ContextKeyService; @inject(EditorManager) - protected readonly editorManager: EditorManager; + protected readonly editorManager!: EditorManager; @inject(ApplicationShell) - protected readonly shell: ApplicationShell; + protected readonly shell!: ApplicationShell; @inject(DiffService) - protected readonly diffService: DiffService; + protected readonly diffService!: DiffService; @inject(OpenerService) - protected readonly openerService: OpenerService; + protected readonly openerService!: OpenerService; @inject(ApplicationShellMouseTracker) - protected readonly mouseTracker: ApplicationShellMouseTracker; + protected readonly mouseTracker!: ApplicationShellMouseTracker; @inject(QuickInputService) @optional() - protected readonly quickInput: QuickInputService; + protected readonly quickInput?: QuickInputService; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @inject(TerminalFrontendContribution) - protected readonly terminalContribution: TerminalFrontendContribution; + protected readonly terminalContribution!: TerminalFrontendContribution; @inject(QuickOpenWorkspace) - protected readonly quickOpenWorkspace: QuickOpenWorkspace; + protected readonly quickOpenWorkspace!: QuickOpenWorkspace; @inject(TerminalService) - protected readonly terminalService: TerminalService; + protected readonly terminalService!: TerminalService; @inject(CodeEditorWidgetUtil) - protected readonly codeEditorWidgetUtil: CodeEditorWidgetUtil; + protected readonly codeEditorWidgetUtil!: CodeEditorWidgetUtil; @inject(PluginServer) - protected readonly pluginServer: PluginServer; + protected readonly pluginServer!: PluginServer; @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; @inject(CallHierarchyServiceProvider) - protected readonly callHierarchyProvider: CallHierarchyServiceProvider; + protected readonly callHierarchyProvider!: CallHierarchyServiceProvider; @inject(MonacoTextModelService) - protected readonly textModelService: MonacoTextModelService; + protected readonly textModelService!: MonacoTextModelService; private async openWith(commandId: string, resource: URI, columnOrOptions?: ViewColumn | TextDocumentShowOptions, openerId?: string): Promise { if (!resource) { @@ -293,7 +293,13 @@ export class PluginVscodeCommandsContribution implements CommandContribution { execute: () => commands.executeCommand(EditorCommands.GOTO_LINE_COLUMN.id) }); commands.registerCommand({ id: 'workbench.action.quickOpen' }, { - execute: (prefix?: unknown) => this.quickInput.open(typeof prefix === 'string' ? prefix : '') + execute: (prefix?: unknown) => { + if (this.quickInput) { + this.quickInput.open(typeof prefix === 'string' ? prefix : ''); + } else { + console.debug('PluginVscodeCommandsContribution.quickInput is not set'); + } + } }); commands.registerCommand({ id: 'workbench.action.openSettings' }, { execute: (query?: string) => commands.executeCommand(CommonCommands.OPEN_PREFERENCES.id, query) diff --git a/packages/plugin-ext-vscode/src/common/plugin-vscode-environment.ts b/packages/plugin-ext-vscode/src/common/plugin-vscode-environment.ts index 8e83ee01d4c58..b392c1f7191de 100644 --- a/packages/plugin-ext-vscode/src/common/plugin-vscode-environment.ts +++ b/packages/plugin-ext-vscode/src/common/plugin-vscode-environment.ts @@ -22,7 +22,7 @@ import URI from '@theia/core/lib/common/uri'; export class PluginVSCodeEnvironment { @inject(EnvVariablesServer) - protected readonly environments: EnvVariablesServer; + protected readonly environments!: EnvVariablesServer; protected _extensionsDirUri: URI | undefined; async getExtensionsDirUri(): Promise { diff --git a/packages/plugin-ext-vscode/src/node/plugin-vscode-deployer-participant.ts b/packages/plugin-ext-vscode/src/node/plugin-vscode-deployer-participant.ts index f6609d12342d5..1af636c938877 100644 --- a/packages/plugin-ext-vscode/src/node/plugin-vscode-deployer-participant.ts +++ b/packages/plugin-ext-vscode/src/node/plugin-vscode-deployer-participant.ts @@ -22,7 +22,7 @@ import { PluginDeployerParticipant, PluginDeployerStartContext } from '@theia/pl export class PluginVSCodeDeployerParticipant implements PluginDeployerParticipant { @inject(PluginVSCodeEnvironment) - protected readonly environments: PluginVSCodeEnvironment; + protected readonly environments!: PluginVSCodeEnvironment; async onWillStart(context: PluginDeployerStartContext): Promise { const extensionsDirUri = await this.environments.getExtensionsDirUri(); diff --git a/packages/plugin-ext-vscode/src/node/plugin-vscode-file-handler.ts b/packages/plugin-ext-vscode/src/node/plugin-vscode-file-handler.ts index 3409e18aa5e43..ccc4acbf65a34 100644 --- a/packages/plugin-ext-vscode/src/node/plugin-vscode-file-handler.ts +++ b/packages/plugin-ext-vscode/src/node/plugin-vscode-file-handler.ts @@ -27,7 +27,7 @@ import { FileUri } from '@theia/core/lib/node/file-uri'; export class PluginVsCodeFileHandler implements PluginDeployerFileHandler { @inject(PluginVSCodeEnvironment) - protected readonly environment: PluginVSCodeEnvironment; + protected readonly environment!: PluginVSCodeEnvironment; private readonly systemExtensionsDirUri = FileUri.create(getTempDir('vscode-unpacked')); diff --git a/packages/plugin-ext/src/common/rpc-protocol.ts b/packages/plugin-ext/src/common/rpc-protocol.ts index 799592b4fb100..34d26d1c18eed 100644 --- a/packages/plugin-ext/src/common/rpc-protocol.ts +++ b/packages/plugin-ext/src/common/rpc-protocol.ts @@ -94,7 +94,7 @@ export class RPCProtocolImpl implements RPCProtocol { constructor(connection: MessageConnection, transformations?: { replacer?: (key: string | undefined, value: any) => any, - reviver?: (key: string | undefined, value: any) => any + reviver?: (key: string | undefined, value: any) => any }) { this.toDispose.push( this.multiplexer = new RPCMultiplexer(connection) @@ -482,29 +482,29 @@ export const enum MessageType { Terminated = 6 } -class CancelMessage { - type: MessageType.Cancel; - id: string; +abstract class CancelMessage { + abstract type: MessageType.Cancel; + abstract id: string; } -class RequestMessage { - type: MessageType.Request; - id: string; - proxyId: string; - method: string; - args: any[]; +abstract class RequestMessage { + abstract type: MessageType.Request; + abstract id: string; + abstract proxyId: string; + abstract method: string; + abstract args: any[]; } -class ReplyMessage { - type: MessageType.Reply; - id: string; - res: any; +abstract class ReplyMessage { + abstract type: MessageType.Reply; + abstract id: string; + abstract res: any; } -class ReplyErrMessage { - type: MessageType.ReplyErr; - id: string; - err: SerializedError; +abstract class ReplyErrMessage { + abstract type: MessageType.ReplyErr; + abstract id: string; + abstract err: SerializedError; } type RPCMessage = RequestMessage | ReplyMessage | ReplyErrMessage | CancelMessage; diff --git a/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts b/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts index d0074cefebe0c..8f37dc593a2b4 100644 --- a/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts +++ b/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts @@ -73,88 +73,88 @@ export class HostedPluginSupport { protected readonly clientId = UUID.uuid4(); - protected container: interfaces.Container; + protected container!: interfaces.Container; @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(HostedPluginServer) - private readonly server: JsonRpcProxy; + private readonly server!: JsonRpcProxy; @inject(HostedPluginWatcher) - private readonly watcher: HostedPluginWatcher; + private readonly watcher!: HostedPluginWatcher; @inject(PluginContributionHandler) - private readonly contributionHandler: PluginContributionHandler; + private readonly contributionHandler!: PluginContributionHandler; @inject(ContributionProvider) @named(MainPluginApiProvider) - protected readonly mainPluginApiProviders: ContributionProvider; + protected readonly mainPluginApiProviders!: ContributionProvider; @inject(PluginServer) - protected readonly pluginServer: PluginServer; + protected readonly pluginServer!: PluginServer; @inject(PreferenceProviderProvider) - protected readonly preferenceProviderProvider: PreferenceProviderProvider; + protected readonly preferenceProviderProvider!: PreferenceProviderProvider; @inject(PreferenceServiceImpl) - private readonly preferenceServiceImpl: PreferenceServiceImpl; + private readonly preferenceServiceImpl!: PreferenceServiceImpl; @inject(PluginPathsService) - private readonly pluginPathsService: PluginPathsService; + private readonly pluginPathsService!: PluginPathsService; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @inject(CommandRegistry) - protected readonly commands: CommandRegistry; + protected readonly commands!: CommandRegistry; @inject(DebugSessionManager) - protected readonly debugSessionManager: DebugSessionManager; + protected readonly debugSessionManager!: DebugSessionManager; @inject(DebugConfigurationManager) - protected readonly debugConfigurationManager: DebugConfigurationManager; + protected readonly debugConfigurationManager!: DebugConfigurationManager; @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; @inject(FileSearchService) - protected readonly fileSearchService: FileSearchService; + protected readonly fileSearchService!: FileSearchService; @inject(FrontendApplicationStateService) - protected readonly appState: FrontendApplicationStateService; + protected readonly appState!: FrontendApplicationStateService; @inject(PluginViewRegistry) - protected readonly viewRegistry: PluginViewRegistry; + protected readonly viewRegistry!: PluginViewRegistry; @inject(TaskProviderRegistry) - protected readonly taskProviderRegistry: TaskProviderRegistry; + protected readonly taskProviderRegistry!: TaskProviderRegistry; @inject(TaskResolverRegistry) - protected readonly taskResolverRegistry: TaskResolverRegistry; + protected readonly taskResolverRegistry!: TaskResolverRegistry; @inject(ProgressService) - protected readonly progressService: ProgressService; + protected readonly progressService!: ProgressService; @inject(WebviewEnvironment) - protected readonly webviewEnvironment: WebviewEnvironment; + protected readonly webviewEnvironment!: WebviewEnvironment; @inject(WidgetManager) - protected readonly widgets: WidgetManager; + protected readonly widgets!: WidgetManager; @inject(TerminalService) - protected readonly terminalService: TerminalService; + protected readonly terminalService!: TerminalService; @inject(EnvVariablesServer) - protected readonly envServer: EnvVariablesServer; + protected readonly envServer!: EnvVariablesServer; @inject(JsonSchemaStore) - protected readonly jsonSchemaStore: JsonSchemaStore; + protected readonly jsonSchemaStore!: JsonSchemaStore; @inject(PluginCustomEditorRegistry) - protected readonly customEditorRegistry: PluginCustomEditorRegistry; + protected readonly customEditorRegistry!: PluginCustomEditorRegistry; - private theiaReadyPromise: Promise; + private theiaReadyPromise!: Promise; protected readonly managers = new Map(); @@ -209,10 +209,11 @@ export class HostedPluginSupport { const storeState = widget.storeState.bind(widget); const restoreState = widget.restoreState.bind(widget); - widget.storeState = () => { + widget.storeState = (): WebviewWidget.State => { if (this.webviewRevivers.has(widget.viewType)) { return storeState(); } + // @ts-expect-error TS2322 return undefined; }; diff --git a/packages/plugin-ext/src/hosted/node/hosted-plugin-deployer-handler.ts b/packages/plugin-ext/src/hosted/node/hosted-plugin-deployer-handler.ts index 35b5314771351..7a6a12ee74087 100644 --- a/packages/plugin-ext/src/hosted/node/hosted-plugin-deployer-handler.ts +++ b/packages/plugin-ext/src/hosted/node/hosted-plugin-deployer-handler.ts @@ -27,13 +27,13 @@ import { BackendApplicationConfigProvider } from '@theia/core/lib/node/backend-a export class HostedPluginDeployerHandler implements PluginDeployerHandler { @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(HostedPluginReader) - private readonly reader: HostedPluginReader; + private readonly reader!: HostedPluginReader; @inject(HostedPluginLocalizationService) - private readonly localizationService: HostedPluginLocalizationService; + private readonly localizationService!: HostedPluginLocalizationService; private readonly deployedLocations = new Map>(); diff --git a/packages/plugin-ext/src/hosted/node/hosted-plugin-localization-service.ts b/packages/plugin-ext/src/hosted/node/hosted-plugin-localization-service.ts index 10bba0b938915..df52db44fa9c4 100644 --- a/packages/plugin-ext/src/hosted/node/hosted-plugin-localization-service.ts +++ b/packages/plugin-ext/src/hosted/node/hosted-plugin-localization-service.ts @@ -37,10 +37,10 @@ export interface VSCodeNlsConfig { export class HostedPluginLocalizationService { @inject(LocalizationProvider) - protected readonly localizationProvider: LocalizationProvider; + protected readonly localizationProvider!: LocalizationProvider; @inject(EnvVariablesServer) - protected readonly envVariables: EnvVariablesServer; + protected readonly envVariables!: EnvVariablesServer; protected translationConfigFiles: Map = new Map(); diff --git a/packages/plugin-ext/src/hosted/node/hosted-plugin-process.ts b/packages/plugin-ext/src/hosted/node/hosted-plugin-process.ts index 8aef156a150f7..de9ce050a3781 100644 --- a/packages/plugin-ext/src/hosted/node/hosted-plugin-process.ts +++ b/packages/plugin-ext/src/hosted/node/hosted-plugin-process.ts @@ -41,26 +41,26 @@ export interface HostedPluginProcessConfiguration { export class HostedPluginProcess implements ServerPluginRunner { @inject(HostedPluginProcessConfiguration) - protected configuration: HostedPluginProcessConfiguration; + protected configuration!: HostedPluginProcessConfiguration; @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(HostedPluginCliContribution) - protected readonly cli: HostedPluginCliContribution; + protected readonly cli!: HostedPluginCliContribution; @inject(ContributionProvider) @named(PluginHostEnvironmentVariable) - protected readonly pluginHostEnvironmentVariables: ContributionProvider; + protected readonly pluginHostEnvironmentVariables!: ContributionProvider; @inject(MessageService) - protected readonly messageService: MessageService; + protected readonly messageService!: MessageService; @inject(HostedPluginLocalizationService) - protected readonly localizationService: HostedPluginLocalizationService; + protected readonly localizationService!: HostedPluginLocalizationService; private childProcess: cp.ChildProcess | undefined; - private client: HostedPluginClient; + private client?: HostedPluginClient; private terminatingPluginServer = false; diff --git a/packages/plugin-ext/src/hosted/node/hosted-plugin.ts b/packages/plugin-ext/src/hosted/node/hosted-plugin.ts index ceca7b1bdb897..1000e517c3bf2 100644 --- a/packages/plugin-ext/src/hosted/node/hosted-plugin.ts +++ b/packages/plugin-ext/src/hosted/node/hosted-plugin.ts @@ -30,20 +30,20 @@ export interface IPCConnectionOptions { @injectable() export class HostedPluginSupport { private isPluginProcessRunning = false; - private client: HostedPluginClient; + private client?: HostedPluginClient; @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(HostedPluginProcess) - protected readonly hostedPluginProcess: HostedPluginProcess; + protected readonly hostedPluginProcess!: HostedPluginProcess; /** * Optional runners to delegate some work */ @optional() @multiInject(ServerPluginRunner) - private readonly pluginRunners: ServerPluginRunner[]; + private readonly pluginRunners: ServerPluginRunner[] = []; @postConstruct() protected init(): void { @@ -96,18 +96,20 @@ export class HostedPluginSupport { * Provides additional plugin ids. */ async getExtraDeployedPluginIds(): Promise { - return [].concat.apply([], await Promise.all(this.pluginRunners.map(runner => runner.getExtraDeployedPluginIds()))); + const runnerIds: string[][] = await Promise.all(this.pluginRunners.map(runner => runner.getExtraDeployedPluginIds())); + return Array.prototype.concat(...runnerIds); } /** * Provides additional deployed plugins. */ async getExtraDeployedPlugins(): Promise { - return [].concat.apply([], await Promise.all(this.pluginRunners.map(runner => runner.getExtraDeployedPlugins()))); + const deployedPlugins: DeployedPlugin[][] = await Promise.all(this.pluginRunners.map(runner => runner.getExtraDeployedPlugins())); + return Array.prototype.concat(...deployedPlugins); } sendLog(logPart: LogPart): void { - this.client.log(logPart); + this.client?.log(logPart); } private terminatePluginServer(): void { diff --git a/packages/plugin-ext/src/hosted/node/plugin-host-rpc.ts b/packages/plugin-ext/src/hosted/node/plugin-host-rpc.ts index d521db06dfa4a..ca1c164bc7f42 100644 --- a/packages/plugin-ext/src/hosted/node/plugin-host-rpc.ts +++ b/packages/plugin-ext/src/hosted/node/plugin-host-rpc.ts @@ -40,9 +40,9 @@ import { BackendInitializationFn } from '../../common'; */ export class PluginHostRPC { - private apiFactory: PluginAPIFactory; + private apiFactory!: PluginAPIFactory; - private pluginManager: PluginManagerExtImpl; + private pluginManager!: PluginManagerExtImpl; // eslint-disable-next-line @typescript-eslint/no-explicit-any constructor(protected readonly rpc: any) { @@ -83,10 +83,16 @@ export class PluginHostRPC { ); } + /** + * `initialize` must have been called before. + */ async terminate(): Promise { await this.pluginManager.terminate(); } + /** + * `initialize` must have been called before. + */ initContext(contextPath: string, plugin: Plugin): void { const { name, version } = plugin.rawModel; console.log('PLUGIN_HOST(' + process.pid + '): initializing(' + name + '@' + version + ' with ' + contextPath + ')'); diff --git a/packages/plugin-ext/src/hosted/node/plugin-reader.ts b/packages/plugin-ext/src/hosted/node/plugin-reader.ts index 9a922453a2807..6ed297124fdeb 100644 --- a/packages/plugin-ext/src/hosted/node/plugin-reader.ts +++ b/packages/plugin-ext/src/hosted/node/plugin-reader.ts @@ -28,13 +28,14 @@ import { loadManifest } from './plugin-manifest-loader'; export class HostedPluginReader implements BackendApplicationContribution { @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(MetadataScanner) - protected readonly scanner: MetadataScanner; + protected readonly scanner!: MetadataScanner; @optional() - @multiInject(MetadataProcessor) private readonly metadataProcessors: MetadataProcessor[]; + @multiInject(MetadataProcessor) + private readonly metadataProcessors?: MetadataProcessor[]; /** * Map between a plugin id and its local storage diff --git a/packages/plugin-ext/src/hosted/node/plugin-service.ts b/packages/plugin-ext/src/hosted/node/plugin-service.ts index ef10f01c9a309..34797c12c01eb 100644 --- a/packages/plugin-ext/src/hosted/node/plugin-service.ts +++ b/packages/plugin-ext/src/hosted/node/plugin-service.ts @@ -25,24 +25,24 @@ import { HostedPluginLocalizationService } from './hosted-plugin-localization-se @injectable() export class HostedPluginServerImpl implements HostedPluginServer { @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(HostedPluginDeployerHandler) - protected readonly deployerHandler: HostedPluginDeployerHandler; + protected readonly deployerHandler!: HostedPluginDeployerHandler; @inject(PluginDeployer) - protected readonly pluginDeployer: PluginDeployerImpl; + protected readonly pluginDeployer!: PluginDeployerImpl; @inject(HostedPluginLocalizationService) - protected readonly localizationService: HostedPluginLocalizationService; + protected readonly localizationService!: HostedPluginLocalizationService; @inject(ContributionProvider) @named(Symbol.for(ExtPluginApiProvider)) - protected readonly extPluginAPIContributions: ContributionProvider; + protected readonly extPluginAPIContributions!: ContributionProvider; protected client: HostedPluginClient | undefined; - protected deployedListener: Disposable; + protected deployedListener!: Disposable; constructor( @inject(HostedPluginSupport) private readonly hostedPlugin: HostedPluginSupport) { diff --git a/packages/plugin-ext/src/hosted/node/scanners/scanner-theia.ts b/packages/plugin-ext/src/hosted/node/scanners/scanner-theia.ts index d44b75bdf3f08..8f575cb714958 100644 --- a/packages/plugin-ext/src/hosted/node/scanners/scanner-theia.ts +++ b/packages/plugin-ext/src/hosted/node/scanners/scanner-theia.ts @@ -98,10 +98,10 @@ export class TheiaPluginScanner implements PluginScanner { private readonly _apiType: PluginEngine = 'theiaPlugin'; @inject(GrammarsReader) - private readonly grammarsReader: GrammarsReader; + private readonly grammarsReader!: GrammarsReader; @inject(PluginUriFactory) - protected readonly pluginUriFactory: PluginUriFactory; + protected readonly pluginUriFactory!: PluginUriFactory; get apiType(): PluginEngine { return this._apiType; diff --git a/packages/plugin-ext/src/main/browser/commands.ts b/packages/plugin-ext/src/main/browser/commands.ts index 4409035b70dc9..66136486240c5 100644 --- a/packages/plugin-ext/src/main/browser/commands.ts +++ b/packages/plugin-ext/src/main/browser/commands.ts @@ -64,9 +64,8 @@ export class OpenUriCommandHandler { class OpenNewTabDialog extends AbstractDialog { protected readonly windowService: WindowService; protected readonly openButton: HTMLButtonElement; - protected readonly messageNode: HTMLDivElement; protected readonly linkNode: HTMLAnchorElement; - value: string; + protected _value?: string; constructor(windowService: WindowService) { super({ @@ -88,8 +87,15 @@ class OpenNewTabDialog extends AbstractDialog { this.openButton = this.appendAcceptButton('Open'); } + get value(): string { + if (!this._value) { + throw new Error('OpenNewTabDialog._value is not set'); + } + return this._value; + } + showOpenNewTabDialog(uri: string): void { - this.value = uri; + this._value = uri; this.linkNode.innerHTML = DOMPurify.sanitize(uri); this.linkNode.href = uri; diff --git a/packages/plugin-ext/src/main/browser/comments/comments-context-key-service.ts b/packages/plugin-ext/src/main/browser/comments/comments-context-key-service.ts index 63b91f89bfe32..4158c7f7a6d77 100644 --- a/packages/plugin-ext/src/main/browser/comments/comments-context-key-service.ts +++ b/packages/plugin-ext/src/main/browser/comments/comments-context-key-service.ts @@ -22,13 +22,13 @@ import { Emitter } from '@theia/core/lib/common'; export class CommentsContextKeyService { @inject(ContextKeyService) - protected readonly contextKeyService: ContextKeyService; + protected readonly contextKeyService!: ContextKeyService; protected readonly contextKeys: Set = new Set(); protected readonly onDidChangeEmitter = new Emitter(); readonly onDidChange = this.onDidChangeEmitter.event; - protected _commentIsEmpty: ContextKey; - protected _commentController: ContextKey; - protected _comment: ContextKey; + protected _commentIsEmpty!: ContextKey; + protected _commentController!: ContextKey; + protected _comment!: ContextKey; get commentController(): ContextKey { return this._commentController; diff --git a/packages/plugin-ext/src/main/browser/comments/comments-contribution.ts b/packages/plugin-ext/src/main/browser/comments/comments-contribution.ts index eb70dc962f383..49852bd182673 100644 --- a/packages/plugin-ext/src/main/browser/comments/comments-contribution.ts +++ b/packages/plugin-ext/src/main/browser/comments/comments-contribution.ts @@ -40,10 +40,10 @@ export class CommentsContribution { private commentInfos: CommentInfoMain[]; private emptyThreadsToAddQueue: [number, EditorMouseEvent | undefined][] = []; - @inject(MenuModelRegistry) protected readonly menus: MenuModelRegistry; - @inject(CommentsContextKeyService) protected readonly commentsContextKeyService: CommentsContextKeyService; - @inject(ContextKeyService) protected readonly contextKeyService: ContextKeyService; - @inject(CommandRegistry) protected readonly commands: CommandRegistry; + @inject(MenuModelRegistry) protected readonly menus!: MenuModelRegistry; + @inject(CommentsContextKeyService) protected readonly commentsContextKeyService!: CommentsContextKeyService; + @inject(ContextKeyService) protected readonly contextKeyService!: ContextKeyService; + @inject(CommandRegistry) protected readonly commands!: CommandRegistry; constructor(@inject(CommentingRangeDecorator) protected readonly rangeDecorator: CommentingRangeDecorator, @inject(CommentsService) protected readonly commentService: CommentsService, diff --git a/packages/plugin-ext/src/main/browser/custom-editors/custom-editor-contribution.ts b/packages/plugin-ext/src/main/browser/custom-editors/custom-editor-contribution.ts index 94ae908e57adb..891a57b720177 100644 --- a/packages/plugin-ext/src/main/browser/custom-editors/custom-editor-contribution.ts +++ b/packages/plugin-ext/src/main/browser/custom-editors/custom-editor-contribution.ts @@ -23,7 +23,7 @@ import { CustomEditorWidget } from './custom-editor-widget'; export class CustomEditorContribution implements CommandContribution { @inject(ApplicationShell) - protected readonly shell: ApplicationShell; + protected readonly shell!: ApplicationShell; registerCommands(commands: CommandRegistry): void { commands.registerHandler(CommonCommands.UNDO.id, { diff --git a/packages/plugin-ext/src/main/browser/custom-editors/custom-editor-widget.ts b/packages/plugin-ext/src/main/browser/custom-editors/custom-editor-widget.ts index 229073c9b970e..94162a5e058c6 100644 --- a/packages/plugin-ext/src/main/browser/custom-editors/custom-editor-widget.ts +++ b/packages/plugin-ext/src/main/browser/custom-editors/custom-editor-widget.ts @@ -27,24 +27,41 @@ import { CustomEditorModel } from './custom-editors-main'; export class CustomEditorWidget extends WebviewWidget implements SaveableSource, NavigatableWidget { static FACTORY_ID = 'plugin-custom-editor'; - id: string; - resource: URI; + id!: string; + + protected _resource?: URI; + protected _modelRef?: Reference; + + get resource(): URI { + if (!this._resource) { + throw new Error('CustomEditorWidget._resource is not set'); + } + return this._resource; + } + + set resource(value) { + this._resource = value; + } - protected _modelRef: Reference; get modelRef(): Reference { + if (!this._modelRef) { + throw new Error('CustomEditorWidget._modelRef is not set'); + } return this._modelRef; } + set modelRef(modelRef: Reference) { this._modelRef = modelRef; this.doUpdateContent(); Saveable.apply(this); } + get saveable(): Saveable { - return this._modelRef.object; + return this.modelRef.object; } @inject(UndoRedoService) - protected readonly undoRedoService: UndoRedoService; + protected readonly undoRedoService!: UndoRedoService; @postConstruct() protected init(): void { @@ -66,11 +83,11 @@ export class CustomEditorWidget extends WebviewWidget implements SaveableSource, } async save(options?: SaveOptions): Promise { - await this._modelRef.object.saveCustomEditor(options); + await this.modelRef.object.saveCustomEditor(options); } async saveAs(source: URI, target: URI, options?: SaveOptions): Promise { - const result = await this._modelRef.object.saveCustomEditorAs(source, target, options); + const result = await this.modelRef.object.saveCustomEditorAs(source, target, options); this.doMove(target); return result; } diff --git a/packages/plugin-ext/src/main/browser/custom-editors/custom-editors-main.ts b/packages/plugin-ext/src/main/browser/custom-editors/custom-editors-main.ts index c0b9eeb1dbe8b..13c7d46386140 100644 --- a/packages/plugin-ext/src/main/browser/custom-editors/custom-editors-main.ts +++ b/packages/plugin-ext/src/main/browser/custom-editors/custom-editors-main.ts @@ -487,7 +487,6 @@ export class CustomTextEditorModel implements CustomEditorModel { private readonly toDispose = new DisposableCollection(); private readonly onDirtyChangedEmitter = new Emitter(); readonly onDirtyChanged = this.onDirtyChangedEmitter.event; - readonly autoSave: 'on' | 'off'; static async create( viewType: string, @@ -519,6 +518,10 @@ export class CustomTextEditorModel implements CustomEditorModel { this.model.dispose(); } + get autoSave(): 'on' | 'off' { + return this.model.object.autoSave; + } + get resource(): URI { return URI.file(this.editorResource.path.toString()); } diff --git a/packages/plugin-ext/src/main/browser/custom-editors/glob.ts b/packages/plugin-ext/src/main/browser/custom-editors/glob.ts index d915b91d76187..4392bff0cdcbc 100644 --- a/packages/plugin-ext/src/main/browser/custom-editors/glob.ts +++ b/packages/plugin-ext/src/main/browser/custom-editors/glob.ts @@ -589,6 +589,7 @@ function parsedExpression(expression: IExpression, options: IGlobOptions): Parse if (!parsedPatterns.some(parsedPattern => (parsedPattern).requiresSiblings!)) { if (n === 1) { + // @ts-expect-error TS2322 return parsedPatterns[0]; } @@ -619,6 +620,7 @@ function parsedExpression(expression: IExpression, options: IGlobOptions): Parse resultExpression.allPaths = allPaths; } + // @ts-expect-error TS2322 return resultExpression; } @@ -656,6 +658,7 @@ function parsedExpression(expression: IExpression, options: IGlobOptions): Parse resultExpression.allPaths = allPaths; } + // @ts-expect-error TS2322 return resultExpression; } diff --git a/packages/plugin-ext/src/main/browser/custom-editors/plugin-custom-editor-registry.ts b/packages/plugin-ext/src/main/browser/custom-editors/plugin-custom-editor-registry.ts index 5c871ba529681..e84c8801ea383 100644 --- a/packages/plugin-ext/src/main/browser/custom-editors/plugin-custom-editor-registry.ts +++ b/packages/plugin-ext/src/main/browser/custom-editors/plugin-custom-editor-registry.ts @@ -36,22 +36,22 @@ export class PluginCustomEditorRegistry { readonly onWillOpenCustomEditor = this.onWillOpenCustomEditorEmitter.event; @inject(DefaultOpenerService) - protected readonly defaultOpenerService: DefaultOpenerService; + protected readonly defaultOpenerService!: DefaultOpenerService; @inject(MenuModelRegistry) - protected readonly menuModelRegistry: MenuModelRegistry; + protected readonly menuModelRegistry!: MenuModelRegistry; @inject(CommandRegistry) - protected readonly commandRegistry: CommandRegistry; + protected readonly commandRegistry!: CommandRegistry; @inject(SelectionService) - protected readonly selectionService: SelectionService; + protected readonly selectionService!: SelectionService; @inject(WidgetManager) - protected readonly widgetManager: WidgetManager; + protected readonly widgetManager!: WidgetManager; @inject(ApplicationShell) - protected readonly shell: ApplicationShell; + protected readonly shell!: ApplicationShell; @postConstruct() protected init(): void { diff --git a/packages/plugin-ext/src/main/browser/debug/plugin-debug-service.ts b/packages/plugin-ext/src/main/browser/debug/plugin-debug-service.ts index c0b94290e777a..3b6b6a9f4820b 100644 --- a/packages/plugin-ext/src/main/browser/debug/plugin-debug-service.ts +++ b/packages/plugin-ext/src/main/browser/debug/plugin-debug-service.ts @@ -55,12 +55,12 @@ export class PluginDebugService implements DebugService, PluginDebugAdapterContr // maps session and contribution protected readonly sessionId2contrib = new Map(); - protected delegated: DebugService; + protected delegated!: DebugService; @inject(WebSocketConnectionProvider) - protected readonly connectionProvider: WebSocketConnectionProvider; + protected readonly connectionProvider!: WebSocketConnectionProvider; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @postConstruct() protected init(): void { diff --git a/packages/plugin-ext/src/main/browser/debug/plugin-debug-session-contribution-registry.ts b/packages/plugin-ext/src/main/browser/debug/plugin-debug-session-contribution-registry.ts index e789fe4f593d6..e6aa9c97753fb 100644 --- a/packages/plugin-ext/src/main/browser/debug/plugin-debug-session-contribution-registry.ts +++ b/packages/plugin-ext/src/main/browser/debug/plugin-debug-session-contribution-registry.ts @@ -45,7 +45,7 @@ export class PluginDebugSessionContributionRegistry implements DebugSessionContr protected readonly contribs = new Map(); @inject(ContributionProvider) @named(DebugSessionContribution) - protected readonly contributions: ContributionProvider; + protected readonly contributions!: ContributionProvider; @postConstruct() protected init(): void { diff --git a/packages/plugin-ext/src/main/browser/editor/untitled-resource.ts b/packages/plugin-ext/src/main/browser/editor/untitled-resource.ts index 8c2dcb7852fd7..f0818c7f19dcf 100644 --- a/packages/plugin-ext/src/main/browser/editor/untitled-resource.ts +++ b/packages/plugin-ext/src/main/browser/editor/untitled-resource.ts @@ -28,7 +28,7 @@ let index = 0; export class UntitledResourceResolver implements ResourceResolver { @inject(FileResourceResolver) - protected readonly fileResourceResolver: FileResourceResolver; + protected readonly fileResourceResolver!: FileResourceResolver; protected readonly resources = new Map(); diff --git a/packages/plugin-ext/src/main/browser/keybindings/keybindings-contribution-handler.ts b/packages/plugin-ext/src/main/browser/keybindings/keybindings-contribution-handler.ts index 8ce2a7174feff..a07cc07d767db 100644 --- a/packages/plugin-ext/src/main/browser/keybindings/keybindings-contribution-handler.ts +++ b/packages/plugin-ext/src/main/browser/keybindings/keybindings-contribution-handler.ts @@ -26,7 +26,7 @@ import { DisposableCollection } from '@theia/core'; export class KeybindingsContributionPointHandler { @inject(KeybindingRegistry) - private readonly keybindingRegistry: KeybindingRegistry; + private readonly keybindingRegistry!: KeybindingRegistry; handle(contributions: PluginContribution): Disposable { if (!contributions || !contributions.keybindings) { diff --git a/packages/plugin-ext/src/main/browser/languages-main.ts b/packages/plugin-ext/src/main/browser/languages-main.ts index bdfbd58d6906b..61ec087877111 100644 --- a/packages/plugin-ext/src/main/browser/languages-main.ts +++ b/packages/plugin-ext/src/main/browser/languages-main.ts @@ -63,13 +63,13 @@ import { DiagnosticTag } from '@theia/core/shared/vscode-languageserver-protocol export class LanguagesMainImpl implements LanguagesMain, Disposable { @inject(MonacoLanguages) - private readonly monacoLanguages: MonacoLanguages; + private readonly monacoLanguages!: MonacoLanguages; @inject(ProblemManager) - private readonly problemManager: ProblemManager; + private readonly problemManager!: ProblemManager; @inject(CallHierarchyServiceProvider) - private readonly callHierarchyServiceContributionRegistry: CallHierarchyServiceProvider; + private readonly callHierarchyServiceContributionRegistry!: CallHierarchyServiceProvider; private readonly proxy: LanguagesExt; private readonly services = new Map(); diff --git a/packages/plugin-ext/src/main/browser/menus/menus-contribution-handler.ts b/packages/plugin-ext/src/main/browser/menus/menus-contribution-handler.ts index 759cefe0a10d4..ba87d356c65bc 100644 --- a/packages/plugin-ext/src/main/browser/menus/menus-contribution-handler.ts +++ b/packages/plugin-ext/src/main/browser/menus/menus-contribution-handler.ts @@ -61,37 +61,37 @@ export class CodeEditorWidgetUtil { export class MenusContributionPointHandler { @inject(MenuModelRegistry) - protected readonly menuRegistry: MenuModelRegistry; + protected readonly menuRegistry!: MenuModelRegistry; @inject(CommandRegistry) - protected readonly commands: CommandRegistry; + protected readonly commands!: CommandRegistry; @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(ScmService) - protected readonly scmService: ScmService; + protected readonly scmService!: ScmService; @inject(QuickCommandService) @optional() - protected readonly quickCommandService: QuickCommandService; + protected readonly quickCommandService?: QuickCommandService; @inject(TabBarToolbarRegistry) - protected readonly tabBarToolbar: TabBarToolbarRegistry; + protected readonly tabBarToolbar!: TabBarToolbarRegistry; @inject(SelectionService) - protected readonly selectionService: SelectionService; + protected readonly selectionService!: SelectionService; @inject(ResourceContextKey) - protected readonly resourceContextKey: ResourceContextKey; + protected readonly resourceContextKey!: ResourceContextKey; @inject(ViewContextKeyService) - protected readonly viewContextKeys: ViewContextKeyService; + protected readonly viewContextKeys!: ViewContextKeyService; @inject(ContextKeyService) - protected readonly contextKeyService: ContextKeyService; + protected readonly contextKeyService!: ContextKeyService; @inject(CodeEditorWidgetUtil) - protected readonly codeEditorWidgetUtil: CodeEditorWidgetUtil; + protected readonly codeEditorWidgetUtil!: CodeEditorWidgetUtil; handle(plugin: DeployedPlugin): Disposable { const allMenus = plugin.contributes && plugin.contributes.menus; @@ -226,6 +226,10 @@ export class MenusContributionPointHandler { } protected registerCommandPaletteAction(menu: Menu): Disposable { + if (!this.quickCommandService) { + + throw new Error('MenusContributionPointHandler.quickCommandService is not set'); + } if (menu.command && menu.when) { return this.quickCommandService.pushCommandContext(menu.command, menu.when); } @@ -524,14 +528,18 @@ export class MenusContributionPointHandler { const commandId = this.createSyntheticCommandId(menu.command, { prefix: '__plugin.menu.action.' }); const command: Command = { id: commandId }; toDispose.push(this.commands.registerCommand(command, handler(menu.command))); - toDispose.push(this.quickCommandService?.pushCommandContext(commandId, 'false')); + if (this.quickCommandService) { + toDispose.push(this.quickCommandService.pushCommandContext(commandId, 'false')); + } let altId: string | undefined; if (menu.alt) { altId = this.createSyntheticCommandId(menu.alt, { prefix: '__plugin.menu.action.' }); const alt: Command = { id: altId }; toDispose.push(this.commands.registerCommand(alt, handler(menu.alt))); - toDispose.push(this.quickCommandService?.pushCommandContext(altId, 'false')); + if (this.quickCommandService) { + toDispose.push(this.quickCommandService.pushCommandContext(altId, 'false')); + } toDispose.push(this.onDidRegisterCommand(menu.alt, pluginCommand => { alt.category = pluginCommand.category; alt.label = pluginCommand.label; diff --git a/packages/plugin-ext/src/main/browser/output-channel-registry-main.ts b/packages/plugin-ext/src/main/browser/output-channel-registry-main.ts index d90f36a326dd4..7fa5858f19747 100644 --- a/packages/plugin-ext/src/main/browser/output-channel-registry-main.ts +++ b/packages/plugin-ext/src/main/browser/output-channel-registry-main.ts @@ -23,7 +23,7 @@ import { OutputChannelRegistryMain, PluginInfo } from '../../common/plugin-api-r export class OutputChannelRegistryMainImpl implements OutputChannelRegistryMain { @inject(CommandService) - protected readonly commandService: CommandService; + protected readonly commandService!: CommandService; $append(name: string, text: string, pluginInfo: PluginInfo): PromiseLike { this.commandService.executeCommand(OutputCommands.APPEND.id, { name, text }); diff --git a/packages/plugin-ext/src/main/browser/plugin-contribution-handler.ts b/packages/plugin-ext/src/main/browser/plugin-contribution-handler.ts index fc9dd2232237e..51cd9f82d075e 100644 --- a/packages/plugin-ext/src/main/browser/plugin-contribution-handler.ts +++ b/packages/plugin-ext/src/main/browser/plugin-contribution-handler.ts @@ -47,64 +47,64 @@ export class PluginContributionHandler { private injections = new Map(); @inject(TextmateRegistry) - private readonly grammarsRegistry: TextmateRegistry; + private readonly grammarsRegistry!: TextmateRegistry; @inject(PluginViewRegistry) - private readonly viewRegistry: PluginViewRegistry; + private readonly viewRegistry!: PluginViewRegistry; @inject(PluginCustomEditorRegistry) - private readonly customEditorRegistry: PluginCustomEditorRegistry; + private readonly customEditorRegistry!: PluginCustomEditorRegistry; @inject(MenusContributionPointHandler) - private readonly menusContributionHandler: MenusContributionPointHandler; + private readonly menusContributionHandler!: MenusContributionPointHandler; @inject(PreferenceSchemaProvider) - private readonly preferenceSchemaProvider: PreferenceSchemaProvider; + private readonly preferenceSchemaProvider!: PreferenceSchemaProvider; @inject(PreferenceLanguageOverrideService) - private readonly preferenceOverrideService: PreferenceLanguageOverrideService; + private readonly preferenceOverrideService!: PreferenceLanguageOverrideService; @inject(MonacoTextmateService) - private readonly monacoTextmateService: MonacoTextmateService; + private readonly monacoTextmateService!: MonacoTextmateService; @inject(KeybindingsContributionPointHandler) - private readonly keybindingsContributionHandler: KeybindingsContributionPointHandler; + private readonly keybindingsContributionHandler!: KeybindingsContributionPointHandler; @inject(MonacoSnippetSuggestProvider) - protected readonly snippetSuggestProvider: MonacoSnippetSuggestProvider; + protected readonly snippetSuggestProvider!: MonacoSnippetSuggestProvider; @inject(CommandRegistry) - protected readonly commands: CommandRegistry; + protected readonly commands!: CommandRegistry; @inject(PluginSharedStyle) - protected readonly style: PluginSharedStyle; + protected readonly style!: PluginSharedStyle; @inject(TaskDefinitionRegistry) - protected readonly taskDefinitionRegistry: TaskDefinitionRegistry; + protected readonly taskDefinitionRegistry!: TaskDefinitionRegistry; @inject(ProblemMatcherRegistry) - protected readonly problemMatcherRegistry: ProblemMatcherRegistry; + protected readonly problemMatcherRegistry!: ProblemMatcherRegistry; @inject(ProblemPatternRegistry) - protected readonly problemPatternRegistry: ProblemPatternRegistry; + protected readonly problemPatternRegistry!: ProblemPatternRegistry; @inject(PluginDebugService) - protected readonly debugService: PluginDebugService; + protected readonly debugService!: PluginDebugService; @inject(DebugSchemaUpdater) - protected readonly debugSchema: DebugSchemaUpdater; + protected readonly debugSchema!: DebugSchemaUpdater; @inject(MonacoThemingService) - protected readonly monacoThemingService: MonacoThemingService; + protected readonly monacoThemingService!: MonacoThemingService; @inject(ColorRegistry) - protected readonly colors: ColorRegistry; + protected readonly colors!: ColorRegistry; @inject(PluginIconThemeService) - protected readonly iconThemeService: PluginIconThemeService; + protected readonly iconThemeService!: PluginIconThemeService; @inject(ContributionProvider) @named(LabelProviderContribution) - protected readonly contributionProvider: ContributionProvider; + protected readonly contributionProvider!: ContributionProvider; protected readonly commandHandlers = new Map(); diff --git a/packages/plugin-ext/src/main/browser/plugin-ext-deploy-command.ts b/packages/plugin-ext/src/main/browser/plugin-ext-deploy-command.ts index 367e4fe7b8788..b5576f07e16cd 100644 --- a/packages/plugin-ext/src/main/browser/plugin-ext-deploy-command.ts +++ b/packages/plugin-ext/src/main/browser/plugin-ext-deploy-command.ts @@ -28,10 +28,10 @@ export class PluginExtDeployCommandService /* implements QuickOpenModel */ { }; @inject(QuickInputService) @optional() - protected readonly quickInputService: QuickInputService; + protected readonly quickInputService?: QuickInputService; @inject(PluginServer) - protected readonly pluginServer: PluginServer; + protected readonly pluginServer!: PluginServer; deploy(): void { this.quickInputService?.showQuickPick([], diff --git a/packages/plugin-ext/src/main/browser/plugin-ext-widget.tsx b/packages/plugin-ext/src/main/browser/plugin-ext-widget.tsx index 38dde4f5acd4c..3678bbcd28364 100644 --- a/packages/plugin-ext/src/main/browser/plugin-ext-widget.tsx +++ b/packages/plugin-ext/src/main/browser/plugin-ext-widget.tsx @@ -29,10 +29,10 @@ import { codicon } from '@theia/core/lib/browser'; export class PluginWidget extends ReactWidget { @inject(HostedPluginSupport) - protected readonly pluginService: HostedPluginSupport; + protected readonly pluginService!: HostedPluginSupport; @inject(ProgressBarFactory) - protected readonly progressBarFactory: ProgressBarFactory; + protected readonly progressBarFactory!: ProgressBarFactory; constructor() { super(); diff --git a/packages/plugin-ext/src/main/browser/plugin-frontend-contribution.ts b/packages/plugin-ext/src/main/browser/plugin-frontend-contribution.ts index d32d319d845f1..d3471851cd61b 100644 --- a/packages/plugin-ext/src/main/browser/plugin-frontend-contribution.ts +++ b/packages/plugin-ext/src/main/browser/plugin-frontend-contribution.ts @@ -24,10 +24,10 @@ import URI from '@theia/core/lib/common/uri'; export class PluginApiFrontendContribution implements CommandContribution { @inject(PluginExtDeployCommandService) - protected readonly pluginExtDeployCommandService: PluginExtDeployCommandService; + protected readonly pluginExtDeployCommandService!: PluginExtDeployCommandService; @inject(OpenUriCommandHandler) - protected readonly openUriCommandHandler: OpenUriCommandHandler; + protected readonly openUriCommandHandler!: OpenUriCommandHandler; registerCommands(commands: CommandRegistry): void { diff --git a/packages/plugin-ext/src/main/browser/plugin-icon-theme-service.ts b/packages/plugin-ext/src/main/browser/plugin-icon-theme-service.ts index 8740ae7e074eb..24fc0a76094c3 100644 --- a/packages/plugin-ext/src/main/browser/plugin-icon-theme-service.ts +++ b/packages/plugin-ext/src/main/browser/plugin-icon-theme-service.ts @@ -83,14 +83,14 @@ export const PluginIconThemeFactory = Symbol('PluginIconThemeFactory'); export type PluginIconThemeFactory = (definition: PluginIconThemeDefinition) => PluginIconTheme; @injectable() -export class PluginIconThemeDefinition implements IconThemeDefinition, IconThemeContribution { - id: string; - label: string; +export abstract class PluginIconThemeDefinition implements IconThemeDefinition, IconThemeContribution { + abstract id: string; + abstract label: string; description?: string; - uri: string; + abstract uri: string; uiTheme?: UiTheme; - pluginId: string; - packageUri: string; + abstract pluginId: string; + abstract packageUri: string; hasFileIcons?: boolean; hasFolderIcons?: boolean; hidesExplorerArrows?: boolean; @@ -99,17 +99,24 @@ export class PluginIconThemeDefinition implements IconThemeDefinition, IconTheme @injectable() export class PluginIconTheme extends PluginIconThemeDefinition implements IconTheme, Disposable { + // The following fields should be set in the `postConstruct` method. + id!: string; + label!: string; + uri!: string; + pluginId!: string; + packageUri!: string; + @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(PluginIconThemeDefinition) - protected readonly definition: PluginIconThemeDefinition; + protected readonly definition!: PluginIconThemeDefinition; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; protected readonly onDidChangeEmitter = new Emitter(); readonly onDidChange = this.onDidChangeEmitter.event; @@ -121,8 +128,8 @@ export class PluginIconTheme extends PluginIconThemeDefinition implements IconTh this.toDeactivate, this.toDisposeStyleElement, this.toUnload, this.onDidChangeEmitter ); - protected packageRootUri: URI; - protected locationUri: URI; + protected packageRootUri!: URI; + protected locationUri!: URI; protected styleSheetContent: string | undefined; protected readonly icons = new Set(); @@ -531,10 +538,10 @@ export class PluginIconTheme extends PluginIconThemeDefinition implements IconTh export class PluginIconThemeService implements LabelProviderContribution { @inject(IconThemeService) - protected readonly iconThemeService: IconThemeService; + protected readonly iconThemeService!: IconThemeService; @inject(PluginIconThemeFactory) - protected readonly iconThemeFactory: PluginIconThemeFactory; + protected readonly iconThemeFactory!: PluginIconThemeFactory; protected readonly onDidChangeEmitter = new Emitter(); readonly onDidChange = this.onDidChangeEmitter.event; diff --git a/packages/plugin-ext/src/main/browser/plugin-shared-style.ts b/packages/plugin-ext/src/main/browser/plugin-shared-style.ts index 9436dd4701e67..99303ec4b9544 100644 --- a/packages/plugin-ext/src/main/browser/plugin-shared-style.ts +++ b/packages/plugin-ext/src/main/browser/plugin-shared-style.ts @@ -33,7 +33,7 @@ export interface PluginIcon extends Disposable { @injectable() export class PluginSharedStyle { - protected style: HTMLStyleElement; + protected style!: HTMLStyleElement; protected readonly rules: { selector: string; body: (theme: Theme) => string diff --git a/packages/plugin-ext/src/main/browser/quick-open-main.ts b/packages/plugin-ext/src/main/browser/quick-open-main.ts index a31d26c46a0ba..1e842e2aecbd3 100644 --- a/packages/plugin-ext/src/main/browser/quick-open-main.ts +++ b/packages/plugin-ext/src/main/browser/quick-open-main.ts @@ -209,8 +209,8 @@ export class QuickOpenMainImpl implements QuickOpenMain, Disposable { quickPick.onDidChangeSelection((items: Array) => { this.proxy.$onDidChangeSelection(sessionId, items.map(item => (item as TransferQuickPickItems).handle)); }); - quickPick.onDidTriggerButton((button: QuickInputButtonHandle) => { - this.proxy.$acceptOnDidTriggerButton(sessionId, button); + quickPick.onDidTriggerButton(button => { + this.proxy.$acceptOnDidTriggerButton(sessionId, button as QuickInputButtonHandle); }); quickPick.onDidChangeValue((value: string) => { this.proxy.$acceptDidChangeValue(sessionId, value); @@ -227,8 +227,8 @@ export class QuickOpenMainImpl implements QuickOpenMain, Disposable { inputBox.onDidAccept(() => { this.proxy.$acceptOnDidAccept(sessionId); }); - inputBox.onDidTriggerButton((button: QuickInputButtonHandle) => { - this.proxy.$acceptOnDidTriggerButton(sessionId, button); + inputBox.onDidTriggerButton(button => { + this.proxy.$acceptOnDidTriggerButton(sessionId, button as QuickInputButtonHandle); }); inputBox.onDidChangeValue((value: string) => { this.proxy.$acceptDidChangeValue(sessionId, value); diff --git a/packages/plugin-ext/src/main/browser/selection-provider-command.ts b/packages/plugin-ext/src/main/browser/selection-provider-command.ts index 554ad4110fa9a..f3e454d9e545b 100644 --- a/packages/plugin-ext/src/main/browser/selection-provider-command.ts +++ b/packages/plugin-ext/src/main/browser/selection-provider-command.ts @@ -30,7 +30,7 @@ export namespace SelectionProviderCommands { @injectable() export class SelectionProviderCommandContribution implements CommandContribution { - @inject(SelectionService) protected readonly selectionService: SelectionService; + @inject(SelectionService) protected readonly selectionService!: SelectionService; registerCommands(commands: CommandRegistry): void { commands.registerCommand(SelectionProviderCommands.GET_SELECTED_CONTEXT, this.newMultiUriAwareCommandHandler({ diff --git a/packages/plugin-ext/src/main/browser/view/plugin-tree-view-node-label-provider.ts b/packages/plugin-ext/src/main/browser/view/plugin-tree-view-node-label-provider.ts index aa02de38cbffa..87e4271decc09 100644 --- a/packages/plugin-ext/src/main/browser/view/plugin-tree-view-node-label-provider.ts +++ b/packages/plugin-ext/src/main/browser/view/plugin-tree-view-node-label-provider.ts @@ -25,10 +25,10 @@ import { TreeNode } from '@theia/core/lib/browser/tree/tree'; export class PluginTreeViewNodeLabelProvider implements LabelProviderContribution { @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(TreeLabelProvider) - protected readonly treeLabelProvider: TreeLabelProvider; + protected readonly treeLabelProvider!: TreeLabelProvider; // eslint-disable-next-line @typescript-eslint/no-explicit-any canHandle(element: TreeViewNode | any): number { diff --git a/packages/plugin-ext/src/main/browser/view/plugin-view-registry.ts b/packages/plugin-ext/src/main/browser/view/plugin-view-registry.ts index 187b56df2f2e7..14e0aa03df89b 100644 --- a/packages/plugin-ext/src/main/browser/view/plugin-view-registry.ts +++ b/packages/plugin-ext/src/main/browser/view/plugin-view-registry.ts @@ -51,37 +51,37 @@ export type ViewDataProvider = (params: { state?: object, viewInfo: View }) => P export class PluginViewRegistry implements FrontendApplicationContribution { @inject(ApplicationShell) - protected readonly shell: ApplicationShell; + protected readonly shell!: ApplicationShell; @inject(PluginSharedStyle) - protected readonly style: PluginSharedStyle; + protected readonly style!: PluginSharedStyle; @inject(WidgetManager) - protected readonly widgetManager: WidgetManager; + protected readonly widgetManager!: WidgetManager; @inject(ScmContribution) - protected readonly scm: ScmContribution; + protected readonly scm!: ScmContribution; @inject(FileNavigatorContribution) - protected readonly explorer: FileNavigatorContribution; + protected readonly explorer!: FileNavigatorContribution; @inject(DebugFrontendApplicationContribution) - protected readonly debug: DebugFrontendApplicationContribution; + protected readonly debug!: DebugFrontendApplicationContribution; @inject(CommandRegistry) - protected readonly commands: CommandRegistry; + protected readonly commands!: CommandRegistry; @inject(MenuModelRegistry) - protected readonly menus: MenuModelRegistry; + protected readonly menus!: MenuModelRegistry; @inject(QuickViewService) @optional() - protected readonly quickView: QuickViewService; + protected readonly quickView?: QuickViewService; @inject(ContextKeyService) - protected readonly contextKeyService: ContextKeyService; + protected readonly contextKeyService!: ContextKeyService; @inject(ViewContextKeyService) - protected readonly viewContextKeys: ViewContextKeyService; + protected readonly viewContextKeys!: ViewContextKeyService; protected readonly onDidExpandViewEmitter = new Emitter(); readonly onDidExpandView = this.onDidExpandViewEmitter.event; @@ -259,15 +259,17 @@ export class PluginViewRegistry implements FrontendApplicationContribution { commandId: toggleCommandId, label: options.label })); - toDispose.push(this.quickView?.registerItem({ - label: options.label, - open: async () => { - const widget = await this.openViewContainer(id); - if (widget) { - this.shell.activateWidget(widget.id); + if (this.quickView) { + toDispose.push(this.quickView.registerItem({ + label: options.label, + open: async () => { + const widget = await this.openViewContainer(id); + if (widget) { + this.shell.activateWidget(widget.id); + } } - } - })); + })); + } toDispose.push(Disposable.create(async () => { const widget = await this.getPluginViewContainer(id); if (widget) { @@ -309,11 +311,13 @@ export class PluginViewRegistry implements FrontendApplicationContribution { toDispose.push(Disposable.create(() => this.viewClauseContexts.delete(view.id))); } } - toDispose.push(this.quickView?.registerItem({ - label: view.name, - when: view.when, - open: () => this.openView(view.id, { activate: true }) - })); + if (this.quickView) { + toDispose.push(this.quickView.registerItem({ + label: view.name, + when: view.when, + open: () => this.openView(view.id, { activate: true }) + })); + } toDispose.push(this.commands.registerCommand({ id: `${view.id}.focus` }, { execute: async () => { await this.openView(view.id, { activate: true }); } })); diff --git a/packages/plugin-ext/src/main/browser/view/plugin-view-widget.ts b/packages/plugin-ext/src/main/browser/view/plugin-view-widget.ts index 90d65b892dfb0..49e5b32d27110 100644 --- a/packages/plugin-ext/src/main/browser/view/plugin-view-widget.ts +++ b/packages/plugin-ext/src/main/browser/view/plugin-view-widget.ts @@ -26,25 +26,25 @@ import { DescriptionWidget } from '@theia/core/lib/browser/view-container'; import { Emitter } from '@theia/core/lib/common'; @injectable() -export class PluginViewWidgetIdentifier { - id: string; - viewId: string; +export abstract class PluginViewWidgetIdentifier { + abstract id: string; + abstract viewId: string; } @injectable() export class PluginViewWidget extends Panel implements StatefulWidget, DescriptionWidget { @inject(MenuModelRegistry) - protected readonly menus: MenuModelRegistry; + protected readonly menus!: MenuModelRegistry; @inject(CommandRegistry) - protected readonly commands: CommandRegistry; + protected readonly commands!: CommandRegistry; @inject(ViewContextKeyService) - protected readonly contextKeys: ViewContextKeyService; + protected readonly contextKeys!: ViewContextKeyService; @inject(PluginViewWidgetIdentifier) - readonly options: PluginViewWidgetIdentifier; + readonly options!: PluginViewWidgetIdentifier; currentViewContainerId: string | undefined; diff --git a/packages/plugin-ext/src/main/browser/view/tree-view-widget.tsx b/packages/plugin-ext/src/main/browser/view/tree-view-widget.tsx index 41ec551adb89c..f6fb8b510aad7 100644 --- a/packages/plugin-ext/src/main/browser/view/tree-view-widget.tsx +++ b/packages/plugin-ext/src/main/browser/view/tree-view-widget.tsx @@ -81,28 +81,28 @@ export namespace CompositeTreeViewNode { } @injectable() -export class TreeViewWidgetIdentifier { - id: string; +export abstract class TreeViewWidgetIdentifier { + abstract id: string; } @injectable() export class PluginTree extends TreeImpl { @inject(PluginSharedStyle) - protected readonly sharedStyle: PluginSharedStyle; + protected readonly sharedStyle!: PluginSharedStyle; @inject(TreeViewWidgetIdentifier) - protected readonly identifier: TreeViewWidgetIdentifier; + protected readonly identifier!: TreeViewWidgetIdentifier; @inject(MessageService) - protected readonly notification: MessageService; + protected readonly notification!: MessageService; protected readonly onDidChangeWelcomeStateEmitter: Emitter = new Emitter(); readonly onDidChangeWelcomeState = this.onDidChangeWelcomeStateEmitter.event; private _proxy: TreeViewsExt | undefined; private _viewInfo: View | undefined; - private _isEmpty: boolean; + private _isEmpty: boolean = false; set proxy(proxy: TreeViewsExt | undefined) { this._proxy = proxy; @@ -205,7 +205,7 @@ export class PluginTree extends TreeImpl { export class PluginTreeModel extends TreeModelImpl { @inject(PluginTree) - protected readonly tree: PluginTree; + protected readonly tree!: PluginTree; set proxy(proxy: TreeViewsExt | undefined) { this.tree.proxy = proxy; @@ -234,22 +234,22 @@ export class TreeViewWidget extends TreeViewWelcomeWidget { protected _contextSelection = false; @inject(MenuModelRegistry) - protected readonly menus: MenuModelRegistry; + protected readonly menus!: MenuModelRegistry; @inject(ViewContextKeyService) - protected readonly contextKeys: ViewContextKeyService; + protected readonly contextKeys!: ViewContextKeyService; @inject(TreeViewWidgetIdentifier) - readonly identifier: TreeViewWidgetIdentifier; + readonly identifier!: TreeViewWidgetIdentifier; @inject(PluginTreeModel) - readonly model: PluginTreeModel; + readonly model!: PluginTreeModel; @inject(ContextKeyService) - protected readonly contextKeyService: ContextKeyService; + protected readonly contextKeyService!: ContextKeyService; @inject(TooltipService) - protected readonly tooltipService: TooltipService; + protected readonly tooltipService!: TooltipService; protected readonly onDidChangeVisibilityEmitter = new Emitter(); readonly onDidChangeVisibility = this.onDidChangeVisibilityEmitter.event; diff --git a/packages/plugin-ext/src/main/browser/view/view-context-key-service.ts b/packages/plugin-ext/src/main/browser/view/view-context-key-service.ts index 75f906e583844..771b8a85954b1 100644 --- a/packages/plugin-ext/src/main/browser/view/view-context-key-service.ts +++ b/packages/plugin-ext/src/main/browser/view/view-context-key-service.ts @@ -20,17 +20,17 @@ import { ContextKey, ContextKeyService } from '@theia/core/lib/browser/context-k @injectable() export class ViewContextKeyService { - protected _view: ContextKey; + protected _view!: ContextKey; get view(): ContextKey { return this._view; } - protected _viewItem: ContextKey; + protected _viewItem!: ContextKey; get viewItem(): ContextKey { return this._viewItem; } - protected _activeViewlet: ContextKey; + protected _activeViewlet!: ContextKey; /** * Viewlet is a tab in the left area in VS Code. Active means visible in this context. * @@ -42,7 +42,7 @@ export class ViewContextKeyService { return this._activeViewlet; } - protected _activePanel: ContextKey; + protected _activePanel!: ContextKey; /** * Panel is a tab in the bottom area in VS Code. Active means visible in this context. * @@ -54,13 +54,13 @@ export class ViewContextKeyService { return this._activePanel; } - protected _focusedView: ContextKey; + protected _focusedView!: ContextKey; get focusedView(): ContextKey { return this._focusedView; } @inject(ContextKeyService) - protected readonly contextKeyService: ContextKeyService; + protected readonly contextKeyService!: ContextKeyService; @postConstruct() protected init(): void { diff --git a/packages/plugin-ext/src/main/browser/webview/webview-environment.ts b/packages/plugin-ext/src/main/browser/webview/webview-environment.ts index 3896d92e9d3b3..0445628035823 100644 --- a/packages/plugin-ext/src/main/browser/webview/webview-environment.ts +++ b/packages/plugin-ext/src/main/browser/webview/webview-environment.ts @@ -25,12 +25,12 @@ import { environment } from '@theia/core/shared/@theia/application-package/lib/e @injectable() export class WebviewEnvironment { - protected _hostPatternPromise: Promise; + protected _hostPatternPromise!: Promise; protected readonly externalEndpointHost = new Deferred(); @inject(EnvVariablesServer) - protected readonly environments: EnvVariablesServer; + protected readonly environments!: EnvVariablesServer; @postConstruct() protected async init(): Promise { diff --git a/packages/plugin-ext/src/main/browser/webview/webview-frontend-security-warnings.ts b/packages/plugin-ext/src/main/browser/webview/webview-frontend-security-warnings.ts index 29c6890612482..e0c94b714f70f 100644 --- a/packages/plugin-ext/src/main/browser/webview/webview-frontend-security-warnings.ts +++ b/packages/plugin-ext/src/main/browser/webview/webview-frontend-security-warnings.ts @@ -27,13 +27,13 @@ import { WebviewEnvironment } from './webview-environment'; export class WebviewFrontendSecurityWarnings implements FrontendApplicationContribution { @inject(WindowService) - protected windowService: WindowService; + protected windowService!: WindowService; @inject(MessageService) - protected messageService: MessageService; + protected messageService!: MessageService; @inject(WebviewEnvironment) - protected webviewEnvironment: WebviewEnvironment; + protected webviewEnvironment!: WebviewEnvironment; initialize(): void { this.checkHostPattern(); diff --git a/packages/plugin-ext/src/main/browser/webview/webview-theme-data-provider.ts b/packages/plugin-ext/src/main/browser/webview/webview-theme-data-provider.ts index 394b1d5291740..66ed5f2e599a5 100644 --- a/packages/plugin-ext/src/main/browser/webview/webview-theme-data-provider.ts +++ b/packages/plugin-ext/src/main/browser/webview/webview-theme-data-provider.ts @@ -39,13 +39,13 @@ export class WebviewThemeDataProvider { readonly onDidChangeThemeData = this.onDidChangeThemeDataEmitter.event; @inject(EditorPreferences) - protected readonly editorPreferences: EditorPreferences; + protected readonly editorPreferences!: EditorPreferences; @inject(ColorRegistry) - protected readonly colors: ColorRegistry; + protected readonly colors!: ColorRegistry; @inject(ColorApplicationContribution) - protected readonly colorContribution: ColorApplicationContribution; + protected readonly colorContribution!: ColorApplicationContribution; protected themeData: WebviewThemeData | undefined; diff --git a/packages/plugin-ext/src/main/browser/webview/webview.ts b/packages/plugin-ext/src/main/browser/webview/webview.ts index e516fa7ef3f58..7e5ef20b03d88 100644 --- a/packages/plugin-ext/src/main/browser/webview/webview.ts +++ b/packages/plugin-ext/src/main/browser/webview/webview.ts @@ -77,8 +77,8 @@ export interface WebviewContentOptions { } @injectable() -export class WebviewWidgetIdentifier { - id: string; +export abstract class WebviewWidgetIdentifier { + abstract id: string; } export const WebviewWidgetExternalEndpoint = Symbol('WebviewWidgetExternalEndpoint'); @@ -100,46 +100,46 @@ export class WebviewWidget extends BaseWidget implements StatefulWidget { // eslint-disable-next-line max-len // XXX This is a hack to be able to tack the mouse events when drag and dropping the widgets. // On `mousedown` we put a transparent div over the `iframe` to avoid losing the mouse tacking. - protected transparentOverlay: HTMLElement; + protected transparentOverlay!: HTMLElement; @inject(WebviewWidgetIdentifier) - readonly identifier: WebviewWidgetIdentifier; + readonly identifier!: WebviewWidgetIdentifier; @inject(WebviewWidgetExternalEndpoint) - readonly externalEndpoint: string; + readonly externalEndpoint!: string; @inject(ApplicationShellMouseTracker) - protected readonly mouseTracker: ApplicationShellMouseTracker; + protected readonly mouseTracker!: ApplicationShellMouseTracker; @inject(WebviewEnvironment) - protected readonly environment: WebviewEnvironment; + protected readonly environment!: WebviewEnvironment; @inject(OpenerService) - protected readonly openerService: OpenerService; + protected readonly openerService!: OpenerService; @inject(KeybindingRegistry) - protected readonly keybindings: KeybindingRegistry; + protected readonly keybindings!: KeybindingRegistry; @inject(PluginSharedStyle) - protected readonly sharedStyle: PluginSharedStyle; + protected readonly sharedStyle!: PluginSharedStyle; @inject(WebviewThemeDataProvider) - protected readonly themeDataProvider: WebviewThemeDataProvider; + protected readonly themeDataProvider!: WebviewThemeDataProvider; @inject(ExternalUriService) - protected readonly externalUriService: ExternalUriService; + protected readonly externalUriService!: ExternalUriService; @inject(OutputChannelManager) - protected readonly outputManager: OutputChannelManager; + protected readonly outputManager!: OutputChannelManager; @inject(WebviewPreferences) - protected readonly preferences: WebviewPreferences; + protected readonly preferences!: WebviewPreferences; @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; @inject(WebviewResourceCache) - protected readonly resourceCache: WebviewResourceCache; + protected readonly resourceCache!: WebviewResourceCache; viewState: WebviewPanelViewState = { visible: false, @@ -159,8 +159,20 @@ export class WebviewWidget extends BaseWidget implements StatefulWidget { return this._state; } - viewType: string; - viewColumn: ViewColumn; + protected _viewType?: string; + + get viewType(): string { + if (this._viewType === undefined) { + throw new Error('WebviewWidget._viewType is not set'); + } + return this._viewType; + } + + set viewType(value) { + this._viewType = value; + } + + viewColumn?: ViewColumn; options: WebviewPanelOptions = {}; protected ready = new Deferred(); @@ -537,7 +549,7 @@ export class WebviewWidget extends BaseWidget implements StatefulWidget { restoreState(oldState: WebviewWidget.State): void { const { viewType, title, iconUrl, options, contentOptions, state } = oldState; - this.viewType = viewType; + this._viewType = viewType; this.title.label = title; this.setIconUrl(iconUrl); this.options = options; diff --git a/packages/plugin-ext/src/main/browser/workspace-main.ts b/packages/plugin-ext/src/main/browser/workspace-main.ts index 61cab00823fa2..efeca97b63b1e 100644 --- a/packages/plugin-ext/src/main/browser/workspace-main.ts +++ b/packages/plugin-ext/src/main/browser/workspace-main.ts @@ -44,7 +44,7 @@ export class WorkspaceMainImpl implements WorkspaceMain, Disposable { private searchInWorkspaceService: SearchInWorkspaceService; - private roots: string[]; + private roots: string[] = []; private resourceResolver: TextContentResourceResolver; @@ -98,7 +98,7 @@ export class WorkspaceMainImpl implements WorkspaceMain, Disposable { } private isAnyRootChanged(roots: string[]): boolean { - if (!this.roots || this.roots.length !== roots.length) { + if (this.roots.length !== roots.length) { return true; } @@ -110,10 +110,10 @@ export class WorkspaceMainImpl implements WorkspaceMain, Disposable { } $pickWorkspaceFolder(options: WorkspaceFolderPickOptionsMain): Promise { - return new Promise((resolve, reject) => { + return new Promise(resolve => { // Return undefined if workspace root is not set - if (!this.roots || !this.roots.length) { - resolve(undefined); + if (this.roots.length === 0) { + resolve(); return; } diff --git a/packages/plugin-ext/src/main/common/plugin-theia-environment.ts b/packages/plugin-ext/src/main/common/plugin-theia-environment.ts index 607ecdc4c37ff..4c55e7215d567 100644 --- a/packages/plugin-ext/src/main/common/plugin-theia-environment.ts +++ b/packages/plugin-ext/src/main/common/plugin-theia-environment.ts @@ -22,7 +22,7 @@ import URI from '@theia/core/lib/common/uri'; export class PluginTheiaEnvironment { @inject(EnvVariablesServer) - protected readonly environments: EnvVariablesServer; + protected readonly environments!: EnvVariablesServer; protected _pluginsDirUri: URI | undefined; async getPluginsDirUri(): Promise { diff --git a/packages/plugin-ext/src/main/node/handlers/plugin-theia-file-handler.ts b/packages/plugin-ext/src/main/node/handlers/plugin-theia-file-handler.ts index 38a89af5793ce..f775666749275 100644 --- a/packages/plugin-ext/src/main/node/handlers/plugin-theia-file-handler.ts +++ b/packages/plugin-ext/src/main/node/handlers/plugin-theia-file-handler.ts @@ -28,7 +28,7 @@ export class PluginTheiaFileHandler implements PluginDeployerFileHandler { private readonly systemPluginsDirUri = FileUri.create(getTempDir('theia-unpacked')); @inject(PluginTheiaEnvironment) - protected readonly environment: PluginTheiaEnvironment; + protected readonly environment!: PluginTheiaEnvironment; accept(resolvedPlugin: PluginDeployerEntry): boolean { return resolvedPlugin.isFile() && resolvedPlugin.path() !== null && resolvedPlugin.path().endsWith('.theia'); diff --git a/packages/plugin-ext/src/main/node/paths/plugin-paths-service.ts b/packages/plugin-ext/src/main/node/paths/plugin-paths-service.ts index e94b7065e2574..871e05a998bf5 100644 --- a/packages/plugin-ext/src/main/node/paths/plugin-paths-service.ts +++ b/packages/plugin-ext/src/main/node/paths/plugin-paths-service.ts @@ -35,13 +35,13 @@ const SESSION_TIMESTAMP_PATTERN = /^\d{8}T\d{6}$/; export class PluginPathsServiceImpl implements PluginPathsService { @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(EnvVariablesServer) - protected readonly envServer: EnvVariablesServer; + protected readonly envServer!: EnvVariablesServer; @inject(PluginCliContribution) - protected readonly cliContribution: PluginCliContribution; + protected readonly cliContribution!: PluginCliContribution; async getHostLogPath(): Promise { const parentLogsDir = await this.getLogsDirPath(); diff --git a/packages/plugin-ext/src/main/node/plugin-cli-contribution.ts b/packages/plugin-ext/src/main/node/plugin-cli-contribution.ts index 72ec53973cb4e..c91b3a8bcbfd4 100644 --- a/packages/plugin-ext/src/main/node/plugin-cli-contribution.ts +++ b/packages/plugin-ext/src/main/node/plugin-cli-contribution.ts @@ -31,7 +31,7 @@ export class PluginCliContribution implements CliContribution { static DEFAULT_PLUGIN_MAX_SESSION_LOGS_FOLDERS = 10; protected _localDir: string | undefined; - protected _maxSessionLogsFolders: number; + protected _maxSessionLogsFolders: number = PluginCliContribution.DEFAULT_PLUGIN_MAX_SESSION_LOGS_FOLDERS; configure(conf: Argv): void { conf.option(PluginCliContribution.PLUGINS, { diff --git a/packages/plugin-ext/src/main/node/plugin-deployer-contribution.ts b/packages/plugin-ext/src/main/node/plugin-deployer-contribution.ts index 1a0adc3f22377..757a4fdbb5c30 100644 --- a/packages/plugin-ext/src/main/node/plugin-deployer-contribution.ts +++ b/packages/plugin-ext/src/main/node/plugin-deployer-contribution.ts @@ -23,10 +23,10 @@ import { ILogger } from '@theia/core'; export class PluginDeployerContribution implements BackendApplicationContribution { @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(PluginDeployer) - protected pluginDeployer: PluginDeployer; + protected pluginDeployer!: PluginDeployer; initialize(): void { this.pluginDeployer.start(); diff --git a/packages/plugin-ext/src/main/node/plugin-deployer-entry-impl.ts b/packages/plugin-ext/src/main/node/plugin-deployer-entry-impl.ts index 96477a9805e50..de13041e41712 100644 --- a/packages/plugin-ext/src/main/node/plugin-deployer-entry-impl.ts +++ b/packages/plugin-ext/src/main/node/plugin-deployer-entry-impl.ts @@ -19,9 +19,9 @@ import * as fs from 'fs'; export class PluginDeployerEntryImpl implements PluginDeployerEntry { - private initPath: string; + private initPath?: string; - private currentPath: string; + private currentPath?: string; // eslint-disable-next-line @typescript-eslint/no-explicit-any private map: Map; @@ -31,7 +31,7 @@ export class PluginDeployerEntryImpl implements PluginDeployerEntry { private changes: string[]; - private resolvedByName: string; + private resolvedByName?: string; private _type = PluginType.System; private _rootPath: string | undefined; @@ -53,9 +53,15 @@ export class PluginDeployerEntryImpl implements PluginDeployerEntry { return this.pluginId; } originalPath(): string { + if (this.initPath === undefined) { + throw new Error('PluginDeployerEntryImpl.initPath is not set'); + } return this.initPath; } path(): string { + if (this.currentPath === undefined) { + throw new Error('PluginDeployerEntryImpl.currentPath is not set'); + } return this.currentPath; } getValue(key: string): T { @@ -75,6 +81,7 @@ export class PluginDeployerEntryImpl implements PluginDeployerEntry { } isFile(): boolean { try { + // @ts-expect-error TS2322 return fs.statSync(this.currentPath).isFile(); } catch (e) { return false; @@ -82,6 +89,7 @@ export class PluginDeployerEntryImpl implements PluginDeployerEntry { } isDirectory(): boolean { try { + // @ts-expect-error TS2322 return fs.statSync(this.currentPath).isDirectory(); } catch (e) { return false; @@ -108,6 +116,9 @@ export class PluginDeployerEntryImpl implements PluginDeployerEntry { } resolvedBy(): string { + if (this.resolvedByName === undefined) { + throw new Error('PluginDeployerEntryImpl.resolvedByName is not set'); + } return this.resolvedByName; } diff --git a/packages/plugin-ext/src/main/node/plugin-deployer-impl.ts b/packages/plugin-ext/src/main/node/plugin-deployer-impl.ts index 80ef8372eff5d..cf1355227e94a 100644 --- a/packages/plugin-ext/src/main/node/plugin-deployer-impl.ts +++ b/packages/plugin-ext/src/main/node/plugin-deployer-impl.ts @@ -42,34 +42,34 @@ export class PluginDeployerImpl implements PluginDeployer { readonly onDidDeploy = this.onDidDeployEmitter.event; @inject(ILogger) - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(PluginDeployerHandler) - protected readonly pluginDeployerHandler: PluginDeployerHandler; + protected readonly pluginDeployerHandler!: PluginDeployerHandler; @inject(PluginCliContribution) - protected readonly cliContribution: PluginCliContribution; + protected readonly cliContribution!: PluginCliContribution; /** * Inject all plugin resolvers found at runtime. */ @optional() @multiInject(PluginDeployerResolver) - private pluginResolvers: PluginDeployerResolver[]; + private pluginResolvers: PluginDeployerResolver[] = []; /** * Inject all file handler for local resolved plugins. */ @optional() @multiInject(PluginDeployerFileHandler) - private pluginDeployerFileHandlers: PluginDeployerFileHandler[]; + private pluginDeployerFileHandlers: PluginDeployerFileHandler[] = []; /** * Inject all directory handler for local resolved plugins. */ @optional() @multiInject(PluginDeployerDirectoryHandler) - private pluginDeployerDirectoryHandlers: PluginDeployerDirectoryHandler[]; + private pluginDeployerDirectoryHandlers: PluginDeployerDirectoryHandler[] = []; @inject(ContributionProvider) @named(PluginDeployerParticipant) - protected readonly participants: ContributionProvider; + protected readonly participants!: ContributionProvider; public start(): void { this.logger.debug('Starting the deployer with the list of resolvers', this.pluginResolvers); diff --git a/packages/plugin-ext/src/main/node/plugin-server-handler.ts b/packages/plugin-ext/src/main/node/plugin-server-handler.ts index c28a58f1b4a60..58ba63daea683 100644 --- a/packages/plugin-ext/src/main/node/plugin-server-handler.ts +++ b/packages/plugin-ext/src/main/node/plugin-server-handler.ts @@ -25,10 +25,10 @@ import { KeysToAnyValues, KeysToKeysToAnyValue } from '../../common/types'; export class PluginServerHandler implements PluginServer { @inject(PluginDeployer) - protected readonly pluginDeployer: PluginDeployerImpl; + protected readonly pluginDeployer!: PluginDeployerImpl; @inject(PluginsKeyValueStorage) - protected readonly pluginsKeyValueStorage: PluginsKeyValueStorage; + protected readonly pluginsKeyValueStorage!: PluginsKeyValueStorage; deploy(pluginEntry: string, arg2?: PluginType | CancellationToken): Promise { const type = typeof arg2 === 'number' ? arg2 as PluginType : undefined; diff --git a/packages/plugin-ext/src/main/node/plugin-service.ts b/packages/plugin-ext/src/main/node/plugin-service.ts index 3055a1647d072..d96176ad48563 100644 --- a/packages/plugin-ext/src/main/node/plugin-service.ts +++ b/packages/plugin-ext/src/main/node/plugin-service.ts @@ -29,7 +29,7 @@ import { MaybePromise } from '@theia/core/lib/common'; @injectable() export class PluginApiContribution implements BackendApplicationContribution, WsRequestValidatorContribution { - protected webviewExternalEndpointRegExp: RegExp; + protected webviewExternalEndpointRegExp!: RegExp; protected serveSameOrigin: boolean = false; diff --git a/packages/plugin-ext/src/main/node/plugin-theia-deployer-participant.ts b/packages/plugin-ext/src/main/node/plugin-theia-deployer-participant.ts index fc4a4493c4810..6423727cd7363 100644 --- a/packages/plugin-ext/src/main/node/plugin-theia-deployer-participant.ts +++ b/packages/plugin-ext/src/main/node/plugin-theia-deployer-participant.ts @@ -22,7 +22,7 @@ import { PluginDeployerParticipant, PluginDeployerStartContext } from '../../com export class PluginTheiaDeployerParticipant implements PluginDeployerParticipant { @inject(PluginTheiaEnvironment) - protected readonly environments: PluginTheiaEnvironment; + protected readonly environments!: PluginTheiaEnvironment; async onWillStart(context: PluginDeployerStartContext): Promise { const pluginsDirUri = await this.environments.getPluginsDirUri(); diff --git a/packages/plugin-ext/src/main/node/plugins-key-value-storage.ts b/packages/plugin-ext/src/main/node/plugins-key-value-storage.ts index 4ab7c1ed44188..390f123f68bdf 100644 --- a/packages/plugin-ext/src/main/node/plugins-key-value-storage.ts +++ b/packages/plugin-ext/src/main/node/plugins-key-value-storage.ts @@ -31,10 +31,10 @@ export class PluginsKeyValueStorage { private readonly deferredGlobalDataPath = new Deferred(); @inject(PluginPathsService) - private readonly pluginPathsService: PluginPathsService; + private readonly pluginPathsService!: PluginPathsService; @inject(EnvVariablesServer) - protected readonly envServer: EnvVariablesServer; + protected readonly envServer!: EnvVariablesServer; @postConstruct() protected async init(): Promise { diff --git a/packages/plugin-ext/src/plugin/authentication-ext.ts b/packages/plugin-ext/src/plugin/authentication-ext.ts index 82c07b50349e6..ce5ebf8207594 100644 --- a/packages/plugin-ext/src/plugin/authentication-ext.ts +++ b/packages/plugin-ext/src/plugin/authentication-ext.ts @@ -61,10 +61,26 @@ export class AuthenticationExtImpl implements AuthenticationExt { return Object.freeze(this._providers.slice()); } - async getSession(requestingExtension: InternalPlugin, providerId: string, scopes: string[], - options: theia.AuthenticationGetSessionOptions & { createIfNone: true }): Promise; - async getSession(requestingExtension: InternalPlugin, providerId: string, scopes: string[], - options: theia.AuthenticationGetSessionOptions = {}): Promise { + async getSession( + requestingExtension: InternalPlugin, + providerId: string, + scopes: string[], + options?: theia.AuthenticationGetSessionOptions & { createIfNone: true } + ): Promise; + + async getSession( + requestingExtension: InternalPlugin, + providerId: string, + scopes: string[], + options?: theia.AuthenticationGetSessionOptions + ): Promise; + + async getSession( + requestingExtension: InternalPlugin, + providerId: string, + scopes: string[], + options: theia.AuthenticationGetSessionOptions = {} + ): Promise { const extensionName = requestingExtension.model.displayName || requestingExtension.model.name; const extensionId = requestingExtension.model.id.toLowerCase(); @@ -163,7 +179,7 @@ export class AuthenticationExtImpl implements AuthenticationExt { return Promise.resolve(); } - async $onDidChangeAuthenticationProviders(added: theia.AuthenticationProviderInformation[], removed: theia.AuthenticationProviderInformation[]): Promise { + async $onDidChangeAuthenticationProviders(added: theia.AuthenticationProviderInformation[], removed: theia.AuthenticationProviderInformation[]): Promise { added.forEach(id => { if (this._providers.indexOf(id) === -1) { this._providers.push(id); diff --git a/packages/plugin-ext/src/plugin/command-registry.ts b/packages/plugin-ext/src/plugin/command-registry.ts index 93d283a1762e8..9e341fac43883 100644 --- a/packages/plugin-ext/src/plugin/command-registry.ts +++ b/packages/plugin-ext/src/plugin/command-registry.ts @@ -78,7 +78,7 @@ export class CommandRegistryImpl implements CommandRegistryExt { } this.proxy.$registerHandler(commandId); // eslint-disable-next-line @typescript-eslint/no-explicit-any - this.handlers.set(commandId, (...args: any[]) => handler.apply(thisArg, args)); + this.handlers.set(commandId, (...args: any[]) => handler.apply(thisArg, args) as any); return Disposable.create(() => { this.handlers.delete(commandId); this.proxy.$unregisterHandler(commandId); @@ -197,8 +197,7 @@ export class CommandsConverter { // we're deprecating Command.id, so it has to be optional. // Existing code will have compiled against a non - optional version of the field, so asserting it to exist is ok // eslint-disable-next-line @typescript-eslint/no-explicit-any - return KnownCommands.map((external.command || external.id)!, external.arguments, (mappedId: string, mappedArgs: any[]) => - ({ + return KnownCommands.map((external.command || external.id)!, external.arguments, (mappedId, mappedArgs = []) => ({ id: mappedId, title: external.title || external.label || ' ', tooltip: external.tooltip, diff --git a/packages/plugin-ext/src/plugin/document-data.ts b/packages/plugin-ext/src/plugin/document-data.ts index d1360fa06c80d..48d955da80d47 100644 --- a/packages/plugin-ext/src/plugin/document-data.ts +++ b/packages/plugin-ext/src/plugin/document-data.ts @@ -34,7 +34,7 @@ export class DocumentDataExt { private disposed = false; private dirty: boolean; - private _document: theia.TextDocument; + private _document?: theia.TextDocument; private textLines = new Array(); private lineStarts: PrefixSumComputer | undefined; diff --git a/packages/plugin-ext/src/plugin/env.ts b/packages/plugin-ext/src/plugin/env.ts index 9f0e464fb04dc..29904409f1203 100644 --- a/packages/plugin-ext/src/plugin/env.ts +++ b/packages/plugin-ext/src/plugin/env.ts @@ -22,11 +22,11 @@ import { v4 } from 'uuid'; export abstract class EnvExtImpl { private proxy: EnvMain; - private queryParameters: QueryParameters; - private lang: string; - private applicationName: string; - private defaultShell: string; - private ui: theia.UIKind; + private queryParameters?: QueryParameters; + private lang?: string; + private applicationName?: string; + private defaultShell?: string; + private ui?: theia.UIKind; private envMachineId: string; private envSessionId: string; @@ -46,10 +46,16 @@ export abstract class EnvExtImpl { } getQueryParameter(queryParamName: string): string | string[] | undefined { + if (!this.queryParameters) { + throw new Error('EnvExtImpl.queryParameters is not set'); + } return this.queryParameters[queryParamName]; } getQueryParameters(): QueryParameters { + if (!this.queryParameters) { + throw new Error('EnvExtImpl.queryParameters is not set'); + } return this.queryParameters; } @@ -78,12 +84,18 @@ export abstract class EnvExtImpl { } get appName(): string { + if (!this.applicationName) { + throw new Error('EnvExtImpl.applicationName is not set'); + } return this.applicationName; } abstract get appRoot(): string; get language(): string { + if (!this.lang) { + throw new Error('EnvExtImpl.lang is not set'); + } return this.lang; } get machineId(): string { @@ -96,9 +108,15 @@ export abstract class EnvExtImpl { return 'theia'; } get shell(): string { + if (!this.defaultShell) { + throw new Error('EnvExtImpl.defaultShell is not set'); + } return this.defaultShell; } get uiKind(): theia.UIKind { + if (!this.ui) { + throw new Error('EnvExtImpl.ui is not set'); + } return this.ui; } } diff --git a/packages/plugin-ext/src/plugin/known-commands.spec.ts b/packages/plugin-ext/src/plugin/known-commands.spec.ts index dbc115a14a732..a0279bd3afcfc 100644 --- a/packages/plugin-ext/src/plugin/known-commands.spec.ts +++ b/packages/plugin-ext/src/plugin/known-commands.spec.ts @@ -34,7 +34,7 @@ describe('Known Command Conversions', () => { // when // eslint-disable-next-line @typescript-eslint/no-explicit-any - KnownCommands.map(commandID, [uri, position], (mappedID: string, mappedArgs: any[]) => { + KnownCommands.map(commandID, [uri, position], (mappedID, mappedArgs = []) => { // then assert.strictEqual(commandID, mappedID); diff --git a/packages/plugin-ext/src/plugin/languages/diagnostics.ts b/packages/plugin-ext/src/plugin/languages/diagnostics.ts index ddcf4e164cb5f..21f779544169c 100644 --- a/packages/plugin-ext/src/plugin/languages/diagnostics.ts +++ b/packages/plugin-ext/src/plugin/languages/diagnostics.ts @@ -131,7 +131,7 @@ export class DiagnosticCollection implements theia.DiagnosticCollection { this.ensureNotDisposed(); this.diagnostics.forEach((diagnostics, uriString) => { const uri = URI.parse(uriString); - callback.apply(thisArg, [uri, this.getDiagnosticsByUri(uri), this]); + callback.apply(thisArg, [uri, this.getDiagnosticsByUri(uri)!, this]); }); } diff --git a/packages/plugin-ext/src/plugin/message-registry.ts b/packages/plugin-ext/src/plugin/message-registry.ts index 983f7cd6a8837..ece0e8d44ac26 100644 --- a/packages/plugin-ext/src/plugin/message-registry.ts +++ b/packages/plugin-ext/src/plugin/message-registry.ts @@ -27,9 +27,26 @@ export class MessageRegistryExt { this.proxy = rpc.getProxy(Ext.MESSAGE_REGISTRY_MAIN); } - async showMessage(type: MainMessageType, message: string, + showMessage( + type: MainMessageType, + message: string, + optionsOrFirstItem?: MessageOptions | string, + ...rest: string[] + ): Promise + + showMessage( + type: MainMessageType, + message: string, + optionsOrFirstItem?: MessageOptions | T, + ...rest: T[] + ): Promise + + async showMessage( + type: MainMessageType, + message: string, optionsOrFirstItem?: MessageOptions | string | MessageItem, - ...rest: (string | MessageItem)[]): Promise { + ...rest: (string | MessageItem)[] + ): Promise { const options: MainMessageOptions = {}; const actions: MessageItem[] = []; const items: (string | MessageItem)[] = []; diff --git a/packages/plugin-ext/src/plugin/node/debug/debug.ts b/packages/plugin-ext/src/plugin/node/debug/debug.ts index a7d51c5a8cfce..4c4f6b877b54e 100644 --- a/packages/plugin-ext/src/plugin/node/debug/debug.ts +++ b/packages/plugin-ext/src/plugin/node/debug/debug.ts @@ -60,8 +60,8 @@ export class DebugExtImpl implements DebugExt { private trackerFactories: [string, theia.DebugAdapterTrackerFactory][] = []; private contributionPaths = new Map(); - private connectionExt: ConnectionExtImpl; - private commandRegistryExt: CommandRegistryImpl; + private connectionExt?: ConnectionExtImpl; + private commandRegistryExt?: CommandRegistryImpl; private proxy: DebugMain; @@ -449,6 +449,9 @@ export class DebugExtImpl implements DebugExt { } protected async resolveDebugAdapterExecutable(debugConfiguration: theia.DebugConfiguration): Promise { + if (!this.commandRegistryExt) { + throw new Error('DebugExtImpl.commandRegistryExt is not set'); + } const { type } = debugConfiguration; const contribution = this.debuggersContributions.get(type); if (contribution) { diff --git a/packages/plugin-ext/src/plugin/node/env-node-ext.ts b/packages/plugin-ext/src/plugin/node/env-node-ext.ts index 33351132519a7..9cebd0663ddeb 100644 --- a/packages/plugin-ext/src/plugin/node/env-node-ext.ts +++ b/packages/plugin-ext/src/plugin/node/env-node-ext.ts @@ -26,7 +26,7 @@ import { v4 } from 'uuid'; */ export class EnvNodeExtImpl extends EnvExtImpl { - private macMachineId: string; + private macMachineId?: string; constructor(rpc: RPCProtocol) { super(rpc); @@ -44,6 +44,9 @@ export class EnvNodeExtImpl extends EnvExtImpl { * override machineID */ get machineId(): string { + if (!this.macMachineId) { + throw new Error('EnvNodeExtImpl.macMachineId is not set'); + } return this.macMachineId; } diff --git a/packages/plugin-ext/src/plugin/output-channel/output-channel-item.ts b/packages/plugin-ext/src/plugin/output-channel/output-channel-item.ts index c1cb4fb31921a..a08b42ce01f6e 100644 --- a/packages/plugin-ext/src/plugin/output-channel/output-channel-item.ts +++ b/packages/plugin-ext/src/plugin/output-channel/output-channel-item.ts @@ -18,7 +18,7 @@ import { OutputChannelRegistryMain, PluginInfo } from '../../common/plugin-api-r export class OutputChannelImpl implements theia.OutputChannel { - private disposed: boolean; + private disposed: boolean = false; constructor(readonly name: string, private proxy: OutputChannelRegistryMain, private readonly pluginInfo: PluginInfo) { } diff --git a/packages/plugin-ext/src/plugin/plugin-context.ts b/packages/plugin-ext/src/plugin/plugin-context.ts index 122a024feed66..59eafaae1c263 100644 --- a/packages/plugin-ext/src/plugin/plugin-context.ts +++ b/packages/plugin-ext/src/plugin/plugin-context.ts @@ -20,7 +20,7 @@ import type * as theia from '@theia/plugin'; import { CommandRegistryImpl } from './command-registry'; import { Emitter } from '@theia/core/lib/common/event'; -import { CancellationError, CancellationToken, CancellationTokenSource } from '@theia/core/lib/common/cancellation'; +import { CancellationError, CancellationTokenSource } from '@theia/core/lib/common/cancellation'; import { QuickOpenExtImpl } from './quick-open'; import { MAIN_RPC_CONTEXT, @@ -213,6 +213,11 @@ export function createAPIFactory( rpc.set(MAIN_RPC_CONTEXT.DEBUG_EXT, debugExt); return function (plugin: InternalPlugin): typeof theia { + function getSession(providerId: string, scopes: string[], options?: theia.AuthenticationGetSessionOptions & { createIfNone: true }): Thenable; + function getSession(providerId: string, scopes: string[], options?: theia.AuthenticationGetSessionOptions): Thenable; + function getSession(providerId: string, scopes: string[], options?: theia.AuthenticationGetSessionOptions): any { + return authenticationExt.getSession(plugin, providerId, scopes, options); + }; const authentication: typeof theia.authentication = { registerAuthenticationProvider(provider: theia.AuthenticationProvider): theia.Disposable { return authenticationExt.registerAuthenticationProvider(provider); @@ -229,9 +234,7 @@ export function createAPIFactory( get providers(): ReadonlyArray { return authenticationExt.providers; }, - getSession(providerId: string, scopes: string[], options: theia.AuthenticationGetSessionOptions) { - return authenticationExt.getSession(plugin, providerId, scopes, options as any); - }, + getSession, logout(providerId: string, sessionId: string): Thenable { return authenticationExt.logout(providerId, sessionId); }, @@ -258,14 +261,14 @@ export function createAPIFactory( return commandRegistry.executeCommand(commandId, ...args); }, registerTextEditorCommand(command: string, handler: (textEditor: theia.TextEditor, edit: theia.TextEditorEdit, ...arg: any[]) => void, thisArg?: any): Disposable { - return commandRegistry.registerCommand({ id: command }, (...args: any[]): any => { + return commandRegistry.registerCommand({ id: command }, (...args: [theia.TextEditor, theia.TextEditorEdit, ...any[]]): any => { const activeTextEditor = editors.getActiveEditor(); if (!activeTextEditor) { console.warn('Cannot execute ' + command + ' because there is no active text editor.'); return undefined; } - return activeTextEditor.edit((edit: theia.TextEditorEdit) => { + return activeTextEditor.edit(edit => { args.unshift(activeTextEditor, edit); handler.apply(thisArg, args); }).then(result => { @@ -294,9 +297,9 @@ export function createAPIFactory( }; const { onDidChangeActiveTerminal, onDidCloseTerminal, onDidOpenTerminal } = terminalExt; - const showInformationMessage = messageRegistryExt.showMessage.bind(messageRegistryExt, MainMessageType.Info); - const showWarningMessage = messageRegistryExt.showMessage.bind(messageRegistryExt, MainMessageType.Warning); - const showErrorMessage = messageRegistryExt.showMessage.bind(messageRegistryExt, MainMessageType.Error); + const showInformationMessage: any = messageRegistryExt.showMessage.bind(messageRegistryExt, MainMessageType.Info); + const showWarningMessage: any = messageRegistryExt.showMessage.bind(messageRegistryExt, MainMessageType.Warning); + const showErrorMessage: any = messageRegistryExt.showMessage.bind(messageRegistryExt, MainMessageType.Error); const window: typeof theia.window = { get activeTerminal(): TerminalExtImpl | undefined { @@ -430,7 +433,7 @@ export function createAPIFactory( return treeViewsExt.createTreeView(plugin, viewId, options); }, withProgress( - options: ProgressOptions, + options: theia.ProgressOptions, task: (progress: Progress<{ message?: string; increment?: number }>, token: theia.CancellationToken) => PromiseLike ): PromiseLike { return notificationExt.withProgress(options, task); @@ -530,13 +533,14 @@ export function createAPIFactory( const data = await documents.openDocument(uri); return data && data.document; }, - createFileSystemWatcher: (pattern, ignoreCreate, ignoreChange, ignoreDelete): theia.FileSystemWatcher => - extHostFileSystemEvent.createFileSystemWatcher(fromGlobPattern(pattern), ignoreCreate, ignoreChange, ignoreDelete), - findFiles(include: theia.GlobPattern, exclude?: theia.GlobPattern | null, maxResults?: number, token?: CancellationToken): PromiseLike { + createFileSystemWatcher(pattern: theia.GlobPattern, ignoreCreate?: boolean, ignoreChange?: boolean, ignoreDelete?: boolean): theia.FileSystemWatcher { + return extHostFileSystemEvent.createFileSystemWatcher(fromGlobPattern(pattern), ignoreCreate, ignoreChange, ignoreDelete); + }, + findFiles(include: theia.GlobPattern, exclude?: theia.GlobPattern | null, maxResults?: number, token?: theia.CancellationToken): PromiseLike { return workspaceExt.findFiles(include, exclude, maxResults, token); }, findTextInFiles(query: theia.TextSearchQuery, optionsOrCallback: theia.FindTextInFilesOptions | ((result: theia.TextSearchResult) => void), - callbackOrToken?: CancellationToken | ((result: theia.TextSearchResult) => void), token?: CancellationToken): Promise { + callbackOrToken?: theia.CancellationToken | ((result: theia.TextSearchResult) => void), token?: theia.CancellationToken): Promise { return workspaceExt.findTextInFiles(query, optionsOrCallback, callbackOrToken, token); }, saveAll(includeUntitled?: boolean): PromiseLike { diff --git a/packages/plugin-ext/src/plugin/plugin-storage.ts b/packages/plugin-ext/src/plugin/plugin-storage.ts index 8ee734a840abb..6061f6dc976cd 100644 --- a/packages/plugin-ext/src/plugin/plugin-storage.ts +++ b/packages/plugin-ext/src/plugin/plugin-storage.ts @@ -76,8 +76,8 @@ export class KeyValueStorageProxy implements StorageExt { private readonly proxy: StorageMain; - private globalDataCache: KeysToKeysToAnyValue; - private workspaceDataCache: KeysToKeysToAnyValue; + private globalDataCache!: KeysToKeysToAnyValue; + private workspaceDataCache!: KeysToKeysToAnyValue; constructor(rpc: RPCProtocol) { this.proxy = rpc.getProxy(PLUGIN_RPC_CONTEXT.STORAGE_MAIN); diff --git a/packages/plugin-ext/src/plugin/preference-registry.ts b/packages/plugin-ext/src/plugin/preference-registry.ts index c736294061057..c672af759db11 100644 --- a/packages/plugin-ext/src/plugin/preference-registry.ts +++ b/packages/plugin-ext/src/plugin/preference-registry.ts @@ -70,7 +70,7 @@ function lookUp(tree: any, key: string): any { export class PreferenceRegistryExtImpl implements PreferenceRegistryExt { private proxy: PreferenceRegistryMain; - private _preferences: Configuration; + private _preferences!: Configuration; private readonly _onDidChangeConfiguration = new Emitter(); readonly onDidChangeConfiguration: Event = this._onDidChangeConfiguration.event; diff --git a/packages/plugin-ext/src/plugin/quick-open.ts b/packages/plugin-ext/src/plugin/quick-open.ts index 5ad0daa2219bf..524459b024f42 100644 --- a/packages/plugin-ext/src/plugin/quick-open.ts +++ b/packages/plugin-ext/src/plugin/quick-open.ts @@ -232,13 +232,13 @@ export class QuickInputExt implements QuickInput { private static _nextId = 1; _id = QuickInputExt._nextId++; - private _busy: boolean; - private _enabled: boolean; - private _ignoreFocusOut: boolean; + private _busy: boolean = false; + private _enabled: boolean = false; + private _ignoreFocusOut: boolean = false; private _step: number | undefined; private _title: string | undefined; private _totalSteps: number | undefined; - private _value: string; + private _value?: string; private _placeholder: string | undefined; private _buttons: theia.QuickInputButton[] = []; private _handlesToButtons = new Map(); @@ -331,6 +331,9 @@ export class QuickInputExt implements QuickInput { } get value(): string { + if (this._value === undefined) { + throw new Error('QuickInputExt._value is not set'); + } return this._value; } @@ -488,7 +491,7 @@ export class QuickInputExt implements QuickInput { */ export class InputBoxExt extends QuickInputExt implements InputBox { - private _password: boolean; + private _password: boolean = false; private _prompt: string | undefined; private _validationMessage: string | undefined; diff --git a/packages/plugin-ext/src/plugin/status-bar/status-bar-item.ts b/packages/plugin-ext/src/plugin/status-bar/status-bar-item.ts index d36564a166f0d..e5dd6fcdf5a88 100644 --- a/packages/plugin-ext/src/plugin/status-bar/status-bar-item.ts +++ b/packages/plugin-ext/src/plugin/status-bar/status-bar-item.ts @@ -25,12 +25,12 @@ export class StatusBarItemImpl implements theia.StatusBarItem { private _alignment: StatusBarAlignment; private _priority: number; - private _text: string; - private _tooltip: string; - private _color: string | ThemeColor; - private _command: string | theia.Command; + private _text!: string; + private _tooltip!: string; + private _color!: string | ThemeColor; + private _command!: string | theia.Command; - private _isVisible: boolean; + private _isVisible: boolean = false; private _timeoutHandle: NodeJS.Timer | undefined; _proxy: StatusBarMessageRegistryMain; diff --git a/packages/plugin-ext/src/plugin/tasks/tasks.ts b/packages/plugin-ext/src/plugin/tasks/tasks.ts index 7d6487c33df87..d89351934bebf 100644 --- a/packages/plugin-ext/src/plugin/tasks/tasks.ts +++ b/packages/plugin-ext/src/plugin/tasks/tasks.ts @@ -39,7 +39,7 @@ export class TasksExtImpl implements TasksExt { private adaptersMap = new Map(); private executions = new Map(); protected callbackIdBase: string = UUID.uuid4(); - protected callbackId: number; + protected callbackId: number = 0; protected customExecutionIds: Map = new Map(); protected customExecutionFunctions: Map = new Map(); protected lastStartedTask: number | undefined; diff --git a/packages/plugin-ext/src/plugin/terminal-ext.ts b/packages/plugin-ext/src/plugin/terminal-ext.ts index 2a37f24c9e2e4..0959280ab570c 100644 --- a/packages/plugin-ext/src/plugin/terminal-ext.ts +++ b/packages/plugin-ext/src/plugin/terminal-ext.ts @@ -265,7 +265,7 @@ export class EnvironmentVariableCollection implements theia.EnvironmentVariableC export class TerminalExtImpl implements Terminal { - name: string; + name: string = 'unnamed'; readonly id = new Deferred(); diff --git a/packages/plugin-ext/src/plugin/text-editor.ts b/packages/plugin-ext/src/plugin/text-editor.ts index 3109637fa3421..8a12f87c34ff0 100644 --- a/packages/plugin-ext/src/plugin/text-editor.ts +++ b/packages/plugin-ext/src/plugin/text-editor.ts @@ -267,9 +267,9 @@ export class TextEditorExt implements theia.TextEditor { export class TextEditorOptionsExt implements theia.TextEditorOptions { private _tabSize?: number; - private _insertSpace: boolean; - private _cursorStyle: TextEditorCursorStyle; - private _lineNumbers: TextEditorLineNumbersStyle; + private _insertSpace!: boolean; + private _cursorStyle!: TextEditorCursorStyle; + private _lineNumbers!: TextEditorLineNumbersStyle; constructor(private readonly proxy: TextEditorsMain, private readonly id: string, source: TextEditorConfiguration) { diff --git a/packages/plugin-ext/src/plugin/tree/tree-views.ts b/packages/plugin-ext/src/plugin/tree/tree-views.ts index 6d7957d2fd3e4..238a16dea5dda 100644 --- a/packages/plugin-ext/src/plugin/tree/tree-views.ts +++ b/packages/plugin-ext/src/plugin/tree/tree-views.ts @@ -192,7 +192,7 @@ class TreeViewExtImpl implements Disposable { this.toDispose.push(Disposable.create(() => this.proxy.$unregisterTreeDataProvider(treeViewId))); if (treeDataProvider.onDidChangeTreeData) { - treeDataProvider.onDidChangeTreeData((e: T) => { + treeDataProvider.onDidChangeTreeData(e => { this.pendingRefresh = proxy.$refresh(treeViewId); }); } diff --git a/packages/plugin-ext/src/plugin/types-impl.ts b/packages/plugin-ext/src/plugin/types-impl.ts index 698344a051ad0..c1964f22a5bbd 100644 --- a/packages/plugin-ext/src/plugin/types-impl.ts +++ b/packages/plugin-ext/src/plugin/types-impl.ts @@ -809,9 +809,9 @@ export enum IndentAction { @es5ClassCompat export class TextEdit { - protected _range: Range; - protected _newText: string; - protected _newEol: EndOfLine; + protected _range!: Range; + protected _newText!: string; + protected _newEol: EndOfLine = EndOfLine.LF; get range(): Range { return this._range; @@ -923,16 +923,16 @@ export class CompletionItem implements theia.CompletionItem { label: string; kind?: CompletionItemKind; tags?: CompletionItemTag[]; - detail: string; - documentation: string | MarkdownString; - sortText: string; - filterText: string; - preselect: boolean; - insertText: string | SnippetString; - range: Range; - textEdit: TextEdit; - additionalTextEdits: TextEdit[]; - command: theia.Command; + detail?: string; + documentation?: string | MarkdownString; + sortText?: string; + filterText?: string; + preselect?: boolean; + insertText?: string | SnippetString; + range?: Range; + textEdit?: TextEdit; + additionalTextEdits?: TextEdit[]; + command?: theia.Command; constructor(label: string, kind?: CompletionItemKind) { this.label = label; @@ -976,6 +976,8 @@ export class Location { this.range = rangeOrPosition; } else if (rangeOrPosition instanceof Position) { this.range = new Range(rangeOrPosition, rangeOrPosition); + } else { + throw illegalArgument('rangeOrPosition'); } } @@ -1072,13 +1074,9 @@ export enum SignatureHelpTriggerKind { @es5ClassCompat export class SignatureHelp { - signatures: SignatureInformation[]; - activeSignature: number; - activeParameter: number; - - constructor() { - this.signatures = []; - } + signatures: SignatureInformation[] = []; + activeSignature: number = 0; + activeParameter: number = 0; } @es5ClassCompat @@ -1444,6 +1442,7 @@ export class SymbolInformation { kind: SymbolKind; tags?: SymbolTag[]; containerName: undefined | string; + constructor(name: string, kind: SymbolKind, containerName: string, location: Location); constructor(name: string, kind: SymbolKind, range: Range, uri?: URI, containerName?: string); constructor(name: string, kind: SymbolKind, rangeOrContainer: string | Range, locationOrUri?: Location | URI, containerName?: string) { @@ -1459,6 +1458,8 @@ export class SymbolInformation { this.location = locationOrUri; } else if (rangeOrContainer instanceof Range) { this.location = new Location(locationOrUri!, rangeOrContainer); + } else { + throw illegalArgument('locationOrUri'); } SymbolInformation.validate(this); @@ -1679,7 +1680,7 @@ export enum ProgressLocation { @es5ClassCompat export class ProcessExecution { private executionProcess: string; - private arguments: string[]; + private arguments: string[] = []; private executionOptions: theia.ProcessExecutionOptions | undefined; constructor(process: string, options?: theia.ProcessExecutionOptions); @@ -1697,9 +1698,6 @@ export class ProcessExecution { this.executionOptions = varg1; } } - if (this.arguments === undefined) { - this.arguments = []; - } } get process(): string { @@ -1758,9 +1756,9 @@ export enum TaskRevealKind { @es5ClassCompat export class ShellExecution { - private shellCommandLine: string; - private shellCommand: string | theia.ShellQuotedString; - private arguments: (string | theia.ShellQuotedString)[]; + private shellCommandLine!: string; + private shellCommand!: string | theia.ShellQuotedString; + private arguments!: (string | theia.ShellQuotedString)[]; private shellOptions: theia.ShellExecutionOptions | undefined; constructor(commandLine: string, options?: theia.ShellExecutionOptions); @@ -1897,16 +1895,16 @@ export enum TaskScope { @es5ClassCompat export class Task { - private taskDefinition: theia.TaskDefinition; + private taskDefinition!: theia.TaskDefinition; private taskScope: theia.TaskScope.Global | theia.TaskScope.Workspace | theia.WorkspaceFolder | undefined; - private taskName: string; + private taskName!: string; private taskExecution: ProcessExecution | ShellExecution | CustomExecution | undefined; private taskProblemMatchers: string[]; private hasTaskProblemMatchers: boolean; private isTaskBackground: boolean; - private taskSource: string; + private taskSource!: string; private taskGroup: TaskGroup | undefined; - private taskPresentationOptions: theia.TaskPresentationOptions; + private taskPresentationOptions!: theia.TaskPresentationOptions; constructor( taskDefinition: theia.TaskDefinition, scope: theia.WorkspaceFolder | theia.TaskScope.Global | theia.TaskScope.Workspace, diff --git a/packages/plugin-ext/src/plugin/webviews.ts b/packages/plugin-ext/src/plugin/webviews.ts index 7f573d973129d..e83ba27990bf0 100644 --- a/packages/plugin-ext/src/plugin/webviews.ts +++ b/packages/plugin-ext/src/plugin/webviews.ts @@ -156,7 +156,7 @@ export class WebviewsExtImpl implements WebviewsExt { export class WebviewImpl implements theia.Webview { private isDisposed = false; - private _html: string; + private _html?: string; private _options: theia.WebviewOptions; // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -199,6 +199,9 @@ export class WebviewImpl implements theia.Webview { get html(): string { this.checkIsDisposed(); + if (!this._html) { + throw new Error('WebviewImpl._html is not set'); + } return this._html; } diff --git a/packages/plugin-ext/src/plugin/workspace.ts b/packages/plugin-ext/src/plugin/workspace.ts index 73e7abda0b836..6950284834849 100644 --- a/packages/plugin-ext/src/plugin/workspace.ts +++ b/packages/plugin-ext/src/plugin/workspace.ts @@ -168,7 +168,7 @@ export class WorkspaceExtImpl implements WorkspaceExt { } findFiles(include: theia.GlobPattern, exclude?: theia.GlobPattern | null, maxResults?: number, - token: CancellationToken = CancellationToken.None): PromiseLike { + token: theia.CancellationToken = CancellationToken.None): PromiseLike { let includePattern: string; let includeFolderUri: string | undefined; if (include) { @@ -204,7 +204,7 @@ export class WorkspaceExtImpl implements WorkspaceExt { } findTextInFiles(query: theia.TextSearchQuery, optionsOrCallback: theia.FindTextInFilesOptions | ((result: theia.TextSearchResult) => void), - callbackOrToken?: CancellationToken | ((result: theia.TextSearchResult) => void), token?: CancellationToken): Promise { + callbackOrToken?: theia.CancellationToken | ((result: theia.TextSearchResult) => void), token?: theia.CancellationToken): Promise { let options: theia.FindTextInFilesOptions; let callback: (result: theia.TextSearchResult) => void; diff --git a/packages/plugin-metrics/src/browser/plugin-metrics-creator.ts b/packages/plugin-metrics/src/browser/plugin-metrics-creator.ts index c64cfc1e12fa9..08c351bdb8860 100644 --- a/packages/plugin-metrics/src/browser/plugin-metrics-creator.ts +++ b/packages/plugin-metrics/src/browser/plugin-metrics-creator.ts @@ -22,7 +22,7 @@ import { AnalyticsFromRequests, DataFromRequest, createRequestData, createDefaul export class PluginMetricsCreator { @inject(PluginMetrics) - private pluginMetrics: PluginMetrics; + private pluginMetrics!: PluginMetrics; private _extensionIDAnalytics: MetricsMap; diff --git a/packages/plugin-metrics/src/browser/plugin-metrics-languages-main.ts b/packages/plugin-metrics/src/browser/plugin-metrics-languages-main.ts index 0a6f529d9af3d..3361a186d7cfc 100644 --- a/packages/plugin-metrics/src/browser/plugin-metrics-languages-main.ts +++ b/packages/plugin-metrics/src/browser/plugin-metrics-languages-main.ts @@ -27,7 +27,7 @@ import * as theia from '@theia/plugin'; export class LanguagesMainPluginMetrics extends LanguagesMainImpl { @inject(PluginMetricsResolver) - private pluginMetricsResolver: PluginMetricsResolver; + private pluginMetricsResolver!: PluginMetricsResolver; // Map of handle to extension id protected readonly handleToExtensionID = new Map(); diff --git a/packages/plugin-metrics/src/browser/plugin-metrics-output-registry.ts b/packages/plugin-metrics/src/browser/plugin-metrics-output-registry.ts index 961ba51d840a6..530ae0dc319fa 100644 --- a/packages/plugin-metrics/src/browser/plugin-metrics-output-registry.ts +++ b/packages/plugin-metrics/src/browser/plugin-metrics-output-registry.ts @@ -24,7 +24,7 @@ import { PluginInfo } from '@theia/plugin-ext/lib/common/plugin-api-rpc'; export class PluginMetricsOutputChannelRegistry extends OutputChannelRegistryMainImpl { @inject(PluginMetricsCreator) - protected readonly pluginMetricsCreator: PluginMetricsCreator; + protected readonly pluginMetricsCreator!: PluginMetricsCreator; $append(channelName: string, errorOrValue: string, pluginInfo: PluginInfo): PromiseLike { if (errorOrValue.startsWith('[Error')) { diff --git a/packages/plugin-metrics/src/browser/plugin-metrics-resolver.ts b/packages/plugin-metrics/src/browser/plugin-metrics-resolver.ts index 4d95712ac2e37..bf4bec5cae27c 100644 --- a/packages/plugin-metrics/src/browser/plugin-metrics-resolver.ts +++ b/packages/plugin-metrics/src/browser/plugin-metrics-resolver.ts @@ -28,7 +28,7 @@ import { createRequestData } from '../common/plugin-metrics-types'; export class PluginMetricsResolver { @inject(PluginMetricsCreator) - private metricsCreator: PluginMetricsCreator; + private metricsCreator!: PluginMetricsCreator; /** * Resolve a request for pluginID and create a metric based on whether or not diff --git a/packages/plugin-metrics/src/node/metric-string-generator.ts b/packages/plugin-metrics/src/node/metric-string-generator.ts index 538bd355d3e81..97b73658aca1c 100644 --- a/packages/plugin-metrics/src/node/metric-string-generator.ts +++ b/packages/plugin-metrics/src/node/metric-string-generator.ts @@ -22,10 +22,10 @@ import { injectable, inject } from '@theia/core/shared/inversify'; export class PluginMetricStringGenerator { @inject(PluginMetricTimeCount) - private pluginMetricsTimeCount: PluginMetricTimeCount; + private pluginMetricsTimeCount!: PluginMetricTimeCount; @inject(PluginMetricTimeSum) - private pluginMetricsTimeSum: PluginMetricTimeSum; + private pluginMetricsTimeSum!: PluginMetricTimeSum; getMetricsString(extensionIDAnalytics: MetricsMap): string { diff --git a/packages/plugin-metrics/src/node/plugin-metrics.ts b/packages/plugin-metrics/src/node/plugin-metrics.ts index 1e79492f18f35..03eb28fc3ea56 100644 --- a/packages/plugin-metrics/src/node/plugin-metrics.ts +++ b/packages/plugin-metrics/src/node/plugin-metrics.ts @@ -24,14 +24,17 @@ import { PluginMetricStringGenerator } from './metric-string-generator'; export class PluginMetricsContribution implements MetricsContribution { @inject(PluginMetricsContributor) - protected readonly metricsContributor: PluginMetricsContributor; + protected readonly metricsContributor!: PluginMetricsContributor; @inject(PluginMetricStringGenerator) - protected readonly stringGenerator: PluginMetricStringGenerator; + protected readonly stringGenerator!: PluginMetricStringGenerator; - private metrics: string; + private metrics?: string; getMetrics(): string { + if (!this.metrics) { + throw new Error('PluginMetricsContribution.metrics is not set'); + } return this.metrics; } diff --git a/packages/plugin/src/theia.d.ts b/packages/plugin/src/theia.d.ts index afd45dab01163..8a10a3cddcaa3 100644 --- a/packages/plugin/src/theia.d.ts +++ b/packages/plugin/src/theia.d.ts @@ -2287,7 +2287,7 @@ export module '@theia/plugin' { * @return A human readable string which is presented as diagnostic message. * Return `undefined`, or the empty string when 'value' is valid. */ - validateInput?: (input: string) => Promise | undefined; + validateInput?: (input: string) => Promise; /** * An optional function that will be called on Enter key. diff --git a/packages/preferences/src/browser/abstract-resource-preference-provider.ts b/packages/preferences/src/browser/abstract-resource-preference-provider.ts index 6b85d4c45590b..06e0d068a4d52 100644 --- a/packages/preferences/src/browser/abstract-resource-preference-provider.ts +++ b/packages/preferences/src/browser/abstract-resource-preference-provider.ts @@ -38,18 +38,18 @@ export abstract class AbstractResourcePreferenceProvider extends PreferenceProvi protected readonly loading = new Deferred(); protected modelInitialized = false; - @inject(MessageService) protected readonly messageService: MessageService; - @inject(PreferenceSchemaProvider) protected readonly schemaProvider: PreferenceSchemaProvider; - @inject(FileService) protected readonly fileService: FileService; + @inject(MessageService) protected readonly messageService!: MessageService; + @inject(PreferenceSchemaProvider) protected readonly schemaProvider!: PreferenceSchemaProvider; + @inject(FileService) protected readonly fileService!: FileService; @inject(PreferenceConfigurations) - protected readonly configurations: PreferenceConfigurations; + protected readonly configurations!: PreferenceConfigurations; @inject(MonacoTextModelService) - protected readonly textModelService: MonacoTextModelService; + protected readonly textModelService!: MonacoTextModelService; @inject(MonacoWorkspace) - protected readonly workspace: MonacoWorkspace; + protected readonly workspace!: MonacoWorkspace; @postConstruct() protected async init(): Promise { diff --git a/packages/preferences/src/browser/folder-preference-provider.ts b/packages/preferences/src/browser/folder-preference-provider.ts index ac6cc92c68f4c..2428a67225590 100644 --- a/packages/preferences/src/browser/folder-preference-provider.ts +++ b/packages/preferences/src/browser/folder-preference-provider.ts @@ -35,10 +35,10 @@ export interface FolderPreferenceProviderOptions { @injectable() export class FolderPreferenceProvider extends SectionPreferenceProvider { - @inject(WorkspaceService) protected readonly workspaceService: WorkspaceService; - @inject(FolderPreferenceProviderFolder) protected readonly folder: FileStat; + @inject(WorkspaceService) protected readonly workspaceService!: WorkspaceService; + @inject(FolderPreferenceProviderFolder) protected readonly folder!: FileStat; - private _folderUri: URI; + private _folderUri?: URI; get folderUri(): URI { if (!this._folderUri) { diff --git a/packages/preferences/src/browser/folders-preferences-provider.ts b/packages/preferences/src/browser/folders-preferences-provider.ts index c27e10cf3ee3a..1aff861adc0f0 100644 --- a/packages/preferences/src/browser/folders-preferences-provider.ts +++ b/packages/preferences/src/browser/folders-preferences-provider.ts @@ -28,13 +28,13 @@ import { FileStat } from '@theia/filesystem/lib/common/files'; export class FoldersPreferencesProvider extends PreferenceProvider { @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @inject(FolderPreferenceProviderFactory) - protected readonly folderPreferenceProviderFactory: FolderPreferenceProviderFactory; + protected readonly folderPreferenceProviderFactory!: FolderPreferenceProviderFactory; @inject(PreferenceConfigurations) - protected readonly configurations: PreferenceConfigurations; + protected readonly configurations!: PreferenceConfigurations; protected readonly providers = new Map(); diff --git a/packages/preferences/src/browser/preference-tree-model.ts b/packages/preferences/src/browser/preference-tree-model.ts index b05f81cb4105b..6860168e03085 100644 --- a/packages/preferences/src/browser/preference-tree-model.ts +++ b/packages/preferences/src/browser/preference-tree-model.ts @@ -56,11 +56,11 @@ export interface PreferenceFilterChangeEvent { @injectable() export class PreferenceTreeModel extends TreeModelImpl { - @inject(PreferenceSchemaProvider) protected readonly schemaProvider: PreferenceSchemaProvider; - @inject(PreferencesSearchbarWidget) protected readonly filterInput: PreferencesSearchbarWidget; - @inject(PreferenceTreeGenerator) protected readonly treeGenerator: PreferenceTreeGenerator; - @inject(PreferencesScopeTabBar) protected readonly scopeTracker: PreferencesScopeTabBar; - @inject(PreferenceService) protected readonly preferenceService: PreferenceService; + @inject(PreferenceSchemaProvider) protected readonly schemaProvider!: PreferenceSchemaProvider; + @inject(PreferencesSearchbarWidget) protected readonly filterInput!: PreferencesSearchbarWidget; + @inject(PreferenceTreeGenerator) protected readonly treeGenerator!: PreferenceTreeGenerator; + @inject(PreferencesScopeTabBar) protected readonly scopeTracker!: PreferencesScopeTabBar; + @inject(PreferenceService) protected readonly preferenceService!: PreferenceService; protected readonly onTreeFilterChangedEmitter = new Emitter(); readonly onFilterChanged = this.onTreeFilterChangedEmitter.event; diff --git a/packages/preferences/src/browser/preferences-contribution.ts b/packages/preferences/src/browser/preferences-contribution.ts index 28c2789d35094..34cbc95280b41 100644 --- a/packages/preferences/src/browser/preferences-contribution.ts +++ b/packages/preferences/src/browser/preferences-contribution.ts @@ -44,14 +44,14 @@ import { FileStat } from '@theia/filesystem/lib/common/files'; @injectable() export class PreferencesContribution extends AbstractViewContribution { - @inject(FileService) protected readonly fileService: FileService; - @inject(PreferenceProvider) @named(PreferenceScope.Workspace) protected readonly workspacePreferenceProvider: WorkspacePreferenceProvider; - @inject(EditorManager) protected readonly editorManager: EditorManager; - @inject(PreferenceService) protected readonly preferenceService: PreferenceService; - @inject(ClipboardService) protected readonly clipboardService: ClipboardService; - @inject(PreferencesWidget) protected readonly scopeTracker: PreferencesWidget; - @inject(WorkspaceService) protected readonly workspaceService: WorkspaceService; - @inject(QuickInputService) @optional() protected readonly quickInputService: QuickInputService; + @inject(FileService) protected readonly fileService!: FileService; + @inject(PreferenceProvider) @named(PreferenceScope.Workspace) protected readonly workspacePreferenceProvider!: WorkspacePreferenceProvider; + @inject(EditorManager) protected readonly editorManager!: EditorManager; + @inject(PreferenceService) protected readonly preferenceService!: PreferenceService; + @inject(ClipboardService) protected readonly clipboardService!: ClipboardService; + @inject(PreferencesWidget) protected readonly scopeTracker!: PreferencesWidget; + @inject(WorkspaceService) protected readonly workspaceService!: WorkspaceService; + @inject(QuickInputService) @optional() protected readonly quickInputService?: QuickInputService; constructor() { super({ diff --git a/packages/preferences/src/browser/preferences-json-schema-contribution.ts b/packages/preferences/src/browser/preferences-json-schema-contribution.ts index 39d0934fecc17..23db5db127823 100644 --- a/packages/preferences/src/browser/preferences-json-schema-contribution.ts +++ b/packages/preferences/src/browser/preferences-json-schema-contribution.ts @@ -31,16 +31,16 @@ export class PreferencesJsonSchemaContribution implements JsonSchemaContribution private serializeSchema = (scope: PreferenceScope) => JSON.stringify(this.schemaProvider.getSchema(scope)); @inject(PreferenceSchemaProvider) - protected readonly schemaProvider: PreferenceSchemaProvider; + protected readonly schemaProvider!: PreferenceSchemaProvider; @inject(InMemoryResources) - protected readonly inmemoryResources: InMemoryResources; + protected readonly inmemoryResources!: InMemoryResources; @inject(PreferenceConfigurations) - protected readonly preferenceConfigurations: PreferenceConfigurations; + protected readonly preferenceConfigurations!: PreferenceConfigurations; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; registerSchemas(context: JsonSchemaRegisterContext): void { this.registerSchema(PreferenceScope.Default, context); diff --git a/packages/preferences/src/browser/section-preference-provider.ts b/packages/preferences/src/browser/section-preference-provider.ts index 90c17461c22c4..bf78060d9fb24 100644 --- a/packages/preferences/src/browser/section-preference-provider.ts +++ b/packages/preferences/src/browser/section-preference-provider.ts @@ -31,13 +31,13 @@ export const SectionPreferenceProviderSection = Symbol('SectionPreferenceProvide export abstract class SectionPreferenceProvider extends AbstractResourcePreferenceProvider { @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @inject(SectionPreferenceProviderUri) - protected readonly uri: URI; + protected readonly uri!: URI; @inject(SectionPreferenceProviderSection) - protected readonly section: string; + protected readonly section!: string; @inject(PreferenceConfigurations) - protected readonly preferenceConfigurations: PreferenceConfigurations; + protected readonly preferenceConfigurations!: PreferenceConfigurations; private _isSection?: boolean; diff --git a/packages/preferences/src/browser/user-configs-preference-provider.ts b/packages/preferences/src/browser/user-configs-preference-provider.ts index 19891acae6e8e..d37df3dcd997d 100644 --- a/packages/preferences/src/browser/user-configs-preference-provider.ts +++ b/packages/preferences/src/browser/user-configs-preference-provider.ts @@ -30,10 +30,10 @@ import { UserPreferenceProvider, UserPreferenceProviderFactory } from './user-pr export class UserConfigsPreferenceProvider extends PreferenceProvider { @inject(UserPreferenceProviderFactory) - protected readonly providerFactory: UserPreferenceProviderFactory; + protected readonly providerFactory!: UserPreferenceProviderFactory; @inject(PreferenceConfigurations) - protected readonly configurations: PreferenceConfigurations; + protected readonly configurations!: PreferenceConfigurations; protected readonly providers = new Map(); diff --git a/packages/preferences/src/browser/util/preference-scope-command-manager.ts b/packages/preferences/src/browser/util/preference-scope-command-manager.ts index a6df7b3ce75e9..c09d79a5f2bf9 100644 --- a/packages/preferences/src/browser/util/preference-scope-command-manager.ts +++ b/packages/preferences/src/browser/util/preference-scope-command-manager.ts @@ -30,9 +30,9 @@ export const FOLDER_SCOPE_MENU_PATH = PreferenceMenus.FOLDER_SCOPE_MENU_PATH; */ @injectable() export class PreferenceScopeCommandManager { - @inject(CommandRegistry) protected readonly commandRegistry: CommandRegistry; - @inject(MenuModelRegistry) protected readonly menuModelRegistry: MenuModelRegistry; - @inject(LabelProvider) protected readonly labelProvider: LabelProvider; + @inject(CommandRegistry) protected readonly commandRegistry!: CommandRegistry; + @inject(MenuModelRegistry) protected readonly menuModelRegistry!: MenuModelRegistry; + @inject(LabelProvider) protected readonly labelProvider!: LabelProvider; protected foldersAsCommands: Command[] = []; diff --git a/packages/preferences/src/browser/util/preference-tree-generator.ts b/packages/preferences/src/browser/util/preference-tree-generator.ts index 8c67a0569df28..9d1aee6cac3dd 100644 --- a/packages/preferences/src/browser/util/preference-tree-generator.ts +++ b/packages/preferences/src/browser/util/preference-tree-generator.ts @@ -25,10 +25,10 @@ export const COMMONLY_USED_SECTION_PREFIX = 'commonly-used'; @injectable() export class PreferenceTreeGenerator { - @inject(PreferenceSchemaProvider) protected readonly schemaProvider: PreferenceSchemaProvider; - @inject(PreferenceConfigurations) protected readonly preferenceConfigs: PreferenceConfigurations; + @inject(PreferenceSchemaProvider) protected readonly schemaProvider!: PreferenceSchemaProvider; + @inject(PreferenceConfigurations) protected readonly preferenceConfigs!: PreferenceConfigurations; - protected _root: CompositeTreeNode; + protected _root?: CompositeTreeNode; protected readonly onSchemaChangedEmitter = new Emitter(); readonly onSchemaChanged = this.onSchemaChangedEmitter.event; diff --git a/packages/preferences/src/browser/util/preference-tree-label-provider.ts b/packages/preferences/src/browser/util/preference-tree-label-provider.ts index 6911ed4f808af..eebc37d4c3f31 100644 --- a/packages/preferences/src/browser/util/preference-tree-label-provider.ts +++ b/packages/preferences/src/browser/util/preference-tree-label-provider.ts @@ -20,7 +20,7 @@ import { Preference } from './preference-types'; import { PreferenceTreeGenerator } from './preference-tree-generator'; @injectable() export class PreferenceTreeLabelProvider implements LabelProviderContribution { - @inject(PreferenceTreeGenerator) protected readonly treeGenerator: PreferenceTreeGenerator; + @inject(PreferenceTreeGenerator) protected readonly treeGenerator!: PreferenceTreeGenerator; canHandle(element: object): number { return TreeNode.is(element) && Preference.TreeNode.is(element) ? 150 : 0; diff --git a/packages/preferences/src/browser/views/components/preference-array-input.ts b/packages/preferences/src/browser/views/components/preference-array-input.ts index a471adc549beb..d11e9959ab4ae 100644 --- a/packages/preferences/src/browser/views/components/preference-array-input.ts +++ b/packages/preferences/src/browser/views/components/preference-array-input.ts @@ -21,8 +21,8 @@ import { PreferenceLeafNodeRenderer } from './preference-node-renderer'; @injectable() export class PreferenceArrayInputRenderer extends PreferenceLeafNodeRenderer { existingValues = new Map(); - wrapper: HTMLElement; - inputWrapper: HTMLElement; + wrapper?: HTMLElement; + inputWrapper?: HTMLElement; protected createInteractable(parent: HTMLElement): void { const wrapper = document.createElement('ul'); @@ -109,7 +109,7 @@ export class PreferenceArrayInputRenderer extends PreferenceLeafNodeRenderer { - @inject(CommandService) protected readonly commandService: CommandService; + @inject(CommandService) protected readonly commandService!: CommandService; protected createInteractable(parent: HTMLElement): void { const message = 'Edit in settings.json'; diff --git a/packages/preferences/src/browser/views/components/preference-node-renderer.ts b/packages/preferences/src/browser/views/components/preference-node-renderer.ts index 46453e91448b4..783b9769a3f0f 100644 --- a/packages/preferences/src/browser/views/components/preference-node-renderer.ts +++ b/packages/preferences/src/browser/views/components/preference-node-renderer.ts @@ -49,15 +49,15 @@ export interface GeneralPreferenceNodeRenderer extends Disposable { @injectable() export abstract class PreferenceNodeRenderer implements Disposable, GeneralPreferenceNodeRenderer { - @inject(Preference.Node) protected readonly preferenceNode: Preference.Node; - @inject(PreferenceTreeLabelProvider) protected readonly labelProvider: PreferenceTreeLabelProvider; + @inject(Preference.Node) protected readonly preferenceNode!: Preference.Node; + @inject(PreferenceTreeLabelProvider) protected readonly labelProvider!: PreferenceTreeLabelProvider; protected attached = false; - _id: string; - _group: string; - _subgroup: string; - protected domNode: HTMLElement; + _id!: string; + _group!: string; + _subgroup!: string; + protected domNode!: HTMLElement; get node(): HTMLElement { return this.domNode; @@ -145,16 +145,16 @@ export class PreferenceHeaderRenderer extends PreferenceNodeRenderer { export abstract class PreferenceLeafNodeRenderer extends PreferenceNodeRenderer implements Required { - @inject(Preference.Node) protected readonly preferenceNode: Preference.LeafNode; - @inject(PreferenceService) protected readonly preferenceService: PreferenceService; - @inject(ContextMenuRenderer) protected readonly menuRenderer: ContextMenuRenderer; - @inject(PreferencesScopeTabBar) protected readonly scopeTracker: PreferencesScopeTabBar; - @inject(PreferenceTreeModel) protected readonly model: PreferenceTreeModel; - @inject(PreferencesSearchbarWidget) protected readonly searchbar: PreferencesSearchbarWidget; - - protected headlineWrapper: HTMLDivElement; - protected gutter: HTMLDivElement; - protected interactable: InteractableType; + @inject(Preference.Node) protected readonly preferenceNode!: Preference.LeafNode; + @inject(PreferenceService) protected readonly preferenceService!: PreferenceService; + @inject(ContextMenuRenderer) protected readonly menuRenderer!: ContextMenuRenderer; + @inject(PreferencesScopeTabBar) protected readonly scopeTracker!: PreferencesScopeTabBar; + @inject(PreferenceTreeModel) protected readonly model!: PreferenceTreeModel; + @inject(PreferencesSearchbarWidget) protected readonly searchbar!: PreferencesSearchbarWidget; + + protected headlineWrapper!: HTMLDivElement; + protected gutter!: HTMLDivElement; + protected interactable!: InteractableType; protected inspection: PreferenceInspection | undefined; protected isModifiedFromDefault = false; diff --git a/packages/preferences/src/browser/views/components/preference-number-input.ts b/packages/preferences/src/browser/views/components/preference-number-input.ts index 4e864a6df1368..51de7f79d2436 100644 --- a/packages/preferences/src/browser/views/components/preference-number-input.ts +++ b/packages/preferences/src/browser/views/components/preference-number-input.ts @@ -32,7 +32,7 @@ interface PreferenceNumberInputValidation { export class PreferenceNumberInputRenderer extends PreferenceLeafNodeRenderer { protected _errorMessage: HTMLElement | undefined; - protected interactableWrapper: HTMLElement; + protected interactableWrapper?: HTMLElement; get errorMessage(): HTMLElement { if (!this._errorMessage) { @@ -119,7 +119,7 @@ export class PreferenceNumberInputRenderer extends PreferenceLeafNodeRenderer(); - @inject(PreferenceService) protected readonly preferenceService: PreferenceService; - @inject(PreferenceTreeModel) protected readonly model: PreferenceTreeModel; - @inject(PreferenceNodeRendererFactory) protected readonly rendererFactory: PreferenceNodeRendererFactory; - @inject(PreferencesScopeTabBar) protected readonly tabbar: PreferencesScopeTabBar; + @inject(PreferenceService) protected readonly preferenceService!: PreferenceService; + @inject(PreferenceTreeModel) protected readonly model!: PreferenceTreeModel; + @inject(PreferenceNodeRendererFactory) protected readonly rendererFactory!: PreferenceNodeRendererFactory; + @inject(PreferencesScopeTabBar) protected readonly tabbar!: PreferencesScopeTabBar; @postConstruct() protected async init(): Promise { diff --git a/packages/preferences/src/browser/views/preference-scope-tabbar-widget.tsx b/packages/preferences/src/browser/views/preference-scope-tabbar-widget.tsx index f2f64cc86b51f..316faf9290421 100644 --- a/packages/preferences/src/browser/views/preference-scope-tabbar-widget.tsx +++ b/packages/preferences/src/browser/views/preference-scope-tabbar-widget.tsx @@ -51,18 +51,18 @@ export interface PreferencesScopeTabBarState { export class PreferencesScopeTabBar extends TabBar implements StatefulWidget { static ID = 'preferences-scope-tab-bar'; - @inject(WorkspaceService) protected readonly workspaceService: WorkspaceService; - @inject(PreferenceScopeCommandManager) protected readonly preferencesMenuFactory: PreferenceScopeCommandManager; - @inject(ContextMenuRenderer) protected readonly contextMenuRenderer: ContextMenuRenderer; - @inject(LabelProvider) protected readonly labelProvider: LabelProvider; - @inject(CommandRegistry) protected readonly commandRegistry: CommandRegistry; - @inject(MenuModelRegistry) protected readonly menuModelRegistry: MenuModelRegistry; + @inject(WorkspaceService) protected readonly workspaceService!: WorkspaceService; + @inject(PreferenceScopeCommandManager) protected readonly preferencesMenuFactory!: PreferenceScopeCommandManager; + @inject(ContextMenuRenderer) protected readonly contextMenuRenderer!: ContextMenuRenderer; + @inject(LabelProvider) protected readonly labelProvider!: LabelProvider; + @inject(CommandRegistry) protected readonly commandRegistry!: CommandRegistry; + @inject(MenuModelRegistry) protected readonly menuModelRegistry!: MenuModelRegistry; protected readonly onScopeChangedEmitter = new Emitter(); readonly onScopeChanged = this.onScopeChangedEmitter.event; protected toDispose = new DisposableCollection(); - protected folderTitle: Title; + protected folderTitle?: Title; protected currentWorkspaceRoots: FileStat[] = []; protected currentSelection: Preference.SelectedScopeDetails = Preference.DEFAULT_SCOPE; protected editorScrollAtTop = true; @@ -215,6 +215,9 @@ export class PreferencesScopeTabBar extends TabBar implements StatefulWi } protected setFolderTitleProperties(multipleFolderRootsAreAvailable: boolean): void { + if (!this.folderTitle) { + throw new Error('PreferencesScopeTabBawr.folderTitle is not set'); + } this.folderTitle.iconClass = multipleFolderRootsAreAvailable ? FOLDER_DROPDOWN_ICON_CLASSNAME : ''; if (this.currentSelection.scope === FOLDER_TAB_INDEX) { this.folderTitle.label = this.labelProvider.getName(new URI(this.currentSelection.uri)); diff --git a/packages/preferences/src/browser/views/preference-tree-widget.tsx b/packages/preferences/src/browser/views/preference-tree-widget.tsx index d71376fc71acd..d6a6ad56c052b 100644 --- a/packages/preferences/src/browser/views/preference-tree-widget.tsx +++ b/packages/preferences/src/browser/views/preference-tree-widget.tsx @@ -31,11 +31,10 @@ export class PreferencesTreeWidget extends TreeWidget { static ID = 'preferences.tree'; protected shouldFireSelectionEvents: boolean = true; - protected firstVisibleLeafNodeID: string; - @inject(PreferenceTreeModel) readonly model: PreferenceTreeModel; - @inject(TreeProps) protected readonly treeProps: TreeProps; - @inject(ContextMenuRenderer) protected readonly contextMenuRenderer: ContextMenuRenderer; + @inject(PreferenceTreeModel) readonly model!: PreferenceTreeModel; + @inject(TreeProps) protected readonly treeProps!: TreeProps; + @inject(ContextMenuRenderer) protected readonly contextMenuRenderer!: ContextMenuRenderer; @postConstruct() init(): void { diff --git a/packages/preferences/src/browser/views/preference-widget.tsx b/packages/preferences/src/browser/views/preference-widget.tsx index 028ea68e52f7d..643568fab8fc5 100644 --- a/packages/preferences/src/browser/views/preference-widget.tsx +++ b/packages/preferences/src/browser/views/preference-widget.tsx @@ -41,10 +41,10 @@ export class PreferencesWidget extends Panel implements StatefulWidget { */ static readonly LABEL = nls.localizeByDefault('Preferences'); - @inject(PreferencesEditorWidget) protected readonly editorWidget: PreferencesEditorWidget; - @inject(PreferencesTreeWidget) protected readonly treeWidget: PreferencesTreeWidget; - @inject(PreferencesSearchbarWidget) protected readonly searchbarWidget: PreferencesSearchbarWidget; - @inject(PreferencesScopeTabBar) protected readonly tabBarWidget: PreferencesScopeTabBar; + @inject(PreferencesEditorWidget) protected readonly editorWidget!: PreferencesEditorWidget; + @inject(PreferencesTreeWidget) protected readonly treeWidget!: PreferencesTreeWidget; + @inject(PreferencesSearchbarWidget) protected readonly searchbarWidget!: PreferencesSearchbarWidget; + @inject(PreferencesScopeTabBar) protected readonly tabBarWidget!: PreferencesScopeTabBar; get currentScope(): Preference.SelectedScopeDetails { return this.tabBarWidget.currentScope; diff --git a/packages/preferences/src/browser/workspace-file-preference-provider.ts b/packages/preferences/src/browser/workspace-file-preference-provider.ts index 4c2f418f18602..5f047195f896d 100644 --- a/packages/preferences/src/browser/workspace-file-preference-provider.ts +++ b/packages/preferences/src/browser/workspace-file-preference-provider.ts @@ -21,8 +21,8 @@ import { WorkspaceService, WorkspaceData } from '@theia/workspace/lib/browser/wo import { AbstractResourcePreferenceProvider } from './abstract-resource-preference-provider'; @injectable() -export class WorkspaceFilePreferenceProviderOptions { - workspaceUri: URI; +export abstract class WorkspaceFilePreferenceProviderOptions { + abstract workspaceUri: URI; } export const WorkspaceFilePreferenceProviderFactory = Symbol('WorkspaceFilePreferenceProviderFactory'); @@ -32,10 +32,10 @@ export type WorkspaceFilePreferenceProviderFactory = (options: WorkspaceFilePref export class WorkspaceFilePreferenceProvider extends AbstractResourcePreferenceProvider { @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @inject(WorkspaceFilePreferenceProviderOptions) - protected readonly options: WorkspaceFilePreferenceProviderOptions; + protected readonly options!: WorkspaceFilePreferenceProviderOptions; protected sectionsInsideSettings = new Set(); diff --git a/packages/preferences/src/browser/workspace-preference-provider.ts b/packages/preferences/src/browser/workspace-preference-provider.ts index 7d2d81a542842..9c053065598c2 100644 --- a/packages/preferences/src/browser/workspace-preference-provider.ts +++ b/packages/preferences/src/browser/workspace-preference-provider.ts @@ -27,13 +27,13 @@ import { WorkspaceFilePreferenceProviderFactory, WorkspaceFilePreferenceProvider export class WorkspacePreferenceProvider extends PreferenceProvider { @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @inject(WorkspaceFilePreferenceProviderFactory) - protected readonly workspaceFileProviderFactory: WorkspaceFilePreferenceProviderFactory; + protected readonly workspaceFileProviderFactory!: WorkspaceFilePreferenceProviderFactory; @inject(PreferenceProvider) @named(PreferenceScope.Folder) - protected readonly folderPreferenceProvider: PreferenceProvider; + protected readonly folderPreferenceProvider!: PreferenceProvider; protected readonly toDisposeOnEnsureDelegateUpToDate = new DisposableCollection(); diff --git a/packages/preview/src/browser/markdown/markdown-preview-handler.ts b/packages/preview/src/browser/markdown/markdown-preview-handler.ts index 8444e7b60c109..ac8d5ea7ab471 100644 --- a/packages/preview/src/browser/markdown/markdown-preview-handler.ts +++ b/packages/preview/src/browser/markdown/markdown-preview-handler.ts @@ -36,10 +36,10 @@ export class MarkdownPreviewHandler implements PreviewHandler { readonly contentClass: string = 'markdown-preview'; @inject(OpenerService) - protected readonly openerService: OpenerService; + protected readonly openerService!: OpenerService; @inject(PreviewLinkNormalizer) - protected readonly linkNormalizer: PreviewLinkNormalizer; + protected readonly linkNormalizer!: PreviewLinkNormalizer; canHandle(uri: URI): number { return uri.scheme === 'file' diff --git a/packages/preview/src/browser/preview-contribution.ts b/packages/preview/src/browser/preview-contribution.ts index c00ae6fb45fec..6fe1676c2b47e 100644 --- a/packages/preview/src/browser/preview-contribution.ts +++ b/packages/preview/src/browser/preview-contribution.ts @@ -59,13 +59,13 @@ export class PreviewContribution extends NavigatableWidgetOpenHandler(); diff --git a/packages/preview/src/browser/preview-link-normalizer.ts b/packages/preview/src/browser/preview-link-normalizer.ts index a618dc99522e9..22dbd6b9b6542 100644 --- a/packages/preview/src/browser/preview-link-normalizer.ts +++ b/packages/preview/src/browser/preview-link-normalizer.ts @@ -24,7 +24,7 @@ export class PreviewLinkNormalizer { protected urlScheme = new RegExp('^[a-z][a-z|0-9|\+|\-|\.]*:', 'i'); @inject(MiniBrowserEnvironment) - protected readonly miniBrowserEnvironment: MiniBrowserEnvironment; + protected readonly miniBrowserEnvironment!: MiniBrowserEnvironment; normalizeLink(documentUri: URI, link: string): string { try { diff --git a/packages/preview/src/browser/preview-widget.ts b/packages/preview/src/browser/preview-widget.ts index 0edc8156a1735..b4d81a7378f6f 100644 --- a/packages/preview/src/browser/preview-widget.ts +++ b/packages/preview/src/browser/preview-widget.ts @@ -48,7 +48,7 @@ export class PreviewWidget extends BaseWidget implements Navigatable { protected firstUpdate: (() => void) | undefined = undefined; protected readonly onDidScrollEmitter = new Emitter(); protected readonly onDidDoubleClickEmitter = new Emitter(); - protected scrollBeyondLastLine: boolean; + protected scrollBeyondLastLine!: boolean; constructor( @inject(PreviewWidgetOptions) protected readonly options: PreviewWidgetOptions, @@ -114,7 +114,7 @@ export class PreviewWidget extends BaseWidget implements Navigatable { protected preventScrollNotification: boolean = false; protected startScrollSync(): Disposable { - return addEventListener(this.node, 'scroll', throttle((event: UIEvent) => { + return addEventListener(this.node, 'scroll', throttle(event => { if (this.preventScrollNotification) { return; } @@ -124,7 +124,7 @@ export class PreviewWidget extends BaseWidget implements Navigatable { } protected startDoubleClickListener(): Disposable { - return addEventListener(this.node, 'dblclick', (event: MouseEvent) => { + return addEventListener(this.node, 'dblclick', event => { if (!(event.target instanceof HTMLElement)) { return; } diff --git a/packages/property-view/src/browser/property-view-service.ts b/packages/property-view/src/browser/property-view-service.ts index 4fb208e796d56..a2d9fc75d8a72 100644 --- a/packages/property-view/src/browser/property-view-service.ts +++ b/packages/property-view/src/browser/property-view-service.ts @@ -26,10 +26,10 @@ import { PropertyViewWidgetProvider } from './property-view-widget-provider'; export class PropertyViewService { @inject(ContributionProvider) @named(PropertyViewWidgetProvider) - private readonly contributions: ContributionProvider; + private readonly contributions!: ContributionProvider; @inject(EmptyPropertyViewWidgetProvider) - private readonly emptyWidgetProvider: EmptyPropertyViewWidgetProvider; + private readonly emptyWidgetProvider!: EmptyPropertyViewWidgetProvider; private providers: PropertyViewWidgetProvider[] = []; diff --git a/packages/property-view/src/browser/property-view-widget-provider.ts b/packages/property-view/src/browser/property-view-widget-provider.ts index 411ef0bd43e9f..4149ef3d339cf 100644 --- a/packages/property-view/src/browser/property-view-widget-provider.ts +++ b/packages/property-view/src/browser/property-view-widget-provider.ts @@ -65,7 +65,7 @@ export interface PropertyViewWidgetProvider { export abstract class DefaultPropertyViewWidgetProvider implements PropertyViewWidgetProvider { @inject(ContributionProvider) @named(PropertyDataService) - protected readonly contributions: ContributionProvider; + protected readonly contributions!: ContributionProvider; protected propertyDataServices: PropertyDataService[] = []; diff --git a/packages/property-view/src/browser/property-view-widget.tsx b/packages/property-view/src/browser/property-view-widget.tsx index 9e2078bf30c86..1d47ae4ebd2a8 100644 --- a/packages/property-view/src/browser/property-view-widget.tsx +++ b/packages/property-view/src/browser/property-view-widget.tsx @@ -29,12 +29,12 @@ export class PropertyViewWidget extends BaseWidget { static readonly ID = 'property-view'; static readonly LABEL = nls.localize('theia/property-view/properties', 'Properties'); - protected contentWidget: PropertyViewContentWidget; + protected contentWidget?: PropertyViewContentWidget; protected toDisposeOnDetach = new DisposableCollection(); - @inject(PropertyViewService) protected readonly propertyViewService: PropertyViewService; - @inject(SelectionService) protected readonly selectionService: SelectionService; + @inject(PropertyViewService) protected readonly propertyViewService!: PropertyViewService; + @inject(SelectionService) protected readonly selectionService!: SelectionService; @postConstruct() init(): void { @@ -71,7 +71,7 @@ export class PropertyViewWidget extends BaseWidget { } protected replaceContentWidget(newContentWidget: PropertyViewContentWidget): void { - if (this.contentWidget.id !== newContentWidget.id) { + if (!this.contentWidget || this.contentWidget.id !== newContentWidget.id) { if (this.contentWidget) { Widget.detach(this.contentWidget); } diff --git a/packages/property-view/src/browser/resource-property-view/resource-property-data-service.ts b/packages/property-view/src/browser/resource-property-view/resource-property-data-service.ts index fd604c4e98ce8..806dd019a8767 100644 --- a/packages/property-view/src/browser/resource-property-view/resource-property-data-service.ts +++ b/packages/property-view/src/browser/resource-property-view/resource-property-data-service.ts @@ -28,7 +28,7 @@ export class ResourcePropertyDataService implements PropertyDataService { readonly id = 'resources'; readonly label = 'ResourcePropertyDataService'; - @inject(FileService) protected readonly fileService: FileService; + @inject(FileService) protected readonly fileService!: FileService; canHandleSelection(selection: Object | undefined): number { return (this.isFileSelection(selection) || this.isNavigatableSelection(selection)) ? 1 : 0; diff --git a/packages/property-view/src/browser/resource-property-view/resource-property-view-label-provider.ts b/packages/property-view/src/browser/resource-property-view/resource-property-view-label-provider.ts index 6781f6c41defc..237e88f0c059d 100644 --- a/packages/property-view/src/browser/resource-property-view/resource-property-view-label-provider.ts +++ b/packages/property-view/src/browser/resource-property-view/resource-property-view-label-provider.ts @@ -23,7 +23,7 @@ export const DEFAULT_INFO_ICON = codicon('info'); @injectable() export class ResourcePropertiesLabelProvider implements LabelProviderContribution { - @inject(LabelProvider) protected readonly labelProvider: LabelProvider; + @inject(LabelProvider) protected readonly labelProvider!: LabelProvider; canHandle(element: TreeNode): number { return (ResourcePropertiesCategoryNode.is(element) || ResourcePropertiesItemNode.is(element)) ? 75 : 0; diff --git a/packages/property-view/src/browser/resource-property-view/resource-property-view-tree-widget.tsx b/packages/property-view/src/browser/resource-property-view/resource-property-view-tree-widget.tsx index 6aa1774e71be4..6bbf10e7dd3aa 100644 --- a/packages/property-view/src/browser/resource-property-view/resource-property-view-tree-widget.tsx +++ b/packages/property-view/src/browser/resource-property-view/resource-property-view-tree-widget.tsx @@ -45,7 +45,7 @@ export class ResourcePropertyViewTreeWidget extends TreeWidget implements Proper protected propertiesTree: Map; protected currentSelection: Object | undefined; - @inject(LabelProvider) protected readonly labelProvider: LabelProvider; + @inject(LabelProvider) protected readonly labelProvider!: LabelProvider; constructor( @inject(TreeProps) readonly props: TreeProps, @@ -83,8 +83,8 @@ export class ResourcePropertyViewTreeWidget extends TreeWidget implements Proper if (this.updateNeeded(selection)) { this.currentSelection = selection; if (propertyDataService) { - propertyDataService.providePropertyData(selection).then((fileStatObject?: FileStat) => { - this.fillPropertiesTree(fileStatObject); + propertyDataService.providePropertyData(selection).then(fileStatObject => { + this.fillPropertiesTree(fileStatObject as FileStat | undefined); }); } } diff --git a/packages/property-view/src/browser/resource-property-view/resource-property-view-widget-provider.ts b/packages/property-view/src/browser/resource-property-view/resource-property-view-widget-provider.ts index 2ec74f978a8c7..29533c0e3de08 100644 --- a/packages/property-view/src/browser/resource-property-view/resource-property-view-widget-provider.ts +++ b/packages/property-view/src/browser/resource-property-view/resource-property-view-widget-provider.ts @@ -23,7 +23,7 @@ import { ResourcePropertyViewTreeWidget } from './resource-property-view-tree-wi @injectable() export class ResourcePropertyViewWidgetProvider extends DefaultPropertyViewWidgetProvider { - @inject(ResourcePropertyViewTreeWidget) protected treeWidget: ResourcePropertyViewTreeWidget; + @inject(ResourcePropertyViewTreeWidget) protected treeWidget!: ResourcePropertyViewTreeWidget; readonly id = 'resources'; readonly label = 'ResourcePropertyViewWidgetProvider'; diff --git a/packages/scm-extra/src/browser/history/scm-history-contribution.ts b/packages/scm-extra/src/browser/history/scm-history-contribution.ts index 4c4887f273f42..c97791e124d43 100644 --- a/packages/scm-extra/src/browser/history/scm-history-contribution.ts +++ b/packages/scm-extra/src/browser/history/scm-history-contribution.ts @@ -49,9 +49,9 @@ export interface ScmHistoryOpenViewArguments extends OpenViewArguments { export class ScmHistoryContribution extends AbstractViewContribution { @inject(SelectionService) - protected readonly selectionService: SelectionService; + protected readonly selectionService!: SelectionService; @inject(ScmService) - protected readonly scmService: ScmService; + protected readonly scmService!: ScmService; constructor() { super({ diff --git a/packages/scm-extra/src/browser/history/scm-history-widget.tsx b/packages/scm-extra/src/browser/history/scm-history-widget.tsx index 011597a45780c..b9d945de6ea2e 100644 --- a/packages/scm-extra/src/browser/history/scm-history-widget.tsx +++ b/packages/scm-extra/src/browser/history/scm-history-widget.tsx @@ -19,7 +19,7 @@ import { Event as TheiaEvent, DisposableCollection } from '@theia/core'; import { OpenerService, open, StatefulWidget, SELECTED_CLASS, WidgetManager, ApplicationShell, codicon } from '@theia/core/lib/browser'; import { CancellationTokenSource } from '@theia/core/lib/common/cancellation'; import { Message } from '@theia/core/shared/@phosphor/messaging'; -import { AutoSizer, List, ListRowRenderer, ListRowProps, InfiniteLoader, IndexRange, ScrollParams, CellMeasurerCache, CellMeasurer } from '@theia/core/shared/react-virtualized'; +import { AutoSizer, List, ListRowRenderer, ListRowProps, InfiniteLoader, IndexRange, CellMeasurerCache, CellMeasurer } from '@theia/core/shared/react-virtualized'; import URI from '@theia/core/lib/common/uri'; import { ScmService } from '@theia/scm/lib/browser/scm-service'; import { ScmHistoryProvider } from '.'; @@ -66,21 +66,23 @@ export type ScmHistoryListNode = (ScmCommitNode | ScmFileChangeNode); @injectable() export class ScmHistoryWidget extends ScmNavigableListWidget implements StatefulWidget { - protected options: HistoryWidgetOptions; - protected singleFileMode: boolean; + protected options: HistoryWidgetOptions = {}; + protected singleFileMode: boolean = false; private cancelIndicator: CancellationTokenSource; protected listView: ScmHistoryList | undefined; - protected hasMoreCommits: boolean; - protected allowScrollToSelected: boolean; + protected hasMoreCommits: boolean = false; + protected allowScrollToSelected: boolean = false; protected status: { - state: 'loading', + state: 'loading' } | { - state: 'ready', - commits: ScmCommitNode[]; + state: 'ready' + commits: ScmCommitNode[] } | { - state: 'error', + state: 'error' errorMessage: React.ReactNode + } = { + state: 'loading' }; protected readonly toDisposeOnRepositoryChange = new DisposableCollection(); @@ -200,8 +202,8 @@ export class ScmHistoryWidget extends ScmNavigableListWidget } } - protected resetState(options?: HistoryWidgetOptions): void { - this.options = options || {}; + protected resetState(options: HistoryWidgetOptions = {}): void { + this.options = options; this.status = { state: 'loading' }; this.scmNodes = []; this.hasMoreCommits = true; @@ -392,8 +394,8 @@ export class ScmHistoryWidget extends ScmNavigableListWidget return list; } - protected readonly handleScroll = (info: ScrollParams) => this.doHandleScroll(info); - protected doHandleScroll(info: ScrollParams): void { + protected readonly handleScroll = (info: { clientHeight: number; scrollHeight: number; scrollTop: number }) => this.doHandleScroll(info); + protected doHandleScroll(info: { clientHeight: number; scrollHeight: number; scrollTop: number }): void { this.node.scrollTop = info.scrollTop; } diff --git a/packages/scm-extra/src/browser/scm-file-change-label-provider.ts b/packages/scm-extra/src/browser/scm-file-change-label-provider.ts index 396035cfa104e..fe67dbc8ea6d1 100644 --- a/packages/scm-extra/src/browser/scm-file-change-label-provider.ts +++ b/packages/scm-extra/src/browser/scm-file-change-label-provider.ts @@ -24,10 +24,10 @@ import { ScmService } from '@theia/scm/lib/browser/scm-service'; export class ScmFileChangeLabelProvider implements LabelProviderContribution { @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(ScmService) - protected readonly scmService: ScmService; + protected readonly scmService!: ScmService; canHandle(element: object): number { return ScmFileChangeNode.is(element) ? 100 : 0; diff --git a/packages/scm-extra/src/browser/scm-navigable-list-widget.tsx b/packages/scm-extra/src/browser/scm-navigable-list-widget.tsx index bba4064a396f7..7c7e6f54543c0 100644 --- a/packages/scm-extra/src/browser/scm-navigable-list-widget.tsx +++ b/packages/scm-extra/src/browser/scm-navigable-list-widget.tsx @@ -29,13 +29,13 @@ import { ScmFileChangeNode } from './scm-file-change-node'; @injectable() export abstract class ScmNavigableListWidget extends ReactWidget { - protected scmNodes: T[]; - private _scrollContainer: string; + protected scmNodes: T[] = []; + private _scrollContainer?: string; - @inject(ScmService) protected readonly scmService: ScmService; - @inject(LabelProvider) protected readonly labelProvider: LabelProvider; + @inject(ScmService) protected readonly scmService!: ScmService; + @inject(LabelProvider) protected readonly labelProvider!: LabelProvider; @inject(ScmFileChangeLabelProvider) - protected readonly scmLabelProvider: ScmFileChangeLabelProvider; + protected readonly scmLabelProvider!: ScmFileChangeLabelProvider; constructor() { super(); @@ -53,6 +53,9 @@ export abstract class ScmNavigableListWidget e } protected get scrollContainer(): string { + if (!this._scrollContainer) { + throw new Error('ScmNavigableListWidget._scrollContainer is not set'); + } return this._scrollContainer; } @@ -123,7 +126,7 @@ export abstract class ScmNavigableListWidget e } protected getSelected(): T | undefined { - return this.scmNodes ? this.scmNodes.find(c => c.selected || false) : undefined; + return this.scmNodes.find(c => c.selected || false); } protected selectNode(node: T): void { @@ -152,7 +155,7 @@ export abstract class ScmNavigableListWidget e } protected get indexOfSelected(): number { - if (this.scmNodes && this.scmNodes.length > 0) { + if (this.scmNodes.length > 0) { return this.scmNodes.findIndex(c => c.selected || false); } return -1; diff --git a/packages/scm/src/browser/decorations/scm-navigator-decorator.ts b/packages/scm/src/browser/decorations/scm-navigator-decorator.ts index cbc68b88dcc05..ac619682b01f1 100644 --- a/packages/scm/src/browser/decorations/scm-navigator-decorator.ts +++ b/packages/scm/src/browser/decorations/scm-navigator-decorator.ts @@ -31,10 +31,10 @@ export class ScmNavigatorDecorator implements TreeDecorator { readonly id = 'theia-scm-decorator'; private decorationsMap: Map | undefined; - @inject(ILogger) protected readonly logger: ILogger; + @inject(ILogger) protected readonly logger!: ILogger; @inject(ColorRegistry) - protected readonly colors: ColorRegistry; + protected readonly colors!: ColorRegistry; constructor(@inject(DecorationsService) protected readonly decorationsService: DecorationsService) { this.decorationsService.onDidChangeDecorations(data => { diff --git a/packages/scm/src/browser/decorations/scm-tab-bar-decorator.ts b/packages/scm/src/browser/decorations/scm-tab-bar-decorator.ts index e098566ba8832..e3fbdb341a042 100644 --- a/packages/scm/src/browser/decorations/scm-tab-bar-decorator.ts +++ b/packages/scm/src/browser/decorations/scm-tab-bar-decorator.ts @@ -33,7 +33,7 @@ export class ScmTabBarDecorator implements TabBarDecorator { private readonly toDisposeOnDidChange = new DisposableCollection(); @inject(ScmService) - protected readonly scmService: ScmService; + protected readonly scmService!: ScmService; @postConstruct() protected init(): void { diff --git a/packages/scm/src/browser/scm-amend-widget.tsx b/packages/scm/src/browser/scm-amend-widget.tsx index fd777cc304479..39ebba8b92f68 100644 --- a/packages/scm/src/browser/scm-amend-widget.tsx +++ b/packages/scm/src/browser/scm-amend-widget.tsx @@ -29,12 +29,12 @@ export class ScmAmendWidget extends ReactWidget { static ID = 'scm-amend-widget'; - @inject(ScmService) protected readonly scmService: ScmService; - @inject(ScmAvatarService) protected readonly avatarService: ScmAvatarService; - @inject(StorageService) protected readonly storageService: StorageService; - @inject(SelectionService) protected readonly selectionService: SelectionService; - @inject(LabelProvider) protected readonly labelProvider: LabelProvider; - @inject(KeybindingRegistry) protected readonly keybindings: KeybindingRegistry; + @inject(ScmService) protected readonly scmService!: ScmService; + @inject(ScmAvatarService) protected readonly avatarService!: ScmAvatarService; + @inject(StorageService) protected readonly storageService!: StorageService; + @inject(SelectionService) protected readonly selectionService!: SelectionService; + @inject(LabelProvider) protected readonly labelProvider!: LabelProvider; + @inject(KeybindingRegistry) protected readonly keybindings!: KeybindingRegistry; protected shouldScrollToRow = true; diff --git a/packages/scm/src/browser/scm-commit-widget.tsx b/packages/scm/src/browser/scm-commit-widget.tsx index 9938419622c65..707012813d5fe 100644 --- a/packages/scm/src/browser/scm-commit-widget.tsx +++ b/packages/scm/src/browser/scm-commit-widget.tsx @@ -30,8 +30,8 @@ export class ScmCommitWidget extends ReactWidget implements StatefulWidget { static ID = 'scm-commit-widget'; - @inject(ScmService) protected readonly scmService: ScmService; - @inject(KeybindingRegistry) protected readonly keybindings: KeybindingRegistry; + @inject(ScmService) protected readonly scmService!: ScmService; + @inject(KeybindingRegistry) protected readonly keybindings!: KeybindingRegistry; protected readonly toDisposeOnRepositoryChange = new DisposableCollection(); diff --git a/packages/scm/src/browser/scm-context-key-service.ts b/packages/scm/src/browser/scm-context-key-service.ts index d645365d0f428..b7a3059d089cd 100644 --- a/packages/scm/src/browser/scm-context-key-service.ts +++ b/packages/scm/src/browser/scm-context-key-service.ts @@ -21,14 +21,14 @@ import { ContextKeyService, ContextKey } from '@theia/core/lib/browser/context-k export class ScmContextKeyService { @inject(ContextKeyService) - protected readonly contextKeyService: ContextKeyService; + protected readonly contextKeyService!: ContextKeyService; - protected _scmProvider: ContextKey; + protected _scmProvider!: ContextKey; get scmProvider(): ContextKey { return this._scmProvider; } - protected _scmResourceGroup: ContextKey; + protected _scmResourceGroup!: ContextKey; get scmResourceGroup(): ContextKey { return this._scmResourceGroup; } diff --git a/packages/scm/src/browser/scm-contribution.ts b/packages/scm/src/browser/scm-contribution.ts index f9b19ace25d05..7a8f237281f29 100644 --- a/packages/scm/src/browser/scm-contribution.ts +++ b/packages/scm/src/browser/scm-contribution.ts @@ -88,16 +88,16 @@ export namespace ScmColors { @injectable() export class ScmContribution extends AbstractViewContribution implements FrontendApplicationContribution, TabBarToolbarContribution, ColorContribution { - @inject(StatusBar) protected readonly statusBar: StatusBar; - @inject(ScmService) protected readonly scmService: ScmService; - @inject(ScmQuickOpenService) protected readonly scmQuickOpenService: ScmQuickOpenService; - @inject(LabelProvider) protected readonly labelProvider: LabelProvider; - @inject(CommandService) protected readonly commands: CommandService; - @inject(CommandRegistry) protected readonly commandRegistry: CommandRegistry; - @inject(ContextKeyService) protected readonly contextKeys: ContextKeyService; - @inject(ScmDecorationsService) protected readonly scmDecorationsService: ScmDecorationsService; + @inject(StatusBar) protected readonly statusBar!: StatusBar; + @inject(ScmService) protected readonly scmService!: ScmService; + @inject(ScmQuickOpenService) protected readonly scmQuickOpenService!: ScmQuickOpenService; + @inject(LabelProvider) protected readonly labelProvider!: LabelProvider; + @inject(CommandService) protected readonly commands!: CommandService; + @inject(CommandRegistry) protected readonly commandRegistry!: CommandRegistry; + @inject(ContextKeyService) protected readonly contextKeys!: ContextKeyService; + @inject(ScmDecorationsService) protected readonly scmDecorationsService!: ScmDecorationsService; - protected scmFocus: ContextKey; + protected scmFocus!: ContextKey; constructor() { super({ diff --git a/packages/scm/src/browser/scm-groups-tree-model.ts b/packages/scm/src/browser/scm-groups-tree-model.ts index 34189f40a9b30..59287c8731db4 100644 --- a/packages/scm/src/browser/scm-groups-tree-model.ts +++ b/packages/scm/src/browser/scm-groups-tree-model.ts @@ -23,7 +23,7 @@ import { ScmResourceGroup, ScmProvider } from './scm-provider'; @injectable() export class ScmGroupsTreeModel extends ScmTreeModel { - @inject(ScmService) protected readonly scmService: ScmService; + @inject(ScmService) protected readonly scmService!: ScmService; protected readonly toDisposeOnRepositoryChange = new DisposableCollection(); diff --git a/packages/scm/src/browser/scm-quick-open-service.ts b/packages/scm/src/browser/scm-quick-open-service.ts index 98f7bcf89e256..2f75f6f2c7c1c 100644 --- a/packages/scm/src/browser/scm-quick-open-service.ts +++ b/packages/scm/src/browser/scm-quick-open-service.ts @@ -24,10 +24,10 @@ import { QuickInputService } from '@theia/core/lib/browser'; @injectable() export class ScmQuickOpenService { - @inject(QuickInputService) @optional() protected readonly quickInputService: QuickInputService; - @inject(MessageService) protected readonly messageService: MessageService; - @inject(LabelProvider) protected readonly labelProvider: LabelProvider; - @inject(ScmService) protected readonly scmService: ScmService; + @inject(QuickInputService) @optional() protected readonly quickInputService?: QuickInputService; + @inject(MessageService) protected readonly messageService!: MessageService; + @inject(LabelProvider) protected readonly labelProvider!: LabelProvider; + @inject(ScmService) protected readonly scmService!: ScmService; async changeRepository(): Promise { const repositories = this.scmService.repositories; diff --git a/packages/scm/src/browser/scm-service.ts b/packages/scm/src/browser/scm-service.ts index 8ea9b7d71da16..e9a00f4ace2bc 100644 --- a/packages/scm/src/browser/scm-service.ts +++ b/packages/scm/src/browser/scm-service.ts @@ -27,7 +27,7 @@ import URI from '@theia/core/lib/common/uri'; export class ScmService { @inject(ScmContextKeyService) - protected readonly contextKeys: ScmContextKeyService; + protected readonly contextKeys!: ScmContextKeyService; protected readonly _repositories = new Map(); protected _selectedRepository: ScmRepository | undefined; diff --git a/packages/scm/src/browser/scm-tree-label-provider.ts b/packages/scm/src/browser/scm-tree-label-provider.ts index 2cd60742088b3..b0f319c58d63d 100644 --- a/packages/scm/src/browser/scm-tree-label-provider.ts +++ b/packages/scm/src/browser/scm-tree-label-provider.ts @@ -23,7 +23,7 @@ import { ScmFileChangeFolderNode, ScmFileChangeNode, ScmFileChangeGroupNode } fr @injectable() export class ScmTreeLabelProvider implements LabelProviderContribution { - @inject(LabelProvider) protected readonly labelProvider: LabelProvider; + @inject(LabelProvider) protected readonly labelProvider!: LabelProvider; canHandle(element: object): number { return TreeNode.is(element) && (ScmFileChangeGroupNode.is(element) || ScmFileChangeFolderNode.is(element) || ScmFileChangeNode.is(element)) ? 60 : 0; diff --git a/packages/scm/src/browser/scm-tree-model.ts b/packages/scm/src/browser/scm-tree-model.ts index bddf6c08517a1..1a55b4a46179f 100644 --- a/packages/scm/src/browser/scm-tree-model.ts +++ b/packages/scm/src/browser/scm-tree-model.ts @@ -84,9 +84,9 @@ export abstract class ScmTreeModel extends TreeModelImpl { protected provider: ScmProvider | undefined; - @inject(TreeProps) protected readonly props: ScmTreeModelProps; + @inject(TreeProps) protected readonly props!: ScmTreeModelProps; - @inject(ScmContextKeyService) protected readonly contextKeys: ScmContextKeyService; + @inject(ScmContextKeyService) protected readonly contextKeys!: ScmContextKeyService; get languageId(): string | undefined { return this._languageId; diff --git a/packages/scm/src/browser/scm-tree-widget.tsx b/packages/scm/src/browser/scm-tree-widget.tsx index 179cb0290c2c3..4f8ed25ce6c9b 100644 --- a/packages/scm/src/browser/scm-tree-widget.tsx +++ b/packages/scm/src/browser/scm-tree-widget.tsx @@ -48,15 +48,15 @@ export class ScmTreeWidget extends TreeWidget { static RESOURCE_INLINE_MENU = ['RESOURCE_INLINE_MENU']; static RESOURCE_CONTEXT_MENU = ['RESOURCE_CONTEXT_MENU']; - @inject(MenuModelRegistry) protected readonly menus: MenuModelRegistry; - @inject(CommandRegistry) protected readonly commands: CommandRegistry; - @inject(CorePreferences) protected readonly corePreferences: CorePreferences; - @inject(ScmContextKeyService) protected readonly contextKeys: ScmContextKeyService; - @inject(EditorManager) protected readonly editorManager: EditorManager; - @inject(DiffNavigatorProvider) protected readonly diffNavigatorProvider: DiffNavigatorProvider; - @inject(IconThemeService) protected readonly iconThemeService: IconThemeService; - @inject(DecorationsService) protected readonly decorationsService: DecorationsService; - @inject(ColorRegistry) protected readonly colors: ColorRegistry; + @inject(MenuModelRegistry) protected readonly menus!: MenuModelRegistry; + @inject(CommandRegistry) protected readonly commands!: CommandRegistry; + @inject(CorePreferences) protected readonly corePreferences!: CorePreferences; + @inject(ScmContextKeyService) protected readonly contextKeys!: ScmContextKeyService; + @inject(EditorManager) protected readonly editorManager!: EditorManager; + @inject(DiffNavigatorProvider) protected readonly diffNavigatorProvider!: DiffNavigatorProvider; + @inject(IconThemeService) protected readonly iconThemeService!: IconThemeService; + @inject(DecorationsService) protected readonly decorationsService!: DecorationsService; + @inject(ColorRegistry) protected readonly colors!: ColorRegistry; model: ScmTreeModel; diff --git a/packages/scm/src/browser/scm-widget.tsx b/packages/scm/src/browser/scm-widget.tsx index e0a30cbd55ef9..5a9985986d78c 100644 --- a/packages/scm/src/browser/scm-widget.tsx +++ b/packages/scm/src/browser/scm-widget.tsx @@ -33,16 +33,16 @@ import { nls } from '@theia/core/lib/common/nls'; @injectable() export class ScmWidget extends BaseWidget implements StatefulWidget { - protected panel: Panel; + protected panel!: Panel; static ID = 'scm-view'; - @inject(ScmService) protected readonly scmService: ScmService; - @inject(ScmCommitWidget) protected readonly commitWidget: ScmCommitWidget; - @inject(ScmTreeWidget) readonly resourceWidget: ScmTreeWidget; - @inject(ScmAmendWidget) protected readonly amendWidget: ScmAmendWidget; - @inject(ScmNoRepositoryWidget) readonly noRepositoryWidget: ScmNoRepositoryWidget; - @inject(ScmPreferences) protected readonly scmPreferences: ScmPreferences; + @inject(ScmService) protected readonly scmService!: ScmService; + @inject(ScmCommitWidget) protected readonly commitWidget!: ScmCommitWidget; + @inject(ScmTreeWidget) readonly resourceWidget!: ScmTreeWidget; + @inject(ScmAmendWidget) protected readonly amendWidget!: ScmAmendWidget; + @inject(ScmNoRepositoryWidget) readonly noRepositoryWidget!: ScmNoRepositoryWidget; + @inject(ScmPreferences) protected readonly scmPreferences!: ScmPreferences; set viewMode(mode: 'tree' | 'list') { this.resourceWidget.viewMode = mode; diff --git a/packages/search-in-workspace/src/browser/search-in-workspace-context-key-service.ts b/packages/search-in-workspace/src/browser/search-in-workspace-context-key-service.ts index 30f2d36637587..78aa0850c5c1f 100644 --- a/packages/search-in-workspace/src/browser/search-in-workspace-context-key-service.ts +++ b/packages/search-in-workspace/src/browser/search-in-workspace-context-key-service.ts @@ -21,43 +21,43 @@ import { ContextKeyService, ContextKey } from '@theia/core/lib/browser/context-k export class SearchInWorkspaceContextKeyService { @inject(ContextKeyService) - protected readonly contextKeyService: ContextKeyService; + protected readonly contextKeyService!: ContextKeyService; - protected _searchViewletVisible: ContextKey; + protected _searchViewletVisible!: ContextKey; get searchViewletVisible(): ContextKey { return this._searchViewletVisible; } - protected _searchViewletFocus: ContextKey; + protected _searchViewletFocus!: ContextKey; get searchViewletFocus(): ContextKey { return this._searchViewletFocus; } - protected searchInputBoxFocus: ContextKey; + protected searchInputBoxFocus!: ContextKey; setSearchInputBoxFocus(searchInputBoxFocus: boolean): void { this.searchInputBoxFocus.set(searchInputBoxFocus); this.updateInputBoxFocus(); } - protected replaceInputBoxFocus: ContextKey; + protected replaceInputBoxFocus!: ContextKey; setReplaceInputBoxFocus(replaceInputBoxFocus: boolean): void { this.replaceInputBoxFocus.set(replaceInputBoxFocus); this.updateInputBoxFocus(); } - protected patternIncludesInputBoxFocus: ContextKey; + protected patternIncludesInputBoxFocus!: ContextKey; setPatternIncludesInputBoxFocus(patternIncludesInputBoxFocus: boolean): void { this.patternIncludesInputBoxFocus.set(patternIncludesInputBoxFocus); this.updateInputBoxFocus(); } - protected patternExcludesInputBoxFocus: ContextKey; + protected patternExcludesInputBoxFocus!: ContextKey; setPatternExcludesInputBoxFocus(patternExcludesInputBoxFocus: boolean): void { this.patternExcludesInputBoxFocus.set(patternExcludesInputBoxFocus); this.updateInputBoxFocus(); } - protected inputBoxFocus: ContextKey; + protected inputBoxFocus!: ContextKey; protected updateInputBoxFocus(): void { this.inputBoxFocus.set( this.searchInputBoxFocus.get() || @@ -67,12 +67,12 @@ export class SearchInWorkspaceContextKeyService { ); } - protected _replaceActive: ContextKey; + protected _replaceActive!: ContextKey; get replaceActive(): ContextKey { return this._replaceActive; } - protected _hasSearchResult: ContextKey; + protected _hasSearchResult!: ContextKey; get hasSearchResult(): ContextKey { return this._hasSearchResult; } diff --git a/packages/search-in-workspace/src/browser/search-in-workspace-factory.ts b/packages/search-in-workspace/src/browser/search-in-workspace-factory.ts index cb15895a45be1..63087b608a604 100644 --- a/packages/search-in-workspace/src/browser/search-in-workspace-factory.ts +++ b/packages/search-in-workspace/src/browser/search-in-workspace-factory.ts @@ -42,8 +42,8 @@ export class SearchInWorkspaceFactory implements WidgetFactory { }; @inject(ViewContainer.Factory) - protected readonly viewContainerFactory: ViewContainer.Factory; - @inject(WidgetManager) protected readonly widgetManager: WidgetManager; + protected readonly viewContainerFactory!: ViewContainer.Factory; + @inject(WidgetManager) protected readonly widgetManager!: WidgetManager; async createWidget(): Promise { const viewContainer = this.viewContainerFactory({ diff --git a/packages/search-in-workspace/src/browser/search-in-workspace-frontend-contribution.ts b/packages/search-in-workspace/src/browser/search-in-workspace-frontend-contribution.ts index ac7ba2a8100c6..24d1009424e52 100644 --- a/packages/search-in-workspace/src/browser/search-in-workspace-frontend-contribution.ts +++ b/packages/search-in-workspace/src/browser/search-in-workspace-frontend-contribution.ts @@ -85,14 +85,14 @@ export namespace SearchInWorkspaceCommands { @injectable() export class SearchInWorkspaceFrontendContribution extends AbstractViewContribution implements FrontendApplicationContribution, TabBarToolbarContribution { - @inject(SelectionService) protected readonly selectionService: SelectionService; - @inject(LabelProvider) protected readonly labelProvider: LabelProvider; - @inject(WorkspaceService) protected readonly workspaceService: WorkspaceService; - @inject(FileService) protected readonly fileService: FileService; - @inject(EditorManager) protected readonly editorManager: EditorManager; + @inject(SelectionService) protected readonly selectionService!: SelectionService; + @inject(LabelProvider) protected readonly labelProvider!: LabelProvider; + @inject(WorkspaceService) protected readonly workspaceService!: WorkspaceService; + @inject(FileService) protected readonly fileService!: FileService; + @inject(EditorManager) protected readonly editorManager!: EditorManager; @inject(SearchInWorkspaceContextKeyService) - protected readonly contextKeyService: SearchInWorkspaceContextKeyService; + protected readonly contextKeyService!: SearchInWorkspaceContextKeyService; constructor() { super({ diff --git a/packages/search-in-workspace/src/browser/search-in-workspace-label-provider.ts b/packages/search-in-workspace/src/browser/search-in-workspace-label-provider.ts index 09dd3acb56f1c..b033621297b10 100644 --- a/packages/search-in-workspace/src/browser/search-in-workspace-label-provider.ts +++ b/packages/search-in-workspace/src/browser/search-in-workspace-label-provider.ts @@ -23,7 +23,7 @@ import URI from '@theia/core/lib/common/uri'; export class SearchInWorkspaceLabelProvider implements LabelProviderContribution { @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; canHandle(element: object): number { return SearchInWorkspaceRootFolderNode.is(element) || SearchInWorkspaceFileNode.is(element) ? 100 : 0; diff --git a/packages/search-in-workspace/src/browser/search-in-workspace-result-tree-widget.tsx b/packages/search-in-workspace/src/browser/search-in-workspace-result-tree-widget.tsx index dd60f943de4c3..75f778c6634d8 100644 --- a/packages/search-in-workspace/src/browser/search-in-workspace-result-tree-widget.tsx +++ b/packages/search-in-workspace/src/browser/search-in-workspace-result-tree-widget.tsx @@ -111,7 +111,7 @@ export class SearchInWorkspaceResultTreeWidget extends TreeWidget { protected _showReplaceButtons = false; protected _replaceTerm = ''; protected searchTerm = ''; - protected searchOptions: SearchInWorkspaceOptions; + protected searchOptions: SearchInWorkspaceOptions = {}; protected readonly startSearchOnModification = (activeEditor: EditorWidget) => debounce( () => this.searchActiveEditor(activeEditor, this.searchTerm, this.searchOptions), @@ -137,17 +137,17 @@ export class SearchInWorkspaceResultTreeWidget extends TreeWidget { // eslint-disable-next-line @typescript-eslint/no-explicit-any protected focusInputEmitter = new Emitter(); - @inject(SearchInWorkspaceService) protected readonly searchService: SearchInWorkspaceService; - @inject(EditorManager) protected readonly editorManager: EditorManager; - @inject(FileResourceResolver) protected readonly fileResourceResolver: FileResourceResolver; - @inject(ApplicationShell) protected readonly shell: ApplicationShell; - @inject(WorkspaceService) protected readonly workspaceService: WorkspaceService; - @inject(TreeExpansionService) protected readonly expansionService: TreeExpansionService; - @inject(SearchInWorkspacePreferences) protected readonly searchInWorkspacePreferences: SearchInWorkspacePreferences; - @inject(ProgressService) protected readonly progressService: ProgressService; - @inject(ColorRegistry) protected readonly colorRegistry: ColorRegistry; - @inject(FileSystemPreferences) protected readonly filesystemPreferences: FileSystemPreferences; - @inject(FileService) protected readonly fileService: FileService; + @inject(SearchInWorkspaceService) protected readonly searchService!: SearchInWorkspaceService; + @inject(EditorManager) protected readonly editorManager!: EditorManager; + @inject(FileResourceResolver) protected readonly fileResourceResolver!: FileResourceResolver; + @inject(ApplicationShell) protected readonly shell!: ApplicationShell; + @inject(WorkspaceService) protected readonly workspaceService!: WorkspaceService; + @inject(TreeExpansionService) protected readonly expansionService!: TreeExpansionService; + @inject(SearchInWorkspacePreferences) protected readonly searchInWorkspacePreferences!: SearchInWorkspacePreferences; + @inject(ProgressService) protected readonly progressService!: ProgressService; + @inject(ColorRegistry) protected readonly colorRegistry!: ColorRegistry; + @inject(FileSystemPreferences) protected readonly filesystemPreferences!: FileSystemPreferences; + @inject(FileService) protected readonly fileService!: FileService; constructor( @inject(TreeProps) readonly props: TreeProps, diff --git a/packages/search-in-workspace/src/browser/search-in-workspace-service.ts b/packages/search-in-workspace/src/browser/search-in-workspace-service.ts index 60eb9b2bda010..d2150772257e8 100644 --- a/packages/search-in-workspace/src/browser/search-in-workspace-service.ts +++ b/packages/search-in-workspace/src/browser/search-in-workspace-service.ts @@ -32,17 +32,25 @@ import { ILogger } from '@theia/core'; @injectable() export class SearchInWorkspaceClientImpl implements SearchInWorkspaceClient { - private service: SearchInWorkspaceClient; + private _service?: SearchInWorkspaceClient; + + private get service(): SearchInWorkspaceClient { + if (!this._service) { + throw new Error('SearchInWorkspaceClientImpl._service is not set'); + } + return this._service; + } onResult(searchId: number, result: SearchInWorkspaceResult): void { this.service.onResult(searchId, result); } + onDone(searchId: number, error?: string): void { this.service.onDone(searchId, error); } setService(service: SearchInWorkspaceClient): void { - this.service = service; + this._service = service; } } @@ -68,10 +76,10 @@ export class SearchInWorkspaceService implements SearchInWorkspaceClient { private lastKnownSearchId: number = -1; - @inject(SearchInWorkspaceServer) protected readonly searchServer: SearchInWorkspaceServer; - @inject(SearchInWorkspaceClientImpl) protected readonly client: SearchInWorkspaceClientImpl; - @inject(WorkspaceService) protected readonly workspaceService: WorkspaceService; - @inject(ILogger) protected readonly logger: ILogger; + @inject(SearchInWorkspaceServer) protected readonly searchServer!: SearchInWorkspaceServer; + @inject(SearchInWorkspaceClientImpl) protected readonly client!: SearchInWorkspaceClientImpl; + @inject(WorkspaceService) protected readonly workspaceService!: WorkspaceService; + @inject(ILogger) protected readonly logger!: ILogger; @postConstruct() protected init(): void { diff --git a/packages/search-in-workspace/src/browser/search-in-workspace-widget.tsx b/packages/search-in-workspace/src/browser/search-in-workspace-widget.tsx index 8979a935079a7..58c6bc07d3c4f 100644 --- a/packages/search-in-workspace/src/browser/search-in-workspace-widget.tsx +++ b/packages/search-in-workspace/src/browser/search-in-workspace-widget.tsx @@ -42,10 +42,10 @@ export class SearchInWorkspaceWidget extends BaseWidget implements StatefulWidge static ID = 'search-in-workspace'; static LABEL = nls.localizeByDefault('Search'); - protected matchCaseState: SearchFieldState; - protected wholeWordState: SearchFieldState; - protected regExpState: SearchFieldState; - protected includeIgnoredState: SearchFieldState; + protected matchCaseState!: SearchFieldState; + protected wholeWordState!: SearchFieldState; + protected regExpState!: SearchFieldState; + protected includeIgnoredState!: SearchFieldState; protected showSearchDetails = false; protected _hasResults = false; @@ -60,7 +60,7 @@ export class SearchInWorkspaceWidget extends BaseWidget implements StatefulWidge protected searchFieldContainerIsFocused = false; - protected searchInWorkspaceOptions: SearchInWorkspaceOptions; + protected searchInWorkspaceOptions!: SearchInWorkspaceOptions; protected searchTerm = ''; protected replaceTerm = ''; @@ -79,26 +79,25 @@ export class SearchInWorkspaceWidget extends BaseWidget implements StatefulWidge this._showReplaceField = showReplaceField; } - protected contentNode: HTMLElement; - protected searchFormContainer: HTMLElement; - protected resultContainer: HTMLElement; + protected contentNode!: HTMLElement; + protected searchFormContainer!: HTMLElement; protected readonly onDidUpdateEmitter = new Emitter(); readonly onDidUpdate: Event = this.onDidUpdateEmitter.event; - @inject(SearchInWorkspaceResultTreeWidget) protected readonly resultTreeWidget: SearchInWorkspaceResultTreeWidget; - @inject(WorkspaceService) protected readonly workspaceService: WorkspaceService; + @inject(SearchInWorkspaceResultTreeWidget) protected readonly resultTreeWidget!: SearchInWorkspaceResultTreeWidget; + @inject(WorkspaceService) protected readonly workspaceService!: WorkspaceService; @inject(SearchInWorkspaceContextKeyService) - protected readonly contextKeyService: SearchInWorkspaceContextKeyService; + protected readonly contextKeyService!: SearchInWorkspaceContextKeyService; @inject(ProgressBarFactory) - protected readonly progressBarFactory: ProgressBarFactory; + protected readonly progressBarFactory!: ProgressBarFactory; - @inject(EditorManager) protected readonly editorManager: EditorManager; + @inject(EditorManager) protected readonly editorManager!: EditorManager; @inject(SearchInWorkspacePreferences) - protected readonly searchInWorkspacePreferences: SearchInWorkspacePreferences; + protected readonly searchInWorkspacePreferences!: SearchInWorkspacePreferences; @postConstruct() protected init(): void { @@ -419,7 +418,7 @@ export class SearchInWorkspaceWidget extends BaseWidget implements StatefulWidge this.doBlurSearchFieldContainer(); } - private _searchTimeout: number; + private _searchTimeout?: number; protected readonly search = (e: React.KeyboardEvent) => { e.persist(); const searchOnType = this.searchInWorkspacePreferences['search.searchOnType']; diff --git a/packages/search-in-workspace/src/node/ripgrep-search-in-workspace-server.ts b/packages/search-in-workspace/src/node/ripgrep-search-in-workspace-server.ts index fb36901213f32..cc84de7a4e2be 100644 --- a/packages/search-in-workspace/src/node/ripgrep-search-in-workspace-server.ts +++ b/packages/search-in-workspace/src/node/ripgrep-search-in-workspace-server.ts @@ -84,7 +84,7 @@ export class RipgrepSearchInWorkspaceServer implements SearchInWorkspaceServer { private client: SearchInWorkspaceClient | undefined; @inject(RgPath) - protected readonly rgPath: string; + protected readonly rgPath!: string; constructor( @inject(ILogger) protected readonly logger: ILogger, diff --git a/packages/task/src/browser/process/process-task-contribution.ts b/packages/task/src/browser/process/process-task-contribution.ts index 71dd591215700..d24d6a7c46e75 100644 --- a/packages/task/src/browser/process/process-task-contribution.ts +++ b/packages/task/src/browser/process/process-task-contribution.ts @@ -22,7 +22,7 @@ import { TaskContribution, TaskResolverRegistry } from '../task-contribution'; export class ProcessTaskContribution implements TaskContribution { @inject(ProcessTaskResolver) - protected readonly processTaskResolver: ProcessTaskResolver; + protected readonly processTaskResolver!: ProcessTaskResolver; registerResolvers(resolvers: TaskResolverRegistry): void { resolvers.registerExecutionResolver('process', this.processTaskResolver); diff --git a/packages/task/src/browser/process/process-task-resolver.ts b/packages/task/src/browser/process/process-task-resolver.ts index 1be9e053bb232..7fe57b1daf23e 100644 --- a/packages/task/src/browser/process/process-task-resolver.ts +++ b/packages/task/src/browser/process/process-task-resolver.ts @@ -27,13 +27,13 @@ import { WorkspaceService } from '@theia/workspace/lib/browser'; export class ProcessTaskResolver implements TaskResolver { @inject(VariableResolverService) - protected readonly variableResolverService: VariableResolverService; + protected readonly variableResolverService!: VariableResolverService; @inject(TaskDefinitionRegistry) - protected readonly taskDefinitionRegistry: TaskDefinitionRegistry; + protected readonly taskDefinitionRegistry!: TaskDefinitionRegistry; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; /** * Perform some adjustments to the task launch configuration, before sending diff --git a/packages/task/src/browser/provided-task-configurations.ts b/packages/task/src/browser/provided-task-configurations.ts index 87db0bc09faf3..a2af8ac3910d4 100644 --- a/packages/task/src/browser/provided-task-configurations.ts +++ b/packages/task/src/browser/provided-task-configurations.ts @@ -29,10 +29,10 @@ export class ProvidedTaskConfigurations { protected tasksMap = new Map>>(); @inject(TaskProviderRegistry) - protected readonly taskProviderRegistry: TaskProviderRegistry; + protected readonly taskProviderRegistry!: TaskProviderRegistry; @inject(TaskDefinitionRegistry) - protected readonly taskDefinitionRegistry: TaskDefinitionRegistry; + protected readonly taskDefinitionRegistry!: TaskDefinitionRegistry; private currentToken: number = 0; private nextToken = 1; diff --git a/packages/task/src/browser/quick-open-task.ts b/packages/task/src/browser/quick-open-task.ts index 6fcbd838a9f68..a2abd4637e5ce 100644 --- a/packages/task/src/browser/quick-open-task.ts +++ b/packages/task/src/browser/quick-open-task.ts @@ -40,34 +40,34 @@ export class QuickOpenTask implements QuickAccessProvider { protected items: Array = []; @inject(TaskService) - protected readonly taskService: TaskService; + protected readonly taskService!: TaskService; @inject(QuickInputService) @optional() - protected readonly quickInputService: QuickInputService; + protected readonly quickInputService?: QuickInputService; @inject(QuickAccessRegistry) - protected readonly quickAccessRegistry: QuickAccessRegistry; + protected readonly quickAccessRegistry!: QuickAccessRegistry; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @inject(TaskDefinitionRegistry) - protected readonly taskDefinitionRegistry: TaskDefinitionRegistry; + protected readonly taskDefinitionRegistry!: TaskDefinitionRegistry; @inject(TaskNameResolver) - protected readonly taskNameResolver: TaskNameResolver; + protected readonly taskNameResolver!: TaskNameResolver; @inject(TaskSourceResolver) - protected readonly taskSourceResolver: TaskSourceResolver; + protected readonly taskSourceResolver!: TaskSourceResolver; @inject(TaskConfigurationManager) - protected readonly taskConfigurationManager: TaskConfigurationManager; + protected readonly taskConfigurationManager!: TaskConfigurationManager; @inject(PreferenceService) - protected readonly preferences: PreferenceService; + protected readonly preferences!: PreferenceService; @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; init(): Promise { return this.doInit(this.taskService.startUserAction()); @@ -95,6 +95,9 @@ export class QuickOpenTask implements QuickAccessProvider { protected onDidTriggerGearIcon(item: QuickPickItem): void { if (item instanceof TaskRunQuickOpenItem) { + if (!this.quickInputService) { + throw new Error('QuickOpenTask.quickInputService is not set'); + } this.taskService.configure(item.token, item.task); this.quickInputService.hide(); } @@ -163,18 +166,14 @@ export class QuickOpenTask implements QuickAccessProvider { if (groupedTasks.has(TaskScope.Global.toString())) { const configs = groupedTasks.get(TaskScope.Global.toString())!; this.items.push( - ...configs.map(taskConfig => { - const item = new TaskConfigureQuickOpenItem( - token, - taskConfig, - this.taskService, - this.taskNameResolver, - this.workspaceService, - isMulti - ); - item['taskDefinitionRegistry'] = this.taskDefinitionRegistry; - return item; - }) + ...configs.map(taskConfig => new TaskConfigureQuickOpenItem( + token, + taskConfig, + this.taskService, + this.taskNameResolver, + this.workspaceService, + isMulti + )) ); } @@ -184,19 +183,14 @@ export class QuickOpenTask implements QuickAccessProvider { if (groupedTasks.has(rootFolder)) { const configs = groupedTasks.get(rootFolder.toString())!; this.items.push( - ...configs.map((taskConfig, index) => { - const item = new TaskConfigureQuickOpenItem( - token, - taskConfig, - this.taskService, - this.taskNameResolver, - this.workspaceService, - isMulti, - - ); - item['taskDefinitionRegistry'] = this.taskDefinitionRegistry; - return item; - }) + ...configs.map(taskConfig => new TaskConfigureQuickOpenItem( + token, + taskConfig, + this.taskService, + this.taskNameResolver, + this.workspaceService, + isMulti, + )) ); } else { const { configUri } = this.preferences.resolve('tasks', [], rootFolder); @@ -238,11 +232,11 @@ export class QuickOpenTask implements QuickAccessProvider { const taskItems = this.getTaskItems(); if (taskItems.length > 0) { // the item in `this.items` is not 'No tasks found' - const buildOrTestTasks = taskItems.filter((t: TaskRunQuickOpenItem) => + const buildOrTestTasks = (taskItems as TaskRunQuickOpenItem[]).filter(t => shouldRunBuildTask ? TaskCustomization.isBuildTask(t.task) : TaskCustomization.isTestTask(t.task) ); if (buildOrTestTasks.length > 0) { // build / test tasks are defined in the workspace - const defaultBuildOrTestTasks = buildOrTestTasks.filter((t: TaskRunQuickOpenItem) => + const defaultBuildOrTestTasks = buildOrTestTasks.filter(t => shouldRunBuildTask ? TaskCustomization.isDefaultBuildTask(t.task) : TaskCustomization.isDefaultTestTask(t.task) ); if (defaultBuildOrTestTasks.length === 1) { // run the default build / test task @@ -266,7 +260,7 @@ export class QuickOpenTask implements QuickAccessProvider { execute: () => { this.doInit(token).then(() => { // update the `tasks.json` file, instead of running the task itself - this.items = this.getTaskItems().map((item: TaskRunQuickOpenItem) => new ConfigureBuildOrTestTaskQuickOpenItem( + this.items = (this.getTaskItems() as TaskRunQuickOpenItem[]).map(item => new ConfigureBuildOrTestTaskQuickOpenItem( token, item.task, this.taskService, @@ -460,8 +454,6 @@ function renderScope(scope: TaskConfigurationScope, isMulti: boolean): string { export class TaskConfigureQuickOpenItem implements QuickPickItem { - protected taskDefinitionRegistry: TaskDefinitionRegistry; - constructor( protected readonly token: number, protected readonly task: TaskConfiguration, @@ -495,25 +487,25 @@ export class TaskConfigureQuickOpenItem implements QuickPickItem { export class TaskTerminateQuickOpen { @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(QuickInputService) @optional() - protected readonly quickInputService: QuickInputService; + protected readonly quickInputService?: QuickInputService; @inject(TaskDefinitionRegistry) - protected readonly taskDefinitionRegistry: TaskDefinitionRegistry; + protected readonly taskDefinitionRegistry!: TaskDefinitionRegistry; @inject(TaskNameResolver) - protected readonly taskNameResolver: TaskNameResolver; + protected readonly taskNameResolver!: TaskNameResolver; @inject(TaskSourceResolver) - protected readonly taskSourceResolver: TaskSourceResolver; + protected readonly taskSourceResolver!: TaskSourceResolver; @inject(TaskService) - protected readonly taskService: TaskService; + protected readonly taskService!: TaskService; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; async getItems(): Promise> { const items: Array = []; @@ -559,28 +551,28 @@ export class TaskTerminateQuickOpen { @injectable() export class TaskRunningQuickOpen { @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(QuickInputService) @optional() - protected readonly quickInputService: QuickInputService; + protected readonly quickInputService?: QuickInputService; @inject(TaskDefinitionRegistry) - protected readonly taskDefinitionRegistry: TaskDefinitionRegistry; + protected readonly taskDefinitionRegistry!: TaskDefinitionRegistry; @inject(TaskNameResolver) - protected readonly taskNameResolver: TaskNameResolver; + protected readonly taskNameResolver!: TaskNameResolver; @inject(TaskSourceResolver) - protected readonly taskSourceResolver: TaskSourceResolver; + protected readonly taskSourceResolver!: TaskSourceResolver; @inject(TaskService) - protected readonly taskService: TaskService; + protected readonly taskService!: TaskService; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @inject(TerminalService) - protected readonly terminalService: TerminalService; + protected readonly terminalService!: TerminalService; async getItems(): Promise> { const items: Array = []; @@ -648,25 +640,25 @@ export class RunningTaskQuickOpenItem implements QuickPickItem { @injectable() export class TaskRestartRunningQuickOpen { @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(QuickInputService) @optional() - protected readonly quickInputService: QuickInputService; + protected readonly quickInputService?: QuickInputService; @inject(TaskDefinitionRegistry) - protected readonly taskDefinitionRegistry: TaskDefinitionRegistry; + protected readonly taskDefinitionRegistry!: TaskDefinitionRegistry; @inject(TaskNameResolver) - protected readonly taskNameResolver: TaskNameResolver; + protected readonly taskNameResolver!: TaskNameResolver; @inject(TaskSourceResolver) - protected readonly taskSourceResolver: TaskSourceResolver; + protected readonly taskSourceResolver!: TaskSourceResolver; @inject(TaskService) - protected readonly taskService: TaskService; + protected readonly taskService!: TaskService; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; async getItems(): Promise> { const items: Array = []; @@ -698,4 +690,3 @@ export class TaskRestartRunningQuickOpen { this.quickInputService?.showQuickPick(items, { placeholder: 'Select task to restart' }); } } - diff --git a/packages/task/src/browser/task-configuration-manager.ts b/packages/task/src/browser/task-configuration-manager.ts index 6f1ba795aa0fc..814b99e5352c3 100644 --- a/packages/task/src/browser/task-configuration-manager.ts +++ b/packages/task/src/browser/task-configuration-manager.ts @@ -45,49 +45,49 @@ export interface TasksChange { export class TaskConfigurationManager { @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @inject(EditorManager) - protected readonly editorManager: EditorManager; + protected readonly editorManager!: EditorManager; @inject(QuickPickService) - protected readonly quickPickService: QuickPickService; + protected readonly quickPickService!: QuickPickService; @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; @inject(PreferenceService) - protected readonly preferenceService: PreferenceService; + protected readonly preferenceService!: PreferenceService; @inject(TaskSchemaUpdater) - protected readonly taskSchemaProvider: TaskSchemaUpdater; + protected readonly taskSchemaProvider!: TaskSchemaUpdater; @inject(PreferenceProvider) @named(PreferenceScope.Folder) - protected readonly folderPreferences: PreferenceProvider; + protected readonly folderPreferences!: PreferenceProvider; @inject(PreferenceProvider) @named(PreferenceScope.User) - protected readonly userPreferences: PreferenceProvider; + protected readonly userPreferences!: PreferenceProvider; @inject(PreferenceProvider) @named(PreferenceScope.Workspace) - protected readonly workspacePreferences: PreferenceProvider; + protected readonly workspacePreferences!: PreferenceProvider; @inject(PreferenceConfigurations) - protected readonly preferenceConfigurations: PreferenceConfigurations; + protected readonly preferenceConfigurations!: PreferenceConfigurations; @inject(WorkspaceVariableContribution) - protected readonly workspaceVariables: WorkspaceVariableContribution; + protected readonly workspaceVariables!: WorkspaceVariableContribution; @inject(TaskTemplateSelector) - protected readonly taskTemplateSelector: TaskTemplateSelector; + protected readonly taskTemplateSelector!: TaskTemplateSelector; protected readonly onDidChangeTaskConfigEmitter = new Emitter(); readonly onDidChangeTaskConfig: Event = this.onDidChangeTaskConfigEmitter.event; protected readonly models = new Map(); - protected workspaceDelegate: PreferenceProvider; + protected workspaceDelegate?: PreferenceProvider; @postConstruct() - protected async init(): Promise { + protected init(): void { this.createModels(); this.folderPreferences.onDidPreferencesChanged(e => { if (e['tasks']) { diff --git a/packages/task/src/browser/task-configuration-model.ts b/packages/task/src/browser/task-configuration-model.ts index 48b1712c01766..6687b1acdb453 100644 --- a/packages/task/src/browser/task-configuration-model.ts +++ b/packages/task/src/browser/task-configuration-model.ts @@ -26,7 +26,7 @@ import { PreferenceProvider, PreferenceProviderDataChanges, PreferenceProviderDa */ export class TaskConfigurationModel implements Disposable { - protected json: TaskConfigurationModel.JsonContent; + protected json!: TaskConfigurationModel.JsonContent; protected readonly onDidChangeEmitter = new Emitter(); readonly onDidChange: Event = this.onDidChangeEmitter.event; diff --git a/packages/task/src/browser/task-configurations.ts b/packages/task/src/browser/task-configurations.ts index 5642b87ec550d..3a794c7074f1b 100644 --- a/packages/task/src/browser/task-configurations.ts +++ b/packages/task/src/browser/task-configurations.ts @@ -65,22 +65,22 @@ export class TaskConfigurations implements Disposable { private rawTaskConfigurations = new Map(); @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @inject(TaskDefinitionRegistry) - protected readonly taskDefinitionRegistry: TaskDefinitionRegistry; + protected readonly taskDefinitionRegistry!: TaskDefinitionRegistry; @inject(ProvidedTaskConfigurations) - protected readonly providedTaskConfigurations: ProvidedTaskConfigurations; + protected readonly providedTaskConfigurations!: ProvidedTaskConfigurations; @inject(TaskConfigurationManager) - protected readonly taskConfigurationManager: TaskConfigurationManager; + protected readonly taskConfigurationManager!: TaskConfigurationManager; @inject(TaskSchemaUpdater) - protected readonly taskSchemaUpdater: TaskSchemaUpdater; + protected readonly taskSchemaUpdater!: TaskSchemaUpdater; @inject(TaskSourceResolver) - protected readonly taskSourceResolver: TaskSourceResolver; + protected readonly taskSourceResolver!: TaskSourceResolver; constructor() { this.toDispose.push(Disposable.create(() => { diff --git a/packages/task/src/browser/task-contribution.ts b/packages/task/src/browser/task-contribution.ts index 9b0dea3422056..1bb6a0f4a8bdf 100644 --- a/packages/task/src/browser/task-contribution.ts +++ b/packages/task/src/browser/task-contribution.ts @@ -14,7 +14,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 ********************************************************************************/ -import { injectable, postConstruct } from '@theia/core/shared/inversify'; +import { injectable } from '@theia/core/shared/inversify'; import { Disposable } from '@theia/core/lib/common/disposable'; import { TaskConfiguration } from '../common/task-protocol'; import { WaitUntilEvent, Emitter } from '@theia/core/lib/common/event'; @@ -207,12 +207,7 @@ export class TaskProviderRegistry { */ readonly onWillProvideTaskProvider = this.onWillProvideTaskProviderEmitter.event; - protected providers: Map; - - @postConstruct() - protected init(): void { - this.providers = new Map(); - } + protected providers = new Map(); /** * Registers the given {@link TaskProvider} for task configurations of the specified type diff --git a/packages/task/src/browser/task-frontend-contribution.ts b/packages/task/src/browser/task-frontend-contribution.ts index 97f8a92337467..b81266ab4f13f 100644 --- a/packages/task/src/browser/task-frontend-contribution.ts +++ b/packages/task/src/browser/task-frontend-contribution.ts @@ -116,55 +116,55 @@ const TASKS_STORAGE_KEY = 'tasks'; @injectable() export class TaskFrontendContribution implements CommandContribution, MenuContribution, KeybindingContribution, FrontendApplicationContribution, QuickAccessContribution { @inject(QuickOpenTask) - protected readonly quickOpenTask: QuickOpenTask; + protected readonly quickOpenTask!: QuickOpenTask; @inject(EditorManager) - protected readonly editorManager: EditorManager; + protected readonly editorManager!: EditorManager; @inject(FrontendApplication) - protected readonly app: FrontendApplication; + protected readonly app!: FrontendApplication; @inject(ILogger) @named('task') - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(WidgetManager) - protected readonly widgetManager: WidgetManager; + protected readonly widgetManager!: WidgetManager; @inject(ContributionProvider) @named(TaskContribution) - protected readonly contributionProvider: ContributionProvider; + protected readonly contributionProvider!: ContributionProvider; @inject(TaskProviderRegistry) - protected readonly taskProviderRegistry: TaskProviderRegistry; + protected readonly taskProviderRegistry!: TaskProviderRegistry; @inject(TaskResolverRegistry) - protected readonly taskResolverRegistry: TaskResolverRegistry; + protected readonly taskResolverRegistry!: TaskResolverRegistry; @inject(TaskService) - protected readonly taskService: TaskService; + protected readonly taskService!: TaskService; @inject(TaskSchemaUpdater) - protected readonly schemaUpdater: TaskSchemaUpdater; + protected readonly schemaUpdater!: TaskSchemaUpdater; @inject(StorageService) - protected readonly storageService: StorageService; + protected readonly storageService!: StorageService; @inject(TaskRunningQuickOpen) - protected readonly taskRunningQuickOpen: TaskRunningQuickOpen; + protected readonly taskRunningQuickOpen!: TaskRunningQuickOpen; @inject(TaskTerminateQuickOpen) - protected readonly taskTerminateQuickOpen: TaskTerminateQuickOpen; + protected readonly taskTerminateQuickOpen!: TaskTerminateQuickOpen; @inject(TaskRestartRunningQuickOpen) - protected readonly taskRestartRunningQuickOpen: TaskRestartRunningQuickOpen; + protected readonly taskRestartRunningQuickOpen!: TaskRestartRunningQuickOpen; @inject(TaskWatcher) - protected readonly taskWatcher: TaskWatcher; + protected readonly taskWatcher!: TaskWatcher; @inject(StatusBar) - protected readonly statusBar: StatusBar; + protected readonly statusBar!: StatusBar; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @postConstruct() protected async init(): Promise { diff --git a/packages/task/src/browser/task-name-resolver.ts b/packages/task/src/browser/task-name-resolver.ts index 4a049c4b43497..8e2130fe1b867 100644 --- a/packages/task/src/browser/task-name-resolver.ts +++ b/packages/task/src/browser/task-name-resolver.ts @@ -22,10 +22,10 @@ import { TaskConfigurations } from './task-configurations'; @injectable() export class TaskNameResolver { @inject(TaskDefinitionRegistry) - protected taskDefinitionRegistry: TaskDefinitionRegistry; + protected taskDefinitionRegistry!: TaskDefinitionRegistry; @inject(TaskConfigurations) - protected readonly taskConfigurations: TaskConfigurations; + protected readonly taskConfigurations!: TaskConfigurations; /** * Returns task name to display. diff --git a/packages/task/src/browser/task-problem-matcher-registry.ts b/packages/task/src/browser/task-problem-matcher-registry.ts index 78d5fb5c09355..3c72141e4a276 100644 --- a/packages/task/src/browser/task-problem-matcher-registry.ts +++ b/packages/task/src/browser/task-problem-matcher-registry.ts @@ -33,10 +33,10 @@ import { Severity } from '@theia/core/lib/common/severity'; export class ProblemMatcherRegistry { private readonly matchers = new Map(); - private readyPromise: Promise; + private readyPromise!: Promise; @inject(ProblemPatternRegistry) - protected readonly problemPatternRegistry: ProblemPatternRegistry; + protected readonly problemPatternRegistry!: ProblemPatternRegistry; protected readonly onDidChangeProblemMatcherEmitter = new Emitter(); get onDidChangeProblemMatcher(): Event { @@ -45,9 +45,8 @@ export class ProblemMatcherRegistry { @postConstruct() protected init(): void { - this.problemPatternRegistry.onReady().then(() => { + this.readyPromise = this.problemPatternRegistry.onReady().then(() => { this.fillDefaults(); - this.readyPromise = new Promise((res, rej) => res(undefined)); this.onDidChangeProblemMatcherEmitter.fire(undefined); }); } diff --git a/packages/task/src/browser/task-problem-pattern-registry.ts b/packages/task/src/browser/task-problem-pattern-registry.ts index 3ca853e2ede94..26eb5bfaaabc7 100644 --- a/packages/task/src/browser/task-problem-pattern-registry.ts +++ b/packages/task/src/browser/task-problem-pattern-registry.ts @@ -26,12 +26,11 @@ import { Disposable, DisposableCollection } from '@theia/core/lib/common/disposa @injectable() export class ProblemPatternRegistry { private readonly patterns = new Map(); - private readyPromise: Promise; + private readyPromise = Promise.resolve(); @postConstruct() protected init(): void { this.fillDefaults(); - this.readyPromise = new Promise((res, rej) => res(undefined)); } onReady(): Promise { diff --git a/packages/task/src/browser/task-schema-updater.ts b/packages/task/src/browser/task-schema-updater.ts index bd07660b74672..7f33a94c9675c 100644 --- a/packages/task/src/browser/task-schema-updater.ts +++ b/packages/task/src/browser/task-schema-updater.ts @@ -40,19 +40,19 @@ export const taskSchemaId = 'vscode://schemas/tasks'; export class TaskSchemaUpdater implements JsonSchemaContribution { @inject(InMemoryResources) - protected readonly inmemoryResources: InMemoryResources; + protected readonly inmemoryResources!: InMemoryResources; @inject(ProblemMatcherRegistry) - protected readonly problemMatcherRegistry: ProblemMatcherRegistry; + protected readonly problemMatcherRegistry!: ProblemMatcherRegistry; @inject(TaskDefinitionRegistry) - protected readonly taskDefinitionRegistry: TaskDefinitionRegistry; + protected readonly taskDefinitionRegistry!: TaskDefinitionRegistry; @inject(TaskServer) - protected readonly taskServer: TaskServer; + protected readonly taskServer!: TaskServer; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; protected readonly onDidChangeTaskSchemaEmitter = new Emitter(); readonly onDidChangeTaskSchema = this.onDidChangeTaskSchemaEmitter.event; diff --git a/packages/task/src/browser/task-service.ts b/packages/task/src/browser/task-service.ts index 4336a15e10ac2..4e814b0e6bb43 100644 --- a/packages/task/src/browser/task-service.ts +++ b/packages/task/src/browser/task-service.ts @@ -104,88 +104,88 @@ export class TaskService implements TaskConfigurationClient { protected taskStartingLock: Mutex = new Mutex(); @inject(FrontendApplication) - protected readonly app: FrontendApplication; + protected readonly app!: FrontendApplication; @inject(ApplicationShell) - protected readonly shell: ApplicationShell; + protected readonly shell!: ApplicationShell; @inject(TaskServer) - protected readonly taskServer: TaskServer; + protected readonly taskServer!: TaskServer; @inject(ILogger) @named('task') - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(WidgetManager) - protected readonly widgetManager: WidgetManager; + protected readonly widgetManager!: WidgetManager; @inject(TaskWatcher) - protected readonly taskWatcher: TaskWatcher; + protected readonly taskWatcher!: TaskWatcher; @inject(MessageService) - protected readonly messageService: MessageService; + protected readonly messageService!: MessageService; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @inject(TaskConfigurations) - protected readonly taskConfigurations: TaskConfigurations; + protected readonly taskConfigurations!: TaskConfigurations; @inject(ProvidedTaskConfigurations) - protected readonly providedTaskConfigurations: ProvidedTaskConfigurations; + protected readonly providedTaskConfigurations!: ProvidedTaskConfigurations; @inject(VariableResolverService) - protected readonly variableResolverService: VariableResolverService; + protected readonly variableResolverService!: VariableResolverService; @inject(TaskResolverRegistry) - protected readonly taskResolverRegistry: TaskResolverRegistry; + protected readonly taskResolverRegistry!: TaskResolverRegistry; @inject(TerminalService) - protected readonly terminalService: TerminalService; + protected readonly terminalService!: TerminalService; @inject(EditorManager) - protected readonly editorManager: EditorManager; + protected readonly editorManager!: EditorManager; @inject(ProblemManager) - protected readonly problemManager: ProblemManager; + protected readonly problemManager!: ProblemManager; @inject(TaskDefinitionRegistry) - protected readonly taskDefinitionRegistry: TaskDefinitionRegistry; + protected readonly taskDefinitionRegistry!: TaskDefinitionRegistry; @inject(ProblemMatcherRegistry) - protected readonly problemMatcherRegistry: ProblemMatcherRegistry; + protected readonly problemMatcherRegistry!: ProblemMatcherRegistry; @inject(QuickPickService) - protected readonly quickPickService: QuickPickService; + protected readonly quickPickService!: QuickPickService; @inject(OpenerService) - protected readonly openerService: OpenerService; + protected readonly openerService!: OpenerService; @inject(ShellTerminalServerProxy) - protected readonly shellTerminalServer: ShellTerminalServerProxy; + protected readonly shellTerminalServer!: ShellTerminalServerProxy; @inject(TaskNameResolver) - protected readonly taskNameResolver: TaskNameResolver; + protected readonly taskNameResolver!: TaskNameResolver; @inject(TaskSourceResolver) - protected readonly taskSourceResolver: TaskSourceResolver; + protected readonly taskSourceResolver!: TaskSourceResolver; @inject(TaskSchemaUpdater) - protected readonly taskSchemaUpdater: TaskSchemaUpdater; + protected readonly taskSchemaUpdater!: TaskSchemaUpdater; @inject(TaskConfigurationManager) - protected readonly taskConfigurationManager: TaskConfigurationManager; + protected readonly taskConfigurationManager!: TaskConfigurationManager; @inject(CommandService) - protected readonly commands: CommandService; + protected readonly commands!: CommandService; @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(MonacoWorkspace) - protected monacoWorkspace: MonacoWorkspace; + protected monacoWorkspace!: MonacoWorkspace; @inject(TaskTerminalWidgetManager) - protected readonly taskTerminalWidgetManager: TaskTerminalWidgetManager; + protected readonly taskTerminalWidgetManager!: TaskTerminalWidgetManager; @postConstruct() protected init(): void { @@ -1028,11 +1028,11 @@ export class TaskService implements TaskConfigurationClient { const registeredProblemMatchers = this.problemMatcherRegistry.getAll(); items.push(...registeredProblemMatchers.map(matcher => - ({ - label: matcher.label, - value: { problemMatchers: [matcher] }, - description: matcher.name.startsWith('$') ? matcher.name : `$${matcher.name}` - }) + ({ + label: matcher.label, + value: { problemMatchers: [matcher] }, + description: matcher.name.startsWith('$') ? matcher.name : `$${matcher.name}` + }) )); return items; } diff --git a/packages/task/src/browser/task-source-resolver.ts b/packages/task/src/browser/task-source-resolver.ts index 6377d6c41dc7a..6b5a6f32735a7 100644 --- a/packages/task/src/browser/task-source-resolver.ts +++ b/packages/task/src/browser/task-source-resolver.ts @@ -21,7 +21,7 @@ import { TaskDefinitionRegistry } from './task-definition-registry'; @injectable() export class TaskSourceResolver { @inject(TaskDefinitionRegistry) - protected taskDefinitionRegistry: TaskDefinitionRegistry; + protected taskDefinitionRegistry!: TaskDefinitionRegistry; /** * Returns task source to display. diff --git a/packages/task/src/browser/task-terminal-widget-manager.ts b/packages/task/src/browser/task-terminal-widget-manager.ts index be39786410df0..ee6bb1646c152 100644 --- a/packages/task/src/browser/task-terminal-widget-manager.ts +++ b/packages/task/src/browser/task-terminal-widget-manager.ts @@ -68,22 +68,22 @@ export namespace TaskTerminalWidgetOpenerOptions { export class TaskTerminalWidgetManager { @inject(ApplicationShell) - protected readonly shell: ApplicationShell; + protected readonly shell!: ApplicationShell; @inject(TaskDefinitionRegistry) - protected readonly taskDefinitionRegistry: TaskDefinitionRegistry; + protected readonly taskDefinitionRegistry!: TaskDefinitionRegistry; @inject(TerminalService) - protected readonly terminalService: TerminalService; + protected readonly terminalService!: TerminalService; @inject(TaskWatcher) - protected readonly taskWatcher: TaskWatcher; + protected readonly taskWatcher!: TaskWatcher; @inject(TaskServer) - protected readonly taskServer: TaskServer; + protected readonly taskServer!: TaskServer; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @postConstruct() protected init(): void { diff --git a/packages/task/src/node/custom/custom-task-runner-contribution.ts b/packages/task/src/node/custom/custom-task-runner-contribution.ts index a32e3831cfc7c..73d99eb86d828 100644 --- a/packages/task/src/node/custom/custom-task-runner-contribution.ts +++ b/packages/task/src/node/custom/custom-task-runner-contribution.ts @@ -22,7 +22,7 @@ import { TaskRunnerContribution, TaskRunnerRegistry } from '../task-runner'; export class CustomTaskRunnerContribution implements TaskRunnerContribution { @inject(CustomTaskRunner) - protected readonly customTaskRunner: CustomTaskRunner; + protected readonly customTaskRunner!: CustomTaskRunner; registerRunner(runners: TaskRunnerRegistry): void { runners.registerRunner('customExecution', this.customTaskRunner); diff --git a/packages/task/src/node/custom/custom-task-runner.ts b/packages/task/src/node/custom/custom-task-runner.ts index bca9059421185..6e2940af5e7fa 100644 --- a/packages/task/src/node/custom/custom-task-runner.ts +++ b/packages/task/src/node/custom/custom-task-runner.ts @@ -33,13 +33,13 @@ import { export class CustomTaskRunner implements TaskRunner { @inject(ILogger) @named('task') - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(TerminalProcessFactory) - protected readonly terminalProcessFactory: TerminalProcessFactory; + protected readonly terminalProcessFactory!: TerminalProcessFactory; @inject(TaskFactory) - protected readonly taskFactory: TaskFactory; + protected readonly taskFactory!: TaskFactory; async run(taskConfig: TaskConfiguration, ctx?: string): Promise { try { diff --git a/packages/task/src/node/process/process-task-runner-contribution.ts b/packages/task/src/node/process/process-task-runner-contribution.ts index 563985ea1ce7a..4a217dbac59fd 100644 --- a/packages/task/src/node/process/process-task-runner-contribution.ts +++ b/packages/task/src/node/process/process-task-runner-contribution.ts @@ -22,7 +22,7 @@ import { TaskRunnerContribution, TaskRunnerRegistry } from '../task-runner'; export class ProcessTaskRunnerContribution implements TaskRunnerContribution { @inject(ProcessTaskRunner) - protected readonly processTaskRunner: ProcessTaskRunner; + protected readonly processTaskRunner!: ProcessTaskRunner; registerRunner(runners: TaskRunnerRegistry): void { runners.registerRunner('process', this.processTaskRunner); diff --git a/packages/task/src/node/process/process-task-runner.ts b/packages/task/src/node/process/process-task-runner.ts index cced3ebf20c5f..15caa2cb50e12 100644 --- a/packages/task/src/node/process/process-task-runner.ts +++ b/packages/task/src/node/process/process-task-runner.ts @@ -60,16 +60,16 @@ interface ShellSpecificOptions { export class ProcessTaskRunner implements TaskRunner { @inject(ILogger) @named('task') - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(RawProcessFactory) - protected readonly rawProcessFactory: RawProcessFactory; + protected readonly rawProcessFactory!: RawProcessFactory; @inject(TaskTerminalProcessFactory) - protected readonly taskTerminalProcessFactory: TaskTerminalProcessFactory; + protected readonly taskTerminalProcessFactory!: TaskTerminalProcessFactory; @inject(TaskFactory) - protected readonly taskFactory: TaskFactory; + protected readonly taskFactory!: TaskFactory; /** * Runs a task from the given task configuration. diff --git a/packages/task/src/node/task-backend-application-contribution.ts b/packages/task/src/node/task-backend-application-contribution.ts index 31f45d6df2241..09db573c155ab 100644 --- a/packages/task/src/node/task-backend-application-contribution.ts +++ b/packages/task/src/node/task-backend-application-contribution.ts @@ -23,10 +23,10 @@ import { TaskRunnerContribution, TaskRunnerRegistry } from './task-runner'; export class TaskBackendApplicationContribution implements BackendApplicationContribution { @inject(ContributionProvider) @named(TaskRunnerContribution) - protected readonly contributionProvider: ContributionProvider; + protected readonly contributionProvider!: ContributionProvider; @inject(TaskRunnerRegistry) - protected readonly taskRunnerRegistry: TaskRunnerRegistry; + protected readonly taskRunnerRegistry!: TaskRunnerRegistry; onStart(): void { this.contributionProvider.getContributions().forEach(contrib => diff --git a/packages/task/src/node/task-runner.ts b/packages/task/src/node/task-runner.ts index aa53a768b8a48..bc16851f2245d 100644 --- a/packages/task/src/node/task-runner.ts +++ b/packages/task/src/node/task-runner.ts @@ -55,16 +55,16 @@ export interface TaskRunner { @injectable() export class TaskRunnerRegistry { - protected runners: Map; + protected runners = new Map(); + /** A Task Runner that will be used for executing a Task without an associated Runner. */ - protected defaultRunner: TaskRunner; + protected defaultRunner!: TaskRunner; @inject(ProcessTaskRunner) - protected readonly processTaskRunner: ProcessTaskRunner; + protected readonly processTaskRunner!: ProcessTaskRunner; @postConstruct() protected init(): void { - this.runners = new Map(); this.defaultRunner = this.processTaskRunner; } /** diff --git a/packages/task/src/node/task-server.ts b/packages/task/src/node/task-server.ts index 798aad5bd3068..f9a76c32f2d74 100644 --- a/packages/task/src/node/task-server.ts +++ b/packages/task/src/node/task-server.ts @@ -46,13 +46,13 @@ export class TaskServerImpl implements TaskServer, Disposable { protected readonly backgroundTaskStatusMap = new Map(); @inject(ILogger) @named('task') - protected readonly logger: ILogger; + protected readonly logger!: ILogger; @inject(TaskManager) - protected readonly taskManager: TaskManager; + protected readonly taskManager!: TaskManager; @inject(TaskRunnerRegistry) - protected readonly runnerRegistry: TaskRunnerRegistry; + protected readonly runnerRegistry!: TaskRunnerRegistry; /** task context - {task id - problem collector} */ private problemCollectors: Map> = new Map(); diff --git a/packages/terminal/src/browser/base/terminal-widget.ts b/packages/terminal/src/browser/base/terminal-widget.ts index d1a7378feb171..5ff4a35f17fd6 100644 --- a/packages/terminal/src/browser/base/terminal-widget.ts +++ b/packages/terminal/src/browser/base/terminal-widget.ts @@ -46,7 +46,7 @@ export abstract class TerminalWidget extends BaseWidget { abstract readonly dimensions: TerminalDimensions; /** The last CWD assigned to the terminal, useful when attempting getCwdURI on a task terminal fails */ - lastCwd: URI; + abstract lastCwd: URI; /** * Start terminal and return terminal id. diff --git a/packages/terminal/src/browser/search/terminal-search-widget.tsx b/packages/terminal/src/browser/search/terminal-search-widget.tsx index 0461e11142ed3..a05730390d95f 100644 --- a/packages/terminal/src/browser/search/terminal-search-widget.tsx +++ b/packages/terminal/src/browser/search/terminal-search-widget.tsx @@ -29,13 +29,13 @@ export type TerminalSearchWidgetFactory = (terminal: Terminal) => TerminalSearch @injectable() export class TerminalSearchWidget extends ReactWidget { - private searchInput: HTMLInputElement | null; - private searchBox: HTMLDivElement | null; + private searchInput?: HTMLInputElement | null; + private searchBox?: HTMLDivElement | null; private searchOptions: ISearchOptions = {}; - private searchAddon: SearchAddon; + private searchAddon!: SearchAddon; @inject(Terminal) - protected terminal: Terminal; + protected terminal!: Terminal; @postConstruct() protected init(): void { diff --git a/packages/terminal/src/browser/terminal-copy-on-selection-handler.ts b/packages/terminal/src/browser/terminal-copy-on-selection-handler.ts index ff93cc5c7e064..c1221bdfdfa50 100644 --- a/packages/terminal/src/browser/terminal-copy-on-selection-handler.ts +++ b/packages/terminal/src/browser/terminal-copy-on-selection-handler.ts @@ -20,11 +20,11 @@ import { isFirefox } from '@theia/core/lib/browser'; @injectable() export class TerminalCopyOnSelectionHandler { - private textToCopy: string; - private interceptCopy: boolean; + private textToCopy?: string; + private interceptCopy: boolean = false; private copyListener = (ev: ClipboardEvent) => { - if (this.interceptCopy && ev.clipboardData) { + if (this.textToCopy && this.interceptCopy && ev.clipboardData) { ev.clipboardData.setData('text/plain', this.textToCopy); ev.preventDefault(); } diff --git a/packages/terminal/src/browser/terminal-frontend-contribution.ts b/packages/terminal/src/browser/terminal-frontend-contribution.ts index 28070e206f394..40d7350526f10 100644 --- a/packages/terminal/src/browser/terminal-frontend-contribution.ts +++ b/packages/terminal/src/browser/terminal-frontend-contribution.ts @@ -143,29 +143,29 @@ export namespace TerminalCommands { export class TerminalFrontendContribution implements FrontendApplicationContribution, TerminalService, CommandContribution, MenuContribution, KeybindingContribution, TabBarToolbarContribution, ColorContribution { - @inject(ApplicationShell) protected readonly shell: ApplicationShell; - @inject(ShellTerminalServerProxy) protected readonly shellTerminalServer: ShellTerminalServerProxy; - @inject(WidgetManager) protected readonly widgetManager: WidgetManager; - @inject(FileService) protected readonly fileService: FileService; - @inject(SelectionService) protected readonly selectionService: SelectionService; + @inject(ApplicationShell) protected readonly shell!: ApplicationShell; + @inject(ShellTerminalServerProxy) protected readonly shellTerminalServer!: ShellTerminalServerProxy; + @inject(WidgetManager) protected readonly widgetManager!: WidgetManager; + @inject(FileService) protected readonly fileService!: FileService; + @inject(SelectionService) protected readonly selectionService!: SelectionService; @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(QuickInputService) @optional() - protected readonly quickInputService: QuickInputService; + protected readonly quickInputService?: QuickInputService; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @inject(TerminalWatcher) - protected readonly terminalWatcher: TerminalWatcher; + protected readonly terminalWatcher!: TerminalWatcher; @inject(StorageService) - protected readonly storageService: StorageService; + protected readonly storageService!: StorageService; @inject(TerminalPreferences) - protected terminalPreferences: TerminalPreferences; + protected terminalPreferences!: TerminalPreferences; protected readonly onDidCreateTerminalEmitter = new Emitter(); readonly onDidCreateTerminal: Event = this.onDidCreateTerminalEmitter.event; @@ -174,7 +174,7 @@ export class TerminalFrontendContribution implements FrontendApplicationContribu readonly onDidChangeCurrentTerminal: Event = this.onDidChangeCurrentTerminalEmitter.event; @inject(ContextKeyService) - protected readonly contextKeyService: ContextKeyService; + protected readonly contextKeyService!: ContextKeyService; @postConstruct() protected init(): void { diff --git a/packages/terminal/src/browser/terminal-keybinding-contexts.ts b/packages/terminal/src/browser/terminal-keybinding-contexts.ts index e982d6da25a5d..fc5c3e4ba1371 100644 --- a/packages/terminal/src/browser/terminal-keybinding-contexts.ts +++ b/packages/terminal/src/browser/terminal-keybinding-contexts.ts @@ -28,7 +28,7 @@ export class TerminalActiveContext implements KeybindingContext { readonly id: string = TerminalKeybindingContexts.terminalActive; @inject(ApplicationShell) - protected readonly shell: ApplicationShell; + protected readonly shell!: ApplicationShell; isEnabled(): boolean { return this.shell.activeWidget instanceof TerminalWidget; @@ -40,7 +40,7 @@ export class TerminalSearchVisibleContext implements KeybindingContext { readonly id: string = TerminalKeybindingContexts.terminalHideSearch; @inject(ApplicationShell) - protected readonly shell: ApplicationShell; + protected readonly shell!: ApplicationShell; isEnabled(): boolean { if (!(this.shell.activeWidget instanceof TerminalWidget)) { diff --git a/packages/terminal/src/browser/terminal-linkmatcher-files.ts b/packages/terminal/src/browser/terminal-linkmatcher-files.ts index f1ce410a26232..31cc232479745 100644 --- a/packages/terminal/src/browser/terminal-linkmatcher-files.ts +++ b/packages/terminal/src/browser/terminal-linkmatcher-files.ts @@ -28,11 +28,11 @@ import { FileService } from '@theia/filesystem/lib/browser/file-service'; @injectable() export class TerminalLinkmatcherFiles extends AbstractCmdClickTerminalContribution { - @inject(ApplicationServer) protected appServer: ApplicationServer; - @inject(OpenerService) protected openerService: OpenerService; - @inject(FileService) protected fileService: FileService; + @inject(ApplicationServer) protected appServer!: ApplicationServer; + @inject(OpenerService) protected openerService!: OpenerService; + @inject(FileService) protected fileService!: FileService; - protected backendOs: Promise; + protected backendOs!: Promise; @postConstruct() protected init(): void { diff --git a/packages/terminal/src/browser/terminal-linkmatcher.ts b/packages/terminal/src/browser/terminal-linkmatcher.ts index 6fa17f665d0a5..4c79df170d958 100644 --- a/packages/terminal/src/browser/terminal-linkmatcher.ts +++ b/packages/terminal/src/browser/terminal-linkmatcher.ts @@ -96,7 +96,7 @@ export abstract class AbstractCmdClickTerminalContribution implements TerminalCo export class URLMatcher extends AbstractCmdClickTerminalContribution { @inject(OpenerService) - protected readonly openerService: OpenerService; + protected readonly openerService!: OpenerService; async getRegExp(): Promise { return /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/; @@ -112,7 +112,7 @@ export class URLMatcher extends AbstractCmdClickTerminalContribution { export class LocalhostMatcher extends AbstractCmdClickTerminalContribution { @inject(OpenerService) - protected readonly openerService: OpenerService; + protected readonly openerService!: OpenerService; async getRegExp(): Promise { return /(https?:\/\/)?(localhost|127\.0\.0\.1|0\.0\.0\.0)(:[0-9]{1,5})?([-a-zA-Z0-9@:%_\+.~#?&//=]*)/; diff --git a/packages/terminal/src/browser/terminal-quick-open-service.ts b/packages/terminal/src/browser/terminal-quick-open-service.ts index 06fdb2082b44c..0b3ae1a495351 100644 --- a/packages/terminal/src/browser/terminal-quick-open-service.ts +++ b/packages/terminal/src/browser/terminal-quick-open-service.ts @@ -33,16 +33,16 @@ export class TerminalQuickOpenService implements QuickAccessProvider { static readonly PREFIX = 'term '; @inject(QuickInputService) @optional() - protected readonly quickInputService: QuickInputService; + protected readonly quickInputService?: QuickInputService; @inject(QuickAccessRegistry) - protected readonly quickAccessRegistry: QuickAccessRegistry; + protected readonly quickAccessRegistry!: QuickAccessRegistry; @inject(CommandService) - protected readonly commandService: CommandService; + protected readonly commandService!: CommandService; @inject(TerminalService) - protected readonly terminalService: TerminalService; + protected readonly terminalService!: TerminalService; open(): void { this.quickInputService?.open(TerminalQuickOpenService.PREFIX); @@ -118,7 +118,7 @@ export class TerminalQuickOpenService implements QuickAccessProvider { export class TerminalQuickOpenContribution implements CommandContribution, QuickAccessContribution { @inject(TerminalQuickOpenService) - protected readonly terminalQuickOpenService: TerminalQuickOpenService; + protected readonly terminalQuickOpenService!: TerminalQuickOpenService; registerQuickAccessProvider(): void { this.terminalQuickOpenService.registerQuickAccessProvider(); diff --git a/packages/terminal/src/browser/terminal-theme-service.ts b/packages/terminal/src/browser/terminal-theme-service.ts index 4eca584cbf266..4e3ddd06e2bcc 100644 --- a/packages/terminal/src/browser/terminal-theme-service.ts +++ b/packages/terminal/src/browser/terminal-theme-service.ts @@ -157,7 +157,7 @@ export const terminalAnsiColorMap: { [key: string]: { index: number, defaults: C export class TerminalThemeService { @inject(ColorRegistry) - protected readonly colorRegistry: ColorRegistry; + protected readonly colorRegistry!: ColorRegistry; readonly onDidChange = ThemeService.get().onDidColorThemeChange; diff --git a/packages/terminal/src/browser/terminal-widget-impl.ts b/packages/terminal/src/browser/terminal-widget-impl.ts index a5d5748b68646..76a2d3ecc615b 100644 --- a/packages/terminal/src/browser/terminal-widget-impl.ts +++ b/packages/terminal/src/browser/terminal-widget-impl.ts @@ -53,31 +53,31 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget protected terminalKind = 'user'; protected _terminalId = -1; protected readonly onTermDidClose = new Emitter(); - protected fitAddon: FitAddon; - protected term: Terminal; - protected searchBox: TerminalSearchWidget; + protected fitAddon!: FitAddon; + protected term!: Terminal; + protected searchBox!: TerminalSearchWidget; protected restored = false; protected closeOnDispose = true; protected waitForConnection: Deferred | undefined; - protected hoverMessage: HTMLDivElement; + protected hoverMessage!: HTMLDivElement; protected lastTouchEnd: TouchEvent | undefined; protected isAttachedCloseListener: boolean = false; lastCwd = new URI(); - @inject(WorkspaceService) protected readonly workspaceService: WorkspaceService; - @inject(WebSocketConnectionProvider) protected readonly webSocketConnectionProvider: WebSocketConnectionProvider; - @inject(TerminalWidgetOptions) options: TerminalWidgetOptions; - @inject(ShellTerminalServerProxy) protected readonly shellTerminalServer: ShellTerminalServerProxy; - @inject(TerminalWatcher) protected readonly terminalWatcher: TerminalWatcher; - @inject(ILogger) @named('terminal') protected readonly logger: ILogger; - @inject('terminal-dom-id') public readonly id: string; - @inject(TerminalPreferences) protected readonly preferences: TerminalPreferences; - @inject(ContributionProvider) @named(TerminalContribution) protected readonly terminalContributionProvider: ContributionProvider; - @inject(TerminalService) protected readonly terminalService: TerminalService; - @inject(TerminalSearchWidgetFactory) protected readonly terminalSearchBoxFactory: TerminalSearchWidgetFactory; - @inject(TerminalCopyOnSelectionHandler) protected readonly copyOnSelectionHandler: TerminalCopyOnSelectionHandler; - @inject(TerminalThemeService) protected readonly themeService: TerminalThemeService; - @inject(ShellCommandBuilder) protected readonly shellCommandBuilder: ShellCommandBuilder; + @inject(WorkspaceService) protected readonly workspaceService!: WorkspaceService; + @inject(WebSocketConnectionProvider) protected readonly webSocketConnectionProvider!: WebSocketConnectionProvider; + @inject(TerminalWidgetOptions) options!: TerminalWidgetOptions; + @inject(ShellTerminalServerProxy) protected readonly shellTerminalServer!: ShellTerminalServerProxy; + @inject(TerminalWatcher) protected readonly terminalWatcher!: TerminalWatcher; + @inject(ILogger) @named('terminal') protected readonly logger!: ILogger; + @inject('terminal-dom-id') public readonly id!: string; + @inject(TerminalPreferences) protected readonly preferences!: TerminalPreferences; + @inject(ContributionProvider) @named(TerminalContribution) protected readonly terminalContributionProvider!: ContributionProvider; + @inject(TerminalService) protected readonly terminalService!: TerminalService; + @inject(TerminalSearchWidgetFactory) protected readonly terminalSearchBoxFactory!: TerminalSearchWidgetFactory; + @inject(TerminalCopyOnSelectionHandler) protected readonly copyOnSelectionHandler!: TerminalCopyOnSelectionHandler; + @inject(TerminalThemeService) protected readonly themeService!: TerminalThemeService; + @inject(ShellCommandBuilder) protected readonly shellCommandBuilder!: ShellCommandBuilder; protected readonly onDidOpenEmitter = new Emitter(); readonly onDidOpen: Event = this.onDidOpenEmitter.event; diff --git a/packages/terminal/src/node/shell-terminal-server.ts b/packages/terminal/src/node/shell-terminal-server.ts index 03626ac73a0ce..dcb9398b47513 100644 --- a/packages/terminal/src/node/shell-terminal-server.ts +++ b/packages/terminal/src/node/shell-terminal-server.ts @@ -27,7 +27,7 @@ import * as cp from 'child_process'; @injectable() export class ShellTerminalServer extends BaseTerminalServer { - @inject(EnvironmentUtils) protected environmentUtils: EnvironmentUtils; + @inject(EnvironmentUtils) protected environmentUtils!: EnvironmentUtils; constructor( @inject(ShellProcessFactory) protected readonly shellFactory: ShellProcessFactory, diff --git a/packages/terminal/src/node/terminal-backend-contribution.ts b/packages/terminal/src/node/terminal-backend-contribution.ts index 7f15a6bf337fa..6d34c20738eb6 100644 --- a/packages/terminal/src/node/terminal-backend-contribution.ts +++ b/packages/terminal/src/node/terminal-backend-contribution.ts @@ -24,13 +24,13 @@ import { MessagingService } from '@theia/core/lib/node/messaging/messaging-servi export class TerminalBackendContribution implements MessagingService.Contribution { @inject(ProcessManager) - protected readonly processManager: ProcessManager; + protected readonly processManager!: ProcessManager; @inject(ILogger) @named('terminal') - protected readonly logger: ILogger; + protected readonly logger!: ILogger; configure(service: MessagingService): void { - service.listen(`${terminalsPath}/:id`, (params: { id: string }, connection) => { + service.listen(`${terminalsPath}/:id`, (params, connection) => { const id = parseInt(params.id, 10); const termProcess = this.processManager.get(id); if (termProcess instanceof TerminalProcess) { diff --git a/packages/timeline/src/browser/timeline-context-key-service.ts b/packages/timeline/src/browser/timeline-context-key-service.ts index 9c9110306b564..f35b6c577818d 100644 --- a/packages/timeline/src/browser/timeline-context-key-service.ts +++ b/packages/timeline/src/browser/timeline-context-key-service.ts @@ -21,9 +21,9 @@ import { ContextKeyService, ContextKey } from '@theia/core/lib/browser/context-k export class TimelineContextKeyService { @inject(ContextKeyService) - protected readonly contextKeyService: ContextKeyService; + protected readonly contextKeyService!: ContextKeyService; - protected _timelineItem: ContextKey; + protected _timelineItem!: ContextKey; get timelineItem(): ContextKey { return this._timelineItem; } diff --git a/packages/timeline/src/browser/timeline-contribution.ts b/packages/timeline/src/browser/timeline-contribution.ts index 5145d08684c67..8f71a3aef29e0 100644 --- a/packages/timeline/src/browser/timeline-contribution.ts +++ b/packages/timeline/src/browser/timeline-contribution.ts @@ -34,15 +34,15 @@ import { toArray } from '@theia/core/shared/@phosphor/algorithm'; export class TimelineContribution implements CommandContribution, TabBarToolbarContribution { @inject(WidgetManager) - protected readonly widgetManager: WidgetManager; + protected readonly widgetManager!: WidgetManager; @inject(TimelineService) - protected readonly timelineService: TimelineService; + protected readonly timelineService!: TimelineService; @inject(CommandRegistry) - protected readonly commandRegistry: CommandRegistry; + protected readonly commandRegistry!: CommandRegistry; @inject(TabBarToolbarRegistry) - protected readonly tabBarToolbar: TabBarToolbarRegistry; + protected readonly tabBarToolbar!: TabBarToolbarRegistry; @inject(ApplicationShell) - protected readonly shell: ApplicationShell; + protected readonly shell!: ApplicationShell; public static readonly LOAD_MORE_COMMAND: Command = { id: 'timeline-load-more' diff --git a/packages/timeline/src/browser/timeline-service.ts b/packages/timeline/src/browser/timeline-service.ts index 8d147a6da8b48..199cda9bc9205 100644 --- a/packages/timeline/src/browser/timeline-service.ts +++ b/packages/timeline/src/browser/timeline-service.ts @@ -100,9 +100,9 @@ export class TimelineService { export class TimelineAggregate { readonly items: TimelineItem[]; readonly source: string; - readonly uri: string; private _cursor?: string; + get cursor(): string | undefined { return this._cursor; } diff --git a/packages/timeline/src/browser/timeline-tree-widget.tsx b/packages/timeline/src/browser/timeline-tree-widget.tsx index 481f5ef1550f6..cfaafde9089fb 100644 --- a/packages/timeline/src/browser/timeline-tree-widget.tsx +++ b/packages/timeline/src/browser/timeline-tree-widget.tsx @@ -32,8 +32,8 @@ export class TimelineTreeWidget extends TreeWidget { static ID = 'timeline-tree-widget'; static PAGE_SIZE = 20; - @inject(MenuModelRegistry) protected readonly menus: MenuModelRegistry; - @inject(TimelineContextKeyService) protected readonly contextKeys: TimelineContextKeyService; + @inject(MenuModelRegistry) protected readonly menus!: MenuModelRegistry; + @inject(TimelineContextKeyService) protected readonly contextKeys!: TimelineContextKeyService; constructor( @inject(TreeProps) readonly props: TreeProps, diff --git a/packages/timeline/src/browser/timeline-widget.tsx b/packages/timeline/src/browser/timeline-widget.tsx index d08deb0cb224f..4f649b56eab73 100644 --- a/packages/timeline/src/browser/timeline-widget.tsx +++ b/packages/timeline/src/browser/timeline-widget.tsx @@ -35,17 +35,17 @@ import { URI as CodeURI } from '@theia/core/shared/vscode-uri'; @injectable() export class TimelineWidget extends BaseWidget { - protected panel: Panel; + protected panel!: Panel; static ID = 'timeline-view'; private readonly timelinesBySource = new Map(); - @inject(TimelineTreeWidget) protected readonly resourceWidget: TimelineTreeWidget; - @inject(TimelineService) protected readonly timelineService: TimelineService; - @inject(CommandRegistry) protected readonly commandRegistry: CommandRegistry; - @inject(ApplicationShell) protected readonly applicationShell: ApplicationShell; - @inject(TimelineEmptyWidget) protected readonly timelineEmptyWidget: TimelineEmptyWidget; - @inject(SelectionService) protected readonly selectionService: SelectionService; + @inject(TimelineTreeWidget) protected readonly resourceWidget!: TimelineTreeWidget; + @inject(TimelineService) protected readonly timelineService!: TimelineService; + @inject(CommandRegistry) protected readonly commandRegistry!: CommandRegistry; + @inject(ApplicationShell) protected readonly applicationShell!: ApplicationShell; + @inject(TimelineEmptyWidget) protected readonly timelineEmptyWidget!: TimelineEmptyWidget; + @inject(SelectionService) protected readonly selectionService!: SelectionService; constructor() { super(); diff --git a/packages/typehierarchy/src/browser/tree/typehierarchy-tree-model.ts b/packages/typehierarchy/src/browser/tree/typehierarchy-tree-model.ts index 5b5b14b272f66..d9b7020516823 100644 --- a/packages/typehierarchy/src/browser/tree/typehierarchy-tree-model.ts +++ b/packages/typehierarchy/src/browser/tree/typehierarchy-tree-model.ts @@ -24,7 +24,7 @@ import { TypeHierarchyTree } from './typehierarchy-tree'; export class TypeHierarchyTreeModel extends TreeModelImpl { @inject(TypeHierarchyRegistry) - protected readonly registry: TypeHierarchyRegistry; + protected readonly registry!: TypeHierarchyRegistry; protected doOpenNode(node: TreeNode): void { // do nothing (in particular do not expand the node) diff --git a/packages/typehierarchy/src/browser/typehierarchy-contribution.ts b/packages/typehierarchy/src/browser/typehierarchy-contribution.ts index 168c804c7f262..110585c619071 100644 --- a/packages/typehierarchy/src/browser/typehierarchy-contribution.ts +++ b/packages/typehierarchy/src/browser/typehierarchy-contribution.ts @@ -31,10 +31,10 @@ export class TypeHierarchyContribution extends AbstractViewContribution { diff --git a/packages/variable-resolver/src/browser/common-variable-contribution.ts b/packages/variable-resolver/src/browser/common-variable-contribution.ts index 11a3cabb53624..6b1ea92d8f2c6 100644 --- a/packages/variable-resolver/src/browser/common-variable-contribution.ts +++ b/packages/variable-resolver/src/browser/common-variable-contribution.ts @@ -30,22 +30,22 @@ import { MaybeArray, RecursivePartial } from '@theia/core/lib/common/types'; export class CommonVariableContribution implements VariableContribution { @inject(EnvVariablesServer) - protected readonly env: EnvVariablesServer; + protected readonly env!: EnvVariablesServer; @inject(CommandService) - protected readonly commands: CommandService; + protected readonly commands!: CommandService; @inject(PreferenceService) - protected readonly preferences: PreferenceService; + protected readonly preferences!: PreferenceService; @inject(ResourceContextKey) - protected readonly resourceContextKey: ResourceContextKey; + protected readonly resourceContextKey!: ResourceContextKey; @inject(QuickInputService) @optional() - protected readonly quickInputService: QuickInputService; + protected readonly quickInputService?: QuickInputService; @inject(ApplicationServer) - protected readonly appServer: ApplicationServer; + protected readonly appServer!: ApplicationServer; async registerVariables(variables: VariableRegistry): Promise { const [execPath, backendOS] = await Promise.all([ diff --git a/packages/variable-resolver/src/browser/variable-quick-open-service.ts b/packages/variable-resolver/src/browser/variable-quick-open-service.ts index 74790bff3e9c5..47e4951d2c7cf 100644 --- a/packages/variable-resolver/src/browser/variable-quick-open-service.ts +++ b/packages/variable-resolver/src/browser/variable-quick-open-service.ts @@ -23,16 +23,16 @@ import { QuickPickItem, QuickInputService } from '@theia/core/lib/browser'; @injectable() export class VariableQuickOpenService { - protected items: Array; + protected items?: QuickPickItem[]; @inject(MessageService) - protected readonly messages: MessageService; + protected readonly messages!: MessageService; @inject(QuickInputService) @optional() - protected readonly quickInputService: QuickInputService; + protected readonly quickInputService?: QuickInputService; @inject(VariableResolverService) - protected readonly variableResolver: VariableResolverService; + protected readonly variableResolver!: VariableResolverService; constructor( @inject(VariableRegistry) protected readonly variableRegistry: VariableRegistry diff --git a/packages/variable-resolver/src/browser/variable-resolver-service.ts b/packages/variable-resolver/src/browser/variable-resolver-service.ts index 32340e452c42f..2e71e6973cf22 100644 --- a/packages/variable-resolver/src/browser/variable-resolver-service.ts +++ b/packages/variable-resolver/src/browser/variable-resolver-service.ts @@ -37,7 +37,7 @@ export class VariableResolverService { protected static VAR_REGEXP = /\$\{(.*?)\}/g; - @inject(VariableRegistry) protected readonly variableRegistry: VariableRegistry; + @inject(VariableRegistry) protected readonly variableRegistry!: VariableRegistry; /** * Resolve the variables in the given string array. diff --git a/packages/vsx-registry/src/browser/recommended-extensions/recommended-extensions-json-schema.ts b/packages/vsx-registry/src/browser/recommended-extensions/recommended-extensions-json-schema.ts index 90e220b718760..acdbcbe0d06dd 100644 --- a/packages/vsx-registry/src/browser/recommended-extensions/recommended-extensions-json-schema.ts +++ b/packages/vsx-registry/src/browser/recommended-extensions/recommended-extensions-json-schema.ts @@ -54,8 +54,8 @@ export const extensionsConfigurationSchema: IJSONSchema = { @injectable() export class ExtensionSchemaContribution implements JsonSchemaContribution { protected readonly uri = new URI(extensionsSchemaID); - @inject(InMemoryResources) protected readonly inmemoryResources: InMemoryResources; - @inject(WorkspaceService) protected readonly workspaceService: WorkspaceService; + @inject(InMemoryResources) protected readonly inmemoryResources!: InMemoryResources; + @inject(WorkspaceService) protected readonly workspaceService!: WorkspaceService; @postConstruct() protected init(): void { diff --git a/packages/vsx-registry/src/browser/vsx-extension-editor.tsx b/packages/vsx-registry/src/browser/vsx-extension-editor.tsx index 85c785547119f..5725906b385dd 100644 --- a/packages/vsx-registry/src/browser/vsx-extension-editor.tsx +++ b/packages/vsx-registry/src/browser/vsx-extension-editor.tsx @@ -27,10 +27,10 @@ export class VSXExtensionEditor extends ReactWidget { static ID = 'vsx-extension-editor'; @inject(VSXExtension) - protected readonly extension: VSXExtension; + protected readonly extension!: VSXExtension; @inject(VSXExtensionsModel) - protected readonly model: VSXExtensionsModel; + protected readonly model!: VSXExtensionsModel; protected readonly deferredScrollContainer = new Deferred(); diff --git a/packages/vsx-registry/src/browser/vsx-extension.tsx b/packages/vsx-registry/src/browser/vsx-extension.tsx index ecf1b6091bb03..e33387ba30abd 100644 --- a/packages/vsx-registry/src/browser/vsx-extension.tsx +++ b/packages/vsx-registry/src/browser/vsx-extension.tsx @@ -79,8 +79,8 @@ export class VSXExtensionData { } @injectable() -export class VSXExtensionOptions { - readonly id: string; +export abstract class VSXExtensionOptions { + abstract readonly id: string; } export const VSXExtensionFactory = Symbol('VSXExtensionFactory'); @@ -90,31 +90,31 @@ export type VSXExtensionFactory = (options: VSXExtensionOptions) => VSXExtension export class VSXExtension implements VSXExtensionData, TreeElement { @inject(VSXExtensionOptions) - protected readonly options: VSXExtensionOptions; + protected readonly options!: VSXExtensionOptions; @inject(OpenerService) - protected readonly openerService: OpenerService; + protected readonly openerService!: OpenerService; @inject(HostedPluginSupport) - protected readonly pluginSupport: HostedPluginSupport; + protected readonly pluginSupport!: HostedPluginSupport; @inject(PluginServer) - protected readonly pluginServer: PluginServer; + protected readonly pluginServer!: PluginServer; @inject(ProgressService) - protected readonly progressService: ProgressService; + protected readonly progressService!: ProgressService; @inject(ContextMenuRenderer) - protected readonly contextMenuRenderer: ContextMenuRenderer; + protected readonly contextMenuRenderer!: ContextMenuRenderer; @inject(VSXEnvironment) - readonly environment: VSXEnvironment; + readonly environment!: VSXEnvironment; @inject(VSXExtensionsSearchModel) - readonly search: VSXExtensionsSearchModel; + readonly search!: VSXExtensionsSearchModel; @inject(TooltipService) - readonly tooltipService: TooltipService; + readonly tooltipService!: TooltipService; protected readonly data: Partial = {}; diff --git a/packages/vsx-registry/src/browser/vsx-extensions-contribution.ts b/packages/vsx-registry/src/browser/vsx-extensions-contribution.ts index eec1d8a81c2ca..86dac50da3383 100644 --- a/packages/vsx-registry/src/browser/vsx-extensions-contribution.ts +++ b/packages/vsx-registry/src/browser/vsx-extensions-contribution.ts @@ -42,13 +42,13 @@ export { VSXExtensionsCommands }; export class VSXExtensionsContribution extends AbstractViewContribution implements ColorContribution, FrontendApplicationContribution { - @inject(VSXExtensionsModel) protected readonly model: VSXExtensionsModel; - @inject(CommandRegistry) protected readonly commandRegistry: CommandRegistry; - @inject(FileDialogService) protected readonly fileDialogService: FileDialogService; - @inject(MessageService) protected readonly messageService: MessageService; - @inject(LabelProvider) protected readonly labelProvider: LabelProvider; - @inject(ClipboardService) protected readonly clipboardService: ClipboardService; - @inject(PreferenceService) protected readonly preferenceService: PreferenceService; + @inject(VSXExtensionsModel) protected readonly model!: VSXExtensionsModel; + @inject(CommandRegistry) protected readonly commandRegistry!: CommandRegistry; + @inject(FileDialogService) protected readonly fileDialogService!: FileDialogService; + @inject(MessageService) protected readonly messageService!: MessageService; + @inject(LabelProvider) protected readonly labelProvider!: LabelProvider; + @inject(ClipboardService) protected readonly clipboardService!: ClipboardService; + @inject(PreferenceService) protected readonly preferenceService!: PreferenceService; constructor() { super({ diff --git a/packages/vsx-registry/src/browser/vsx-extensions-model.ts b/packages/vsx-registry/src/browser/vsx-extensions-model.ts index 3fa521820032d..1e31877d57ade 100644 --- a/packages/vsx-registry/src/browser/vsx-extensions-model.ts +++ b/packages/vsx-registry/src/browser/vsx-extensions-model.ts @@ -39,25 +39,25 @@ export class VSXExtensionsModel { readonly onDidChange = this.onDidChangeEmitter.event; @inject(OVSXClientProvider) - protected clientProvider: OVSXClientProvider; + protected clientProvider!: OVSXClientProvider; @inject(HostedPluginSupport) - protected readonly pluginSupport: HostedPluginSupport; + protected readonly pluginSupport!: HostedPluginSupport; @inject(VSXExtensionFactory) - protected readonly extensionFactory: VSXExtensionFactory; + protected readonly extensionFactory!: VSXExtensionFactory; @inject(ProgressService) - protected readonly progressService: ProgressService; + protected readonly progressService!: ProgressService; @inject(PreferenceService) - protected readonly preferences: PreferenceService; + protected readonly preferences!: PreferenceService; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @inject(VSXExtensionsSearchModel) - readonly search: VSXExtensionsSearchModel; + readonly search!: VSXExtensionsSearchModel; protected readonly initialized = new Deferred(); diff --git a/packages/vsx-registry/src/browser/vsx-extensions-search-bar.tsx b/packages/vsx-registry/src/browser/vsx-extensions-search-bar.tsx index c9a07882aa607..e020f770c97de 100644 --- a/packages/vsx-registry/src/browser/vsx-extensions-search-bar.tsx +++ b/packages/vsx-registry/src/browser/vsx-extensions-search-bar.tsx @@ -23,7 +23,7 @@ import { VSXExtensionsSearchModel } from './vsx-extensions-search-model'; export class VSXExtensionsSearchBar extends ReactWidget { @inject(VSXExtensionsSearchModel) - protected readonly model: VSXExtensionsSearchModel; + protected readonly model!: VSXExtensionsSearchModel; @postConstruct() protected init(): void { diff --git a/packages/vsx-registry/src/browser/vsx-extensions-source.ts b/packages/vsx-registry/src/browser/vsx-extensions-source.ts index 2bcbd296a16fe..a63d40b1baa70 100644 --- a/packages/vsx-registry/src/browser/vsx-extensions-source.ts +++ b/packages/vsx-registry/src/browser/vsx-extensions-source.ts @@ -19,22 +19,22 @@ import { TreeSource, TreeElement } from '@theia/core/lib/browser/source-tree'; import { VSXExtensionsModel } from './vsx-extensions-model'; @injectable() -export class VSXExtensionsSourceOptions { +export abstract class VSXExtensionsSourceOptions { static INSTALLED = 'installed'; static BUILT_IN = 'builtin'; static SEARCH_RESULT = 'searchResult'; static RECOMMENDED = 'recommended'; - readonly id: string; + abstract readonly id: string; } @injectable() export class VSXExtensionsSource extends TreeSource { @inject(VSXExtensionsSourceOptions) - protected readonly options: VSXExtensionsSourceOptions; + protected readonly options!: VSXExtensionsSourceOptions; @inject(VSXExtensionsModel) - protected readonly model: VSXExtensionsModel; + protected readonly model!: VSXExtensionsModel; @postConstruct() protected async init(): Promise { diff --git a/packages/vsx-registry/src/browser/vsx-extensions-view-container.ts b/packages/vsx-registry/src/browser/vsx-extensions-view-container.ts index d38f45990f45c..8af48b165d5f9 100644 --- a/packages/vsx-registry/src/browser/vsx-extensions-view-container.ts +++ b/packages/vsx-registry/src/browser/vsx-extensions-view-container.ts @@ -33,10 +33,10 @@ export class VSXExtensionsViewContainer extends ViewContainer { disableDNDBetweenContainers = true; @inject(VSXExtensionsSearchBar) - protected readonly searchBar: VSXExtensionsSearchBar; + protected readonly searchBar!: VSXExtensionsSearchBar; @inject(VSXExtensionsModel) - protected readonly model: VSXExtensionsModel; + protected readonly model!: VSXExtensionsModel; @postConstruct() protected init(): void { diff --git a/packages/vsx-registry/src/browser/vsx-extensions-widget.ts b/packages/vsx-registry/src/browser/vsx-extensions-widget.ts index f735564588f1c..ee3cf2b0afae7 100644 --- a/packages/vsx-registry/src/browser/vsx-extensions-widget.ts +++ b/packages/vsx-registry/src/browser/vsx-extensions-widget.ts @@ -20,7 +20,7 @@ import { VSXExtensionsSource, VSXExtensionsSourceOptions } from './vsx-extension import { nls } from '@theia/core/lib/common/nls'; @injectable() -export class VSXExtensionsWidgetOptions extends VSXExtensionsSourceOptions { +export abstract class VSXExtensionsWidgetOptions extends VSXExtensionsSourceOptions { title?: string; } @@ -45,10 +45,10 @@ export class VSXExtensionsWidget extends SourceTreeWidget { } @inject(VSXExtensionsWidgetOptions) - protected readonly options: VSXExtensionsWidgetOptions; + protected readonly options!: VSXExtensionsWidgetOptions; @inject(VSXExtensionsSource) - protected readonly extensionsSource: VSXExtensionsSource; + protected readonly extensionsSource!: VSXExtensionsSource; @postConstruct() protected init(): void { diff --git a/packages/vsx-registry/src/node/vsx-environment-impl.ts b/packages/vsx-registry/src/node/vsx-environment-impl.ts index 86dbb0d8792b7..51536e0a950bf 100644 --- a/packages/vsx-registry/src/node/vsx-environment-impl.ts +++ b/packages/vsx-registry/src/node/vsx-environment-impl.ts @@ -25,7 +25,7 @@ export class VSXEnvironmentImpl implements VSXEnvironment { protected _registryUri = new URI(process.env['VSX_REGISTRY_URL']?.trim() || 'https://open-vsx.org'); @inject(PluginVsCodeCliContribution) - protected readonly pluginVscodeCli: PluginVsCodeCliContribution; + protected readonly pluginVscodeCli!: PluginVsCodeCliContribution; async getRegistryUri(): Promise { return this._registryUri.toString(true); diff --git a/packages/vsx-registry/src/node/vsx-extension-resolver.ts b/packages/vsx-registry/src/node/vsx-extension-resolver.ts index 84cd5e939e635..61444f8b5d420 100644 --- a/packages/vsx-registry/src/node/vsx-extension-resolver.ts +++ b/packages/vsx-registry/src/node/vsx-extension-resolver.ts @@ -29,7 +29,7 @@ import { OVSXClientProvider } from '../common/ovsx-client-provider'; export class VSXExtensionResolver implements PluginDeployerResolver { @inject(OVSXClientProvider) - protected clientProvider: OVSXClientProvider; + protected clientProvider!: OVSXClientProvider; protected readonly downloadPath: string; diff --git a/packages/workspace/src/browser/diff-service.ts b/packages/workspace/src/browser/diff-service.ts index e22ce96ec6a4a..c59caa157d537 100644 --- a/packages/workspace/src/browser/diff-service.ts +++ b/packages/workspace/src/browser/diff-service.ts @@ -24,9 +24,9 @@ import { FileService } from '@theia/filesystem/lib/browser/file-service'; @injectable() export class DiffService { - @inject(FileService) protected readonly fileService: FileService; - @inject(OpenerService) protected readonly openerService: OpenerService; - @inject(MessageService) protected readonly messageService: MessageService; + @inject(FileService) protected readonly fileService!: FileService; + @inject(OpenerService) protected readonly openerService!: OpenerService; + @inject(MessageService) protected readonly messageService!: MessageService; public async openDiffEditor(left: URI, right: URI, label?: string, options?: OpenerOptions): Promise { if (left.scheme === 'file' && right.scheme === 'file') { diff --git a/packages/workspace/src/browser/quick-open-workspace.ts b/packages/workspace/src/browser/quick-open-workspace.ts index 1e5448f1a3719..8ca536a3dc841 100644 --- a/packages/workspace/src/browser/quick-open-workspace.ts +++ b/packages/workspace/src/browser/quick-open-workspace.ts @@ -30,15 +30,15 @@ interface RecentlyOpenedPick extends QuickPickItem { @injectable() export class QuickOpenWorkspace { - protected items: Array; - protected opened: boolean; + protected items?: RecentlyOpenedPick[]; + protected opened?: boolean; - @inject(QuickInputService) @optional() protected readonly quickInputService: QuickInputService; - @inject(WorkspaceService) protected readonly workspaceService: WorkspaceService; - @inject(FileService) protected readonly fileService: FileService; - @inject(LabelProvider) protected readonly labelProvider: LabelProvider; - @inject(WorkspacePreferences) protected preferences: WorkspacePreferences; - @inject(EnvVariablesServer) protected readonly envServer: EnvVariablesServer; + @inject(QuickInputService) @optional() protected readonly quickInputService?: QuickInputService; + @inject(WorkspaceService) protected readonly workspaceService!: WorkspaceService; + @inject(FileService) protected readonly fileService!: FileService; + @inject(LabelProvider) protected readonly labelProvider!: LabelProvider; + @inject(WorkspacePreferences) protected preferences!: WorkspacePreferences; + @inject(EnvVariablesServer) protected readonly envServer!: EnvVariablesServer; protected readonly removeRecentWorkspaceButton: QuickInputButton = { iconClass: 'codicon-remove-close', diff --git a/packages/workspace/src/browser/workspace-breadcrumbs-contribution.ts b/packages/workspace/src/browser/workspace-breadcrumbs-contribution.ts index 5903c2f4beb7c..0e61a2406517b 100644 --- a/packages/workspace/src/browser/workspace-breadcrumbs-contribution.ts +++ b/packages/workspace/src/browser/workspace-breadcrumbs-contribution.ts @@ -24,7 +24,7 @@ import URI from '@theia/core/lib/common/uri'; export class WorkspaceBreadcrumbsContribution extends FilepathBreadcrumbsContribution { @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; getContainerClassCreator(fileURI: URI): FilepathBreadcrumbClassNameFactory { const workspaceRoot = this.workspaceService.getWorkspaceRootUri(fileURI); diff --git a/packages/workspace/src/browser/workspace-commands.ts b/packages/workspace/src/browser/workspace-commands.ts index babf7cbe327f9..200de0fbedb7c 100644 --- a/packages/workspace/src/browser/workspace-commands.ts +++ b/packages/workspace/src/browser/workspace-commands.ts @@ -193,24 +193,26 @@ export interface DidCreateNewResourceEvent { @injectable() export class WorkspaceCommandContribution implements CommandContribution { - @inject(LabelProvider) protected readonly labelProvider: LabelProvider; - @inject(FileService) protected readonly fileService: FileService; - @inject(WorkspaceService) protected readonly workspaceService: WorkspaceService; - @inject(SelectionService) protected readonly selectionService: SelectionService; - @inject(OpenerService) protected readonly openerService: OpenerService; - @inject(FrontendApplication) protected readonly app: FrontendApplication; - @inject(MessageService) protected readonly messageService: MessageService; - @inject(WorkspacePreferences) protected readonly preferences: WorkspacePreferences; - @inject(FileDialogService) protected readonly fileDialogService: FileDialogService; - @inject(WorkspaceDeleteHandler) protected readonly deleteHandler: WorkspaceDeleteHandler; - @inject(WorkspaceDuplicateHandler) protected readonly duplicateHandler: WorkspaceDuplicateHandler; - @inject(WorkspaceCompareHandler) protected readonly compareHandler: WorkspaceCompareHandler; - @inject(ApplicationServer) protected readonly applicationServer: ApplicationServer; + openers: OpenHandler[] = []; + + @inject(LabelProvider) protected readonly labelProvider!: LabelProvider; + @inject(FileService) protected readonly fileService!: FileService; + @inject(WorkspaceService) protected readonly workspaceService!: WorkspaceService; + @inject(SelectionService) protected readonly selectionService!: SelectionService; + @inject(OpenerService) protected readonly openerService!: OpenerService; + @inject(FrontendApplication) protected readonly app!: FrontendApplication; + @inject(MessageService) protected readonly messageService!: MessageService; + @inject(WorkspacePreferences) protected readonly preferences!: WorkspacePreferences; + @inject(FileDialogService) protected readonly fileDialogService!: FileDialogService; + @inject(WorkspaceDeleteHandler) protected readonly deleteHandler!: WorkspaceDeleteHandler; + @inject(WorkspaceDuplicateHandler) protected readonly duplicateHandler!: WorkspaceDuplicateHandler; + @inject(WorkspaceCompareHandler) protected readonly compareHandler!: WorkspaceCompareHandler; + @inject(ApplicationServer) protected readonly applicationServer!: ApplicationServer; private readonly onDidCreateNewFileEmitter = new Emitter(); private readonly onDidCreateNewFolderEmitter = new Emitter(); - protected backendOS: Promise; + protected backendOS!: Promise; @postConstruct() async init(): Promise { @@ -355,7 +357,6 @@ export class WorkspaceCommandContribution implements CommandContribution { }); } - openers: OpenHandler[]; protected async registerOpenWith(registry: CommandRegistry): Promise { if (this.openerService.onDidChangeOpeners) { this.openerService.onDidChangeOpeners(async e => { diff --git a/packages/workspace/src/browser/workspace-compare-handler.ts b/packages/workspace/src/browser/workspace-compare-handler.ts index 4962c28c75a48..7b7cbbf47099a 100644 --- a/packages/workspace/src/browser/workspace-compare-handler.ts +++ b/packages/workspace/src/browser/workspace-compare-handler.ts @@ -22,7 +22,7 @@ import { DiffService } from './diff-service'; @injectable() export class WorkspaceCompareHandler implements UriCommandHandler { - @inject(DiffService) protected readonly diffService: DiffService; + @inject(DiffService) protected readonly diffService!: DiffService; /** * Determine if the command is visible. diff --git a/packages/workspace/src/browser/workspace-delete-handler.ts b/packages/workspace/src/browser/workspace-delete-handler.ts index 00886324641e3..979cf79276879 100644 --- a/packages/workspace/src/browser/workspace-delete-handler.ts +++ b/packages/workspace/src/browser/workspace-delete-handler.ts @@ -28,19 +28,19 @@ import { FileDeleteOptions, FileSystemProviderCapabilities } from '@theia/filesy export class WorkspaceDeleteHandler implements UriCommandHandler { @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; @inject(ApplicationShell) - protected readonly shell: ApplicationShell; + protected readonly shell!: ApplicationShell; @inject(WorkspaceUtils) - protected readonly workspaceUtils: WorkspaceUtils; + protected readonly workspaceUtils!: WorkspaceUtils; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @inject(FileSystemPreferences) - protected readonly fsPreferences: FileSystemPreferences; + protected readonly fsPreferences!: FileSystemPreferences; /** * Determine if the command is visible. diff --git a/packages/workspace/src/browser/workspace-duplicate-handler.ts b/packages/workspace/src/browser/workspace-duplicate-handler.ts index 5a0410cd70481..e420e8816770e 100644 --- a/packages/workspace/src/browser/workspace-duplicate-handler.ts +++ b/packages/workspace/src/browser/workspace-duplicate-handler.ts @@ -26,13 +26,13 @@ import { FileService } from '@theia/filesystem/lib/browser/file-service'; export class WorkspaceDuplicateHandler implements UriCommandHandler { @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; @inject(WorkspaceUtils) - protected readonly workspaceUtils: WorkspaceUtils; + protected readonly workspaceUtils!: WorkspaceUtils; @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; /** * Determine if the command is visible. diff --git a/packages/workspace/src/browser/workspace-frontend-contribution.ts b/packages/workspace/src/browser/workspace-frontend-contribution.ts index 61a2cde7aaca7..bcdfc4aa2c53e 100644 --- a/packages/workspace/src/browser/workspace-frontend-contribution.ts +++ b/packages/workspace/src/browser/workspace-frontend-contribution.ts @@ -55,27 +55,27 @@ export type WorkspaceState = keyof typeof WorkspaceStates; @injectable() export class WorkspaceFrontendContribution implements CommandContribution, KeybindingContribution, MenuContribution, FrontendApplicationContribution { - @inject(ApplicationShell) protected readonly applicationShell: ApplicationShell; - @inject(MessageService) protected readonly messageService: MessageService; - @inject(FileService) protected readonly fileService: FileService; - @inject(OpenerService) protected readonly openerService: OpenerService; - @inject(WorkspaceService) protected readonly workspaceService: WorkspaceService; - @inject(StorageService) protected readonly workspaceStorage: StorageService; - @inject(LabelProvider) protected readonly labelProvider: LabelProvider; - @inject(QuickOpenWorkspace) protected readonly quickOpenWorkspace: QuickOpenWorkspace; - @inject(FileDialogService) protected readonly fileDialogService: FileDialogService; - @inject(WorkspacePreferences) protected preferences: WorkspacePreferences; - @inject(SelectionService) protected readonly selectionService: SelectionService; - @inject(CommandRegistry) protected readonly commandRegistry: CommandRegistry; + @inject(ApplicationShell) protected readonly applicationShell!: ApplicationShell; + @inject(MessageService) protected readonly messageService!: MessageService; + @inject(FileService) protected readonly fileService!: FileService; + @inject(OpenerService) protected readonly openerService!: OpenerService; + @inject(WorkspaceService) protected readonly workspaceService!: WorkspaceService; + @inject(StorageService) protected readonly workspaceStorage!: StorageService; + @inject(LabelProvider) protected readonly labelProvider!: LabelProvider; + @inject(QuickOpenWorkspace) protected readonly quickOpenWorkspace!: QuickOpenWorkspace; + @inject(FileDialogService) protected readonly fileDialogService!: FileDialogService; + @inject(WorkspacePreferences) protected preferences!: WorkspacePreferences; + @inject(SelectionService) protected readonly selectionService!: SelectionService; + @inject(CommandRegistry) protected readonly commandRegistry!: CommandRegistry; @inject(ContextKeyService) - protected readonly contextKeyService: ContextKeyService; + protected readonly contextKeyService!: ContextKeyService; @inject(EncodingRegistry) - protected readonly encodingRegistry: EncodingRegistry; + protected readonly encodingRegistry!: EncodingRegistry; @inject(PreferenceConfigurations) - protected readonly preferenceConfigurations: PreferenceConfigurations; + protected readonly preferenceConfigurations!: PreferenceConfigurations; configure(): void { this.encodingRegistry.registerOverride({ encoding: UTF8, extension: THEIA_EXT }); diff --git a/packages/workspace/src/browser/workspace-input-dialog.ts b/packages/workspace/src/browser/workspace-input-dialog.ts index a789c9104236e..e103fe6287f45 100644 --- a/packages/workspace/src/browser/workspace-input-dialog.ts +++ b/packages/workspace/src/browser/workspace-input-dialog.ts @@ -19,12 +19,12 @@ import URI from '@theia/core/lib/common/uri'; import { SingleTextInputDialog, SingleTextInputDialogProps, LabelProvider, codiconArray } from '@theia/core/lib/browser'; @injectable() -export class WorkspaceInputDialogProps extends SingleTextInputDialogProps { +export abstract class WorkspaceInputDialogProps extends SingleTextInputDialogProps { /** * The parent `URI` for the selection present in the explorer. * Used to display the path in which the file/folder is created at. */ - parentUri: URI; + abstract parentUri: URI; } export class WorkspaceInputDialog extends SingleTextInputDialog { diff --git a/packages/workspace/src/browser/workspace-schema-updater.ts b/packages/workspace/src/browser/workspace-schema-updater.ts index 5bdb0e6905fef..3fdbc02860a48 100644 --- a/packages/workspace/src/browser/workspace-schema-updater.ts +++ b/packages/workspace/src/browser/workspace-schema-updater.ts @@ -38,7 +38,7 @@ export class WorkspaceSchemaUpdater implements JsonSchemaContribution { protected readonly editQueue: SchemaUpdateMessage[] = []; protected safeToHandleQueue = new Deferred(); - @inject(InMemoryResources) protected readonly inmemoryResources: InMemoryResources; + @inject(InMemoryResources) protected readonly inmemoryResources!: InMemoryResources; @postConstruct() protected init(): void { diff --git a/packages/workspace/src/browser/workspace-service.ts b/packages/workspace/src/browser/workspace-service.ts index 4214c6b560223..8d835ee48eb4e 100644 --- a/packages/workspace/src/browser/workspace-service.ts +++ b/packages/workspace/src/browser/workspace-service.ts @@ -47,42 +47,42 @@ export class WorkspaceService implements FrontendApplicationContribution { protected deferredRoots = new Deferred(); @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; @inject(WorkspaceServer) - protected readonly server: WorkspaceServer; + protected readonly server!: WorkspaceServer; @inject(WindowService) - protected readonly windowService: WindowService; + protected readonly windowService!: WindowService; @inject(ILogger) - protected logger: ILogger; + protected logger!: ILogger; @inject(WorkspacePreferences) - protected preferences: WorkspacePreferences; + protected preferences!: WorkspacePreferences; @inject(PreferenceServiceImpl) - protected readonly preferenceImpl: PreferenceServiceImpl; + protected readonly preferenceImpl!: PreferenceServiceImpl; @inject(PreferenceSchemaProvider) - protected readonly schemaProvider: PreferenceSchemaProvider; + protected readonly schemaProvider!: PreferenceSchemaProvider; @inject(EnvVariablesServer) - protected readonly envVariableServer: EnvVariablesServer; + protected readonly envVariableServer!: EnvVariablesServer; @inject(MessageService) - protected readonly messageService: MessageService; + protected readonly messageService!: MessageService; @inject(LabelProvider) - protected readonly labelProvider: LabelProvider; + protected readonly labelProvider!: LabelProvider; @inject(FileSystemPreferences) - protected readonly fsPreferences: FileSystemPreferences; + protected readonly fsPreferences!: FileSystemPreferences; @inject(WorkspaceSchemaUpdater) - protected readonly schemaUpdater: WorkspaceSchemaUpdater; + protected readonly schemaUpdater!: WorkspaceSchemaUpdater; - protected applicationName: string; + protected applicationName!: string; protected _ready = new Deferred(); get ready(): Promise { diff --git a/packages/workspace/src/browser/workspace-storage-service.ts b/packages/workspace/src/browser/workspace-storage-service.ts index 69f66686cb4b5..9c15d45692405 100644 --- a/packages/workspace/src/browser/workspace-storage-service.ts +++ b/packages/workspace/src/browser/workspace-storage-service.ts @@ -25,11 +25,11 @@ import { FileStat } from '@theia/filesystem/lib/common/files'; @injectable() export class WorkspaceStorageService implements StorageService { - private prefix: string; - private initialized: Promise; + private prefix?: string; + private initialized!: Promise; - @inject(LocalStorageService) protected storageService: StorageService; - @inject(WorkspaceService) protected workspaceService: WorkspaceService; + @inject(LocalStorageService) protected storageService!: StorageService; + @inject(WorkspaceService) protected workspaceService!: WorkspaceService; @postConstruct() protected init(): void { diff --git a/packages/workspace/src/browser/workspace-uri-contribution.ts b/packages/workspace/src/browser/workspace-uri-contribution.ts index a3789903a753f..b43552a8a8be9 100644 --- a/packages/workspace/src/browser/workspace-uri-contribution.ts +++ b/packages/workspace/src/browser/workspace-uri-contribution.ts @@ -24,7 +24,7 @@ import { WorkspaceVariableContribution } from './workspace-variable-contribution export class WorkspaceUriLabelProviderContribution extends DefaultUriLabelProviderContribution { @inject(WorkspaceVariableContribution) - protected readonly workspaceVariable: WorkspaceVariableContribution; + protected readonly workspaceVariable!: WorkspaceVariableContribution; @postConstruct() async init(): Promise { diff --git a/packages/workspace/src/browser/workspace-utils.ts b/packages/workspace/src/browser/workspace-utils.ts index 99d2ba67eac0e..b458fcd760511 100644 --- a/packages/workspace/src/browser/workspace-utils.ts +++ b/packages/workspace/src/browser/workspace-utils.ts @@ -29,7 +29,7 @@ import { WorkspaceService } from './workspace-service'; export class WorkspaceUtils { @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; /** * Determine if root directory exists diff --git a/packages/workspace/src/browser/workspace-variable-contribution.ts b/packages/workspace/src/browser/workspace-variable-contribution.ts index 85c67f06d71b5..8fcb7392f22b9 100644 --- a/packages/workspace/src/browser/workspace-variable-contribution.ts +++ b/packages/workspace/src/browser/workspace-variable-contribution.ts @@ -26,13 +26,13 @@ import { FileService } from '@theia/filesystem/lib/browser/file-service'; export class WorkspaceVariableContribution implements VariableContribution { @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; + protected readonly workspaceService!: WorkspaceService; @inject(ApplicationShell) - protected readonly shell: ApplicationShell; + protected readonly shell!: ApplicationShell; @inject(FileService) - protected readonly fileService: FileService; + protected readonly fileService!: FileService; @inject(WidgetManager) - protected readonly widgetManager: WidgetManager; + protected readonly widgetManager!: WidgetManager; protected currentWidget: NavigatableWidget | undefined; diff --git a/packages/workspace/src/node/default-workspace-server.ts b/packages/workspace/src/node/default-workspace-server.ts index 9de9a803180c5..a6c00a0a12034 100644 --- a/packages/workspace/src/node/default-workspace-server.ts +++ b/packages/workspace/src/node/default-workspace-server.ts @@ -64,10 +64,10 @@ export class DefaultWorkspaceServer implements WorkspaceServer { protected root: Deferred = new Deferred(); @inject(WorkspaceCliContribution) - protected readonly cliParams: WorkspaceCliContribution; + protected readonly cliParams!: WorkspaceCliContribution; @inject(EnvVariablesServer) - protected readonly envServer: EnvVariablesServer; + protected readonly envServer!: EnvVariablesServer; @postConstruct() protected async init(): Promise {