提交 f322baeb 编写于 作者: A Alex Dima

Use URI for ExtHostDocumentsShape methods

上级 5b1d34e4
......@@ -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 {
......
......@@ -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);
......
......@@ -298,7 +298,7 @@ suite('ExtHostDocumentSaveParticipant', () => {
let sub = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (e) {
// concurrent change from somewhere
documents.$acceptModelChanged(resource.toString(), {
documents.$acceptModelChanged(resource, {
changes: [{
range: { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 },
rangeLength: undefined,
......@@ -332,7 +332,7 @@ suite('ExtHostDocumentSaveParticipant', () => {
const { resource, edits } = edit;
const uri = URI.revive(resource);
for (const { text, range } of edits) {
documents.$acceptModelChanged(uri.toString(), {
documents.$acceptModelChanged(uri, {
changes: [{
range,
text,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册