Commit e33767205bd2663b90d1fedbba43bef6fbcf9835
Introduced SemanticInfo::isValid().
| |   |
| 678 | 678 | m_completions.clear(); |
| 679 | 679 | |
| 680 | 680 | const SemanticInfo semanticInfo = edit->semanticInfo(); |
| const QmlJS::Snapshot snapshot = semanticInfo.snapshot; |
| const Document::Ptr document = semanticInfo.document; |
| 683 | 681 | |
| if (!document) |
| if (! semanticInfo.isValid()) |
| 685 | 683 | return -1; |
| 686 | 684 | |
| const Document::Ptr document = semanticInfo.document; |
| 687 | 686 | const QFileInfo currentFileInfo(fileName); |
| 688 | 687 | |
| 689 | 688 | bool isQmlFile = false; |
| |   |
| 556 | 556 | |
| 557 | 557 | LookupContext::Ptr SemanticInfo::lookupContext(const QList<QmlJS::AST::Node *> &path) const |
| 558 | 558 | { |
| Q_ASSERT(! m_context.isNull()); |
|
| if (m_context.isNull()) |
| return LookupContext::create(document, snapshot, path); |
|
| 559 | 564 | return LookupContext::create(document, snapshot, *m_context, path); |
| 560 | 565 | } |
| 561 | 566 | |
| … | … | |
| 615 | 615 | return 0; |
| 616 | 616 | } |
| 617 | 617 | |
| bool SemanticInfo::isValid() const |
| { |
| if (document && m_context) |
| return true; |
|
| return false; |
| } |
|
| 618 | 626 | int SemanticInfo::revision() const |
| 619 | 627 | { |
| 620 | 628 | if (document) |
| … | … | |
| 1373 | 1373 | TextEditor::BaseTextEditor::Link QmlJSTextEditor::findLinkAt(const QTextCursor &cursor, bool /*resolveTarget*/) |
| 1374 | 1374 | { |
| 1375 | 1375 | const SemanticInfo semanticInfo = m_semanticInfo; |
| if (! semanticInfo.isValid()) |
| return Link(); |
|
| 1376 | 1379 | const unsigned cursorPosition = cursor.position(); |
| 1377 | 1380 | |
| 1378 | 1381 | AST::Node *node = semanticInfo.nodeUnderCursor(cursorPosition); |
| |   |
| 121 | 121 | public: |
| 122 | 122 | SemanticInfo() {} |
| 123 | 123 | |
| bool isValid() const; |
| 124 | 125 | int revision() const; |
| 125 | 126 | |
| 126 | 127 | // Returns the declaring member |
| |   |
| 110 | 110 | |
| 111 | 111 | if (!matchDiagnosticMessage(qmlEditor, pos)) { |
| 112 | 112 | const SemanticInfo &semanticInfo = qmlEditor->semanticInfo(); |
| if (semanticInfo.revision() != qmlEditor->editorRevision()) |
| if (! semanticInfo.isValid() || semanticInfo.revision() != qmlEditor->editorRevision()) |
| 114 | 114 | return; |
| 115 | 115 | |
| 116 | 116 | QList<AST::Node *> astPath = semanticInfo.astPath(pos); |
| |   |
| 80 | 80 | |
| 81 | 81 | void ModelManager::loadQmlTypeDescriptions() |
| 82 | 82 | { |
| const QString resourcePath = Core::ICore::instance()->resourcePath(); |
| loadQmlTypeDescriptions(Core::ICore::instance()->resourcePath()); |
| loadQmlTypeDescriptions(Core::ICore::instance()->userResourcePath()); |
| } |
|
| void ModelManager::loadQmlTypeDescriptions(const QString &resourcePath) |
| { |
| 84 | 89 | const QDir typeFileDir(resourcePath + QLatin1String("/qml-type-descriptions")); |
| 85 | 90 | const QStringList xmlExtensions = QStringList() << QLatin1String("*.xml"); |
| 86 | 91 | const QFileInfoList xmlFiles = typeFileDir.entryInfoList(xmlExtensions, |
| |   |
| 101 | 101 | bool emitDocChangedOnDisk); |
| 102 | 102 | |
| 103 | 103 | void loadQmlTypeDescriptions(); |
| void loadQmlTypeDescriptions(const QString &path); |
| 104 | 105 | |
| 105 | 106 | void updateImportPaths(); |
| 106 | 107 | |
| |   |
| 136 | 136 | if (QmlJSTextEditor *qmljsEditor = qobject_cast<QmlJSTextEditor *>(editor)) { |
| 137 | 137 | const SemanticInfo info = qmljsEditor->semanticInfo(); |
| 138 | 138 | |
| if (qmljsEditor->isOutdated()) { |
| if (! info.isValid() || qmljsEditor->isOutdated()) { |
| 140 | 140 | // outdated |
| 141 | 141 | qWarning() << "TODO: outdated semantic info, force a reparse."; |
| 142 | 142 | return 0; |
| |   |
| 330 | 330 | void QmlOutlineModel::update(const SemanticInfo &semanticInfo) |
| 331 | 331 | { |
| 332 | 332 | m_semanticInfo = semanticInfo; |
| if (! m_semanticInfo.isValid()) |
| return; |
| 333 | 335 | |
| 334 | 336 | m_treePos.clear(); |
| 335 | 337 | m_treePos.append(0); |