This is an archive of the discontinued LLVM Phabricator instance.

[ClangRepl] support code completion at the repl
AbandonedPublic

Authored by capfredf on Jul 6 2023, 9:10 AM.

Details

Reviewers
None
Summary

This patch enabled code completion for ClangREPL. The feature was built upon two
existing Clang components: a list completer for LineEditor and SemaCodeCompletion.

The former serves the main entry point to trigger the latter. Because a
completion point for a compiler instance needs to be unchanged once it is set,
an incremental compiler instance for code completion is created. In addition to
completion points, it differs from a regular incremental compiler in the following ways:

  1. It does not execute input.
  1. To obtain declarations or bindings from previous input in the same REPL

session, it carries over AST context source from the main compiler, i.e. the one
used for the interpreter.

  1. It contains a ReplCompletionConsumer, a subclass of

CodeCompletionConsumer. The consumer communicates completion results from
SemaCodeCompletion back to the list completer for the REPL.

Diff Detail

Event Timeline

capfredf created this revision.Jul 6 2023, 9:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 9:10 AM
capfredf requested review of this revision.Jul 6 2023, 9:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 9:10 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
capfredf abandoned this revision.Jul 6 2023, 9:13 AM