提交 779e29a4 编写于 作者: R Rob Lourens

Fix some strictPropertyInitialization in search, #78168

上级 c1650691
......@@ -11,6 +11,7 @@
"strictBindCallApply": true,
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true,
"strictPropertyInitialization": true,
"baseUrl": ".",
"paths": {
"vs/*": [
......
......@@ -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;
......
......@@ -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;
......@@ -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;
......@@ -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);
}
......
......@@ -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[] = [];
......@@ -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();
}
}
......@@ -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;
......@@ -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));
......@@ -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 {
......@@ -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) {
......@@ -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,
......@@ -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) {
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册