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
QQmlJS::Dom::DomEnvironment Class Referencefinal

Represents a consistent set of types organized in modules, it is the top level of the DOM. More...

#include <qqmldomtop_p.h>

Inheritance diagram for QQmlJS::Dom::DomEnvironment:
Collaboration diagram for QQmlJS::Dom::DomEnvironment:

Classes

struct  LoadResult

Public Types

enum class  Option {
  Default = 0x0 , KeepValid = 0x1 , Exported = 0x2 , NoReload = 0x4 ,
  WeakLoad = 0x8 , SingleThreaded = 0x10 , NoDependencies = 0x20
}
Public Types inherited from QQmlJS::Dom::DomTop
using Callback = DomItem::Callback
Public Types inherited from QQmlJS::Dom::DomBase
using FilterT = function_ref<bool(const DomItem &, const PathEls::PathComponent &, const DomItem &)>

Public Member Functions

 Q_DECLARE_FLAGS (Options, Option)
DomType kind () const override
Path canonicalPath () const override
bool iterateDirectSubpaths (const DomItem &self, DirectVisitor) const override
DomItem field (const DomItem &self, QStringView name) const final override
std::shared_ptr< DomEnvironment > makeCopy (const DomItem &self) const
bool hasFile (const QString &filePath) const
void loadFile (const FileToLoad &file, const Callback &callback, std::optional< DomType > fileType=std::optional< DomType >(), const ErrorHandler &h=nullptr)
void removePath (const QString &path)
std::shared_ptr< DomUniverse > universe () const
QSet< QString > moduleIndexUris (const DomItem &self, EnvLookup lookup=EnvLookup::Normal) const
QSet< int > moduleIndexMajorVersions (const DomItem &self, const QString &uri, EnvLookup lookup=EnvLookup::Normal) const
std::shared_ptr< ExternalItemInfoBase > qmlDirWithPath (const DomItem &self, const QString &path, EnvLookup options=EnvLookup::Normal) const
std::shared_ptr< ExternalItemInfo< QmlFile > > qmlFileWithPath (const DomItem &self, const QString &path, EnvLookup options=EnvLookup::Normal) const
QSet< QString > qmlFilePaths (const DomItem &self, EnvLookup lookup=EnvLookup::Normal) const
std::shared_ptr< ExternalItemInfo< JsFile > > jsFileWithPath (const DomItem &self, const QString &path, EnvLookup options=EnvLookup::Normal) const
QSet< QString > jsFilePaths (const DomItem &self, EnvLookup lookup=EnvLookup::Normal) const
 DomEnvironment (const QStringList &loadPaths, Options options=Option::SingleThreaded, DomCreationOption domCreationOption=Default, const std::shared_ptr< DomUniverse > &universe=nullptr)
 DomEnvironment (const std::shared_ptr< DomEnvironment > &parent, const QStringList &loadPaths, Options options=Option::SingleThreaded, DomCreationOption domCreationOption=Default)
 DomEnvironment (const DomEnvironment &o)=delete
void addQmlFile (const std::shared_ptr< QmlFile > &file, AddOption option=AddOption::KeepExisting)
void addJsFile (const std::shared_ptr< JsFile > &file, AddOption option=AddOption::KeepExisting)
bool commitToBase (const DomItem &self, const std::shared_ptr< DomEnvironment > &validEnv=nullptr)
void addDependenciesToLoad (const Path &path)
void addLoadInfo (const DomItem &self, const std::shared_ptr< LoadInfo > &loadInfo)
std::shared_ptr< LoadInfo > loadInfo (const Path &path) const
QList< Path > loadInfoPaths () const
QHash< Path, std::shared_ptr< LoadInfo > > loadInfos () const
void loadPendingDependencies ()
bool finishLoadingDependencies (int waitMSec=30000)
void addWorkForLoadInfo (const Path &elementCanonicalPath)
Options options () const
std::shared_ptr< DomEnvironment > base () const
QStringList loadPaths () const
QList< Import > implicitImports () const
void addAllLoadedCallback (const DomItem &self, Callback c)
void clearReferenceCache ()
void setLoadPaths (const QStringList &v)
void setResourceFiles (const QStringList &v)
template<typename T>
LoadResult insertOrUpdateExternalItemInfo (const QString &path, std::shared_ptr< T > extItem)
template<typename T>
void addExternalItemInfo (const DomItem &newExtItem, const Callback &loadCallback, const Callback &endCallback)
void populateFromQmlFile (MutableDomItem &&qmlFile)
DomCreationOption domCreationOption () const
SemanticAnalysis semanticAnalysis ()
Path canonicalPath (const DomItem &) const override
 QQml::Dom::DomTop::loadFile.
Public Member Functions inherited from QQmlJS::Dom::DomTop
 DomTop (QMap< QString, OwnerT > extraOwningItems={}, int derivedFrom=0)
 DomTop (const DomTop &o)
Path canonicalPath (const DomItem &) const override
 QQml::Dom::DomTop::loadFile.
DomItem containingObject (const DomItem &) const override
bool iterateDirectSubpaths (const DomItem &self, DirectVisitor) const override
template<typename T>
void setExtraOwningItem (const QString &fieldName, const std::shared_ptr< T > &item)
void clearExtraOwningItems ()
QMap< QString, OwnerT > extraOwningItems () const
Public Member Functions inherited from QQmlJS::Dom::OwningItem
 OwningItem (const OwningItem &o)
 OwningItem (int derivedFrom=0)
 OwningItem (int derivedFrom, const QDateTime &lastDataUpdateAt)
 OwningItem (const OwningItem &&)=delete
OwningItem & operator= (const OwningItem &&)=delete
bool iterateDirectSubpaths (const DomItem &self, DirectVisitor) const override
std::shared_ptr< OwningItem > makeCopy (const DomItem &self) const
Path pathFromOwner () const override final
DomItem containingObject (const DomItem &self) const override
int derivedFrom () const
virtual int revision () const
QDateTime createdAt () const
virtual QDateTime lastDataUpdateAt () const
virtual void refreshedDataAt (QDateTime tNew)
virtual bool frozen () const
virtual bool freeze ()
QDateTime frozenAt () const
virtual void addError (const DomItem &self, ErrorMessage &&msg)
void addErrorLocal (ErrorMessage &&msg)
void clearErrors (const ErrorGroups &groups=ErrorGroups({}))
bool iterateErrors (const DomItem &self, function_ref< bool(const DomItem &source, const ErrorMessage &msg)> visitor, const Path &inPath=Path())
QMultiMap< Path, ErrorMessage > localErrors () const
virtual bool iterateSubOwners (const DomItem &self, function_ref< bool(const DomItem &owner)> visitor)
QBasicMutex * mutex () const
Public Member Functions inherited from QQmlJS::Dom::DomBase
virtual ~DomBase ()=default
DomBase * domBase ()
const DomBase * domBase () const
virtual DomKind domKind () const
virtual void dump (const DomItem &, const Sink &sink, int indent, FilterT filter) const
virtual quintptr id () const
QString typeName () const
virtual QList< QString > fields (const DomItem &self) const
virtual index_type indexes (const DomItem &self) const
virtual DomItem index (const DomItem &self, index_type index) const
virtual QSet< QString > const keys (const DomItem &self) const
virtual DomItem key (const DomItem &self, const QString &name) const
virtual QString canonicalFilePath (const DomItem &self) const
virtual void writeOut (const DomItem &self, OutWriter &lw) const
virtual QCborValue value () const

Static Public Member Functions

static ErrorGroups myErrors ()
static std::shared_ptr< DomEnvironment > create (const QStringList &loadPaths, Options options=Option::SingleThreaded, DomCreationOption creationOption=DomCreationOption::Default, const DomItem &universe=DomItem::empty)
static QList< Import > defaultImplicitImports ()
Static Public Member Functions inherited from QQmlJS::Dom::OwningItem
static int nextRevision ()

Static Public Attributes

static constexpr DomType kindValue = DomType::DomEnvironment

Protected Member Functions

std::shared_ptr< OwningItem > doCopy (const DomItem &self) const override

Friends

class RefCacheEntry

Detailed Description

Represents a consistent set of types organized in modules, it is the top level of the DOM.

The DomEnvironment keeps a pointer m_lastValidBase to the last used valid DomEnvironment in the commitToBase() method. This allows the qqmldomastcreator to commit lazily loaded dependencies to the valid environment used by qmlls.

Definition at line 626 of file qqmldomtop_p.h.

Member Enumeration Documentation

◆ Option

Enumerator
Default 
KeepValid 
Exported 
NoReload 
WeakLoad 
SingleThreaded 
NoDependencies 

Definition at line 650 of file qqmldomtop_p.h.

Constructor & Destructor Documentation

◆ DomEnvironment() [1/3]

QQmlJS::Dom::DomEnvironment::DomEnvironment ( const QStringList & loadPaths,
Options options = Option::SingleThreaded,
DomCreationOption domCreationOption = Default,
const std::shared_ptr< DomUniverse > & universe = nullptr )
explicit

◆ DomEnvironment() [2/3]

QQmlJS::Dom::DomEnvironment::DomEnvironment ( const std::shared_ptr< DomEnvironment > & parent,
const QStringList & loadPaths,
Options options = Option::SingleThreaded,
DomCreationOption domCreationOption = Default )
explicit

◆ DomEnvironment() [3/3]

QQmlJS::Dom::DomEnvironment::DomEnvironment ( const DomEnvironment & o)
delete

Member Function Documentation

◆ addAllLoadedCallback()

void QQmlJS::Dom::DomEnvironment::addAllLoadedCallback ( const DomItem & self,
DomTop::Callback c )

Definition at line 1503 of file qqmldomtop.cpp.

References QQmlJS::Dom::Path::Path().

Here is the call graph for this function:

◆ addDependenciesToLoad()

void QQmlJS::Dom::DomEnvironment::addDependenciesToLoad ( const Path & path)

Depending on the creation options, this function adds LoadInfo of the provided path

Definition at line 1123 of file qqmldomtop.cpp.

References addLoadInfo().

Referenced by addExternalItemInfo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addExternalItemInfo()

template<typename T>
void QQmlJS::Dom::DomEnvironment::addExternalItemInfo ( const DomItem & newExtItem,
const Callback & loadCallback,
const Callback & endCallback )
inline

Definition at line 791 of file qqmldomtop_p.h.

References addDependenciesToLoad().

Here is the call graph for this function:

◆ addJsFile()

void QQmlJS::Dom::DomEnvironment::addJsFile ( const std::shared_ptr< JsFile > & file,
AddOption option = AddOption::KeepExisting )

Definition at line 1294 of file qqmldomtop.cpp.

◆ addLoadInfo()

void QQmlJS::Dom::DomEnvironment::addLoadInfo ( const DomItem & self,
const std::shared_ptr< LoadInfo > & loadInfo )

Enqueues path to the m_loadsWithWork (queue of the pending "load" jobs). In simpler words, schedule the load of the dependencies of the path from loadInfo.

Definition at line 1138 of file qqmldomtop.cpp.

References QQmlJS::Dom::DomItem::addError(), QQmlJS::Dom::LoadInfo::Done, QQmlJS::Dom::ErrorGroups::error(), and myErrors().

Referenced by addDependenciesToLoad().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addQmlFile()

void QQmlJS::Dom::DomEnvironment::addQmlFile ( const std::shared_ptr< QmlFile > & file,
AddOption option = AddOption::KeepExisting )

Definition at line 1279 of file qqmldomtop.cpp.

References domCreationOption(), QQmlJS::Dom::Extended, and semanticAnalysis().

Here is the call graph for this function:

◆ addWorkForLoadInfo()

void QQmlJS::Dom::DomEnvironment::addWorkForLoadInfo ( const Path & elementCanonicalPath)

Definition at line 1458 of file qqmldomtop.cpp.

◆ base()

std::shared_ptr< DomEnvironment > QQmlJS::Dom::DomEnvironment::base ( ) const

Definition at line 1469 of file qqmldomtop.cpp.

Referenced by commitToBase().

Here is the caller graph for this function:

◆ canonicalPath() [1/2]

Path QQmlJS::Dom::DomEnvironment::canonicalPath ( ) const
overridevirtual

Implements QQmlJS::Dom::DomTop.

Definition at line 785 of file qqmldomtop.cpp.

References QQmlJS::Dom::Path::fromRoot().

Here is the call graph for this function:

◆ canonicalPath() [2/2]

Path QQmlJS::Dom::DomTop::canonicalPath ( const DomItem & ) const
overridevirtual

QQml::Dom::DomTop::loadFile.

Parameters
filePaththe file path to load
logicalPaththe path from the
callbacka callback called with an canonical path, the old value, and the current value.
loadOptionsare if force is true the file is always read

Implements QQmlJS::Dom::OwningItem.

Definition at line 154 of file qqmldomtop.cpp.

◆ clearReferenceCache()

void QQmlJS::Dom::DomEnvironment::clearReferenceCache ( )

Definition at line 1519 of file qqmldomtop.cpp.

◆ commitToBase()

bool QQmlJS::Dom::DomEnvironment::commitToBase ( const DomItem & self,
const std::shared_ptr< DomEnvironment > & validEnv = nullptr )

Definition at line 1325 of file qqmldomtop.cpp.

References base().

Here is the call graph for this function:

◆ create()

std::shared_ptr< DomEnvironment > QQmlJS::Dom::DomEnvironment::create ( const QStringList & loadPaths,
Options options = Option::SingleThreaded,
DomCreationOption creationOption = DomCreationOption::Default,
const DomItem & universe = DomItem::empty )
static

Definition at line 1259 of file qqmldomtop.cpp.

◆ defaultImplicitImports()

QList< Import > QQmlJS::Dom::DomEnvironment::defaultImplicitImports ( )
static

Definition at line 1492 of file qqmldomtop.cpp.

◆ doCopy()

std::shared_ptr< OwningItem > QQmlJS::Dom::DomEnvironment::doCopy ( const DomItem & self) const
overrideprotectedvirtual

Implements QQmlJS::Dom::OwningItem.

Definition at line 916 of file qqmldomtop.cpp.

Referenced by makeCopy().

Here is the caller graph for this function:

◆ domCreationOption()

DomCreationOption QQmlJS::Dom::DomEnvironment::domCreationOption ( ) const
inline

Definition at line 826 of file qqmldomtop_p.h.

Referenced by addQmlFile().

Here is the caller graph for this function:

◆ field()

DomItem QQmlJS::Dom::DomEnvironment::field ( const DomItem & self,
QStringView name ) const
finaloverridevirtual

Reimplemented from QQmlJS::Dom::DomBase.

Definition at line 906 of file qqmldomtop.cpp.

◆ finishLoadingDependencies()

bool QQmlJS::Dom::DomEnvironment::finishLoadingDependencies ( int waitMSec = 30000)

Definition at line 1430 of file qqmldomtop.cpp.

References QQmlJS::Dom::LoadInfo::Done, and loadPendingDependencies().

Here is the call graph for this function:

◆ hasFile()

bool QQmlJS::Dom::DomEnvironment::hasFile ( const QString & filePath) const

Definition at line 927 of file qqmldomtop.cpp.

◆ implicitImports()

QList< Import > QQmlJS::Dom::DomEnvironment::implicitImports ( ) const

Definition at line 1498 of file qqmldomtop.cpp.

◆ insertOrUpdateExternalItemInfo()

template<typename T>
LoadResult QQmlJS::Dom::DomEnvironment::insertOrUpdateExternalItemInfo ( const QString & path,
std::shared_ptr< T > extItem )
inline

Definition at line 751 of file qqmldomtop_p.h.

References QQmlJS::Dom::BaseOnly.

◆ iterateDirectSubpaths()

bool QQmlJS::Dom::DomEnvironment::iterateDirectSubpaths ( const DomItem & self,
DirectVisitor visitor ) const
overridevirtual

Implements QQmlJS::Dom::DomBase.

Definition at line 790 of file qqmldomtop.cpp.

References universe().

Here is the call graph for this function:

◆ jsFilePaths()

QSet< QString > QQmlJS::Dom::DomEnvironment::jsFilePaths ( const DomItem & self,
EnvLookup lookup = EnvLookup::Normal ) const

Definition at line 1109 of file qqmldomtop.cpp.

◆ jsFileWithPath()

std::shared_ptr< ExternalItemInfo< JsFile > > QQmlJS::Dom::DomEnvironment::jsFileWithPath ( const DomItem & self,
const QString & path,
EnvLookup options = EnvLookup::Normal ) const

Definition at line 1104 of file qqmldomtop.cpp.

◆ kind()

DomType QQmlJS::Dom::DomEnvironment::kind ( ) const
overridevirtual

Implements QQmlJS::Dom::DomBase.

Definition at line 780 of file qqmldomtop.cpp.

References kindValue.

◆ loadFile()

void QQmlJS::Dom::DomEnvironment::loadFile ( const FileToLoad & file,
const Callback & callback,
std::optional< DomType > fileType = std::optional<DomType>(),
const ErrorHandler & h = nullptr )

Definition at line 931 of file qqmldomtop.cpp.

◆ loadInfo()

std::shared_ptr< LoadInfo > QQmlJS::Dom::DomEnvironment::loadInfo ( const Path & path) const

Definition at line 1160 of file qqmldomtop.cpp.

◆ loadInfoPaths()

QList< Path > QQmlJS::Dom::DomEnvironment::loadInfoPaths ( ) const

Definition at line 1172 of file qqmldomtop.cpp.

◆ loadInfos()

QHash< Path, std::shared_ptr< LoadInfo > > QQmlJS::Dom::DomEnvironment::loadInfos ( ) const

Definition at line 1166 of file qqmldomtop.cpp.

◆ loadPaths()

QStringList QQmlJS::Dom::DomEnvironment::loadPaths ( ) const

Definition at line 1486 of file qqmldomtop.cpp.

◆ loadPendingDependencies()

void QQmlJS::Dom::DomEnvironment::loadPendingDependencies ( )

Definition at line 1386 of file qqmldomtop.cpp.

References QQmlJS::Dom::DomItem::addError(), QQmlJS::Dom::ErrorGroups::error(), and myErrors().

Referenced by finishLoadingDependencies().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeCopy()

std::shared_ptr< DomEnvironment > QQmlJS::Dom::DomEnvironment::makeCopy ( const DomItem & self) const

Definition at line 911 of file qqmldomtop.cpp.

References doCopy().

Here is the call graph for this function:

◆ moduleIndexMajorVersions()

QSet< int > QQmlJS::Dom::DomEnvironment::moduleIndexMajorVersions ( const DomItem & self,
const QString & uri,
EnvLookup lookup = EnvLookup::Normal ) const

◆ moduleIndexUris()

QSet< QString > QQmlJS::Dom::DomEnvironment::moduleIndexUris ( const DomItem & self,
EnvLookup lookup = EnvLookup::Normal ) const

◆ myErrors()

ErrorGroups QQmlJS::Dom::DomEnvironment::myErrors ( )
static

Definition at line 774 of file qqmldomtop.cpp.

Referenced by addLoadInfo(), QQmlJS::Dom::LoadInfo::advanceLoad(), QQmlJS::Dom::LoadInfo::doCopy(), QQmlJS::Dom::LoadInfo::finishedLoadingDep(), and loadPendingDependencies().

Here is the caller graph for this function:

◆ options()

DomEnvironment::Options QQmlJS::Dom::DomEnvironment::options ( ) const

◆ populateFromQmlFile()

void QQmlJS::Dom::DomEnvironment::populateFromQmlFile ( MutableDomItem && qmlFile)

Definition at line 1524 of file qqmldomtop.cpp.

References QQmlJS::Dom::CommentCollector::CommentCollector(), QQmlJS::Dom::CommentCollector::collectComments(), QQmlJS::Dom::Default, QQmlJS::Dom::Extended, and QQmlJS::Dom::Minimal.

Here is the call graph for this function:

◆ Q_DECLARE_FLAGS()

QQmlJS::Dom::DomEnvironment::Q_DECLARE_FLAGS ( Options ,
Option  )

◆ qmlDirWithPath()

std::shared_ptr< ExternalItemInfoBase > QQmlJS::Dom::DomEnvironment::qmlDirWithPath ( const DomItem & self,
const QString & path,
EnvLookup options = EnvLookup::Normal ) const

◆ qmlFilePaths()

QSet< QString > QQmlJS::Dom::DomEnvironment::qmlFilePaths ( const DomItem & self,
EnvLookup lookup = EnvLookup::Normal ) const

Definition at line 1093 of file qqmldomtop.cpp.

◆ qmlFileWithPath()

std::shared_ptr< ExternalItemInfo< QmlFile > > QQmlJS::Dom::DomEnvironment::qmlFileWithPath ( const DomItem & self,
const QString & path,
EnvLookup options = EnvLookup::Normal ) const

Definition at line 1088 of file qqmldomtop.cpp.

◆ removePath()

void QQmlJS::Dom::DomEnvironment::removePath ( const QString & path)

Definition at line 1042 of file qqmldomtop.cpp.

◆ semanticAnalysis()

DomEnvironment::SemanticAnalysis QQmlJS::Dom::DomEnvironment::semanticAnalysis ( )

Do not call this method inside of DomEnvironment's constructor! It requires weak_from_this() that only works after the constructor call finished.

Definition at line 1195 of file qqmldomtop.cpp.

Referenced by addQmlFile().

Here is the caller graph for this function:

◆ setLoadPaths()

void QQmlJS::Dom::DomEnvironment::setLoadPaths ( const QStringList & v)

Definition at line 1474 of file qqmldomtop.cpp.

◆ setResourceFiles()

void QQmlJS::Dom::DomEnvironment::setResourceFiles ( const QStringList & v)

Definition at line 1480 of file qqmldomtop.cpp.

◆ universe()

shared_ptr< DomUniverse > QQmlJS::Dom::DomEnvironment::universe ( ) const

Definition at line 1053 of file qqmldomtop.cpp.

Referenced by iterateDirectSubpaths().

Here is the caller graph for this function:

◆ RefCacheEntry

friend class RefCacheEntry
friend

Definition at line 829 of file qqmldomtop_p.h.

Member Data Documentation

◆ kindValue

DomType QQmlJS::Dom::DomEnvironment::kindValue = DomType::DomEnvironment
staticconstexpr

Definition at line 663 of file qqmldomtop_p.h.

Referenced by kind().


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