Open ljos opened 9 years ago
Also look at LSP:
I made a basic implementation for that no idea how to integrate it properly, it works because I have a node_modules in my project (projectile).
https://gist.github.com/bjonnh/dc274cc64aef296d65e37fe71bcf6cbc
Flycheck works well for me, using qparse from Jena. Since I'm on Windows, the command is qparse.bat:
(flycheck-define-checker sparql-syntax
"A SPARQL syntax checker using ARQ qparse. See URL https://jena.apache.org/documentation/query/cmds.html."
:command ("qparse.bat" "--query" source)
:error-patterns
((error line-start "Encountered \"" (message) "\" at line " line ", column " column "." line-end)
(error line-start "Lexical error at line " line ", column " column "." (+ space) "Encountered: " (message) line-end))
:modes sparql-mode)
(add-to-list 'flycheck-checkers 'sparql-syntax)
(add-hook 'sparql-mode-hook 'flycheck-mode)
@johanwk @ljos
1) sparql-mode also works well on SPARQL Update files (*.ru
).
Would it be possible to make the flychecker work for such files as well?
Jena has another command update
that produces errors in the same format as qparse
(see below).
Maybe the cleanest approach is to define a derived sparql-update-mode
?
update --update <query>.ru
org.apache.jena.query.QueryParseException: Lexical error at line 7, column 2. Encountered: "\r" (13), after : "z"
at org.apache.jena.sparql.lang.ParserSPARQL11Update._parse(ParserSPARQL11Update.java:72)
at org.apache.jena.sparql.lang.ParserSPARQL11Update.parse$(ParserSPARQL11Update.java:45)
at org.apache.jena.sparql.lang.UpdateParser.parse(UpdateParser.java:48)
at org.apache.jena.update.UpdateFactory.make(UpdateFactory.java:283)
at org.apache.jena.update.UpdateFactory.read(UpdateFactory.java:272)
at org.apache.jena.update.UpdateFactory.read(UpdateFactory.java:183)
at org.apache.jena.update.UpdateFactory.read(UpdateFactory.java:167)
at org.apache.jena.update.UpdateFactory.read(UpdateFactory.java:155)
at arq.update.execOneFile(update.java:104)
at arq.update.execUpdate(update.java:81)
at arq.cmdline.CmdUpdate.exec(CmdUpdate.java:63)
at jena.cmd.CmdMain.mainMethod(CmdMain.java:93)
at jena.cmd.CmdMain.mainRun(CmdMain.java:58)
at jena.cmd.CmdMain.mainRun(CmdMain.java:45)
at arq.update.main(update.java:49)
2) Would it be possible to adapt the checker to work with http://tarql.github.io/? It's the same as SPARQL, except the last bullet below:
qparse
To do true syntax error checking we need to parse the syntax and report errors if there are any.
Look into: