提交 49607e57 编写于 作者: J Johannes Rieken

strict null - Map.get(K) can return undefined

上级 ed0057fd
......@@ -10,7 +10,7 @@ interface Map<K, V> {
clear(): void;
delete(key: K): boolean;
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
get(key: K): V;
get(key: K): V | undefined;
has(key: K): boolean;
set(key: K, value?: V): Map<K, V>;
readonly size: number;
......
......@@ -108,7 +108,7 @@ export class OneSnippet {
for (const placeholder of this._placeholderGroups[this._placeholderGroupsIdx]) {
// Check if the placeholder has a transformation
if (placeholder.transform) {
const id = this._placeholderDecorations.get(placeholder);
const id = this._placeholderDecorations.get(placeholder)!;
const range = this._editor.getModel().getDecorationRange(id)!;
const currentValue = this._editor.getModel().getValueInRange(range);
......@@ -158,7 +158,7 @@ export class OneSnippet {
activePlaceholders.add(placeholder);
for (const enclosingPlaceholder of this._snippet.enclosingPlaceholders(placeholder)) {
const id = this._placeholderDecorations.get(enclosingPlaceholder);
const id = this._placeholderDecorations.get(enclosingPlaceholder)!;
accessor.changeDecorationOptions(id, enclosingPlaceholder.isFinalTabstop ? OneSnippet._decor.activeFinal : OneSnippet._decor.active);
activePlaceholders.add(enclosingPlaceholder);
}
......@@ -206,7 +206,7 @@ export class OneSnippet {
result.set(placeholder.index, ranges);
}
const id = this._placeholderDecorations.get(placeholder);
const id = this._placeholderDecorations.get(placeholder)!;
const range = this._editor.getModel().getDecorationRange(id);
if (!range) {
// one of the placeholder lost its decoration and
......@@ -257,7 +257,7 @@ export class OneSnippet {
// Remove the placeholder at which position are inserting
// the snippet and also remove its decoration.
const id = this._placeholderDecorations.get(placeholder);
const id = this._placeholderDecorations.get(placeholder)!;
accessor.removeDecoration(id);
this._placeholderDecorations.delete(placeholder);
......@@ -574,7 +574,7 @@ export class SnippetSession {
// add selections from 'this' snippet so that we know all
// selections for this placeholder
allPossibleSelections.forEach((array, index) => {
array.push(...possibleSelections.get(index));
array.push(...possibleSelections.get(index)!);
});
}
......
......@@ -204,7 +204,7 @@ export class ContributableViewsModel extends Disposable {
readonly viewDescriptors: IViewDescriptor[] = [];
get visibleViewDescriptors(): IViewDescriptor[] {
return this.viewDescriptors.filter(v => this.viewStates.get(v.id).visible);
return this.viewDescriptors.filter(v => this.viewStates.get(v.id)!.visible);
}
private _onDidAdd = this._register(new Emitter<IAddedViewDescriptorRef[]>());
......@@ -298,7 +298,7 @@ export class ContributableViewsModel extends Disposable {
move(this.viewDescriptors, fromIndex, toIndex);
for (let index = 0; index < this.viewDescriptors.length; index++) {
const state = this.viewStates.get(this.viewDescriptors[index].id);
const state = this.viewStates.get(this.viewDescriptors[index].id)!;
state.order = index;
}
......@@ -388,7 +388,7 @@ export class ContributableViewsModel extends Disposable {
}
for (const viewDescriptor of splice.toInsert) {
const state = this.viewStates.get(viewDescriptor.id);
const state = this.viewStates.get(viewDescriptor.id)!;
if (state.visible) {
toAdd.push({ index: startIndex++, viewDescriptor, size: state.size, collapsed: state.collapsed });
......@@ -536,7 +536,7 @@ export class ViewsService extends Disposable implements IViewsService {
}
getViewDescriptors(container: ViewContainer): IViewDescriptorCollection {
return this.viewDescriptorCollections.get(container);
return this.viewDescriptorCollections.get(container)!;
}
openView(id: string, focus: boolean): Promise<IView | null> {
......
......@@ -341,7 +341,7 @@ class ExtensionDependencies implements IExtensionDependencies {
if (!this.hasDependencies) {
return [];
}
return this._extension.dependencies.map(id => new ExtensionDependencies(this._map.get(id), id, this._map, this));
return this._extension.dependencies.map(id => new ExtensionDependencies(this._map.get(id)!, id, this._map, this));
}
private computeHasDependencies(): boolean {
......
......@@ -203,7 +203,7 @@ export class FileWalker {
const useRipgrep = this.useRipgrep;
let noSiblingsClauses: boolean;
if (useRipgrep) {
const ripgrep = spawnRipgrepCmd(this.config, folderQuery, this.config.includePattern, this.folderExcludePatterns.get(folderQuery.folder.fsPath).expression);
const ripgrep = spawnRipgrepCmd(this.config, folderQuery, this.config.includePattern, this.folderExcludePatterns.get(folderQuery.folder.fsPath)!.expression);
cmd = ripgrep.cmd;
noSiblingsClauses = !Object.keys(ripgrep.siblingClauses).length;
......@@ -286,7 +286,7 @@ export class FileWalker {
* Public for testing.
*/
spawnFindCmd(folderQuery: IFolderQuery) {
const excludePattern = this.folderExcludePatterns.get(folderQuery.folder.fsPath);
const excludePattern = this.folderExcludePatterns.get(folderQuery.folder.fsPath)!;
const basenames = excludePattern.getBasenameTerms();
const pathTerms = excludePattern.getPathTerms();
const args = ['-L', '.'];
......@@ -428,7 +428,7 @@ export class FileWalker {
private matchDirectoryTree({ rootEntries, pathToEntries }: IDirectoryTree, rootFolder: string, onResult: (result: IRawFileMatch) => void) {
const self = this;
const excludePattern = this.folderExcludePatterns.get(rootFolder);
const excludePattern = this.folderExcludePatterns.get(rootFolder)!;
const filePattern = this.filePattern;
function matchDirectory(entries: IDirectoryEntry[]) {
self.directoriesWalked++;
......@@ -508,7 +508,7 @@ export class FileWalker {
// to ignore filtering by siblings because the user seems to know what she
// is searching for and we want to include the result in that case anyway
const currentRelativePath = relativeParentPath ? [relativeParentPath, file].join(path.sep) : file;
if (this.folderExcludePatterns.get(folderQuery.folder.fsPath).test(currentRelativePath, file, this.config.filePattern !== file ? hasSibling : undefined)) {
if (this.folderExcludePatterns.get(folderQuery.folder.fsPath)!.test(currentRelativePath, file, this.config.filePattern !== file ? hasSibling : undefined)) {
return clb(null);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册