diff --git a/doc/api/qtcreator-api.qdoc b/doc/api/qtcreator-api.qdoc index b2bbb68b87dc5491d5989b5f8a4ca285b6c06bea..559192ace0f77028d77dcc1ff18bac4b490f12bf 100644 --- a/doc/api/qtcreator-api.qdoc +++ b/doc/api/qtcreator-api.qdoc @@ -57,6 +57,10 @@ \o \l{Utils} \o General utility library. + \row + \o \l{QmlJS} + \o QML and JavaScript language support library. + \endtable \section2 Additional libraries diff --git a/doc/config/qtcreator-developer.qdocconf b/doc/config/qtcreator-developer.qdocconf index 72b607d2e74fa6a1322589a7e4483a256857f184..ba161ea34d06a5fc4de4003d27831fbb8537e660 100644 --- a/doc/config/qtcreator-developer.qdocconf +++ b/doc/config/qtcreator-developer.qdocconf @@ -8,6 +8,7 @@ headerdirs = . \ ../../src/libs/cplusplus \ ../../src/libs/extensionsystem \ ../../src/libs/utils \ + ../../src/libs/qmljs \ ../../src/libs/qtcreatorcdbext \ ../../src/plugins/coreplugin \ ../../src/plugins/find \ @@ -22,6 +23,7 @@ sourcedirs = . \ ../../src/libs/cplusplus \ ../../src/libs/extensionsystem \ ../../src/libs/utils \ + ../../src/libs/qmljs \ ../../src/libs/qtcreatorcdbext \ ../../src/plugins/coreplugin \ ../../src/plugins/find \ diff --git a/src/libs/qmljs/qmljsbind.cpp b/src/libs/qmljs/qmljsbind.cpp index abc219e791a55df68d7d90e4e04f8871ba258d06..8e9d2e1490732ee2c631bcbe1a366bcedb99880f 100644 --- a/src/libs/qmljs/qmljsbind.cpp +++ b/src/libs/qmljs/qmljsbind.cpp @@ -48,16 +48,18 @@ using namespace QmlJS::AST; /*! \class QmlJS::Bind \brief Collected information about a single Document. - \sa QmlJS::Document QmlJS::Link + \sa QmlJS::Document QmlJS::Context - Each QmlJS::Document owns a instance of Bind. It provides access to data + Each QmlJS::Document owns an instance of Bind. It provides access to data that can be derived by looking at the document in isolation. If you need - information that goes beyond that, you need to create a - \l{QmlJS::Context} using \l{QmlJS::Link}. + information that goes beyond that, you need to use a + \l{QmlJS::Context}. The document's imports are classified and available through imports(). - It allows AST to code model lookup through findQmlObject() and findFunctionScope(). + This class makes the structural information found in the AST available + for analysis through \l{QmlJS::Value} instances. See findQmlObject(), + idEnvironment(), rootObjectValue() and findAttachedJSScope(). */ Bind::Bind(Document *doc, QList<DiagnosticMessage> *messages, bool isJsLibrary, const QList<ImportInfo> &jsImports) diff --git a/src/libs/qmljs/qmljscontext.cpp b/src/libs/qmljs/qmljscontext.cpp index 648702b1111fad51d1476ab8571fb12b0b63cbff..df2ea8341040f7f434e07d5b31704d59b11a04dd 100644 --- a/src/libs/qmljs/qmljscontext.cpp +++ b/src/libs/qmljs/qmljscontext.cpp @@ -37,6 +37,20 @@ using namespace QmlJS; using namespace QmlJS::AST; +/*! + \class QmlJS::Context + \brief Holds information about relationships between documents in a QmlJS::Snapshot. + \sa QmlJS::Document QmlJS::Link QmlJS::Snapshot + + Contexts are usually created through \l{QmlJS::Link}. + + Once created, a Context is immutable and can be freely shared between threads. + + Their main purpose is to allow lookup of types with lookupType() and resolving + of references through lookupReference(). Information about the imports of + a QmlJS::Document can be accessed with imports(). +*/ + ContextPtr Context::create(const QmlJS::Snapshot &snapshot, ValueOwner *valueOwner, const ImportsPerDocument &imports) { QSharedPointer<Context> result(new Context(snapshot, valueOwner, imports)); diff --git a/src/libs/qmljs/qmljsdocument.cpp b/src/libs/qmljs/qmljsdocument.cpp index 51f8108ee9aca61a87c618875fb8e80c81c9504e..9387423e38b82d59e1c9d7e61f81f9bd9a61c02e 100644 --- a/src/libs/qmljs/qmljsdocument.cpp +++ b/src/libs/qmljs/qmljsdocument.cpp @@ -46,13 +46,17 @@ using namespace QmlJS::AST; \brief A Qml or JavaScript document. \sa QmlJS::Snapshot - Documents are usually created by the \l{QmlJSEditor::Internal::ModelManager} + Documents are usually created by the \l{QmlJS::ModelManagerInterface} and stored in a \l{QmlJS::Snapshot}. They allow access to data such as the file path, source code, abstract syntax tree and the \l{QmlJS::Bind} instance for the document. To make sure unused and outdated documents are removed correctly, Document instances are usually accessed through a shared pointer, see \l{Document::Ptr}. + + Documents in a Snapshot are immutable: They, or anything reachable through them, + must not be changed. This allows Documents to be shared freely among threads + without extra synchronization. */ /*! @@ -60,7 +64,7 @@ using namespace QmlJS::AST; \brief A Qml library. \sa QmlJS::Snapshot - A LibraryInfo is created when the \l{QmlJSEditor::Internal::ModelManager} finds + A LibraryInfo is created when the \l{QmlJS::ModelManagerInterface} finds a Qml library and parses the qmldir file. The instance holds information about which Components the library provides and which plugins to load. @@ -77,7 +81,7 @@ using namespace QmlJS::AST; A Snapshot holds and offers access to a set of Document and LibraryInfo instances. Usually Snapshots are copies of the snapshot maintained and updated by the - \l{QmlJSEditor::Internal::ModelManager} that updates its instance as parsing + \l{QmlJS::ModelManagerInterface} that updates its instance as parsing threads finish and new information becomes available. */ diff --git a/src/libs/qmljs/qmljsdocument.h b/src/libs/qmljs/qmljsdocument.h index 50e7a81034de22e5040e2e8f02c548c586819d17..4f7ca3e7272aca85166bcf2bc5cc0fb21a376e7c 100644 --- a/src/libs/qmljs/qmljsdocument.h +++ b/src/libs/qmljs/qmljsdocument.h @@ -43,8 +43,6 @@ #include "parser/qmljsengine_p.h" #include "qmljs_global.h" -QT_QML_BEGIN_NAMESPACE - namespace QmlJS { class Bind; @@ -239,6 +237,4 @@ public: } // namespace QmlJS -QT_QML_END_NAMESPACE - #endif // QMLDOCUMENT_H diff --git a/src/libs/qmljs/qmljslink.cpp b/src/libs/qmljs/qmljslink.cpp index 17127dfc0113b8deb5e736f8c686a072d570cdb0..70746d440ca34fb0a56d128f0dd6588770d0fab6 100644 --- a/src/libs/qmljs/qmljslink.cpp +++ b/src/libs/qmljs/qmljslink.cpp @@ -125,15 +125,13 @@ public: /*! \class QmlJS::Link - \brief Initializes the Context for a Document. - \sa QmlJS::Document QmlJS::Context + \brief Creates a Context for a Snapshot. + \sa QmlJS::Context QmlJS::Snapshot - Initializes a context by resolving imports and building the root scope - chain. Currently, this is a expensive operation. + Initializes a context by resolving imports. This is an expensive operation. - It's recommended to use a the \l{LookupContext} returned by - \l{QmlJSEditor::SemanticInfo::lookupContext()} instead of building a new - \l{Context} with \l{Link}. + Instead of making a fresh context, consider reusing the one maintained in the + \l{QmlJSEditor::SemanticInfo} of a \l{QmlJSEditor::QmlJSTextEditorWidget}. */ Link::Link(const Snapshot &snapshot, const QStringList &importPaths, const LibraryInfo &builtins) diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.h b/src/libs/qmljs/qmljsmodelmanagerinterface.h index c5bb8d2292829b3b6904b19db51de3573664ee3f..07311c0efa9c9da11fd3e723f49a9e7d76301941 100644 --- a/src/libs/qmljs/qmljsmodelmanagerinterface.h +++ b/src/libs/qmljs/qmljsmodelmanagerinterface.h @@ -46,8 +46,6 @@ namespace ProjectExplorer { class Project; } -QT_QML_BEGIN_NAMESPACE - namespace QmlJS { class Snapshot; @@ -170,6 +168,4 @@ signals: } // namespace QmlJS -QT_QML_END_NAMESPACE - #endif // QMLJSMODELMANAGERINTERFACE_H diff --git a/src/libs/qmljs/qmljsutils.cpp b/src/libs/qmljs/qmljsutils.cpp index 1a6e6eb40f40d736b7de2ab862db03142af6bde1..52c839c793ba6e8c2c59cd0204bff8e50ead93ca 100644 --- a/src/libs/qmljs/qmljsutils.cpp +++ b/src/libs/qmljs/qmljsutils.cpp @@ -5,6 +5,11 @@ using namespace QmlJS; using namespace QmlJS::AST; +/*! + \namespace QmlJS + QML and JavaScript language support library +*/ + namespace { class SharedData { diff --git a/src/libs/qmljs/qmljsvalueowner.cpp b/src/libs/qmljs/qmljsvalueowner.cpp index 9182f0374044ee017162bc558d1aaa6fe24c9322..173f68b767be6fce60a3d139fc0607ff958a7626 100644 --- a/src/libs/qmljs/qmljsvalueowner.cpp +++ b/src/libs/qmljs/qmljsvalueowner.cpp @@ -34,6 +34,17 @@ using namespace QmlJS; +/*! + \class QmlJS::ValueOwner + \brief Manages the lifetime of \l{QmlJS::Value}s. + \sa QmlJS::Value + + Values are usually created on a ValueOwner. When the ValueOwner is destroyed + it deletes all values it has registered. + + A ValueOwner also provides access to various default values. +*/ + namespace { ////////////////////////////////////////////////////////////////////////////////