MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / sourceLocationForView

Function sourceLocationForView

packages/nativescript-inspector/src/index.ts:2253–2284  ·  view source on GitHub ↗
(view: any, sourceRoot = "")

Source from the content-addressed store, hash-verified

2251}
2252
2253function sourceLocationForView(view: any, sourceRoot = ""): JSONObject | null {
2254 const raw = safeCall(
2255 () => view.getAttribute?.(angularSourceLocationAttribute),
2256 null,
2257 );
2258 const value = stringValue(raw);
2259 if (!value) {
2260 return null;
2261 }
2262 const separator = value.lastIndexOf("@");
2263 if (separator <= 0) {
2264 return { file: absoluteSourceFile(value, sourceRoot) };
2265 }
2266 const location: JSONObject = {
2267 file: absoluteSourceFile(value.slice(0, separator), sourceRoot),
2268 };
2269 for (const part of value.slice(separator + 1).split(",")) {
2270 const [key, rawNumber] = part.split(":");
2271 const parsed = Number(rawNumber);
2272 if (!Number.isFinite(parsed)) {
2273 continue;
2274 }
2275 if (key === "o") {
2276 location.offset = parsed;
2277 } else if (key === "l") {
2278 location.line = parsed;
2279 } else if (key === "c") {
2280 location.column = parsed;
2281 }
2282 }
2283 return location;
2284}
2285
2286function nativeScriptInfo(
2287 view: View,

Callers 6

nativeScriptNodeMethod · 0.85
uikitNodeMethod · 0.85
nativeScriptTabItemsFunction · 0.85
tabItemSourceLocationFunction · 0.85
nativeScriptInfoFunction · 0.85

Calls 4

safeCallFunction · 0.85
stringValueFunction · 0.85
getAttributeMethod · 0.80
absoluteSourceFileFunction · 0.70

Tested by

no test coverage detected