Skip to content

Commit df1f459

Browse files
bmeurerDevtools-frontend LUCI CQ
authored andcommitted
[cleanup] Remove unused shouldFormatDiff option.
All call sites (even in unit tests) pass `true` for this option, so we can as well simply remove it all-together. Bug: 393244410, 40784389, 40803732, 40694280 Change-Id: Ic33ac3831b27916704f9b3913f25d5f49c7123d4 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6218359 Auto-Submit: Benedikt Meurer <[email protected]> Commit-Queue: Benedikt Meurer <[email protected]> Reviewed-by: Alex Rudenko <[email protected]> Commit-Queue: Alex Rudenko <[email protected]>
1 parent 311f667 commit df1f459

File tree

4 files changed

+17
-30
lines changed

4 files changed

+17
-30
lines changed

front_end/models/workspace_diff/WorkspaceDiff.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describeWithEnvironment('UISourceCodeDiff', () => {
3838
uiSourceCode.setWorkingCopyGetter(() => 'const data={modified:true,original:false}');
3939

4040
const uiSourceCodeDiff = new WorkspaceDiff.WorkspaceDiff.UISourceCodeDiff(uiSourceCode);
41-
const {diff, formattedCurrentMapping} = (await uiSourceCodeDiff.requestDiff({shouldFormatDiff: true}))!;
41+
const {diff, formattedCurrentMapping} = (await uiSourceCodeDiff.requestDiff())!;
4242
assert.deepEqual(diff, [
4343
{0: 0, 1: ['const data = {']},
4444
{0: -1, 1: [' original: true']},

front_end/models/workspace_diff/WorkspaceDiff.ts

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ import * as Persistence from '../persistence/persistence.js';
1010
import * as TextUtils from '../text_utils/text_utils.js';
1111
import * as Workspace from '../workspace/workspace.js';
1212

13-
interface DiffRequestOptions {
14-
shouldFormatDiff: boolean;
15-
}
16-
1713
interface DiffResponse {
1814
diff: Diff.Diff.DiffArray;
1915
formattedCurrentMapping?: FormatterModule.ScriptFormatter.FormatterSourceMapping;
@@ -40,9 +36,8 @@ export class WorkspaceDiffImpl extends Common.ObjectWrapper.ObjectWrapper<EventT
4036
workspace.uiSourceCodes().forEach(this.updateModifiedState.bind(this));
4137
}
4238

43-
requestDiff(uiSourceCode: Workspace.UISourceCode.UISourceCode, diffRequestOptions: DiffRequestOptions):
44-
Promise<DiffResponse|null> {
45-
return this.uiSourceCodeDiff(uiSourceCode).requestDiff(diffRequestOptions);
39+
requestDiff(uiSourceCode: Workspace.UISourceCode.UISourceCode): Promise<DiffResponse|null> {
40+
return this.uiSourceCodeDiff(uiSourceCode).requestDiff();
4641
}
4742

4843
subscribeToDiffChange(uiSourceCode: Workspace.UISourceCode.UISourceCode, callback: () => void, thisObj?: Object):
@@ -224,9 +219,9 @@ export class UISourceCodeDiff extends Common.ObjectWrapper.ObjectWrapper<UISourc
224219
}
225220
}
226221

227-
requestDiff(diffRequestOptions: DiffRequestOptions): Promise<DiffResponse|null> {
222+
requestDiff(): Promise<DiffResponse|null> {
228223
if (!this.requestDiffPromise) {
229-
this.requestDiffPromise = this.innerRequestDiff(diffRequestOptions);
224+
this.requestDiffPromise = this.innerRequestDiff();
230225
}
231226
return this.requestDiffPromise;
232227
}
@@ -246,7 +241,7 @@ export class UISourceCodeDiff extends Common.ObjectWrapper.ObjectWrapper<UISourc
246241
return content.asDeferedContent().content;
247242
}
248243

249-
private async innerRequestDiff({shouldFormatDiff}: DiffRequestOptions): Promise<DiffResponse|null> {
244+
private async innerRequestDiff(): Promise<DiffResponse|null> {
250245
if (this.dispose) {
251246
return null;
252247
}
@@ -276,19 +271,13 @@ export class UISourceCodeDiff extends Common.ObjectWrapper.ObjectWrapper<UISourc
276271
return null;
277272
}
278273

279-
if (current === null || baseline === null) {
280-
return null;
281-
}
282-
let formattedCurrentMapping;
283-
if (shouldFormatDiff) {
284-
baseline = (await FormatterModule.ScriptFormatter.format(
285-
this.uiSourceCode.contentType(), this.uiSourceCode.mimeType(), baseline))
286-
.formattedContent;
287-
const formatCurrentResult = await FormatterModule.ScriptFormatter.format(
288-
this.uiSourceCode.contentType(), this.uiSourceCode.mimeType(), current);
289-
current = formatCurrentResult.formattedContent;
290-
formattedCurrentMapping = formatCurrentResult.formattedMapping;
291-
}
274+
baseline = (await FormatterModule.ScriptFormatter.format(
275+
this.uiSourceCode.contentType(), this.uiSourceCode.mimeType(), baseline))
276+
.formattedContent;
277+
const formatCurrentResult = await FormatterModule.ScriptFormatter.format(
278+
this.uiSourceCode.contentType(), this.uiSourceCode.mimeType(), current);
279+
current = formatCurrentResult.formattedContent;
280+
const formattedCurrentMapping = formatCurrentResult.formattedMapping;
292281
const reNewline = /\r\n?|\n/;
293282
const diff = Diff.Diff.DiffWrapper.lineDiff(baseline.split(reNewline), current.split(reNewline));
294283
return {

front_end/panels/changes/ChangesView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export class ChangesView extends UI.Widget.VBox {
144144
if (!uiSourceCode) {
145145
return;
146146
}
147-
const diffResponse = await this.workspaceDiff.requestDiff(uiSourceCode, {shouldFormatDiff: true});
147+
const diffResponse = await this.workspaceDiff.requestDiff(uiSourceCode);
148148
// Diff array with real diff will contain at least 2 lines.
149149
if (!diffResponse || diffResponse?.diff.length < 2) {
150150
return;
@@ -226,7 +226,7 @@ export class ChangesView extends UI.Widget.VBox {
226226
this.hideDiff(i18nString(UIStrings.noTextualDiff), i18nString(UIStrings.binaryDataDescription));
227227
return;
228228
}
229-
const diffResponse = await this.workspaceDiff.requestDiff(uiSourceCode, {shouldFormatDiff: true});
229+
const diffResponse = await this.workspaceDiff.requestDiff(uiSourceCode);
230230
if (this.selectedUISourceCode !== uiSourceCode) {
231231
return;
232232
}

front_end/panels/elements/StylesSidebarPane.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,8 +1550,7 @@ export class StylesSidebarPane extends Common.ObjectWrapper.eventMixin<EventType
15501550
if (!changeTracker) {
15511551
return;
15521552
}
1553-
const diffResponse =
1554-
await WorkspaceDiff.WorkspaceDiff.workspaceDiff().requestDiff(uiSourceCode, {shouldFormatDiff: true});
1553+
const diffResponse = await WorkspaceDiff.WorkspaceDiff.workspaceDiff().requestDiff(uiSourceCode);
15551554
const changedLines = new Set<number>();
15561555
changeTracker.changedLines = changedLines;
15571556
if (!diffResponse) {
@@ -1570,8 +1569,7 @@ export class StylesSidebarPane extends Common.ObjectWrapper.eventMixin<EventType
15701569
async getFormattedChanges(): Promise<string> {
15711570
let allChanges = '';
15721571
for (const [url, {uiSourceCode}] of this.#urlToChangeTracker) {
1573-
const diffResponse =
1574-
await WorkspaceDiff.WorkspaceDiff.workspaceDiff().requestDiff(uiSourceCode, {shouldFormatDiff: true});
1572+
const diffResponse = await WorkspaceDiff.WorkspaceDiff.workspaceDiff().requestDiff(uiSourceCode);
15751573
// Diff array with real diff will contain at least 2 lines.
15761574
if (!diffResponse || diffResponse?.diff.length < 2) {
15771575
continue;

0 commit comments

Comments
 (0)