mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-23 11:49:38 +00:00
Use undefined instead of null
This commit is contained in:
@@ -158,7 +158,7 @@ class TscTaskProvider implements vscode.TaskProvider {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private getActiveTypeScriptFile(): string | null {
|
||||
private getActiveTypeScriptFile(): string | undefined {
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
if (editor) {
|
||||
const document = editor.document;
|
||||
@@ -166,7 +166,7 @@ class TscTaskProvider implements vscode.TaskProvider {
|
||||
return this.client.value.toPath(document.uri);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private async getTasksForProject(project: TSConfig): Promise<vscode.Task[]> {
|
||||
|
||||
@@ -63,14 +63,14 @@ export interface ITypeScriptServiceClient {
|
||||
*
|
||||
* Does not try handling case insensitivity.
|
||||
*/
|
||||
normalizedPath(resource: vscode.Uri): string | null;
|
||||
normalizedPath(resource: vscode.Uri): string | undefined;
|
||||
|
||||
/**
|
||||
* Map a resource to a normalized path
|
||||
*
|
||||
* This will attempt to handle case insensitivity.
|
||||
*/
|
||||
toPath(resource: vscode.Uri): string | null;
|
||||
toPath(resource: vscode.Uri): string | undefined;
|
||||
|
||||
/**
|
||||
* Convert a path to a resource.
|
||||
|
||||
@@ -488,7 +488,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
}
|
||||
}
|
||||
|
||||
public normalizedPath(resource: vscode.Uri): string | null {
|
||||
public normalizedPath(resource: vscode.Uri): string | undefined {
|
||||
if (this._apiVersion.gte(API.v213)) {
|
||||
if (resource.scheme === fileSchemes.walkThroughSnippet || resource.scheme === fileSchemes.untitled) {
|
||||
const dirName = path.dirname(resource.path);
|
||||
@@ -498,19 +498,19 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
}
|
||||
|
||||
if (resource.scheme !== fileSchemes.file) {
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const result = resource.fsPath;
|
||||
if (!result) {
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Both \ and / must be escaped in regular expressions
|
||||
return result.replace(new RegExp('\\' + this.pathSeparator, 'g'), '/');
|
||||
}
|
||||
|
||||
public toPath(resource: vscode.Uri): string | null {
|
||||
public toPath(resource: vscode.Uri): string | undefined {
|
||||
return this.normalizedPath(resource);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ export default class ManagedFileContextManager {
|
||||
private readonly onDidChangeActiveTextEditorSub: vscode.Disposable;
|
||||
|
||||
public constructor(
|
||||
private readonly normalizePath: (resource: vscode.Uri) => string | null
|
||||
private readonly normalizePath: (resource: vscode.Uri) => string | undefined
|
||||
) {
|
||||
this.onDidChangeActiveTextEditorSub = vscode.window.onDidChangeActiveTextEditor(this.onDidChangeActiveTextEditor, this);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ export class ResourceMap<T> {
|
||||
private readonly _map = new Map<string, { resource: vscode.Uri, value: T }>();
|
||||
|
||||
constructor(
|
||||
private readonly _normalizePath: (resource: vscode.Uri) => string | null = (resource) => resource.fsPath
|
||||
private readonly _normalizePath: (resource: vscode.Uri) => string | undefined = (resource) => resource.fsPath
|
||||
) { }
|
||||
|
||||
public get size() {
|
||||
@@ -71,7 +71,7 @@ export class ResourceMap<T> {
|
||||
return this._map.values();
|
||||
}
|
||||
|
||||
private toKey(resource: vscode.Uri): string | null {
|
||||
private toKey(resource: vscode.Uri): string | undefined {
|
||||
const key = this._normalizePath(resource);
|
||||
if (!key) {
|
||||
return key;
|
||||
|
||||
@@ -12,7 +12,7 @@ export default class VersionStatus {
|
||||
private readonly _versionBarEntry: vscode.StatusBarItem;
|
||||
|
||||
constructor(
|
||||
private readonly _normalizePath: (resource: vscode.Uri) => string | null
|
||||
private readonly _normalizePath: (resource: vscode.Uri) => string | undefined
|
||||
) {
|
||||
this._versionBarEntry = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 99 /* to the right of editor status (100) */);
|
||||
this._onChangeEditorSub = vscode.window.onDidChangeActiveTextEditor(this.showHideStatus, this);
|
||||
|
||||
Reference in New Issue
Block a user