Code completion: add results for __FILE__, __LINE__, __COLUMN__

Swift SVN r6859
This commit is contained in:
Dmitri Hrybenko
2013-08-02 22:08:53 +00:00
parent 8305b0229d
commit 773227d90a

View File

@@ -545,6 +545,17 @@ public:
addTypeAnnotation(Builder, TypeAnnotation);
}
void addKeyword(StringRef Name, StringRef TypeAnnotation) {
CodeCompletionResultBuilder Builder(
CompletionContext,
CodeCompletionResult::ResultKind::Keyword);
if (needDot())
Builder.addDot();
Builder.addTextChunk(Name);
if (!TypeAnnotation.empty())
Builder.addTypeAnnotation(TypeAnnotation);
}
// Implement swift::VisibleDeclConsumer
void foundDecl(ValueDecl *D) override {
switch (Kind) {
@@ -679,6 +690,13 @@ public:
Kind = LookupKind::DeclContext;
lookupVisibleDecls(*this, CurrDeclContext, Loc);
// FIXME: The pedantically correct way to find the type is to resolve the
// swift.StringLiteralType type.
addKeyword("__FILE__", "String");
// Same: swift.IntegerLiteralType.
addKeyword("__LINE__", "Int");
addKeyword("__COLUMN__", "Int");
if (!CompletionContext.haveClangResults())
if (auto Importer = SwiftContext.getClangModuleLoader())
static_cast<ClangImporter&>(*Importer).lookupVisibleDecls(*this);