summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/src/utils/selected-location.js
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/debugger/src/utils/selected-location.js')
-rw-r--r--devtools/client/debugger/src/utils/selected-location.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/devtools/client/debugger/src/utils/selected-location.js b/devtools/client/debugger/src/utils/selected-location.js
new file mode 100644
index 0000000000..a07877449f
--- /dev/null
+++ b/devtools/client/debugger/src/utils/selected-location.js
@@ -0,0 +1,23 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
+
+// @flow
+
+import { isOriginalId } from "devtools-source-map";
+import type { SourceLocation, MappedLocation, Source } from "../types";
+
+export function getSelectedLocation(
+ mappedLocation: MappedLocation,
+ context: ?(Source | SourceLocation)
+): SourceLocation {
+ if (!context) {
+ return mappedLocation.location;
+ }
+
+ // $FlowIgnore
+ const sourceId = context.sourceId || context.id;
+ return isOriginalId(sourceId)
+ ? mappedLocation.location
+ : mappedLocation.generatedLocation;
+}