Skip to content

Commit

Permalink
yz.debug.internal.findSourceLineInCode( )
Browse files Browse the repository at this point in the history
  • Loading branch information
yazz committed Jan 9, 2025
1 parent ff03140 commit 3ab31b6
Showing 1 changed file with 114 additions and 114 deletions.
228 changes: 114 additions & 114 deletions public/go.html
Original file line number Diff line number Diff line change
Expand Up @@ -13448,7 +13448,7 @@ <h1 style='width:100%;vertical-align:top;display:inline-block;font-size:100px; t
//
if ((dbgCode != null) && (yz.uiDb.tablesCreated)) {
if (startOfSql.startsWith("insert") || startOfSql.startsWith("update") || startOfSql.startsWith("delete")) {
let sourceForCallerOfFunction = yz.uiDb.findSourceLineInCode(dbgCode)
let sourceForCallerOfFunction = yz.debug.internal.findSourceLineInCode(dbgCode)
let sourceFileName = null
let lineNumber = null
if (sourceForCallerOfFunction.found) {
Expand Down Expand Up @@ -13551,7 +13551,7 @@ <h1 style='width:100%;vertical-align:top;display:inline-block;font-size:100px; t
//
// find the source code where this was called from
//
let sourceForCallerOfFunction = yz.uiDb.findSourceLineInCode(callerDebugToken)
let sourceForCallerOfFunction = yz.debug.internal.findSourceLineInCode(callerDebugToken)


//
Expand All @@ -13564,7 +13564,7 @@ <h1 style='width:100%;vertical-align:top;display:inline-block;font-size:100px; t
console.log(" (" + JSON.stringify(argsPassedIn,null,2) + ")")
yz.debug.debugTick ++
let fnName = yz.uiDb.getFnNameFromStackTrace(fnLine)
let sourceForFunction = yz.uiDb.findSourceLineInCode(fnName + ":")
let sourceForFunction = yz.debug.internal.findSourceLineInCode(fnName + ":")
if (sourceForFunction.found) {
const argsArray = Array.from(argsPassedIn);
const commaSeparatedValues = argsArray.join(', ');
Expand Down Expand Up @@ -13702,7 +13702,7 @@ <h1 style='width:100%;vertical-align:top;display:inline-block;font-size:100px; t
// Find out which source code line we are editing
//
//debugger
let sourceForFunction = yz.uiDb.findSourceLineInCode(debugId)
let sourceForFunction = yz.debug.internal.findSourceLineInCode(debugId)

//
// store the debug code
Expand Down Expand Up @@ -13821,7 +13821,7 @@ <h1 style='width:100%;vertical-align:top;display:inline-block;font-size:100px; t
},

internal: {
readSourceFileForDebugging: async function ( fileName ) {
readSourceFileForDebugging: async function ( fileName ) {
if ((typeof $DEBUGUI == 'undefined') || (!$DEBUGUI)) {
return
}
Expand All @@ -13834,6 +13834,114 @@ <h1 style='width:100%;vertical-align:top;display:inline-block;font-size:100px; t
[yz.uiDb.uiDbNextId ++,result.fileName,result.contents])
yz.debug.linesOfSourceFile[result.fileName] = result.contents.split('\n');
},
findDebugIdInCode: 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 }
},
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...]
Expand Down Expand Up @@ -14096,114 +14204,6 @@ <h1 style='width:100%;vertical-align:top;display:inline-block;font-size:100px; t
await yz.debug.internal.readSourceFileForDebugging("/public/go.html")
await yz.debug.internal.readSourceFileForDebugging("/public/visifile_drivers/apps/appstore.vjs")
},
findDebugIdInCode: 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 }
},
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)

Expand All @@ -14221,7 +14221,7 @@ <h1 style='width:100%;vertical-align:top;display:inline-block;font-size:100px; t
if (lastSpace > lastPeriod) {lastDelimeter = lastSpace}
if (lastSemicolon > lastPeriod) {lastDelimeter = lastSemicolon}
let functionNameString = secondString.substring(lastDelimeter+1,lastParan)
//let sourceForFunction = yz.uiDb.findSourceLineInCode(functionNameString + ":")
//let sourceForFunction = yz.debug.internal.findSourceLineInCode(functionNameString + ":")
return functionNameString
},
getCallStack: function ( ) {
Expand Down

0 comments on commit 3ab31b6

Please sign in to comment.