mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Code completion: add results for __FILE__, __LINE__, __COLUMN__
Swift SVN r6859
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user