From 529b57d628263fcda0eeab921b238161cf014cd2 Mon Sep 17 00:00:00 2001 From: Andy Bunce Date: Tue, 7 Oct 2025 17:23:32 +0100 Subject: [PATCH] [mod] tidy --- test/diagnostic.xq | 7 +++---- test/sample.docs/pdfbox.xqm | 2 +- .../{pdfbox.xqng => pdfbox3-bad.xqm} | 9 ++++----- webapp/lsp/lsp-text.xqm | 1 + webapp/lsp/providers/documentSymbols.xqm | 3 ++- webapp/static/clients/codemirror/grail.html | 2 +- webapp/static/clients/codemirror/list.js | 18 ++++-------------- webapp/static/clients/codemirror/script.js | 6 +++--- 8 files changed, 19 insertions(+), 29 deletions(-) rename test/sample.docs/{pdfbox.xqng => pdfbox3-bad.xqm} (99%) diff --git a/test/diagnostic.xq b/test/diagnostic.xq index 03e98ac..1e5781e 100644 --- a/test/diagnostic.xq +++ b/test/diagnostic.xq @@ -1,6 +1,5 @@ -import module namespace hnd="lsp/handlers" at "../webapp/lsp/handlers.xqm"; -import module namespace syms="lsp/symbols" at "../webapp/lsp/providers/documentSymbols.xqm"; +import module namespace lsp-diags = 'lsp-diags' at "../webapp/lsp/providers/diagnostics.xqm"; declare variable $src:="sample.docs/parse-pdfbox.xml"; declare variable $parse:=doc($src)/*; - -hnd:diags($parse ) +declare variable $text:=unparsed-text("sample.docs/pdfbox3-bad.xqm"); +lsp-diags:list("file",$text,$parse ) diff --git a/test/sample.docs/pdfbox.xqm b/test/sample.docs/pdfbox.xqm index 22d14d8..474d450 100644 --- a/test/sample.docs/pdfbox.xqm +++ b/test/sample.docs/pdfbox.xqm @@ -34,7 +34,7 @@ declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"; declare namespace RandomAccessReadBuffer="java:org.apache.pdfbox.io.RandomAccessReadBuffer"; declare namespace RandomAccessReadBufferedFile = "java:org.apache.pdfbox.io.RandomAccessReadBufferedFile"; -declare namespace PDRectangle="org.apache.pdfbox.pdmodel.common.PDRectangle"; +declare namespace PDRectangle="java:org.apache.pdfbox.pdmodel.common.PDRectangle"; declare namespace File ="java:java.io.File"; diff --git a/test/sample.docs/pdfbox.xqng b/test/sample.docs/pdfbox3-bad.xqm similarity index 99% rename from test/sample.docs/pdfbox.xqng rename to test/sample.docs/pdfbox3-bad.xqm index 22d14d8..572d067 100644 --- a/test/sample.docs/pdfbox.xqng +++ b/test/sample.docs/pdfbox3-bad.xqm @@ -1,5 +1,6 @@ -xquery version '3.1'; +xquery version '3.1'; (:~ +A BaseX 10.7+ interface to pdfbox3 https://pdfbox.apache.org/ , requires pdfbox jars on classpath, in lib/custom or xar @note following the java source the terms outline and bookmark refer to the same concept. Also label and (page)range are used interchangably @@ -286,8 +287,7 @@ as map(*)*{ =>PDDocumentCatalog:getDocumentOutline() return if(exists($outline)) - then pdfbox:outline($pdf,PDOutlineItem:getFirstChild($outline)) - else () + then pdfbox:outline($pdf,PDOutlineItem:getFirstChild($outline)) } }; @@ -364,7 +364,6 @@ as item()? then PDDocument:getDocumentCatalog($pdf) =>PDDocumentCatalog:getPages() =>PDPageTree:indexOf($page) - else () }; (:~ Return new PDF doc with pages from $start to $end as xs:base64Binary, (1 based) @@ -436,7 +435,7 @@ as xs:string?{ return string-join(($page, if(empty($style)) then "-" else $style, if(($start eq 1)) then "" else $start, - if(exists($prefix)) then '*' || $prefix else () (:TODO double " :) + if(exists($prefix)) then '*' || $prefix (:TODO double " :) )) }; diff --git a/webapp/lsp/lsp-text.xqm b/webapp/lsp/lsp-text.xqm index 5ba7d30..18eee32 100644 --- a/webapp/lsp/lsp-text.xqm +++ b/webapp/lsp/lsp-text.xqm @@ -7,6 +7,7 @@ import module namespace docs="lsp/docs" at "docs.xqm"; import module namespace rpc = 'rpc' at 'jsonrpc.xqm'; import module namespace lspt = 'lsp-typedefs' at 'lsp-typedefs.xqm'; import module namespace pos="lsp/position" at "position.xqm"; +import module namespace syms="lsp/symbols" at "providers/documentSymbols.xqm"; declare variable $lsp-text:methods:=map{ "textDocument/didOpen": lsp-text:didOpen#1, diff --git a/webapp/lsp/providers/documentSymbols.xqm b/webapp/lsp/providers/documentSymbols.xqm index 96eca9f..85b55fc 100644 --- a/webapp/lsp/providers/documentSymbols.xqm +++ b/webapp/lsp/providers/documentSymbols.xqm @@ -5,7 +5,7 @@ import module namespace hnd="lsp/handlers" at "../handlers.xqm"; import module namespace lspt = 'lsp-typedefs' at "../lsp-typedefs.xqm"; declare function syms:list($parse as element(),$syms as lspt:DocumentSymbol* :=() ) -{ +as lspt:DocumentSymbol*{ let $actions as hnd:actionMap :={ "ContextValueDecl": syms:action#2, "VarDecl": syms:VarDecl#2, @@ -18,6 +18,7 @@ declare function syms:list($parse as element(),$syms as lspt:DocumentSymbol* :=( return $result?result }; +(:~ just trace :) declare function syms:action($parse as element(),$state as hnd:Result ) as hnd:Result{ hnd:Result($state?result,true()) ,message(name($parse),"ACTION: ") diff --git a/webapp/static/clients/codemirror/grail.html b/webapp/static/clients/codemirror/grail.html index 8b6581a..0e416a0 100644 --- a/webapp/static/clients/codemirror/grail.html +++ b/webapp/static/clients/codemirror/grail.html @@ -172,7 +172,7 @@ -