Skip to content

Commit 299d29f

Browse files
authored
Adds originalUrl to GetPreferredUILocationResult (#2159)
adds GetPreferredUILocationResult.originalUrl to lookup urls from stack traces.
1 parent ab19f0c commit 299d29f

File tree

5 files changed

+36
-9
lines changed

5 files changed

+36
-9
lines changed

src/adapter/debugAdapter.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { BasicCpuProfiler } from './profiling/basicCpuProfiler';
3737
import { ScriptSkipper } from './scriptSkipper/implementation';
3838
import { IScriptSkipper } from './scriptSkipper/scriptSkipper';
3939
import { SmartStepper } from './smartStepping';
40-
import { ISourceWithMap, SourceFromMap } from './source';
40+
import { ISourceWithMap, Source, SourceFromMap } from './source';
4141
import { SourceContainer } from './sourceContainer';
4242
import { Thread } from './threads';
4343
import { VariableStore } from './variableStore';
@@ -136,9 +136,25 @@ export class DebugAdapter implements IDisposable {
136136
private async _getPreferredUILocation(
137137
params: Dap.GetPreferredUILocationParams,
138138
): Promise<Dap.GetPreferredUILocationResult> {
139-
const source = this.sourceContainer.source(params.source);
139+
let source: Source | undefined = undefined;
140+
if (params.originalUrl) {
141+
source = this.sourceContainer.getSourceByOriginalUrl(params.originalUrl);
142+
}
143+
if (!source && params.source) {
144+
source = this.sourceContainer.source(params.source);
145+
}
146+
140147
if (!source) {
141-
return params;
148+
if (params.source) {
149+
// Return unmodified input source
150+
return {
151+
column: params.column,
152+
line: params.line,
153+
source: params.source,
154+
};
155+
} else {
156+
throw new ProtocolError(errors.missingSourceInformation());
157+
}
142158
}
143159

144160
const location = await this.sourceContainer.preferredUiLocation({

src/build/dapCustom.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,11 @@ const dapCustom: JSONSchema4 = {
805805
properties: {
806806
source: {
807807
$ref: '#/definitions/Source',
808-
description: 'The source to look up.',
808+
description: 'The source to look up. Either source or originalUrl must be set.',
809+
},
810+
originalUrl: {
811+
type: 'string',
812+
description: 'The original url to look up. Either source or originalUrl must be set.',
809813
},
810814
line: {
811815
type: 'integer',
@@ -816,7 +820,7 @@ const dapCustom: JSONSchema4 = {
816820
description: 'The base-0 column number to look up.',
817821
},
818822
},
819-
required: ['source', 'line', 'column'],
823+
required: ['line', 'column'],
820824
},
821825
{
822826
properties: {

src/cdp/api.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,7 +1934,7 @@ export namespace Cdp {
19341934
| 'InteractiveContentLegendChild';
19351935

19361936
/**
1937-
* This isue warns about errors in the select element content model.
1937+
* This issue warns about errors in the select element content model.
19381938
*/
19391939
export interface SelectElementAccessibilityIssueDetails {
19401940
nodeId: DOM.BackendNodeId;
@@ -31218,7 +31218,6 @@ export namespace Cdp {
3121831218
* Enum of possible storage types.
3121931219
*/
3122031220
export type StorageType =
31221-
| 'appcache'
3122231221
| 'cookies'
3122331222
| 'file_systems'
3122431223
| 'indexeddb'

src/dap/api.d.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2460,9 +2460,14 @@ export namespace Dap {
24602460

24612461
export interface GetPreferredUILocationParams {
24622462
/**
2463-
* The source to look up.
2463+
* The source to look up. Either source or originalUrl must be set.
24642464
*/
2465-
source: Source;
2465+
source?: Source;
2466+
2467+
/**
2468+
* The original url to look up. Either source or originalUrl must be set.
2469+
*/
2470+
originalUrl?: string;
24662471

24672472
/**
24682473
* The base-0 line number to look up.

src/dap/errors.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,9 @@ export const noUwpPipeFound = () =>
237237
export const locationNotFound = () =>
238238
createUserError(l10n.t('Could not find a location for the variable'));
239239

240+
export const missingSourceInformation = () =>
241+
createSilentError(l10n.t('Missing source information. Did you set "originalUrl" or "source"?'));
242+
240243
/**
241244
* Returns if the value looks like a DAP error.
242245
*/

0 commit comments

Comments
 (0)