language/editor
KDevelop::EditorIntegrator Class Reference
Provides facilities for easy integration of a text editor component with the information parsed from a source file. More...
#include <editorintegrator.h>
Public Types | |
| enum | Edge { FrontEdge, BackEdge } |
| enum | RangeEdge { InnerEdge, OuterEdge } |
| enum | TopRangeType { Highlighting, DefinitionUseChain, TopRangeCount } |
Public Member Functions | |
| void | adjustRangeTo (const LockedSmartInterface &iface, const SimpleRange &fromRange) |
| KTextEditor::SmartCursor * | createCursor (const LockedSmartInterface &iface, std::size_t token, Edge edge) |
| KTextEditor::SmartCursor * | createCursor (const LockedSmartInterface &iface, const KTextEditor::Cursor &position) |
| KTextEditor::SmartRange * | createRange (const LockedSmartInterface &iface, const KTextEditor::Cursor &start, const KTextEditor::Cursor &end) |
| KTextEditor::SmartRange * | createRange (const LockedSmartInterface &iface, const KTextEditor::Range &range, KTextEditor::SmartRange::InsertBehaviors insertBehavior=KTextEditor::SmartRange::DoNotExpand) |
| KTextEditor::SmartRange * | currentRange (const LockedSmartInterface &iface) const |
| IndexedString | currentUrl () const |
| void | exitCurrentRange (const LockedSmartInterface &iface) |
| void | insertLoadedDocument (KTextEditor::Document *document) |
| int | rangeStackSize (const LockedSmartInterface &iface) const |
| void | setCurrentRange (const LockedSmartInterface &iface, KTextEditor::SmartRange *range) |
| void | setCurrentUrl (const IndexedString &url, bool useSmart=true) |
| LockedSmartInterface | smart () const |
| KTextEditor::SmartRange * | topRange (const LockedSmartInterface &iface, TopRangeType type) |
| SimpleRange | translate (const LockedSmartInterface &iface, const SimpleRange &fromRange) const |
Static Public Member Functions | |
| static void | addDocument (KTextEditor::Document *document) |
| static KTextEditor::Document * | documentForUrl (const IndexedString &url) |
| static KTextEditor::Document * | documentForUrl (const HashedString &url) |
| static bool | documentLoaded (KTextEditor::Document *document) |
| static void | initialise () |
| static QObject * | notifier () |
| static void | releaseRange (KTextEditor::SmartRange *range) |
| static void | releaseTopRange (KTextEditor::SmartRange *range) |
| static void | removeDocument (KTextEditor::Document *document) |
| static LockedSmartInterface | smart (const KUrl &url) |
Detailed Description
Provides facilities for easy integration of a text editor component with the information parsed from a source file.
Uses a disguised singleton + stateful design.
- Todo:
introduce stacks for the state?
move private members to a private class
non-loaded documents don't trigger the removeDocument call...
Definition at line 85 of file editorintegrator.h.
Member Enumeration Documentation
Definition at line 179 of file editorintegrator.h.
Definition at line 238 of file editorintegrator.h.
Top range type enumeration.
- Enumerator:
Highlighting top range type for highlighting
DefinitionUseChain top range type for duchain
TopRangeCount top range type for counting
Definition at line 149 of file editorintegrator.h.
Member Function Documentation
| void KDevelop::EditorIntegrator::addDocument | ( | KTextEditor::Document * | document | ) | [static] |
Adds a text editor document to the integrator.
Definition at line 96 of file editorintegrator.cpp.
| void KDevelop::EditorIntegrator::adjustRangeTo | ( | const LockedSmartInterface & | iface, | |
| const SimpleRange & | fromRange | |||
| ) |
Apply a possibly dated range to the current smart cursor.
Performs translation on fromRange, then applies it to smartRange.
Definition at line 418 of file editorintegrator.cpp.
| KTextEditor::SmartCursor* KDevelop::EditorIntegrator::createCursor | ( | const LockedSmartInterface & | iface, | |
| std::size_t | token, | |||
| Edge | edge | |||
| ) |
Create a new persistant cursor from the given token on the given edge.
| SmartCursor * KDevelop::EditorIntegrator::createCursor | ( | const LockedSmartInterface & | iface, | |
| const KTextEditor::Cursor & | position | |||
| ) |
Create a new persistant cursor from the given position.
Definition at line 159 of file editorintegrator.cpp.
| SmartRange * KDevelop::EditorIntegrator::createRange | ( | const LockedSmartInterface & | iface, | |
| const KTextEditor::Cursor & | start, | |||
| const KTextEditor::Cursor & | end | |||
| ) |
Create a text range from start to end as a child range of the current range.
The returned range will become the new currentRange().
If the current document is loaded, and it supports creating smart ranges, this will be a smart range, otherwise it will be a DocumentRange.
- Parameters:
-
start start of the range of text to cover. If this is outside the parent's range, the parent will be adjusted (standard behaviour of SmartRanges). end end of the range of text to cover. If this is outside the parent's range, the parent will be adjusted (standard behaviour of SmartRanges).
- Returns:
- the newly created text range, or zero if no smart interface is available for the document.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 297 of file editorintegrator.cpp.
| SmartRange * KDevelop::EditorIntegrator::createRange | ( | const LockedSmartInterface & | iface, | |
| const KTextEditor::Range & | range, | |||
| KTextEditor::SmartRange::InsertBehaviors | insertBehavior = KTextEditor::SmartRange::DoNotExpand | |||
| ) |
Create a text range over range as a child range of the current range.
The returned range will become the new currentRange(), and will be put upon the range-stack.
If the current document is loaded, and it supports creating smart ranges, this will be a smart range, otherwise it will be a DocumentRange.
- Parameters:
-
range Range of text to cover. If this is outside the parent's range, the parent will be adjusted (standard behaviour of SmartRanges). insertBehavior,: If a smart-range will be created, it will be created with the given insert-behavior
- Returns:
- the newly created text range, or zero if no smart interface is available for the document.
Definition at line 288 of file editorintegrator.cpp.
| SmartRange * KDevelop::EditorIntegrator::currentRange | ( | const LockedSmartInterface & | iface | ) | const |
Returns the most current text range.
Definition at line 312 of file editorintegrator.cpp.
| IndexedString KDevelop::EditorIntegrator::currentUrl | ( | ) | const |
Returns the url of the currently associated editor.
Definition at line 322 of file editorintegrator.cpp.
| Document * KDevelop::EditorIntegrator::documentForUrl | ( | const IndexedString & | url | ) | [static] |
Returns the text document for url, if one exists.
The url should have been formatted using KUrl::pathOrUrl() at some point. This shouuld be preferred over the method above
Definition at line 120 of file editorintegrator.cpp.
| Document * KDevelop::EditorIntegrator::documentForUrl | ( | const HashedString & | url | ) | [static] |
Returns the text document for url, if one exists.
The url should have been formatted using KUrl::pathOrUrl() at some point.
Definition at line 115 of file editorintegrator.cpp.
| static bool KDevelop::EditorIntegrator::documentLoaded | ( | KTextEditor::Document * | document | ) | [static] |
Determine if a document has been loaded yet.
| void KDevelop::EditorIntegrator::exitCurrentRange | ( | const LockedSmartInterface & | iface | ) |
Sets the previous range on the stack to be the new current range.
Does nothing if the range stack is empty.
Definition at line 387 of file editorintegrator.cpp.
| static void KDevelop::EditorIntegrator::initialise | ( | ) | [static] |
Initialise the editor integrator.
Only needs to be called once from the main thread.
| void KDevelop::EditorIntegrator::insertLoadedDocument | ( | KTextEditor::Document * | document | ) |
A hack working around problems while initialization,.
- See also:
- DUChain::documentLoadedPrepare. It used to happen that the document wasn't registered to the editor-integrator there, and thus no smart-ranges/highlighting were created. We use this to inject the document.
Definition at line 92 of file editorintegrator.cpp.
| QObject * KDevelop::EditorIntegrator::notifier | ( | ) | [static] |
Use this to connect to notifications provided by EditorIntegratorStatic.
Definition at line 413 of file editorintegrator.cpp.
| int KDevelop::EditorIntegrator::rangeStackSize | ( | const LockedSmartInterface & | iface | ) | const |
Count of ranges currently on the stack.
Definition at line 407 of file editorintegrator.cpp.
| void KDevelop::EditorIntegrator::releaseRange | ( | KTextEditor::SmartRange * | range | ) | [static] |
Releases + safely deletes a text editor range.
- Warning:
- you must already hold the smart lock for the corresponding document.
- Todo:
- audit uses to check for smart lock holding
Definition at line 368 of file editorintegrator.cpp.
| void KDevelop::EditorIntegrator::releaseTopRange | ( | KTextEditor::SmartRange * | range | ) | [static] |
Releases a toplevel range.
The range should be deleted by the caller.
Definition at line 363 of file editorintegrator.cpp.
| void KDevelop::EditorIntegrator::removeDocument | ( | KTextEditor::Document * | document | ) | [static] |
Retrieve the mutex which allows background parsers to lock a document in place while they make their changes.
static QMutex* mutexForDocument(KTextEditor::Document* document); Removes the text editor document from the integrator.
Definition at line 106 of file editorintegrator.cpp.
| void KDevelop::EditorIntegrator::setCurrentRange | ( | const LockedSmartInterface & | iface, | |
| KTextEditor::SmartRange * | range | |||
| ) |
Sets the current range to range.
It is put upon the range-stack. Does nothing if the range is zero.
Definition at line 302 of file editorintegrator.cpp.
| void KDevelop::EditorIntegrator::setCurrentUrl | ( | const IndexedString & | url, | |
| bool | useSmart = true | |||
| ) |
Associate this editor integrator with the editor which is currently editing the given url.
- Parameters:
-
useSmart Whether smart-ranges should be created for this url.
Definition at line 327 of file editorintegrator.cpp.
| LockedSmartInterface KDevelop::EditorIntegrator::smart | ( | const KUrl & | url | ) | [static] |
Retrieve a locked version of the SmartInterface for the current document, or null if one does not exist / is being deleted etc.
Definition at line 145 of file editorintegrator.cpp.
| LockedSmartInterface KDevelop::EditorIntegrator::smart | ( | ) | const |
Retrieve a locked version of the SmartInterface for the current document, or null if one does not exist / is being deleted etc.
- Todo:
- This opens a very short window where the document could eventually be deleted But it prevents a much more probable deadlock.
Definition at line 130 of file editorintegrator.cpp.
| SmartRange * KDevelop::EditorIntegrator::topRange | ( | const LockedSmartInterface & | iface, | |
| TopRangeType | type | |||
| ) |
Returns a toplevel range in a document for use as type.
- Parameters:
-
type The use for which the created range will be used
- Returns:
- the range either found or created, if the document was valid and supports smart ranges. Zero if no smart interface is available for the document.
Opens a range that needs to be closed using exitCurrentRange()
Definition at line 272 of file editorintegrator.cpp.
| SimpleRange KDevelop::EditorIntegrator::translate | ( | const LockedSmartInterface & | iface, | |
| const SimpleRange & | fromRange | |||
| ) | const |
Translate the given range to the current smart revision, and return the result.
You need to have the smart mutex locked for the result to remain valid while you process it.
Definition at line 428 of file editorintegrator.cpp.
The documentation for this class was generated from the following files:
KDE 4.4 API Reference