[cfe-dev] Advice for using clang's code completion capabilities

Keno Fischer kfischer at college.harvard.edu
Sun Jan 4 06:35:14 PST 2015


Hello everyone,

I'm trying to add code completion support to my project.
For background, I'm working on Julia's C++ FFI [1], which
also allows the user to interactively enter C++ code, which is
where I'd like to support completion.

>From looking at the code right now, it seems like one would set
the code completion point once, then run the parser as usual, for
which I'd then get results back through my set CodeCompletionConsumer.
Is that understanding correct so far?

If so, it seems like I'd have to create a new Preprocessor, Sema, etc.
every time I want to do completion. I don't think it is feasible for me in
an interactive context to go back and reparse everything with the new
Preprocessor etc. Ideally the new objects would just fall back to looking
up identifiers, macros etc. in the old instances, basically only maintaining
any new definitions added in the completion snippet. Is this possible?
It seems like I might be able to use External*Source. Is there any example
of this?

Alternatively, I may be totally off base with the above interpretation, so
I'd appreciate any advice on how to properly implement completion given
that
I have an active CompilerInstance, PP, Sema, etc. that should already
contain
everything needed for completion. I'd also be fine with not completing any
definitions that are newly added in the completion snippet (in case that
makes
things easier).

Thank you for your help,
Keno


[1] https://github.com/Keno/Cxx.jl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150104/5cb0c9c5/attachment.html>


More information about the cfe-dev mailing list