File tree Expand file tree Collapse file tree 3 files changed +12
-13
lines changed
commonMain/kotlin/cc/unitmesh/devins/document/docql
jvmTest/kotlin/cc/unitmesh/devins/document/docql Expand file tree Collapse file tree 3 files changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -377,16 +377,14 @@ class CodeDocQLExecutor(
377377 // Filter to function-level chunks and require EXACT name match
378378 val exactMatches = chunks.filter { chunk ->
379379 val title = chunk.chapterTitle ? : " "
380- // Must be a function (not a class)
381- val isFunction = title.contains(" fun " ) ||
382- (! title.startsWith(" class " ) &&
383- ! title.startsWith(" interface " ) &&
384- ! title.startsWith(" enum " ) &&
385- ! title.startsWith(" object " ) &&
386- title.contains(" (" ))
387-
388- if (! isFunction) return @filter false
389-
380+ // Must NOT be a class/interface/enum/object (i.e., must be a function)
381+ val isClassLike = title.startsWith(" class " ) ||
382+ title.startsWith(" interface " ) ||
383+ title.startsWith(" enum " ) ||
384+ title.startsWith(" object " )
385+
386+ if (isClassLike) return @filter false
387+
390388 val funcName = extractFunctionNameFromTitle(title)
391389 funcName.equals(functionName, ignoreCase = true )
392390 }
Original file line number Diff line number Diff line change @@ -477,7 +477,8 @@ class MarkdownDocQLExecutor(
477477 val headers = parseTableRow(tableLines[0 ])
478478
479479 // Skip separator line (e.g., |---|---|)
480- val dataRows = if (tableLines.size > 2 && tableLines[1 ].trim().matches(Regex (" \\ |[:\\ s-|]+\\ |" ))) {
480+ // Note: In the character class, '-' must be at the end to avoid being interpreted as a range
481+ val dataRows = if (tableLines.size > 2 && tableLines[1 ].trim().matches(Regex (" \\ |[:\\ s|\\ -]+\\ |" ))) {
481482 tableLines.drop(2 )
482483 } else {
483484 tableLines.drop(1 )
Original file line number Diff line number Diff line change @@ -157,12 +157,12 @@ class DocQLCodeQueryTest {
157157 )
158158
159159 val parsedFile = parser.parse(file, sampleKotlinCode) as DocumentFile
160-
160+
161161 // Execute $.code.function("execute")
162162 val query = parseDocQL(" $.code.function(\" execute\" )" )
163163 val executor = DocQLExecutor (parsedFile, parser)
164164 val result = executor.execute(query)
165-
165+
166166 assertTrue(result is DocQLResult .Chunks )
167167 val chunks = result as DocQLResult .Chunks
168168 assertTrue(chunks.totalCount >= 1 )
You can’t perform that action at this time.
0 commit comments