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)
QList< CompletionItemcompletions (const DomItem &currentItem, const CompletionContextStrings &ctx) const

Static Public Member Functions

static CompletionItem makeSnippet (QUtf8StringView qualifier, QUtf8StringView label, QUtf8StringView insertText)
static CompletionItem makeSnippet (QUtf8StringView label, 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 36 of file qqmllscompletion_p.h.

Member Typedef Documentation

◆ BackInsertIterator

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

Definition at line 46 of file qqmllscompletion_p.h.

◆ CompletionItem

using QQmlLSCompletion::CompletionItem = QLspSpecification::CompletionItem

Definition at line 45 of file qqmllscompletion_p.h.

Member Enumeration Documentation

◆ AppendOption

Enumerator
AppendSemicolon 
AppendNothing 

Definition at line 41 of file qqmllscompletion_p.h.

◆ ImportCompletionType

Enumerator
None 
Module 
Version 

Definition at line 40 of file qqmllscompletion_p.h.

Constructor & Destructor Documentation

◆ QQmlLSCompletion()

QQmlLSCompletion::QQmlLSCompletion ( const QFactoryLoader & pluginLoader)

Definition at line 1974 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 1747 of file qqmllscompletion.cpp.

◆ makeSnippet() [1/2]

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

Definition at line 64 of file qqmllscompletion.cpp.

◆ makeSnippet() [2/2]

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

Definition at line 42 of file qqmllscompletion.cpp.


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