mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user