blob: 045177270689f450ab01c1b6d744dd64bf66c100 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#include "cppeditor.h"
#include <cppeditor/cppeditor.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <cppeditor/cppeditorconstants.h>
#include "utils/signalwaiter.h"
#include "cppfunction.h"
#include <cpptools/cppmodelmanagerinterface.h>
namespace Scripting {
namespace Internal {
CppEditor::CppEditor(QObject *parent) :
BaseTextEditor(parent)
{
}
void CppEditor::switchDeclarationDefinition()
{
Core::ActionManager::command(::CppEditor::Constants::SWITCH_DECLARATION_DEFINITION)->action()->trigger();
}
CppFunction *CppEditor::currentFunction() const
{
return functionAt(editor()->currentLine(), editor()->currentColumn());
}
CppFunction* CppEditor::functionAt(int line, int column) const
{
return CppFunction::create(line, column, editor()->document()->fileName());
}
/**
\brief Wait for the editor to signal that it has been initialized after opening a file
When opening a C++ file, the editor will asyncronicly parse the file. Until that has completed switchDeclarationDefinition() will not work.
*/
void CppEditor::waitForInitialized()
{
CPlusPlus::Snapshot snapshot = CppTools::CppModelManagerInterface::instance()->snapshot();
if (!snapshot.isEmpty())
return;
SignalWaiter waiter;
const bool received = waiter.wait(CppTools::CppModelManagerInterface::instance(), SIGNAL(sourceFilesRefreshed(QStringList)), 1000);
if ( !received )
qWarning("editor did not complete initialization in time");
}
} // namespace Internal
} // namespace Scripting
|