Support query symbol information - #85
Conversation
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
|
That's a good idea to include the source line
This made me thing that "endLine" could probably also be useful. I imagine, an LLM would want to read the actual definition of some symbol, in that case it could issue a "read" command with the begin and end lines to read only a slice of a file. |
There was a problem hiding this comment.
Does --query work only with --format json?
If so, then you essentially give only two options:
- "--query --format json"
- "--format html" and no
--query(or is it permitted and ignored?)
Thus you could simplify the API to accept either --query and then output json or no --query and output HTML and require --out, and you don't need the --format parameter.
Additionally, I am not sure --query is needed. If you output all available symbols in JSON format to stdout, and especially in JSONL (i.e., just a stream of json objects, rather than a JSON array), then the consumer can use a plethora of standard tools to filter/query/transform the json on-the-fly. For example they could use jq to select the symbol of interest and discard the rest.
Having your own query means you have to implement and explain the query language, and if it is even slightly non-trivial it means headache for the users to learn it and use correctly.
This is a good point, given that The only case where Currently, it kind of works as you mentioned: if
The reason why In addition, without --query, it's not clear how to support a simple use case like the following: |
Sure, but it invites confusion. As a language designer you should know that a better designed language makes something inexpressible rather than simply forbidden at compile or at runtime. CLI is a form of a language, so making unwanted things inexpressible also plays in its favor.
Indeed it is large by default, but there is always
Here is how I would do that in shell (note that I cannot avoid jo compile --doc --query jo.List | jq '.. | objects | select(.name == "jo.List.map")'Or, what is more likely, I (or LLM) would invoke As an aside,
BTW should jo/docs/usage/commands/doc.md also mention this new mode? |
Yes, we can go even further here to decouple the
I think For normal compilation, standard library is indispensable.
This is painful, I never remember the syntax of
This is a bug, I'll investigate.
|
|
My use case: retriever all the symbols defined in a file and their doc string (#84 ). Does this implementation support it? |
Luckily we have LLMs for that now.
You can implement a separate I think adding a query language before anyone asks for it is premature, but I do not insist, as long as it does not get in the way. |
I am speaking only about documentation extraction. |
If the namespace of the file is know, it can be done by querying the namespace symbol. Otherwise, query with the file name |
|
I think "query language" is not an accurate characterization: it's just an input format. If a user or LLM wants to know the interface of String, it simply queries I'm not sure how to tell whether something is "premature" or not. But as principled design we never take a requirement at its surface value and for information-retrival interface, narrowing/querying is essential IMHO. |
Here is how I tried to do it: |
Then you can add an equivalent for docs. e.g. |
That won't work, because without standard library, it is impossible generate docs. |
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
|
@necto Thank you again for your feedback. Now I have fixed the bugs you mentioned about Could you please take a look and let me now whether it satisfies your use case? |
necto
left a comment
There was a problem hiding this comment.
Could you please take a look and let me now whether it satisfies your use case?
It works well now. thank you.
I was surprised that you dropped the lines from the output (i.e., line:... endLine:...). But I did not intend to use that feature presently.
|
Le mer. 29 juil. 2026, 19:09, Arseniy Zaostrovnykh ***@***.***>
a écrit :
***@***.**** approved this pull request.
Could you please take a look and let me now whether it satisfies your use
case?
It works well now. thank you.
I was surprised that you dropped the lines from the output (i.e., line:...
endLine:...). But I did not intend to use that feature presently.
`
They are there, just not shown by default. You can use `--fields name,signature,doc,loc` to get it.
I currently use "end", maybe it's better to change it to "endLine"?
… —
Reply to this email directly, view it on GitHub
<#85?email_source=notifications&email_token=AAFYHSLXWGERGAVPWP2S2N35HIVVJA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTIOBRGA4TQMRSG422M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#pullrequestreview-4810982275>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFYHSLVCC74FV56DN7PRT35HIVVJAVCNFSNUABGKJSXA33TNF2G64TZHMYTEMJQHAYDOMJTHA5US43TOVSTWNBZHA2DMNJQHEYDDILWAI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Fix #84 : Support query symbol information
Summary
Support query symbol information from command line:
It outputs
[ { "name": "jo.List.map", "kind": "def", "signature": "def map[S](f: T => S receives none): List[S] receives none", "source": { "file": "lib/List.jo", "line": 162 }, "visibility": "public", "flags": ["loaded", "fun", "method"], "annotations": [], "doc": "Apply `f` to each element and return the resulting list." } ]It is also possible to filter by file name:
Only symbols defined in the specified will be included.
Checklist
tests/pos/ortests/warn/How to sign off commits
Use
git commit -sto add theSigned-off-byline automatically:To add a sign-off to the last commit retroactively:
To add sign-off to the last 3 commits:
Security impact
No
Compatibility impact
No