{"version":3,"sources":["../../src/utils/locations.ts"],"sourcesContent":["import type ts from \"typescript\";\n\nimport { TSModule } from \"./programs.js\";\n\nexport const locForTSNode = (sourceFile: ts.SourceFile, node: ts.Node) => {\n\tconst start = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n\tconst end = sourceFile.getLineAndCharacterOfPosition(node.getEnd());\n\n\treturn {\n\t\tend: {\n\t\t\tcolumn: end.character,\n\t\t\tline: end.line + 1,\n\t\t},\n\t\tstart: {\n\t\t\tcolumn: start.character,\n\t\t\tline: start.line + 1,\n\t\t},\n\t};\n};\n\nexport function getNodeAtPosition(\n\tsourceFile: ts.SourceFile,\n\tposition: number,\n\ttsModule: TSModule,\n): ts.Node | undefined {\n\tlet candidate: ts.Node | undefined = undefined;\n\ttsModule.forEachChild(sourceFile, function iterate(node) {\n\t\tconst start = node.getStart();\n\t\tconst end = node.getEnd();\n\t\tif (position >= start && position <= end) {\n\t\t\tcandidate = node;\n\t\t\ttsModule.forEachChild(node, iterate);\n\t\t}\n\t});\n\treturn candidate;\n}\n\nexport function lineOfPosition(pos: number, sourceFile: ts.SourceFile): number {\n\treturn sourceFile.getLineAndCharacterOfPosition(pos).line;\n}\n"],"mappings":";AAIO,MAAM,eAAe,CAAC,YAA2B,SAAkB;AACzE,QAAM,QAAQ,WAAW,8BAA8B,KAAK,SAAS,CAAC;AACtE,QAAM,MAAM,WAAW,8BAA8B,KAAK,OAAO,CAAC;AAElE,SAAO;AAAA,IACN,KAAK;AAAA,MACJ,QAAQ,IAAI;AAAA,MACZ,MAAM,IAAI,OAAO;AAAA,IAClB;AAAA,IACA,OAAO;AAAA,MACN,QAAQ,MAAM;AAAA,MACd,MAAM,MAAM,OAAO;AAAA,IACpB;AAAA,EACD;AACD;AAEO,SAAS,kBACf,YACA,UACA,UACsB;AACtB,MAAI,YAAiC;AACrC,WAAS,aAAa,YAAY,SAAS,QAAQ,MAAM;AACxD,UAAM,QAAQ,KAAK,SAAS;AAC5B,UAAM,MAAM,KAAK,OAAO;AACxB,QAAI,YAAY,SAAS,YAAY,KAAK;AACzC,kBAAY;AACZ,eAAS,aAAa,MAAM,OAAO;AAAA,IACpC;AAAA,EACD,CAAC;AACD,SAAO;AACR;AAEO,SAAS,eAAe,KAAa,YAAmC;AAC9E,SAAO,WAAW,8BAA8B,GAAG,EAAE;AACtD;","names":[]}