[mod] tidy
This commit is contained in:
parent
afb9e59fe4
commit
6ff94888ef
9 changed files with 18 additions and 400 deletions
|
|
@ -8,7 +8,7 @@ module namespace hnd="lsp/handlers";
|
||||||
declare record hnd:State(
|
declare record hnd:State(
|
||||||
result as item()*,
|
result as item()*,
|
||||||
skipchildren? as xs:boolean:=false(),
|
skipchildren? as xs:boolean:=false(),
|
||||||
extras?
|
extras? (: typically map with ?text:)
|
||||||
);
|
);
|
||||||
|
|
||||||
declare type hnd:actionFn as fn(
|
declare type hnd:actionFn as fn(
|
||||||
|
|
|
||||||
|
|
@ -66,21 +66,20 @@ as lspt:Diagnostic*
|
||||||
(: test data :)
|
(: test data :)
|
||||||
declare function lsp-diags:parse-xquery($text as xs:string, $parse as element(Module))
|
declare function lsp-diags:parse-xquery($text as xs:string, $parse as element(Module))
|
||||||
as map(*)*{
|
as map(*)*{
|
||||||
let $state:= hnd:State(())
|
let $state:= hnd:State((),false(),{"text":$text})
|
||||||
let $result:= hnd:walk($parse,$lsp-diags:actions,$state)
|
let $state:= hnd:walk($parse,$lsp-diags:actions,$state)
|
||||||
return $result?result
|
return $state?result
|
||||||
};
|
};
|
||||||
|
|
||||||
declare function lsp-diags:Module($parse as element(Module),$state as hnd:State )
|
declare function lsp-diags:Module($parse as element(Module),$state as hnd:State )
|
||||||
as hnd:State{
|
as hnd:State{
|
||||||
let $new:=if(exists($parse/VersionDecl)=>trace("has ver: "))
|
let $new:=if(exists($parse/VersionDecl)=>trace("has ver: "))
|
||||||
then ()
|
then ()
|
||||||
else let $text:="dddjjjjjjjjjjjjjjjj"
|
else let $text:=$state?extras?text
|
||||||
let $e:=1
|
|
||||||
let $last:=8
|
|
||||||
return lspt:Diagnostic(lspt:Range(
|
return lspt:Diagnostic(lspt:Range(
|
||||||
pos:toPosition($text, 1 ),
|
pos:toPosition($text, 0 ),
|
||||||
pos:toPosition($text, 1)
|
pos:toPosition($text, 0)
|
||||||
),
|
),
|
||||||
$lspt:SeverityKind?info,
|
$lspt:SeverityKind?info,
|
||||||
"No XQuery version declaration present",
|
"No XQuery version declaration present",
|
||||||
|
|
@ -88,7 +87,7 @@ as hnd:State{
|
||||||
return (
|
return (
|
||||||
$state
|
$state
|
||||||
=>map:put("result",($state?result,$new=>trace(" VER ")))
|
=>map:put("result",($state?result,$new=>trace(" VER ")))
|
||||||
=>map:put("skipchildren",true())
|
=>map:put("skipchildren",false())
|
||||||
|
|
||||||
,message(name($parse),"Module: ")
|
,message(name($parse),"Module: ")
|
||||||
)
|
)
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
6
webapp/static/clients/bootstrap@5.3.7.css
vendored
6
webapp/static/clients/bootstrap@5.3.7.css
vendored
File diff suppressed because one or more lines are too long
|
|
@ -1,80 +0,0 @@
|
||||||
.wrapper {
|
|
||||||
height: 100vh;
|
|
||||||
overflow: hidden;
|
|
||||||
display: grid;
|
|
||||||
grid-gap: 0;
|
|
||||||
grid-template-areas:
|
|
||||||
"header header"
|
|
||||||
"sidebar content"
|
|
||||||
"footer footer"
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebar {
|
|
||||||
grid-area: sidebar;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content {
|
|
||||||
grid-area: content;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header {
|
|
||||||
grid-area: header;
|
|
||||||
}
|
|
||||||
|
|
||||||
.footer {
|
|
||||||
grid-area: footer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set editor dimensions */
|
|
||||||
#editor {
|
|
||||||
height: 90%;
|
|
||||||
max-width: 100%;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Stretch editor to fit inside its containing div */
|
|
||||||
.cm-editor {
|
|
||||||
height: 100%;
|
|
||||||
width: 100%;
|
|
||||||
overflow: auto;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.container {
|
|
||||||
display: grid;
|
|
||||||
grid-template-rows: auto 1fr auto;
|
|
||||||
min-height: 100vh;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Tablet view */
|
|
||||||
@media (min-width: 768px) {
|
|
||||||
.main-layout {
|
|
||||||
grid-template-columns: 1fr 1fr;
|
|
||||||
/* Two columns for sidebars */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Desktop view */
|
|
||||||
@media (min-width: 1024px) {
|
|
||||||
.main-layout {
|
|
||||||
grid-template-columns: 200px 1fr 200px;
|
|
||||||
/* Fixed sidebars, fluid main */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
font-family: 'Roboto', sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
.left-sidebar,
|
|
||||||
.right-sidebar {
|
|
||||||
background-color: var(--surface);
|
|
||||||
/* Use BeerCSS surface color */
|
|
||||||
}
|
|
||||||
|
|
||||||
main {
|
|
||||||
background-color: var(--background);
|
|
||||||
/* Main content background */
|
|
||||||
}
|
|
||||||
|
|
@ -1,152 +0,0 @@
|
||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Beer example using BaseX LSP</title>
|
|
||||||
<link rel="icon" type="image/png" href="../favicon.png" />
|
|
||||||
<link href="../beercss-3.12.3/beer.min.css" rel="stylesheet" />
|
|
||||||
<link href="beer.css" rel="stylesheet" />
|
|
||||||
|
|
||||||
<script src="popover.js" defer></script>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div class="wrapper">
|
|
||||||
<header class="header row tertiary">
|
|
||||||
|
|
||||||
<a id="help">XQuery 4.0 LSP client</a>
|
|
||||||
<button popovertarget="popHelp" class="circle transparent"><i>info</i></button>
|
|
||||||
<div class="max"></div>
|
|
||||||
<a class="nav-link active" aria-current="page" href="#">Editor</a>
|
|
||||||
|
|
||||||
<a class="nav-link" href="#">Msgs</a>
|
|
||||||
|
|
||||||
<a class="nav-link" href="/dba/logs" target="dba">Dba</a>
|
|
||||||
|
|
||||||
<div class="max"></div>
|
|
||||||
|
|
||||||
<button id="popcon" popovertarget="popConnect" class="circle transparent error">
|
|
||||||
<i>Cloud_Off</i>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
|
|
||||||
</header>
|
|
||||||
<article class="sidebar">
|
|
||||||
|
|
||||||
<div id="msg">(msgs)</div>
|
|
||||||
<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>
|
|
||||||
</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.xq">
|
|
||||||
generator.xquery</option>
|
|
||||||
|
|
||||||
</optgroup>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<ul id="traffic" style="overflow: scroll;">
|
|
||||||
<li>-</li>
|
|
||||||
</ul>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
<main class="content">
|
|
||||||
<div class="row top">
|
|
||||||
<nav class="group connected">
|
|
||||||
<label for="file">File:</label>
|
|
||||||
<input id="iFile" type="url" value="file:///some/file.xqm" />
|
|
||||||
<select id="language">
|
|
||||||
<option selected>Language</option>
|
|
||||||
<option value="plaintext">plaintext</option>
|
|
||||||
<option value="xquery">xquery</option>
|
|
||||||
<option value="xml">xml</option>
|
|
||||||
</select>
|
|
||||||
<label for="symbols">Symbols:</label><select id="symbols" disabled="disabled"></select>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<nav class="group connected">
|
|
||||||
<button id="search" title="Search" type="button" class=""><i>Search</i></button>
|
|
||||||
|
|
||||||
<button id="lint" title="Diagnostics" type="button" class=""><i>Data_Alert</i></button>
|
|
||||||
|
|
||||||
<button id="sync" title="Sync changes to server" type="button" class="btn btn-light">
|
|
||||||
<i>Sync</i>
|
|
||||||
</button>
|
|
||||||
<button id="fullscreen" title="Full screen" type="button" class="btn btn-light">
|
|
||||||
<i>Fullscreen</i>
|
|
||||||
</button>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<nav class="group connected">
|
|
||||||
|
|
||||||
<button id="syntax" type="button" class="btn btn-light" title="Syntax">
|
|
||||||
<i>Chat</i></button>
|
|
||||||
|
|
||||||
<button id="format" type="button" class="btn btn-light" title="Format (Shift-Alt-f)">
|
|
||||||
<i>Format_Align_Left</i></button>
|
|
||||||
|
|
||||||
<button id="cmd" type="button" class="btn btn-light" title="Cmd ">
|
|
||||||
<i>Order_Play</i>
|
|
||||||
</button>
|
|
||||||
<button type="button" class="btn btn-light" popovertarget="popSettings" title="Settings">
|
|
||||||
<i>Settings</i></button>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
<!-- Editor goes in here -->
|
|
||||||
<div id="editor"></div>
|
|
||||||
</main>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Popovers -->
|
|
||||||
<dialog id="popConnect" popover>
|
|
||||||
<header>Connect to LSP
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
||||||
</header>
|
|
||||||
<div class="modal-body">
|
|
||||||
<div id="state">🔴</div>
|
|
||||||
<input id="iServer" type="text" style="width:25em" />
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<button id="connect">connect</button>
|
|
||||||
</div>
|
|
||||||
</dialog>
|
|
||||||
|
|
||||||
<popup-info id="popHelp">hhhh</popup-info>
|
|
||||||
|
|
||||||
<dialog id="popSettings" popover>
|
|
||||||
<header>Editor configuration
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"
|
|
||||||
onclick="$('popSettings').hidePopover(); "></button>
|
|
||||||
</header>
|
|
||||||
<div class="modal-body">
|
|
||||||
@TODO
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<button id="connect">ok</button>
|
|
||||||
</div>
|
|
||||||
</dialog>
|
|
||||||
|
|
||||||
<!-- CodeMirror 6 -->
|
|
||||||
<script src="./lsp.bundle.js"></script>
|
|
||||||
<script type="module" src="../beercss-3.12.3/beer.min.js"></script>
|
|
||||||
<script src="./beer.js"></script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
|
|
@ -1,127 +0,0 @@
|
||||||
const view = new lsp.EditorView({
|
|
||||||
extensions: lsp.baseExts,
|
|
||||||
parent: document.getElementById("editor")
|
|
||||||
});
|
|
||||||
let doc = "xquery version '3.1';\n(:~ comment:)\nmodule namespace pdfbox='ns';\n";
|
|
||||||
var client;
|
|
||||||
var extLint;
|
|
||||||
|
|
||||||
function $(id) { return document.getElementById(id) };
|
|
||||||
|
|
||||||
// Load saved content from localStorage when the page loads
|
|
||||||
window.addEventListener('load', () => {
|
|
||||||
const savedText = localStorage.getItem('code');
|
|
||||||
if (savedText) doc = savedText;
|
|
||||||
let svr = localStorage.getItem('lsp');
|
|
||||||
if (!svr) {
|
|
||||||
let x = new URL(window.location.href);
|
|
||||||
x.protocol = "ws";
|
|
||||||
x.pathname = "ws/lsp"
|
|
||||||
svr = x.href;
|
|
||||||
}
|
|
||||||
$("iServer").value = svr;
|
|
||||||
view.setState(lsp.EditorState.create({ doc: doc, extensions: lsp.baseExts }));
|
|
||||||
connect();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Save content to localStorage when the page is about to unload
|
|
||||||
window.addEventListener('beforeunload', () => {
|
|
||||||
const doc = view.state.doc.toString();
|
|
||||||
localStorage.setItem('code', doc);
|
|
||||||
localStorage.setItem('lsp', $("iServer").value);
|
|
||||||
});
|
|
||||||
|
|
||||||
$("connect").onclick = e => { e.preventDefault(); connect() };
|
|
||||||
|
|
||||||
$("search").onclick = e => lsp.openSearchPanel(view);
|
|
||||||
|
|
||||||
$("fullscreen").onclick = e => $("editor").requestFullscreen();
|
|
||||||
|
|
||||||
$("cmd").onclick = e => console.log("CMDS", lsp.listCommands(view));
|
|
||||||
|
|
||||||
$("lint").onclick = async e => {
|
|
||||||
console.log("word", view.state.wordAt(1));
|
|
||||||
lsp.openLintPanel(view);
|
|
||||||
};
|
|
||||||
|
|
||||||
$("sync").onclick = e => { client.sync(); console.log("XXXsync"); };
|
|
||||||
|
|
||||||
$("format").onclick = e => {
|
|
||||||
console.log("FMT", lsp.formatDocument(view));
|
|
||||||
};
|
|
||||||
|
|
||||||
$("load").onchange = e => {
|
|
||||||
const url = e.target.value;
|
|
||||||
if (url.length == 0) return
|
|
||||||
fetch(url)
|
|
||||||
.then(response => response.text())
|
|
||||||
.then(t => {
|
|
||||||
view.dispatch({
|
|
||||||
|
|
||||||
changes: {
|
|
||||||
from: 0,
|
|
||||||
to: view.state.doc.length,
|
|
||||||
insert: t
|
|
||||||
}
|
|
||||||
})
|
|
||||||
//client.sync();
|
|
||||||
//console.log("SYNC");
|
|
||||||
});
|
|
||||||
$("load").value = "";
|
|
||||||
};
|
|
||||||
function connect() {
|
|
||||||
const server = $("iServer").value;
|
|
||||||
const file = $("iFile").value;
|
|
||||||
lsp.simpleWebSocketTransport(server)
|
|
||||||
.then(transport => {
|
|
||||||
transport.socket.onclose = (event) => connectStatus(false);
|
|
||||||
transport.socket.oneror = (event) => $("msg").innerText = "sock error!";
|
|
||||||
transport.subscribe(incoming);
|
|
||||||
client = new lsp.LSPClient({ extensions: lsp.languageServerExtensions() });
|
|
||||||
client.connect(transport);
|
|
||||||
$("popConnect").hidePopover();
|
|
||||||
connectStatus(true);
|
|
||||||
let extLsp = client.plugin(file, "xquery");
|
|
||||||
|
|
||||||
view.dispatch({
|
|
||||||
effects: lsp.StateEffect.appendConfig.of(
|
|
||||||
[lsp.linter(null, { autoPanel: true }), ...extLsp,
|
|
||||||
lsp.keymap.of([...lsp.formatKeymap])])
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.catch(e => {
|
|
||||||
console.log(e);
|
|
||||||
connectStatus(false);
|
|
||||||
alert("connection failed: " + server)
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
function connectStatus(bool) {
|
|
||||||
if (bool) {
|
|
||||||
$("popcon").querySelector("i").innerText="cloud"
|
|
||||||
$("popcon").classList.remove("error")
|
|
||||||
$("popcon").classList.add("primary")
|
|
||||||
} else {
|
|
||||||
$("popcon").querySelector("i").innerText="cloud_off"
|
|
||||||
$("popcon").classList.add("error")
|
|
||||||
$("popcon").classList.remove("primary")
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function incoming(msg) {
|
|
||||||
const rpc = JSON.parse(msg);
|
|
||||||
log(rpc);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
function log(rpc) {
|
|
||||||
console.log("<-", rpc)
|
|
||||||
if (rpc.id) return
|
|
||||||
const text = rpc.method;
|
|
||||||
const li = document.createElement("li");
|
|
||||||
const n = $("traffic").childElementCount + " ";
|
|
||||||
li.appendChild(document.createTextNode(n + text));
|
|
||||||
$("traffic").insertBefore(li, $("traffic").firstChild)
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
@ -81,7 +81,7 @@
|
||||||
LSP Manager <quiet-icon name="external-link" slot="icon"></quiet-icon></quiet-dropdown-item>
|
LSP Manager <quiet-icon name="external-link" slot="icon"></quiet-icon></quiet-dropdown-item>
|
||||||
<quiet-dropdown-item href="/dba/logs" target="dba" rel="noreferrer noopener">
|
<quiet-dropdown-item href="/dba/logs" target="dba" rel="noreferrer noopener">
|
||||||
Dba <quiet-icon name="external-link" slot="icon"></quiet-icon></quiet-dropdown-item>
|
Dba <quiet-icon name="external-link" slot="icon"></quiet-icon></quiet-dropdown-item>
|
||||||
|
<quiet-divider></quiet-divider>
|
||||||
</quiet-dropdown>
|
</quiet-dropdown>
|
||||||
<button popovertarget="popAbout" type="button">
|
<button popovertarget="popAbout" type="button">
|
||||||
<i class="codicon codicon-info"></i>
|
<i class="codicon codicon-info"></i>
|
||||||
|
|
@ -182,34 +182,23 @@
|
||||||
|
|
||||||
<footer class="page-footer">
|
<footer class="page-footer">
|
||||||
<div style="display:flex;">
|
<div style="display:flex;">
|
||||||
<select id="language" style="width:10em;display:inline-block;">
|
|
||||||
<option selected>Language</option>
|
|
||||||
<option value="plaintext">plaintext</option>
|
|
||||||
<option value="xquery">xquery</option>
|
|
||||||
<option value="xml">xml</option>
|
|
||||||
</select>
|
|
||||||
<div>
|
<div>
|
||||||
<label for="iFile">File:</label>
|
<label for="iFile">File:</label>
|
||||||
<input id="iFile" type="url" value="file:///some/file.xqm"
|
<input id="iFile" type="url" value="file:///some/file.xqm"
|
||||||
style="width:10em;display:inline-block;" />
|
style="width:20em;display:inline-block;" />
|
||||||
|
|
||||||
<label for="symbols">Symbols:</label>
|
<label for="symbols">Symbols:</label>
|
||||||
<select id="symbols" disabled="disabled" style="width:10em;display:inline-block;"></select>
|
<select id="symbols" disabled="disabled" style="width:10em;display:inline-block;"></select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<quiet-relative-time live id="relative-time__live" style="width:10em;"></quiet-relative-time>
|
<quiet-relative-time live id="relative-time__live" style="width:10em;"></quiet-relative-time>
|
||||||
<quiet-dropdown id="dropdown__checkboxes">
|
<select id="language" style="width:10em;display:inline-block;">
|
||||||
<quiet-button slot="trigger"><i class='codicon codicon-kebab-vertical'></i></quiet-button>
|
<option selected>Language</option>
|
||||||
<quiet-dropdown-item type="checkbox" value="canvas" checked>Follow cursor</quiet-dropdown-item>
|
<option value="plaintext">plaintext</option>
|
||||||
|
<option value="xquery">xquery</option>
|
||||||
<quiet-divider></quiet-divider>
|
<option value="xml">xml</option>
|
||||||
<quiet-dropdown-item type="checkbox" value="position" checked>sort by: Position</quiet-dropdown-item>
|
</select>
|
||||||
<quiet-dropdown-item type="checkbox" value="name">sort by: Name</quiet-dropdown-item>
|
|
||||||
<quiet-dropdown-item type="checkbox" value="category">sort by: Category</quiet-dropdown-item>
|
|
||||||
</quiet-dropdown>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
<!-- dialogs -->
|
<!-- dialogs -->
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Add table
Reference in a new issue