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
HighlightingUtils Namespace Reference

Enumerations

enum class  QmlHighlightKind {
  QmlKeyword , QmlType , QmlImportId , QmlNamespace ,
  QmlLocalId , QmlExternalId , QmlProperty , QmlScopeObjectProperty ,
  QmlRootObjectProperty , QmlExternalObjectProperty , QmlMethod , QmlMethodParameter ,
  QmlSignal , QmlSignalHandler , QmlEnumName , QmlEnumMember ,
  QmlPragmaName , QmlPragmaValue , QmlTypeModifier , JsImport ,
  JsGlobalVar , JsGlobalMethod , JsScopeVar , JsLabel ,
  Number , String , Comment , Operator ,
  Field , Unknown
}
enum class  QmlHighlightModifier {
  None = 0 , QmlPropertyDefinition = 1 << 0 , QmlDefaultProperty = 1 << 1 , QmlFinalProperty = 1 << 2 ,
  QmlRequiredProperty = 1 << 3 , QmlReadonlyProperty = 1 << 4
}
enum class  HighlightingMode { Default , QtCHighlighting }
enum class  SemanticTokenProtocolTypes {
  Namespace , Type , Enum , Parameter ,
  Variable , Property , EnumMember , Method ,
  Keyword , Comment , String , Number ,
  Regexp , Operator , Decorator , QmlLocalId ,
  QmlExternalId , QmlRootObjectProperty , QmlScopeObjectProperty , QmlExternalObjectProperty ,
  JsScopeVar , JsImportVar , JsGlobalVar , QmlStateName ,
  Field , Unknown
}

Functions

QList< int > encodeSemanticTokens (Highlights &highlights)
QList< QQmlJS::SourceLocationsourceLocationsFromMultiLineToken (QStringView code, const QQmlJS::SourceLocation &tokenLocation)
 Returns multiple source locations for a given raw comment.
void addModifier (QLspSpecification::SemanticTokenModifiers modifier, int *baseModifier)
bool rangeOverlapsWithSourceLocation (const QQmlJS::SourceLocation &loc, const HighlightsRange &r)
QList< QLspSpecification::SemanticTokensEdit > computeDiff (const QList< int > &, const QList< int > &)
void updateResultID (QByteArray &resultID)
QList< int > collectTokens (const QQmlJS::Dom::DomItem &item, const std::optional< HighlightsRange > &range, HighlightingMode mode=HighlightingMode::Default)
Highlights visitTokens (const QQmlJS::Dom::DomItem &item, const std::optional< HighlightsRange > &range, HighlightingMode mode=HighlightingMode::Default)

Enumeration Type Documentation

◆ HighlightingMode

Enumerator
Default 
QtCHighlighting 

Definition at line 79 of file qqmlsemantictokens_p.h.

◆ QmlHighlightKind

Enumerator
QmlKeyword 
QmlType 
QmlImportId 
QmlNamespace 
QmlLocalId 
QmlExternalId 
QmlProperty 
QmlScopeObjectProperty 
QmlRootObjectProperty 
QmlExternalObjectProperty 
QmlMethod 
QmlMethodParameter 
QmlSignal 
QmlSignalHandler 
QmlEnumName 
QmlEnumMember 
QmlPragmaName 
QmlPragmaValue 
QmlTypeModifier 
JsImport 
JsGlobalVar 
JsGlobalMethod 
JsScopeVar 
JsLabel 
Number 
String 
Comment 
Operator 
Field 
Unknown 

Definition at line 35 of file qqmlsemantictokens_p.h.

◆ QmlHighlightModifier

Enumerator
None 
QmlPropertyDefinition 
QmlDefaultProperty 
QmlFinalProperty 
QmlRequiredProperty 
QmlReadonlyProperty 

Definition at line 68 of file qqmlsemantictokens_p.h.

◆ SemanticTokenProtocolTypes

Enumerator
Namespace 
Type 
Enum 
Parameter 
Variable 
Property 
EnumMember 
Method 
Keyword 
Comment 
String 
Number 
Regexp 
Operator 
Decorator 
QmlLocalId 
QmlExternalId 
QmlRootObjectProperty 
QmlScopeObjectProperty 
QmlExternalObjectProperty 
JsScopeVar 
JsImportVar 
JsGlobalVar 
QmlStateName 
Field 
Unknown 

Definition at line 86 of file qqmlsemantictokens_p.h.

Function Documentation

◆ addModifier()

void HighlightingUtils::addModifier ( QLspSpecification::SemanticTokenModifiers modifier,
int * baseModifier )

◆ collectTokens()

QList< int > HighlightingUtils::collectTokens ( const QQmlJS::Dom::DomItem & item,
const std::optional< HighlightsRange > & range,
HighlightingMode mode = HighlightingMode::Default )

Definition at line 1057 of file qqmlsemantictokens.cpp.

◆ computeDiff()

QList< SemanticTokensEdit > HighlightingUtils::computeDiff ( const QList< int > & oldData,
const QList< int > & newData )

Definition at line 993 of file qqmlsemantictokens.cpp.

◆ encodeSemanticTokens()

QList< int > HighlightingUtils::encodeSemanticTokens ( Highlights & highlights)

Definition at line 914 of file qqmlsemantictokens.cpp.

◆ rangeOverlapsWithSourceLocation()

bool HighlightingUtils::rangeOverlapsWithSourceLocation ( const QQmlJS::SourceLocation & loc,
const HighlightsRange & r )

Check if the ranges overlap by ensuring that one range starts before the other ends

Definition at line 961 of file qqmlsemantictokens.cpp.

References HighlightsRange::endOffset, and HighlightsRange::startOffset.

◆ sourceLocationsFromMultiLineToken()

QList< QQmlJS::SourceLocation > HighlightingUtils::sourceLocationsFromMultiLineToken ( QStringView stringLiteral,
const QQmlJS::SourceLocation & locationInDocument )

Returns multiple source locations for a given raw comment.

Needed by semantic highlighting of comments. LSP clients usually don't support multiline tokens. In QML, we can have multiline tokens like string literals and comments. This method generates multiple source locations of sub-elements of token split by a newline delimiter.

Definition at line 866 of file qqmlsemantictokens.cpp.

◆ updateResultID()

void HighlightingUtils::updateResultID ( QByteArray & resultID)

Definition at line 973 of file qqmlsemantictokens.cpp.

Referenced by SemanticTokenDeltaHandler::process(), SemanticTokenFullHandler::process(), and SemanticTokenRangeHandler::process().

Here is the caller graph for this function:

◆ visitTokens()

Highlights HighlightingUtils::visitTokens ( const QQmlJS::Dom::DomItem & item,
const std::optional< HighlightsRange > & range,
HighlightingMode mode = HighlightingMode::Default )

Definition at line 1048 of file qqmlsemantictokens.cpp.

References HighlightingVisitor::highlights().

Here is the call graph for this function: