本文整理汇总了C++中cplusplus::Snapshot::document方法的典型用法代码示例。如果您正苦于以下问题:C++ Snapshot::document方法的具体用法?C++ Snapshot::document怎么用?C++ Snapshot::document使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cplusplus::Snapshot
的用法示例。
在下文中一共展示了Snapshot::document方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: functionAt
QString AbstractEditorSupport::functionAt(const CppModelManagerInterface *modelManager,
const QString &fileName,
int line, int column)
{
const CPlusPlus::Snapshot snapshot = modelManager->snapshot();
const CPlusPlus::Document::Ptr document = snapshot.document(fileName);
if (!document)
return QString();
if (const CPlusPlus::Symbol *symbol = document->lastVisibleSymbolAt(line, column))
if (const CPlusPlus::Scope *scope = symbol->enclosingScope())
if (const CPlusPlus::Scope *functionScope = scope->enclosingFunction())
if (const CPlusPlus::Symbol *function = functionScope) {
const CPlusPlus::Overview o;
QString rc = o.prettyName(function->name());
// Prepend namespace "Foo::Foo::foo()" up to empty root namespace
for (const CPlusPlus::Symbol *owner = function->enclosingNamespace();
owner; owner = owner->enclosingNamespace()) {
const QString name = o.prettyName(owner->name());
if (name.isEmpty()) {
break;
} else {
rc.prepend(QLatin1String("::"));
rc.prepend(name);
}
}
return rc;
}
return QString();
}
示例2: while
CPlusPlus::Function *CppFunction::function(int line, int column, const QString &fileName)
{
const CPlusPlus::Snapshot snapshot = CppTools::CppModelManagerInterface::instance()->snapshot();
const CPlusPlus::Document::Ptr document = snapshot.document(fileName);
if (!document)
return 0;
CPlusPlus::Symbol *symbol = document->lastVisibleSymbolAt(line, column);
if (!symbol)
return 0;
// Find the enclosing function scope (which might be several levels up, or we might be standing on it)
CPlusPlus::Scope *scope;
if (symbol->isScope())
scope = symbol->asScope();
else
scope = symbol->enclosingScope();
while (scope && !scope->isFunction() )
scope = scope->enclosingScope();
if (!scope)
return 0;
return scope->asFunction();
}