Skip to content

Instantly share code, notes, and snippets.

@jasonLaster
Created December 4, 2022 03:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonLaster/62c1b946b9cf50addbac96bc00bb59c3 to your computer and use it in GitHub Desktop.
Save jasonLaster/62c1b946b9cf50addbac96bc00bb59c3 to your computer and use it in GitHub Desktop.

User

What has to be true if the function CurrentLineHighlightSuspends is returning a div with the attribute data-test-name equal to CurrentExecutionPointLineHighlight?

function CurrentLineHighlightSuspends({
  lineNumber,
  sourceId
}) {
  const client = useContext(ReplayClientContext);
  const {
    0: sourceSearchState
  } = useContext(SourceSearchContext);
  const {
    selectedPauseAndFrameId,
    previewLocation
  } = useContext(SelectedFrameContext);
  const {
    currentSearchResultLocation
  } = useContext(SourcesContext);
  if (previewLocation?.sourceId === sourceId) {
    if (previewLocation.line === lineNumber) {
      return /*#__PURE__*/ _jsx("div", {
        className: styles.CurrentExecutionPoint,
        "data-test-name": "CurrentExecutionPointLineHighlight"
      });
    }
    return null;
  }
  const frameId = selectedPauseAndFrameId?.frameId || null;
  const pauseId = selectedPauseAndFrameId?.pauseId || null;
  if (pauseId !== null && frameId !== null) {
    const frames = getFramesSuspense(client, pauseId);
    if (frames) {
      const correspondingSourceIds = client.getCorrespondingSourceIds(sourceId);
      const selectedFrame = frames.find(frame => frame.frameId === frameId);
      if (selectedFrame) {
        if (selectedFrame.location.find(location => {
            if (correspondingSourceIds.includes(location.sourceId)) {
              const correspondingLocations = client.getCorrespondingLocations(
                location);
              return correspondingLocations.findIndex(correspondingLocation =>
                correspondingLocation.line === lineNumber &&
                correspondingLocation.sourceId === sourceId) >= 0;
            }
          })) {
          return /*#__PURE__*/ _jsx("div", {
            className: styles.CurrentExecutionPoint,
            "data-test-name": "CurrentExecutionPointLineHighlight"
          });
        }
      }
    }
  }
  if (currentSearchResultLocation != null && currentSearchResultLocation
    .sourceId === sourceSearchState.currentScopeId &&
    currentSearchResultLocation.line === lineNumber) {
    return /*#__PURE__*/ _jsx("div", {
      className: styles.CurrentSearchResult,
      "data-test-name": "CurrentSearchResultHighlight"
    });
  }
  return null;
}

Chat

If the CurrentLineHighlightSuspends function is returning a div with the attribute data-test-name equal to CurrentExecutionPointLineHighlight, then the following must be true:

  1. The previewLocation object exists, and its sourceId property is equal to the sourceId parameter passed to the CurrentLineHighlightSuspends function.

  2. The previewLocation object's line property is equal to the lineNumber parameter passed to the CurrentLineHighlightSuspends function. OR

  3. The selectedPauseAndFrameId object exists and has both frameId and pauseId properties.

  4. The function getFramesSuspense returns a truthy value when called with the ReplayClientContext's client object and the selectedPauseAndFrameId object's pauseId property.

  5. The selectedFrame variable, which is the result of calling find on the value returned by getFramesSuspense, exists and has a location property.

  6. The selectedFrame variable's location property contains an object with a sourceId property that is included in the result of calling getCorrespondingSourceIds on the ReplayClientContext's client object and passing it the sourceId parameter passed to the CurrentLineHighlightSuspends function.

  7. The selectedFrame variable's location property contains an object with a line property that is equal to the lineNumber parameter passed to the CurrentLineHighlightSuspends function.

OR

  1. The currentSearchResultLocation variable exists and is not null.
  2. The currentSearchResultLocation variable's sourceId property is equal to the currentScopeId property of the SourceSearchContext's sourceSearchState object.
  3. The currentSearchResultLocation variable's line property is equal to the lineNumber parameter passed to the CurrentLineHighlightSuspends function.

User

selectedPauseAndFrameId equals {pauseId: "0027f53e-8035-464e-b7a5-04a18e903a5f", frameId: "0"}

Chat

If selectedPauseAndFrameId is equal to {pauseId: "0027f53e-8035-464e-b7a5-04a18e903a5f", frameId: "0"}, then in order for the CurrentLineHighlightSuspends function to return a div with the attribute data-test-name equal to CurrentExecutionPointLineHighlight, the following must be true:

  1. The previewLocation object does not exist, or its sourceId property is not equal to the sourceId parameter passed to the CurrentLineHighlightSuspends function, or its line property is not equal to the lineNumber parameter passed to the CurrentLineHighlightSuspends function. AND

  2. The getFramesSuspense function returns a truthy value when called with the ReplayClientContext's client object and the selectedPauseAndFrameId object's pauseId property.

  3. The selectedFrame variable, which is the result of calling find on the value returned by getFramesSuspense, exists and has a location property.

  4. The selectedFrame variable's location property contains an object with a sourceId property that is included in the result of calling getCorrespondingSourceIds on the ReplayClientContext's client object and passing it the sourceId parameter passed to the CurrentLineHighlightSuspends function.

  5. The selectedFrame variable's location property contains an object with a line property that is equal to the lineNumber parameter passed to the CurrentLineHighlightSuspends function. OR

  6. The currentSearchResultLocation variable does not exist or is null.

  7. The currentSearchResultLocation variable's sourceId property is not equal to the currentScopeId property of the SourceSearchContext's sourceSearchState object.

  8. The currentSearchResultLocation variable's line property is not equal to the lineNumber parameter passed to the CurrentLineHighlightSuspends function.

User

previewLocation is null

Chat

If previewLocation is null, then in order for the CurrentLineHighlightSuspends function to return a div with the attribute data-test-name equal to CurrentExecutionPointLineHighlight, the following must be true:

  1. The selectedPauseAndFrameId object exists and has both frameId and pauseId properties.

  2. The function getFramesSuspense returns a truthy value when called with the ReplayClientContext's client object and the selectedPauseAndFrameId object's pauseId property.

  3. The selectedFrame variable, which is the result of calling find on the value returned by getFramesSuspense, exists and has a location property.

  4. The selectedFrame variable's location property contains an object with a sourceId property that is included in the result of calling getCorrespondingSourceIds on the ReplayClientContext's client object and passing it the sourceId parameter passed to the CurrentLineHighlightSuspends function.

  5. The selectedFrame variable's location property contains an object with a line property that is equal to the lineNumber parameter passed to the CurrentLineHighlightSuspends function. OR

  6. The currentSearchResultLocation variable exists and is not null.

  7. The currentSearchResultLocation variable's sourceId property is equal to the currentScopeId property of the SourceSearchContext's sourceSearchState object.

  8. The currentSearchResultLocation variable's line property is equal to the lineNumber parameter passed to the CurrentLineHighlightSuspends function.

User

here is selectedFrame {"frameId":"0","functionLocation":[{"column":288382,"line":1,"sourceId":"9"},{"sourceId":"pp9","line":17491,"column":13},{"sourceId":"o9-122-f73cce-6da222","line":22,"column":16}],"functionName":"zs","location":[{"sourceId":"9","line":1,"column":288683,"functionId":"15900","offset":1048},{"sourceId":"pp9","line":17501,"column":5},{"sourceId":"o9-122-f73cce-6da222","line":73,"column":2}],"scopeChain":["13","14","15","16","4","5"],"this":{},"type":"call","originalScopeChain":["original:0:0","original:0:1"],"originalFunctionName":"TestCase"}Less

Chat

If selectedFrame is equal to

{
  "frameId": "0",
  "functionLocation": [
    {
      "column": 288382,
      "line": 1,
      "sourceId": "9"
    },
    {
      "sourceId": "pp9",
      "line": 17491,
      "column": 13
    },
    {
      "sourceId": "o9-122-f73cce-6da222",
      "line": 22,
      "column": 16
    }
  ],
  "functionName": "zs",
  "location": [
    {
      "sourceId": "9",
      "line": 1,
      "column": 288683,
      "functionId": "15900",
      "offset": 1048
    },
    {
      "sourceId": "pp9",
      "line": 17501,
      "column": 5
    },
    {
      "sourceId": "o9-122-f73cce-6da222",
      "line": 73,
      "column": 2
    }
  ],
  "scopeChain": [
    "13",
    "14",
    "15",
    "16",
    "4",
    "5"
  ],
  "this": {},
  "type": "call",
  "originalScopeChain": [
    "original:0:0",
    "original:0:1"
  ],
  "originalFunctionName": "TestCase"
}

then in order for the CurrentLineHighlightSuspends function to return a div with the attribute data-test-name equal to CurrentExecutionPointLineHighlight, the following must be true:

  1. The getCorrespondingSourceIds function, when called on the ReplayClientContext's client object and passed the sourceId parameter passed to the CurrentLineHighlightSuspends function, returns an array that contains at least one of the sourceId properties from the objects in the selectedFrame variable's location property.
  2. At least one of the objects in the selectedFrame variable's location property has a line property that is equal to the lineNumber parameter passed to the CurrentLineHighlightSuspends function, and a sourceId property that is included in the array returned by getCorrespondingSourceIds when called with the ReplayClientContext's client object and the sourceId parameter passed to the CurrentLineHighlightSuspends function.

OR

  1. The currentSearchResultLocation variable does not exist or is null.
  2. The currentSearchResultLocation variable's sourceId property is not equal to the currentScopeId property of the SourceSearchContext's sourceSearchState object.
  3. The currentSearchResultLocation variable's line property is not equal to the lineNumber parameter passed to the CurrentLineHighlightSuspends function.

User

correspondingSourceIds equals ["o9-122-f73cce-6da222"]

Chat

If correspondingSourceIds is equal to ["o9-122-f73cce-6da222"], then in order for the CurrentLineHighlightSuspends function to return a div with the attribute data-test-name equal to CurrentExecutionPointLineHighlight, the following must be true:

  1. At least one of the objects in the selectedFrame variable's location property has a line property that is equal to the lineNumber parameter passed to the CurrentLineHighlightSuspends function, and a sourceId property that is equal to "o9-122-f73cce-6da222". OR

  2. The currentSearchResultLocation variable does not exist or is null.

  3. The currentSearchResultLocation variable's sourceId property is not equal to the currentScopeId property of the SourceSearchContext's sourceSearchState object.

  4. The currentSearchResultLocation variable's line property is not equal to the lineNumber parameter passed to the CurrentLineHighlightSuspends function.

User

The lineNumber is 73

Chat

If lineNumber is equal to 73, then in order for the CurrentLineHighlightSuspends function to return a div with the attribute data-test-name equal to CurrentExecutionPointLineHighlight, the following must be true:

  1. At least one of the objects in the selectedFrame variable's location property has a line property that is equal to 73, and a sourceId property that is equal to "o9-122-f73cce-6da222". OR

  2. The currentSearchResultLocation variable does not exist or is null.

  3. The currentSearchResultLocation variable's sourceId property is not equal to the currentScopeId property of the SourceSearchContext's sourceSearchState object.

  4. The currentSearchResultLocation variable's line property is not equal to 73.

User

will we return a div with the attribute data-test-name equal to CurrentExecutionPointLineHighlight?

Chat

In order for the CurrentLineHighlightSuspends function to return a div with the attribute data-test-name equal to CurrentExecutionPointLineHighlight, the following must be true:

  1. At least one of the objects in the selectedFrame variable's location property has a line property that is equal to 73, and a sourceId property that is equal to "o9-122-f73cce-6da222". OR

  2. The currentSearchResultLocation variable does not exist or is null.

  3. The currentSearchResultLocation variable's sourceId property is not equal to the currentScopeId property of the SourceSearchContext's sourceSearchState object.

  4. The currentSearchResultLocation variable's line property is not equal to 73. Without more information, it is impossible to determine whether or not the function will return a div with the attribute data-test-name equal to CurrentExecutionPointLineHighlight.

User

currentSearchResultLocation is null

If currentSearchResultLocation is null, then in order for the CurrentLineHighlightSuspends function to return a div with the attribute data-test-name equal to CurrentExecutionPointLineHighlight, the following must be true:

  1. At least one of the objects in the selectedFrame variable's location property has a line property that is equal to 73, and a sourceId property that is equal to "o9-122-f73cce-6da222". If currentSearchResultLocation is null and the selectedFrame variable's location property does not contain an object with a line property that is equal to 73 and a sourceId property that is equal to "o9-122-f73cce-6da222", then the CurrentLineHighlightSuspends function will not return a div with the attribute data-test-name equal to CurrentExecutionPointLineHighlight. It will return null.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment