提交 fec1775a 编写于 作者: M Matt Bierner

Strict null checks

上级 10b95a0b
......@@ -108,12 +108,16 @@
"./vs/code/electron-browser/issue/issueReporterModel.ts",
"./vs/code/electron-browser/issue/issueReporterPage.ts",
"./vs/code/electron-browser/issue/issueReporterUtil.ts",
"./vs/code/electron-browser/sharedProcess/contrib/contributions.ts",
"./vs/code/electron-browser/sharedProcess/contrib/languagePackCachedDataCleaner.ts",
"./vs/code/electron-browser/sharedProcess/contrib/nodeCachedDataCleaner.ts",
"./vs/code/electron-main/auth.ts",
"./vs/code/electron-main/keyboard.ts",
"./vs/code/electron-main/sharedProcess.ts",
"./vs/code/electron-main/theme.ts",
"./vs/code/node/shellEnv.ts",
"./vs/code/node/wait.ts",
"./vs/code/node/windowsFinder.ts",
"./vs/editor/browser/config/charWidthReader.ts",
"./vs/editor/browser/config/configuration.ts",
"./vs/editor/browser/config/elementSizeObserver.ts",
......@@ -331,6 +335,7 @@
"./vs/editor/contrib/referenceSearch/referencesModel.ts",
"./vs/editor/contrib/rename/rename.ts",
"./vs/editor/contrib/rename/renameInputField.ts",
"./vs/editor/contrib/smartSelect/tokenSelectionSupport.ts",
"./vs/editor/contrib/smartSelect/tokenTree.ts",
"./vs/editor/contrib/snippet/snippetParser.ts",
"./vs/editor/contrib/suggest/suggest.ts",
......@@ -395,6 +400,7 @@
"./vs/platform/dialogs/node/dialogService.ts",
"./vs/platform/download/common/download.ts",
"./vs/platform/download/node/downloadService.ts",
"./vs/platform/driver/node/driver.ts",
"./vs/platform/editor/common/editor.ts",
"./vs/platform/environment/common/environment.ts",
"./vs/platform/environment/node/argv.ts",
......@@ -497,6 +503,7 @@
"./vs/platform/workspace/common/workspace.ts",
"./vs/platform/workspace/test/common/testWorkspace.ts",
"./vs/platform/workspaces/common/workspaces.ts",
"./vs/platform/workspaces/electron-main/workspacesMainService.ts",
"./vs/platform/workspaces/node/workspaces.ts",
"./vs/platform/workspaces/node/workspacesIpc.ts",
"./vs/vscode.d.ts",
......@@ -529,6 +536,7 @@
"./vs/workbench/common/theme.ts",
"./vs/workbench/common/viewlet.ts",
"./vs/workbench/common/views.ts",
"./vs/workbench/parts/cli/electron-browser/cli.contribution.ts",
"./vs/workbench/parts/codeEditor/browser/menuPreventer.ts",
"./vs/workbench/parts/codeEditor/browser/simpleEditorOptions.ts",
"./vs/workbench/parts/codeEditor/electron-browser/accessibility.ts",
......@@ -549,6 +557,7 @@
"./vs/workbench/parts/emmet/electron-browser/emmetActions.ts",
"./vs/workbench/parts/emmet/test/electron-browser/emmetAction.test.ts",
"./vs/workbench/parts/execution/common/execution.ts",
"./vs/workbench/parts/execution/electron-browser/terminal.ts",
"./vs/workbench/parts/extensions/common/extensionQuery.ts",
"./vs/workbench/parts/extensions/common/extensions.ts",
"./vs/workbench/parts/extensions/common/extensionsFileTemplate.ts",
......@@ -593,6 +602,7 @@
"./vs/workbench/parts/terminal/node/terminal.ts",
"./vs/workbench/parts/terminal/node/terminalCommandTracker.ts",
"./vs/workbench/parts/terminal/node/terminalEnvironment.ts",
"./vs/workbench/parts/terminal/node/terminalProcess.ts",
"./vs/workbench/parts/terminal/node/terminalProcessExtHostProxy.ts",
"./vs/workbench/parts/url/electron-browser/url.contribution.ts",
"./vs/workbench/parts/webview/electron-browser/webviewProtocols.ts",
......
......@@ -50,7 +50,7 @@ export class LanguagePackCachedDataCleaner {
}
private _manageCachedDataSoon(): void {
let handle = setTimeout(async () => {
let handle: any = setTimeout(async () => {
handle = undefined;
this._logService.info('Starting to clean up unused language packs.');
const maxAge = product.nameLong.indexOf('Insiders') >= 0
......
......@@ -41,7 +41,7 @@ export class NodeCachedDataCleaner {
const nodeCachedDataRootDir = dirname(this._environmentService.nodeCachedDataDir);
const nodeCachedDataCurrent = basename(this._environmentService.nodeCachedDataDir);
let handle = setTimeout(() => {
let handle: any = setTimeout(() => {
handle = undefined;
readdir(nodeCachedDataRootDir).then(entries => {
......
......@@ -45,7 +45,7 @@ function findWindowOnFilePath<W extends ISimpleWindow>(windows: W[], fileUri: UR
const workspaceWindows = windows.filter(window => !!window.openedWorkspace);
for (let i = 0; i < workspaceWindows.length; i++) {
const window = workspaceWindows[i];
const resolvedWorkspace = workspaceResolver(window.openedWorkspace);
const resolvedWorkspace = workspaceResolver(window.openedWorkspace!);
if (resolvedWorkspace && resolvedWorkspace.folders.some(folder => isEqualOrParent(fileUri, folder.uri))) {
return window;
}
......@@ -54,7 +54,7 @@ function findWindowOnFilePath<W extends ISimpleWindow>(windows: W[], fileUri: UR
// Then go with single folder windows that are parent of the provided file path
const singleFolderWindowsOnFilePath = windows.filter(window => window.openedFolderUri && isEqualOrParent(fileUri, window.openedFolderUri));
if (singleFolderWindowsOnFilePath.length) {
return singleFolderWindowsOnFilePath.sort((a, b) => -(a.openedFolderUri.path.length - b.openedFolderUri.path.length))[0];
return singleFolderWindowsOnFilePath.sort((a, b) => -(a.openedFolderUri!.path.length - b.openedFolderUri!.path.length))[0];
}
return null;
......@@ -90,7 +90,7 @@ export function findWindowOnWorkspace<W extends ISimpleWindow>(windows: W[], wor
export function findWindowOnExtensionDevelopmentPath<W extends ISimpleWindow>(windows: W[], extensionDevelopmentPath: string): W | null {
for (const window of windows) {
// match on extension development path. The path can be a path or uri string, using paths.isEqual is not 100% correct but good enough
if (paths.isEqual(window.extensionDevelopmentPath, extensionDevelopmentPath, !platform.isLinux /* ignorecase */)) {
if (window.extensionDevelopmentPath && paths.isEqual(window.extensionDevelopmentPath, extensionDevelopmentPath, !platform.isLinux /* ignorecase */)) {
return window;
}
}
......
......@@ -7,14 +7,14 @@ import { URI } from 'vs/base/common/uri';
import { Range } from 'vs/editor/common/core/range';
import { ITextModel } from 'vs/editor/common/model';
import { IModelService } from 'vs/editor/common/services/modelService';
import { Node, build, find } from './tokenTree';
import { build, find } from './tokenTree';
import { Position } from 'vs/editor/common/core/position';
/**
* Interface used to compute a hierachry of logical ranges.
*/
export interface ILogicalSelectionEntry {
type: string;
type?: string;
range: Range;
}
......@@ -45,10 +45,9 @@ export class TokenSelectionSupport {
private _doGetRangesToPosition(model: ITextModel, position: Position): Range[] {
let tree = build(model);
let node: Node;
let lastRange: Range;
let lastRange: Range | undefined;
node = find(tree, position);
let node = find(tree, position);
let ranges: Range[] = [];
while (node) {
if (!lastRange || !Range.equalsRange(lastRange, node.range)) {
......
......@@ -86,7 +86,7 @@ export class DriverChannel implements IDriverChannel {
case 'writeInTerminal': return this.driver.writeInTerminal(arg[0], arg[1], arg[2]);
}
return undefined;
throw new Error(`Call not found: ${command}`);
}
}
......@@ -178,7 +178,7 @@ export class WindowDriverRegistryChannel implements IWindowDriverRegistryChannel
case 'reloadWindowDriver': return this.registry.reloadWindowDriver(arg);
}
return undefined;
throw new Error(`Call not found: ${command}`);
}
}
......@@ -243,7 +243,7 @@ export class WindowDriverChannel implements IWindowDriverChannel {
case 'writeInTerminal': return this.driver.writeInTerminal(arg[0], arg[1]);
}
return undefined;
throw new Error(`Call not found: ${command}`);
}
}
......
......@@ -85,9 +85,9 @@ export interface IWorkspacesMainService extends IWorkspacesService {
createWorkspaceSync(folders?: IWorkspaceFolderCreationData[]): IWorkspaceIdentifier;
resolveWorkspace(path: string): TPromise<IResolvedWorkspace>;
resolveWorkspace(path: string): TPromise<IResolvedWorkspace | null>;
resolveWorkspaceSync(path: string): IResolvedWorkspace;
resolveWorkspaceSync(path: string): IResolvedWorkspace | null;
isUntitledWorkspace(workspace: IWorkspaceIdentifier): boolean;
......
......@@ -50,7 +50,7 @@ export class WorkspacesMainService extends Disposable implements IWorkspacesMain
this.workspacesHome = environmentService.workspacesHome;
}
resolveWorkspace(path: string): TPromise<IResolvedWorkspace> {
resolveWorkspace(path: string): TPromise<IResolvedWorkspace | null> {
if (!this.isWorkspacePath(path)) {
return TPromise.as(null); // does not look like a valid workspace config file
}
......@@ -58,7 +58,7 @@ export class WorkspacesMainService extends Disposable implements IWorkspacesMain
return readFile(path, 'utf8').then(contents => this.doResolveWorkspace(path, contents));
}
resolveWorkspaceSync(path: string): IResolvedWorkspace {
resolveWorkspaceSync(path: string): IResolvedWorkspace | null {
if (!this.isWorkspacePath(path)) {
return null; // does not look like a valid workspace config file
}
......@@ -77,7 +77,7 @@ export class WorkspacesMainService extends Disposable implements IWorkspacesMain
return this.isInsideWorkspacesHome(path) || extname(path) === `.${WORKSPACE_EXTENSION}`;
}
private doResolveWorkspace(path: string, contents: string): IResolvedWorkspace {
private doResolveWorkspace(path: string, contents: string): IResolvedWorkspace | null {
try {
const workspace = this.doParseStoredWorkspace(path, contents);
......
......@@ -20,7 +20,7 @@ import Severity from 'vs/base/common/severity';
import { ILogService } from 'vs/platform/log/common/log';
import { getPathFromAmdModule } from 'vs/base/common/amd';
function ignore<T>(code: string, value: T | null = null): (err: any) => Promise<T> {
function ignore<T>(code: string, value: T): (err: any) => Promise<T> {
return err => err.code === code ? Promise.resolve<T>(value) : Promise.reject<T>(err);
}
......@@ -70,7 +70,7 @@ class InstallAction extends Action {
return Promise.resolve(null);
} else {
return pfs.unlink(this.target)
.then(null, ignore('ENOENT'))
.then(null, ignore('ENOENT', null))
.then(() => pfs.symlink(getSource(), this.target))
.then(null, err => {
if (err.code === 'EACCES' || err.code === 'ENOENT') {
......@@ -147,7 +147,7 @@ class UninstallAction extends Action {
const uninstall = () => {
return pfs.unlink(this.target)
.then(null, ignore('ENOENT'));
.then(null, ignore('ENOENT', null));
};
return uninstall().then(null, err => {
......
......@@ -11,7 +11,7 @@ export function getDefaultTerminalLinuxReady(): Promise<string> {
if (!_DEFAULT_TERMINAL_LINUX_READY) {
_DEFAULT_TERMINAL_LINUX_READY = new Promise<string>(c => {
if (env.isLinux) {
Promise.all([pfs.exists('/etc/debian_version'), process.lazyEnv]).then(([isDebian]) => {
Promise.all([pfs.exists('/etc/debian_version'), process.lazyEnv || Promise.resolve(void 0)]).then(([isDebian]) => {
if (isDebian) {
c('x-terminal-emulator');
} else if (process.env.DESKTOP_SESSION === 'gnome' || process.env.DESKTOP_SESSION === 'gnome-classic') {
......
......@@ -37,7 +37,7 @@ export class TerminalProcess implements ITerminalChildProcess, IDisposable {
) {
let shellName: string;
if (os.platform() === 'win32') {
shellName = path.basename(shellLaunchConfig.executable);
shellName = path.basename(shellLaunchConfig.executable || '');
} else {
// Using 'xterm-256color' here helps ensure that the majority of Linux distributions will use a
// color prompt as defined in the default ~/.bashrc file.
......@@ -53,7 +53,7 @@ export class TerminalProcess implements ITerminalChildProcess, IDisposable {
};
try {
this._ptyProcess = pty.spawn(shellLaunchConfig.executable, shellLaunchConfig.args, options);
this._ptyProcess = pty.spawn(shellLaunchConfig.executable!, shellLaunchConfig.args || [], options);
this._processStartupComplete = new Promise<void>(c => {
this.onProcessIdReady((pid) => {
c();
......
......@@ -51,7 +51,7 @@ export class SearchWorkerChannel implements ISearchWorkerChannel {
case 'search': return this.worker.search(arg);
case 'cancel': return this.worker.cancel();
}
return undefined;
throw new Error(`Call not found: ${command}`);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册