Code completion: add a lot of infrastructure code

* Added a mode in swift-ide-test to test code completion.  Unlike c-index-test,
  the code completion token in tests is a real token -- we don't need to
  count lines and columns anymore.

* Added support in lexer to produce a code completion token.

* Added a parser interface to code completion.  It is passed down from the
  libFrontend to the parser, but its functions are not called yet.

* Added a sketch of the interface of code completion consumer and code
  completion results.

Note: all this is not doing anything useful yet.


Swift SVN r6128
This commit is contained in:
Dmitri Hrybenko
2013-07-10 20:53:40 +00:00
parent 4bbf608e8f
commit 3c5b12fc0f
25 changed files with 546 additions and 25 deletions

View File

@@ -20,6 +20,7 @@
#include "swift/AST/Diagnostics.h"
#include "swift/AST/PrettyStackTrace.h"
#include "swift/Parse/Lexer.h"
#include "swift/Parse/CodeCompletionCallbacks.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/SaveAndRestore.h"
@@ -94,9 +95,23 @@ bool swift::parseIntoTranslationUnit(TranslationUnit *TU,
return FoundSideEffects;
}
void swift::performDelayedParsing(TranslationUnit *TU,
Parser *TheParser) {
if (!TU->Ctx.LangOpts.DelayFunctionBodyParsing)
void swift::performDelayedParsing(
TranslationUnit *TU, Parser *TheParser,
CodeCompletionCallbacksFactory *CodeCompletionFactory) {
bool NeedSecondPass = false;
if (TU->Ctx.LangOpts.DelayFunctionBodyParsing)
NeedSecondPass = true;
std::unique_ptr<CodeCompletionCallbacks> CodeCompletion;
if (TU->Ctx.LangOpts.isCodeCompletion() && CodeCompletionFactory) {
CodeCompletion.reset(
CodeCompletionFactory->createCodeCompletionCallbacks(*TheParser));
TheParser->setCodeCompletion(TU->Ctx.LangOpts.CodeCompletionOffset,
CodeCompletion.get());
NeedSecondPass = true;
}
if (!NeedSecondPass)
return;
TheParser->setDelayedParsingSecondPass();