mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 23:02:20 +00:00
Bug 1829688 - [devtools] Avoid querying the parser worker for unsupported sources. r=nchevobbe,devtools-reviewers
The worker itself ignores already the WASM sources, but we could save some cycle to avoid calling the parserWorker entirely when we know the source won't be supported by it. Differential Revision: https://phabricator.services.mozilla.com/D176414
This commit is contained in:
parent
851dc88347
commit
e4ee099d1d
@ -35,7 +35,7 @@ async function getInScopeLines(
|
||||
const sourceTextContent = getSourceTextContent(getState(), location);
|
||||
|
||||
let locations = null;
|
||||
if (location.line && location.source && !location.source.isWasm) {
|
||||
if (location.line && parserWorker.isLocationSupported(location)) {
|
||||
locations = await parserWorker.findOutOfScopeLocations(location);
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ export function highlightCalls(cx) {
|
||||
getCurrentThread(getState())
|
||||
);
|
||||
|
||||
if (!frame) {
|
||||
if (!frame || !parserWorker.isLocationSupported(frame.location)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -63,6 +63,10 @@ export function generateInlinePreview(cx, frame) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!parserWorker.isLocationSupported(selectedLocation)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const originalAstScopes = await parserWorker.getScopes(selectedLocation);
|
||||
validateThreadContext(getState(), cx);
|
||||
if (!originalAstScopes) {
|
||||
|
@ -126,27 +126,35 @@ async function onSourceTextContentAvailable(
|
||||
sourceActor,
|
||||
{ dispatch, getState, parserWorker }
|
||||
) {
|
||||
const content = getSettledSourceTextContent(
|
||||
getState(),
|
||||
createLocation({
|
||||
source,
|
||||
sourceActor,
|
||||
})
|
||||
);
|
||||
const location = createLocation({
|
||||
source,
|
||||
sourceActor,
|
||||
});
|
||||
const content = getSettledSourceTextContent(getState(), location);
|
||||
if (!content) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!source.isWasm && content) {
|
||||
if (parserWorker.isLocationSupported(location)) {
|
||||
parserWorker.setSource(
|
||||
source.id,
|
||||
isFulfilled(content)
|
||||
? content.value
|
||||
: { type: "text", value: "", contentType: undefined }
|
||||
);
|
||||
}
|
||||
|
||||
// Update the text in any breakpoints for this source by re-adding them.
|
||||
const breakpoints = getBreakpointsForSource(getState(), source.id);
|
||||
for (const { location, options, disabled } of breakpoints) {
|
||||
await dispatch(addBreakpoint(cx, location, options, disabled));
|
||||
}
|
||||
// Update the text in any breakpoints for this source by re-adding them.
|
||||
const breakpoints = getBreakpointsForSource(getState(), source.id);
|
||||
for (const breakpoint of breakpoints) {
|
||||
await dispatch(
|
||||
addBreakpoint(
|
||||
cx,
|
||||
breakpoint.location,
|
||||
breakpoint.options,
|
||||
breakpoint.disabled
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,8 @@ async function doSetSymbols(
|
||||
}
|
||||
|
||||
export const setSymbols = memoizeableAction("setSymbols", {
|
||||
getValue: ({ location }, { getState }) => {
|
||||
if (location.source.isWasm) {
|
||||
getValue: ({ location }, { getState, parserWorker }) => {
|
||||
if (!parserWorker.isLocationSupported(location)) {
|
||||
return fulfilled(null);
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,9 @@ export async function buildMappedScopes(
|
||||
thunkArgs
|
||||
) {
|
||||
const { parserWorker } = thunkArgs;
|
||||
if (!parserWorker.isLocationSupported(frame.location)) {
|
||||
return null;
|
||||
}
|
||||
const originalAstScopes = await parserWorker.getScopes(frame.location);
|
||||
const generatedAstScopes = await parserWorker.getScopes(
|
||||
frame.generatedLocation
|
||||
|
@ -33,4 +33,21 @@ export class ParserDispatcher extends WorkerDispatcher {
|
||||
mapExpression = this.task("mapExpression");
|
||||
|
||||
clear = this.task("clearState");
|
||||
|
||||
/**
|
||||
* Reports if the location's source can be parsed by this worker.
|
||||
*
|
||||
* @param {Object} location
|
||||
* A debugger frontend location object. See createLocation().
|
||||
* @return {Boolean}
|
||||
* True, if the worker may be able to parse this source.
|
||||
*/
|
||||
isLocationSupported(location) {
|
||||
// There might be more sources that the worker doesn't support,
|
||||
// like original sources which aren't JavaScript.
|
||||
// But we can only know with the source's content type,
|
||||
// which isn't available right away.
|
||||
// These source will be ignored from within the worker.
|
||||
return !location.source.isWasm;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user