Renamed classes and files to use the QmlJS prefix.

This commit is contained in:
Roberto Raggi
2010-01-18 16:15:23 +01:00
parent 7024c1e1a8
commit c943d8e4f1
57 changed files with 1888 additions and 589 deletions

View File

@@ -34,7 +34,7 @@
#include "qmllookupcontext.h"
#include "qmlresolveexpression.h"
#include <qmljs/qmlsymbol.h>
#include <qmljs/qmljssymbol.h>
#include <texteditor/basetexteditor.h>
#include <QtDebug>
@@ -42,7 +42,7 @@
using namespace QmlJSEditor;
using namespace QmlJSEditor::Internal;
QmlCodeCompletion::QmlCodeCompletion(QmlModelManagerInterface *modelManager, Qml::QmlTypeSystem *typeSystem, QObject *parent)
QmlCodeCompletion::QmlCodeCompletion(QmlModelManagerInterface *modelManager, QmlJS::TypeSystem *typeSystem, QObject *parent)
: TextEditor::ICompletionCollector(parent),
m_modelManager(modelManager),
m_editor(0),
@@ -90,7 +90,7 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
m_startPosition = pos;
m_completions.clear();
Qml::QmlDocument::Ptr qmlDocument = edit->qmlDocument();
QmlJS::Document::Ptr qmlDocument = edit->qmlDocument();
// qDebug() << "*** document:" << qmlDocument;
if (qmlDocument.isNull())
return pos;
@@ -112,10 +112,10 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
QmlLookupContext context(expressionUnderCursor.expressionScopes(), qmlDocument, m_modelManager->snapshot(), m_typeSystem);
QmlResolveExpression resolver(context);
// qDebug()<<"*** expression under cursor:"<<expressionUnderCursor.expressionNode();
QList<Qml::QmlSymbol*> symbols = resolver.visibleSymbols(expressionUnderCursor.expressionNode());
QList<QmlJS::Symbol*> symbols = resolver.visibleSymbols(expressionUnderCursor.expressionNode());
// qDebug()<<"***"<<symbols.size()<<"visible symbols";
foreach (Qml::QmlSymbol *symbol, symbols) {
foreach (QmlJS::Symbol *symbol, symbols) {
QString word;
if (symbol->isIdSymbol()) {

View File

@@ -30,7 +30,7 @@
#ifndef QMLCODECOMPLETION_H
#define QMLCODECOMPLETION_H
#include <qmljs/qmltypesystem.h>
#include <qmljs/qmljstypesystem.h>
#include <texteditor/icompletioncollector.h>
namespace TextEditor {
@@ -48,7 +48,7 @@ class QmlCodeCompletion: public TextEditor::ICompletionCollector
Q_OBJECT
public:
QmlCodeCompletion(QmlModelManagerInterface *modelManager, Qml::QmlTypeSystem *typeSystem, QObject *parent = 0);
QmlCodeCompletion(QmlModelManagerInterface *modelManager, QmlJS::TypeSystem *typeSystem, QObject *parent = 0);
virtual ~QmlCodeCompletion();
Qt::CaseSensitivity caseSensitivity() const;
@@ -68,7 +68,7 @@ private:
int m_startPosition;
QList<TextEditor::CompletionItem> m_completions;
Qt::CaseSensitivity m_caseSensitivity;
Qml::QmlTypeSystem *m_typeSystem;
QmlJS::TypeSystem *m_typeSystem;
};

View File

@@ -38,7 +38,6 @@
#include <QDebug>
using namespace Qml;
using namespace QmlJS;
using namespace QmlJS::AST;
@@ -124,7 +123,7 @@ namespace QmlJSEditor {
class ScopeCalculator: protected Visitor
{
public:
QStack<QmlSymbol*> operator()(const QmlDocument::Ptr &doc, int pos)
QStack<Symbol*> operator()(const Document::Ptr &doc, int pos)
{
_doc = doc;
_pos = pos;
@@ -179,7 +178,7 @@ namespace QmlJSEditor {
private:
void push(Node *node)
{
QmlSymbolFromFile* symbol;
SymbolFromFile* symbol;
if (_currentSymbol) {
symbol = _currentSymbol->findMember(node);
@@ -196,10 +195,10 @@ namespace QmlJSEditor {
}
private:
QmlDocument::Ptr _doc;
Document::Ptr _doc;
quint32 _pos;
QStack<QmlSymbol*> _scopes;
QmlSymbolFromFile* _currentSymbol;
QStack<Symbol*> _scopes;
SymbolFromFile* _currentSymbol;
};
}
}
@@ -220,7 +219,7 @@ QmlExpressionUnderCursor::~QmlExpressionUnderCursor()
}
void QmlExpressionUnderCursor::operator()(const QTextCursor &cursor,
const QmlDocument::Ptr &doc)
const Document::Ptr &doc)
{
if (_engine) { delete _engine; _engine = 0; }
if (_nodePool) { delete _nodePool; _nodePool = 0; }

View File

@@ -31,8 +31,8 @@
#define QMLEXPRESSIONUNDERCURSOR_H
#include <qmljs/parser/qmljsastfwd_p.h>
#include <qmljs/qmldocument.h>
#include <qmljs/qmlsymbol.h>
#include <qmljs/qmljsdocument.h>
#include <qmljs/qmljssymbol.h>
#include <QStack>
#include <QTextBlock>
@@ -52,9 +52,9 @@ public:
QmlExpressionUnderCursor();
virtual ~QmlExpressionUnderCursor();
void operator()(const QTextCursor &cursor, const Qml::QmlDocument::Ptr &doc);
void operator()(const QTextCursor &cursor, const QmlJS::Document::Ptr &doc);
QStack<Qml::QmlSymbol *> expressionScopes() const
QStack<QmlJS::Symbol *> expressionScopes() const
{ return _expressionScopes; }
QmlJS::AST::Node *expressionNode() const
@@ -73,7 +73,7 @@ private:
QmlJS::AST::UiObjectMember *tryBinding(const QString &text);
private:
QStack<Qml::QmlSymbol *> _expressionScopes;
QStack<QmlJS::Symbol *> _expressionScopes;
QmlJS::AST::Node *_expressionNode;
int _expressionOffset;
int _expressionLength;

View File

@@ -30,7 +30,7 @@
#ifndef QMLSYNTAXHIGHLIGHTER_H
#define QMLSYNTAXHIGHLIGHTER_H
#include <qmljs/qscripthighlighter.h>
#include <qmljs/qmljshighlighter.h>
#include <texteditor/basetexteditor.h>
namespace QmlJSEditor {

View File

@@ -38,7 +38,7 @@
#include <coreplugin/editormanager/editormanager.h>
#include <debugger/debuggerconstants.h>
#include <extensionsystem/pluginmanager.h>
#include <qmljs/qmlsymbol.h>
#include <qmljs/qmljssymbol.h>
#include <texteditor/itexteditor.h>
#include <texteditor/basetexteditor.h>
@@ -52,7 +52,7 @@
#include <QtHelp/QHelpEngineCore>
using namespace Core;
using namespace Qml;
using namespace QmlJS;
using namespace QmlJSEditor;
using namespace QmlJSEditor::Internal;
@@ -128,7 +128,7 @@ void QmlHoverHandler::updateContextHelpId(TextEditor::ITextEditor *editor, int p
updateHelpIdAndTooltip(editor, pos);
}
static QString buildHelpId(QmlSymbol *symbol)
static QString buildHelpId(Symbol *symbol)
{
if (!symbol)
return QString();
@@ -152,7 +152,7 @@ void QmlHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
const Snapshot documents = m_modelManager->snapshot();
const QString fileName = editor->file()->fileName();
QmlDocument::Ptr doc = documents.value(fileName);
Document::Ptr doc = documents.value(fileName);
if (!doc)
return; // nothing to do
@@ -188,18 +188,18 @@ void QmlHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
QmlExpressionUnderCursor expressionUnderCursor;
expressionUnderCursor(tc, doc);
Qml::QmlTypeSystem *typeSystem = ExtensionSystem::PluginManager::instance()->getObject<Qml::QmlTypeSystem>();
QmlJS::TypeSystem *typeSystem = ExtensionSystem::PluginManager::instance()->getObject<QmlJS::TypeSystem>();
QmlLookupContext context(expressionUnderCursor.expressionScopes(), doc, m_modelManager->snapshot(), typeSystem);
QmlResolveExpression resolver(context);
QmlSymbol *resolvedSymbol = resolver.typeOf(expressionUnderCursor.expressionNode());
Symbol *resolvedSymbol = resolver.typeOf(expressionUnderCursor.expressionNode());
if (resolvedSymbol) {
symbolName = resolvedSymbol->name();
if (resolvedSymbol->isBuildInSymbol())
m_helpId = buildHelpId(resolvedSymbol);
else if (QmlSymbolFromFile *symbolFromFile = resolvedSymbol->asSymbolFromFile())
else if (SymbolFromFile *symbolFromFile = resolvedSymbol->asSymbolFromFile())
m_toolTip = symbolFromFile->fileName();
}
}

View File

@@ -37,14 +37,14 @@
#include "qmllookupcontext.h"
#include "qmlresolveexpression.h"
#include <qmljs/qscriptindenter.h>
#include <qmljs/qmljsindenter.h>
#include <qmljs/qmltypesystem.h>
#include <qmljs/qmljstypesystem.h>
#include <qmljs/parser/qmljsastvisitor_p.h>
#include <qmljs/parser/qmljsast_p.h>
#include <qmljs/parser/qmljsengine_p.h>
#include <qmljs/qmldocument.h>
#include <qmljs/qmlidcollector.h>
#include <qmljs/qmljsdocument.h>
#include <qmljs/qmljsidcollector.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/icore.h>
@@ -74,7 +74,6 @@ enum {
UPDATE_USES_DEFAULT_INTERVAL = 150
};
using namespace Qml;
using namespace QmlJS;
using namespace QmlJS::AST;
@@ -359,11 +358,11 @@ QmlJSTextEditor::QmlJSTextEditor(QWidget *parent) :
baseTextDocument()->setSyntaxHighlighter(new QmlHighlighter);
m_modelManager = ExtensionSystem::PluginManager::instance()->getObject<QmlModelManagerInterface>();
m_typeSystem = ExtensionSystem::PluginManager::instance()->getObject<Qml::QmlTypeSystem>();
m_typeSystem = ExtensionSystem::PluginManager::instance()->getObject<QmlJS::TypeSystem>();
if (m_modelManager) {
connect(m_modelManager, SIGNAL(documentUpdated(Qml::QmlDocument::Ptr)),
this, SLOT(onDocumentUpdated(Qml::QmlDocument::Ptr)));
connect(m_modelManager, SIGNAL(documentUpdated(QmlJS::Document::Ptr)),
this, SLOT(onDocumentUpdated(QmlJS::Document::Ptr)));
}
}
@@ -415,7 +414,7 @@ void QmlJSTextEditor::updateDocumentNow()
m_modelManager->updateSourceFiles(QStringList() << fileName);
}
void QmlJSTextEditor::onDocumentUpdated(Qml::QmlDocument::Ptr doc)
void QmlJSTextEditor::onDocumentUpdated(QmlJS::Document::Ptr doc)
{
if (file()->fileName() != doc->fileName())
return;
@@ -617,13 +616,13 @@ bool QmlJSTextEditor::isElectricCharacter(const QChar &ch) const
return false;
}
bool QmlJSTextEditor::isClosingBrace(const QList<QScriptIncrementalScanner::Token> &tokens) const
bool QmlJSTextEditor::isClosingBrace(const QList<QmlJSScanner::Token> &tokens) const
{
if (tokens.size() == 1) {
const QScriptIncrementalScanner::Token firstToken = tokens.first();
const QmlJSScanner::Token firstToken = tokens.first();
return firstToken.is(QScriptIncrementalScanner::Token::RightBrace) || firstToken.is(QScriptIncrementalScanner::Token::RightBracket);
return firstToken.is(QmlJSScanner::Token::RightBrace) || firstToken.is(QmlJSScanner::Token::RightBracket);
}
return false;
@@ -632,7 +631,7 @@ bool QmlJSTextEditor::isClosingBrace(const QList<QScriptIncrementalScanner::Toke
void QmlJSTextEditor::indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar)
{
TextEditor::TabSettings ts = tabSettings();
QScriptIndenter indenter;
QmlJSIndenter indenter;
indenter.setTabSize(ts.m_tabSize);
indenter.setIndentSize(ts.m_indentSize);
@@ -678,7 +677,7 @@ TextEditor::BaseTextEditor::Link QmlJSTextEditor::findLinkAt(const QTextCursor &
return link;
const Snapshot snapshot = m_modelManager->snapshot();
QmlDocument::Ptr doc = snapshot.document(file()->fileName());
Document::Ptr doc = snapshot.document(file()->fileName());
if (!doc)
return link;
@@ -702,12 +701,12 @@ TextEditor::BaseTextEditor::Link QmlJSTextEditor::findLinkAt(const QTextCursor &
QmlLookupContext context(expressionUnderCursor.expressionScopes(), doc, snapshot, m_typeSystem);
QmlResolveExpression resolver(context);
QmlSymbol *symbol = resolver.typeOf(expressionUnderCursor.expressionNode());
Symbol *symbol = resolver.typeOf(expressionUnderCursor.expressionNode());
if (!symbol)
return link;
if (const QmlSymbolFromFile *target = symbol->asSymbolFromFile()) {
if (const SymbolFromFile *target = symbol->asSymbolFromFile()) {
link.pos = expressionUnderCursor.expressionOffset();
link.length = expressionUnderCursor.expressionLength();
link.fileName = target->fileName();
@@ -794,32 +793,32 @@ bool QmlJSTextEditor::contextAllowsAutoParentheses(const QTextCursor &cursor, co
const QString blockText = cursor.block().text();
const int blockState = blockStartState(cursor.block());
QScriptIncrementalScanner tokenize;
const QList<QScriptIncrementalScanner::Token> tokens = tokenize(blockText, blockState);
QmlJSScanner tokenize;
const QList<QmlJSScanner::Token> tokens = tokenize(blockText, blockState);
const int pos = cursor.columnNumber();
int tokenIndex = 0;
for (; tokenIndex < tokens.size(); ++tokenIndex) {
const QScriptIncrementalScanner::Token &token = tokens.at(tokenIndex);
const QmlJSScanner::Token &token = tokens.at(tokenIndex);
if (pos >= token.begin()) {
if (pos < token.end())
break;
else if (pos == token.end() && (token.is(QScriptIncrementalScanner::Token::Comment) ||
token.is(QScriptIncrementalScanner::Token::String)))
else if (pos == token.end() && (token.is(QmlJSScanner::Token::Comment) ||
token.is(QmlJSScanner::Token::String)))
break;
}
}
if (tokenIndex != tokens.size()) {
const QScriptIncrementalScanner::Token &token = tokens.at(tokenIndex);
const QmlJSScanner::Token &token = tokens.at(tokenIndex);
switch (token.kind) {
case QScriptIncrementalScanner::Token::Comment:
case QmlJSScanner::Token::Comment:
return false;
case QScriptIncrementalScanner::Token::String: {
case QmlJSScanner::Token::String: {
const QStringRef tokenText = blockText.midRef(token.offset, token.length);
const QChar quote = tokenText.at(0);

View File

@@ -30,8 +30,8 @@
#ifndef QMLJSEDITOR_H
#define QMLJSEDITOR_H
#include <qmljs/qmldocument.h>
#include <qmljs/qscriptincrementalscanner.h>
#include <qmljs/qmljsdocument.h>
#include <qmljs/qmljsscanner.h>
#include <texteditor/basetexteditor.h>
QT_BEGIN_NAMESPACE
@@ -43,8 +43,8 @@ namespace Core {
class ICore;
}
namespace Qml {
class QmlTypeSystem;
namespace QmlJS {
class TypeSystem;
}
namespace QmlJSEditor {
@@ -109,13 +109,13 @@ public:
virtual void unCommentSelection();
Qml::QmlDocument::Ptr qmlDocument() const { return m_document; }
QmlJS::Document::Ptr qmlDocument() const { return m_document; }
public slots:
virtual void setFontSettings(const TextEditor::FontSettings &);
private slots:
void onDocumentUpdated(Qml::QmlDocument::Ptr doc);
void onDocumentUpdated(QmlJS::Document::Ptr doc);
void updateDocument();
void updateDocumentNow();
@@ -145,7 +145,7 @@ protected:
private:
virtual bool isElectricCharacter(const QChar &ch) const;
virtual void indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar);
bool isClosingBrace(const QList<QmlJS::QScriptIncrementalScanner::Token> &tokens) const;
bool isClosingBrace(const QList<QmlJS::QmlJSScanner::Token> &tokens) const;
QString wordUnderCursor() const;
@@ -158,9 +158,9 @@ private:
QMap<QString, QList<QmlJS::AST::SourceLocation> > m_ids; // ### use QMultiMap
int m_idsRevision;
QList<QmlJS::DiagnosticMessage> m_diagnosticMessages;
Qml::QmlDocument::Ptr m_document;
QmlJS::Document::Ptr m_document;
QmlModelManagerInterface *m_modelManager;
Qml::QmlTypeSystem *m_typeSystem;
QmlJS::TypeSystem *m_typeSystem;
QTextCharFormat m_occurrencesFormat;
};

View File

@@ -92,7 +92,7 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e
m_modelManager = new QmlModelManager(this);
addAutoReleasedObject(m_modelManager);
Qml::QmlTypeSystem *typeSystem = new Qml::QmlTypeSystem;
QmlJS::TypeSystem *typeSystem = new QmlJS::TypeSystem;
addAutoReleasedObject(typeSystem);
QList<int> context;

View File

@@ -33,20 +33,19 @@
#include <qmljs/parser/qmljsast_p.h>
#include <qmljs/parser/qmljsengine_p.h>
#include <qmljs/qmltypesystem.h>
#include <qmljs/qmljstypesystem.h>
#include <QDebug>
using namespace Qml;
using namespace QmlJS;
using namespace QmlJSEditor;
using namespace QmlJSEditor::Internal;
using namespace QmlJS;
using namespace QmlJS::AST;
QmlLookupContext::QmlLookupContext(const QStack<QmlSymbol *> &scopes,
const QmlDocument::Ptr &doc,
QmlLookupContext::QmlLookupContext(const QStack<Symbol *> &scopes,
const Document::Ptr &doc,
const Snapshot &snapshot,
QmlTypeSystem *typeSystem):
TypeSystem *typeSystem):
_scopes(scopes),
_doc(doc),
_snapshot(snapshot),
@@ -55,13 +54,13 @@ QmlLookupContext::QmlLookupContext(const QStack<QmlSymbol *> &scopes,
Q_ASSERT(typeSystem != 0);
}
static inline int findFirstQmlObjectScope(const QStack<QmlSymbol*> &scopes, int startIdx)
static inline int findFirstQmlObjectScope(const QStack<Symbol*> &scopes, int startIdx)
{
if (startIdx < 0 || startIdx >= scopes.size())
return -1;
for (int i = startIdx; i >= 0; --i) {
QmlSymbol *current = scopes.at(i);
Symbol *current = scopes.at(i);
if (current->isSymbolFromFile()) {
Node *node = current->asSymbolFromFile()->node();
@@ -75,7 +74,7 @@ static inline int findFirstQmlObjectScope(const QStack<QmlSymbol*> &scopes, int
return -1;
}
static inline QmlSymbol *resolveParent(const QStack<QmlSymbol*> &scopes)
static inline Symbol *resolveParent(const QStack<Symbol*> &scopes)
{
int idx = findFirstQmlObjectScope(scopes, scopes.size() - 1);
if (idx < 1)
@@ -89,14 +88,14 @@ static inline QmlSymbol *resolveParent(const QStack<QmlSymbol*> &scopes)
return scopes.at(idx);
}
QmlSymbol *QmlLookupContext::resolve(const QString &name)
Symbol *QmlLookupContext::resolve(const QString &name)
{
// find element type names
if (QmlSymbol *type = resolveType(name))
if (Symbol *type = resolveType(name))
return type;
// find ids
const QmlDocument::IdTable ids = _doc->ids();
const Document::IdTable ids = _doc->ids();
if (ids.contains(name))
return ids[name];
@@ -110,12 +109,12 @@ QmlSymbol *QmlLookupContext::resolve(const QString &name)
// find properties of the scope object
int scopeObjectIndex = findFirstQmlObjectScope(_scopes, _scopes.size() - 1);
if (scopeObjectIndex != -1)
if (QmlSymbol *propertySymbol = resolveProperty(name, _scopes.at(scopeObjectIndex), _doc->fileName()))
if (Symbol *propertySymbol = resolveProperty(name, _scopes.at(scopeObjectIndex), _doc->fileName()))
return propertySymbol;
// find properties of the component's root object
if (!_doc->symbols().isEmpty())
if (QmlSymbol *propertySymbol = resolveProperty(name, _doc->symbols()[0], _doc->fileName()))
if (Symbol *propertySymbol = resolveProperty(name, _doc->symbols()[0], _doc->fileName()))
return propertySymbol;
// component chain
@@ -130,10 +129,10 @@ QmlSymbol *QmlLookupContext::resolve(const QString &name)
return 0;
}
QmlSymbol *QmlLookupContext::resolveType(const QString &name, const QString &fileName)
Symbol *QmlLookupContext::resolveType(const QString &name, const QString &fileName)
{
// TODO: handle import-as.
QmlDocument::Ptr document = _snapshot[fileName];
Document::Ptr document = _snapshot[fileName];
if (document.isNull())
return 0;
@@ -157,9 +156,9 @@ QmlSymbol *QmlLookupContext::resolveType(const QString &name, const QString &fil
const QString path = import->fileName->asString();
const QMap<QString, QmlDocument::Ptr> importedTypes = _snapshot.componentsDefinedByImportedDocuments(document, path);
const QMap<QString, Document::Ptr> importedTypes = _snapshot.componentsDefinedByImportedDocuments(document, path);
if (importedTypes.contains(name)) {
QmlDocument::Ptr importedDoc = importedTypes.value(name);
Document::Ptr importedDoc = importedTypes.value(name);
return importedDoc->symbols().at(0);
}
@@ -169,17 +168,17 @@ QmlSymbol *QmlLookupContext::resolveType(const QString &name, const QString &fil
return resolveBuildinType(name);
}
QmlSymbol *QmlLookupContext::resolveBuildinType(const QString &name)
Symbol *QmlLookupContext::resolveBuildinType(const QString &name)
{
QList<Qml::PackageInfo> packages;
QList<QmlJS::PackageInfo> packages;
// FIXME:
packages.append(PackageInfo("Qt", 4, 6));
return m_typeSystem->resolve(name, packages);
}
QmlSymbol *QmlLookupContext::resolveProperty(const QString &name, QmlSymbol *scope, const QString &fileName)
Symbol *QmlLookupContext::resolveProperty(const QString &name, Symbol *scope, const QString &fileName)
{
foreach (QmlSymbol *symbol, scope->members())
foreach (Symbol *symbol, scope->members())
if (symbol->isProperty() && symbol->name() == name)
return symbol;
@@ -198,14 +197,14 @@ QmlSymbol *QmlLookupContext::resolveProperty(const QString &name, QmlSymbol *sco
if (typeName == 0)
return 0;
QmlSymbol *typeSymbol = resolveType(toString(typeName), fileName);
Symbol *typeSymbol = resolveType(toString(typeName), fileName);
if (!typeSymbol)
return 0;
if (typeSymbol->isSymbolFromFile()) {
return resolveProperty(name, typeSymbol->asSymbolFromFile(), typeSymbol->asSymbolFromFile()->fileName());
} else if (QmlBuildInSymbol *builtinSymbol = typeSymbol->asBuildInSymbol()) {
foreach (QmlSymbol *member, builtinSymbol->members(true)) {
} else if (PrimitiveSymbol *builtinSymbol = typeSymbol->asPrimitiveSymbol()) {
foreach (Symbol *member, builtinSymbol->members(true)) {
if (member->isProperty() && member->name() == name)
return member;
}
@@ -231,12 +230,12 @@ QString QmlLookupContext::toString(UiQualifiedId *id)
return str;
}
QList<QmlSymbol*> QmlLookupContext::visibleSymbolsInScope()
QList<Symbol*> QmlLookupContext::visibleSymbolsInScope()
{
QList<QmlSymbol*> result;
QList<Symbol*> result;
if (!_scopes.isEmpty()) {
QmlSymbol *scope = _scopes.top();
Symbol *scope = _scopes.top();
// add members defined in this symbol:
result.append(scope->members());
@@ -248,9 +247,9 @@ QList<QmlSymbol*> QmlLookupContext::visibleSymbolsInScope()
return result;
}
QList<QmlSymbol*> QmlLookupContext::visibleTypes()
QList<Symbol*> QmlLookupContext::visibleTypes()
{
QList<QmlSymbol*> result;
QList<Symbol*> result;
UiProgram *program = _doc->qmlProgram();
if (!program)
@@ -267,8 +266,8 @@ QList<QmlSymbol*> QmlLookupContext::visibleTypes()
// TODO: handle "import as".
const QMap<QString, QmlDocument::Ptr> types = _snapshot.componentsDefinedByImportedDocuments(_doc, path);
foreach (const QmlDocument::Ptr typeDoc, types) {
const QMap<QString, Document::Ptr> types = _snapshot.componentsDefinedByImportedDocuments(_doc, path);
foreach (const Document::Ptr typeDoc, types) {
result.append(typeDoc->symbols().at(0));
}
}
@@ -278,22 +277,22 @@ QList<QmlSymbol*> QmlLookupContext::visibleTypes()
return result;
}
QList<QmlSymbol*> QmlLookupContext::expandType(Qml::QmlSymbol *symbol)
QList<Symbol*> QmlLookupContext::expandType(QmlJS::Symbol *symbol)
{
if (symbol == 0) {
return QList<QmlSymbol*>();
} else if (QmlBuildInSymbol *buildInSymbol = symbol->asBuildInSymbol()) {
return QList<Symbol*>();
} else if (PrimitiveSymbol *buildInSymbol = symbol->asPrimitiveSymbol()) {
return buildInSymbol->members(true);
} else if (QmlSymbolFromFile *symbolFromFile = symbol->asSymbolFromFile()){
QList<QmlSymbol*> result;
} else if (SymbolFromFile *symbolFromFile = symbol->asSymbolFromFile()){
QList<Symbol*> result;
if (QmlSymbol *superTypeSymbol = resolveType(symbolFromFile->name(), symbolFromFile->fileName())) {
if (Symbol *superTypeSymbol = resolveType(symbolFromFile->name(), symbolFromFile->fileName())) {
result.append(superTypeSymbol->members());
result.append(expandType(superTypeSymbol));
}
return result;
} else {
return QList<QmlSymbol*>();
return QList<Symbol*>();
}
}

View File

@@ -30,10 +30,10 @@
#ifndef QMLLOOKUPCONTEXT_H
#define QMLLOOKUPCONTEXT_H
#include <qmljs/qmltypesystem.h>
#include <qmljs/qmljstypesystem.h>
#include <qmljs/parser/qmljsastvisitor_p.h>
#include <qmljs/qmldocument.h>
#include <qmljs/qmlsymbol.h>
#include <qmljs/qmljsdocument.h>
#include <qmljs/qmljssymbol.h>
#include <QStack>
@@ -43,37 +43,37 @@ namespace Internal {
class QmlLookupContext
{
public:
QmlLookupContext(const QStack<Qml::QmlSymbol *> &scopes,
const Qml::QmlDocument::Ptr &doc,
const Qml::Snapshot &snapshot,
Qml::QmlTypeSystem *typeSystem);
QmlLookupContext(const QStack<QmlJS::Symbol *> &scopes,
const QmlJS::Document::Ptr &doc,
const QmlJS::Snapshot &snapshot,
QmlJS::TypeSystem *typeSystem);
Qml::QmlSymbol *resolve(const QString &name);
Qml::QmlSymbol *resolveType(const QString &name)
QmlJS::Symbol *resolve(const QString &name);
QmlJS::Symbol *resolveType(const QString &name)
{ return resolveType(name, _doc->fileName()); }
Qml::QmlSymbol *resolveType(QmlJS::AST::UiQualifiedId *name)
QmlJS::Symbol *resolveType(QmlJS::AST::UiQualifiedId *name)
{ return resolveType(toString(name), _doc->fileName()); }
Qml::QmlDocument::Ptr document() const
QmlJS::Document::Ptr document() const
{ return _doc; }
QList<Qml::QmlSymbol*> visibleSymbolsInScope();
QList<Qml::QmlSymbol*> visibleTypes();
QList<QmlJS::Symbol*> visibleSymbolsInScope();
QList<QmlJS::Symbol*> visibleTypes();
QList<Qml::QmlSymbol*> expandType(Qml::QmlSymbol *symbol);
QList<QmlJS::Symbol*> expandType(QmlJS::Symbol *symbol);
private:
Qml::QmlSymbol *resolveType(const QString &name, const QString &fileName);
Qml::QmlSymbol *resolveProperty(const QString &name, Qml::QmlSymbol *scope, const QString &fileName);
Qml::QmlSymbol *resolveBuildinType(const QString &name);
QmlJS::Symbol *resolveType(const QString &name, const QString &fileName);
QmlJS::Symbol *resolveProperty(const QString &name, QmlJS::Symbol *scope, const QString &fileName);
QmlJS::Symbol *resolveBuildinType(const QString &name);
static QString toString(QmlJS::AST::UiQualifiedId *id);
private:
QStack<Qml::QmlSymbol *> _scopes;
Qml::QmlDocument::Ptr _doc;
Qml::Snapshot _snapshot;
Qml::QmlTypeSystem *m_typeSystem;
QStack<QmlJS::Symbol *> _scopes;
QmlJS::Document::Ptr _doc;
QmlJS::Snapshot _snapshot;
QmlJS::TypeSystem *m_typeSystem;
};
} // namespace Internal

View File

@@ -51,13 +51,13 @@ QmlModelManager::QmlModelManager(QObject *parent):
{
m_synchronizer.setCancelOnWait(true);
qRegisterMetaType<Qml::QmlDocument::Ptr>("Qml::QmlDocument::Ptr");
qRegisterMetaType<QmlJS::Document::Ptr>("QmlJS::Document::Ptr");
connect(this, SIGNAL(documentUpdated(Qml::QmlDocument::Ptr)),
this, SLOT(onDocumentUpdated(Qml::QmlDocument::Ptr)));
connect(this, SIGNAL(documentUpdated(QmlJS::Document::Ptr)),
this, SLOT(onDocumentUpdated(QmlJS::Document::Ptr)));
}
Qml::Snapshot QmlModelManager::snapshot() const
QmlJS::Snapshot QmlModelManager::snapshot() const
{
QMutexLocker locker(&m_mutex);
@@ -118,10 +118,10 @@ QMap<QString, QString> QmlModelManager::buildWorkingCopyList()
return workingCopy;
}
void QmlModelManager::emitDocumentUpdated(Qml::QmlDocument::Ptr doc)
void QmlModelManager::emitDocumentUpdated(QmlJS::Document::Ptr doc)
{ emit documentUpdated(doc); }
void QmlModelManager::onDocumentUpdated(Qml::QmlDocument::Ptr doc)
void QmlModelManager::onDocumentUpdated(QmlJS::Document::Ptr doc)
{
QMutexLocker locker(&m_mutex);
@@ -153,7 +153,7 @@ void QmlModelManager::parse(QFutureInterface<void> &future,
}
}
Qml::QmlDocument::Ptr doc = Qml::QmlDocument::create(fileName);
QmlJS::Document::Ptr doc = QmlJS::Document::create(fileName);
doc->setSource(contents);
{

View File

@@ -32,7 +32,7 @@
#include "qmlmodelmanagerinterface.h"
#include <qmljs/qmldocument.h>
#include <qmljs/qmljsdocument.h>
#include <QFuture>
#include <QFutureSynchronizer>
@@ -52,10 +52,10 @@ class QmlModelManager: public QmlModelManagerInterface
public:
QmlModelManager(QObject *parent = 0);
virtual Qml::Snapshot snapshot() const;
virtual QmlJS::Snapshot snapshot() const;
virtual void updateSourceFiles(const QStringList &files);
void emitDocumentUpdated(Qml::QmlDocument::Ptr doc);
void emitDocumentUpdated(QmlJS::Document::Ptr doc);
Q_SIGNALS:
void projectPathChanged(const QString &projectPath);
@@ -63,7 +63,7 @@ Q_SIGNALS:
private Q_SLOTS:
// this should be executed in the GUI thread.
void onDocumentUpdated(Qml::QmlDocument::Ptr doc);
void onDocumentUpdated(QmlJS::Document::Ptr doc);
protected:
QFuture<void> refreshSourceFiles(const QStringList &sourceFiles);
@@ -77,7 +77,7 @@ protected:
private:
mutable QMutex m_mutex;
Core::ICore *m_core;
Qml::Snapshot _snapshot;
QmlJS::Snapshot _snapshot;
QFutureSynchronizer<void> m_synchronizer;
};

View File

@@ -32,14 +32,14 @@
#include "qmljseditor_global.h"
#include <qmljs/qmldocument.h>
#include <qmljs/qmltypesystem.h>
#include <qmljs/qmljsdocument.h>
#include <qmljs/qmljstypesystem.h>
#include <QObject>
#include <QStringList>
#include <QSharedPointer>
namespace Qml {
namespace QmlJS {
class Snapshot;
}
@@ -53,11 +53,11 @@ public:
QmlModelManagerInterface(QObject *parent = 0);
virtual ~QmlModelManagerInterface();
virtual Qml::Snapshot snapshot() const = 0;
virtual QmlJS::Snapshot snapshot() const = 0;
virtual void updateSourceFiles(const QStringList &files) = 0;
signals:
void documentUpdated(Qml::QmlDocument::Ptr doc);
void documentUpdated(QmlJS::Document::Ptr doc);
};
} // namespace QmlJSEditor

View File

@@ -32,7 +32,6 @@
#include <qmljs/parser/qmljsast_p.h>
#include <qmljs/parser/qmljsengine_p.h>
using namespace Qml;
using namespace QmlJSEditor;
using namespace QmlJSEditor::Internal;
using namespace QmlJS;
@@ -43,18 +42,18 @@ QmlResolveExpression::QmlResolveExpression(const QmlLookupContext &context)
{
}
QmlSymbol *QmlResolveExpression::typeOf(Node *node)
Symbol *QmlResolveExpression::typeOf(Node *node)
{
QmlSymbol *previousValue = switchValue(0);
Symbol *previousValue = switchValue(0);
Node::accept(node, this);
return switchValue(previousValue);
}
QList<QmlSymbol*> QmlResolveExpression::visibleSymbols(Node *node)
QList<Symbol*> QmlResolveExpression::visibleSymbols(Node *node)
{
QList<QmlSymbol*> result;
QList<Symbol*> result;
QmlSymbol *symbol = typeOf(node);
Symbol *symbol = typeOf(node);
if (symbol) {
if (symbol->isIdSymbol())
symbol = symbol->asIdSymbol()->parentNode();
@@ -66,7 +65,7 @@ QList<QmlSymbol*> QmlResolveExpression::visibleSymbols(Node *node)
}
if (node) {
foreach (QmlIdSymbol *idSymbol, _context.document()->ids().values())
foreach (IdSymbol *idSymbol, _context.document()->ids().values())
result.append(idSymbol);
}
@@ -75,9 +74,9 @@ QList<QmlSymbol*> QmlResolveExpression::visibleSymbols(Node *node)
return result;
}
QmlSymbol *QmlResolveExpression::switchValue(QmlSymbol *value)
Symbol *QmlResolveExpression::switchValue(Symbol *value)
{
QmlSymbol *previousValue = _value;
Symbol *previousValue = _value;
_value = value;
return previousValue;
}
@@ -107,7 +106,7 @@ bool QmlResolveExpression::visit(FieldMemberExpression *ast)
{
const QString memberName = ast->name->asString();
QmlSymbol *base = typeOf(ast->base);
Symbol *base = typeOf(ast->base);
if (!base)
return false;
@@ -117,7 +116,7 @@ bool QmlResolveExpression::visit(FieldMemberExpression *ast)
if (!base)
return false;
foreach (QmlSymbol *memberSymbol, base->members())
foreach (Symbol *memberSymbol, base->members())
if (memberSymbol->name() == memberName)
_value = memberSymbol;

View File

@@ -33,7 +33,7 @@
#include "qmllookupcontext.h"
#include <qmljs/parser/qmljsastvisitor_p.h>
#include <qmljs/qmlsymbol.h>
#include <qmljs/qmljssymbol.h>
namespace QmlJSEditor {
namespace Internal {
@@ -43,13 +43,13 @@ class QmlResolveExpression: protected QmlJS::AST::Visitor
public:
QmlResolveExpression(const QmlLookupContext &context);
Qml::QmlSymbol *typeOf(QmlJS::AST::Node *node);
QList<Qml::QmlSymbol*> visibleSymbols(QmlJS::AST::Node *node);
QmlJS::Symbol *typeOf(QmlJS::AST::Node *node);
QList<QmlJS::Symbol*> visibleSymbols(QmlJS::AST::Node *node);
protected:
using QmlJS::AST::Visitor::visit;
Qml::QmlSymbol *switchValue(Qml::QmlSymbol *symbol);
QmlJS::Symbol *switchValue(QmlJS::Symbol *symbol);
virtual bool visit(QmlJS::AST::FieldMemberExpression *ast);
virtual bool visit(QmlJS::AST::IdentifierExpression *ast);
@@ -57,7 +57,7 @@ protected:
private:
QmlLookupContext _context;
Qml::QmlSymbol *_value;
QmlJS::Symbol *_value;
};
} // namespace Internal