From bf3dd4d69342b4a733488665fc614dc574a139dc Mon Sep 17 00:00:00 2001 From: Andy Bunce Date: Mon, 4 Aug 2025 13:00:18 +0100 Subject: [PATCH] [fix] syntax --- webapp/lsp/docs.xqm | 16 +++++++++------- webapp/lsp/lint.xqm | 31 +++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 webapp/lsp/lint.xqm diff --git a/webapp/lsp/docs.xqm b/webapp/lsp/docs.xqm index 1975698..91a9f40 100644 --- a/webapp/lsp/docs.xqm +++ b/webapp/lsp/docs.xqm @@ -55,10 +55,10 @@ return ( ) }; -declare function docs:resolvePosition(text as xs:string, pos as docs:Position) +declare function docs:resolvePosition($text as xs:string, $pos as docs:Position) as xs:integer { - let line = 0, off = 0 + (: let line = 0, off = 0 while (line < pos.line) { let next = text.indexOf("\n", off) if (!next) throw new RangeError("Position out of bounds") @@ -67,15 +67,17 @@ as xs:integer } off += pos.character if (off > string-length($text)) throw new RangeError("Position out of bounds") - return off -} + return off :) + 0 +}; declare function docs:toPosition($text as xs:string, $pos as xs:integer) as docs:Position { - for (let off = 0, line = 0;;) { + (: for (let off = 0, line = 0;;) { let next = text.indexOf("\n", off) if (next < 0 || next >= pos) return {line, character: pos - off} off = next + 1 line++ - } -} \ No newline at end of file + } :) + docs:Position(0,0) +}; \ No newline at end of file diff --git a/webapp/lsp/lint.xqm b/webapp/lsp/lint.xqm new file mode 100644 index 0000000..8e39c19 --- /dev/null +++ b/webapp/lsp/lint.xqm @@ -0,0 +1,31 @@ +module namespace lint="lsp/lint"; +(: + Describes a problem or hint for a piece of code. + + from: number + + The start position of the relevant text. + to: number + + The end position. May be equal to from, though actually covering text is preferable. + severity: "error" | "hint" | "info" | "warning" + + The severity of the problem. This will influence how it is displayed. + markClass⁠?: string + + When given, add an extra CSS class to parts of the code that this diagnostic applies to. + source⁠?: string + + An optional source string indicating where the diagnostic is coming from. You can put the name of your linter here, if applicable. + message: string + + The message associated with this diagnostic. + renderMessage⁠?: fn(view: EditorView) → Node + + An optional custom rendering function that displays the message as a DOM node. + actions⁠?: readonly Action[] + + An optional array of actions that can be taken on this diagnostic. + + +:) \ No newline at end of file