} else {
switch (D->getKind()) {
+ case Decl::Import:
+ Info.Kind = SymbolKind::Module;
+ break;
case Decl::Typedef:
Info.Kind = SymbolKind::Typedef; break;
case Decl::Function:
}
bool IndexingContext::importedModule(const ImportDecl *ImportD) {
- SourceLocation Loc = ImportD->getLocation();
+ SourceLocation Loc;
+ auto IdLocs = ImportD->getIdentifierLocs();
+ if (!IdLocs.empty())
+ Loc = IdLocs.front();
+ else
+ Loc = ImportD->getLocation();
SourceManager &SM = Ctx->getSourceManager();
Loc = SM.getFileLoc(Loc);
if (Loc.isInvalid())
}
}
- SymbolRoleSet Roles{};
+ SymbolRoleSet Roles = (unsigned)SymbolRole::Reference;
if (ImportD->isImplicit())
Roles |= (unsigned)SymbolRole::Implicit;
--- /dev/null
+
+void ModA_func(void);
--- /dev/null
+module ModA { header "ModA.h" export * }
--- /dev/null
+// RUN: rm -rf %t.mcp
+// RUN: c-index-test core -print-source-symbols -- %s -I %S/Inputs/module -fmodules -fmodules-cache-path=%t.mcp | FileCheck %s
+
+// CHECK: [[@LINE+1]]:9 | module/C | ModA | Ref |
+@import ModA;
+// CHECK: [[@LINE+1]]:1 | module/C | ModA | Ref,Impl |
+#include "ModA.h"
+
+void foo() {
+ // CHECK: [[@LINE+1]]:3 | function/C | ModA_func | c:@F@ModA_func | {{.*}} | Ref,Call,RelCall | rel: 1
+ ModA_func();
+}
\ No newline at end of file
return true;
}
+
+ bool handleModuleOccurence(const ImportDecl *ImportD, SymbolRoleSet Roles,
+ FileID FID, unsigned Offset) override {
+ ASTContext &Ctx = ImportD->getASTContext();
+ SourceManager &SM = Ctx.getSourceManager();
+
+ unsigned Line = SM.getLineNumber(FID, Offset);
+ unsigned Col = SM.getColumnNumber(FID, Offset);
+ OS << Line << ':' << Col << " | ";
+
+ printSymbolInfo(getSymbolInfo(ImportD), OS);
+ OS << " | ";
+
+ OS << ImportD->getImportedModule()->getFullModuleName() << " | ";
+
+ printSymbolRoles(Roles, OS);
+ OS << " |\n";
+
+ return true;
+ }
};
} // anonymous namespace