本文整理汇总了C++中cplusplus::document::Ptr::scopeAt方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::scopeAt方法的具体用法?C++ Ptr::scopeAt怎么用?C++ Ptr::scopeAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cplusplus::document::Ptr
的用法示例。
在下文中一共展示了Ptr::scopeAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: moveCursorToEndOfName
// TODO: Can this be improved? This code is ripped from CppEditor, especially CppElementEvaluater
// We cannot depend on this since CppEditor plugin code is internal and requires building the implementation files ourselves
CPlusPlus::Symbol *AnalyzerUtils::findSymbolUnderCursor()
{
EditorManager *editorManager = EditorManager::instance();
if (!editorManager)
return 0;
IEditor *editor = editorManager->currentEditor();
if (!editor)
return 0;
TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor *>(editor);
if (!textEditor)
return 0;
TextEditor::BaseTextEditorWidget *editorWidget = qobject_cast<TextEditor::BaseTextEditorWidget *>(editor->widget());
if (!editorWidget)
return 0;
QPlainTextEdit *ptEdit = qobject_cast<QPlainTextEdit *>(editor->widget());
if (!ptEdit)
return 0;
QTextCursor tc;
tc = ptEdit->textCursor();
int line = 0;
int column = 0;
const int pos = tc.position();
editorWidget->convertPosition(pos, &line, &column);
const CPlusPlus::Snapshot &snapshot = CPlusPlus::CppModelManagerInterface::instance()->snapshot();
CPlusPlus::Document::Ptr doc = snapshot.document(editor->document()->fileName());
QTC_ASSERT(doc, return 0)
// fetch the expression's code
CPlusPlus::ExpressionUnderCursor expressionUnderCursor;
moveCursorToEndOfName(&tc);
const QString &expression = expressionUnderCursor(tc);
CPlusPlus::Scope *scope = doc->scopeAt(line, column);
CPlusPlus::TypeOfExpression typeOfExpression;
typeOfExpression.init(doc, snapshot);
const QList<CPlusPlus::LookupItem> &lookupItems = typeOfExpression(expression.toUtf8(), scope);
if (lookupItems.isEmpty())
return 0;
const CPlusPlus::LookupItem &lookupItem = lookupItems.first(); // ### TODO: select best candidate.
return lookupItem.declaration();
}