提交 6d973fef 编写于 作者: M Matt Bierner

Strict null work on main thread

上级 f9687fc5
...@@ -23,6 +23,6 @@ export interface IBulkEditResult { ...@@ -23,6 +23,6 @@ export interface IBulkEditResult {
export interface IBulkEditService { export interface IBulkEditService {
_serviceBrand: any; _serviceBrand: any;
apply(edit: WorkspaceEdit, options: IBulkEditOptions): Promise<IBulkEditResult>; apply(edit: WorkspaceEdit, options?: IBulkEditOptions): Promise<IBulkEditResult>;
} }
...@@ -576,7 +576,7 @@ export class SimpleBulkEditService implements IBulkEditService { ...@@ -576,7 +576,7 @@ export class SimpleBulkEditService implements IBulkEditService {
// //
} }
apply(workspaceEdit: WorkspaceEdit, options: IBulkEditOptions): Promise<IBulkEditResult> { apply(workspaceEdit: WorkspaceEdit, options?: IBulkEditOptions): Promise<IBulkEditResult> {
let edits = new Map<ITextModel, TextEdit[]>(); let edits = new Map<ITextModel, TextEdit[]>();
......
...@@ -419,7 +419,7 @@ export interface IBaseStat { ...@@ -419,7 +419,7 @@ export interface IBaseStat {
* A unique identifier thet represents the * A unique identifier thet represents the
* current state of the file or directory. * current state of the file or directory.
*/ */
etag: string; etag?: string;
/** /**
* The resource is readonly. * The resource is readonly.
......
...@@ -109,13 +109,17 @@ export class MainThreadDecorations implements MainThreadDecorationsShape { ...@@ -109,13 +109,17 @@ export class MainThreadDecorations implements MainThreadDecorationsShape {
} }
$onDidChange(handle: number, resources: UriComponents[]): void { $onDidChange(handle: number, resources: UriComponents[]): void {
const [emitter] = this._provider.get(handle); const provider = this._provider.get(handle);
emitter.fire(resources && resources.map(URI.revive)); if (provider) {
const [emitter] = provider;
emitter.fire(resources && resources.map(URI.revive));
}
} }
$unregisterDecorationProvider(handle: number): void { $unregisterDecorationProvider(handle: number): void {
if (this._provider.has(handle)) { const provider = this._provider.get(handle);
dispose(this._provider.get(handle)); if (provider) {
dispose(provider);
this._provider.delete(handle); this._provider.delete(handle);
} }
} }
......
...@@ -130,14 +130,14 @@ export class MainThreadDocuments implements MainThreadDocumentsShape { ...@@ -130,14 +130,14 @@ export class MainThreadDocuments implements MainThreadDocumentsShape {
private _shouldHandleFileEvent(e: TextFileModelChangeEvent): boolean { private _shouldHandleFileEvent(e: TextFileModelChangeEvent): boolean {
const model = this._modelService.getModel(e.resource); const model = this._modelService.getModel(e.resource);
return model && shouldSynchronizeModel(model); return !!model && shouldSynchronizeModel(model);
} }
private _onModelAdded(model: ITextModel): void { private _onModelAdded(model: ITextModel): void {
// Same filter as in mainThreadEditorsTracker // Same filter as in mainThreadEditorsTracker
if (!shouldSynchronizeModel(model)) { if (!shouldSynchronizeModel(model)) {
// don't synchronize too large models // don't synchronize too large models
return null; return;
} }
let modelUrl = model.uri; let modelUrl = model.uri;
this._modelIsSynced[modelUrl.toString()] = true; this._modelIsSynced[modelUrl.toString()] = true;
......
...@@ -7,7 +7,7 @@ import { Emitter, Event } from 'vs/base/common/event'; ...@@ -7,7 +7,7 @@ import { Emitter, Event } from 'vs/base/common/event';
import { IDisposable, combinedDisposable, dispose } from 'vs/base/common/lifecycle'; import { IDisposable, combinedDisposable, dispose } from 'vs/base/common/lifecycle';
import { values } from 'vs/base/common/map'; import { values } from 'vs/base/common/map';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
import { ICodeEditor, isCodeEditor, isDiffEditor } from 'vs/editor/browser/editorBrowser'; import { ICodeEditor, isCodeEditor, isDiffEditor, IActiveCodeEditor } from 'vs/editor/browser/editorBrowser';
import { IBulkEditService } from 'vs/editor/browser/services/bulkEditService'; import { IBulkEditService } from 'vs/editor/browser/services/bulkEditService';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { IEditor } from 'vs/editor/common/editorCommon'; import { IEditor } from 'vs/editor/common/editorCommon';
...@@ -70,7 +70,7 @@ class TextEditorSnapshot { ...@@ -70,7 +70,7 @@ class TextEditorSnapshot {
readonly id: string; readonly id: string;
constructor( constructor(
readonly editor: ICodeEditor, readonly editor: IActiveCodeEditor,
) { ) {
this.id = `${editor.getId()},${editor.getModel().id}`; this.id = `${editor.getId()},${editor.getModel().id}`;
} }
...@@ -85,8 +85,8 @@ class DocumentAndEditorStateDelta { ...@@ -85,8 +85,8 @@ class DocumentAndEditorStateDelta {
readonly addedDocuments: ITextModel[], readonly addedDocuments: ITextModel[],
readonly removedEditors: TextEditorSnapshot[], readonly removedEditors: TextEditorSnapshot[],
readonly addedEditors: TextEditorSnapshot[], readonly addedEditors: TextEditorSnapshot[],
readonly oldActiveEditor: string, readonly oldActiveEditor: string | undefined,
readonly newActiveEditor: string, readonly newActiveEditor: string | undefined,
) { ) {
this.isEmpty = this.removedDocuments.length === 0 this.isEmpty = this.removedDocuments.length === 0
&& this.addedDocuments.length === 0 && this.addedDocuments.length === 0
...@@ -131,7 +131,7 @@ class DocumentAndEditorState { ...@@ -131,7 +131,7 @@ class DocumentAndEditorState {
constructor( constructor(
readonly documents: Set<ITextModel>, readonly documents: Set<ITextModel>,
readonly textEditors: Map<string, TextEditorSnapshot>, readonly textEditors: Map<string, TextEditorSnapshot>,
readonly activeEditor: string, readonly activeEditor: string | undefined,
) { ) {
// //
} }
...@@ -230,14 +230,14 @@ class MainThreadDocumentAndEditorStateComputer { ...@@ -230,14 +230,14 @@ class MainThreadDocumentAndEditorStateComputer {
// editor: only take those that have a not too large model // editor: only take those that have a not too large model
const editors = new Map<string, TextEditorSnapshot>(); const editors = new Map<string, TextEditorSnapshot>();
let activeEditor: string | null = null; let activeEditor: string | undefined = undefined;
for (const editor of this._codeEditorService.listCodeEditors()) { for (const editor of this._codeEditorService.listCodeEditors()) {
if (editor.isSimpleWidget) { if (editor.isSimpleWidget) {
continue; continue;
} }
const model = editor.getModel(); const model = editor.getModel();
if (model && shouldSynchronizeModel(model) if (editor.hasModel() && model && shouldSynchronizeModel(model)
&& !model.isDisposed() // model disposed && !model.isDisposed() // model disposed
&& Boolean(this._modelService.getModel(model.uri)) // model disposing, the flag didn't flip yet but the model service already removed it && Boolean(this._modelService.getModel(model.uri)) // model disposing, the flag didn't flip yet but the model service already removed it
) { ) {
...@@ -282,7 +282,7 @@ class MainThreadDocumentAndEditorStateComputer { ...@@ -282,7 +282,7 @@ class MainThreadDocumentAndEditorStateComputer {
} }
} }
private _getActiveEditorFromPanel(): IEditor { private _getActiveEditorFromPanel(): IEditor | undefined {
let panel = this._panelService.getActivePanel(); let panel = this._panelService.getActivePanel();
if (panel instanceof BaseTextEditor && isCodeEditor(panel.getControl())) { if (panel instanceof BaseTextEditor && isCodeEditor(panel.getControl())) {
return panel.getControl(); return panel.getControl();
...@@ -444,8 +444,8 @@ export class MainThreadDocumentsAndEditors { ...@@ -444,8 +444,8 @@ export class MainThreadDocumentsAndEditors {
}; };
} }
private _findEditorPosition(editor: MainThreadTextEditor): EditorViewColumn { private _findEditorPosition(editor: MainThreadTextEditor): EditorViewColumn | undefined {
for (let workbenchEditor of this._editorService.visibleControls) { for (const workbenchEditor of this._editorService.visibleControls) {
if (editor.matches(workbenchEditor)) { if (editor.matches(workbenchEditor)) {
return editorGroupToViewColumn(this._editorGroupService, workbenchEditor.group); return editorGroupToViewColumn(this._editorGroupService, workbenchEditor.group);
} }
...@@ -453,8 +453,8 @@ export class MainThreadDocumentsAndEditors { ...@@ -453,8 +453,8 @@ export class MainThreadDocumentsAndEditors {
return undefined; return undefined;
} }
findTextEditorIdFor(editor: IWorkbenchEditor): string { findTextEditorIdFor(editor: IWorkbenchEditor): string | undefined {
for (let id in this._textEditors) { for (const id in this._textEditors) {
if (this._textEditors[id].matches(editor)) { if (this._textEditors[id].matches(editor)) {
return id; return id;
} }
......
...@@ -187,7 +187,7 @@ export class MainThreadTextEditor { ...@@ -187,7 +187,7 @@ export class MainThreadTextEditor {
private _focusTracker: IFocusTracker; private _focusTracker: IFocusTracker;
private _codeEditorListeners: IDisposable[]; private _codeEditorListeners: IDisposable[];
private _properties: MainThreadTextEditorProperties | null; private _properties: MainThreadTextEditorProperties;
private readonly _onPropertiesChanged: Emitter<IEditorPropertiesChangeData>; private readonly _onPropertiesChanged: Emitter<IEditorPropertiesChangeData>;
constructor( constructor(
...@@ -204,7 +204,6 @@ export class MainThreadTextEditor { ...@@ -204,7 +204,6 @@ export class MainThreadTextEditor {
this._modelService = modelService; this._modelService = modelService;
this._codeEditorListeners = []; this._codeEditorListeners = [];
this._properties = null;
this._onPropertiesChanged = new Emitter<IEditorPropertiesChangeData>(); this._onPropertiesChanged = new Emitter<IEditorPropertiesChangeData>();
this._modelListeners = []; this._modelListeners = [];
...@@ -300,7 +299,7 @@ export class MainThreadTextEditor { ...@@ -300,7 +299,7 @@ export class MainThreadTextEditor {
return !!this._codeEditor; return !!this._codeEditor;
} }
public getProperties(): MainThreadTextEditorProperties | null { public getProperties(): MainThreadTextEditorProperties {
return this._properties; return this._properties;
} }
...@@ -316,7 +315,7 @@ export class MainThreadTextEditor { ...@@ -316,7 +315,7 @@ export class MainThreadTextEditor {
const newSelections = selections.map(Selection.liftSelection); const newSelections = selections.map(Selection.liftSelection);
this._setProperties( this._setProperties(
new MainThreadTextEditorProperties(newSelections, this._properties!.options, this._properties!.visibleRanges), new MainThreadTextEditorProperties(newSelections, this._properties.options, this._properties.visibleRanges),
null null
); );
} }
......
...@@ -36,7 +36,7 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape { ...@@ -36,7 +36,7 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
private _documentsAndEditors: MainThreadDocumentsAndEditors; private _documentsAndEditors: MainThreadDocumentsAndEditors;
private _toDispose: IDisposable[]; private _toDispose: IDisposable[];
private _textEditorsListenersMap: { [editorId: string]: IDisposable[]; }; private _textEditorsListenersMap: { [editorId: string]: IDisposable[]; };
private _editorPositionData: ITextEditorPositionData; private _editorPositionData: ITextEditorPositionData | null;
private _registeredDecorationTypes: { [decorationType: string]: boolean; }; private _registeredDecorationTypes: { [decorationType: string]: boolean; };
constructor( constructor(
...@@ -145,7 +145,7 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape { ...@@ -145,7 +145,7 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
options: { preserveFocus: false } options: { preserveFocus: false }
}, viewColumnToEditorGroup(this._editorGroupService, position)).then(() => { return; }); }, viewColumnToEditorGroup(this._editorGroupService, position)).then(() => { return; });
} }
return undefined; return Promise.resolve();
} }
$tryHideEditor(id: string): Promise<void> { $tryHideEditor(id: string): Promise<void> {
...@@ -158,7 +158,7 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape { ...@@ -158,7 +158,7 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
} }
} }
} }
return undefined; return Promise.resolve();
} }
$trySetSelections(id: string, selections: ISelection[]): Promise<void> { $trySetSelections(id: string, selections: ISelection[]): Promise<void> {
...@@ -192,7 +192,7 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape { ...@@ -192,7 +192,7 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
return Promise.reject(disposed(`TextEditor(${id})`)); return Promise.reject(disposed(`TextEditor(${id})`));
} }
this._documentsAndEditors.getEditor(id).revealRange(range, revealType); this._documentsAndEditors.getEditor(id).revealRange(range, revealType);
return undefined; return Promise.resolve();
} }
$trySetOptions(id: string, options: ITextEditorConfigurationUpdate): Promise<void> { $trySetOptions(id: string, options: ITextEditorConfigurationUpdate): Promise<void> {
......
...@@ -198,7 +198,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha ...@@ -198,7 +198,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
$registerHoverProvider(handle: number, selector: ISerializedDocumentFilter[]): void { $registerHoverProvider(handle: number, selector: ISerializedDocumentFilter[]): void {
this._registrations[handle] = modes.HoverProviderRegistry.register(typeConverters.LanguageSelector.from(selector), <modes.HoverProvider>{ this._registrations[handle] = modes.HoverProviderRegistry.register(typeConverters.LanguageSelector.from(selector), <modes.HoverProvider>{
provideHover: (model: ITextModel, position: EditorPosition, token: CancellationToken): Promise<modes.Hover> => { provideHover: (model: ITextModel, position: EditorPosition, token: CancellationToken): Promise<modes.Hover | undefined> => {
return this._proxy.$provideHover(handle, model.uri, position, token); return this._proxy.$provideHover(handle, model.uri, position, token);
} }
}); });
...@@ -208,7 +208,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha ...@@ -208,7 +208,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
$registerDocumentHighlightProvider(handle: number, selector: ISerializedDocumentFilter[]): void { $registerDocumentHighlightProvider(handle: number, selector: ISerializedDocumentFilter[]): void {
this._registrations[handle] = modes.DocumentHighlightProviderRegistry.register(typeConverters.LanguageSelector.from(selector), <modes.DocumentHighlightProvider>{ this._registrations[handle] = modes.DocumentHighlightProviderRegistry.register(typeConverters.LanguageSelector.from(selector), <modes.DocumentHighlightProvider>{
provideDocumentHighlights: (model: ITextModel, position: EditorPosition, token: CancellationToken): Promise<modes.DocumentHighlight[]> => { provideDocumentHighlights: (model: ITextModel, position: EditorPosition, token: CancellationToken): Promise<modes.DocumentHighlight[] | undefined> => {
return this._proxy.$provideDocumentHighlights(handle, model.uri, position, token); return this._proxy.$provideDocumentHighlights(handle, model.uri, position, token);
} }
}); });
...@@ -243,7 +243,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha ...@@ -243,7 +243,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
$registerDocumentFormattingSupport(handle: number, selector: ISerializedDocumentFilter[], displayName: string): void { $registerDocumentFormattingSupport(handle: number, selector: ISerializedDocumentFilter[], displayName: string): void {
this._registrations[handle] = modes.DocumentFormattingEditProviderRegistry.register(typeConverters.LanguageSelector.from(selector), <modes.DocumentFormattingEditProvider>{ this._registrations[handle] = modes.DocumentFormattingEditProviderRegistry.register(typeConverters.LanguageSelector.from(selector), <modes.DocumentFormattingEditProvider>{
displayName, displayName,
provideDocumentFormattingEdits: (model: ITextModel, options: modes.FormattingOptions, token: CancellationToken): Promise<ISingleEditOperation[]> => { provideDocumentFormattingEdits: (model: ITextModel, options: modes.FormattingOptions, token: CancellationToken): Promise<ISingleEditOperation[] | undefined> => {
return this._proxy.$provideDocumentFormattingEdits(handle, model.uri, options, token); return this._proxy.$provideDocumentFormattingEdits(handle, model.uri, options, token);
} }
}); });
...@@ -252,7 +252,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha ...@@ -252,7 +252,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
$registerRangeFormattingSupport(handle: number, selector: ISerializedDocumentFilter[], displayName: string): void { $registerRangeFormattingSupport(handle: number, selector: ISerializedDocumentFilter[], displayName: string): void {
this._registrations[handle] = modes.DocumentRangeFormattingEditProviderRegistry.register(typeConverters.LanguageSelector.from(selector), <modes.DocumentRangeFormattingEditProvider>{ this._registrations[handle] = modes.DocumentRangeFormattingEditProviderRegistry.register(typeConverters.LanguageSelector.from(selector), <modes.DocumentRangeFormattingEditProvider>{
displayName, displayName,
provideDocumentRangeFormattingEdits: (model: ITextModel, range: EditorRange, options: modes.FormattingOptions, token: CancellationToken): Promise<ISingleEditOperation[]> => { provideDocumentRangeFormattingEdits: (model: ITextModel, range: EditorRange, options: modes.FormattingOptions, token: CancellationToken): Promise<ISingleEditOperation[] | undefined> => {
return this._proxy.$provideDocumentRangeFormattingEdits(handle, model.uri, range, options, token); return this._proxy.$provideDocumentRangeFormattingEdits(handle, model.uri, range, options, token);
} }
}); });
...@@ -263,7 +263,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha ...@@ -263,7 +263,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
autoFormatTriggerCharacters, autoFormatTriggerCharacters,
provideOnTypeFormattingEdits: (model: ITextModel, position: EditorPosition, ch: string, options: modes.FormattingOptions, token: CancellationToken): Promise<ISingleEditOperation[]> => { provideOnTypeFormattingEdits: (model: ITextModel, position: EditorPosition, ch: string, options: modes.FormattingOptions, token: CancellationToken): Promise<ISingleEditOperation[] | undefined> => {
return this._proxy.$provideOnTypeFormattingEdits(handle, model.uri, position, ch, options, token); return this._proxy.$provideOnTypeFormattingEdits(handle, model.uri, position, ch, options, token);
} }
}); });
...@@ -272,7 +272,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha ...@@ -272,7 +272,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
// --- navigate type // --- navigate type
$registerNavigateTypeSupport(handle: number): void { $registerNavigateTypeSupport(handle: number): void {
let lastResultId: number; let lastResultId: number | undefined;
this._registrations[handle] = search.WorkspaceSymbolProviderRegistry.register(<search.IWorkspaceSymbolProvider>{ this._registrations[handle] = search.WorkspaceSymbolProviderRegistry.register(<search.IWorkspaceSymbolProvider>{
provideWorkspaceSymbols: (search: string, token: CancellationToken): Promise<search.IWorkspaceSymbol[]> => { provideWorkspaceSymbols: (search: string, token: CancellationToken): Promise<search.IWorkspaceSymbol[]> => {
return this._proxy.$provideWorkspaceSymbols(handle, search, token).then(result => { return this._proxy.$provideWorkspaceSymbols(handle, search, token).then(result => {
...@@ -298,7 +298,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha ...@@ -298,7 +298,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
return this._proxy.$provideRenameEdits(handle, model.uri, position, newName, token).then(reviveWorkspaceEditDto); return this._proxy.$provideRenameEdits(handle, model.uri, position, newName, token).then(reviveWorkspaceEditDto);
}, },
resolveRenameLocation: supportResolveLocation resolveRenameLocation: supportResolveLocation
? (model: ITextModel, position: EditorPosition, token: CancellationToken): Promise<modes.RenameLocation> => this._proxy.$resolveRenameLocation(handle, model.uri, position, token) ? (model: ITextModel, position: EditorPosition, token: CancellationToken): Promise<modes.RenameLocation | undefined> => this._proxy.$resolveRenameLocation(handle, model.uri, position, token)
: undefined : undefined
}); });
} }
......
...@@ -45,7 +45,10 @@ export class MainThreadTreeViews extends Disposable implements MainThreadTreeVie ...@@ -45,7 +45,10 @@ export class MainThreadTreeViews extends Disposable implements MainThreadTreeVie
return this.viewsService.openView(treeViewId, options.focus) return this.viewsService.openView(treeViewId, options.focus)
.then(() => { .then(() => {
const viewer = this.getTreeView(treeViewId); const viewer = this.getTreeView(treeViewId);
return this.reveal(viewer, this._dataProviders.get(treeViewId), item, parentChain, options); if (viewer) {
return this.reveal(viewer, this._dataProviders.get(treeViewId)!, item, parentChain, options);
}
return undefined;
}); });
} }
...@@ -56,7 +59,7 @@ export class MainThreadTreeViews extends Disposable implements MainThreadTreeVie ...@@ -56,7 +59,7 @@ export class MainThreadTreeViews extends Disposable implements MainThreadTreeVie
const itemsToRefresh = dataProvider.getItemsToRefresh(itemsToRefreshByHandle); const itemsToRefresh = dataProvider.getItemsToRefresh(itemsToRefreshByHandle);
return viewer.refresh(itemsToRefresh.length ? itemsToRefresh : undefined); return viewer.refresh(itemsToRefresh.length ? itemsToRefresh : undefined);
} }
return null; return Promise.resolve();
} }
$setMessage(treeViewId: string, message: string | IMarkdownString): void { $setMessage(treeViewId: string, message: string | IMarkdownString): void {
......
...@@ -68,14 +68,14 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv ...@@ -68,14 +68,14 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
handle: WebviewPanelHandle, handle: WebviewPanelHandle,
viewType: string, viewType: string,
title: string, title: string,
showOptions: { viewColumn: EditorViewColumn | null, preserveFocus: boolean }, showOptions: { viewColumn?: EditorViewColumn, preserveFocus?: boolean },
options: WebviewInputOptions, options: WebviewInputOptions,
extensionId: ExtensionIdentifier, extensionId: ExtensionIdentifier,
extensionLocation: UriComponents extensionLocation: UriComponents
): void { ): void {
const mainThreadShowOptions: ICreateWebViewShowOptions = Object.create(null); const mainThreadShowOptions: ICreateWebViewShowOptions = Object.create(null);
if (showOptions) { if (showOptions) {
mainThreadShowOptions.preserveFocus = showOptions.preserveFocus; mainThreadShowOptions.preserveFocus = !!showOptions.preserveFocus;
mainThreadShowOptions.group = viewColumnToEditorGroup(this._editorGroupService, showOptions.viewColumn); mainThreadShowOptions.group = viewColumnToEditorGroup(this._editorGroupService, showOptions.viewColumn);
} }
...@@ -129,7 +129,7 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv ...@@ -129,7 +129,7 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
const targetGroup = this._editorGroupService.getGroup(viewColumnToEditorGroup(this._editorGroupService, showOptions.viewColumn)); const targetGroup = this._editorGroupService.getGroup(viewColumnToEditorGroup(this._editorGroupService, showOptions.viewColumn));
this._webviewService.revealWebview(webview, targetGroup || this._editorGroupService.activeGroup, showOptions.preserveFocus); this._webviewService.revealWebview(webview, targetGroup || this._editorGroupService.activeGroup, !!showOptions.preserveFocus);
} }
public $postMessage(handle: WebviewPanelHandle, message: any): Promise<boolean> { public $postMessage(handle: WebviewPanelHandle, message: any): Promise<boolean> {
...@@ -137,7 +137,7 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv ...@@ -137,7 +137,7 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
const editors = this._editorService.visibleControls const editors = this._editorService.visibleControls
.filter(e => e instanceof WebviewEditor) .filter(e => e instanceof WebviewEditor)
.map(e => e as WebviewEditor) .map(e => e as WebviewEditor)
.filter(e => e.input.matches(webview)); .filter(e => e.input!.matches(webview));
for (const editor of editors) { for (const editor of editors) {
editor.sendMessage(message); editor.sendMessage(message);
...@@ -216,7 +216,7 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv ...@@ -216,7 +216,7 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
let newActiveWebview: { input: WebviewEditorInput, handle: WebviewPanelHandle } | undefined = undefined; let newActiveWebview: { input: WebviewEditorInput, handle: WebviewPanelHandle } | undefined = undefined;
if (activeEditor && activeEditor.input instanceof WebviewEditorInput) { if (activeEditor && activeEditor.input instanceof WebviewEditorInput) {
for (const handle of map.keys(this._webviews)) { for (const handle of map.keys(this._webviews)) {
const input = this._webviews.get(handle); const input = this._webviews.get(handle)!;
if (input.matches(activeEditor.input)) { if (input.matches(activeEditor.input)) {
newActiveWebview = { input, handle }; newActiveWebview = { input, handle };
break; break;
...@@ -240,7 +240,7 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv ...@@ -240,7 +240,7 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
if (oldActiveWebview) { if (oldActiveWebview) {
this._proxy.$onDidChangeWebviewPanelViewState(this._activeWebview, { this._proxy.$onDidChangeWebviewPanelViewState(this._activeWebview, {
active: false, active: false,
visible: this._editorService.visibleControls.some(editor => editor.input && editor.input.matches(oldActiveWebview)), visible: this._editorService.visibleControls.some(editor => !!editor.input && editor.input.matches(oldActiveWebview)),
position: editorGroupToViewColumn(this._editorGroupService, oldActiveWebview.group), position: editorGroupToViewColumn(this._editorGroupService, oldActiveWebview.group),
}); });
} }
......
...@@ -443,7 +443,7 @@ export namespace TextEdit { ...@@ -443,7 +443,7 @@ export namespace TextEdit {
export function to(edit: modes.TextEdit): types.TextEdit { export function to(edit: modes.TextEdit): types.TextEdit {
const result = new types.TextEdit(Range.to(edit.range), edit.text); const result = new types.TextEdit(Range.to(edit.range), edit.text);
result.newEol = typeof edit.eol === 'undefined' ? undefined : EndOfLine.to(edit.eol); result.newEol = (typeof edit.eol === 'undefined' ? undefined : EndOfLine.to(edit.eol))!;
return result; return result;
} }
} }
...@@ -457,7 +457,7 @@ export namespace WorkspaceEdit { ...@@ -457,7 +457,7 @@ export namespace WorkspaceEdit {
const [uri, uriOrEdits] = entry; const [uri, uriOrEdits] = entry;
if (Array.isArray(uriOrEdits)) { if (Array.isArray(uriOrEdits)) {
// text edits // text edits
const doc = documents ? documents.getDocument(uri.toString()) : undefined; const doc = documents && uri ? documents.getDocument(uri.toString()) : undefined;
result.edits.push(<ResourceTextEditDto>{ resource: uri, modelVersionId: doc && doc.version, edits: uriOrEdits.map(TextEdit.from) }); result.edits.push(<ResourceTextEditDto>{ resource: uri, modelVersionId: doc && doc.version, edits: uriOrEdits.map(TextEdit.from) });
} else { } else {
// resource edits // resource edits
...@@ -986,6 +986,9 @@ export namespace GlobPattern { ...@@ -986,6 +986,9 @@ export namespace GlobPattern {
export namespace LanguageSelector { export namespace LanguageSelector {
export function from(selector: undefined): undefined;
export function from(selector: vscode.DocumentSelector): languageSelector.LanguageSelector;
export function from(selector: vscode.DocumentSelector | undefined): languageSelector.LanguageSelector | undefined;
export function from(selector: vscode.DocumentSelector | undefined): languageSelector.LanguageSelector | undefined { export function from(selector: vscode.DocumentSelector | undefined): languageSelector.LanguageSelector | undefined {
if (!selector) { if (!selector) {
return undefined; return undefined;
...@@ -997,7 +1000,7 @@ export namespace LanguageSelector { ...@@ -997,7 +1000,7 @@ export namespace LanguageSelector {
return <languageSelector.LanguageFilter>{ return <languageSelector.LanguageFilter>{
language: selector.language, language: selector.language,
scheme: selector.scheme, scheme: selector.scheme,
pattern: GlobPattern.from(selector.pattern), pattern: typeof selector.pattern === 'undefined' ? undefined : GlobPattern.from(selector.pattern),
exclusive: selector.exclusive exclusive: selector.exclusive
}; };
} }
......
...@@ -948,9 +948,9 @@ export class SymbolInformation { ...@@ -948,9 +948,9 @@ export class SymbolInformation {
kind: SymbolKind; kind: SymbolKind;
containerName: string | undefined; containerName: string | undefined;
constructor(name: string, kind: SymbolKind, containerName: string, location: Location); constructor(name: string, kind: SymbolKind, containerName: string | undefined, location: Location);
constructor(name: string, kind: SymbolKind, range: Range, uri?: URI, containerName?: string); constructor(name: string, kind: SymbolKind, range: Range, uri?: URI, containerName?: string);
constructor(name: string, kind: SymbolKind, rangeOrContainer: string | Range, locationOrUri?: Location | URI, containerName?: string) { constructor(name: string, kind: SymbolKind, rangeOrContainer: string | undefined | Range, locationOrUri?: Location | URI, containerName?: string) {
this.name = name; this.name = name;
this.kind = kind; this.kind = kind;
this.containerName = containerName; this.containerName = containerName;
......
...@@ -27,7 +27,7 @@ export interface IResourceDescriptor { ...@@ -27,7 +27,7 @@ export interface IResourceDescriptor {
readonly resource: URI; readonly resource: URI;
readonly name: string; readonly name: string;
readonly size: number; readonly size: number;
readonly etag: string; readonly etag?: string;
readonly mime: string; readonly mime: string;
} }
......
...@@ -16,7 +16,7 @@ export class BinaryEditorModel extends EditorModel { ...@@ -16,7 +16,7 @@ export class BinaryEditorModel extends EditorModel {
private name: string; private name: string;
private resource: URI; private resource: URI;
private size: number; private size: number;
private etag: string; private etag?: string;
private mime: string; private mime: string;
constructor( constructor(
...@@ -70,7 +70,7 @@ export class BinaryEditorModel extends EditorModel { ...@@ -70,7 +70,7 @@ export class BinaryEditorModel extends EditorModel {
/** /**
* The etag of the binary resource if known. * The etag of the binary resource if known.
*/ */
getETag(): string { getETag(): string | undefined {
return this.etag; return this.etag;
} }
......
...@@ -31,7 +31,7 @@ export interface IDecoration { ...@@ -31,7 +31,7 @@ export interface IDecoration {
export interface IDecorationsProvider { export interface IDecorationsProvider {
readonly label: string; readonly label: string;
readonly onDidChange: Event<URI[]>; readonly onDidChange: Event<URI[]>;
provideDecorations(uri: URI, token: CancellationToken): IDecorationData | Promise<IDecorationData> | undefined; provideDecorations(uri: URI, token: CancellationToken): IDecorationData | Promise<IDecorationData | undefined> | undefined;
} }
export interface IResourceDecorationChangeEvent { export interface IResourceDecorationChangeEvent {
......
...@@ -301,7 +301,7 @@ class DecorationProviderWrapper { ...@@ -301,7 +301,7 @@ class DecorationProviderWrapper {
const source = new CancellationTokenSource(); const source = new CancellationTokenSource();
const dataOrThenable = this._provider.provideDecorations(uri, source.token); const dataOrThenable = this._provider.provideDecorations(uri, source.token);
if (!isThenable(dataOrThenable)) { if (!isThenable<IDecorationData | Promise<IDecorationData | undefined> | undefined>(dataOrThenable)) {
// sync -> we have a result now // sync -> we have a result now
return this._keepItem(uri, dataOrThenable); return this._keepItem(uri, dataOrThenable);
......
...@@ -37,13 +37,13 @@ const NO_OP_VOID_PROMISE = Promise.resolve<void>(undefined); ...@@ -37,13 +37,13 @@ const NO_OP_VOID_PROMISE = Promise.resolve<void>(undefined);
schema.properties.engines.properties.vscode.default = `^${pkg.version}`; schema.properties.engines.properties.vscode.default = `^${pkg.version}`;
let productAllowProposedApi: Set<string> = null; let productAllowProposedApi: Set<string> | null = null;
function allowProposedApiFromProduct(id: ExtensionIdentifier): boolean { function allowProposedApiFromProduct(id: ExtensionIdentifier): boolean {
// create set if needed // create set if needed
if (productAllowProposedApi === null) { if (!productAllowProposedApi) {
productAllowProposedApi = new Set<string>(); productAllowProposedApi = new Set<string>();
if (isNonEmptyArray(product.extensionAllowedProposedApi)) { if (isNonEmptyArray(product.extensionAllowedProposedApi)) {
product.extensionAllowedProposedApi.forEach((id) => productAllowProposedApi.add(ExtensionIdentifier.toKey(id))); product.extensionAllowedProposedApi.forEach((id) => productAllowProposedApi!.add(ExtensionIdentifier.toKey(id)));
} }
} }
return productAllowProposedApi.has(ExtensionIdentifier.toKey(id)); return productAllowProposedApi.has(ExtensionIdentifier.toKey(id));
...@@ -167,7 +167,7 @@ export class ExtensionService extends Disposable implements IExtensionService { ...@@ -167,7 +167,7 @@ export class ExtensionService extends Disposable implements IExtensionService {
} }
while (this._deltaExtensionsQueue.length > 0) { while (this._deltaExtensionsQueue.length > 0) {
const item = this._deltaExtensionsQueue.shift(); const item = this._deltaExtensionsQueue.shift()!;
try { try {
this._inHandleDeltaExtensions = true; this._inHandleDeltaExtensions = true;
await this._deltaExtensions(item.toAdd, item.toRemove); await this._deltaExtensions(item.toAdd, item.toRemove);
...@@ -856,7 +856,7 @@ export class ExtensionService extends Disposable implements IExtensionService { ...@@ -856,7 +856,7 @@ export class ExtensionService extends Disposable implements IExtensionService {
if (!this._extensionsMessages.has(extensionKey)) { if (!this._extensionsMessages.has(extensionKey)) {
this._extensionsMessages.set(extensionKey, []); this._extensionsMessages.set(extensionKey, []);
} }
this._extensionsMessages.get(extensionKey).push({ this._extensionsMessages.get(extensionKey)!.push({
type: severity, type: severity,
message: message, message: message,
extensionId: null, extensionId: null,
......
...@@ -189,8 +189,8 @@ export class ExtensionDescriptionRegistry { ...@@ -189,8 +189,8 @@ export class ExtensionDescriptionRegistry {
return this._extensionsArr.slice(0); return this._extensionsArr.slice(0);
} }
public getExtensionDescription(extensionId: ExtensionIdentifier | string): IExtensionDescription | null { public getExtensionDescription(extensionId: ExtensionIdentifier | string): IExtensionDescription | undefined {
const extension = this._extensionsMap.get(ExtensionIdentifier.toKey(extensionId)); const extension = this._extensionsMap.get(ExtensionIdentifier.toKey(extensionId));
return extension ? extension : null; return extension ? extension : undefined;
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册