Skip to content

Commit

Permalink
Adds originalUrl to GetPreferredUILocationResult (#2159)
Browse files Browse the repository at this point in the history
adds GetPreferredUILocationResult.originalUrl to lookup urls from stack traces.
  • Loading branch information
hediet authored Jan 8, 2025
1 parent ab19f0c commit 299d29f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 9 deletions.
22 changes: 19 additions & 3 deletions src/adapter/debugAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { BasicCpuProfiler } from './profiling/basicCpuProfiler';
import { ScriptSkipper } from './scriptSkipper/implementation';
import { IScriptSkipper } from './scriptSkipper/scriptSkipper';
import { SmartStepper } from './smartStepping';
import { ISourceWithMap, SourceFromMap } from './source';
import { ISourceWithMap, Source, SourceFromMap } from './source';
import { SourceContainer } from './sourceContainer';
import { Thread } from './threads';
import { VariableStore } from './variableStore';
Expand Down Expand Up @@ -136,9 +136,25 @@ export class DebugAdapter implements IDisposable {
private async _getPreferredUILocation(
params: Dap.GetPreferredUILocationParams,
): Promise<Dap.GetPreferredUILocationResult> {
const source = this.sourceContainer.source(params.source);
let source: Source | undefined = undefined;
if (params.originalUrl) {
source = this.sourceContainer.getSourceByOriginalUrl(params.originalUrl);
}
if (!source && params.source) {
source = this.sourceContainer.source(params.source);
}

if (!source) {
return params;
if (params.source) {
// Return unmodified input source
return {
column: params.column,
line: params.line,
source: params.source,
};
} else {
throw new ProtocolError(errors.missingSourceInformation());
}
}

const location = await this.sourceContainer.preferredUiLocation({
Expand Down
8 changes: 6 additions & 2 deletions src/build/dapCustom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,11 @@ const dapCustom: JSONSchema4 = {
properties: {
source: {
$ref: '#/definitions/Source',
description: 'The source to look up.',
description: 'The source to look up. Either source or originalUrl must be set.',
},
originalUrl: {
type: 'string',
description: 'The original url to look up. Either source or originalUrl must be set.',
},
line: {
type: 'integer',
Expand All @@ -816,7 +820,7 @@ const dapCustom: JSONSchema4 = {
description: 'The base-0 column number to look up.',
},
},
required: ['source', 'line', 'column'],
required: ['line', 'column'],
},
{
properties: {
Expand Down
3 changes: 1 addition & 2 deletions src/cdp/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1934,7 +1934,7 @@ export namespace Cdp {
| 'InteractiveContentLegendChild';

/**
* This isue warns about errors in the select element content model.
* This issue warns about errors in the select element content model.
*/
export interface SelectElementAccessibilityIssueDetails {
nodeId: DOM.BackendNodeId;
Expand Down Expand Up @@ -31218,7 +31218,6 @@ export namespace Cdp {
* Enum of possible storage types.
*/
export type StorageType =
| 'appcache'
| 'cookies'
| 'file_systems'
| 'indexeddb'
Expand Down
9 changes: 7 additions & 2 deletions src/dap/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2460,9 +2460,14 @@ export namespace Dap {

export interface GetPreferredUILocationParams {
/**
* The source to look up.
* The source to look up. Either source or originalUrl must be set.
*/
source: Source;
source?: Source;

/**
* The original url to look up. Either source or originalUrl must be set.
*/
originalUrl?: string;

/**
* The base-0 line number to look up.
Expand Down
3 changes: 3 additions & 0 deletions src/dap/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ export const noUwpPipeFound = () =>
export const locationNotFound = () =>
createUserError(l10n.t('Could not find a location for the variable'));

export const missingSourceInformation = () =>
createSilentError(l10n.t('Missing source information. Did you set "originalUrl" or "source"?'));

/**
* Returns if the value looks like a DAP error.
*/
Expand Down

0 comments on commit 299d29f

Please sign in to comment.