Skip to content

Commit

Permalink
Fix some strictPropertyInitialization in search, #78168
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens committed Sep 3, 2019
1 parent c165069 commit 779e29a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 32 deletions.
1 change: 1 addition & 0 deletions src/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"strictBindCallApply": true,
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true,
"strictPropertyInitialization": true,
"baseUrl": ".",
"paths": {
"vs/*": [
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/api/node/extHostSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export class ExtHostSearch implements ExtHostSearchShape {
private readonly _fileSearchUsedSchemes = new Set<string>();
private _handlePool: number = 0;

private _internalFileSearchHandle: number;
private _internalFileSearchProvider: SearchService | null;
private _internalFileSearchHandle: number = -1;
private _internalFileSearchProvider: SearchService | null = null;

private _fileSearchManager: FileSearchManager;

Expand Down
34 changes: 17 additions & 17 deletions src/vs/workbench/contrib/search/browser/searchView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ export class SearchView extends ViewletPanel {
private static readonly WIDE_VIEW_SIZE = 1000;
private static readonly ACTIONS_RIGHT_CLASS_NAME = 'actions-right';

private isDisposed: boolean;
private isDisposed = false;

private container: HTMLElement;
private container!: HTMLElement;
private queryBuilder: QueryBuilder;
private viewModel: SearchModel;
private memento: Memento;
Expand All @@ -99,31 +99,31 @@ export class SearchView extends ViewletPanel {
private matchFocused: IContextKey<boolean>;
private hasSearchResultsKey: IContextKey<boolean>;

private state: SearchUIState;
private state: SearchUIState = SearchUIState.Idle;

private actions: Array<CollapseDeepestExpandedLevelAction | ClearSearchResultsAction> = [];
private cancelAction: CancelSearchAction;
private refreshAction: RefreshAction;
private contextMenu: IMenu;
private contextMenu: IMenu | null = null;

private tree: WorkbenchObjectTree<RenderableMatch>;
private treeLabels: ResourceLabels;
private tree!: WorkbenchObjectTree<RenderableMatch>;
private treeLabels!: ResourceLabels;
private viewletState: MementoObject;
private messagesElement: HTMLElement;
private messagesElement!: HTMLElement;
private messageDisposables: IDisposable[] = [];
private searchWidgetsContainerElement: HTMLElement;
private searchWidget: SearchWidget;
private size: dom.Dimension;
private queryDetails: HTMLElement;
private toggleQueryDetailsButton: HTMLElement;
private inputPatternExcludes: ExcludePatternInputWidget;
private inputPatternIncludes: PatternInputWidget;
private resultsElement: HTMLElement;
private searchWidgetsContainerElement!: HTMLElement;
private searchWidget!: SearchWidget;
private size!: dom.Dimension;
private queryDetails!: HTMLElement;
private toggleQueryDetailsButton!: HTMLElement;
private inputPatternExcludes!: ExcludePatternInputWidget;
private inputPatternIncludes!: PatternInputWidget;
private resultsElement!: HTMLElement;

private currentSelectedFileMatch: FileMatch | undefined;

private delayedRefresh: Delayer<void>;
private changedWhileHidden: boolean;
private changedWhileHidden: boolean = false;

private searchWithoutFolderMessageElement: HTMLElement | undefined;

Expand Down Expand Up @@ -441,7 +441,7 @@ export class SearchView extends ViewletPanel {

private refreshAndUpdateCount(event?: IChangeEvent): void {
this.searchWidget.setReplaceAllActionState(!this.viewModel.searchResult.isEmpty());
this.updateSearchResultCount(this.viewModel.searchResult.query.userDisabledExcludesAndIgnoreFiles);
this.updateSearchResultCount(this.viewModel.searchResult.query!.userDisabledExcludesAndIgnoreFiles);
return this.refreshTree(event);
}

Expand Down
32 changes: 19 additions & 13 deletions src/vs/workbench/contrib/search/common/searchModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,11 @@ export class FileMatch extends Disposable implements IFileMatch {
readonly onDispose: Event<void> = this._onDispose.event;

private _resource: URI;
private _model: ITextModel | null;
private _modelListener: IDisposable;
private _model: ITextModel | null = null;
private _modelListener: IDisposable | null = null;
private _matches: Map<string, Match>;
private _removedMatches: Set<string>;
private _selectedMatch: Match | null;
private _selectedMatch: Match | null = null;

private _updateScheduler: RunOnceScheduler;
private _modelDecorations: string[] = [];
Expand Down Expand Up @@ -244,7 +244,7 @@ export class FileMatch extends Disposable implements IFileMatch {
this._updateScheduler.cancel();
this._model.deltaDecorations(this._modelDecorations, []);
this._model = null;
this._modelListener.dispose();
this._modelListener!.dispose();
}
}

Expand Down Expand Up @@ -633,10 +633,10 @@ export class SearchResult extends Disposable {
readonly onChange: Event<IChangeEvent> = this._onChange.event;

private _folderMatches: FolderMatchWithResource[] = [];
private _otherFilesMatch: FolderMatch;
private _otherFilesMatch: FolderMatch | null = null;
private _folderMatchesMap: TernarySearchTree<FolderMatchWithResource> = TernarySearchTree.forPaths<FolderMatchWithResource>();
private _showHighlights: boolean;
private _query: ITextQuery;
private _showHighlights: boolean = false;
private _query: ITextQuery | null = null;

private _rangeHighlightDecorations: RangeHighlightDecorations;

Expand All @@ -653,14 +653,18 @@ export class SearchResult extends Disposable {
this._register(this.modelService.onModelAdded(model => this.onModelAdded(model)));
}

get query(): ITextQuery {
get query(): ITextQuery | null {
return this._query;
}

set query(query: ITextQuery) {
set query(query: ITextQuery | null) {
// When updating the query we could change the roots, so ensure we clean up the old roots first.
this.clear();
this._folderMatches = (query.folderQueries || [])
if (!query) {
return;
}

this._folderMatches = (query && query.folderQueries || [])
.map(fq => fq.folder)
.map((resource, index) => this.createFolderMatchWithResource(resource, resource.toString(), index, query));

Expand Down Expand Up @@ -717,6 +721,8 @@ export class SearchResult extends Disposable {
clear(): void {
this.folderMatches().forEach((folderMatch) => folderMatch.clear());
this.disposeMatches();
this._folderMatches = [];
this._otherFilesMatch = null;
}

remove(matches: FileMatch | FolderMatch | (FileMatch | FolderMatch)[]): void {
Expand Down Expand Up @@ -835,7 +841,7 @@ export class SearchResult extends Disposable {

private getFolderMatch(resource: URI): FolderMatch {
const folderMatch = this._folderMatchesMap.findSubstr(resource.toString());
return folderMatch ? folderMatch : this._otherFilesMatch;
return folderMatch ? folderMatch : this._otherFilesMatch!;
}

private set replacingAll(running: boolean) {
Expand Down Expand Up @@ -896,7 +902,7 @@ export class SearchModel extends Disposable {
private readonly _onReplaceTermChanged: Emitter<void> = this._register(new Emitter<void>());
readonly onReplaceTermChanged: Event<void> = this._onReplaceTermChanged.event;

private currentCancelTokenSource: CancellationTokenSource;
private currentCancelTokenSource: CancellationTokenSource | null = null;

constructor(
@ISearchService private readonly searchService: ISearchService,
Expand Down Expand Up @@ -1064,7 +1070,7 @@ export type RenderableMatch = FolderMatch | FolderMatchWithResource | FileMatch
export class SearchWorkbenchService implements ISearchWorkbenchService {

_serviceBrand: undefined;
private _searchModel: SearchModel;
private _searchModel: SearchModel | null = null;

constructor(@IInstantiationService private readonly instantiationService: IInstantiationService) {
}
Expand Down

0 comments on commit 779e29a

Please sign in to comment.