From 3ab31b6e73558f446ef91166194004eedc74ed72 Mon Sep 17 00:00:00 2001 From: Zubair Quraishi Date: Thu, 9 Jan 2025 07:27:10 +0100 Subject: [PATCH] yz.debug.internal.findSourceLineInCode( ) --- public/go.html | 228 ++++++++++++++++++++++++------------------------- 1 file changed, 114 insertions(+), 114 deletions(-) diff --git a/public/go.html b/public/go.html index fb5af99bb..791bad074 100644 --- a/public/go.html +++ b/public/go.html @@ -13448,7 +13448,7 @@

linesOfFile.length) { + endLine = linesOfFile.length + } + + for (let currentLineNumber = startLine; currentLineNumber <= endLine ; currentLineNumber ++) { + let currentLine = linesOfFile[currentLineNumber - 1] + + let existsRow = yz.uiDb.sqlui1("select id from ui_table_command_source_file_lines where source_file_name= ? and source_line_number = ?", + [fileSourceRecord.source_file_name , currentLineNumber]) + if (!existsRow) { + yz.uiDb.sqlui("INSERT INTO ui_table_command_source_file_lines ( id , source_file_name , source_line_text , source_line_number ) VALUES (?,?,?,?)", + [yz.uiDb.uiDbNextId ++,fileSourceRecord.source_file_name, currentLine, currentLineNumber]) + } + } + console.log("Filename: " + fileSourceRecord.source_file_name) + foundLine = linesOfFile[lineNumberOfSearchItem - 1] + console.log(" foundOnLine: " + lineNumberOfSearchItem + ":" + foundLine) + + surroundingLines = sqlui("select * from ui_table_command_source_file_lines where source_file_name = ? and source_line_number >= ? and source_line_number <= ?",[foundFile, startLine, endLine]) + + break + } + } + return { found: found , fileName: foundFile, lineNumber: lineNumberOfSearchItem, lineText: foundLine , context: surroundingLines } + }, + findSourceLineInCode: function ( searchText ) { + let found = false + let startLine = null + let endLine = null + let foundLine = null + let foundFile = null + let lineNumberOfSearchItem = null + let surroundingLines = null + + for (let fileSourceRecord of yz.uiDb.uiDbTableData["ui_table_command_source_files"].data) { + console.log("Searching " + fileSourceRecord.source_file_name) + let indexOfSearch = fileSourceRecord.source_text.indexOf(searchText) + + if ( indexOfSearch != -1 ) { + console.log(" Found '" + searchText + "' at index " + indexOfSearch) + found = true + foundFile = fileSourceRecord.source_file_name + + let textUpToSearchItem = fileSourceRecord.source_text.substring(0,indexOfSearch) + let linesOfFileBeforeSearchItem = textUpToSearchItem.split('\n'); + lineNumberOfSearchItem = linesOfFileBeforeSearchItem.length + + let linesOfFile = yz.debug.linesOfSourceFile[fileSourceRecord.source_file_name] + + startLine = lineNumberOfSearchItem - 5 + if (startLine < 1) { + startLine = 1 + } + endLine = lineNumberOfSearchItem + 5 + if (endLine > linesOfFile.length) { + endLine = linesOfFile.length + } + + for (let currentLineNumber = startLine; currentLineNumber <= endLine ; currentLineNumber ++) { + let currentLine = linesOfFile[currentLineNumber - 1] + + let existsRow = yz.uiDb.sqlui1("select id from ui_table_command_source_file_lines where source_file_name= ? and source_line_number = ?", + [fileSourceRecord.source_file_name , currentLineNumber]) + if (!existsRow) { + yz.uiDb.sqlui("INSERT INTO ui_table_command_source_file_lines ( id , source_file_name , source_line_text , source_line_number ) VALUES (?,?,?,?)", + [yz.uiDb.uiDbNextId ++,fileSourceRecord.source_file_name, currentLine, currentLineNumber]) + } + } + console.log("Filename: " + fileSourceRecord.source_file_name) + foundLine = linesOfFile[lineNumberOfSearchItem - 1] + console.log(" foundOnLine: " + lineNumberOfSearchItem + ":" + foundLine) + + surroundingLines = sqlui("select * from ui_table_command_source_file_lines where source_file_name = ? and source_line_number >= ? and source_line_number <= ?",[foundFile, startLine, endLine]) + + break + } + } + return { found: found , fileName: foundFile, lineNumber: lineNumberOfSearchItem, lineText: foundLine , context: surroundingLines } + }, }, linesOfSourceFile: {}, // the lines of code in go.html and other source files = [line 1, line 2, etc...] @@ -14096,114 +14204,6 @@

linesOfFile.length) { - endLine = linesOfFile.length - } - - for (let currentLineNumber = startLine; currentLineNumber <= endLine ; currentLineNumber ++) { - let currentLine = linesOfFile[currentLineNumber - 1] - - let existsRow = yz.uiDb.sqlui1("select id from ui_table_command_source_file_lines where source_file_name= ? and source_line_number = ?", - [fileSourceRecord.source_file_name , currentLineNumber]) - if (!existsRow) { - yz.uiDb.sqlui("INSERT INTO ui_table_command_source_file_lines ( id , source_file_name , source_line_text , source_line_number ) VALUES (?,?,?,?)", - [yz.uiDb.uiDbNextId ++,fileSourceRecord.source_file_name, currentLine, currentLineNumber]) - } - } - console.log("Filename: " + fileSourceRecord.source_file_name) - foundLine = linesOfFile[lineNumberOfSearchItem - 1] - console.log(" foundOnLine: " + lineNumberOfSearchItem + ":" + foundLine) - - surroundingLines = sqlui("select * from ui_table_command_source_file_lines where source_file_name = ? and source_line_number >= ? and source_line_number <= ?",[foundFile, startLine, endLine]) - - break - } - } - return { found: found , fileName: foundFile, lineNumber: lineNumberOfSearchItem, lineText: foundLine , context: surroundingLines } - }, - findSourceLineInCode: function ( searchText ) { - let found = false - let startLine = null - let endLine = null - let foundLine = null - let foundFile = null - let lineNumberOfSearchItem = null - let surroundingLines = null - - for (let fileSourceRecord of yz.uiDb.uiDbTableData["ui_table_command_source_files"].data) { - console.log("Searching " + fileSourceRecord.source_file_name) - let indexOfSearch = fileSourceRecord.source_text.indexOf(searchText) - - if ( indexOfSearch != -1 ) { - console.log(" Found '" + searchText + "' at index " + indexOfSearch) - found = true - foundFile = fileSourceRecord.source_file_name - - let textUpToSearchItem = fileSourceRecord.source_text.substring(0,indexOfSearch) - let linesOfFileBeforeSearchItem = textUpToSearchItem.split('\n'); - lineNumberOfSearchItem = linesOfFileBeforeSearchItem.length - - let linesOfFile = yz.debug.linesOfSourceFile[fileSourceRecord.source_file_name] - - startLine = lineNumberOfSearchItem - 5 - if (startLine < 1) { - startLine = 1 - } - endLine = lineNumberOfSearchItem + 5 - if (endLine > linesOfFile.length) { - endLine = linesOfFile.length - } - - for (let currentLineNumber = startLine; currentLineNumber <= endLine ; currentLineNumber ++) { - let currentLine = linesOfFile[currentLineNumber - 1] - - let existsRow = yz.uiDb.sqlui1("select id from ui_table_command_source_file_lines where source_file_name= ? and source_line_number = ?", - [fileSourceRecord.source_file_name , currentLineNumber]) - if (!existsRow) { - yz.uiDb.sqlui("INSERT INTO ui_table_command_source_file_lines ( id , source_file_name , source_line_text , source_line_number ) VALUES (?,?,?,?)", - [yz.uiDb.uiDbNextId ++,fileSourceRecord.source_file_name, currentLine, currentLineNumber]) - } - } - console.log("Filename: " + fileSourceRecord.source_file_name) - foundLine = linesOfFile[lineNumberOfSearchItem - 1] - console.log(" foundOnLine: " + lineNumberOfSearchItem + ":" + foundLine) - - surroundingLines = sqlui("select * from ui_table_command_source_file_lines where source_file_name = ? and source_line_number >= ? and source_line_number <= ?",[foundFile, startLine, endLine]) - - break - } - } - return { found: found , fileName: foundFile, lineNumber: lineNumberOfSearchItem, lineText: foundLine , context: surroundingLines } - }, findFnNameInDebugString: function ( { line , dbg }) { let indexOfDbgId = line.indexOf(dbg) @@ -14221,7 +14221,7 @@