MCPcopy Create free account
hub / github.com/CashScript/cashscript / updateLocationData

Function updateLocationData

packages/utils/src/bitauth-script.ts:153–169  ·  view source on GitHub ↗
(locationData: FullLocationData, insertions: Insertion[])

Source from the content-addressed store, hash-verified

151}
152
153function updateLocationData(locationData: FullLocationData, insertions: Insertion[]): FullLocationData {
154 return insertions.reduceRight((location, insertion) => {
155 return location.map((entry, opcodeIndex) => {
156 const currentLineNumber = getDisplayLine(location[opcodeIndex]);
157 const updatedLineNumber = getUpdatedLineNumber(currentLineNumber, insertion, opcodeIndex);
158 if (updatedLineNumber === currentLineNumber) return entry;
159
160 return {
161 location: {
162 start: { line: updatedLineNumber, column: 0 },
163 end: { line: updatedLineNumber, column: 0 },
164 },
165 positionHint: PositionHint.START,
166 };
167 });
168 }, locationData);
169}
170
171const getUpdatedLineNumber = (currentLineNumber: number, insertion: Insertion, opcodeIndex: number): number => {
172 const newLineNumber = insertion.insertAfterLine + 1;

Callers 1

formatBitAuthScriptFunction · 0.85

Calls 2

getDisplayLineFunction · 0.85
getUpdatedLineNumberFunction · 0.85

Tested by

no test coverage detected