diff --git a/compose.yaml b/compose.yaml index 537bc7a..2e4930f 100644 --- a/compose.yaml +++ b/compose.yaml @@ -13,7 +13,7 @@ services: - ./webapp/custom:/srv/basex/lib/custom:ro # jars - ./webapp/lsp:/srv/basex/webapp/lsp - ./webapp/static/clients:/srv/basex/webapp/static/clients:ro - - webawesome-3.2.1:/srv/basex/webapp/static/webawesome:ro + - webawesome:/srv/basex/webapp/static/webawesome:ro - ./webapp/lsp-manager:/srv/basex/webapp/lsp-manager # - ./repo:/srv/basex/repo environment: @@ -22,5 +22,6 @@ services: volumes: basex-lsp: - webawesome-3.2.1: + webawesome: external: true + name: webawesome-3.2.1 diff --git a/webapp/lsp/storex.xqm b/webapp/lsp/storex.xqm new file mode 100644 index 0000000..193ac15 --- /dev/null +++ b/webapp/lsp/storex.xqm @@ -0,0 +1,68 @@ +(:~ + Manage a store for websocket info.It is named as the websocket $sid +:) +module namespace storex = 'storex'; + +(: cache has index :) +declare variable $storex:rules:={ + "doc":{ + "description":"A text document" + }, + + "parse":{ + "description":"XML parse tree" , + "depends":"text", + "calc": "xqparse" + }, + + "symbols":{ + "description":"LSP symbols", + "depends":"parse", + "calc": "symbols" + } + +}; +(:~ in store $sid, and key $uri get value of $property :) +declare function storex:get($uri as xs:string,$sid as xs:string,$property as xs:string) +{ +let $id:=storex:id($uri,$sid ) +let $property:=storex:property($property) +return store:get($property || $id,$sid) + otherwise error(xs:QName("storex:get"),`property unknown: '{$property}'`) +}; + +(:~ get value of $property :) +declare function storex:put($uri as xs:string, + $sid as xs:string, + $property as xs:string, + $value as item()) +{ +let $id:=storex:id($uri,$sid ,true() ) +let $property:=storex:property($property) +return store:put($property || $id,$value,$sid) +}; + +(:~ key for $sid and $uri, error if not found unless $add. +if $add then add entry for uri + :) +declare function storex:id($uri as xs:string,$sid as xs:string,$add as xs:boolean:=false()) +{ +let $index:=store:get-or-put("index",fn(){{}},$sid) +return if(map:contains($index,$uri)) + then $index?uri + else if($add) + then let $id:=random:uuid() + return ($id,store:put("index",map:put($index,$uri,$id),$sid)) + else error(xs:QName("storex:get"),`Uri not found: '{$uri}'`) +}; + +(:~ key for $sid and $uri, error if not found unless $add. +if $add then add entry for uri + :) +declare function storex:property($property as xs:string) +as xs:string +{ + if(map:contains($storex:rules,$property)) + then $property + else error(xs:QName("storex:get"),`property not in rules: '{$property}'`) +}; \ No newline at end of file diff --git a/webapp/static/clients/codemirror/index.html b/webapp/static/clients/codemirror/index.html index 16d4d52..5721e7e 100644 --- a/webapp/static/clients/codemirror/index.html +++ b/webapp/static/clients/codemirror/index.html @@ -71,9 +71,9 @@
-
- WORKSPACE - +