Skip to content

Commit f322bae

Browse files
committed
Use URI for ExtHostDocumentsShape methods
1 parent 5b1d34e commit f322bae

4 files changed

Lines changed: 26 additions & 18 deletions

File tree

src/vs/workbench/api/electron-browser/mainThreadDocuments.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,17 @@ export class MainThreadDocuments implements MainThreadDocumentsShape {
104104

105105
this._toDispose.push(textFileService.models.onModelSaved(e => {
106106
if (this._shouldHandleFileEvent(e)) {
107-
this._proxy.$acceptModelSaved(e.resource.toString());
107+
this._proxy.$acceptModelSaved(e.resource);
108108
}
109109
}));
110110
this._toDispose.push(textFileService.models.onModelReverted(e => {
111111
if (this._shouldHandleFileEvent(e)) {
112-
this._proxy.$acceptDirtyStateChanged(e.resource.toString(), false);
112+
this._proxy.$acceptDirtyStateChanged(e.resource, false);
113113
}
114114
}));
115115
this._toDispose.push(textFileService.models.onModelDirty(e => {
116116
if (this._shouldHandleFileEvent(e)) {
117-
this._proxy.$acceptDirtyStateChanged(e.resource.toString(), true);
117+
this._proxy.$acceptDirtyStateChanged(e.resource, true);
118118
}
119119
}));
120120

@@ -143,7 +143,7 @@ export class MainThreadDocuments implements MainThreadDocumentsShape {
143143
let modelUrl = model.uri;
144144
this._modelIsSynced[modelUrl.toString()] = true;
145145
this._modelToDisposeMap[modelUrl.toString()] = model.onDidChangeContent((e) => {
146-
this._proxy.$acceptModelChanged(modelUrl.toString(), e, this._textFileService.isDirty(modelUrl));
146+
this._proxy.$acceptModelChanged(modelUrl, e, this._textFileService.isDirty(modelUrl));
147147
});
148148
}
149149

@@ -153,7 +153,7 @@ export class MainThreadDocuments implements MainThreadDocumentsShape {
153153
if (!this._modelIsSynced[modelUrl.toString()]) {
154154
return;
155155
}
156-
this._proxy.$acceptModelModeChanged(model.uri.toString(), oldModeId, model.getLanguageIdentifier().language);
156+
this._proxy.$acceptModelModeChanged(model.uri, oldModeId, model.getLanguageIdentifier().language);
157157
}
158158

159159
private _onModelRemoved(modelUrl: URI): void {
@@ -227,7 +227,7 @@ export class MainThreadDocuments implements MainThreadDocumentsShape {
227227
throw new Error(`expected URI ${resource.toString()} to have come to LIFE`);
228228
}
229229

230-
this._proxy.$acceptDirtyStateChanged(resource.toString(), true); // mark as dirty
230+
this._proxy.$acceptDirtyStateChanged(resource, true); // mark as dirty
231231

232232
return resource;
233233
});

src/vs/workbench/api/node/extHost.protocol.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,10 @@ export interface IModelAddedData {
479479
isDirty: boolean;
480480
}
481481
export interface ExtHostDocumentsShape {
482-
$acceptModelModeChanged(strURL: string, oldModeId: string, newModeId: string): void;
483-
$acceptModelSaved(strURL: string): void;
484-
$acceptDirtyStateChanged(strURL: string, isDirty: boolean): void;
485-
$acceptModelChanged(strURL: string, e: IModelChangedEvent, isDirty: boolean): void;
482+
$acceptModelModeChanged(strURL: UriComponents, oldModeId: string, newModeId: string): void;
483+
$acceptModelSaved(strURL: UriComponents): void;
484+
$acceptDirtyStateChanged(strURL: UriComponents, isDirty: boolean): void;
485+
$acceptModelChanged(strURL: UriComponents, e: IModelChangedEvent, isDirty: boolean): void;
486486
}
487487

488488
export interface ExtHostDocumentSaveParticipantShape {

src/vs/workbench/api/node/extHostDocuments.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
'use strict';
66

77
import Event, { Emitter } from 'vs/base/common/event';
8-
import URI from 'vs/base/common/uri';
8+
import URI, { UriComponents } from 'vs/base/common/uri';
99
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
1010
import * as TypeConverters from './extHostTypeConverters';
1111
import { TPromise } from 'vs/base/common/winjs.base';
@@ -95,7 +95,9 @@ export class ExtHostDocuments implements ExtHostDocumentsShape {
9595
return this._proxy.$tryCreateDocument(options).then(data => URI.revive(data));
9696
}
9797

98-
public $acceptModelModeChanged(strURL: string, oldModeId: string, newModeId: string): void {
98+
public $acceptModelModeChanged(uriComponents: UriComponents, oldModeId: string, newModeId: string): void {
99+
const uri = URI.revive(uriComponents);
100+
const strURL = uri.toString();
99101
let data = this._documentsAndEditors.getDocument(strURL);
100102

101103
// Treat a mode change as a remove + add
@@ -105,13 +107,17 @@ export class ExtHostDocuments implements ExtHostDocumentsShape {
105107
this._onDidAddDocument.fire(data.document);
106108
}
107109

108-
public $acceptModelSaved(strURL: string): void {
110+
public $acceptModelSaved(uriComponents: UriComponents): void {
111+
const uri = URI.revive(uriComponents);
112+
const strURL = uri.toString();
109113
let data = this._documentsAndEditors.getDocument(strURL);
110-
this.$acceptDirtyStateChanged(strURL, false);
114+
this.$acceptDirtyStateChanged(uriComponents, false);
111115
this._onDidSaveDocument.fire(data.document);
112116
}
113117

114-
public $acceptDirtyStateChanged(strURL: string, isDirty: boolean): void {
118+
public $acceptDirtyStateChanged(uriComponents: UriComponents, isDirty: boolean): void {
119+
const uri = URI.revive(uriComponents);
120+
const strURL = uri.toString();
115121
let data = this._documentsAndEditors.getDocument(strURL);
116122
data._acceptIsDirty(isDirty);
117123
this._onDidChangeDocument.fire({
@@ -120,7 +126,9 @@ export class ExtHostDocuments implements ExtHostDocumentsShape {
120126
});
121127
}
122128

123-
public $acceptModelChanged(strURL: string, events: IModelChangedEvent, isDirty: boolean): void {
129+
public $acceptModelChanged(uriComponents: UriComponents, events: IModelChangedEvent, isDirty: boolean): void {
130+
const uri = URI.revive(uriComponents);
131+
const strURL = uri.toString();
124132
let data = this._documentsAndEditors.getDocument(strURL);
125133
data._acceptIsDirty(isDirty);
126134
data.onEvents(events);

src/vs/workbench/test/electron-browser/api/extHostDocumentSaveParticipant.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ suite('ExtHostDocumentSaveParticipant', () => {
298298
let sub = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (e) {
299299

300300
// concurrent change from somewhere
301-
documents.$acceptModelChanged(resource.toString(), {
301+
documents.$acceptModelChanged(resource, {
302302
changes: [{
303303
range: { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 },
304304
rangeLength: undefined,
@@ -332,7 +332,7 @@ suite('ExtHostDocumentSaveParticipant', () => {
332332
const { resource, edits } = edit;
333333
const uri = URI.revive(resource);
334334
for (const { text, range } of edits) {
335-
documents.$acceptModelChanged(uri.toString(), {
335+
documents.$acceptModelChanged(uri, {
336336
changes: [{
337337
range,
338338
text,

0 commit comments

Comments
 (0)