Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QQmlLSCompletion Class Reference

QQmlLSCompletion provides completions for all kinds of QML and JS constructs. More...

#include <qqmllscompletion_p.h>

Collaboration diagram for QQmlLSCompletion:

Public Types

enum class  ImportCompletionType { None , Module , Version }
enum  AppendOption { AppendSemicolon , AppendNothing }
using CompletionItem = QLspSpecification::CompletionItem
using BackInsertIterator = std::back_insert_iterator<QList<CompletionItem>>

Public Member Functions

 QQmlLSCompletion (const QFactoryLoader &pluginLoader)
void exploreImportPaths (const QStringList &importPaths)
QQmlLSModuleExplorer * moduleExplorer () const
QList< CompletionItem > completions (const DomItem &currentItem, const CompletionContextStrings &ctx) const

Static Public Member Functions

static CompletionItem makeSnippet (QUtf8StringView qualifier, QUtf8StringView labellabel, QUtf8StringView insertText)
static CompletionItem makeSnippet (QUtf8StringView labellabel, QUtf8StringView insertText)

Detailed Description

QQmlLSCompletion provides completions for all kinds of QML and JS constructs.

Use the \l{completions} method to obtain completions at a certain DomItem.

All the other methods in this class are helper methods: some compute completions for specific QML and JS constructs and some are shared between multiple QML or JS constructs to avoid code duplication. Most of the helper methods add their completion items via a BackInsertIterator.

Some helper methods are called "suggest*" and will try to suggest code that does not exist yet. For example, any JS statement can be expected inside a Blockstatement so suggestJSStatementCompletion() is used to suggest JS statements inside of BlockStatements. Another example might be suggestReachableTypes() that will suggest Types for type annotations, attached types or Qml Object hierarchies, or suggestCaseAndDefaultStatementCompletion() that will only suggest "case" and "default" clauses for switch statements.

Some helper methods are called "inside*" and will try to suggest code inside an existing structure. For example, insideForStatementCompletion() will try to suggest completion for the different code pieces initializer, condition, increment and statement that exist inside of: \badcode for(initializer; condition; increment) statement

Definition at line 38 of file qqmllscompletion_p.h.

Member Typedef Documentation

◆ BackInsertIterator

using QQmlLSCompletion::BackInsertIterator = std::back_insert_iterator<QList<CompletionItem>>

Definition at line 51 of file qqmllscompletion_p.h.

◆ CompletionItem

using QQmlLSCompletion::CompletionItem = QLspSpecification::CompletionItem

Definition at line 50 of file qqmllscompletion_p.h.

Member Enumeration Documentation

◆ AppendOption

Enumerator
AppendSemicolon 
AppendNothing 

Definition at line 43 of file qqmllscompletion_p.h.

◆ ImportCompletionType

Enumerator
None 
Module 
Version 

Definition at line 42 of file qqmllscompletion_p.h.

Constructor & Destructor Documentation

◆ QQmlLSCompletion()

QQmlLSCompletion::QQmlLSCompletion ( const QFactoryLoader & pluginLoader)

Definition at line 1980 of file qqmllscompletion.cpp.

Member Function Documentation

◆ completions()

QList< CompletionItem > QQmlLSCompletion::completions ( const DomItem & currentItem,
const CompletionContextStrings & contextStrings ) const

Decide which completions can be used at currentItem and compute them.

Definition at line 1753 of file qqmllscompletion.cpp.

◆ exploreImportPaths()

void QQmlLSCompletion::exploreImportPaths ( const QStringList & importPaths)

Definition at line 936 of file qqmllscompletion.cpp.

◆ makeSnippet() [1/2]

CompletionItem QQmlLSCompletion::makeSnippet ( QUtf8StringView label,
QUtf8StringView insertText )
static

Definition at line 67 of file qqmllscompletion.cpp.

◆ makeSnippet() [2/2]

CompletionItem QQmlLSCompletion::makeSnippet ( QUtf8StringView qualifier,
QUtf8StringView label,
QUtf8StringView insertText )
static

Definition at line 45 of file qqmllscompletion.cpp.

◆ moduleExplorer()

QQmlLSModuleExplorer * QQmlLSCompletion::moduleExplorer ( ) const
inline

Definition at line 48 of file qqmllscompletion_p.h.


The documentation for this class was generated from the following files: