3 * This file is part of KDevelop
5 * Copyright 2007 David Nolden <david.nolden.kdevelop@art-master.de>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Library General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public
18 * License along with this program; if not, write to the
19 * Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 #ifndef CONTEXTBROWSERPLUGIN_H
24 #define CONTEXTBROWSERPLUGIN_H
26 #include <QtCore/QVariant>
30 #include <ktexteditor/smartrange.h>
31 #include <ktexteditor/rangefeedback.h>
32 #include <interfaces/iplugin.h>
33 #include <interfaces/irunprovider.h>
34 #include <language/duchain/duchainpointer.h>
35 #include <language/editor/simplecursor.h>
36 #include <language/editor/simplerange.h>
37 #include <language/duchain/declaration.h>
48 namespace KTextEditor
{
52 using namespace KDevelop
;
54 class ContextBrowserViewFactory
;
55 class ContextBrowserView
;
57 class ContextBrowserPlugin
: public KDevelop::IPlugin
, public KTextEditor::SmartRangeWatcher
61 ContextBrowserPlugin(QObject
*parent
, const QVariantList
& = QVariantList() );
62 virtual ~ContextBrowserPlugin();
64 virtual void unload();
66 void registerToolView(ContextBrowserView
* view
);
67 void unRegisterToolView(ContextBrowserView
* view
);
70 void previousContextShortcut();
71 void nextContextShortcut();
74 void previousUseShortcut();
75 void nextUseShortcut();
77 void declarationSelectedInUI(DeclarationPointer decl
);
79 void parseJobFinished(KDevelop::ParseJob
* job
);
80 void textDocumentCreated( KDevelop::IDocument
* document
);
81 void documentClosed( KDevelop::IDocument
* document
);
82 void documentDestroyed( QObject
* obj
);
83 void viewDestroyed( QObject
* obj
);
84 void cursorPositionChanged( KTextEditor::View
* view
, const KTextEditor::Cursor
& newPosition
);
85 void viewCreated( KTextEditor::Document
* , KTextEditor::View
* );
88 void textHintRequested(const KTextEditor::Cursor
&, QString
&);
91 void switchUse(bool foward
);
92 void clearMouseHover();
93 virtual void rangeDeleted (KTextEditor::SmartRange
*range
);
94 virtual void mouseEnteredRange(KTextEditor::SmartRange
* range
, KTextEditor::View
* view
);
95 virtual void mouseExitedRange(KTextEditor::SmartRange
* range
, KTextEditor::View
* view
);
97 void changeHighlight( KTextEditor::SmartRange
* range
, bool highlight
, bool declaration
, bool mouseHighlight
);
98 void changeHighlight( KTextEditor::View
* view
, KDevelop::Declaration
* decl
, bool highlight
, bool mouseHighlight
);
100 void watchRange(KTextEditor::SmartRange
* range
);
101 void ignoreRange(KTextEditor::SmartRange
* range
);
103 void registerAsRangeWatcher(KDevelop::DUChainBase
* base
);
104 void registerAsRangeWatcher(KDevelop::DUContext
* ctx
);
106 /** helper for updateBrowserView().
107 * Tries to find a 'specialLanguageObject' (eg macro) in @p view under cursor @c.
108 * If found returns true and sets @p pickedLanguage to the language this object belongs to */
109 bool findSpecialObject(KTextEditor::View
* view
, const KDevelop::SimpleCursor
&, KDevelop::ILanguage
*& pickedLanguage
);
110 KDevelop::Declaration
* findDeclaration(KTextEditor::View
* view
, const KDevelop::SimpleCursor
&, bool mouseHighlight
);
111 bool showDeclarationView(KTextEditor::View
* view
, const KDevelop::SimpleCursor
&, KDevelop::Declaration
* dcl
, KDevelop::DUContext
*);
112 bool showSpecialObjectView(KTextEditor::View
* view
, const KDevelop::SimpleCursor
&, KDevelop::ILanguage
*, KDevelop::DUContext
*);
113 void showContextView(KTextEditor::View
* view
, const SimpleCursor
& cursor
, KDevelop::DUContext
*);
114 void updateBrowserWidgetFor(KTextEditor::View
* view
);
117 QTimer
* m_updateTimer
;
118 QMap
<KTextEditor::SmartRange
*, KTextEditor::Attribute::Ptr
> m_backups
;
119 QSet
<KTextEditor::View
*> m_updateViews
;
120 QMap
<KTextEditor::View
*, DeclarationPointer
> m_highlightedDeclarations
;
121 QMap
<KTextEditor::View
*, KTextEditor::SmartRange
*> m_highlightedRange
; //Special language-object range
123 QSet
<KTextEditor::SmartRange
*> m_watchedRanges
;
125 //Holds a list of all active context browser tool views
126 QList
<ContextBrowserView
*> m_views
;
128 //Used to override the next declaration that will be highlighted
129 IndexedDeclaration m_useDeclaration
;
130 IndexedDeclaration m_lastHighlightedDeclaration
;
132 KUrl m_mouseHoverDocument
;
133 SimpleCursor m_mouseHoverCursor
;
134 ContextBrowserViewFactory
* m_viewFactory
;
137 #endif // CONTEXTBROWSERPLUGIN_H
139 // kate: space-indent on; indent-width 2; tab-width 4; replace-tabs on; auto-insert-doxygen on