[add] connection state
This commit is contained in:
parent
b7d0d8e03d
commit
e32ff3d77a
8 changed files with 81 additions and 28 deletions
|
@ -1,5 +1,5 @@
|
|||
declare base-uri "../..";
|
||||
import module namespace xq4="java:quodatum.parser.xq4";
|
||||
(: "test/sample.docs/pdfbox.xqm"=>unparsed-text() :)
|
||||
"2+4"
|
||||
=>xq4:parseModule()
|
||||
""
|
||||
=>xq4:parseModule()
|
||||
|
|
|
@ -12,7 +12,7 @@ import { LSPClient, LSPPlugin, languageServerSupport } from "@codemirror/lsp-cli
|
|||
// Language
|
||||
import { xml } from "@codemirror/lang-xml";
|
||||
|
||||
// no error checking
|
||||
// return promise with socket map or reject if no connect
|
||||
function simpleWebSocketTransport(uri) {
|
||||
let handlers = [];
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
import module namespace pos="lsp/position" at "../webapp/lsp/position.xqm";
|
||||
import module namespace xq4="java:quodatum.parser.xq4";
|
||||
let $text:="1+2 a"
|
||||
|
||||
return pos:toPosition($text,5)
|
||||
let $xml:=xq4:parseModule($text)=>trace("£ ")
|
||||
let $b:=number($xml/@b)-1
|
||||
let $e:= number($xml/@e)-1
|
||||
return (pos:toPosition($text,$b),
|
||||
pos:toPosition($text, min(($e,string-length($text)-1))))
|
||||
|
5
webapp/static/clients/bootstrap-icons.min.css
vendored
Normal file
5
webapp/static/clients/bootstrap-icons.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -6,6 +6,7 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Codemirror6 example using BaseX LSP</title>
|
||||
<link rel="icon" type="image/png" href="../favicon.png" />
|
||||
|
||||
<link href="../bootstrap@5.3.7.css" rel="stylesheet"
|
||||
integrity="sha384-LN+7fdVzj6u52u30Kp6M/trliBMCMKTyK833zpbD+pXdCLuTusPj697FH4R/5mcr" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="styles.css" />
|
||||
|
@ -17,12 +18,17 @@
|
|||
<div class="container-fluid">
|
||||
<a class="navbar-brand">BaseX LSP client</a>
|
||||
<a href="/dba/logs" target="dba">#</a>
|
||||
|
||||
<form class="d-flex">
|
||||
<span id="state">🔴</span>
|
||||
<input id="iServer" type="text" value="ws://localhost:3000/ws/lsp2" style="width:25em" />
|
||||
<button id="connect">connect</button>
|
||||
</form>
|
||||
<div class="btn-toolbar" role="toolbar" aria-label="Toolbar with button groups">
|
||||
<button id="popcon" popovertarget="mypopover" class="btn btn-danger">
|
||||
<i class="bi bi-router"></i>
|
||||
</button>
|
||||
<div id="mypopover" popover>
|
||||
<h2>Connect to LSP</h2>
|
||||
<div id="state">🔴</div>
|
||||
<input id="iServer" type="text" value="ws://localhost:3000/ws/lsp" style="width:25em" />
|
||||
<button id="connect">connect</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div>
|
||||
<select id="language">
|
||||
|
@ -33,10 +39,28 @@
|
|||
</select>
|
||||
<label for="file">File:</label>
|
||||
<input id="iFile" type="url" value="file:///some/file.xml" />
|
||||
<button id="search">🔍</button>
|
||||
<button id="lint">⚠️</button>
|
||||
<button id="sync">🔄</button>
|
||||
|
||||
|
||||
<!-- <div class="btn-group mr-2" role="group" aria-label="First group">
|
||||
<button type="button" class="btn btn-secondary">1</button>
|
||||
<button type="button" class="btn btn-secondary">2</button>
|
||||
<button type="button" class="btn btn-secondary">3</button>
|
||||
<button type="button" class="btn btn-secondary">4</button>
|
||||
</div> -->
|
||||
<div class="btn-group btn-group-sm " role="group" aria-label="Second group">
|
||||
<button id="search" type="button" class="btn btn-light"><i
|
||||
class="bi bi-search"></i></button>
|
||||
<button id="lint" type="button" class="btn btn-light"><i
|
||||
class="bi bi-info-square"></i></button>
|
||||
<button id="sync" type="button" class="btn btn-light">
|
||||
<i class="bi bi-arrow-repeat"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="btn-group" role="group" aria-label="Third group">
|
||||
<button type="button" class="btn btn-light"><i class="bi bi-justify-left"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -46,25 +70,33 @@
|
|||
<div class="row " style="overflow:hidden">
|
||||
<div class="col-2">
|
||||
<div id="msg"> </div>
|
||||
<select id="load">
|
||||
<select id="load">
|
||||
<option selected value="">load..</option>
|
||||
<optgroup label="XQuery3">
|
||||
<option value="https://raw.githubusercontent.com/expkg-zone58/pdfbox/refs/heads/main/src/Pdfbox3.xqm">Pdfbox3.xqm</option>
|
||||
<option value="https://raw.githubusercontent.com/Quodatum/xqdoca/refs/heads/master/src/main/lib/model.xqm">model.xqm</option>
|
||||
<option
|
||||
value="https://raw.githubusercontent.com/expkg-zone58/pdfbox/refs/heads/main/src/Pdfbox3.xqm">
|
||||
Pdfbox3.xqm</option>
|
||||
<option
|
||||
value="https://raw.githubusercontent.com/Quodatum/xqdoca/refs/heads/master/src/main/lib/model.xqm">
|
||||
model.xqm</option>
|
||||
</optgroup>
|
||||
<optgroup label="XQuery4">
|
||||
<option value="https://git.quodatum.duckdns.org/quodatum/basex-lsp/raw/branch/main/webapp/lsp/lsp-text.xqm">lsp-text.xqm</option>
|
||||
|
||||
</optgroup>
|
||||
<optgroup label="xpath">
|
||||
<option value="https://raw.githubusercontent.com/dnovatchev/Articles/refs/heads/main/Generators/Code/generator.xpath">generator.xpath</option>
|
||||
|
||||
<option
|
||||
value="https://git.quodatum.duckdns.org/quodatum/basex-lsp/raw/branch/main/webapp/lsp/lsp-text.xqm">
|
||||
lsp-text.xqm</option>
|
||||
|
||||
</optgroup>
|
||||
</select>
|
||||
<label for="symbols">Symbols:</label><select id="symbols" disabled="disabled"></select>
|
||||
<ul id="traffic" style="overflow: scroll;">
|
||||
<optgroup label="xpath">
|
||||
<option
|
||||
value="https://raw.githubusercontent.com/dnovatchev/Articles/refs/heads/main/Generators/Code/generator.xpath">
|
||||
generator.xpath</option>
|
||||
|
||||
</optgroup>
|
||||
</select>
|
||||
<label for="symbols">Symbols:</label><select id="symbols" disabled="disabled"></select>
|
||||
<ul id="traffic" style="overflow: scroll;">
|
||||
<li>-</li>
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="col flex-grow-1" style="overflow: auto;">
|
||||
|
|
|
@ -65,9 +65,10 @@ function connect() {
|
|||
lsp.simpleWebSocketTransport(server)
|
||||
.then(transport => {
|
||||
transport.subscribe(incoming);
|
||||
transport.socket.onclose=(event) => $("msg").innerText="sock gone!";
|
||||
transport.socket.onclose=(event) => connectStatus(false);
|
||||
transport.socket.oneror=(event) => $("msg").innerText="sock error!";
|
||||
client = new lsp.LSPClient().connect(transport);
|
||||
connectStatus(true);
|
||||
let extLsp=lsp.languageServerSupport(client,file,"xquery");
|
||||
extLint=lsp.linter(
|
||||
view=>{ client.sync();return [];},
|
||||
|
@ -79,6 +80,15 @@ function connect() {
|
|||
.catch(r => alert("connection failed: "+ server));
|
||||
};
|
||||
|
||||
function connectStatus(bool){
|
||||
if(bool){
|
||||
$("popcon").classList.remove("btn-danger")
|
||||
$("popcon").classList.add("btn-success")
|
||||
}else{
|
||||
$("popcon").classList.add("btn-danger")
|
||||
$("popcon").classList.remove("btn-success")
|
||||
}
|
||||
}
|
||||
function incoming(msg) {
|
||||
const rpc=JSON.parse(msg);
|
||||
log(rpc);
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
|
||||
@import url("../bootstrap-icons.min.css");
|
||||
/* Set editor dimensions */
|
||||
#editor {
|
||||
height: 400px;
|
||||
|
|
BIN
webapp/static/clients/fonts/bootstrap-icons.woff2
Normal file
BIN
webapp/static/clients/fonts/bootstrap-icons.woff2
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue