Use URI for ExtHostDocumentsShape methods

This commit is contained in:
Alex Dima
2018-02-07 17:14:18 +01:00
parent 5b1d34e435
commit f322baeb66
4 changed files with 26 additions and 18 deletions
@@ -104,17 +104,17 @@ export class MainThreadDocuments implements MainThreadDocumentsShape {
this._toDispose.push(textFileService.models.onModelSaved(e => {
if (this._shouldHandleFileEvent(e)) {
this._proxy.$acceptModelSaved(e.resource.toString());
this._proxy.$acceptModelSaved(e.resource);
}
}));
this._toDispose.push(textFileService.models.onModelReverted(e => {
if (this._shouldHandleFileEvent(e)) {
this._proxy.$acceptDirtyStateChanged(e.resource.toString(), false);
this._proxy.$acceptDirtyStateChanged(e.resource, false);
}
}));
this._toDispose.push(textFileService.models.onModelDirty(e => {
if (this._shouldHandleFileEvent(e)) {
this._proxy.$acceptDirtyStateChanged(e.resource.toString(), true);
this._proxy.$acceptDirtyStateChanged(e.resource, true);
}
}));
@@ -143,7 +143,7 @@ export class MainThreadDocuments implements MainThreadDocumentsShape {
let modelUrl = model.uri;
this._modelIsSynced[modelUrl.toString()] = true;
this._modelToDisposeMap[modelUrl.toString()] = model.onDidChangeContent((e) => {
this._proxy.$acceptModelChanged(modelUrl.toString(), e, this._textFileService.isDirty(modelUrl));
this._proxy.$acceptModelChanged(modelUrl, e, this._textFileService.isDirty(modelUrl));
});
}
@@ -153,7 +153,7 @@ export class MainThreadDocuments implements MainThreadDocumentsShape {
if (!this._modelIsSynced[modelUrl.toString()]) {
return;
}
this._proxy.$acceptModelModeChanged(model.uri.toString(), oldModeId, model.getLanguageIdentifier().language);
this._proxy.$acceptModelModeChanged(model.uri, oldModeId, model.getLanguageIdentifier().language);
}
private _onModelRemoved(modelUrl: URI): void {
@@ -227,7 +227,7 @@ export class MainThreadDocuments implements MainThreadDocumentsShape {
throw new Error(`expected URI ${resource.toString()} to have come to LIFE`);
}
this._proxy.$acceptDirtyStateChanged(resource.toString(), true); // mark as dirty
this._proxy.$acceptDirtyStateChanged(resource, true); // mark as dirty
return resource;
});
@@ -479,10 +479,10 @@ export interface IModelAddedData {
isDirty: boolean;
}
export interface ExtHostDocumentsShape {
$acceptModelModeChanged(strURL: string, oldModeId: string, newModeId: string): void;
$acceptModelSaved(strURL: string): void;
$acceptDirtyStateChanged(strURL: string, isDirty: boolean): void;
$acceptModelChanged(strURL: string, e: IModelChangedEvent, isDirty: boolean): void;
$acceptModelModeChanged(strURL: UriComponents, oldModeId: string, newModeId: string): void;
$acceptModelSaved(strURL: UriComponents): void;
$acceptDirtyStateChanged(strURL: UriComponents, isDirty: boolean): void;
$acceptModelChanged(strURL: UriComponents, e: IModelChangedEvent, isDirty: boolean): void;
}
export interface ExtHostDocumentSaveParticipantShape {
+14 -6
View File
@@ -5,7 +5,7 @@
'use strict';
import Event, { Emitter } from 'vs/base/common/event';
import URI from 'vs/base/common/uri';
import URI, { UriComponents } from 'vs/base/common/uri';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import * as TypeConverters from './extHostTypeConverters';
import { TPromise } from 'vs/base/common/winjs.base';
@@ -95,7 +95,9 @@ export class ExtHostDocuments implements ExtHostDocumentsShape {
return this._proxy.$tryCreateDocument(options).then(data => URI.revive(data));
}
public $acceptModelModeChanged(strURL: string, oldModeId: string, newModeId: string): void {
public $acceptModelModeChanged(uriComponents: UriComponents, oldModeId: string, newModeId: string): void {
const uri = URI.revive(uriComponents);
const strURL = uri.toString();
let data = this._documentsAndEditors.getDocument(strURL);
// Treat a mode change as a remove + add
@@ -105,13 +107,17 @@ export class ExtHostDocuments implements ExtHostDocumentsShape {
this._onDidAddDocument.fire(data.document);
}
public $acceptModelSaved(strURL: string): void {
public $acceptModelSaved(uriComponents: UriComponents): void {
const uri = URI.revive(uriComponents);
const strURL = uri.toString();
let data = this._documentsAndEditors.getDocument(strURL);
this.$acceptDirtyStateChanged(strURL, false);
this.$acceptDirtyStateChanged(uriComponents, false);
this._onDidSaveDocument.fire(data.document);
}
public $acceptDirtyStateChanged(strURL: string, isDirty: boolean): void {
public $acceptDirtyStateChanged(uriComponents: UriComponents, isDirty: boolean): void {
const uri = URI.revive(uriComponents);
const strURL = uri.toString();
let data = this._documentsAndEditors.getDocument(strURL);
data._acceptIsDirty(isDirty);
this._onDidChangeDocument.fire({
@@ -120,7 +126,9 @@ export class ExtHostDocuments implements ExtHostDocumentsShape {
});
}
public $acceptModelChanged(strURL: string, events: IModelChangedEvent, isDirty: boolean): void {
public $acceptModelChanged(uriComponents: UriComponents, events: IModelChangedEvent, isDirty: boolean): void {
const uri = URI.revive(uriComponents);
const strURL = uri.toString();
let data = this._documentsAndEditors.getDocument(strURL);
data._acceptIsDirty(isDirty);
data.onEvents(events);