Introduced SemanticInfo::isValid().

This commit is contained in:
Roberto Raggi
2010-09-08 10:11:44 +02:00
parent cf40fdcccf
commit e33767205b
8 changed files with 30 additions and 6 deletions

View File

@@ -556,6 +556,11 @@ QList<AST::Node *> SemanticInfo::astPath(int cursorPosition) const
LookupContext::Ptr SemanticInfo::lookupContext(const QList<QmlJS::AST::Node *> &path) const
{
Q_ASSERT(! m_context.isNull());
if (m_context.isNull())
return LookupContext::create(document, snapshot, path);
return LookupContext::create(document, snapshot, *m_context, path);
}
@@ -610,6 +615,14 @@ AST::Node *SemanticInfo::nodeUnderCursor(int pos) const
return 0;
}
bool SemanticInfo::isValid() const
{
if (document && m_context)
return true;
return false;
}
int SemanticInfo::revision() const
{
if (document)
@@ -1360,6 +1373,9 @@ void QmlJSTextEditor::createToolBar(QmlJSEditorEditable *editable)
TextEditor::BaseTextEditor::Link QmlJSTextEditor::findLinkAt(const QTextCursor &cursor, bool /*resolveTarget*/)
{
const SemanticInfo semanticInfo = m_semanticInfo;
if (! semanticInfo.isValid())
return Link();
const unsigned cursorPosition = cursor.position();
AST::Node *node = semanticInfo.nodeUnderCursor(cursorPosition);