KTextEditor::CodeCompletionModelControllerInterface

Search for usage in LXR

KTextEditor::CodeCompletionModelControllerInterface Class Reference

#include <KTextEditor/CodeCompletionModelControllerInterface>

Inheritance diagram for KTextEditor::CodeCompletionModelControllerInterface:

Public Types

enum  MatchReaction { None = 0 , HideListIfAutomaticInvocation = 1 , ForExtension = 0xffff }
 

Public Member Functions

virtual void aborted (View *view)
 
virtual Range completionRange (View *view, const Cursor &position)
 
virtual QString filterString (View *view, const Range &range, const Cursor &position)
 
virtual MatchReaction matchingItem (const QModelIndex &matched)
 
virtual bool shouldAbortCompletion (View *view, const Range &range, const QString &currentCompletion)
 
virtual bool shouldExecute (const QModelIndex &selected, QChar inserted)
 
virtual bool shouldHideItemsWithEqualNames () const
 
virtual bool shouldStartCompletion (View *view, const QString &insertedText, bool userInsertion, const Cursor &position)
 
virtual Range updateCompletionRange (View *view, const Range &range)
 

Detailed Description

Controller interface for a CodeCompletionModel.

The CodeCompletionModelControllerInterface gives an CodeCompletionModel better control over the completion.

By implementing methods defined in this interface you can:

When the interface is not implemented, or no methods are overridden the default behaviour is used, which will be correct in many situations.

Implementing the Interface

To use this class implement it in your CodeCompletionModel.

class MyCodeCompletion : public KTextEditor::CodeCompletionTestModel,
{
Q_OBJECT
public:
};
virtual Range completionRange(View *view, const Cursor &position)
This function returns the completion range that will be used for the current completion.
The Cursor represents a position in a Document.
Definition cursor.h:75
An object representing a section of text, from one Cursor to another.
A text widget with KXMLGUIClient that represents a Document.
Definition view.h:244
See also
CodeCompletionModel
Author
Niko Sams <niko..nosp@m.sams.nosp@m.@gmai.nosp@m.l.co.nosp@m.m>
Joseph Wenninger

Definition at line 60 of file codecompletionmodelcontrollerinterface.h.

Member Enumeration Documentation

◆ MatchReaction

Enumerator
ForExtension 

If this is returned, the completion-list is hidden if it was invoked automatically.

Definition at line 156 of file codecompletionmodelcontrollerinterface.h.

Constructor & Destructor Documentation

◆ CodeCompletionModelControllerInterface()

KTextEditor::CodeCompletionModelControllerInterface::CodeCompletionModelControllerInterface ( )

Definition at line 18 of file codecompletionmodelcontrollerinterface.cpp.

Member Function Documentation

◆ aborted()

void KTextEditor::CodeCompletionModelControllerInterface::aborted ( KTextEditor::View * view)
virtual

Notification that completion for this model has been aborted.

Parameters
viewThe view in which the completion for this model was aborted

Definition at line 102 of file codecompletionmodelcontrollerinterface.cpp.

◆ completionRange()

Range KTextEditor::CodeCompletionModelControllerInterface::completionRange ( View * view,
const Cursor & position )
virtual

This function returns the completion range that will be used for the current completion.

This range will be used for filtering the completion list and will get replaced when executing the completion

The default implementation will work for most languages that don't have special chars in identifiers. Since 5.83 the default implementation takes into account the wordCompletionRemoveTail configuration option, if that option is enabled the whole word the cursor is inside is replaced with the completion, however if it's disabled only the text on the left of the cursor will be replaced with the completion.

Parameters
viewThe view to generate completions for
positionCurrent cursor position
Returns
the completion range

Reimplemented in KateKeywordCompletionModel.

Definition at line 40 of file codecompletionmodelcontrollerinterface.cpp.

◆ filterString()

QString KTextEditor::CodeCompletionModelControllerInterface::filterString ( View * view,
const Range & range,
const Cursor & position )
virtual

This function returns the filter-text used for the current completion.

Can return an empty string to disable filtering.

The default implementation will return the text from range start to the cursor position.

Parameters
viewThe view to generate completions for
rangeThe completion range
positionCurrent cursor position
Returns
the string used for filtering the completion list

Definition at line 86 of file codecompletionmodelcontrollerinterface.cpp.

◆ matchingItem()

KTextEditor::CodeCompletionModelControllerInterface::MatchReaction KTextEditor::CodeCompletionModelControllerInterface::matchingItem ( const QModelIndex & matched)
virtual

Called whenever an item in the completion-list perfectly matches the current filter text.

Parameters
matchedThe index that is matched
Returns
Whether the completion-list should be hidden on this event. The default-implementation always returns HideListIfAutomaticInvocation

Reimplemented in KateKeywordCompletionModel.

Definition at line 114 of file codecompletionmodelcontrollerinterface.cpp.

◆ shouldAbortCompletion()

bool KTextEditor::CodeCompletionModelControllerInterface::shouldAbortCompletion ( View * view,
const Range & range,
const QString & currentCompletion )
virtual

This function decides if the completion should be aborted.

Called after every change to the range (eg. when user entered text)

The default implementation will return true when any special character was entered, or when the range is empty.

Parameters
viewThe view to generate completions for
rangeThe completion range
currentCompletionThe text typed so far
Returns
true, if the completion should be aborted, otherwise false

Reimplemented in KateKeywordCompletionModel.

Definition at line 91 of file codecompletionmodelcontrollerinterface.cpp.

◆ shouldExecute()

bool KTextEditor::CodeCompletionModelControllerInterface::shouldExecute ( const QModelIndex & selected,
QChar inserted )
virtual

When an item within this model is currently selected in the completion-list, and the user inserted the given character, should the completion-item be executed? This can be used to execute items from other inputs than the return-key.

For example a function item could be executed by typing '(', or variable items by typing '.'.

Parameters
selectedThe currently selected index
insertedThe character that was inserted by tue user

Definition at line 107 of file codecompletionmodelcontrollerinterface.cpp.

◆ shouldHideItemsWithEqualNames()

bool KTextEditor::CodeCompletionModelControllerInterface::shouldHideItemsWithEqualNames ( ) const
virtual

When multiple completion models are used at the same time, it may happen that multiple models add items with the same name to the list.

This option allows to hide items from this completion model when another model with higher priority contains items with the same name.

Returns
Whether items of this completion model should be hidden if another completion model has items with the same name

Reimplemented in KateKeywordCompletionModel.

Definition at line 120 of file codecompletionmodelcontrollerinterface.cpp.

◆ shouldStartCompletion()

bool KTextEditor::CodeCompletionModelControllerInterface::shouldStartCompletion ( View * view,
const QString & insertedText,
bool userInsertion,
const Cursor & position )
virtual

This function decides if the automatic completion should be started when the user entered some text.

The default implementation will return true if the last character in insertedText is a letter, a number, '.', '_' or '>'

Parameters
viewThe view to generate completions for
insertedTextThe text that was inserted by the user
userInsertionWhether the text was inserted by the user using typing. If false, it may have been inserted for example by code-completion.
positionCurrent cursor position
Returns
true, if the completion should be started, otherwise false

Reimplemented in KateKeywordCompletionModel.

Definition at line 24 of file codecompletionmodelcontrollerinterface.cpp.

◆ updateCompletionRange()

Range KTextEditor::CodeCompletionModelControllerInterface::updateCompletionRange ( View * view,
const Range & range )
virtual

This function lets the CompletionModel dynamically modify the range.

Called after every change to the range (eg. when user entered text)

The default implementation does nothing.

Parameters
viewThe view to generate completions for
rangeReference to the current range
Returns
the modified range

Definition at line 74 of file codecompletionmodelcontrollerinterface.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:11:28 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.