Changeset View
Changeset View
Standalone View
Standalone View
completion/items.cpp
Show All 16 Lines | |||||
17 | * You should have received a copy of the GNU General Public | 17 | * You should have received a copy of the GNU General Public | ||
18 | * License along with this program; if not, write to the | 18 | * License along with this program; if not, write to the | ||
19 | * Free Software Foundation, Inc., | 19 | * Free Software Foundation, Inc., | ||
20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
21 | */ | 21 | */ | ||
22 | 22 | | |||
23 | #include "items.h" | 23 | #include "items.h" | ||
24 | 24 | | |||
25 | #include <KLocale> | | |||
26 | | ||||
27 | #include <language/duchain/duchain.h> | 25 | #include <language/duchain/duchain.h> | ||
28 | #include <language/duchain/duchainlock.h> | 26 | #include <language/duchain/duchainlock.h> | ||
29 | #include <ktexteditor/range.h> | 27 | #include <ktexteditor/range.h> | ||
30 | #include <ktexteditor/view.h> | 28 | #include <ktexteditor/view.h> | ||
31 | #include <ktexteditor/document.h> | 29 | #include <ktexteditor/document.h> | ||
32 | #include <language/codecompletion/codecompletionmodel.h> | 30 | #include <language/codecompletion/codecompletionmodel.h> | ||
33 | #include <language/duchain/declaration.h> | 31 | #include <language/duchain/declaration.h> | ||
34 | #include <language/duchain/classfunctiondeclaration.h> | 32 | #include <language/duchain/classfunctiondeclaration.h> | ||
35 | #include <language/duchain/namespacealiasdeclaration.h> | 33 | #include <language/duchain/namespacealiasdeclaration.h> | ||
36 | #include <language/duchain/duchainutils.h> | 34 | #include <language/duchain/duchainutils.h> | ||
37 | #include <duchain/classdeclaration.h> | 35 | #include <duchain/classdeclaration.h> | ||
38 | #include <language/codecompletion/codecompletionhelper.h> | 36 | #include <language/codecompletion/codecompletionhelper.h> | ||
39 | #include "helpers.h" | 37 | #include "helpers.h" | ||
40 | 38 | | |||
41 | using namespace KDevelop; | 39 | using namespace KDevelop; | ||
42 | 40 | | |||
43 | namespace java { | 41 | namespace java { | ||
44 | 42 | | |||
45 | NormalDeclarationCompletionItem::NormalDeclarationCompletionItem(KDevelop::DeclarationPointer decl, KSharedPtr< KDevelop::CodeCompletionContext > context, int _inheritanceDepth) | 43 | NormalDeclarationCompletionItem::NormalDeclarationCompletionItem(KDevelop::DeclarationPointer decl, QExplicitlySharedDataPointer< KDevelop::CodeCompletionContext > context, int _inheritanceDepth) | ||
46 | : KDevelop::NormalDeclarationCompletionItem(decl, context, _inheritanceDepth) | 44 | : KDevelop::NormalDeclarationCompletionItem(decl, context, _inheritanceDepth) | ||
47 | { | 45 | { | ||
48 | } | 46 | } | ||
49 | 47 | | |||
50 | void NormalDeclarationCompletionItem::executed(KTextEditor::Document* document, const KTextEditor::Range& word) | 48 | void NormalDeclarationCompletionItem::executed(KTextEditor::View* document, const KTextEditor::Range& word) | ||
51 | { | 49 | { | ||
52 | if( m_declaration && dynamic_cast<AbstractFunctionDeclaration*>(m_declaration.data()) ) { | 50 | if( m_declaration && dynamic_cast<AbstractFunctionDeclaration*>(m_declaration.data()) ) { | ||
53 | //Do some intelligent stuff for functions with the parens: | 51 | //Do some intelligent stuff for functions with the parens: | ||
54 | insertFunctionParenText(document, word.end(), m_declaration); | 52 | insertFunctionParenText(document, word.end(), m_declaration); | ||
55 | } | 53 | } | ||
56 | } | 54 | } | ||
57 | 55 | | |||
58 | QVariant NormalDeclarationCompletionItem::data(const QModelIndex& index, int role, const KDevelop::CodeCompletionModel* model) const | 56 | QVariant NormalDeclarationCompletionItem::data(const QModelIndex& index, int role, const KDevelop::CodeCompletionModel* model) const | ||
59 | { | 57 | { | ||
60 | DUChainReadLocker lock(DUChain::lock(), 500); | 58 | DUChainReadLocker lock(DUChain::lock(), 500); | ||
61 | if(!lock.locked()) { | 59 | if(!lock.locked()) { | ||
62 | kDebug() << "Failed to lock the du-chain in time"; | 60 | qDebug() << "Failed to lock the du-chain in time"; | ||
63 | return QVariant(); | 61 | return QVariant(); | ||
64 | } | 62 | } | ||
65 | 63 | | |||
66 | switch (role) { | 64 | switch (role) { | ||
67 | case Qt::DisplayRole: | 65 | case Qt::DisplayRole: | ||
68 | switch (index.column()) { | 66 | switch (index.column()) { | ||
69 | case CodeCompletionModel::Prefix: | 67 | case CodeCompletionModel::Prefix: | ||
70 | { | 68 | { | ||
▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines |