Merge remote-tracking branch 'origin/3.4'

Change-Id: Ib5ce531102eeef86a34ee78e6990791cf4c910c4
This commit is contained in:
Eike Ziller
2015-02-18 16:35:40 +01:00
116 changed files with 1162 additions and 1254 deletions

View File

@@ -18,6 +18,7 @@ Project {
property pathList additionalLibs: [] property pathList additionalLibs: []
property pathList additionalTools: [] property pathList additionalTools: []
property pathList additionalAutotests: [] property pathList additionalAutotests: []
property string sharedSourcesDir: path + "/src/shared"
property string libDirName: "lib" property string libDirName: "lib"
property string ide_library_path: { property string ide_library_path: {
if (qbs.targetOS.contains("osx")) if (qbs.targetOS.contains("osx"))

View File

@@ -39,9 +39,10 @@ DebugOutputCommand::DebugOutputCommand()
{ {
} }
DebugOutputCommand::DebugOutputCommand(const QString &text, DebugOutputCommand::Type type) DebugOutputCommand::DebugOutputCommand(const QString &text, DebugOutputCommand::Type type, const QVector<qint32> &instanceIds)
: m_text(text), : m_instanceIds(instanceIds)
m_type(type) , m_text(text)
, m_type(type)
{ {
} }
@@ -55,10 +56,16 @@ QString DebugOutputCommand::text() const
return m_text; return m_text;
} }
QVector<qint32> DebugOutputCommand::instanceIds() const
{
return m_instanceIds;
}
QDataStream &operator<<(QDataStream &out, const DebugOutputCommand &command) QDataStream &operator<<(QDataStream &out, const DebugOutputCommand &command)
{ {
out << command.type(); out << command.type();
out << command.text(); out << command.text();
out << command.instanceIds();
return out; return out;
} }
@@ -67,6 +74,7 @@ QDataStream &operator>>(QDataStream &in, DebugOutputCommand &command)
{ {
in >> command.m_type; in >> command.m_type;
in >> command.m_text; in >> command.m_text;
in >> command.m_instanceIds;
return in; return in;
} }

View File

@@ -34,6 +34,7 @@
#include <QMetaType> #include <QMetaType>
#include <QString> #include <QString>
#include <QDataStream> #include <QDataStream>
#include <QVector>
namespace QmlDesigner { namespace QmlDesigner {
@@ -51,12 +52,14 @@ public:
}; };
DebugOutputCommand(); DebugOutputCommand();
explicit DebugOutputCommand(const QString &text, Type type); explicit DebugOutputCommand(const QString &text, Type type, const QVector<qint32> &instanceIds);
qint32 type() const; qint32 type() const;
QString text() const; QString text() const;
QVector<qint32> instanceIds() const;
private: private:
QVector<qint32> m_instanceIds;
QString m_text; QString m_text;
quint32 m_type; quint32 m_type;
}; };

View File

@@ -81,7 +81,7 @@
#include "dummycontextobject.h" #include "dummycontextobject.h"
namespace { namespace {
bool testImportStatements(const QStringList &importStatementList, const QUrl &url, bool enableErrorOutput = false) { bool testImportStatements(const QStringList &importStatementList, const QUrl &url, QString *errorMessage = 0) {
QQmlEngine engine; QQmlEngine engine;
QQmlComponent testImportComponent(&engine); QQmlComponent testImportComponent(&engine);
@@ -93,8 +93,10 @@ namespace {
if (testImportComponent.errors().isEmpty()) { if (testImportComponent.errors().isEmpty()) {
return true; return true;
} else { } else {
if (enableErrorOutput) if (errorMessage) {
qWarning() << "found not working imports: " << testImportComponent.errorString(); errorMessage->append("found not working imports: ");
errorMessage->append(testImportComponent.errorString());
}
return false; return false;
} }
} }
@@ -367,7 +369,7 @@ void NodeInstanceServer::removeSharedMemory(const RemoveSharedMemoryCommand &/*c
{ {
} }
void NodeInstanceServer::setupImports(const QVector<AddImportContainer> &containerVector) void NodeInstanceServer::setupImports(const QVector<AddImportContainer> &containerVector, const QVector<IdContainer> &idContainerVector)
{ {
Q_ASSERT(quickView()); Q_ASSERT(quickView());
QSet<QString> importStatementSet; QSet<QString> importStatementSet;
@@ -394,8 +396,7 @@ void NodeInstanceServer::setupImports(const QVector<AddImportContainer> &contain
QStringList workingImportStatementList; QStringList workingImportStatementList;
// check possible import statements combinations // check possible import statements combinations
bool enableErrorOutput(true); QString errorMessage;
// maybe it just works // maybe it just works
if (testImportStatements(importStatementList, fileUrl())) { if (testImportStatements(importStatementList, fileUrl())) {
workingImportStatementList = importStatementList; workingImportStatementList = importStatementList;
@@ -412,13 +413,18 @@ void NodeInstanceServer::setupImports(const QVector<AddImportContainer> &contain
// find the bad imports from otherImportStatements // find the bad imports from otherImportStatements
foreach (const QString &importStatement, otherImportStatements) { foreach (const QString &importStatement, otherImportStatements) {
if (testImportStatements(QStringList(firstWorkingImportStatement) << if (testImportStatements(QStringList(firstWorkingImportStatement) <<
importStatement, fileUrl(), enableErrorOutput)) { importStatement, fileUrl(), &errorMessage)) {
workingImportStatementList.append(importStatement); workingImportStatementList.append(importStatement);
} }
} }
workingImportStatementList.prepend(firstWorkingImportStatement); workingImportStatementList.prepend(firstWorkingImportStatement);
} }
QVector<qint32> instanceIds;
foreach (const IdContainer &idContainer, idContainerVector)
instanceIds.append(idContainer.instanceId());
if (!errorMessage.isEmpty())
sendDebugOutput(DebugOutputCommand::WarningType, errorMessage, instanceIds);
setupOnlyWorkingImports(workingImportStatementList); setupOnlyWorkingImports(workingImportStatementList);
} }
@@ -1198,9 +1204,16 @@ void NodeInstanceServer::loadDummyDataContext(const QString& directory)
} }
} }
void NodeInstanceServer::sendDebugOutput(DebugOutputCommand::Type type, const QString &message) void NodeInstanceServer::sendDebugOutput(DebugOutputCommand::Type type, const QString &message, qint32 instanceId)
{ {
DebugOutputCommand command(message, type); QVector<qint32> ids;
ids.append(instanceId);
sendDebugOutput(type, message, ids);
}
void NodeInstanceServer::sendDebugOutput(DebugOutputCommand::Type type, const QString &message, const QVector<qint32> &instanceIds)
{
DebugOutputCommand command(message, type, instanceIds);
nodeInstanceClient()->debugOutput(command); nodeInstanceClient()->debugOutput(command);
} }

View File

@@ -60,6 +60,7 @@ class ChildrenChangedCommand;
class ReparentContainer; class ReparentContainer;
class ComponentCompletedCommand; class ComponentCompletedCommand;
class AddImportContainer; class AddImportContainer;
class IdContainer;
namespace Internal { namespace Internal {
class ChildrenChangeEventFilter; class ChildrenChangeEventFilter;
@@ -127,7 +128,8 @@ public:
virtual QQmlView *declarativeView() const = 0; virtual QQmlView *declarativeView() const = 0;
virtual QQuickView *quickView() const = 0; virtual QQuickView *quickView() const = 0;
void sendDebugOutput(DebugOutputCommand::Type type, const QString &message); void sendDebugOutput(DebugOutputCommand::Type type, const QString &message, qint32 instanceId);
void sendDebugOutput(DebugOutputCommand::Type type, const QString &message, const QVector<qint32> &instanceIds);
public slots: public slots:
void refreshLocalFileProperty(const QString &path); void refreshLocalFileProperty(const QString &path);
@@ -192,7 +194,7 @@ protected:
void setupDummysForContext(QQmlContext *context); void setupDummysForContext(QQmlContext *context);
void setupFileUrl(const QUrl &fileUrl); void setupFileUrl(const QUrl &fileUrl);
void setupImports(const QVector<AddImportContainer> &container); void setupImports(const QVector<AddImportContainer> &container, const QVector<IdContainer> &idContainerVector);
void setupDummyData(const QUrl &fileUrl); void setupDummyData(const QUrl &fileUrl);
void setupDefaultDummyData(); void setupDefaultDummyData();
QList<ServerNodeInstance> setupInstances(const CreateSceneCommand &command); QList<ServerNodeInstance> setupInstances(const CreateSceneCommand &command);

View File

@@ -91,7 +91,7 @@ void Qt5NodeInstanceServer::resetAllItems()
void Qt5NodeInstanceServer::setupScene(const CreateSceneCommand &command) void Qt5NodeInstanceServer::setupScene(const CreateSceneCommand &command)
{ {
setupFileUrl(command.fileUrl()); setupFileUrl(command.fileUrl());
setupImports(command.imports()); setupImports(command.imports(), command.ids());
setupDummyData(command.fileUrl()); setupDummyData(command.fileUrl());
setupInstances(command); setupInstances(command);

View File

@@ -218,15 +218,15 @@ ServerNodeInstance ServerNodeInstance::create(NodeInstanceServer *nodeInstanceSe
} else if (!instanceContainer.nodeSource().isEmpty()) { } else if (!instanceContainer.nodeSource().isEmpty()) {
object = Internal::ObjectNodeInstance::createCustomParserObject(instanceContainer.nodeSource(), nodeInstanceServer->importCode(), nodeInstanceServer->context()); object = Internal::ObjectNodeInstance::createCustomParserObject(instanceContainer.nodeSource(), nodeInstanceServer->importCode(), nodeInstanceServer->context());
if (object == 0) if (object == 0)
nodeInstanceServer->sendDebugOutput(DebugOutputCommand::ErrorType, QLatin1String("Custom parser object could not be created.")); nodeInstanceServer->sendDebugOutput(DebugOutputCommand::ErrorType, QLatin1String("Custom parser object could not be created."), instanceContainer.instanceId());
} else if (!instanceContainer.componentPath().isEmpty()) { } else if (!instanceContainer.componentPath().isEmpty()) {
object = Internal::ObjectNodeInstance::createComponent(instanceContainer.componentPath(), nodeInstanceServer->context()); object = Internal::ObjectNodeInstance::createComponent(instanceContainer.componentPath(), nodeInstanceServer->context());
if (object == 0) if (object == 0)
nodeInstanceServer->sendDebugOutput(DebugOutputCommand::ErrorType, QString("Component with path %1 could not be created.").arg(instanceContainer.componentPath())); nodeInstanceServer->sendDebugOutput(DebugOutputCommand::ErrorType, QString("Component with path %1 could not be created.").arg(instanceContainer.componentPath()), instanceContainer.instanceId());
} else { } else {
object = Internal::ObjectNodeInstance::createPrimitive(instanceContainer.type(), instanceContainer.majorNumber(), instanceContainer.minorNumber(), nodeInstanceServer->context()); object = Internal::ObjectNodeInstance::createPrimitive(instanceContainer.type(), instanceContainer.majorNumber(), instanceContainer.minorNumber(), nodeInstanceServer->context());
if (object == 0) if (object == 0)
nodeInstanceServer->sendDebugOutput(DebugOutputCommand::ErrorType, QLatin1String("Item could not be created.")); nodeInstanceServer->sendDebugOutput(DebugOutputCommand::ErrorType, QLatin1String("Item could not be created."), instanceContainer.instanceId());
} }
if (object == 0) { if (object == 0) {

View File

@@ -1071,9 +1071,11 @@ QObject *NodeInstanceServer::dummyContextObject() const
return m_dummyContextObject.data(); return m_dummyContextObject.data();
} }
void NodeInstanceServer::sendDebugOutput(DebugOutputCommand::Type type, const QString &message) void NodeInstanceServer::sendDebugOutput(DebugOutputCommand::Type type, const QString &message, qint32 instanceId)
{ {
DebugOutputCommand command(message, type); QVector<qint32> instanceIds;
instanceIds.append(instanceId);
DebugOutputCommand command(message, type, instanceIds);
nodeInstanceClient()->debugOutput(command); nodeInstanceClient()->debugOutput(command);
} }

View File

@@ -128,7 +128,7 @@ public:
virtual QDeclarativeView *declarativeView() const = 0; virtual QDeclarativeView *declarativeView() const = 0;
virtual QSGView *sgView() const = 0; virtual QSGView *sgView() const = 0;
void sendDebugOutput(DebugOutputCommand::Type type, const QString &message); void sendDebugOutput(DebugOutputCommand::Type type, const QString &message, qint32 instanceId);
public slots: public slots:
void refreshLocalFileProperty(const QString &path); void refreshLocalFileProperty(const QString &path);

View File

@@ -8,8 +8,8 @@ QtcProduct {
cpp.rpaths: qbs.targetOS.contains("osx") ? ["@executable_path/.."] cpp.rpaths: qbs.targetOS.contains("osx") ? ["@executable_path/.."]
: ["$ORIGIN/../" + project.libDirName + "/qtcreator"] : ["$ORIGIN/../" + project.libDirName + "/qtcreator"]
cpp.includePaths: [ cpp.includePaths: [
"../shared/qtsingleapplication", project.sharedSourcesDir + "/qtsingleapplication",
"../shared/qtlockedfile", project.sharedSourcesDir + "/qtlockedfile",
] ]
Depends { name: "app_version_header" } Depends { name: "app_version_header" }

View File

@@ -211,7 +211,7 @@ void QmlProfilerTraceClient::messageReceived(const QByteArray &data)
threadId = 0; threadId = 0;
emit rangedEvent(Event, MaximumRangeType, AnimationFrame, time, 0, QString(), emit rangedEvent(Event, MaximumRangeType, AnimationFrame, time, 0, QString(),
QmlDebug::QmlEventLocation(), frameRate, animationCount, threadId, QmlEventLocation(), frameRate, animationCount, threadId,
0, 0); 0, 0);
d->maximumTime = qMax(time, d->maximumTime); d->maximumTime = qMax(time, d->maximumTime);
break; break;
@@ -222,7 +222,7 @@ void QmlProfilerTraceClient::messageReceived(const QByteArray &data)
break; break;
emit this->rangedEvent(Event, MaximumRangeType, subtype, time, 0, QString(), emit this->rangedEvent(Event, MaximumRangeType, subtype, time, 0, QString(),
QmlDebug::QmlEventLocation(), 0, 0, 0, 0, 0); QmlEventLocation(), 0, 0, 0, 0, 0);
d->maximumTime = qMax(time, d->maximumTime); d->maximumTime = qMax(time, d->maximumTime);
break; break;
} }
@@ -244,8 +244,8 @@ void QmlProfilerTraceClient::messageReceived(const QByteArray &data)
} }
while (count<5) while (count<5)
params[count++] = 0; params[count++] = 0;
emit rangedEvent(SceneGraphFrame, QmlDebug::MaximumRangeType, subtype,time, 0, emit rangedEvent(SceneGraphFrame, MaximumRangeType, subtype,time, 0,
QString(), QmlDebug::QmlEventLocation(), params[0], params[1], QString(), QmlEventLocation(), params[0], params[1],
params[2], params[3], params[4]); params[2], params[3], params[4]);
break; break;
} }
@@ -261,8 +261,8 @@ void QmlProfilerTraceClient::messageReceived(const QByteArray &data)
stream >> width >> height; stream >> width >> height;
refcount = 1; refcount = 1;
} }
emit rangedEvent(QmlDebug::PixmapCacheEvent, QmlDebug::MaximumRangeType, subtype, time, 0, emit rangedEvent(PixmapCacheEvent, MaximumRangeType, subtype, time, 0,
QString(), QmlDebug::QmlEventLocation(pixUrl,0,0), width, height, QString(), QmlEventLocation(pixUrl,0,0), width, height,
refcount, 0, 0); refcount, 0, 0);
d->maximumTime = qMax(time, d->maximumTime); d->maximumTime = qMax(time, d->maximumTime);
break; break;
@@ -273,8 +273,8 @@ void QmlProfilerTraceClient::messageReceived(const QByteArray &data)
qint64 delta; qint64 delta;
stream >> delta; stream >> delta;
emit rangedEvent(QmlDebug::MemoryAllocation, QmlDebug::MaximumRangeType, subtype, time, 0, emit rangedEvent(MemoryAllocation, MaximumRangeType, subtype, time, 0,
QString(), QmlDebug::QmlEventLocation(), delta, 0, 0, 0, 0); QString(), QmlEventLocation(), delta, 0, 0, 0, 0);
d->maximumTime = qMax(time, d->maximumTime); d->maximumTime = qMax(time, d->maximumTime);
break; break;
} }

View File

@@ -41,9 +41,10 @@
#include <QDir> #include <QDir>
using namespace LanguageUtils; using namespace LanguageUtils;
using namespace QmlJS;
using namespace QmlJS::AST; using namespace QmlJS::AST;
namespace QmlJS {
namespace { namespace {
class ImportCacheKey class ImportCacheKey
{ {
@@ -76,8 +77,7 @@ bool operator==(const ImportCacheKey &i1, const ImportCacheKey &i2)
} }
} }
class LinkPrivate
class QmlJS::LinkPrivate
{ {
public: public:
Snapshot snapshot; Snapshot snapshot;
@@ -602,3 +602,5 @@ void LinkPrivate::loadImplicitDefaultImports(Imports *imports)
imports->append(import); imports->append(import);
} }
} }
} // namespace QmlJS

View File

@@ -65,12 +65,10 @@ private:
} }
}; };
} // end of Internal namespace } // namespace Internal
} // end of QmlJS namespace
// globally shared data // globally shared data
class QmlJS::SharedValueOwner : public ValueOwner class SharedValueOwner : public ValueOwner
{ {
public: public:
enum SharedValueOwnerKind{ enum SharedValueOwnerKind{
@@ -969,3 +967,5 @@ const Value *ValueOwner::defaultValueForBuiltinType(const QString &name) const
} }
return undefinedValue(); return undefinedValue();
} }
} // namespace QmlJS

View File

@@ -135,10 +135,10 @@ static inline bool isTextFile(const QByteArray &data)
MimeType MimeDatabasePrivate::findByData(const QByteArray &data, int *accuracyPtr) MimeType MimeDatabasePrivate::findByData(const QByteArray &data, int *accuracyPtr)
{ {
if (data.isEmpty()) { // if (data.isEmpty()) {
*accuracyPtr = 100; // *accuracyPtr = 100;
return mimeTypeForName(QLatin1String("application/x-zerosize")); // return mimeTypeForName(QLatin1String("application/x-zerosize"));
} // }
*accuracyPtr = 0; *accuracyPtr = 0;
MimeType candidate = provider()->findByMagic(data, accuracyPtr); MimeType candidate = provider()->findByMagic(data, accuracyPtr);

View File

@@ -833,7 +833,8 @@ void MimeXMLProvider::ensureLoaded()
{ {
if (!m_loaded /*|| shouldCheck()*/) { if (!m_loaded /*|| shouldCheck()*/) {
// bool fdoXmlFound = false; // bool fdoXmlFound = false;
QStringList allFiles; // add custom mime types first, which overrides any default from freedesktop.org.xml
QStringList allFiles = m_additionalFiles;
// const QStringList packageDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime/packages"), QStandardPaths::LocateDirectory); // const QStringList packageDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime/packages"), QStandardPaths::LocateDirectory);
// //qDebug() << "packageDirs=" << packageDirs; // //qDebug() << "packageDirs=" << packageDirs;
@@ -851,11 +852,9 @@ void MimeXMLProvider::ensureLoaded()
// if (!fdoXmlFound) { // if (!fdoXmlFound) {
// // We could instead install the file as part of installing Qt? // // We could instead install the file as part of installing Qt?
allFiles.prepend(QLatin1String(":/qt-project.org/qmime/freedesktop.org.xml")); allFiles.append(QLatin1String(":/qt-project.org/qmime/freedesktop.org.xml"));
// } // }
allFiles.append(m_additionalFiles);
if (m_allFiles == allFiles) if (m_allFiles == allFiles)
return; return;
m_allFiles = allFiles; m_allFiles = allFiles;

View File

@@ -210,9 +210,12 @@ bool MimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
QXmlStreamReader reader(dev); QXmlStreamReader reader(dev);
ParseState ps = ParseBeginning; ParseState ps = ParseBeginning;
QXmlStreamAttributes atts; QXmlStreamAttributes atts;
bool ignoreCurrentMimeType = false;
while (!reader.atEnd()) { while (!reader.atEnd()) {
switch (reader.readNext()) { switch (reader.readNext()) {
case QXmlStreamReader::StartElement: case QXmlStreamReader::StartElement:
if (ignoreCurrentMimeType)
continue;
ps = nextState(ps, reader.name()); ps = nextState(ps, reader.name());
atts = reader.attributes(); atts = reader.attributes();
switch (ps) { switch (ps) {
@@ -221,7 +224,10 @@ bool MimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
if (name.isEmpty()) { if (name.isEmpty()) {
reader.raiseError(QString::fromLatin1("Missing '%1'-attribute").arg(QString::fromLatin1(mimeTypeAttributeC))); reader.raiseError(QString::fromLatin1("Missing '%1'-attribute").arg(QString::fromLatin1(mimeTypeAttributeC)));
} else { } else {
data.name = name; if (mimeTypeExists(name))
ignoreCurrentMimeType = true;
else
data.name = name;
} }
} }
break; break;
@@ -307,20 +313,25 @@ bool MimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
{ {
const QStringRef elementName = reader.name(); const QStringRef elementName = reader.name();
if (elementName == QLatin1String(mimeTypeTagC)) { if (elementName == QLatin1String(mimeTypeTagC)) {
if (!process(MimeType(data), errorMessage)) if (!ignoreCurrentMimeType) {
return false; if (!process(MimeType(data), errorMessage))
return false;
}
ignoreCurrentMimeType = false;
data.clear(); data.clear();
} else if (elementName == QLatin1String(matchTagC)) { } else if (!ignoreCurrentMimeType) {
// Closing a <match> tag, pop stack if (elementName == QLatin1String(matchTagC)) {
currentRules.pop(); // Closing a <match> tag, pop stack
//qDebug() << " MATCH closed. Stack size is now" << currentRules.size(); currentRules.pop();
} else if (elementName == QLatin1String(magicTagC)) { //qDebug() << " MATCH closed. Stack size is now" << currentRules.size();
//qDebug() << "MAGIC ended, we got" << rules.count() << "rules, with prio" << priority; } else if (elementName == QLatin1String(magicTagC)) {
// Finished a <magic> sequence //qDebug() << "MAGIC ended, we got" << rules.count() << "rules, with prio" << priority;
MimeMagicRuleMatcher ruleMatcher(data.name, priority); // Finished a <magic> sequence
ruleMatcher.addRules(rules); MimeMagicRuleMatcher ruleMatcher(data.name, priority);
processMagicMatcher(ruleMatcher); ruleMatcher.addRules(rules);
rules.clear(); processMagicMatcher(ruleMatcher);
rules.clear();
}
} }
break; break;
} }

View File

@@ -67,6 +67,7 @@ public:
bool parse(QIODevice *dev, const QString &fileName, QString *errorMessage); bool parse(QIODevice *dev, const QString &fileName, QString *errorMessage);
protected: protected:
virtual bool mimeTypeExists(const QString &mimeTypeName) = 0;
virtual bool process(const MimeType &t, QString *errorMessage) = 0; virtual bool process(const MimeType &t, QString *errorMessage) = 0;
virtual bool process(const MimeGlobPattern &t, QString *errorMessage) = 0; virtual bool process(const MimeGlobPattern &t, QString *errorMessage) = 0;
virtual void processParent(const QString &child, const QString &parent) = 0; virtual void processParent(const QString &child, const QString &parent) = 0;
@@ -100,6 +101,9 @@ public:
explicit MimeTypeParser(MimeXMLProvider &provider) : m_provider(provider) {} explicit MimeTypeParser(MimeXMLProvider &provider) : m_provider(provider) {}
protected: protected:
inline bool mimeTypeExists(const QString &mimeTypeName)
{ return m_provider.mimeTypeForName(mimeTypeName).isValid(); }
inline bool process(const MimeType &t, QString *) inline bool process(const MimeType &t, QString *)
{ m_provider.addMimeType(t); return true; } { m_provider.addMimeType(t); return true; }

View File

@@ -151,8 +151,8 @@ public:
void selectAction(AnalyzerAction *action); void selectAction(AnalyzerAction *action);
void handleToolStarted(); void handleToolStarted();
void handleToolFinished(); void handleToolFinished();
void saveToolSettings(AnalyzerAction *action); void saveToolSettings(Id toolId);
void loadToolSettings(AnalyzerAction *action); void loadToolSettings(Id toolId);
// Convenience. // Convenience.
bool isActionRunnable(AnalyzerAction *action) const; bool isActionRunnable(AnalyzerAction *action) const;
@@ -178,9 +178,9 @@ public:
QComboBox *m_toolBox; QComboBox *m_toolBox;
QStackedWidget *m_controlsStackWidget; QStackedWidget *m_controlsStackWidget;
StatusLabel *m_statusLabel; StatusLabel *m_statusLabel;
typedef QMap<IAnalyzerTool *, FancyMainWindowSettings> MainWindowSettingsMap; typedef QMap<Id, FancyMainWindowSettings> MainWindowSettingsMap;
QHash<IAnalyzerTool *, QList<QDockWidget *> > m_toolWidgets; QHash<Id, QList<QDockWidget *> > m_toolWidgets;
QHash<IAnalyzerTool *, QWidget *> m_controlsWidgetFromTool; QHash<Id, QWidget *> m_controlsWidgetFromTool;
MainWindowSettingsMap m_defaultSettings; MainWindowSettingsMap m_defaultSettings;
// list of dock widgets to prevent memory leak // list of dock widgets to prevent memory leak
@@ -431,13 +431,13 @@ bool AnalyzerManagerPrivate::isActionRunnable(AnalyzerAction *action) const
if (action->startMode() == StartRemote) if (action->startMode() == StartRemote)
return true; return true;
return ProjectExplorerPlugin::canRun(SessionManager::startupProject(), action->tool()->runMode(), 0); return ProjectExplorerPlugin::canRun(SessionManager::startupProject(), action->runMode(), 0);
} }
void AnalyzerManagerPrivate::startTool() void AnalyzerManagerPrivate::startTool()
{ {
QTC_ASSERT(m_currentAction, return); QTC_ASSERT(m_currentAction, return);
m_currentAction->tool()->startTool(m_currentAction->startMode()); m_currentAction->toolStarter()(m_currentAction->startMode());
} }
void AnalyzerManagerPrivate::modeChanged(IMode *mode) void AnalyzerManagerPrivate::modeChanged(IMode *mode)
@@ -461,7 +461,7 @@ void AnalyzerManagerPrivate::selectSavedTool()
if (settings->contains(QLatin1String(LAST_ACTIVE_TOOL))) { if (settings->contains(QLatin1String(LAST_ACTIVE_TOOL))) {
const Id lastAction = Id::fromSetting(settings->value(QLatin1String(LAST_ACTIVE_TOOL))); const Id lastAction = Id::fromSetting(settings->value(QLatin1String(LAST_ACTIVE_TOOL)));
foreach (AnalyzerAction *action, m_actions) { foreach (AnalyzerAction *action, m_actions) {
if (action->id() == lastAction) { if (action->toolId() == lastAction) {
selectAction(action); selectAction(action);
return; return;
} }
@@ -496,30 +496,30 @@ void AnalyzerManagerPrivate::selectAction(AnalyzerAction *action)
// Clean up old tool. // Clean up old tool.
if (m_currentAction) { if (m_currentAction) {
saveToolSettings(m_currentAction); saveToolSettings(m_currentAction->toolId());
foreach (QDockWidget *widget, m_toolWidgets.value(m_currentAction->tool())) foreach (QDockWidget *widget, m_toolWidgets.value(m_currentAction->toolId()))
deactivateDock(widget); deactivateDock(widget);
} }
// Now change the tool. // Now change the tool.
m_currentAction = action; m_currentAction = action;
IAnalyzerTool *tool = action->tool(); Id toolId = action->toolId();
if (!m_defaultSettings.contains(tool)) { if (!m_defaultSettings.contains(toolId)) {
QWidget *widget = tool->createWidgets(); QWidget *widget = action->createWidget();
QTC_CHECK(widget); QTC_CHECK(widget);
m_defaultSettings.insert(tool, m_mainWindow->saveSettings()); m_defaultSettings.insert(toolId, m_mainWindow->saveSettings());
QTC_CHECK(!m_controlsWidgetFromTool.contains(tool)); QTC_CHECK(!m_controlsWidgetFromTool.contains(toolId));
m_controlsWidgetFromTool[tool] = widget; m_controlsWidgetFromTool[toolId] = widget;
m_controlsStackWidget->addWidget(widget); m_controlsStackWidget->addWidget(widget);
} }
foreach (QDockWidget *widget, m_toolWidgets.value(tool)) foreach (QDockWidget *widget, m_toolWidgets.value(toolId))
activateDock(Qt::DockWidgetArea(widget->property(INITIAL_DOCK_AREA).toInt()), widget); activateDock(Qt::DockWidgetArea(widget->property(INITIAL_DOCK_AREA).toInt()), widget);
loadToolSettings(action); loadToolSettings(action->toolId());
QTC_CHECK(m_controlsWidgetFromTool.contains(tool)); QTC_CHECK(m_controlsWidgetFromTool.contains(toolId));
m_controlsStackWidget->setCurrentWidget(m_controlsWidgetFromTool.value(tool)); m_controlsStackWidget->setCurrentWidget(m_controlsWidgetFromTool.value(toolId));
m_toolBox->setCurrentIndex(actionIndex); m_toolBox->setCurrentIndex(actionIndex);
updateRunActions(); updateRunActions();
@@ -533,7 +533,7 @@ void AnalyzerManagerPrivate::addAction(AnalyzerAction *action)
Id menuGroup = action->menuGroup(); Id menuGroup = action->menuGroup();
if (menuGroup.isValid()) { if (menuGroup.isValid()) {
Command *command = ActionManager::registerAction(action, action->id(), Context(C_GLOBAL)); Command *command = ActionManager::registerAction(action, action->actionId(), Context(C_GLOBAL));
m_menu->addAction(command, menuGroup); m_menu->addAction(command, menuGroup);
} }
@@ -556,29 +556,28 @@ void AnalyzerManagerPrivate::handleToolFinished()
updateRunActions(); updateRunActions();
} }
void AnalyzerManagerPrivate::loadToolSettings(AnalyzerAction *action) void AnalyzerManagerPrivate::loadToolSettings(Id toolId)
{ {
QTC_ASSERT(m_mainWindow, return); QTC_ASSERT(m_mainWindow, return);
QSettings *settings = ICore::settings(); QSettings *settings = ICore::settings();
settings->beginGroup(QLatin1String("AnalyzerViewSettings_") + action->id().toString()); settings->beginGroup(QLatin1String("AnalyzerViewSettings_") + toolId.toString());
if (settings->value(QLatin1String("ToolSettingsSaved"), false).toBool()) if (settings->value(QLatin1String("ToolSettingsSaved"), false).toBool())
m_mainWindow->restoreSettings(settings); m_mainWindow->restoreSettings(settings);
else else
m_mainWindow->restoreSettings(m_defaultSettings.value(action->tool())); m_mainWindow->restoreSettings(m_defaultSettings.value(toolId));
settings->endGroup(); settings->endGroup();
} }
void AnalyzerManagerPrivate::saveToolSettings(AnalyzerAction *action) void AnalyzerManagerPrivate::saveToolSettings(Id toolId)
{ {
QTC_ASSERT(action, return);
QTC_ASSERT(m_mainWindow, return); QTC_ASSERT(m_mainWindow, return);
QSettings *settings = ICore::settings(); QSettings *settings = ICore::settings();
settings->beginGroup(QLatin1String("AnalyzerViewSettings_") + action->id().toString()); settings->beginGroup(QLatin1String("AnalyzerViewSettings_") + toolId.toString());
m_mainWindow->saveSettings(settings); m_mainWindow->saveSettings(settings);
settings->setValue(QLatin1String("ToolSettingsSaved"), true); settings->setValue(QLatin1String("ToolSettingsSaved"), true);
settings->endGroup(); settings->endGroup();
settings->setValue(QLatin1String(LAST_ACTIVE_TOOL), action->id().toString()); settings->setValue(QLatin1String(LAST_ACTIVE_TOOL), toolId.toString());
} }
void AnalyzerManagerPrivate::updateRunActions() void AnalyzerManagerPrivate::updateRunActions()
@@ -590,7 +589,7 @@ void AnalyzerManagerPrivate::updateRunActions()
disabledReason = tr("No analyzer tool selected."); disabledReason = tr("No analyzer tool selected.");
else else
ProjectExplorerPlugin::canRun(SessionManager::startupProject(), ProjectExplorerPlugin::canRun(SessionManager::startupProject(),
m_currentAction->tool()->runMode(), &disabledReason); m_currentAction->runMode(), &disabledReason);
m_startAction->setEnabled(isActionRunnable(m_currentAction)); m_startAction->setEnabled(isActionRunnable(m_currentAction));
m_startAction->setToolTip(disabledReason); m_startAction->setToolTip(disabledReason);
@@ -625,7 +624,7 @@ AnalyzerManager::~AnalyzerManager()
void AnalyzerManager::shutdown() void AnalyzerManager::shutdown()
{ {
if (d->m_currentAction) if (d->m_currentAction)
d->saveToolSettings(d->m_currentAction); d->saveToolSettings(d->m_currentAction->toolId());
} }
void AnalyzerManager::addAction(AnalyzerAction *action) void AnalyzerManager::addAction(AnalyzerAction *action)
@@ -633,21 +632,21 @@ void AnalyzerManager::addAction(AnalyzerAction *action)
d->addAction(action); d->addAction(action);
} }
QDockWidget *AnalyzerManager::createDockWidget(IAnalyzerTool *tool, QDockWidget *AnalyzerManager::createDockWidget(Core::Id toolId,
QWidget *widget, Qt::DockWidgetArea area) QWidget *widget, Qt::DockWidgetArea area)
{ {
QTC_ASSERT(!widget->objectName().isEmpty(), return 0); QTC_ASSERT(!widget->objectName().isEmpty(), return 0);
QDockWidget *dockWidget = d->m_mainWindow->addDockForWidget(widget); QDockWidget *dockWidget = d->m_mainWindow->addDockForWidget(widget);
dockWidget->setProperty(INITIAL_DOCK_AREA, int(area)); dockWidget->setProperty(INITIAL_DOCK_AREA, int(area));
d->m_dockWidgets.append(AnalyzerManagerPrivate::DockPtr(dockWidget)); d->m_dockWidgets.append(AnalyzerManagerPrivate::DockPtr(dockWidget));
d->m_toolWidgets[tool].push_back(dockWidget); d->m_toolWidgets[toolId].push_back(dockWidget);
return dockWidget; return dockWidget;
} }
void AnalyzerManager::selectTool(IAnalyzerTool *tool, StartMode mode) void AnalyzerManager::selectTool(Id toolId, StartMode mode)
{ {
foreach (AnalyzerAction *action, d->m_actions) foreach (AnalyzerAction *action, d->m_actions)
if (action->tool() == tool && action->startMode() == mode) if (action->toolId() == toolId && action->startMode() == mode)
d->selectAction(action); d->selectAction(action);
} }
@@ -664,7 +663,7 @@ FancyMainWindow *AnalyzerManager::mainWindow()
void AnalyzerManagerPrivate::resetLayout() void AnalyzerManagerPrivate::resetLayout()
{ {
QTC_ASSERT(m_currentAction, return); QTC_ASSERT(m_currentAction, return);
m_mainWindow->restoreSettings(m_defaultSettings.value(m_currentAction->tool())); m_mainWindow->restoreSettings(m_defaultSettings.value(m_currentAction->toolId()));
} }
void AnalyzerManager::showStatusMessage(const QString &message, int timeoutMS) void AnalyzerManager::showStatusMessage(const QString &message, int timeoutMS)
@@ -707,9 +706,8 @@ AnalyzerRunControl *AnalyzerManager::createRunControl(
const AnalyzerStartParameters &sp, RunConfiguration *runConfiguration) const AnalyzerStartParameters &sp, RunConfiguration *runConfiguration)
{ {
foreach (AnalyzerAction *action, d->m_actions) { foreach (AnalyzerAction *action, d->m_actions) {
IAnalyzerTool *tool = action->tool(); if (action->runMode() == sp.runMode && action->startMode() == sp.startMode)
if (tool->runMode() == sp.runMode && action->startMode() == sp.startMode) return action->createRunControl(sp, runConfiguration);
return tool->createRunControl(sp, runConfiguration);
} }
QTC_CHECK(false); QTC_CHECK(false);
return 0; return 0;

View File

@@ -35,6 +35,7 @@
#include "analyzerbase_global.h" #include "analyzerbase_global.h"
#include "analyzerconstants.h" #include "analyzerconstants.h"
#include <coreplugin/id.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
#include <QObject> #include <QObject>
@@ -49,7 +50,6 @@ namespace ProjectExplorer { class RunConfiguration; }
namespace Analyzer { namespace Analyzer {
class IAnalyzerTool;
class AnalyzerAction; class AnalyzerAction;
class AnalyzerRunControl; class AnalyzerRunControl;
class AnalyzerStartParameters; class AnalyzerStartParameters;
@@ -70,13 +70,13 @@ public:
static void addAction(AnalyzerAction *action); static void addAction(AnalyzerAction *action);
// Dockwidgets are registered to the main window. // Dockwidgets are registered to the main window.
static QDockWidget *createDockWidget(IAnalyzerTool *tool, static QDockWidget *createDockWidget(Core::Id toolId,
QWidget *widget, Qt::DockWidgetArea area = Qt::BottomDockWidgetArea); QWidget *widget, Qt::DockWidgetArea area = Qt::BottomDockWidgetArea);
static Utils::FancyMainWindow *mainWindow(); static Utils::FancyMainWindow *mainWindow();
static void showMode(); static void showMode();
static void selectTool(IAnalyzerTool *tool, StartMode mode); static void selectTool(Core::Id toolId, StartMode mode);
static void startTool(); static void startTool();
static void stopTool(); static void stopTool();

View File

@@ -58,7 +58,8 @@ AnalyzerRunControl::AnalyzerRunControl(const AnalyzerStartParameters &sp,
connect(this, &AnalyzerRunControl::finished, connect(this, &AnalyzerRunControl::finished,
this, &AnalyzerRunControl::runControlFinished); this, &AnalyzerRunControl::runControlFinished);
connect(AnalyzerManager::stopAction(), SIGNAL(triggered()), SLOT(stopIt())); connect(AnalyzerManager::stopAction(), &QAction::triggered,
this, &AnalyzerRunControl::stopIt);
} }
void AnalyzerRunControl::stopIt() void AnalyzerRunControl::stopIt()

View File

@@ -31,35 +31,118 @@
#include "ianalyzertool.h" #include "ianalyzertool.h"
#include "analyzermanager.h"
#include "analyzerruncontrol.h"
#include "startremotedialog.h"
#include <coreplugin/icore.h>
#include <coreplugin/imode.h>
#include <coreplugin/modemanager.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/project.h>
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/session.h>
#include <projectexplorer/target.h>
#include <utils/qtcassert.h>
#include <utils/checkablemessagebox.h>
#include <QAction>
#include <QDialog>
#include <QDialogButtonBox>
#include <QSettings>
using namespace Core;
using namespace ProjectExplorer;
namespace Analyzer { namespace Analyzer {
IAnalyzerTool::IAnalyzerTool(QObject *parent)
: QObject(parent)
{}
/// Returns the run mode for this tool.
ProjectExplorer::RunMode IAnalyzerTool::runMode() const
{
return m_runMode;
}
void IAnalyzerTool::setRunMode(ProjectExplorer::RunMode mode)
{
m_runMode = mode;
}
IAnalyzerTool::ToolMode IAnalyzerTool::toolMode() const
{
return m_toolMode;
}
void IAnalyzerTool::setToolMode(IAnalyzerTool::ToolMode mode)
{
m_toolMode = mode;
}
AnalyzerAction::AnalyzerAction(QObject *parent) AnalyzerAction::AnalyzerAction(QObject *parent)
: QAction(parent) : QAction(parent)
{} {}
static bool buildTypeAccepted(ToolMode toolMode, BuildConfiguration::BuildType buildType)
{
if (toolMode == AnyMode)
return true;
if (buildType == BuildConfiguration::Unknown)
return true;
if (buildType == BuildConfiguration::Debug && toolMode == DebugMode)
return true;
if (buildType == BuildConfiguration::Release && toolMode == ReleaseMode)
return true;
return false;
}
bool checkForLocalStart(ToolMode toolMode)
{
// Make sure mode is shown.
AnalyzerManager::showMode();
// ### not sure if we're supposed to check if the RunConFiguration isEnabled
Project *pro = SessionManager::startupProject();
BuildConfiguration::BuildType buildType = BuildConfiguration::Unknown;
if (pro) {
if (const Target *target = pro->activeTarget()) {
// Build configuration is 0 for QML projects.
if (const BuildConfiguration *buildConfig = target->activeBuildConfiguration())
buildType = buildConfig->buildType();
}
}
// Check the project for whether the build config is in the correct mode
// if not, notify the user and urge him to use the correct mode.
if (!buildTypeAccepted(toolMode, buildType)) {
const QString currentMode = buildType == BuildConfiguration::Debug
? AnalyzerManager::tr("Debug")
: AnalyzerManager::tr("Release");
QString toolModeString;
switch (toolMode) {
case DebugMode:
toolModeString = AnalyzerManager::tr("Debug");
break;
case ReleaseMode:
toolModeString = AnalyzerManager::tr("Release");
break;
default:
QTC_CHECK(false);
}
//const QString toolName = displayName();
const QString toolName = AnalyzerManager::tr("Tool"); // FIXME
const QString title = AnalyzerManager::tr("Run %1 in %2 Mode?").arg(toolName).arg(currentMode);
const QString message = AnalyzerManager::tr("<html><head/><body><p>You are trying "
"to run the tool \"%1\" on an application in %2 mode. "
"The tool is designed to be used in %3 mode.</p><p>"
"Debug and Release mode run-time characteristics differ "
"significantly, analytical findings for one mode may or "
"may not be relevant for the other.</p><p>"
"Do you want to continue and run the tool in %2 mode?</p></body></html>")
.arg(toolName).arg(currentMode).arg(toolModeString);
if (Utils::CheckableMessageBox::doNotAskAgainQuestion(ICore::mainWindow(),
title, message, ICore::settings(), QLatin1String("AnalyzerCorrectModeWarning"))
!= QDialogButtonBox::Yes)
return false;
}
return true;
}
bool checkForRemoteStart(AnalyzerStartParameters *sp)
{
StartRemoteDialog dlg;
if (dlg.exec() != QDialog::Accepted)
return false;
sp->startMode = StartRemote;
sp->connParams = dlg.sshParams();
sp->debuggee = dlg.executable();
sp->debuggeeArgs = dlg.arguments();
sp->displayName = dlg.executable();
sp->workingDirectory = dlg.workingDirectory();
return true;
}
} // namespace Analyzer } // namespace Analyzer

View File

@@ -41,68 +41,31 @@
#include <QObject> #include <QObject>
#include <QAction> #include <QAction>
#include <functional>
namespace ProjectExplorer { class RunConfiguration; } namespace ProjectExplorer { class RunConfiguration; }
namespace Analyzer { namespace Analyzer {
class AnalyzerRunControl; class AnalyzerRunControl;
/** /**
* This class represents an analyzation tool, e.g. "Valgrind Memcheck". * The mode in which this tool should preferably be run
* *
* Each tool can run in different run modes. The modes are specific to the mode. * The memcheck tool, for example, requires debug symbols, hence DebugMode
* * is preferred. On the other hand, callgrind should look at optimized code,
* @code * hence ReleaseMode.
* bool YourPlugin::initialize(const QStringList &arguments, QString *errorString)
* {
* AnalyzerManager::addTool(new MemcheckTool(this));
* return true;
* }
* @endcode
*/ */
class ANALYZER_EXPORT IAnalyzerTool : public QObject enum ToolMode {
{ DebugMode,
Q_OBJECT ReleaseMode,
AnyMode
public:
explicit IAnalyzerTool(QObject *parent = 0);
ProjectExplorer::RunMode runMode() const;
void setRunMode(ProjectExplorer::RunMode mode);
/**
* The mode in which this tool should preferably be run
*
* The memcheck tool, for example, requires debug symbols, hence DebugMode
* is preferred. On the other hand, callgrind should look at optimized code,
* hence ReleaseMode.
*/
enum ToolMode {
DebugMode,
ReleaseMode,
AnyMode
};
ToolMode toolMode() const;
void setToolMode(ToolMode mode);
/// Creates all widgets used by the tool.
/// Returns a control widget which will be shown in the status bar when
/// this tool is selected. Must be non-zero.
virtual QWidget *createWidgets() = 0;
/// Returns a new engine for the given start parameters.
/// Called each time the tool is launched.
virtual AnalyzerRunControl *createRunControl(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration) = 0;
virtual void startTool(StartMode mode) = 0;
private:
ProjectExplorer::RunMode m_runMode;
ToolMode m_toolMode;
}; };
ANALYZER_EXPORT bool checkForLocalStart(ToolMode toolMode);
ANALYZER_EXPORT bool checkForRemoteStart(AnalyzerStartParameters *sp);
/** /**
* This class represents an analyzation action, i.e. a tool that runs in a specific mode. * This class represents an analyzation action, i.e. a tool that runs in a specific mode.
* *
@@ -116,26 +79,52 @@ public:
explicit AnalyzerAction(QObject *parent = 0); explicit AnalyzerAction(QObject *parent = 0);
public: public:
IAnalyzerTool *tool() const { return m_tool; }
void setTool(IAnalyzerTool *tool) { m_tool = tool; }
StartMode startMode() const { return m_startMode; } StartMode startMode() const { return m_startMode; }
void setStartMode(StartMode startMode) { m_startMode = startMode; } void setStartMode(StartMode startMode) { m_startMode = startMode; }
Core::Id menuGroup() const { return m_menuGroup; } Core::Id menuGroup() const { return m_menuGroup; }
void setMenuGroup(Core::Id menuGroup) { m_menuGroup = menuGroup; } void setMenuGroup(Core::Id menuGroup) { m_menuGroup = menuGroup; }
Core::Id id() const { return m_id; } Core::Id actionId() const { return m_actionId; }
void setId(Core::Id id) { m_id = id; } void setActionId(Core::Id id) { m_actionId = id; }
Core::Id toolId() const { return m_toolId; }
void setToolId(Core::Id id) { m_toolId = id; }
ProjectExplorer::RunMode runMode() const { return m_runMode; }
void setRunMode(ProjectExplorer::RunMode mode) { m_runMode = mode; }
/// Creates all widgets used by the tool.
/// Returns a control widget which will be shown in the status bar when
/// this tool is selected.
typedef std::function<QWidget *()> WidgetCreator;
QWidget *createWidget() const { return m_widgetCreator(); }
void setWidgetCreator(const WidgetCreator &creator) { m_widgetCreator = creator; }
/// Returns a new engine for the given start parameters.
/// Called each time the tool is launched.
typedef std::function<AnalyzerRunControl *(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration)> RunControlCreator;
AnalyzerRunControl *createRunControl(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration) const
{ return m_runControlCreator(sp, runConfiguration); }
void setRunControlCreator(const RunControlCreator &creator) { m_runControlCreator = creator; }
typedef std::function<void(StartMode)> ToolStarter;
ToolStarter toolStarter() const { return m_toolStarter; }
void setToolStarter(const ToolStarter &toolStarter) { m_toolStarter = toolStarter; }
protected: protected:
IAnalyzerTool *m_tool;
StartMode m_startMode; StartMode m_startMode;
Core::Id m_menuGroup; Core::Id m_menuGroup;
Core::Id m_id; Core::Id m_actionId;
Core::Id m_toolId;
ProjectExplorer::RunMode m_runMode;
WidgetCreator m_widgetCreator;
RunControlCreator m_runControlCreator;
ToolStarter m_toolStarter;
}; };
} // namespace Analyzer } // namespace Analyzer
#endif // IANALYZERTOOL_H #endif // IANALYZERTOOL_H

View File

@@ -9,7 +9,7 @@ QtcPlugin {
Depends { name: "Core" } Depends { name: "Core" }
Depends { name: "TextEditor" } Depends { name: "TextEditor" }
cpp.includePaths: base.concat("../../shared/cpaster") cpp.includePaths: base.concat([project.sharedSourcesDir + "/cpaster"])
files: [ files: [
"columnindicatortextedit.cpp", "columnindicatortextedit.cpp",

View File

@@ -64,7 +64,7 @@
<comment>Objective-C++ source code</comment> <comment>Objective-C++ source code</comment>
<sub-class-of type="text/x-c++src"/> <sub-class-of type="text/x-c++src"/>
<sub-class-of type="text/x-objcsrc"/> <sub-class-of type="text/x-objcsrc"/>
<glob pattern="*.mm"/> <glob pattern="*.mm" weight="70"/>
</mime-type> </mime-type>
</mime-info> </mime-info>

View File

@@ -295,6 +295,7 @@ F2TestCase::F2TestCase(CppEditorAction action,
// that is the function bodies are processed. // that is the function bodies are processed.
forever { forever {
const Document::Ptr document = waitForFileInGlobalSnapshot(testFile->filePath()); const Document::Ptr document = waitForFileInGlobalSnapshot(testFile->filePath());
QVERIFY(document);
if (document->checkMode() == Document::FullCheck) { if (document->checkMode() == Document::FullCheck) {
QVERIFY(document->diagnosticMessages().isEmpty()); QVERIFY(document->diagnosticMessages().isEmpty());
break; break;

View File

@@ -88,8 +88,7 @@ public:
m_textDocument = m_editorWidget->document(); m_textDocument = m_editorWidget->document();
// Get Document // Get Document
waitForFileInGlobalSnapshot(fileName); const Document::Ptr document = waitForFileInGlobalSnapshot(fileName);
const Document::Ptr document = globalSnapshot().document(fileName);
QVERIFY(document); QVERIFY(document);
QVERIFY(document->diagnosticMessages().isEmpty()); QVERIFY(document->diagnosticMessages().isEmpty());

View File

@@ -128,7 +128,7 @@ private:
m_editor = EditorManager::openEditor(m_fileName); m_editor = EditorManager::openEditor(m_fileName);
QVERIFY(m_editor); QVERIFY(m_editor);
waitForFileInGlobalSnapshot(m_fileName); QVERIFY(waitForFileInGlobalSnapshot(m_fileName));
} }
void doAfterLocatorRun() void doAfterLocatorRun()

View File

@@ -170,14 +170,19 @@ bool TestCase::closeEditorWithoutGarbageCollectorInvocation(Core::IEditor *edito
return closeEditorsWithoutGarbageCollectorInvocation(QList<Core::IEditor *>() << editor); return closeEditorsWithoutGarbageCollectorInvocation(QList<Core::IEditor *>() << editor);
} }
CPlusPlus::Document::Ptr TestCase::waitForFileInGlobalSnapshot(const QString &filePath) CPlusPlus::Document::Ptr TestCase::waitForFileInGlobalSnapshot(const QString &filePath,
int timeOutInMs)
{ {
return waitForFilesInGlobalSnapshot(QStringList(filePath)).first(); const auto documents = waitForFilesInGlobalSnapshot(QStringList(filePath), timeOutInMs);
return documents.isEmpty() ? CPlusPlus::Document::Ptr() : documents.first();
} }
QList<CPlusPlus::Document::Ptr> TestCase::waitForFilesInGlobalSnapshot( QList<CPlusPlus::Document::Ptr> TestCase::waitForFilesInGlobalSnapshot(const QStringList &filePaths,
const QStringList &filePaths) int timeOutInMs)
{ {
QTime t;
t.start();
QList<CPlusPlus::Document::Ptr> result; QList<CPlusPlus::Document::Ptr> result;
foreach (const QString &filePath, filePaths) { foreach (const QString &filePath, filePaths) {
forever { forever {
@@ -185,13 +190,15 @@ QList<CPlusPlus::Document::Ptr> TestCase::waitForFilesInGlobalSnapshot(
result.append(document); result.append(document);
break; break;
} }
if (t.elapsed() > timeOutInMs)
return QList<CPlusPlus::Document::Ptr>();
QCoreApplication::processEvents(); QCoreApplication::processEvents();
} }
} }
return result; return result;
} }
bool TestCase::waitUntilCppModelManagerIsAwareOf(Project *project, int timeOut) bool TestCase::waitUntilCppModelManagerIsAwareOf(Project *project, int timeOutInMs)
{ {
if (!project) if (!project)
return false; return false;
@@ -203,7 +210,7 @@ bool TestCase::waitUntilCppModelManagerIsAwareOf(Project *project, int timeOut)
forever { forever {
if (modelManager->projectInfo(project).isValid()) if (modelManager->projectInfo(project).isValid())
return true; return true;
if (t.elapsed() > timeOut) if (t.elapsed() > timeOutInMs)
return false; return false;
QCoreApplication::processEvents(); QCoreApplication::processEvents();
} }

View File

@@ -93,11 +93,16 @@ public:
static CPlusPlus::Snapshot globalSnapshot(); static CPlusPlus::Snapshot globalSnapshot();
static bool garbageCollectGlobalSnapshot(); static bool garbageCollectGlobalSnapshot();
static bool waitUntilCppModelManagerIsAwareOf(ProjectExplorer::Project *project, enum { defaultTimeOutInMs = 30 * 1000 /*= 30 secs*/ };
int timeOut = 30 * 1000 /*= 30 secs*/); static bool waitUntilCppModelManagerIsAwareOf(
static CPlusPlus::Document::Ptr waitForFileInGlobalSnapshot(const QString &filePath); ProjectExplorer::Project *project,
int timeOutInMs = defaultTimeOutInMs);
static CPlusPlus::Document::Ptr waitForFileInGlobalSnapshot(
const QString &filePath,
int timeOutInMs = defaultTimeOutInMs);
static QList<CPlusPlus::Document::Ptr> waitForFilesInGlobalSnapshot( static QList<CPlusPlus::Document::Ptr> waitForFilesInGlobalSnapshot(
const QStringList &filePaths); const QStringList &filePaths,
int timeOutInMs = defaultTimeOutInMs);
static bool writeFile(const QString &filePath, const QByteArray &contents); static bool writeFile(const QString &filePath, const QByteArray &contents);

View File

@@ -87,6 +87,8 @@ enum { debugBreakpoints = 0 };
enum { LocalsUpdateForNewFrame = 0x1 }; enum { LocalsUpdateForNewFrame = 0x1 };
#define CB(callback) [this](const CdbCommandPtr &r) { callback(r); }
#if 0 #if 0
# define STATE_DEBUG(state, func, line, notifyFunc) qDebug("%s in %s at %s:%d", notifyFunc, stateName(state), func, line); # define STATE_DEBUG(state, func, line, notifyFunc) qDebug("%s in %s at %s:%d", notifyFunc, stateName(state), func, line);
#else #else
@@ -202,84 +204,48 @@ static inline bool isCreatorConsole(const DebuggerStartParameters &sp)
} }
// Base data structure for command queue entries with callback // Base data structure for command queue entries with callback
struct CdbCommandBase struct CdbCommand
{ {
typedef CdbEngine::BuiltinCommandHandler CommandHandler; CdbCommand()
: token(0), flags(0), commandSequence(0), isBuiltin(true), success(false)
{}
CdbCommandBase(); CdbCommand(bool builtin, const QByteArray &cmd, int token, unsigned flags,
CdbCommandBase(const QByteArray &cmd, int token, unsigned flags, CdbEngine::CommandHandler h, unsigned nc)
unsigned nc, const QVariant &cookie); : token(token), flags(flags), command(cmd), commandSequence(nc),
isBuiltin(builtin), handler(h), success(false)
{}
QByteArray joinedReply() const;
int token; int token;
unsigned flags; unsigned flags;
QByteArray command; QByteArray command;
QVariant cookie; // Continue with other commands as specified in CommandSequenceFlags
// Continue with another commands as specified in CommandSequenceFlags
unsigned commandSequence; unsigned commandSequence;
bool isBuiltin;
CdbEngine::CommandHandler handler;
QList<QByteArray> builtinReply;
QByteArray extensionReply;
QByteArray errorMessage;
bool success;
}; };
CdbCommandBase::CdbCommandBase() : QByteArray CdbCommand::joinedReply() const
token(0), flags(0), commandSequence(0)
{ {
} if (builtinReply.isEmpty())
CdbCommandBase::CdbCommandBase(const QByteArray &cmd, int t, unsigned f,
unsigned nc, const QVariant &c) :
token(t), flags(f), command(cmd), cookie(c), commandSequence(nc)
{
}
// Queue entry for builtin commands producing free-format
// line-by-line output.
struct CdbBuiltinCommand : public CdbCommandBase
{
typedef CdbEngine::BuiltinCommandHandler CommandHandler;
CdbBuiltinCommand() {}
CdbBuiltinCommand(const QByteArray &cmd, int token, unsigned flags,
CommandHandler h,
unsigned nc, const QVariant &cookie) :
CdbCommandBase(cmd, token, flags, nc, cookie), handler(h)
{}
QByteArray joinedReply() const;
CommandHandler handler;
QList<QByteArray> reply;
};
QByteArray CdbBuiltinCommand::joinedReply() const
{
if (reply.isEmpty())
return QByteArray(); return QByteArray();
QByteArray answer; QByteArray answer;
answer.reserve(120 * reply.size()); answer.reserve(120 * builtinReply.size());
foreach (const QByteArray &l, reply) { foreach (const QByteArray &l, builtinReply) {
answer += l; answer += l;
answer += '\n'; answer += '\n';
} }
return answer; return answer;
} }
// Queue entry for Qt Creator extension commands producing one-line
// output with success flag and error message.
struct CdbExtensionCommand : public CdbCommandBase
{
typedef CdbEngine::ExtensionCommandHandler CommandHandler;
CdbExtensionCommand() : success(false) {}
CdbExtensionCommand(const QByteArray &cmd, int token, unsigned flags,
CommandHandler h,
unsigned nc, const QVariant &cookie) :
CdbCommandBase(cmd, token, flags, nc, cookie), handler(h),success(false) {}
CommandHandler handler;
QByteArray reply;
QByteArray errorMessage;
bool success;
};
template <class CommandPtrType> template <class CommandPtrType>
int indexOfCommand(const QList<CommandPtrType> &l, int token) int indexOfCommand(const QList<CommandPtrType> &l, int token)
{ {
@@ -569,10 +535,10 @@ void CdbEngine::consoleStubExited()
void CdbEngine::createFullBacktrace() void CdbEngine::createFullBacktrace()
{ {
postBuiltinCommand("~*kp", 0, &CdbEngine::handleCreateFullBackTrace); postBuiltinCommand("~*kp", 0, CB(handleCreateFullBackTrace));
} }
void CdbEngine::handleCreateFullBackTrace(const CdbEngine::CdbBuiltinCommandPtr &cmd) void CdbEngine::handleCreateFullBackTrace(const CdbEngine::CdbCommandPtr &cmd)
{ {
Internal::openTextEditor(QLatin1String("Backtrace $"), QLatin1String(cmd->joinedReply())); Internal::openTextEditor(QLatin1String("Backtrace $"), QLatin1String(cmd->joinedReply()));
} }
@@ -765,7 +731,7 @@ void CdbEngine::setupInferior()
const BreakpointParameters bp(BreakpointAtMain); const BreakpointParameters bp(BreakpointAtMain);
postBuiltinCommand(cdbAddBreakpointCommand(bp, m_sourcePathMappings, postBuiltinCommand(cdbAddBreakpointCommand(bp, m_sourcePathMappings,
BreakpointModelId(quint16(-1)), true), 0, BreakpointModelId(quint16(-1)), true), 0,
&CdbEngine::handleBreakInsert); CB(handleBreakInsert));
} }
postCommand("sxn 0x4000001f", 0); // Do not break on WowX86 exceptions. postCommand("sxn 0x4000001f", 0); // Do not break on WowX86 exceptions.
postCommand("sxn ibp", 0); // Do not break on initial breakpoints. postCommand("sxn ibp", 0); // Do not break on initial breakpoints.
@@ -775,7 +741,7 @@ void CdbEngine::setupInferior()
+ " maxStackDepth=" + " maxStackDepth="
+ action(MaximalStackDepth)->value().toByteArray() + action(MaximalStackDepth)->value().toByteArray()
, 0); , 0);
postExtensionCommand("pid", QByteArray(), 0, &CdbEngine::handlePid); postExtensionCommand("pid", QByteArray(), 0, CB(handlePid));
} }
static QByteArray msvcRunTime(const Abi::OSFlavor flavour) static QByteArray msvcRunTime(const Abi::OSFlavor flavour)
@@ -824,25 +790,25 @@ void CdbEngine::runEngine()
const QByteArray debugModule = module + 'D'; const QByteArray debugModule = module + 'D';
const QByteArray wideFunc = QByteArray(CdbOptionsPage::crtDbgReport).append('W'); const QByteArray wideFunc = QByteArray(CdbOptionsPage::crtDbgReport).append('W');
postBuiltinCommand(breakAtFunctionCommand(CdbOptionsPage::crtDbgReport, module), 0, postBuiltinCommand(breakAtFunctionCommand(CdbOptionsPage::crtDbgReport, module), 0,
&CdbEngine::handleBreakInsert); CB(handleBreakInsert));
postBuiltinCommand(breakAtFunctionCommand(wideFunc, module), 0, postBuiltinCommand(breakAtFunctionCommand(wideFunc, module), 0,
&CdbEngine::handleBreakInsert); CB(handleBreakInsert));
postBuiltinCommand(breakAtFunctionCommand(CdbOptionsPage::crtDbgReport, debugModule), 0, postBuiltinCommand(breakAtFunctionCommand(CdbOptionsPage::crtDbgReport, debugModule), 0,
&CdbEngine::handleBreakInsert); CB(handleBreakInsert));
postBuiltinCommand(breakAtFunctionCommand(wideFunc, debugModule), 0, postBuiltinCommand(breakAtFunctionCommand(wideFunc, debugModule), 0,
&CdbEngine::handleBreakInsert); CB(handleBreakInsert));
} }
if (boolSetting(BreakOnWarning)) { if (boolSetting(BreakOnWarning)) {
postBuiltinCommand("bm /( QtCored4!qWarning", 0, postBuiltinCommand("bm /( QtCored4!qWarning", 0,
&CdbEngine::handleBreakInsert); // 'bm': All overloads. CB(handleBreakInsert)); // 'bm': All overloads.
postBuiltinCommand("bm /( Qt5Cored!QMessageLogger::warning", 0, postBuiltinCommand("bm /( Qt5Cored!QMessageLogger::warning", 0,
&CdbEngine::handleBreakInsert); CB(handleBreakInsert));
} }
if (boolSetting(BreakOnFatal)) { if (boolSetting(BreakOnFatal)) {
postBuiltinCommand("bm /( QtCored4!qFatal", 0, postBuiltinCommand("bm /( QtCored4!qFatal", 0,
&CdbEngine::handleBreakInsert); // 'bm': All overloads. CB(handleBreakInsert)); // 'bm': All overloads.
postBuiltinCommand("bm /( Qt5Cored!QMessageLogger::fatal", 0, postBuiltinCommand("bm /( Qt5Cored!QMessageLogger::fatal", 0,
&CdbEngine::handleBreakInsert); CB(handleBreakInsert));
} }
if (startParameters().startMode == AttachCore) { if (startParameters().startMode == AttachCore) {
QTC_ASSERT(!m_coreStopReason.isNull(), return; ); QTC_ASSERT(!m_coreStopReason.isNull(), return; );
@@ -1028,8 +994,7 @@ void CdbEngine::updateWatchData(const WatchData &dataIn,
if (!dataIn.name.isEmpty() && dataIn.name != QLatin1String(dataIn.exp)) if (!dataIn.name.isEmpty() && dataIn.name != QLatin1String(dataIn.exp))
m_watchInameToName.insert(dataIn.iname, dataIn.name); m_watchInameToName.insert(dataIn.iname, dataIn.name);
postExtensionCommand("addwatch", args, 0, postExtensionCommand("addwatch", args, 0,
&CdbEngine::handleAddWatch, 0, [this, dataIn](const CdbCommandPtr &r) { handleAddWatch(r, dataIn); });
qVariantFromValue(dataIn));
return; return;
} }
@@ -1042,9 +1007,8 @@ void CdbEngine::updateWatchData(const WatchData &dataIn,
updateLocalVariable(dataIn.iname); updateLocalVariable(dataIn.iname);
} }
void CdbEngine::handleAddWatch(const CdbExtensionCommandPtr &reply) void CdbEngine::handleAddWatch(const CdbCommandPtr &reply, WatchData item)
{ {
WatchData item = qvariant_cast<WatchData>(reply->cookie);
if (debugWatches) if (debugWatches)
qDebug() << "handleAddWatch ok=" << reply->success << item.iname; qDebug() << "handleAddWatch ok=" << reply->success << item.iname;
if (reply->success) { if (reply->success) {
@@ -1089,8 +1053,8 @@ void CdbEngine::updateLocalVariable(const QByteArray &iname)
str << blankSeparator << stackFrame; str << blankSeparator << stackFrame;
} }
str << blankSeparator << iname; str << blankSeparator << iname;
postExtensionCommand(isWatch ? "watches" : "locals", postExtensionCommand(isWatch ? "watches" : "locals", localsArguments, 0,
localsArguments, 0, &CdbEngine::handleLocals); [this](const CdbCommandPtr &r) { handleLocals(r, 0); });
} }
bool CdbEngine::hasCapability(unsigned cap) const bool CdbEngine::hasCapability(unsigned cap) const
@@ -1225,7 +1189,7 @@ void CdbEngine::executeRunToLine(const ContextData &data)
bp.lineNumber = data.lineNumber; bp.lineNumber = data.lineNumber;
} }
postBuiltinCommand(cdbAddBreakpointCommand(bp, m_sourcePathMappings, BreakpointModelId(), true), postBuiltinCommand(cdbAddBreakpointCommand(bp, m_sourcePathMappings, BreakpointModelId(), true),
0, &CdbEngine::handleBreakInsert); 0, CB(handleBreakInsert));
continueInferior(); continueInferior();
} }
@@ -1236,7 +1200,7 @@ void CdbEngine::executeRunToFunction(const QString &functionName)
bp.functionName = functionName; bp.functionName = functionName;
postBuiltinCommand(cdbAddBreakpointCommand(bp, m_sourcePathMappings, BreakpointModelId(), true), postBuiltinCommand(cdbAddBreakpointCommand(bp, m_sourcePathMappings, BreakpointModelId(), true),
0, &CdbEngine::handleBreakInsert); 0, CB(handleBreakInsert));
continueInferior(); continueInferior();
} }
@@ -1261,8 +1225,7 @@ void CdbEngine::executeJumpToLine(const ContextData &data)
QByteArray cmd; QByteArray cmd;
ByteArrayInputStream str(cmd); ByteArrayInputStream str(cmd);
str << "? `" << QDir::toNativeSeparators(data.fileName) << ':' << data.lineNumber << '`'; str << "? `" << QDir::toNativeSeparators(data.fileName) << ':' << data.lineNumber << '`';
const QVariant cookie = qVariantFromValue(data); postBuiltinCommand(cmd, 0, [this, data](const CdbCommandPtr &r) { handleJumpToLineAddressResolution(r, data); });
postBuiltinCommand(cmd, 0, &CdbEngine::handleJumpToLineAddressResolution, 0, cookie);
} }
} }
@@ -1279,13 +1242,13 @@ void CdbEngine::jumpToAddress(quint64 address)
postCommand(registerCmd, 0); postCommand(registerCmd, 0);
} }
void CdbEngine::handleJumpToLineAddressResolution(const CdbBuiltinCommandPtr &cmd) void CdbEngine::handleJumpToLineAddressResolution(const CdbCommandPtr &cmd, const ContextData &context)
{ {
if (cmd->reply.isEmpty()) if (cmd->builtinReply.isEmpty())
return; return;
// Evaluate expression: 5365511549 = 00000001`3fcf357d // Evaluate expression: 5365511549 = 00000001`3fcf357d
// Set register 'rip' to hex address and goto lcoation // Set register 'rip' to hex address and goto lcoation
QByteArray answer = cmd->reply.front().trimmed(); QByteArray answer = cmd->builtinReply.front().trimmed();
const int equalPos = answer.indexOf(" = "); const int equalPos = answer.indexOf(" = ");
if (equalPos == -1) if (equalPos == -1)
return; return;
@@ -1296,10 +1259,8 @@ void CdbEngine::handleJumpToLineAddressResolution(const CdbBuiltinCommandPtr &cm
bool ok; bool ok;
const quint64 address = answer.toLongLong(&ok, 16); const quint64 address = answer.toLongLong(&ok, 16);
if (ok && address) { if (ok && address) {
QTC_ASSERT(cmd->cookie.canConvert<ContextData>(), return);
const ContextData cookie = qvariant_cast<ContextData>(cmd->cookie);
jumpToAddress(address); jumpToAddress(address);
gotoLocation(Location(cookie.fileName, cookie.lineNumber)); gotoLocation(Location(context.fileName, context.lineNumber));
} }
} }
@@ -1349,13 +1310,13 @@ void CdbEngine::assignValueInDebugger(const WatchData *w, const QString &expr, c
updateLocals(); updateLocals();
} }
void CdbEngine::handleThreads(const CdbExtensionCommandPtr &reply) void CdbEngine::handleThreads(const CdbCommandPtr &reply)
{ {
if (debug) if (debug)
qDebug("CdbEngine::handleThreads success=%d", reply->success); qDebug("CdbEngine::handleThreads success=%d", reply->success);
if (reply->success) { if (reply->success) {
GdbMi data; GdbMi data;
data.fromString(reply->reply); data.fromString(reply->extensionReply);
threadsHandler()->updateThreads(data); threadsHandler()->updateThreads(data);
// Continue sequence // Continue sequence
postCommandSequence(reply->commandSequence); postCommandSequence(reply->commandSequence);
@@ -1385,9 +1346,8 @@ void CdbEngine::postCommand(const QByteArray &cmd, unsigned flags)
// In order to catch the output, it is enclosed in 'echo' commands // In order to catch the output, it is enclosed in 'echo' commands
// printing a specially formatted token to be identifiable in the output. // printing a specially formatted token to be identifiable in the output.
void CdbEngine::postBuiltinCommand(const QByteArray &cmd, unsigned flags, void CdbEngine::postBuiltinCommand(const QByteArray &cmd, unsigned flags,
BuiltinCommandHandler handler, CommandHandler handler,
unsigned nextCommandFlag, unsigned nextCommandFlag)
const QVariant &cookie)
{ {
if (!m_accessible) { if (!m_accessible) {
const QString msg = QString::fromLatin1("Attempt to issue builtin command \"%1\" to non-accessible session (%2)") const QString msg = QString::fromLatin1("Attempt to issue builtin command \"%1\" to non-accessible session (%2)")
@@ -1399,7 +1359,7 @@ void CdbEngine::postBuiltinCommand(const QByteArray &cmd, unsigned flags,
showMessage(QString::fromLocal8Bit(cmd), LogInput); showMessage(QString::fromLocal8Bit(cmd), LogInput);
const int token = m_nextCommandToken++; const int token = m_nextCommandToken++;
CdbBuiltinCommandPtr pendingCommand(new CdbBuiltinCommand(cmd, token, flags, handler, nextCommandFlag, cookie)); CdbCommandPtr pendingCommand(new CdbCommand(true, cmd, token, flags, handler, nextCommandFlag));
m_builtinCommandQueue.push_back(pendingCommand); m_builtinCommandQueue.push_back(pendingCommand);
// Enclose command in echo-commands for token // Enclose command in echo-commands for token
@@ -1408,8 +1368,8 @@ void CdbEngine::postBuiltinCommand(const QByteArray &cmd, unsigned flags,
str << ".echo \"" << m_tokenPrefix << token << "<\"\n" str << ".echo \"" << m_tokenPrefix << token << "<\"\n"
<< cmd << "\n.echo \"" << m_tokenPrefix << token << ">\"\n"; << cmd << "\n.echo \"" << m_tokenPrefix << token << ">\"\n";
if (debug) if (debug)
qDebug("CdbEngine::postBuiltinCommand %dms '%s' flags=%u token=%d %s next=%u, cookie='%s', pending=%d, sequence=0x%x", qDebug("CdbEngine::postBuiltinCommand %dms '%s' flags=%u token=%d %s next=%u, pending=%d, sequence=0x%x",
elapsedLogTime(), cmd.constData(), flags, token, stateName(state()), nextCommandFlag, qPrintable(cookie.toString()), elapsedLogTime(), cmd.constData(), flags, token, stateName(state()), nextCommandFlag,
m_builtinCommandQueue.size(), nextCommandFlag); m_builtinCommandQueue.size(), nextCommandFlag);
if (debug > 1) if (debug > 1)
qDebug("CdbEngine::postBuiltinCommand: resulting command '%s'\n", qDebug("CdbEngine::postBuiltinCommand: resulting command '%s'\n",
@@ -1422,9 +1382,8 @@ void CdbEngine::postBuiltinCommand(const QByteArray &cmd, unsigned flags,
void CdbEngine::postExtensionCommand(const QByteArray &cmd, void CdbEngine::postExtensionCommand(const QByteArray &cmd,
const QByteArray &arguments, const QByteArray &arguments,
unsigned flags, unsigned flags,
ExtensionCommandHandler handler, CommandHandler handler,
unsigned nextCommandFlag, unsigned nextCommandFlag)
const QVariant &cookie)
{ {
if (!m_accessible) { if (!m_accessible) {
const QString msg = QString::fromLatin1("Attempt to issue extension command \"%1\" to non-accessible session (%2)") const QString msg = QString::fromLatin1("Attempt to issue extension command \"%1\" to non-accessible session (%2)")
@@ -1445,13 +1404,13 @@ void CdbEngine::postExtensionCommand(const QByteArray &cmd,
if (!(flags & QuietCommand)) if (!(flags & QuietCommand))
showMessage(QString::fromLocal8Bit(fullCmd), LogInput); showMessage(QString::fromLocal8Bit(fullCmd), LogInput);
CdbExtensionCommandPtr pendingCommand(new CdbExtensionCommand(fullCmd, token, flags, handler, nextCommandFlag, cookie)); CdbCommandPtr pendingCommand(new CdbCommand(false, fullCmd, token, flags, handler, nextCommandFlag));
m_extensionCommandQueue.push_back(pendingCommand); m_extensionCommandQueue.push_back(pendingCommand);
// Enclose command in echo-commands for token // Enclose command in echo-commands for token
if (debug) if (debug)
qDebug("CdbEngine::postExtensionCommand %dms '%s' flags=%u token=%d %s next=%u, cookie='%s', pending=%d, sequence=0x%x", qDebug("CdbEngine::postExtensionCommand %dms '%s' flags=%u token=%d %s next=%u, pending=%d, sequence=0x%x",
elapsedLogTime(), fullCmd.constData(), flags, token, stateName(state()), nextCommandFlag, qPrintable(cookie.toString()), elapsedLogTime(), fullCmd.constData(), flags, token, stateName(state()), nextCommandFlag,
m_extensionCommandQueue.size(), nextCommandFlag); m_extensionCommandQueue.size(), nextCommandFlag);
m_process.write(fullCmd + '\n'); m_process.write(fullCmd + '\n');
} }
@@ -1547,8 +1506,7 @@ void CdbEngine::updateLocals(bool forNewStackFrame)
const int flags = forNewStackFrame ? LocalsUpdateForNewFrame : 0; const int flags = forNewStackFrame ? LocalsUpdateForNewFrame : 0;
str << blankSeparator << frameIndex; str << blankSeparator << frameIndex;
postExtensionCommand("locals", arguments, 0, postExtensionCommand("locals", arguments, 0,
&CdbEngine::handleLocals, 0, [this, flags](const CdbCommandPtr &r) { handleLocals(r, flags); });
QVariant(flags));
} }
void CdbEngine::selectThread(ThreadId threadId) void CdbEngine::selectThread(ThreadId threadId)
@@ -1559,7 +1517,7 @@ void CdbEngine::selectThread(ThreadId threadId)
threadsHandler()->setCurrentThread(threadId); threadsHandler()->setCurrentThread(threadId);
const QByteArray cmd = '~' + QByteArray::number(threadId.raw()) + " s"; const QByteArray cmd = '~' + QByteArray::number(threadId.raw()) + " s";
postBuiltinCommand(cmd, 0, &CdbEngine::dummyHandler, CommandListStack); postBuiltinCommand(cmd, 0, CB(dummyHandler), CommandListStack);
} }
// Default address range for showing disassembly. // Default address range for showing disassembly.
@@ -1576,7 +1534,6 @@ enum { DisassemblerRange = 512 };
void CdbEngine::fetchDisassembler(DisassemblerAgent *agent) void CdbEngine::fetchDisassembler(DisassemblerAgent *agent)
{ {
QTC_ASSERT(m_accessible, return); QTC_ASSERT(m_accessible, return);
const QVariant cookie = qVariantFromValue<DisassemblerAgent*>(agent);
const Location location = agent->location(); const Location location = agent->location();
if (debug) if (debug)
qDebug() << "CdbEngine::fetchDisassembler 0x" qDebug() << "CdbEngine::fetchDisassembler 0x"
@@ -1585,48 +1542,46 @@ void CdbEngine::fetchDisassembler(DisassemblerAgent *agent)
if (!location.functionName().isEmpty()) { if (!location.functionName().isEmpty()) {
// Resolve function (from stack frame with function and address // Resolve function (from stack frame with function and address
// or just function from editor). // or just function from editor).
postResolveSymbol(location.from(), location.functionName(), cookie); postResolveSymbol(location.from(), location.functionName(), agent);
} else if (location.address()) { } else if (location.address()) {
// No function, display a default range. // No function, display a default range.
postDisassemblerCommand(location.address(), cookie); postDisassemblerCommand(location.address(), agent);
} else { } else {
QTC_ASSERT(false, return); QTC_ASSERT(false, return);
} }
} }
void CdbEngine::postDisassemblerCommand(quint64 address, const QVariant &cookie) void CdbEngine::postDisassemblerCommand(quint64 address, DisassemblerAgent *agent)
{ {
postDisassemblerCommand(address - DisassemblerRange / 2, postDisassemblerCommand(address - DisassemblerRange / 2,
address + DisassemblerRange / 2, cookie); address + DisassemblerRange / 2, agent);
} }
void CdbEngine::postDisassemblerCommand(quint64 address, quint64 endAddress, void CdbEngine::postDisassemblerCommand(quint64 address, quint64 endAddress,
const QVariant &cookie) DisassemblerAgent *agent)
{ {
QByteArray cmd; QByteArray cmd;
ByteArrayInputStream str(cmd); ByteArrayInputStream str(cmd);
str << "u " << hex <<hexPrefixOn << address << ' ' << endAddress; str << "u " << hex <<hexPrefixOn << address << ' ' << endAddress;
postBuiltinCommand(cmd, 0, &CdbEngine::handleDisassembler, 0, cookie); postBuiltinCommand(cmd, 0,
[this, agent](const CdbCommandPtr &r) { handleDisassembler(r, agent); });
} }
void CdbEngine::postResolveSymbol(const QString &module, const QString &function, void CdbEngine::postResolveSymbol(const QString &module, const QString &function,
const QVariant &cookie) DisassemblerAgent *agent)
{ {
QString symbol = module.isEmpty() ? QString(QLatin1Char('*')) : module; QString symbol = module.isEmpty() ? QString(QLatin1Char('*')) : module;
symbol += QLatin1Char('!'); symbol += QLatin1Char('!');
symbol += function; symbol += function;
const QList<quint64> addresses = m_symbolAddressCache.values(symbol); const QList<quint64> addresses = m_symbolAddressCache.values(symbol);
if (addresses.isEmpty()) { if (addresses.isEmpty()) {
QVariantList cookieList;
cookieList << QVariant(symbol) << cookie;
showMessage(QLatin1String("Resolving symbol: ") + symbol + QLatin1String("..."), LogMisc); showMessage(QLatin1String("Resolving symbol: ") + symbol + QLatin1String("..."), LogMisc);
postBuiltinCommand(QByteArray("x ") + symbol.toLatin1(), 0, postBuiltinCommand(QByteArray("x ") + symbol.toLatin1(), 0,
&CdbEngine::handleResolveSymbol, 0, [this, symbol, agent](const CdbCommandPtr &r) { handleResolveSymbol(r, symbol, agent); });
QVariant(cookieList));
} else { } else {
showMessage(QString::fromLatin1("Using cached addresses for %1."). showMessage(QString::fromLatin1("Using cached addresses for %1.").
arg(symbol), LogMisc); arg(symbol), LogMisc);
handleResolveSymbol(addresses, cookie); handleResolveSymbolHelper(addresses, agent);
} }
} }
@@ -1647,15 +1602,13 @@ static inline quint64 resolvedAddress(const QByteArray &line)
return 0; return 0;
} }
void CdbEngine::handleResolveSymbol(const CdbBuiltinCommandPtr &command) void CdbEngine::handleResolveSymbol(const CdbCommandPtr &command, const QString &symbol,
DisassemblerAgent *agent)
{ {
QTC_ASSERT(command->cookie.type() == QVariant::List, return; );
const QVariantList cookieList = command->cookie.toList();
const QString symbol = cookieList.front().toString();
// Insert all matches of (potentially) ambiguous symbols // Insert all matches of (potentially) ambiguous symbols
if (const int size = command->reply.size()) { if (const int size = command->builtinReply.size()) {
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
if (const quint64 address = resolvedAddress(command->reply.at(i))) { if (const quint64 address = resolvedAddress(command->builtinReply.at(i))) {
m_symbolAddressCache.insert(symbol, address); m_symbolAddressCache.insert(symbol, address);
showMessage(QString::fromLatin1("Obtained 0x%1 for %2 (#%3)"). showMessage(QString::fromLatin1("Obtained 0x%1 for %2 (#%3)").
arg(address, 0, 16).arg(symbol).arg(i + 1), LogMisc); arg(address, 0, 16).arg(symbol).arg(i + 1), LogMisc);
@@ -1666,7 +1619,7 @@ void CdbEngine::handleResolveSymbol(const CdbBuiltinCommandPtr &command)
+ QString::fromLatin1(command->joinedReply()), + QString::fromLatin1(command->joinedReply()),
LogError); LogError);
} }
handleResolveSymbol(m_symbolAddressCache.values(symbol), cookieList.back()); handleResolveSymbolHelper(m_symbolAddressCache.values(symbol), agent);
} }
// Find the function address matching needle in a list of function // Find the function address matching needle in a list of function
@@ -1714,52 +1667,46 @@ static inline QString msgAmbiguousFunction(const QString &functionName,
return result; return result;
} }
void CdbEngine::handleResolveSymbol(const QList<quint64> &addresses, const QVariant &cookie) void CdbEngine::handleResolveSymbolHelper(const QList<quint64> &addresses, DisassemblerAgent *agent)
{ {
// Disassembly mode: Determine suitable range containing the // Disassembly mode: Determine suitable range containing the
// agent's address within the function to display. // agent's address within the function to display.
if (cookie.canConvert<DisassemblerAgent*>()) { const quint64 agentAddress = agent->address();
DisassemblerAgent *agent = cookie.value<DisassemblerAgent *>(); quint64 functionAddress = 0;
const quint64 agentAddress = agent->address(); quint64 endAddress = 0;
quint64 functionAddress = 0; if (agentAddress) {
quint64 endAddress = 0; // We have an address from the agent, find closest.
if (agentAddress) { if (const quint64 closest = findClosestFunctionAddress(addresses, agentAddress)) {
// We have an address from the agent, find closest. if (closest <= agentAddress) {
if (const quint64 closest = findClosestFunctionAddress(addresses, agentAddress)) { functionAddress = closest;
if (closest <= agentAddress) { endAddress = agentAddress + DisassemblerRange / 2;
functionAddress = closest;
endAddress = agentAddress + DisassemblerRange / 2;
}
}
} else {
// No agent address, disassembly was started with a function name only.
if (!addresses.isEmpty()) {
functionAddress = addresses.first();
endAddress = functionAddress + DisassemblerRange / 2;
if (addresses.size() > 1)
showMessage(msgAmbiguousFunction(agent->location().functionName(), functionAddress, addresses), LogMisc);
} }
} }
// Disassemble a function, else use default range around agent address } else {
if (functionAddress) { // No agent address, disassembly was started with a function name only.
if (const quint64 remainder = endAddress % 8) if (!addresses.isEmpty()) {
endAddress += 8 - remainder; functionAddress = addresses.first();
postDisassemblerCommand(functionAddress, endAddress, cookie); endAddress = functionAddress + DisassemblerRange / 2;
} else if (agentAddress) { if (addresses.size() > 1)
postDisassemblerCommand(agentAddress, cookie); showMessage(msgAmbiguousFunction(agent->location().functionName(), functionAddress, addresses), LogMisc);
} else {
QTC_ASSERT(false, return);
} }
return; }
} // DisassemblerAgent // Disassemble a function, else use default range around agent address
if (functionAddress) {
if (const quint64 remainder = endAddress % 8)
endAddress += 8 - remainder;
postDisassemblerCommand(functionAddress, endAddress, agent);
} else if (agentAddress) {
postDisassemblerCommand(agentAddress, agent);
} else {
QTC_CHECK(false);
}
} }
// Parse: "00000000`77606060 cc int 3" // Parse: "00000000`77606060 cc int 3"
void CdbEngine::handleDisassembler(const CdbBuiltinCommandPtr &command) void CdbEngine::handleDisassembler(const CdbCommandPtr &command, DisassemblerAgent *agent)
{ {
QTC_ASSERT(command->cookie.canConvert<DisassemblerAgent*>(), return); agent->setContents(parseCdbDisassembler(command->builtinReply));
DisassemblerAgent *agent = qvariant_cast<DisassemblerAgent*>(command->cookie);
agent->setContents(parseCdbDisassembler(command->reply));
} }
void CdbEngine::fetchMemory(MemoryAgent *agent, QObject *editor, quint64 addr, quint64 length) void CdbEngine::fetchMemory(MemoryAgent *agent, QObject *editor, quint64 addr, quint64 length)
@@ -1778,8 +1725,8 @@ void CdbEngine::postFetchMemory(const MemoryViewCookie &cookie)
QByteArray args; QByteArray args;
ByteArrayInputStream str(args); ByteArrayInputStream str(args);
str << cookie.address << ' ' << cookie.length; str << cookie.address << ' ' << cookie.length;
postExtensionCommand("memory", args, 0, &CdbEngine::handleMemory, 0, postExtensionCommand("memory", args, 0,
qVariantFromValue(cookie)); [this, cookie](const CdbCommandPtr &r) { handleMemory(r, cookie); });
} }
void CdbEngine::changeMemory(Internal::MemoryAgent *, QObject *, quint64 addr, const QByteArray &data) void CdbEngine::changeMemory(Internal::MemoryAgent *, QObject *, quint64 addr, const QByteArray &data)
@@ -1793,12 +1740,10 @@ void CdbEngine::changeMemory(Internal::MemoryAgent *, QObject *, quint64 addr, c
} }
} }
void CdbEngine::handleMemory(const CdbExtensionCommandPtr &command) void CdbEngine::handleMemory(const CdbCommandPtr &command, const MemoryViewCookie &memViewCookie)
{ {
QTC_ASSERT(command->cookie.canConvert<MemoryViewCookie>(), return);
const MemoryViewCookie memViewCookie = qvariant_cast<MemoryViewCookie>(command->cookie);
if (command->success && memViewCookie.agent) { if (command->success && memViewCookie.agent) {
const QByteArray data = QByteArray::fromBase64(command->reply); const QByteArray data = QByteArray::fromBase64(command->extensionReply);
if (unsigned(data.size()) == memViewCookie.length) if (unsigned(data.size()) == memViewCookie.length)
memViewCookie.agent->addLazyData(memViewCookie.editorToken, memViewCookie.agent->addLazyData(memViewCookie.editorToken,
memViewCookie.address, data); memViewCookie.address, data);
@@ -1841,11 +1786,11 @@ void CdbEngine::reloadFullStack()
postCommandSequence(CommandListStack); postCommandSequence(CommandListStack);
} }
void CdbEngine::handlePid(const CdbExtensionCommandPtr &reply) void CdbEngine::handlePid(const CdbCommandPtr &reply)
{ {
// Fails for core dumps. // Fails for core dumps.
if (reply->success) if (reply->success)
notifyInferiorPid(reply->reply.toULongLong()); notifyInferiorPid(reply->extensionReply.toULongLong());
if (reply->success || startParameters().startMode == AttachCore) { if (reply->success || startParameters().startMode == AttachCore) {
STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorSetupOk") STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorSetupOk")
notifyInferiorSetupOk(); notifyInferiorSetupOk();
@@ -1857,11 +1802,11 @@ void CdbEngine::handlePid(const CdbExtensionCommandPtr &reply)
} }
} }
void CdbEngine::handleModules(const CdbExtensionCommandPtr &reply) void CdbEngine::handleModules(const CdbCommandPtr &reply)
{ {
if (reply->success) { if (reply->success) {
GdbMi value; GdbMi value;
value.fromString(reply->reply); value.fromString(reply->extensionReply);
if (value.type() == GdbMi::List) { if (value.type() == GdbMi::List) {
ModulesHandler *handler = modulesHandler(); ModulesHandler *handler = modulesHandler();
handler->beginUpdateAll(); handler->beginUpdateAll();
@@ -1878,7 +1823,7 @@ void CdbEngine::handleModules(const CdbExtensionCommandPtr &reply)
handler->endUpdateAll(); handler->endUpdateAll();
} else { } else {
showMessage(QString::fromLatin1("Parse error in modules response."), LogError); showMessage(QString::fromLatin1("Parse error in modules response."), LogError);
qWarning("Parse error in modules response:\n%s", reply->reply.constData()); qWarning("Parse error in modules response:\n%s", reply->extensionReply.constData());
} }
} else { } else {
showMessage(QString::fromLatin1("Failed to determine modules: %1"). showMessage(QString::fromLatin1("Failed to determine modules: %1").
@@ -1888,11 +1833,11 @@ void CdbEngine::handleModules(const CdbExtensionCommandPtr &reply)
} }
void CdbEngine::handleRegisters(const CdbExtensionCommandPtr &reply) void CdbEngine::handleRegistersExt(const CdbCommandPtr &reply)
{ {
if (reply->success) { if (reply->success) {
GdbMi value; GdbMi value;
value.fromString(reply->reply); value.fromString(reply->extensionReply);
if (value.type() == GdbMi::List) { if (value.type() == GdbMi::List) {
RegisterHandler *handler = registerHandler(); RegisterHandler *handler = registerHandler();
foreach (const GdbMi &item, value.children()) { foreach (const GdbMi &item, value.children()) {
@@ -1907,7 +1852,7 @@ void CdbEngine::handleRegisters(const CdbExtensionCommandPtr &reply)
handler->commitUpdates(); handler->commitUpdates();
} else { } else {
showMessage(QString::fromLatin1("Parse error in registers response."), LogError); showMessage(QString::fromLatin1("Parse error in registers response."), LogError);
qWarning("Parse error in registers response:\n%s", reply->reply.constData()); qWarning("Parse error in registers response:\n%s", reply->extensionReply.constData());
} }
} else { } else {
showMessage(QString::fromLatin1("Failed to determine registers: %1"). showMessage(QString::fromLatin1("Failed to determine registers: %1").
@@ -1916,12 +1861,11 @@ void CdbEngine::handleRegisters(const CdbExtensionCommandPtr &reply)
postCommandSequence(reply->commandSequence); postCommandSequence(reply->commandSequence);
} }
void CdbEngine::handleLocals(const CdbExtensionCommandPtr &reply) void CdbEngine::handleLocals(const CdbCommandPtr &reply, int flags)
{ {
const int flags = reply->cookie.toInt();
if (reply->success) { if (reply->success) {
if (boolSetting(VerboseLog)) if (boolSetting(VerboseLog))
showMessage(QLatin1String("Locals: ") + QString::fromLatin1(reply->reply), LogDebug); showMessage(QLatin1String("Locals: ") + QString::fromLatin1(reply->extensionReply), LogDebug);
QList<WatchData> watchData; QList<WatchData> watchData;
WatchHandler *handler = watchHandler(); WatchHandler *handler = watchHandler();
if (flags & LocalsUpdateForNewFrame) { if (flags & LocalsUpdateForNewFrame) {
@@ -1929,7 +1873,7 @@ void CdbEngine::handleLocals(const CdbExtensionCommandPtr &reply)
watchData.append(*handler->findData("watch")); watchData.append(*handler->findData("watch"));
} }
GdbMi root; GdbMi root;
root.fromString(reply->reply); root.fromString(reply->extensionReply);
QTC_ASSERT(root.isList(), return); QTC_ASSERT(root.isList(), return);
if (debugLocals) if (debugLocals)
qDebug() << root.toString(true, 4); qDebug() << root.toString(true, 4);
@@ -1965,7 +1909,7 @@ void CdbEngine::handleLocals(const CdbExtensionCommandPtr &reply)
} }
} }
void CdbEngine::handleExpandLocals(const CdbExtensionCommandPtr &reply) void CdbEngine::handleExpandLocals(const CdbCommandPtr &reply)
{ {
if (!reply->success) if (!reply->success)
showMessage(QString::fromLatin1(reply->errorMessage), LogError); showMessage(QString::fromLatin1(reply->errorMessage), LogError);
@@ -2098,7 +2042,7 @@ unsigned CdbEngine::examineStopReason(const GdbMi &stopReason,
QString::number(threadId)); QString::number(threadId));
ConditionalBreakPointCookie cookie(id); ConditionalBreakPointCookie cookie(id);
cookie.stopReason = stopReason; cookie.stopReason = stopReason;
evaluateExpression(parameters.condition, qVariantFromValue(cookie)); evaluateExpression(parameters.condition, cookie);
return StopReportLog; return StopReportLog;
} }
} else { } else {
@@ -2260,8 +2204,8 @@ void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointT
executeStepOut(); executeStepOut();
return; return;
case ParseStackWow64: case ParseStackWow64:
postBuiltinCommand("lm m wow64", 0, &CdbEngine::handleCheckWow64, postBuiltinCommand("lm m wow64", 0,
0, qVariantFromValue(stack)); [this, stack](const CdbCommandPtr &r) { handleCheckWow64(r, stack); });
break; break;
} }
} else { } else {
@@ -2290,9 +2234,9 @@ void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointT
showStoppedByExceptionMessageBox(exceptionBoxMessage); showStoppedByExceptionMessageBox(exceptionBoxMessage);
} }
void CdbEngine::handleBreakInsert(const CdbBuiltinCommandPtr &cmd) void CdbEngine::handleBreakInsert(const CdbCommandPtr &cmd)
{ {
const QList<QByteArray> &reply = cmd->reply; const QList<QByteArray> &reply = cmd->builtinReply;
if (reply.isEmpty()) if (reply.isEmpty())
return; return;
foreach (const QByteArray &line, reply) foreach (const QByteArray &line, reply)
@@ -2354,49 +2298,47 @@ void CdbEngine::handleBreakInsert(const CdbBuiltinCommandPtr &cmd)
attemptBreakpointSynchronization(); attemptBreakpointSynchronization();
} }
void CdbEngine::handleCheckWow64(const CdbBuiltinCommandPtr &cmd) void CdbEngine::handleCheckWow64(const CdbCommandPtr &cmd, const GdbMi &stack)
{ {
// Using the lm (list modules) command to check if there is a 32 bit subsystem in this debuggee. // Using the lm (list modules) command to check if there is a 32 bit subsystem in this debuggee.
// expected reply if there is a 32 bit stack: // expected reply if there is a 32 bit stack:
// start end module name // start end module name
// 00000000`77490000 00000000`774d5000 wow64 (deferred) // 00000000`77490000 00000000`774d5000 wow64 (deferred)
if (cmd->reply.value(1).contains("wow64")) { if (cmd->builtinReply.value(1).contains("wow64")) {
postBuiltinCommand("k", 0, &CdbEngine::ensureUsing32BitStackInWow64, 0, cmd->cookie); postBuiltinCommand("k", 0,
[this, stack](const CdbCommandPtr &r) { ensureUsing32BitStackInWow64(r, stack); });
return; return;
} }
m_wow64State = noWow64Stack; m_wow64State = noWow64Stack;
if (cmd->cookie.canConvert<GdbMi>()) parseStackTrace(stack, false);
parseStackTrace(qvariant_cast<GdbMi>(cmd->cookie), false);
} }
void CdbEngine::ensureUsing32BitStackInWow64(const CdbEngine::CdbBuiltinCommandPtr &cmd) void CdbEngine::ensureUsing32BitStackInWow64(const CdbEngine::CdbCommandPtr &cmd, const GdbMi &stack)
{ {
// Parsing the header of the stack output to check which bitness // Parsing the header of the stack output to check which bitness
// the cdb is currently using. // the cdb is currently using.
foreach (const QByteArray &line, cmd->reply) { foreach (const QByteArray &line, cmd->builtinReply) {
if (!line.startsWith("Child")) if (!line.startsWith("Child"))
continue; continue;
if (line.startsWith("ChildEBP")) { if (line.startsWith("ChildEBP")) {
m_wow64State = wow64Stack32Bit; m_wow64State = wow64Stack32Bit;
if (cmd->cookie.canConvert<GdbMi>()) parseStackTrace(stack, false);
parseStackTrace(qvariant_cast<GdbMi>(cmd->cookie), false);
return; return;
} else if (line.startsWith("Child-SP")) { } else if (line.startsWith("Child-SP")) {
m_wow64State = wow64Stack64Bit; m_wow64State = wow64Stack64Bit;
postBuiltinCommand("!wow64exts.sw", 0, &CdbEngine::handleSwitchWow64Stack); postBuiltinCommand("!wow64exts.sw", 0, CB(handleSwitchWow64Stack));
return; return;
} }
} }
m_wow64State = noWow64Stack; m_wow64State = noWow64Stack;
if (cmd->cookie.canConvert<GdbMi>()) parseStackTrace(stack, false);
parseStackTrace(qvariant_cast<GdbMi>(cmd->cookie), false);
} }
void CdbEngine::handleSwitchWow64Stack(const CdbEngine::CdbBuiltinCommandPtr &cmd) void CdbEngine::handleSwitchWow64Stack(const CdbEngine::CdbCommandPtr &cmd)
{ {
if (cmd->reply.first() == "Switched to 32bit mode") if (cmd->builtinReply.first() == "Switched to 32bit mode")
m_wow64State = wow64Stack32Bit; m_wow64State = wow64Stack32Bit;
else if (cmd->reply.first() == "Switched to 64bit mode") else if (cmd->builtinReply.first() == "Switched to 64bit mode")
m_wow64State = wow64Stack64Bit; m_wow64State = wow64Stack64Bit;
else else
m_wow64State = noWow64Stack; m_wow64State = noWow64Stack;
@@ -2488,10 +2430,10 @@ void CdbEngine::handleExtensionMessage(char t, int token, const QByteArray &what
const int index = indexOfCommand(m_extensionCommandQueue, token); const int index = indexOfCommand(m_extensionCommandQueue, token);
if (index != -1) { if (index != -1) {
// Did the command finish? Take off queue and complete, invoke CB // Did the command finish? Take off queue and complete, invoke CB
const CdbExtensionCommandPtr command = m_extensionCommandQueue.takeAt(index); const CdbCommandPtr command = m_extensionCommandQueue.takeAt(index);
if (t == 'R') { if (t == 'R') {
command->success = true; command->success = true;
command->reply = message; command->extensionReply = message;
} else { } else {
command->success = false; command->success = false;
command->errorMessage = message; command->errorMessage = message;
@@ -2500,7 +2442,7 @@ void CdbEngine::handleExtensionMessage(char t, int token, const QByteArray &what
qDebug("### Completed extension command '%s', token=%d, pending=%d", qDebug("### Completed extension command '%s', token=%d, pending=%d",
command->command.constData(), command->token, m_extensionCommandQueue.size()); command->command.constData(), command->token, m_extensionCommandQueue.size());
if (command->handler) if (command->handler)
(this->*(command->handler))(command); command->handler(command);
return; return;
} }
} }
@@ -2562,8 +2504,6 @@ void CdbEngine::handleExtensionMessage(char t, int token, const QByteArray &what
} }
return; return;
} }
return;
} }
// Check for a CDB prompt '0:000> ' ('process:thread> ')..no regexps for QByteArray... // Check for a CDB prompt '0:000> ' ('process:thread> ')..no regexps for QByteArray...
@@ -2652,21 +2592,21 @@ void CdbEngine::parseOutputLine(QByteArray line)
// command, trigger handler and finish, else append to its output. // command, trigger handler and finish, else append to its output.
if (m_currentBuiltinCommandIndex != -1) { if (m_currentBuiltinCommandIndex != -1) {
QTC_ASSERT(!isStartToken && m_currentBuiltinCommandIndex < m_builtinCommandQueue.size(), return; ); QTC_ASSERT(!isStartToken && m_currentBuiltinCommandIndex < m_builtinCommandQueue.size(), return; );
const CdbBuiltinCommandPtr &currentCommand = m_builtinCommandQueue.at(m_currentBuiltinCommandIndex); const CdbCommandPtr &currentCommand = m_builtinCommandQueue.at(m_currentBuiltinCommandIndex);
if (isCommandToken) { if (isCommandToken) {
// Did the command finish? Invoke callback and remove from queue. // Did the command finish? Invoke callback and remove from queue.
if (debug) if (debug)
qDebug("### Completed builtin command '%s', token=%d, %d lines, pending=%d", qDebug("### Completed builtin command '%s', token=%d, %d lines, pending=%d",
currentCommand->command.constData(), currentCommand->token, currentCommand->command.constData(), currentCommand->token,
currentCommand->reply.size(), m_builtinCommandQueue.size() - 1); currentCommand->builtinReply.size(), m_builtinCommandQueue.size() - 1);
QTC_ASSERT(token == currentCommand->token, return; ); QTC_ASSERT(token == currentCommand->token, return; );
if (currentCommand->handler) if (currentCommand->handler)
(this->*(currentCommand->handler))(currentCommand); currentCommand->handler(currentCommand);
m_builtinCommandQueue.removeAt(m_currentBuiltinCommandIndex); m_builtinCommandQueue.removeAt(m_currentBuiltinCommandIndex);
m_currentBuiltinCommandIndex = -1; m_currentBuiltinCommandIndex = -1;
} else { } else {
// Record output of current command // Record output of current command
currentCommand->reply.push_back(line); currentCommand->builtinReply.push_back(line);
} }
return; return;
} // m_currentCommandIndex } // m_currentCommandIndex
@@ -2675,7 +2615,7 @@ void CdbEngine::parseOutputLine(QByteArray line)
const int index = indexOfCommand(m_builtinCommandQueue, token); const int index = indexOfCommand(m_builtinCommandQueue, token);
QTC_ASSERT(isStartToken && index != -1, return; ); QTC_ASSERT(isStartToken && index != -1, return; );
m_currentBuiltinCommandIndex = index; m_currentBuiltinCommandIndex = index;
const CdbBuiltinCommandPtr &currentCommand = m_builtinCommandQueue.at(m_currentBuiltinCommandIndex); const CdbCommandPtr &currentCommand = m_builtinCommandQueue.at(m_currentBuiltinCommandIndex);
if (debug) if (debug)
qDebug("### Gathering output for '%s' token %d", currentCommand->command.constData(), currentCommand->token); qDebug("### Gathering output for '%s' token %d", currentCommand->command.constData(), currentCommand->token);
return; return;
@@ -2907,11 +2847,11 @@ void CdbEngine::attemptBreakpointSynchronization()
response.lineNumber = lineCorrection->fixLineNumber(parameters.fileName, parameters.lineNumber); response.lineNumber = lineCorrection->fixLineNumber(parameters.fileName, parameters.lineNumber);
postBuiltinCommand( postBuiltinCommand(
cdbAddBreakpointCommand(response, m_sourcePathMappings, id, false), 0, cdbAddBreakpointCommand(response, m_sourcePathMappings, id, false), 0,
&CdbEngine::handleBreakInsert); CB(handleBreakInsert));
} else { } else {
postBuiltinCommand( postBuiltinCommand(
cdbAddBreakpointCommand(parameters, m_sourcePathMappings, id, false), 0, cdbAddBreakpointCommand(parameters, m_sourcePathMappings, id, false), 0,
&CdbEngine::handleBreakInsert); CB(handleBreakInsert));
} }
if (!parameters.enabled) if (!parameters.enabled)
postCommand("bd " + QByteArray::number(breakPointIdToCdbId(id)), 0); postCommand("bd " + QByteArray::number(breakPointIdToCdbId(id)), 0);
@@ -2944,7 +2884,7 @@ void CdbEngine::attemptBreakpointSynchronization()
postCommand(cdbClearBreakpointCommand(id), 0); postCommand(cdbClearBreakpointCommand(id), 0);
postBuiltinCommand( postBuiltinCommand(
cdbAddBreakpointCommand(parameters, m_sourcePathMappings, id, false), 0, cdbAddBreakpointCommand(parameters, m_sourcePathMappings, id, false), 0,
&CdbEngine::handleBreakInsert); CB(handleBreakInsert));
m_pendingBreakpointMap.insert(id, response); m_pendingBreakpointMap.insert(id, response);
} }
bp.notifyBreakpointChangeOk(); bp.notifyBreakpointChangeOk();
@@ -3084,10 +3024,10 @@ unsigned CdbEngine::parseStackTrace(const GdbMi &data, bool sourceStepInto)
void CdbEngine::loadAdditionalQmlStack() void CdbEngine::loadAdditionalQmlStack()
{ {
postExtensionCommand("qmlstack", QByteArray(), 0, &CdbEngine::handleAdditionalQmlStack); postExtensionCommand("qmlstack", QByteArray(), 0, CB(handleAdditionalQmlStack));
} }
void CdbEngine::handleAdditionalQmlStack(const CdbExtensionCommandPtr &reply) void CdbEngine::handleAdditionalQmlStack(const CdbCommandPtr &reply)
{ {
QString errorMessage; QString errorMessage;
do { do {
@@ -3096,7 +3036,7 @@ void CdbEngine::handleAdditionalQmlStack(const CdbExtensionCommandPtr &reply)
break; break;
} }
GdbMi stackGdbMi; GdbMi stackGdbMi;
stackGdbMi.fromString(reply->reply); stackGdbMi.fromString(reply->extensionReply);
if (!stackGdbMi.isValid()) { if (!stackGdbMi.isValid()) {
errorMessage = QLatin1String("GDBMI parser error"); errorMessage = QLatin1String("GDBMI parser error");
break; break;
@@ -3126,14 +3066,14 @@ void CdbEngine::mergeStartParametersSourcePathMap()
} }
} }
void CdbEngine::handleStackTrace(const CdbExtensionCommandPtr &command) void CdbEngine::handleStackTrace(const CdbCommandPtr &command)
{ {
if (command->success) { if (command->success) {
GdbMi data; GdbMi stack;
data.fromString(command->reply); stack.fromString(command->extensionReply);
if (parseStackTrace(data, false) == ParseStackWow64) { if (parseStackTrace(stack, false) == ParseStackWow64) {
postBuiltinCommand("lm m wow64", 0, &CdbEngine::handleCheckWow64, postBuiltinCommand("lm m wow64", 0,
0, qVariantFromValue(data)); [this, stack](const CdbCommandPtr &r) { handleCheckWow64(r, stack); });
} }
postCommandSequence(command->commandSequence); postCommandSequence(command->commandSequence);
} else { } else {
@@ -3141,40 +3081,38 @@ void CdbEngine::handleStackTrace(const CdbExtensionCommandPtr &command)
} }
} }
void CdbEngine::handleExpression(const CdbExtensionCommandPtr &command) void CdbEngine::handleExpression(const CdbCommandPtr &command, const ConditionalBreakPointCookie &cookie)
{ {
int value = 0; int value = 0;
if (command->success) if (command->success)
value = command->reply.toInt(); value = command->extensionReply.toInt();
else else
showMessage(QString::fromLocal8Bit(command->errorMessage), LogError); showMessage(QString::fromLocal8Bit(command->errorMessage), LogError);
// Is this a conditional breakpoint? // Is this a conditional breakpoint?
if (command->cookie.isValid() && command->cookie.canConvert<ConditionalBreakPointCookie>()) { const QString message = value ?
const ConditionalBreakPointCookie cookie = qvariant_cast<ConditionalBreakPointCookie>(command->cookie); tr("Value %1 obtained from evaluating the condition of breakpoint %2, stopping.").
const QString message = value ? arg(value).arg(cookie.id.toString()) :
tr("Value %1 obtained from evaluating the condition of breakpoint %2, stopping."). tr("Value 0 obtained from evaluating the condition of breakpoint %1, continuing.").
arg(value).arg(cookie.id.toString()) : arg(cookie.id.toString());
tr("Value 0 obtained from evaluating the condition of breakpoint %1, continuing."). showMessage(message, LogMisc);
arg(cookie.id.toString()); // Stop if evaluation is true, else continue
showMessage(message, LogMisc); if (value)
// Stop if evaluation is true, else continue processStop(cookie.stopReason, true);
if (value) else
processStop(cookie.stopReason, true); doContinueInferior();
else
doContinueInferior();
}
} }
void CdbEngine::evaluateExpression(QByteArray exp, const QVariant &cookie) void CdbEngine::evaluateExpression(QByteArray exp, const ConditionalBreakPointCookie &cookie)
{ {
if (exp.contains(' ') && !exp.startsWith('"')) { if (exp.contains(' ') && !exp.startsWith('"')) {
exp.prepend('"'); exp.prepend('"');
exp.append('"'); exp.append('"');
} }
postExtensionCommand("expression", exp, 0, &CdbEngine::handleExpression, 0, cookie); postExtensionCommand("expression", exp, 0,
[this, cookie](const CdbCommandPtr &r) { handleExpression(r, cookie); });
} }
void CdbEngine::dummyHandler(const CdbBuiltinCommandPtr &command) void CdbEngine::dummyHandler(const CdbCommandPtr &command)
{ {
postCommandSequence(command->commandSequence); postCommandSequence(command->commandSequence);
} }
@@ -3188,30 +3126,30 @@ void CdbEngine::postCommandSequence(unsigned mask)
if (!mask) if (!mask)
return; return;
if (mask & CommandListThreads) { if (mask & CommandListThreads) {
postExtensionCommand("threads", QByteArray(), 0, &CdbEngine::handleThreads, mask & ~CommandListThreads); postExtensionCommand("threads", QByteArray(), 0, CB(handleThreads), mask & ~CommandListThreads);
return; return;
} }
if (mask & CommandListStack) { if (mask & CommandListStack) {
postExtensionCommand("stack", "unlimited", 0, &CdbEngine::handleStackTrace, mask & ~CommandListStack); postExtensionCommand("stack", "unlimited", 0, CB(handleStackTrace), mask & ~CommandListStack);
return; return;
} }
if (mask & CommandListRegisters) { if (mask & CommandListRegisters) {
QTC_ASSERT(threadsHandler()->currentThreadIndex() >= 0, return); QTC_ASSERT(threadsHandler()->currentThreadIndex() >= 0, return);
postExtensionCommand("registers", QByteArray(), 0, &CdbEngine::handleRegisters, mask & ~CommandListRegisters); postExtensionCommand("registers", QByteArray(), 0, CB(handleRegistersExt), mask & ~CommandListRegisters);
return; return;
} }
if (mask & CommandListModules) { if (mask & CommandListModules) {
postExtensionCommand("modules", QByteArray(), 0, &CdbEngine::handleModules, mask & ~CommandListModules); postExtensionCommand("modules", QByteArray(), 0, CB(handleModules), mask & ~CommandListModules);
return; return;
} }
if (mask & CommandListBreakPoints) { if (mask & CommandListBreakPoints) {
postExtensionCommand("breakpoints", QByteArray("-v"), 0, postExtensionCommand("breakpoints", QByteArray("-v"), 0,
&CdbEngine::handleBreakPoints, mask & ~CommandListBreakPoints); CB(handleBreakPoints), mask & ~CommandListBreakPoints);
return; return;
} }
} }
void CdbEngine::handleWidgetAt(const CdbExtensionCommandPtr &reply) void CdbEngine::handleWidgetAt(const CdbCommandPtr &reply)
{ {
bool success = false; bool success = false;
QString message; QString message;
@@ -3221,7 +3159,7 @@ void CdbEngine::handleWidgetAt(const CdbExtensionCommandPtr &reply)
break; break;
} }
// Should be "namespace::QWidget:0x555" // Should be "namespace::QWidget:0x555"
QString watchExp = QString::fromLatin1(reply->reply); QString watchExp = QString::fromLatin1(reply->extensionReply);
const int sepPos = watchExp.lastIndexOf(QLatin1Char(':')); const int sepPos = watchExp.lastIndexOf(QLatin1Char(':'));
if (sepPos == -1) { if (sepPos == -1) {
message = QString::fromLatin1("Invalid output: %1").arg(watchExp); message = QString::fromLatin1("Invalid output: %1").arg(watchExp);
@@ -3261,16 +3199,16 @@ static inline void formatCdbBreakPointResponse(BreakpointModelId id, const Break
str << '\n'; str << '\n';
} }
void CdbEngine::handleBreakPoints(const CdbExtensionCommandPtr &reply) void CdbEngine::handleBreakPoints(const CdbCommandPtr &reply)
{ {
if (debugBreakpoints) if (debugBreakpoints)
qDebug("CdbEngine::handleBreakPoints: success=%d: %s", reply->success, reply->reply.constData()); qDebug("CdbEngine::handleBreakPoints: success=%d: %s", reply->success, reply->extensionReply.constData());
if (!reply->success) { if (!reply->success) {
showMessage(QString::fromLatin1(reply->errorMessage), LogError); showMessage(QString::fromLatin1(reply->errorMessage), LogError);
return; return;
} }
GdbMi value; GdbMi value;
value.fromString(reply->reply); value.fromString(reply->extensionReply);
if (value.type() != GdbMi::List) { if (value.type() != GdbMi::List) {
showMessage(QString::fromLatin1("Unabled to parse breakpoints reply"), LogError); showMessage(QString::fromLatin1("Unabled to parse breakpoints reply"), LogError);
return; return;
@@ -3364,7 +3302,7 @@ void CdbEngine::postWidgetAtCommand()
QByteArray arguments = QByteArray::number(m_watchPointX); QByteArray arguments = QByteArray::number(m_watchPointX);
arguments.append(' '); arguments.append(' ');
arguments.append(QByteArray::number(m_watchPointY)); arguments.append(QByteArray::number(m_watchPointY));
postExtensionCommand("widgetat", arguments, 0, &CdbEngine::handleWidgetAt, 0); postExtensionCommand("widgetat", arguments, 0, CB(handleWidgetAt));
} }
void CdbEngine::handleCustomSpecialStop(const QVariant &v) void CdbEngine::handleCustomSpecialStop(const QVariant &v)

View File

@@ -42,14 +42,16 @@
#include <QVariant> #include <QVariant>
#include <QTime> #include <QTime>
#include <functional>
namespace Utils { class ConsoleProcess; } namespace Utils { class ConsoleProcess; }
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
class DisassemblerAgent; class DisassemblerAgent;
struct CdbBuiltinCommand; struct CdbCommand;
struct CdbExtensionCommand;
struct MemoryViewCookie; struct MemoryViewCookie;
struct ConditionalBreakPointCookie;
class ByteArrayInputStream; class ByteArrayInputStream;
class GdbMi; class GdbMi;
@@ -68,10 +70,8 @@ public:
CommandListBreakPoints = 0x10 CommandListBreakPoints = 0x10
}; };
typedef QSharedPointer<CdbBuiltinCommand> CdbBuiltinCommandPtr; typedef QSharedPointer<CdbCommand> CdbCommandPtr;
typedef QSharedPointer<CdbExtensionCommand> CdbExtensionCommandPtr; typedef std::function<void(const CdbCommandPtr &)> CommandHandler;
typedef void (CdbEngine::*BuiltinCommandHandler)(const CdbBuiltinCommandPtr &);
typedef void (CdbEngine::*ExtensionCommandHandler)(const CdbExtensionCommandPtr &);
CdbEngine(const DebuggerStartParameters &sp); CdbEngine(const DebuggerStartParameters &sp);
~CdbEngine(); ~CdbEngine();
@@ -139,16 +139,14 @@ private slots:
void postCommand(const QByteArray &cmd, unsigned flags); void postCommand(const QByteArray &cmd, unsigned flags);
void postBuiltinCommand(const QByteArray &cmd, void postBuiltinCommand(const QByteArray &cmd,
unsigned flags, unsigned flags,
BuiltinCommandHandler handler, CommandHandler handler,
unsigned nextCommandFlag = 0, unsigned nextCommandFlag = 0);
const QVariant &cookie = QVariant());
void postExtensionCommand(const QByteArray &cmd, void postExtensionCommand(const QByteArray &cmd,
const QByteArray &arguments, const QByteArray &arguments,
unsigned flags, unsigned flags,
ExtensionCommandHandler handler, CommandHandler handler,
unsigned nextCommandFlag = 0, unsigned nextCommandFlag = 0);
const QVariant &cookie = QVariant());
void postCommandSequence(unsigned mask); void postCommandSequence(unsigned mask);
void operateByInstructionTriggered(bool); void operateByInstructionTriggered(bool);
@@ -212,41 +210,41 @@ private:
void postWidgetAtCommand(); void postWidgetAtCommand();
void handleCustomSpecialStop(const QVariant &v); void handleCustomSpecialStop(const QVariant &v);
void postFetchMemory(const MemoryViewCookie &c); void postFetchMemory(const MemoryViewCookie &c);
inline void postDisassemblerCommand(quint64 address, const QVariant &cookie = QVariant()); inline void postDisassemblerCommand(quint64 address, DisassemblerAgent *agent);
void postDisassemblerCommand(quint64 address, quint64 endAddress, void postDisassemblerCommand(quint64 address, quint64 endAddress,
const QVariant &cookie = QVariant()); DisassemblerAgent *agent);
void postResolveSymbol(const QString &module, const QString &function, void postResolveSymbol(const QString &module, const QString &function,
const QVariant &cookie = QVariant()); DisassemblerAgent *agent);
void evaluateExpression(QByteArray exp, const QVariant &cookie = QVariant()); void evaluateExpression(QByteArray exp, const ConditionalBreakPointCookie &cookie);
// Builtin commands // Builtin commands
void dummyHandler(const CdbBuiltinCommandPtr &); void dummyHandler(const CdbCommandPtr &);
void handleStackTrace(const CdbExtensionCommandPtr &); void handleStackTrace(const CdbCommandPtr &);
void handleRegisters(const CdbBuiltinCommandPtr &); void handleRegisters(const CdbCommandPtr &);
void handleDisassembler(const CdbBuiltinCommandPtr &); void handleDisassembler(const CdbCommandPtr &, DisassemblerAgent *agent);
void handleJumpToLineAddressResolution(const CdbBuiltinCommandPtr &); void handleJumpToLineAddressResolution(const CdbCommandPtr &, const ContextData &context);
void handleExpression(const CdbExtensionCommandPtr &); void handleExpression(const CdbCommandPtr &, const ConditionalBreakPointCookie &cookie);
void handleResolveSymbol(const CdbBuiltinCommandPtr &command); void handleResolveSymbol(const CdbCommandPtr &command, const QString &symbol, DisassemblerAgent *agent);
void handleResolveSymbol(const QList<quint64> &addresses, const QVariant &cookie); void handleResolveSymbolHelper(const QList<quint64> &addresses, DisassemblerAgent *agent);
void handleBreakInsert(const CdbBuiltinCommandPtr &cmd); void handleBreakInsert(const CdbCommandPtr &cmd);
void handleCheckWow64(const CdbBuiltinCommandPtr &cmd); void handleCheckWow64(const CdbCommandPtr &cmd, const GdbMi &stack);
void ensureUsing32BitStackInWow64(const CdbBuiltinCommandPtr &cmd); void ensureUsing32BitStackInWow64(const CdbCommandPtr &cmd, const GdbMi &stack);
void handleSwitchWow64Stack(const CdbBuiltinCommandPtr &cmd); void handleSwitchWow64Stack(const CdbCommandPtr &cmd);
void jumpToAddress(quint64 address); void jumpToAddress(quint64 address);
void handleCreateFullBackTrace(const CdbBuiltinCommandPtr &cmd); void handleCreateFullBackTrace(const CdbCommandPtr &cmd);
// Extension commands // Extension commands
void handleThreads(const CdbExtensionCommandPtr &); void handleThreads(const CdbCommandPtr &);
void handlePid(const CdbExtensionCommandPtr &reply); void handlePid(const CdbCommandPtr &reply);
void handleLocals(const CdbExtensionCommandPtr &reply); void handleLocals(const CdbCommandPtr &reply, int flags);
void handleAddWatch(const CdbExtensionCommandPtr &reply); void handleAddWatch(const CdbCommandPtr &reply, WatchData item);
void handleExpandLocals(const CdbExtensionCommandPtr &reply); void handleExpandLocals(const CdbCommandPtr &reply);
void handleRegisters(const CdbExtensionCommandPtr &reply); void handleRegistersExt(const CdbCommandPtr &reply);
void handleModules(const CdbExtensionCommandPtr &reply); void handleModules(const CdbCommandPtr &reply);
void handleMemory(const CdbExtensionCommandPtr &); void handleMemory(const CdbCommandPtr &, const MemoryViewCookie &memViewCookie);
void handleWidgetAt(const CdbExtensionCommandPtr &); void handleWidgetAt(const CdbCommandPtr &);
void handleBreakPoints(const CdbExtensionCommandPtr &); void handleBreakPoints(const CdbCommandPtr &);
void handleBreakPoints(const GdbMi &value); void handleBreakPoints(const GdbMi &value);
void handleAdditionalQmlStack(const CdbExtensionCommandPtr &); void handleAdditionalQmlStack(const CdbCommandPtr &);
NormalizedSourceFileName sourceMapNormalizeFileNameFromDebugger(const QString &f); NormalizedSourceFileName sourceMapNormalizeFileNameFromDebugger(const QString &f);
void updateLocalVariable(const QByteArray &iname); void updateLocalVariable(const QByteArray &iname);
void updateLocals(bool forNewStackFrame = false); void updateLocals(bool forNewStackFrame = false);
@@ -266,9 +264,9 @@ private:
SpecialStopMode m_specialStopMode; SpecialStopMode m_specialStopMode;
ProjectExplorer::DeviceProcessSignalOperation::Ptr m_signalOperation; ProjectExplorer::DeviceProcessSignalOperation::Ptr m_signalOperation;
int m_nextCommandToken; int m_nextCommandToken;
QList<CdbBuiltinCommandPtr> m_builtinCommandQueue; QList<CdbCommandPtr> m_builtinCommandQueue;
int m_currentBuiltinCommandIndex; //!< Current command whose output is recorded. int m_currentBuiltinCommandIndex; //!< Current command whose output is recorded.
QList<CdbExtensionCommandPtr> m_extensionCommandQueue; QList<CdbCommandPtr> m_extensionCommandQueue;
QMap<QString, NormalizedSourceFileName> m_normalizedFileCache; QMap<QString, NormalizedSourceFileName> m_normalizedFileCache;
const QByteArray m_extensionCommandPrefixBA; //!< Library name used as prefix const QByteArray m_extensionCommandPrefixBA; //!< Library name used as prefix
bool m_operateByInstructionPending; //!< Creator operate by instruction action changed. bool m_operateByInstructionPending; //!< Creator operate by instruction action changed.

View File

@@ -17,7 +17,7 @@ QtcPlugin {
Depends { name: "ProjectExplorer" } Depends { name: "ProjectExplorer" }
Depends { name: "TextEditor" } Depends { name: "TextEditor" }
cpp.includePaths: base.concat(["../../shared/registryaccess"]) cpp.includePaths: base.concat([project.sharedSourcesDir + "/registryaccess"])
pluginRecommends: [ pluginRecommends: [
"CppEditor" "CppEditor"
@@ -214,7 +214,7 @@ QtcPlugin {
Group { Group {
name: "RegistryAccess" name: "RegistryAccess"
condition: qbs.targetOS.contains("windows") condition: qbs.targetOS.contains("windows")
prefix: "../../shared/registryaccess/" prefix: project.sharedSourcesDir + "/registryaccess/"
files: [ files: [
"registryaccess.cpp", "registryaccess.cpp",
"registryaccess.h", "registryaccess.h",

View File

@@ -233,7 +233,7 @@ void GdbMi::parseTuple_helper(const char *&from, const char *to)
//qDebug() << "\n=======\n" << qPrintable(child.toString()) << "\n========\n"; //qDebug() << "\n=======\n" << qPrintable(child.toString()) << "\n========\n";
if (!child.isValid()) if (!child.isValid())
return; return;
m_children += child; m_children.push_back(child);
skipCommas(from, to); skipCommas(from, to);
} }
} }
@@ -253,7 +253,7 @@ void GdbMi::parseList(const char *&from, const char *to)
GdbMi child; GdbMi child;
child.parseResultOrValue(from, to); child.parseResultOrValue(from, to);
if (child.isValid()) if (child.isValid())
m_children += child; m_children.push_back(child);
skipCommas(from, to); skipCommas(from, to);
} }
} }
@@ -265,7 +265,7 @@ static QByteArray ind(int indent)
void GdbMi::dumpChildren(QByteArray * str, bool multiline, int indent) const void GdbMi::dumpChildren(QByteArray * str, bool multiline, int indent) const
{ {
for (int i = 0; i < m_children.size(); ++i) { for (size_t i = 0; i < m_children.size(); ++i) {
if (i != 0) { if (i != 0) {
*str += ','; *str += ',';
if (multiline) if (multiline)
@@ -743,30 +743,6 @@ void DebuggerCommand::argHelper(const char *name, const QByteArray &data)
args.append(","); args.append(",");
} }
QByteArray DebuggerCommand::toData(const QList<QByteArray> &value)
{
QByteArray res;
foreach (const QByteArray &item, value) {
if (!res.isEmpty())
res.append(',');
res += item;
}
return '[' + res + ']';
}
QByteArray DebuggerCommand::toData(const QHash<QByteArray, QByteArray> &value)
{
QByteArray res;
QHashIterator<QByteArray, QByteArray> it(value);
while (it.hasNext()) {
it.next();
if (!res.isEmpty())
res.append(',');
res += '"' + it.key() + "\":" + it.value();
}
return '{' + res + '}';
}
void DebuggerCommand::arg(const char *name, int value) void DebuggerCommand::arg(const char *name, int value)
{ {
argHelper(name, QByteArray::number(value)); argHelper(name, QByteArray::number(value));

View File

@@ -31,9 +31,11 @@
#ifndef DEBUGGER_PROTOCOL_H #ifndef DEBUGGER_PROTOCOL_H
#define DEBUGGER_PROTOCOL_H #define DEBUGGER_PROTOCOL_H
#include <QTime> #include <QByteArray>
#include <QString>
#include <functional> #include <functional>
#include <vector>
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
@@ -67,13 +69,10 @@ public:
void beginGroup(const char *name = 0); void beginGroup(const char *name = 0);
void endGroup(); void endGroup();
static QByteArray toData(const QList<QByteArray> &value);
static QByteArray toData(const QHash<QByteArray, QByteArray> &value);
QByteArray function; QByteArray function;
QByteArray args; QByteArray args;
Callback callback; Callback callback;
QTime postTime; uint postTime; // msecsSinceStartOfDay
int flags; int flags;
private: private:
@@ -137,7 +136,7 @@ public:
QByteArray m_name; QByteArray m_name;
QByteArray m_data; QByteArray m_data;
QList<GdbMi> m_children; std::vector<GdbMi> m_children;
enum Type { enum Type {
Invalid, Invalid,
@@ -159,7 +158,7 @@ public:
inline QByteArray data() const { return m_data; } inline QByteArray data() const { return m_data; }
inline const QList<GdbMi> &children() const { return m_children; } inline const std::vector<GdbMi> &children() const { return m_children; }
inline int childCount() const { return m_children.size(); } inline int childCount() const { return m_children.size(); }
const GdbMi &childAt(int index) const { return m_children[index]; } const GdbMi &childAt(int index) const { return m_children[index]; }

View File

@@ -420,7 +420,7 @@ void GdbEngine::handleResponse(const QByteArray &buff)
data.parseResultOrValue(from, to); data.parseResultOrValue(from, to);
if (data.isValid()) { if (data.isValid()) {
//qDebug() << "parsed result:" << data.toString(); //qDebug() << "parsed result:" << data.toString();
result.m_children += data; result.m_children.push_back(data);
result.m_type = GdbMi::Tuple; result.m_type = GdbMi::Tuple;
} }
} }
@@ -944,7 +944,7 @@ void GdbEngine::flushCommand(const DebuggerCommand &cmd0)
const int token = ++currentToken(); const int token = ++currentToken();
DebuggerCommand cmd = cmd0; DebuggerCommand cmd = cmd0;
cmd.postTime = QTime::currentTime(); cmd.postTime = QTime::currentTime().msecsSinceStartOfDay();
m_commandForToken[token] = cmd; m_commandForToken[token] = cmd;
if (cmd.flags & ConsoleCommand) if (cmd.flags & ConsoleCommand)
cmd.function = "-interpreter-exec console \"" + cmd.function + '"'; cmd.function = "-interpreter-exec console \"" + cmd.function + '"';
@@ -1119,7 +1119,7 @@ void GdbEngine::handleResultRecord(DebuggerResponse *response)
if (boolSetting(LogTimeStamps)) { if (boolSetting(LogTimeStamps)) {
showMessage(_("Response time: %1: %2 s") showMessage(_("Response time: %1: %2 s")
.arg(_(cmd.function)) .arg(_(cmd.function))
.arg(cmd.postTime.msecsTo(QTime::currentTime()) / 1000.), .arg(QTime::fromMSecsSinceStartOfDay(cmd.postTime).msecsTo(QTime::currentTime()) / 1000.),
LogTime); LogTime);
} }
@@ -3441,8 +3441,8 @@ void GdbEngine::handleThreadListIds(const DebuggerResponse &response)
// "72^done,{thread-ids={thread-id="2",thread-id="1"},number-of-threads="2"} // "72^done,{thread-ids={thread-id="2",thread-id="1"},number-of-threads="2"}
// In gdb 7.1+ additionally: current-thread-id="1" // In gdb 7.1+ additionally: current-thread-id="1"
ThreadsHandler *handler = threadsHandler(); ThreadsHandler *handler = threadsHandler();
const QList<GdbMi> items = response.data["thread-ids"].children(); const std::vector<GdbMi> &items = response.data["thread-ids"].children();
for (int index = 0, n = items.size(); index != n; ++index) { for (size_t index = 0, n = items.size(); index != n; ++index) {
ThreadData thread; ThreadData thread;
thread.id = ThreadId(items.at(index).toInt()); thread.id = ThreadId(items.at(index).toInt());
handler->updateThread(thread); handler->updateThread(thread);
@@ -3896,7 +3896,7 @@ void GdbEngine::handleFetchMemory(const DebuggerResponse &response, MemoryAgentC
if (response.resultClass == ResultDone) { if (response.resultClass == ResultDone) {
GdbMi memory = response.data["memory"]; GdbMi memory = response.data["memory"];
QTC_ASSERT(memory.children().size() <= 1, return); QTC_ASSERT(memory.children().size() <= 1, return);
if (memory.children().isEmpty()) if (memory.children().empty())
return; return;
GdbMi memory0 = memory.children().at(0); // we asked for only one 'row' GdbMi memory0 = memory.children().at(0); // we asked for only one 'row'
GdbMi data = memory0["data"]; GdbMi data = memory0["data"];

View File

@@ -461,10 +461,10 @@ void ThreadsHandler::updateThreads(const GdbMi &data)
// m_currentIndex = -1; // m_currentIndex = -1;
// } // }
const QList<GdbMi> items = data["threads"].children(); const std::vector<GdbMi> items = data["threads"].children();
const int n = items.size(); const int n = items.size();
for (int index = 0; index != n; ++index) { for (int index = 0; index != n; ++index) {
const GdbMi item = items.at(index); const GdbMi item = items[index];
const GdbMi frame = item["frame"]; const GdbMi frame = item["frame"];
ThreadData thread; ThreadData thread;
thread.id = ThreadId(item["id"].toInt()); thread.id = ThreadId(item["id"].toInt());

View File

@@ -49,7 +49,7 @@ QtcPlugin {
Group { Group {
name: "Shared Sources" name: "Shared Sources"
id: sharedSources id: sharedSources
prefix: "../../shared/designerintegrationv2/" prefix: project.sharedSourcesDir + "/designerintegrationv2/"
files: [ files: [
"formresizer.cpp", "formresizer.h", "formresizer.cpp", "formresizer.h",
"sizehandlerect.cpp", "sizehandlerect.h", "sizehandlerect.cpp", "sizehandlerect.h",

View File

@@ -64,7 +64,7 @@ QtcPlugin {
Group { Group {
id: sharedSources id: sharedSources
name: "Shared Sources" name: "Shared Sources"
prefix: "../../shared/help/" prefix: project.sharedSourcesDir + "/help/"
files: [ files: [
"bookmarkdialog.ui", "bookmarkdialog.ui",
"bookmarkmanager.cpp", "bookmarkmanager.h", "bookmarkmanager.cpp", "bookmarkmanager.h",

View File

@@ -12,7 +12,6 @@ QtcPlugin {
Depends { name: "QmlDebug" } Depends { name: "QmlDebug" }
Depends { name: "Qt"; submodules: ["widgets", "xml", "network"] } Depends { name: "Qt"; submodules: ["widgets", "xml", "network"] }
cpp.includePaths: base.concat("../../shared")
cpp.frameworks: base.concat(qbs.targetOS.contains("osx") ? ["CoreFoundation", "IOKit"] : []) cpp.frameworks: base.concat(qbs.targetOS.contains("osx") ? ["CoreFoundation", "IOKit"] : [])
files: [ files: [

View File

@@ -16,7 +16,7 @@ QtcPlugin {
Depends { name: "Qt.widgets" } Depends { name: "Qt.widgets" }
cpp.includePaths: base.concat([ cpp.includePaths: base.concat([
"../../shared", project.sharedSourcesDir,
]) ])
files: [ files: [

View File

@@ -117,8 +117,9 @@ public:
{ return operator()(a->path(), b); } { return operator()(a->path(), b); }
bool operator()(const FileName &a, Node *b) bool operator()(const FileName &a, Node *b)
{ return operator()(a, b->path()); } { return operator()(a, b->path()); }
// Compare as strings to correctly detect case-only file rename
bool operator()(const FileName &a, const FileName &b) bool operator()(const FileName &a, const FileName &b)
{ return a < b; } { return a.toString() < b.toString(); }
}; };
class QmakeNodeStaticData { class QmakeNodeStaticData {

View File

@@ -121,4 +121,9 @@ QtcPlugin {
"qtquickapp.png", "qtquickapp.png",
] ]
} }
Export {
Depends { name: "cpp" }
cpp.includePaths: [project.sharedSourcesDir]
}
} }

View File

@@ -308,6 +308,8 @@ void QmakeProjectManagerPlugin::updateRunQMakeAction()
if (BuildManager::isBuilding(ProjectTree::currentProject())) if (BuildManager::isBuilding(ProjectTree::currentProject()))
enable = false; enable = false;
QmakeProject *pro = qobject_cast<QmakeProject *>(ProjectTree::currentProject()); QmakeProject *pro = qobject_cast<QmakeProject *>(ProjectTree::currentProject());
if (!pro)
pro = qobject_cast<QmakeProject *>(SessionManager::startupProject());
if (!pro if (!pro
|| !pro->activeTarget() || !pro->activeTarget()
|| !pro->activeTarget()->activeBuildConfiguration()) || !pro->activeTarget()->activeBuildConfiguration())

View File

@@ -37,7 +37,7 @@ using namespace QmlDesigner::Internal;
using namespace QmlJS; using namespace QmlJS;
using namespace QmlJS::AST; using namespace QmlJS::AST;
AddArrayMemberVisitor::AddArrayMemberVisitor(QmlDesigner::TextModifier &modifier, AddArrayMemberVisitor::AddArrayMemberVisitor(TextModifier &modifier,
quint32 parentLocation, quint32 parentLocation,
const QString &propertyName, const QString &propertyName,
const QString &content): const QString &content):
@@ -62,7 +62,7 @@ void AddArrayMemberVisitor::findArrayBindingAndInsert(const QString &propertyNam
} }
} }
bool AddArrayMemberVisitor::visit(QmlJS::AST::UiObjectBinding *ast) bool AddArrayMemberVisitor::visit(UiObjectBinding *ast)
{ {
if (didRewriting()) if (didRewriting())
return false; return false;
@@ -73,7 +73,7 @@ bool AddArrayMemberVisitor::visit(QmlJS::AST::UiObjectBinding *ast)
return !didRewriting(); return !didRewriting();
} }
bool AddArrayMemberVisitor::visit(QmlJS::AST::UiObjectDefinition *ast) bool AddArrayMemberVisitor::visit(UiObjectDefinition *ast)
{ {
if (didRewriting()) if (didRewriting())
return false; return false;
@@ -85,7 +85,7 @@ bool AddArrayMemberVisitor::visit(QmlJS::AST::UiObjectDefinition *ast)
} }
// FIXME: duplicate code in the QmlJS::Rewriter class, remove this // FIXME: duplicate code in the QmlJS::Rewriter class, remove this
void AddArrayMemberVisitor::insertInto(QmlJS::AST::UiArrayBinding *arrayBinding) void AddArrayMemberVisitor::insertInto(UiArrayBinding *arrayBinding)
{ {
UiObjectMember *lastMember = 0; UiObjectMember *lastMember = 0;
for (UiArrayMemberList *iter = arrayBinding->members; iter; iter = iter->next) for (UiArrayMemberList *iter = arrayBinding->members; iter; iter = iter->next)
@@ -103,7 +103,7 @@ void AddArrayMemberVisitor::insertInto(QmlJS::AST::UiArrayBinding *arrayBinding)
setDidRewriting(true); setDidRewriting(true);
} }
void AddArrayMemberVisitor::convertAndAdd(QmlJS::AST::UiObjectBinding *objectBinding) void AddArrayMemberVisitor::convertAndAdd(UiObjectBinding *objectBinding)
{ {
const int indentDepth = calculateIndentDepth(objectBinding->firstSourceLocation()); const int indentDepth = calculateIndentDepth(objectBinding->firstSourceLocation());
const QString arrayPrefix = QStringLiteral("[\n") + addIndentation(QString(), indentDepth); const QString arrayPrefix = QStringLiteral("[\n") + addIndentation(QString(), indentDepth);

View File

@@ -37,7 +37,7 @@ using namespace QmlDesigner::Internal;
using namespace QmlJS; using namespace QmlJS;
using namespace QmlJS::AST; using namespace QmlJS::AST;
AddObjectVisitor::AddObjectVisitor(QmlDesigner::TextModifier &modifier, AddObjectVisitor::AddObjectVisitor(TextModifier &modifier,
quint32 parentLocation, quint32 parentLocation,
const QString &content, const QString &content,
const PropertyNameList &propertyOrder): const PropertyNameList &propertyOrder):
@@ -48,7 +48,7 @@ AddObjectVisitor::AddObjectVisitor(QmlDesigner::TextModifier &modifier,
{ {
} }
bool AddObjectVisitor::visit(QmlJS::AST::UiObjectBinding *ast) bool AddObjectVisitor::visit(UiObjectBinding *ast)
{ {
if (didRewriting()) if (didRewriting())
return false; return false;
@@ -59,7 +59,7 @@ bool AddObjectVisitor::visit(QmlJS::AST::UiObjectBinding *ast)
return !didRewriting(); return !didRewriting();
} }
bool AddObjectVisitor::visit(QmlJS::AST::UiObjectDefinition *ast) bool AddObjectVisitor::visit(UiObjectDefinition *ast)
{ {
if (didRewriting()) if (didRewriting())
return false; return false;
@@ -71,7 +71,7 @@ bool AddObjectVisitor::visit(QmlJS::AST::UiObjectDefinition *ast)
} }
// FIXME: duplicate code in the QmlJS::Rewriter class, remove this // FIXME: duplicate code in the QmlJS::Rewriter class, remove this
void AddObjectVisitor::insertInto(QmlJS::AST::UiObjectInitializer *ast) void AddObjectVisitor::insertInto(UiObjectInitializer *ast)
{ {
UiObjectMemberList *insertAfter = searchMemberToInsertAfter(ast->members, m_propertyOrder); UiObjectMemberList *insertAfter = searchMemberToInsertAfter(ast->members, m_propertyOrder);

View File

@@ -32,18 +32,16 @@
#include <qmljs/parser/qmljsast_p.h> #include <qmljs/parser/qmljsast_p.h>
using namespace QmlDesigner; namespace QmlDesigner {
using namespace QmlDesigner::Internal; namespace Internal {
using namespace QmlJS;
using namespace QmlJS::AST;
AddPropertyVisitor::AddPropertyVisitor(QmlDesigner::TextModifier &modifier, AddPropertyVisitor::AddPropertyVisitor(TextModifier &modifier,
quint32 parentLocation, quint32 parentLocation,
const QmlDesigner::PropertyName &name, const PropertyName &name,
const QString &value, const QString &value,
QmlRefactoring::PropertyType propertyType, QmlRefactoring::PropertyType propertyType,
const PropertyNameList &propertyOrder, const PropertyNameList &propertyOrder,
const QmlDesigner::TypeName &dynamicTypeName) : const TypeName &dynamicTypeName) :
QMLRewriter(modifier), QMLRewriter(modifier),
m_parentLocation(parentLocation), m_parentLocation(parentLocation),
m_name(name), m_name(name),
@@ -85,9 +83,9 @@ bool AddPropertyVisitor::visit(QmlJS::AST::UiObjectBinding *ast)
// FIXME: duplicate code in the QmlJS::Rewriter class, remove this // FIXME: duplicate code in the QmlJS::Rewriter class, remove this
void AddPropertyVisitor::addInMembers(QmlJS::AST::UiObjectInitializer *initializer) void AddPropertyVisitor::addInMembers(QmlJS::AST::UiObjectInitializer *initializer)
{ {
UiObjectMemberList *insertAfter = searchMemberToInsertAfter(initializer->members, m_name, m_propertyOrder); QmlJS::AST::UiObjectMemberList *insertAfter = searchMemberToInsertAfter(initializer->members, m_name, m_propertyOrder);
SourceLocation endOfPreviousMember; QmlJS::AST::SourceLocation endOfPreviousMember;
SourceLocation startOfNextMember; QmlJS::AST::SourceLocation startOfNextMember;
unsigned depth; unsigned depth;
if (insertAfter == 0 || insertAfter->member == 0) { if (insertAfter == 0 || insertAfter->member == 0) {
@@ -168,3 +166,6 @@ void AddPropertyVisitor::addInMembers(QmlJS::AST::UiObjectInitializer *initializ
setDidRewriting(true); setDidRewriting(true);
} }
} // namespace Internal
} // namespace QmlDesigner

View File

@@ -41,13 +41,13 @@ class AddPropertyVisitor: public QMLRewriter
{ {
public: public:
public: public:
AddPropertyVisitor(QmlDesigner::TextModifier &modifier, AddPropertyVisitor(TextModifier &modifier,
quint32 parentLocation, quint32 parentLocation,
const QmlDesigner::PropertyName &name, const PropertyName &name,
const QString &value, const QString &value,
QmlDesigner::QmlRefactoring::PropertyType propertyType, QmlRefactoring::PropertyType propertyType,
const PropertyNameList &propertyOrder, const PropertyNameList &propertyOrder,
const QmlDesigner::TypeName &dynamicTypeName); const TypeName &dynamicTypeName);
protected: protected:
virtual bool visit(QmlJS::AST::UiObjectDefinition *ast); virtual bool visit(QmlJS::AST::UiObjectDefinition *ast);
@@ -62,7 +62,7 @@ private:
QString m_value; QString m_value;
QmlRefactoring::PropertyType m_propertyType; QmlRefactoring::PropertyType m_propertyType;
PropertyNameList m_propertyOrder; PropertyNameList m_propertyOrder;
QmlDesigner::TypeName m_dynamicTypeName; TypeName m_dynamicTypeName;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -55,7 +55,7 @@ QString ASTObjectTextExtractor::operator ()(int location)
return m_text; return m_text;
} }
bool ASTObjectTextExtractor::visit(QmlJS::AST::UiObjectBinding *ast) bool ASTObjectTextExtractor::visit(UiObjectBinding *ast)
{ {
if (!m_text.isEmpty()) if (!m_text.isEmpty())
return false; return false;
@@ -66,7 +66,7 @@ bool ASTObjectTextExtractor::visit(QmlJS::AST::UiObjectBinding *ast)
return m_text.isEmpty(); return m_text.isEmpty();
} }
bool ASTObjectTextExtractor::visit(QmlJS::AST::UiObjectDefinition *ast) bool ASTObjectTextExtractor::visit(UiObjectDefinition *ast)
{ {
if (!m_text.isEmpty()) if (!m_text.isEmpty())
return false; return false;

View File

@@ -44,7 +44,7 @@ ChangeImportsVisitor::ChangeImportsVisitor(TextModifier &textModifier,
QMLRewriter(textModifier), m_source(source) QMLRewriter(textModifier), m_source(source)
{} {}
bool ChangeImportsVisitor::add(QmlJS::AST::UiProgram *ast, const Import &import) bool ChangeImportsVisitor::add(UiProgram *ast, const Import &import)
{ {
setDidRewriting(false); setDidRewriting(false);
if (!ast) if (!ast)
@@ -72,7 +72,7 @@ bool ChangeImportsVisitor::add(QmlJS::AST::UiProgram *ast, const Import &import)
return true; return true;
} }
bool ChangeImportsVisitor::remove(QmlJS::AST::UiProgram *ast, const Import &import) bool ChangeImportsVisitor::remove(UiProgram *ast, const Import &import)
{ {
setDidRewriting(false); setDidRewriting(false);
if (!ast) if (!ast)
@@ -92,7 +92,7 @@ bool ChangeImportsVisitor::remove(QmlJS::AST::UiProgram *ast, const Import &impo
return didRewriting(); return didRewriting();
} }
bool ChangeImportsVisitor::equals(QmlJS::AST::UiImport *ast, const Import &import) bool ChangeImportsVisitor::equals(UiImport *ast, const Import &import)
{ {
if (import.isLibraryImport()) if (import.isLibraryImport())
return toString(ast->importUri) == import.url(); return toString(ast->importUri) == import.url();

View File

@@ -37,7 +37,7 @@ using namespace QmlJS::AST;
using namespace QmlDesigner; using namespace QmlDesigner;
using namespace QmlDesigner::Internal; using namespace QmlDesigner::Internal;
ChangePropertyVisitor::ChangePropertyVisitor(QmlDesigner::TextModifier &modifier, ChangePropertyVisitor::ChangePropertyVisitor(TextModifier &modifier,
quint32 parentLocation, quint32 parentLocation,
const QString &name, const QString &name,
const QString &value, const QString &value,
@@ -50,7 +50,7 @@ ChangePropertyVisitor::ChangePropertyVisitor(QmlDesigner::TextModifier &modifier
{ {
} }
bool ChangePropertyVisitor::visit(QmlJS::AST::UiObjectDefinition *ast) bool ChangePropertyVisitor::visit(UiObjectDefinition *ast)
{ {
if (didRewriting()) if (didRewriting())
return false; return false;
@@ -66,7 +66,7 @@ bool ChangePropertyVisitor::visit(QmlJS::AST::UiObjectDefinition *ast)
return !didRewriting(); return !didRewriting();
} }
bool ChangePropertyVisitor::visit(QmlJS::AST::UiObjectBinding *ast) bool ChangePropertyVisitor::visit(UiObjectBinding *ast)
{ {
if (didRewriting()) if (didRewriting())
return false; return false;
@@ -192,7 +192,7 @@ bool ChangePropertyVisitor::nextMemberOnSameLine(UiObjectMemberList *members)
} }
// FIXME: duplicate code in the QmlJS::Rewriter class, remove this // FIXME: duplicate code in the QmlJS::Rewriter class, remove this
void ChangePropertyVisitor::insertIntoArray(QmlJS::AST::UiArrayBinding *ast) void ChangePropertyVisitor::insertIntoArray(UiArrayBinding *ast)
{ {
if (!ast) if (!ast)
return; return;

View File

@@ -46,7 +46,7 @@ FirstDefinitionFinder::FirstDefinitionFinder(const QString &text):
if (!ok) { if (!ok) {
qDebug() << text; qDebug() << text;
foreach (const QmlJS::DiagnosticMessage &message, m_doc->diagnosticMessages()) foreach (const DiagnosticMessage &message, m_doc->diagnosticMessages())
qDebug() << message.message; qDebug() << message.message;
} }
@@ -81,7 +81,7 @@ void FirstDefinitionFinder::extractFirstObjectDefinition(UiObjectInitializer* as
} }
} }
bool FirstDefinitionFinder::visit(QmlJS::AST::UiObjectBinding *ast) bool FirstDefinitionFinder::visit(UiObjectBinding *ast)
{ {
if (ast->qualifiedTypeNameId && ast->qualifiedTypeNameId->identifierToken.isValid()) { if (ast->qualifiedTypeNameId && ast->qualifiedTypeNameId->identifierToken.isValid()) {
const quint32 start = ast->qualifiedTypeNameId->identifierToken.offset; const quint32 start = ast->qualifiedTypeNameId->identifierToken.offset;
@@ -94,7 +94,7 @@ bool FirstDefinitionFinder::visit(QmlJS::AST::UiObjectBinding *ast)
return true; return true;
} }
bool FirstDefinitionFinder::visit(QmlJS::AST::UiObjectDefinition *ast) bool FirstDefinitionFinder::visit(UiObjectDefinition *ast)
{ {
const quint32 start = ast->firstSourceLocation().offset; const quint32 start = ast->firstSourceLocation().offset;

View File

@@ -60,7 +60,7 @@ MoveObjectBeforeObjectVisitor::MoveObjectBeforeObjectVisitor(TextModifier &modif
beforeObjectLocation(beforeObjectLocation) beforeObjectLocation(beforeObjectLocation)
{} {}
bool MoveObjectBeforeObjectVisitor::operator ()(QmlJS::AST::UiProgram *ast) bool MoveObjectBeforeObjectVisitor::operator ()(UiProgram *ast)
{ {
movingObject = 0; movingObject = 0;
beforeObject = 0; beforeObject = 0;

View File

@@ -36,15 +36,16 @@
using namespace QmlJS; using namespace QmlJS;
using namespace QmlJS::AST; using namespace QmlJS::AST;
using namespace QmlDesigner::Internal;
using namespace QmlDesigner; namespace QmlDesigner {
namespace Internal {
class Inserter: public QMLRewriter class Inserter: public QMLRewriter
{ {
public: public:
Inserter(QmlDesigner::TextModifier &modifier, Inserter(TextModifier &modifier,
quint32 targetParentObjectLocation, quint32 targetParentObjectLocation,
const QmlDesigner::PropertyName &targetPropertyName, const PropertyName &targetPropertyName,
bool targetIsArrayBinding, bool targetIsArrayBinding,
TextModifier::MoveInfo moveInfo, TextModifier::MoveInfo moveInfo,
const PropertyNameList &propertyOrder): const PropertyNameList &propertyOrder):
@@ -150,15 +151,15 @@ private:
private: private:
quint32 targetParentObjectLocation; quint32 targetParentObjectLocation;
QmlDesigner::PropertyName targetPropertyName; PropertyName targetPropertyName;
bool targetIsArrayBinding; bool targetIsArrayBinding;
TextModifier::MoveInfo moveInfo; TextModifier::MoveInfo moveInfo;
PropertyNameList propertyOrder; PropertyNameList propertyOrder;
}; };
MoveObjectVisitor::MoveObjectVisitor(QmlDesigner::TextModifier &modifier, MoveObjectVisitor::MoveObjectVisitor(TextModifier &modifier,
quint32 objectLocation, quint32 objectLocation,
const QmlDesigner::PropertyName &targetPropertyName, const PropertyName &targetPropertyName,
bool targetIsArrayBinding, bool targetIsArrayBinding,
quint32 targetParentObjectLocation, quint32 targetParentObjectLocation,
const PropertyNameList &propertyOrder): const PropertyNameList &propertyOrder):
@@ -292,3 +293,6 @@ void MoveObjectVisitor::doMove(const TextModifier::MoveInfo &moveInfo)
setDidRewriting(findTargetAndInsert(program)); setDidRewriting(findTargetAndInsert(program));
} }
} }
} // namespace Internal
} // namespace QmlDesigner

View File

@@ -60,7 +60,7 @@ bool ObjectLengthCalculator::operator()(const QString &text, quint32 offset,
} }
} }
bool ObjectLengthCalculator::visit(QmlJS::AST::UiObjectBinding *ast) bool ObjectLengthCalculator::visit(UiObjectBinding *ast)
{ {
if (m_length > 0) if (m_length > 0)
return false; return false;
@@ -80,7 +80,7 @@ bool ObjectLengthCalculator::visit(QmlJS::AST::UiObjectBinding *ast)
} }
} }
bool ObjectLengthCalculator::visit(QmlJS::AST::UiObjectDefinition *ast) bool ObjectLengthCalculator::visit(UiObjectDefinition *ast)
{ {
if (m_length > 0) if (m_length > 0)
return false; return false;

View File

@@ -47,7 +47,7 @@ QMLRewriter::QMLRewriter(QmlDesigner::TextModifier &textModifier):
{ {
} }
bool QMLRewriter::operator()(QmlJS::AST::UiProgram *ast) bool QMLRewriter::operator()(UiProgram *ast)
{ {
setDidRewriting(false); setDidRewriting(false);
@@ -71,7 +71,7 @@ QString QMLRewriter::textBetween(int startPosition, int endPosition) const
return m_textModifier->text().mid(startPosition, endPosition - startPosition); return m_textModifier->text().mid(startPosition, endPosition - startPosition);
} }
QString QMLRewriter::textAt(const QmlJS::AST::SourceLocation &location) const QString QMLRewriter::textAt(const SourceLocation &location) const
{ {
return m_textModifier->text().mid(location.offset, location.length); return m_textModifier->text().mid(location.offset, location.length);
} }
@@ -154,7 +154,7 @@ QString QMLRewriter::removeIndentation(const QString &text, unsigned depth)
return result; return result;
} }
QmlJS::AST::SourceLocation QMLRewriter::calculateLocation(QmlJS::AST::UiQualifiedId *id) SourceLocation QMLRewriter::calculateLocation(UiQualifiedId *id)
{ {
Q_ASSERT(id != 0); Q_ASSERT(id != 0);
@@ -170,7 +170,7 @@ QmlJS::AST::SourceLocation QMLRewriter::calculateLocation(QmlJS::AST::UiQualifie
return SourceLocation(startLocation.offset, endLocation.end() - startLocation.offset); return SourceLocation(startLocation.offset, endLocation.end() - startLocation.offset);
} }
bool QMLRewriter::isMissingSemicolon(QmlJS::AST::UiObjectMember *member) bool QMLRewriter::isMissingSemicolon(UiObjectMember *member)
{ {
UiScriptBinding *binding = AST::cast<UiScriptBinding *>(member); UiScriptBinding *binding = AST::cast<UiScriptBinding *>(member);
if (binding) if (binding)
@@ -179,7 +179,7 @@ bool QMLRewriter::isMissingSemicolon(QmlJS::AST::UiObjectMember *member)
return false; return false;
} }
bool QMLRewriter::isMissingSemicolon(QmlJS::AST::Statement *stmt) bool QMLRewriter::isMissingSemicolon(Statement *stmt)
{ {
if (ExpressionStatement *eStmt = AST::cast<ExpressionStatement *>(stmt)) { if (ExpressionStatement *eStmt = AST::cast<ExpressionStatement *>(stmt)) {
return !eStmt->semicolonToken.isValid(); return !eStmt->semicolonToken.isValid();

View File

@@ -45,7 +45,7 @@ RemovePropertyVisitor::RemovePropertyVisitor(QmlDesigner::TextModifier &modifier
{ {
} }
bool RemovePropertyVisitor::visit(QmlJS::AST::UiObjectBinding *ast) bool RemovePropertyVisitor::visit(UiObjectBinding *ast)
{ {
if (ast->firstSourceLocation().offset == parentLocation) { if (ast->firstSourceLocation().offset == parentLocation) {
//this condition is wrong for the UiObjectBinding case, but we keep it //this condition is wrong for the UiObjectBinding case, but we keep it
@@ -62,7 +62,7 @@ bool RemovePropertyVisitor::visit(QmlJS::AST::UiObjectBinding *ast)
return !didRewriting(); return !didRewriting();
} }
bool RemovePropertyVisitor::visit(QmlJS::AST::UiObjectDefinition *ast) bool RemovePropertyVisitor::visit(UiObjectDefinition *ast)
{ {
if (ast->firstSourceLocation().offset == parentLocation) { if (ast->firstSourceLocation().offset == parentLocation) {
// FIXME: change this to use the QmlJS::Rewriter class // FIXME: change this to use the QmlJS::Rewriter class
@@ -73,7 +73,7 @@ bool RemovePropertyVisitor::visit(QmlJS::AST::UiObjectDefinition *ast)
} }
// FIXME: duplicate code in the QmlJS::Rewriter class, remove this // FIXME: duplicate code in the QmlJS::Rewriter class, remove this
void RemovePropertyVisitor::removeFrom(QmlJS::AST::UiObjectInitializer *ast) void RemovePropertyVisitor::removeFrom(UiObjectInitializer *ast)
{ {
QString prefix; QString prefix;
int dotIdx = propertyName.indexOf(QLatin1Char('.')); int dotIdx = propertyName.indexOf(QLatin1Char('.'));

View File

@@ -39,7 +39,7 @@ using namespace QmlDesigner::Internal;
using namespace QmlJS; using namespace QmlJS;
using namespace QmlJS::AST; using namespace QmlJS::AST;
RemoveUIObjectMemberVisitor::RemoveUIObjectMemberVisitor(QmlDesigner::TextModifier &modifier, RemoveUIObjectMemberVisitor::RemoveUIObjectMemberVisitor(TextModifier &modifier,
quint32 objectLocation): quint32 objectLocation):
QMLRewriter(modifier), QMLRewriter(modifier),
objectLocation(objectLocation) objectLocation(objectLocation)
@@ -58,15 +58,15 @@ void RemoveUIObjectMemberVisitor::postVisit(Node *)
parents.pop(); parents.pop();
} }
bool RemoveUIObjectMemberVisitor::visit(QmlJS::AST::UiPublicMember *ast) { return visitObjectMember(ast); } bool RemoveUIObjectMemberVisitor::visit(UiPublicMember *ast) { return visitObjectMember(ast); }
bool RemoveUIObjectMemberVisitor::visit(QmlJS::AST::UiObjectDefinition *ast) { return visitObjectMember(ast); } bool RemoveUIObjectMemberVisitor::visit(UiObjectDefinition *ast) { return visitObjectMember(ast); }
bool RemoveUIObjectMemberVisitor::visit(QmlJS::AST::UiSourceElement *ast) { return visitObjectMember(ast); } bool RemoveUIObjectMemberVisitor::visit(UiSourceElement *ast) { return visitObjectMember(ast); }
bool RemoveUIObjectMemberVisitor::visit(QmlJS::AST::UiObjectBinding *ast) { return visitObjectMember(ast); } bool RemoveUIObjectMemberVisitor::visit(UiObjectBinding *ast) { return visitObjectMember(ast); }
bool RemoveUIObjectMemberVisitor::visit(QmlJS::AST::UiScriptBinding *ast) { return visitObjectMember(ast); } bool RemoveUIObjectMemberVisitor::visit(UiScriptBinding *ast) { return visitObjectMember(ast); }
bool RemoveUIObjectMemberVisitor::visit(QmlJS::AST::UiArrayBinding *ast) { return visitObjectMember(ast); } bool RemoveUIObjectMemberVisitor::visit(UiArrayBinding *ast) { return visitObjectMember(ast); }
// FIXME: duplicate code in the QmlJS::Rewriter class, remove this // FIXME: duplicate code in the QmlJS::Rewriter class, remove this
bool RemoveUIObjectMemberVisitor::visitObjectMember(QmlJS::AST::UiObjectMember *ast) bool RemoveUIObjectMemberVisitor::visitObjectMember(UiObjectMember *ast)
{ {
const quint32 memberStart = ast->firstSourceLocation().offset; const quint32 memberStart = ast->firstSourceLocation().offset;
@@ -106,8 +106,8 @@ UiArrayBinding *RemoveUIObjectMemberVisitor::containingArray() const
} }
// FIXME: duplicate code in the QmlJS::Rewriter class, remove this // FIXME: duplicate code in the QmlJS::Rewriter class, remove this
void RemoveUIObjectMemberVisitor::extendToLeadingOrTrailingComma(QmlJS::AST::UiArrayBinding *parentArray, void RemoveUIObjectMemberVisitor::extendToLeadingOrTrailingComma(UiArrayBinding *parentArray,
QmlJS::AST::UiObjectMember *ast, UiObjectMember *ast,
int &start, int &start,
int &end) const int &end) const
{ {

View File

@@ -135,10 +135,10 @@ static QString qualifiedTypeNameForContext(const ObjectValue *objectValue,
foreach (const LanguageUtils::FakeMetaObject::Export &e, cppComponent->metaObject()->exports()) { foreach (const LanguageUtils::FakeMetaObject::Export &e, cppComponent->metaObject()->exports()) {
if (e.type == className) if (e.type == className)
packages << e.package; packages << e.package;
if (e.package == QmlJS::CppQmlTypes::cppPackage) if (e.package == CppQmlTypes::cppPackage)
cppName = e.type; cppName = e.type;
} }
if (packages.size() == 1 && packages.at(0) == QmlJS::CppQmlTypes::cppPackage) if (packages.size() == 1 && packages.at(0) == CppQmlTypes::cppPackage)
return packages.at(0) + QLatin1Char('.') + className; return packages.at(0) + QLatin1Char('.') + className;
} }
// try to recover a "global context name" // try to recover a "global context name"
@@ -264,7 +264,7 @@ static QString qualifiedTypeNameForContext(const ObjectValue *objectValue,
return optimalName(possibleFiles); return optimalName(possibleFiles);
} while (false); } while (false);
if (!cppName.isEmpty()) if (!cppName.isEmpty())
return QmlJS::CppQmlTypes::cppPackage + QLatin1Char('.') + cppName; return CppQmlTypes::cppPackage + QLatin1Char('.') + cppName;
if (const CppComponentValue *cppComponent = value_cast<CppComponentValue>(objectValue)) { if (const CppComponentValue *cppComponent = value_cast<CppComponentValue>(objectValue)) {
if (cppComponent->moduleName().isEmpty()) if (cppComponent->moduleName().isEmpty())
return cppComponent->className(); return cppComponent->className();
@@ -280,7 +280,7 @@ class PropertyMemberProcessor : public MemberProcessor
public: public:
PropertyMemberProcessor(const ContextPtr &context) : m_context(context) PropertyMemberProcessor(const ContextPtr &context) : m_context(context)
{} {}
bool processProperty(const QString &name, const Value *value, const QmlJS::PropertyInfo &) bool processProperty(const QString &name, const Value *value, const PropertyInfo &)
{ {
PropertyName propertyName = name.toUtf8(); PropertyName propertyName = name.toUtf8();
const ASTPropertyReference *ref = value_cast<ASTPropertyReference>(value); const ASTPropertyReference *ref = value_cast<ASTPropertyReference>(value);
@@ -567,13 +567,13 @@ public:
private: private:
NodeMetaInfoPrivate(Model *model, TypeName type, int maj = -1, int min = -1); NodeMetaInfoPrivate(Model *model, TypeName type, int maj = -1, int min = -1);
const QmlJS::CppComponentValue *getCppComponentValue() const; const CppComponentValue *getCppComponentValue() const;
const QmlJS::ObjectValue *getObjectValue() const; const ObjectValue *getObjectValue() const;
void setupPropertyInfo(QList<PropertyInfo> propertyInfos); void setupPropertyInfo(QList<PropertyInfo> propertyInfos);
void setupLocalPropertyInfo(QList<PropertyInfo> propertyInfos); void setupLocalPropertyInfo(QList<PropertyInfo> propertyInfos);
QString lookupName() const; QString lookupName() const;
QStringList lookupNameComponent() const; QStringList lookupNameComponent() const;
const QmlJS::CppComponentValue *getNearestCppComponentValue() const; const CppComponentValue *getNearestCppComponentValue() const;
QString fullQualifiedImportAliasType() const; QString fullQualifiedImportAliasType() const;
TypeName m_qualfiedTypeName; TypeName m_qualfiedTypeName;
@@ -591,7 +591,7 @@ private:
QSet<QString> m_prototypeCacheNegatives; QSet<QString> m_prototypeCacheNegatives;
//storing the pointer would not be save //storing the pointer would not be save
QmlJS::ContextPtr context() const; ContextPtr context() const;
const Document *document() const; const Document *document() const;
QPointer<Model> m_model; QPointer<Model> m_model;
@@ -721,7 +721,7 @@ NodeMetaInfoPrivate::NodeMetaInfoPrivate(Model *model, TypeName type, int maj, i
} }
} }
const QmlJS::CppComponentValue *NodeMetaInfoPrivate::getCppComponentValue() const const CppComponentValue *NodeMetaInfoPrivate::getCppComponentValue() const
{ {
const QList<TypeName> nameComponents = m_qualfiedTypeName.split('.'); const QList<TypeName> nameComponents = m_qualfiedTypeName.split('.');
if (nameComponents.size() < 2) if (nameComponents.size() < 2)
@@ -748,29 +748,29 @@ const QmlJS::CppComponentValue *NodeMetaInfoPrivate::getCppComponentValue() cons
return cppValue; return cppValue;
} }
const QmlJS::CppComponentValue *value = value_cast<CppComponentValue>(getObjectValue()); const CppComponentValue *value = value_cast<CppComponentValue>(getObjectValue());
if (value) if (value)
return value; return value;
// maybe 'type' is a cpp name // maybe 'type' is a cpp name
const QmlJS::CppComponentValue *cppValue = context()->valueOwner()->cppQmlTypes().objectByCppName(type); const CppComponentValue *cppValue = context()->valueOwner()->cppQmlTypes().objectByCppName(type);
return cppValue; return cppValue;
} }
const QmlJS::ObjectValue *NodeMetaInfoPrivate::getObjectValue() const const ObjectValue *NodeMetaInfoPrivate::getObjectValue() const
{ {
return context()->lookupType(document(), lookupNameComponent()); return context()->lookupType(document(), lookupNameComponent());
} }
QmlJS::ContextPtr NodeMetaInfoPrivate::context() const ContextPtr NodeMetaInfoPrivate::context() const
{ {
if (m_model && m_model->rewriterView() && m_model->rewriterView()->scopeChain()) if (m_model && m_model->rewriterView() && m_model->rewriterView()->scopeChain())
return m_model->rewriterView()->scopeChain()->context(); return m_model->rewriterView()->scopeChain()->context();
return QmlJS::ContextPtr(0); return ContextPtr(0);
} }
const QmlJS::Document *NodeMetaInfoPrivate::document() const const Document *NodeMetaInfoPrivate::document() const
{ {
if (m_model && m_model->rewriterView()) if (m_model && m_model->rewriterView())
return m_model->rewriterView()->document(); return m_model->rewriterView()->document();
@@ -815,7 +815,7 @@ bool NodeMetaInfoPrivate::isPropertyWritable(const PropertyName &propertyName) c
return true; return true;
} }
const QmlJS::CppComponentValue *qmlObjectValue = getNearestCppComponentValue(); const CppComponentValue *qmlObjectValue = getNearestCppComponentValue();
if (!qmlObjectValue) if (!qmlObjectValue)
return true; return true;
if (qmlObjectValue->hasProperty(propertyName)) if (qmlObjectValue->hasProperty(propertyName))
@@ -846,7 +846,7 @@ bool NodeMetaInfoPrivate::isPropertyList(const PropertyName &propertyName) const
return true; return true;
} }
const QmlJS::CppComponentValue *qmlObjectValue = getNearestCppComponentValue(); const CppComponentValue *qmlObjectValue = getNearestCppComponentValue();
if (!qmlObjectValue) if (!qmlObjectValue)
return false; return false;
return qmlObjectValue->isListProperty(propertyName); return qmlObjectValue->isListProperty(propertyName);
@@ -873,7 +873,7 @@ bool NodeMetaInfoPrivate::isPropertyPointer(const PropertyName &propertyName) co
return true; return true;
} }
const QmlJS::CppComponentValue *qmlObjectValue = getNearestCppComponentValue(); const CppComponentValue *qmlObjectValue = getNearestCppComponentValue();
if (!qmlObjectValue) if (!qmlObjectValue)
return false; return false;
return qmlObjectValue->isPointer(propertyName); return qmlObjectValue->isPointer(propertyName);
@@ -1239,7 +1239,7 @@ QList<TypeDescription> NodeMetaInfoPrivate::prototypes() const
return m_prototypes; return m_prototypes;
} }
const QmlJS::CppComponentValue *NodeMetaInfoPrivate::getNearestCppComponentValue() const const CppComponentValue *NodeMetaInfoPrivate::getNearestCppComponentValue() const
{ {
if (m_isFileComponent) if (m_isFileComponent)
return findQmlPrototype(getObjectValue(), context()); return findQmlPrototype(getObjectValue(), context());

View File

@@ -243,7 +243,7 @@ void ModelToTextMerger::applyChanges()
ModelNodePositionRecalculator positionRecalculator(m_rewriterView->positionStorage(), m_rewriterView->positionStorage()->modelNodes()); ModelNodePositionRecalculator positionRecalculator(m_rewriterView->positionStorage(), m_rewriterView->positionStorage()->modelNodes());
positionRecalculator.connectTo(textModifier); positionRecalculator.connectTo(textModifier);
QmlDesigner::QmlRefactoring refactoring(tmpDocument, *textModifier, getPropertyOrder()); QmlRefactoring refactoring(tmpDocument, *textModifier, getPropertyOrder());
textModifier->deactivateChangeSignals(); textModifier->deactivateChangeSignals();
textModifier->startGroup(); textModifier->startGroup();
@@ -312,26 +312,26 @@ void ModelToTextMerger::schedule(RewriteAction *action)
m_rewriteActions.append(action); m_rewriteActions.append(action);
} }
QmlDesigner::QmlRefactoring::PropertyType ModelToTextMerger::propertyType(const AbstractProperty &property, const QString &textValue) QmlRefactoring::PropertyType ModelToTextMerger::propertyType(const AbstractProperty &property, const QString &textValue)
{ {
if (property.isBindingProperty() || property.isSignalHandlerProperty()) { if (property.isBindingProperty() || property.isSignalHandlerProperty()) {
QString val = textValue.trimmed(); QString val = textValue.trimmed();
if (val.isEmpty()) if (val.isEmpty())
return QmlDesigner::QmlRefactoring::ObjectBinding; return QmlRefactoring::ObjectBinding;
const QChar lastChar = val.at(val.size() - 1); const QChar lastChar = val.at(val.size() - 1);
if (lastChar == '}' || lastChar == ';') if (lastChar == '}' || lastChar == ';')
return QmlDesigner::QmlRefactoring::ObjectBinding; return QmlRefactoring::ObjectBinding;
else else
return QmlDesigner::QmlRefactoring::ScriptBinding; return QmlRefactoring::ScriptBinding;
} else if (property.isNodeListProperty()) } else if (property.isNodeListProperty())
return QmlDesigner::QmlRefactoring::ArrayBinding; return QmlRefactoring::ArrayBinding;
else if (property.isNodeProperty()) else if (property.isNodeProperty())
return QmlDesigner::QmlRefactoring::ObjectBinding; return QmlRefactoring::ObjectBinding;
else if (property.isVariantProperty()) else if (property.isVariantProperty())
return QmlDesigner::QmlRefactoring::ScriptBinding; return QmlRefactoring::ScriptBinding;
Q_ASSERT(!"cannot convert property type"); Q_ASSERT(!"cannot convert property type");
return (QmlDesigner::QmlRefactoring::PropertyType) -1; return (QmlRefactoring::PropertyType) -1;
} }
PropertyNameList ModelToTextMerger::m_propertyOrder; PropertyNameList ModelToTextMerger::m_propertyOrder;

View File

@@ -127,7 +127,7 @@ QString AddPropertyRewriteAction::info() const
return QStringLiteral("AddPropertyRewriteAction for property \"%1\" (type: %2)").arg(m_property.name(), toString(m_propertyType)); return QStringLiteral("AddPropertyRewriteAction for property \"%1\" (type: %2)").arg(m_property.name(), toString(m_propertyType));
} }
bool ChangeIdRewriteAction::execute(QmlDesigner::QmlRefactoring &refactoring, ModelNodePositionStorage &positionStore) bool ChangeIdRewriteAction::execute(QmlRefactoring &refactoring, ModelNodePositionStorage &positionStore)
{ {
const int nodeLocation = positionStore.nodeOffset(m_node); const int nodeLocation = positionStore.nodeOffset(m_node);
static const PropertyName idPropertyName("id"); static const PropertyName idPropertyName("id");
@@ -172,7 +172,7 @@ QString ChangeIdRewriteAction::info() const
return QString("ChangeIdRewriteAction from \"%1\" to \"%2\"").arg(m_oldId, m_newId); return QString("ChangeIdRewriteAction from \"%1\" to \"%2\"").arg(m_oldId, m_newId);
} }
bool ChangePropertyRewriteAction::execute(QmlDesigner::QmlRefactoring &refactoring, ModelNodePositionStorage &positionStore) bool ChangePropertyRewriteAction::execute(QmlRefactoring &refactoring, ModelNodePositionStorage &positionStore)
{ {
const int nodeLocation = positionStore.nodeOffset(m_property.parentModelNode()); const int nodeLocation = positionStore.nodeOffset(m_property.parentModelNode());
bool result = false; bool result = false;
@@ -222,7 +222,7 @@ QString ChangePropertyRewriteAction::info() const
(m_containedModelNode.isValid() ? m_containedModelNode.id() : "(none)")); (m_containedModelNode.isValid() ? m_containedModelNode.id() : "(none)"));
} }
bool ChangeTypeRewriteAction::execute(QmlDesigner::QmlRefactoring &refactoring, ModelNodePositionStorage &positionStore) bool ChangeTypeRewriteAction::execute(QmlRefactoring &refactoring, ModelNodePositionStorage &positionStore)
{ {
const int nodeLocation = positionStore.nodeOffset(m_node); const int nodeLocation = positionStore.nodeOffset(m_node);
bool result = false; bool result = false;
@@ -248,7 +248,7 @@ QString ChangeTypeRewriteAction::info() const
return QString("ChangeTypeRewriteAction"); return QString("ChangeTypeRewriteAction");
} }
bool RemoveNodeRewriteAction::execute(QmlDesigner::QmlRefactoring &refactoring, ModelNodePositionStorage &positionStore) bool RemoveNodeRewriteAction::execute(QmlRefactoring &refactoring, ModelNodePositionStorage &positionStore)
{ {
const int nodeLocation = positionStore.nodeOffset(m_node); const int nodeLocation = positionStore.nodeOffset(m_node);
bool result = refactoring.removeObject(nodeLocation); bool result = refactoring.removeObject(nodeLocation);
@@ -266,7 +266,7 @@ QString RemoveNodeRewriteAction::info() const
return QString("RemoveNodeRewriteAction"); return QString("RemoveNodeRewriteAction");
} }
bool RemovePropertyRewriteAction::execute(QmlDesigner::QmlRefactoring &refactoring, ModelNodePositionStorage &positionStore) bool RemovePropertyRewriteAction::execute(QmlRefactoring &refactoring, ModelNodePositionStorage &positionStore)
{ {
const int nodeLocation = positionStore.nodeOffset(m_property.parentModelNode()); const int nodeLocation = positionStore.nodeOffset(m_property.parentModelNode());
bool result = refactoring.removeProperty(nodeLocation, m_property.name()); bool result = refactoring.removeProperty(nodeLocation, m_property.name());
@@ -285,7 +285,7 @@ QString RemovePropertyRewriteAction::info() const
return QStringLiteral("RemovePropertyRewriteAction for property \"%1\"").arg(QLatin1String(m_property.name())); return QStringLiteral("RemovePropertyRewriteAction for property \"%1\"").arg(QLatin1String(m_property.name()));
} }
bool ReparentNodeRewriteAction::execute(QmlDesigner::QmlRefactoring &refactoring, ModelNodePositionStorage &positionStore) bool ReparentNodeRewriteAction::execute(QmlRefactoring &refactoring, ModelNodePositionStorage &positionStore)
{ {
const int nodeLocation = positionStore.nodeOffset(m_node); const int nodeLocation = positionStore.nodeOffset(m_node);
const int targetParentObjectLocation = positionStore.nodeOffset(m_targetProperty.parentModelNode()); const int targetParentObjectLocation = positionStore.nodeOffset(m_targetProperty.parentModelNode());
@@ -352,7 +352,7 @@ QString MoveNodeRewriteAction::info() const
} }
} }
bool AddImportRewriteAction::execute(QmlDesigner::QmlRefactoring &refactoring, bool AddImportRewriteAction::execute(QmlRefactoring &refactoring,
ModelNodePositionStorage &/*positionStore*/) ModelNodePositionStorage &/*positionStore*/)
{ {
const bool result = refactoring.addImport(m_import); const bool result = refactoring.addImport(m_import);
@@ -370,7 +370,7 @@ QString AddImportRewriteAction::info() const
return toInfo(m_import); return toInfo(m_import);
} }
bool RemoveImportRewriteAction::execute(QmlDesigner::QmlRefactoring &refactoring, bool RemoveImportRewriteAction::execute(QmlRefactoring &refactoring,
ModelNodePositionStorage &/*positionStore*/) ModelNodePositionStorage &/*positionStore*/)
{ {
const bool result = refactoring.removeImport(m_import); const bool result = refactoring.removeImport(m_import);

View File

@@ -59,7 +59,6 @@
using namespace LanguageUtils; using namespace LanguageUtils;
using namespace QmlJS; using namespace QmlJS;
using namespace QmlJS::AST;
namespace { namespace {
@@ -170,34 +169,34 @@ static inline QVariant cleverConvert(const QString &value)
return QVariant(value); return QVariant(value);
} }
static bool isLiteralValue(ExpressionNode *expr) static bool isLiteralValue(AST::ExpressionNode *expr)
{ {
if (cast<NumericLiteral*>(expr)) if (AST::cast<AST::NumericLiteral*>(expr))
return true; return true;
else if (cast<StringLiteral*>(expr)) else if (AST::cast<AST::StringLiteral*>(expr))
return true; return true;
else if (UnaryPlusExpression *plusExpr = cast<UnaryPlusExpression*>(expr)) else if (AST::UnaryPlusExpression *plusExpr = AST::cast<AST::UnaryPlusExpression*>(expr))
return isLiteralValue(plusExpr->expression); return isLiteralValue(plusExpr->expression);
else if (UnaryMinusExpression *minusExpr = cast<UnaryMinusExpression*>(expr)) else if (AST::UnaryMinusExpression *minusExpr = AST::cast<AST::UnaryMinusExpression*>(expr))
return isLiteralValue(minusExpr->expression); return isLiteralValue(minusExpr->expression);
else if (cast<TrueLiteral*>(expr)) else if (AST::cast<AST::TrueLiteral*>(expr))
return true; return true;
else if (cast<FalseLiteral*>(expr)) else if (AST::cast<AST::FalseLiteral*>(expr))
return true; return true;
else else
return false; return false;
} }
static bool isLiteralValue(Statement *stmt) static bool isLiteralValue(AST::Statement *stmt)
{ {
ExpressionStatement *exprStmt = cast<ExpressionStatement *>(stmt); AST::ExpressionStatement *exprStmt = AST::cast<AST::ExpressionStatement *>(stmt);
if (exprStmt) if (exprStmt)
return isLiteralValue(exprStmt->expression); return isLiteralValue(exprStmt->expression);
else else
return false; return false;
} }
static inline bool isLiteralValue(UiScriptBinding *script) static inline bool isLiteralValue(AST::UiScriptBinding *script)
{ {
if (!script || !script->statement) if (!script || !script->statement)
return false; return false;
@@ -324,7 +323,7 @@ public:
: m_snapshot(snapshot) : m_snapshot(snapshot)
, m_doc(doc) , m_doc(doc)
, m_link(snapshot, vContext, , m_link(snapshot, vContext,
QmlJS::ModelManagerInterface::instance()->builtins(doc)) ModelManagerInterface::instance()->builtins(doc))
, m_context(m_link(doc, &m_diagnosticLinkMessages)) , m_context(m_link(doc, &m_diagnosticLinkMessages))
, m_scopeChain(doc, m_context) , m_scopeChain(doc, m_context)
, m_scopeBuilder(&m_scopeChain) , m_scopeBuilder(&m_scopeChain)
@@ -337,31 +336,31 @@ public:
Document::Ptr doc() const Document::Ptr doc() const
{ return m_doc; } { return m_doc; }
void enterScope(Node *node) void enterScope(AST::Node *node)
{ m_scopeBuilder.push(node); } { m_scopeBuilder.push(node); }
void leaveScope() void leaveScope()
{ m_scopeBuilder.pop(); } { m_scopeBuilder.pop(); }
void lookup(UiQualifiedId *astTypeNode, QString &typeName, int &majorVersion, void lookup(AST::UiQualifiedId *astTypeNode, QString &typeName, int &majorVersion,
int &minorVersion, QString &defaultPropertyName) int &minorVersion, QString &defaultPropertyName)
{ {
const ObjectValue *value = m_context->lookupType(m_doc.data(), astTypeNode); const ObjectValue *value = m_context->lookupType(m_doc.data(), astTypeNode);
defaultPropertyName = m_context->defaultPropertyName(value); defaultPropertyName = m_context->defaultPropertyName(value);
const CppComponentValue * qmlValue = value_cast<CppComponentValue>(value); const CppComponentValue *qmlValue = value_cast<CppComponentValue>(value);
if (qmlValue) { if (qmlValue) {
typeName = qmlValue->moduleName() + QStringLiteral(".") + qmlValue->className(); typeName = qmlValue->moduleName() + QStringLiteral(".") + qmlValue->className();
majorVersion = qmlValue->componentVersion().majorVersion(); majorVersion = qmlValue->componentVersion().majorVersion();
minorVersion = qmlValue->componentVersion().minorVersion(); minorVersion = qmlValue->componentVersion().minorVersion();
} else { } else {
for (UiQualifiedId *iter = astTypeNode; iter; iter = iter->next) for (AST::UiQualifiedId *iter = astTypeNode; iter; iter = iter->next)
if (!iter->next && !iter->name.isEmpty()) if (!iter->next && !iter->name.isEmpty())
typeName = iter->name.toString(); typeName = iter->name.toString();
QString fullTypeName; QString fullTypeName;
for (UiQualifiedId *iter = astTypeNode; iter; iter = iter->next) for (AST::UiQualifiedId *iter = astTypeNode; iter; iter = iter->next)
if (!iter->name.isEmpty()) if (!iter->name.isEmpty())
fullTypeName += iter->name.toString() + QLatin1Char('.'); fullTypeName += iter->name.toString() + QLatin1Char('.');
@@ -399,13 +398,13 @@ public:
/// When something is changed here, also change Check::checkScopeObjectMember in /// When something is changed here, also change Check::checkScopeObjectMember in
/// qmljscheck.cpp /// qmljscheck.cpp
/// ### Maybe put this into the context as a helper function. /// ### Maybe put this into the context as a helper function.
bool lookupProperty(const QString &prefix, const UiQualifiedId *id, const Value **property = 0, const ObjectValue **parentObject = 0, QString *name = 0) bool lookupProperty(const QString &prefix, const AST::UiQualifiedId *id, const Value **property = 0, const ObjectValue **parentObject = 0, QString *name = 0)
{ {
QList<const ObjectValue *> scopeObjects = m_scopeChain.qmlScopeObjects(); QList<const ObjectValue *> scopeObjects = m_scopeChain.qmlScopeObjects();
if (scopeObjects.isEmpty()) if (scopeObjects.isEmpty())
return false; return false;
if (! id) if (!id)
return false; // ### error? return false; // ### error?
if (id->name.isEmpty()) // possible after error recovery if (id->name.isEmpty()) // possible after error recovery
@@ -459,7 +458,7 @@ public:
value = m_context->lookupReference(ref); value = m_context->lookupReference(ref);
// member lookup // member lookup
const UiQualifiedId *idPart = id; const AST::UiQualifiedId *idPart = id;
if (prefix.isEmpty()) if (prefix.isEmpty())
idPart = idPart->next; idPart = idPart->next;
for (; idPart; idPart = idPart->next) { for (; idPart; idPart = idPart->next) {
@@ -519,7 +518,7 @@ public:
return false; return false;
} }
QVariant convertToVariant(const QString &astValue, const QString &propertyPrefix, UiQualifiedId *propertyId) QVariant convertToVariant(const QString &astValue, const QString &propertyPrefix, AST::UiQualifiedId *propertyId)
{ {
const bool hasQuotes = astValue.trimmed().left(1) == QStringLiteral("\"") && astValue.trimmed().right(1) == QStringLiteral("\""); const bool hasQuotes = astValue.trimmed().left(1) == QStringLiteral("\"") && astValue.trimmed().right(1) == QStringLiteral("\"");
const QString cleanedValue = fixEscapedUnicodeChar(deEscape(stripQuotes(astValue.trimmed()))); const QString cleanedValue = fixEscapedUnicodeChar(deEscape(stripQuotes(astValue.trimmed())));
@@ -571,7 +570,7 @@ public:
return value; return value;
} }
QVariant convertToEnum(Statement *rhs, const QString &propertyPrefix, UiQualifiedId *propertyId, const QString &astValue) QVariant convertToEnum(AST::Statement *rhs, const QString &propertyPrefix, AST::UiQualifiedId *propertyId, const QString &astValue)
{ {
QStringList astValueList = astValue.split(QStringLiteral(".")); QStringList astValueList = astValue.split(QStringLiteral("."));
@@ -580,7 +579,7 @@ public:
&& globalQtEnums().contains(astValueList.last())) && globalQtEnums().contains(astValueList.last()))
return QVariant::fromValue(Enumeration(astValue)); return QVariant::fromValue(Enumeration(astValue));
ExpressionStatement *eStmt = cast<ExpressionStatement *>(rhs); AST::ExpressionStatement *eStmt = AST::cast<AST::ExpressionStatement *>(rhs);
if (!eStmt || !eStmt->expression) if (!eStmt || !eStmt->expression)
return QVariant(); return QVariant();
@@ -598,12 +597,12 @@ public:
const ObjectValue *rhsValueObject = 0; const ObjectValue *rhsValueObject = 0;
QString rhsValueName; QString rhsValueName;
if (IdentifierExpression *idExp = cast<IdentifierExpression *>(eStmt->expression)) { if (AST::IdentifierExpression *idExp = AST::cast<AST::IdentifierExpression *>(eStmt->expression)) {
if (!m_scopeChain.qmlScopeObjects().isEmpty()) if (!m_scopeChain.qmlScopeObjects().isEmpty())
rhsValueObject = m_scopeChain.qmlScopeObjects().last(); rhsValueObject = m_scopeChain.qmlScopeObjects().last();
if (!idExp->name.isEmpty()) if (!idExp->name.isEmpty())
rhsValueName = idExp->name.toString(); rhsValueName = idExp->name.toString();
} else if (FieldMemberExpression *memberExp = cast<FieldMemberExpression *>(eStmt->expression)) { } else if (AST::FieldMemberExpression *memberExp = AST::cast<AST::FieldMemberExpression *>(eStmt->expression)) {
Evaluate evaluate(&m_scopeChain); Evaluate evaluate(&m_scopeChain);
const Value *result = evaluate(memberExp->base); const Value *result = evaluate(memberExp->base);
rhsValueObject = result->asObjectValue(); rhsValueObject = result->asObjectValue();
@@ -706,8 +705,8 @@ void TextToModelMerger::setupImports(const Document::Ptr &doc,
{ {
QList<Import> existingImports = m_rewriterView->model()->imports(); QList<Import> existingImports = m_rewriterView->model()->imports();
for (UiHeaderItemList *iter = doc->qmlProgram()->headers; iter; iter = iter->next) { for (AST::UiHeaderItemList *iter = doc->qmlProgram()->headers; iter; iter = iter->next) {
UiImport *import = AST::cast<UiImport *>(iter->headerItem); AST::UiImport *import = AST::cast<AST::UiImport *>(iter->headerItem);
if (!import) if (!import)
continue; continue;
@@ -855,14 +854,14 @@ bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceH
if (!doc->isParsedCorrectly()) { if (!doc->isParsedCorrectly()) {
QList<RewriterView::Error> errors; QList<RewriterView::Error> errors;
foreach (const QmlJS::DiagnosticMessage &message, doc->diagnosticMessages()) foreach (const DiagnosticMessage &message, doc->diagnosticMessages())
errors.append(RewriterView::Error(message, QUrl::fromLocalFile(doc->fileName()))); errors.append(RewriterView::Error(message, QUrl::fromLocalFile(doc->fileName())));
m_rewriterView->setErrors(errors); m_rewriterView->setErrors(errors);
setActive(false); setActive(false);
return false; return false;
} }
snapshot.insert(doc); snapshot.insert(doc);
m_vContext = QmlJS::ModelManagerInterface::instance()->defaultVContext(Dialect::Qml, doc, true); m_vContext = ModelManagerInterface::instance()->defaultVContext(Dialect::Qml, doc, true);
ReadingContext ctxt(snapshot, doc, m_vContext); ReadingContext ctxt(snapshot, doc, m_vContext);
m_scopeChain = QSharedPointer<const ScopeChain>( m_scopeChain = QSharedPointer<const ScopeChain>(
new ScopeChain(ctxt.scopeChain())); new ScopeChain(ctxt.scopeChain()));
@@ -871,7 +870,7 @@ bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceH
QList<RewriterView::Error> errors; QList<RewriterView::Error> errors;
QList<RewriterView::Error> warnings; QList<RewriterView::Error> warnings;
foreach (const QmlJS::DiagnosticMessage &diagnosticMessage, ctxt.diagnosticLinkMessages()) { foreach (const DiagnosticMessage &diagnosticMessage, ctxt.diagnosticLinkMessages()) {
errors.append(RewriterView::Error(diagnosticMessage, QUrl::fromLocalFile(doc->fileName()))); errors.append(RewriterView::Error(diagnosticMessage, QUrl::fromLocalFile(doc->fileName())));
} }
@@ -879,13 +878,13 @@ bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceH
setupPossibleImports(snapshot, m_vContext); setupPossibleImports(snapshot, m_vContext);
if (m_rewriterView->model()->imports().isEmpty()) { if (m_rewriterView->model()->imports().isEmpty()) {
const QmlJS::DiagnosticMessage diagnosticMessage(QmlJS::Severity::Error, AST::SourceLocation(0, 0, 0, 0), QCoreApplication::translate("QmlDesigner::TextToModelMerger", "No import statements found")); const DiagnosticMessage diagnosticMessage(Severity::Error, AST::SourceLocation(0, 0, 0, 0), QCoreApplication::translate("QmlDesigner::TextToModelMerger", "No import statements found"));
errors.append(RewriterView::Error(diagnosticMessage, QUrl::fromLocalFile(doc->fileName()))); errors.append(RewriterView::Error(diagnosticMessage, QUrl::fromLocalFile(doc->fileName())));
} }
foreach (const QmlDesigner::Import &import, m_rewriterView->model()->imports()) { foreach (const QmlDesigner::Import &import, m_rewriterView->model()->imports()) {
if (import.isLibraryImport() && import.url() == QStringLiteral("QtQuick") && !supportedQtQuickVersion(import.version())) { if (import.isLibraryImport() && import.url() == QStringLiteral("QtQuick") && !supportedQtQuickVersion(import.version())) {
const QmlJS::DiagnosticMessage diagnosticMessage(QmlJS::Severity::Error, AST::SourceLocation(0, 0, 0, 0), const DiagnosticMessage diagnosticMessage(Severity::Error, AST::SourceLocation(0, 0, 0, 0),
QCoreApplication::translate("QmlDesigner::TextToModelMerger", "Unsupported QtQuick version")); QCoreApplication::translate("QmlDesigner::TextToModelMerger", "Unsupported QtQuick version"));
errors.append(RewriterView::Error(diagnosticMessage, QUrl::fromLocalFile(doc->fileName()))); errors.append(RewriterView::Error(diagnosticMessage, QUrl::fromLocalFile(doc->fileName())));
} }
@@ -955,8 +954,8 @@ bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceH
} }
setupUsedImports(); setupUsedImports();
UiObjectMember *astRootNode = 0; AST::UiObjectMember *astRootNode = 0;
if (UiProgram *program = doc->qmlProgram()) if (AST::UiProgram *program = doc->qmlProgram())
if (program->members) if (program->members)
astRootNode = program->members->member; astRootNode = program->members->member;
ModelNode modelRootNode = m_rewriterView->rootModelNode(); ModelNode modelRootNode = m_rewriterView->rootModelNode();
@@ -981,12 +980,12 @@ bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceH
} }
void TextToModelMerger::syncNode(ModelNode &modelNode, void TextToModelMerger::syncNode(ModelNode &modelNode,
UiObjectMember *astNode, AST::UiObjectMember *astNode,
ReadingContext *context, ReadingContext *context,
DifferenceHandler &differenceHandler) DifferenceHandler &differenceHandler)
{ {
UiQualifiedId *astObjectType = qualifiedTypeNameId(astNode); AST::UiQualifiedId *astObjectType = qualifiedTypeNameId(astNode);
UiObjectInitializer *astInitializer = initializerOfObject(astNode); AST::UiObjectInitializer *astInitializer = initializerOfObject(astNode);
if (!astObjectType || !astInitializer) if (!astObjectType || !astInitializer)
return; return;
@@ -1011,8 +1010,8 @@ void TextToModelMerger::syncNode(ModelNode &modelNode,
} }
if (modelNode.isRootNode() && isComponentType(typeName)) { if (modelNode.isRootNode() && isComponentType(typeName)) {
for (UiObjectMemberList *iter = astInitializer->members; iter; iter = iter->next) { for (AST::UiObjectMemberList *iter = astInitializer->members; iter; iter = iter->next) {
if (UiObjectDefinition *def = cast<UiObjectDefinition *>(iter->member)) { if (AST::UiObjectDefinition *def = AST::cast<AST::UiObjectDefinition *>(iter->member)) {
syncNode(modelNode, def, context, differenceHandler); syncNode(modelNode, def, context, differenceHandler);
return; return;
} }
@@ -1044,20 +1043,20 @@ void TextToModelMerger::syncNode(ModelNode &modelNode,
QSet<PropertyName> modelPropertyNames = QSet<PropertyName>::fromList(modelNode.propertyNames()); QSet<PropertyName> modelPropertyNames = QSet<PropertyName>::fromList(modelNode.propertyNames());
if (!modelNode.id().isEmpty()) if (!modelNode.id().isEmpty())
modelPropertyNames.insert("id"); modelPropertyNames.insert("id");
QList<UiObjectMember *> defaultPropertyItems; QList<AST::UiObjectMember *> defaultPropertyItems;
for (UiObjectMemberList *iter = astInitializer->members; iter; iter = iter->next) { for (AST::UiObjectMemberList *iter = astInitializer->members; iter; iter = iter->next) {
UiObjectMember *member = iter->member; AST::UiObjectMember *member = iter->member;
if (!member) if (!member)
continue; continue;
if (UiArrayBinding *array = cast<UiArrayBinding *>(member)) { if (AST::UiArrayBinding *array = AST::cast<AST::UiArrayBinding *>(member)) {
const QString astPropertyName = toString(array->qualifiedId); const QString astPropertyName = toString(array->qualifiedId);
if (isPropertyChangesType(typeName) || isConnectionsType(typeName) || context->lookupProperty(QString(), array->qualifiedId)) { if (isPropertyChangesType(typeName) || isConnectionsType(typeName) || context->lookupProperty(QString(), array->qualifiedId)) {
AbstractProperty modelProperty = modelNode.property(astPropertyName.toUtf8()); AbstractProperty modelProperty = modelNode.property(astPropertyName.toUtf8());
QList<UiObjectMember *> arrayMembers; QList<AST::UiObjectMember *> arrayMembers;
for (UiArrayMemberList *iter = array->members; iter; iter = iter->next) for (AST::UiArrayMemberList *iter = array->members; iter; iter = iter->next)
if (UiObjectMember *member = iter->member) if (AST::UiObjectMember *member = iter->member)
arrayMembers.append(member); arrayMembers.append(member);
syncArrayProperty(modelProperty, arrayMembers, context, differenceHandler); syncArrayProperty(modelProperty, arrayMembers, context, differenceHandler);
@@ -1066,7 +1065,7 @@ void TextToModelMerger::syncNode(ModelNode &modelNode,
qWarning() << "Skipping invalid array property" << astPropertyName qWarning() << "Skipping invalid array property" << astPropertyName
<< "for node type" << modelNode.type(); << "for node type" << modelNode.type();
} }
} else if (UiObjectDefinition *def = cast<UiObjectDefinition *>(member)) { } else if (AST::UiObjectDefinition *def = AST::cast<AST::UiObjectDefinition *>(member)) {
const QString &name = def->qualifiedTypeNameId->name.toString(); const QString &name = def->qualifiedTypeNameId->name.toString();
if (name.isEmpty() || !name.at(0).isUpper()) { if (name.isEmpty() || !name.at(0).isUpper()) {
QStringList props = syncGroupedProperties(modelNode, QStringList props = syncGroupedProperties(modelNode,
@@ -1079,7 +1078,7 @@ void TextToModelMerger::syncNode(ModelNode &modelNode,
} else { } else {
defaultPropertyItems.append(member); defaultPropertyItems.append(member);
} }
} else if (UiObjectBinding *binding = cast<UiObjectBinding *>(member)) { } else if (AST::UiObjectBinding *binding = AST::cast<AST::UiObjectBinding *>(member)) {
const QString astPropertyName = toString(binding->qualifiedId); const QString astPropertyName = toString(binding->qualifiedId);
if (binding->hasOnToken) { if (binding->hasOnToken) {
// skip value sources // skip value sources
@@ -1092,7 +1091,7 @@ void TextToModelMerger::syncNode(ModelNode &modelNode,
|| isConnectionsType(typeName)) { || isConnectionsType(typeName)) {
AbstractProperty modelProperty = modelNode.property(astPropertyName.toUtf8()); AbstractProperty modelProperty = modelNode.property(astPropertyName.toUtf8());
if (context->isArrayProperty(propertyType, containingObject, name)) if (context->isArrayProperty(propertyType, containingObject, name))
syncArrayProperty(modelProperty, QList<QmlJS::AST::UiObjectMember*>() << member, context, differenceHandler); syncArrayProperty(modelProperty, QList<AST::UiObjectMember*>() << member, context, differenceHandler);
else else
syncNodeProperty(modelProperty, binding, context, differenceHandler); syncNodeProperty(modelProperty, binding, context, differenceHandler);
modelPropertyNames.remove(astPropertyName.toUtf8()); modelPropertyNames.remove(astPropertyName.toUtf8());
@@ -1101,10 +1100,10 @@ void TextToModelMerger::syncNode(ModelNode &modelNode,
<< "for node type" << modelNode.type(); << "for node type" << modelNode.type();
} }
} }
} else if (UiScriptBinding *script = cast<UiScriptBinding *>(member)) { } else if (AST::UiScriptBinding *script = AST::cast<AST::UiScriptBinding *>(member)) {
modelPropertyNames.remove(syncScriptBinding(modelNode, QString(), script, context, differenceHandler)); modelPropertyNames.remove(syncScriptBinding(modelNode, QString(), script, context, differenceHandler));
} else if (UiPublicMember *property = cast<UiPublicMember *>(member)) { } else if (AST::UiPublicMember *property = AST::cast<AST::UiPublicMember *>(member)) {
if (property->type == UiPublicMember::Signal) if (property->type == AST::UiPublicMember::Signal)
continue; // QML designer doesn't support this yet. continue; // QML designer doesn't support this yet.
if (property->name.isEmpty() || property->memberType.isEmpty()) if (property->name.isEmpty() || property->memberType.isEmpty())
@@ -1163,32 +1162,32 @@ void TextToModelMerger::syncNode(ModelNode &modelNode,
context->leaveScope(); context->leaveScope();
} }
static QVariant parsePropertyExpression(ExpressionNode *expressionNode) static QVariant parsePropertyExpression(AST::ExpressionNode *expressionNode)
{ {
Q_ASSERT(expressionNode); Q_ASSERT(expressionNode);
ArrayLiteral *arrayLiteral = cast<ArrayLiteral *>(expressionNode); AST::ArrayLiteral *arrayLiteral = AST::cast<AST::ArrayLiteral *>(expressionNode);
if (arrayLiteral) { if (arrayLiteral) {
QList<QVariant> variantList; QList<QVariant> variantList;
for (ElementList *it = arrayLiteral->elements; it; it = it->next) for (AST::ElementList *it = arrayLiteral->elements; it; it = it->next)
variantList << parsePropertyExpression(it->expression); variantList << parsePropertyExpression(it->expression);
return variantList; return variantList;
} }
StringLiteral *stringLiteral = cast<AST::StringLiteral *>(expressionNode); AST::StringLiteral *stringLiteral = AST::cast<AST::StringLiteral *>(expressionNode);
if (stringLiteral) if (stringLiteral)
return stringLiteral->value.toString(); return stringLiteral->value.toString();
TrueLiteral *trueLiteral = cast<AST::TrueLiteral *>(expressionNode); AST::TrueLiteral *trueLiteral = AST::cast<AST::TrueLiteral *>(expressionNode);
if (trueLiteral) if (trueLiteral)
return true; return true;
FalseLiteral *falseLiteral = cast<AST::FalseLiteral *>(expressionNode); AST::FalseLiteral *falseLiteral = AST::cast<AST::FalseLiteral *>(expressionNode);
if (falseLiteral) if (falseLiteral)
return false; return false;
NumericLiteral *numericLiteral = cast<AST::NumericLiteral *>(expressionNode); AST::NumericLiteral *numericLiteral = AST::cast<AST::NumericLiteral *>(expressionNode);
if (numericLiteral) if (numericLiteral)
return numericLiteral->value; return numericLiteral->value;
@@ -1196,11 +1195,11 @@ static QVariant parsePropertyExpression(ExpressionNode *expressionNode)
return QVariant(); return QVariant();
} }
QVariant parsePropertyScriptBinding(UiScriptBinding *uiScriptBinding) QVariant parsePropertyScriptBinding(AST::UiScriptBinding *uiScriptBinding)
{ {
Q_ASSERT(uiScriptBinding); Q_ASSERT(uiScriptBinding);
ExpressionStatement *expStmt = cast<ExpressionStatement *>(uiScriptBinding->statement); AST::ExpressionStatement *expStmt = AST::cast<AST::ExpressionStatement *>(uiScriptBinding->statement);
if (!expStmt) if (!expStmt)
return QVariant(); return QVariant();
@@ -1209,7 +1208,7 @@ QVariant parsePropertyScriptBinding(UiScriptBinding *uiScriptBinding)
QmlDesigner::PropertyName TextToModelMerger::syncScriptBinding(ModelNode &modelNode, QmlDesigner::PropertyName TextToModelMerger::syncScriptBinding(ModelNode &modelNode,
const QString &prefix, const QString &prefix,
UiScriptBinding *script, AST::UiScriptBinding *script,
ReadingContext *context, ReadingContext *context,
DifferenceHandler &differenceHandler) DifferenceHandler &differenceHandler)
{ {
@@ -1304,7 +1303,7 @@ void TextToModelMerger::syncNodeId(ModelNode &modelNode, const QString &astObjec
} }
void TextToModelMerger::syncNodeProperty(AbstractProperty &modelProperty, void TextToModelMerger::syncNodeProperty(AbstractProperty &modelProperty,
UiObjectBinding *binding, AST::UiObjectBinding *binding,
ReadingContext *context, ReadingContext *context,
DifferenceHandler &differenceHandler) DifferenceHandler &differenceHandler)
{ {
@@ -1366,7 +1365,7 @@ void TextToModelMerger::syncSignalHandler(AbstractProperty &modelProperty,
void TextToModelMerger::syncArrayProperty(AbstractProperty &modelProperty, void TextToModelMerger::syncArrayProperty(AbstractProperty &modelProperty,
const QList<UiObjectMember *> &arrayMembers, const QList<AST::UiObjectMember *> &arrayMembers,
ReadingContext *context, ReadingContext *context,
DifferenceHandler &differenceHandler) DifferenceHandler &differenceHandler)
{ {
@@ -1403,7 +1402,7 @@ void TextToModelMerger::syncVariantProperty(AbstractProperty &modelProperty,
} }
void TextToModelMerger::syncNodeListProperty(NodeListProperty &modelListProperty, void TextToModelMerger::syncNodeListProperty(NodeListProperty &modelListProperty,
const QList<UiObjectMember *> arrayMembers, const QList<AST::UiObjectMember *> arrayMembers,
ReadingContext *context, ReadingContext *context,
DifferenceHandler &differenceHandler) DifferenceHandler &differenceHandler)
{ {
@@ -1416,7 +1415,7 @@ void TextToModelMerger::syncNodeListProperty(NodeListProperty &modelListProperty
for (int j = i; j < arrayMembers.size(); ++j) { for (int j = i; j < arrayMembers.size(); ++j) {
// more elements in the dom-list, so add them to the model // more elements in the dom-list, so add them to the model
UiObjectMember *arrayMember = arrayMembers.at(j); AST::UiObjectMember *arrayMember = arrayMembers.at(j);
const ModelNode newNode = differenceHandler.listPropertyMissingModelNode(modelListProperty, context, arrayMember); const ModelNode newNode = differenceHandler.listPropertyMissingModelNode(modelListProperty, context, arrayMember);
} }
@@ -1431,13 +1430,14 @@ ModelNode TextToModelMerger::createModelNode(const TypeName &typeName,
int majorVersion, int majorVersion,
int minorVersion, int minorVersion,
bool isImplicitComponent, bool isImplicitComponent,
UiObjectMember *astNode, AST::UiObjectMember *astNode,
ReadingContext *context, ReadingContext *context,
DifferenceHandler &differenceHandler) DifferenceHandler &differenceHandler)
{ {
QString nodeSource; QString nodeSource;
UiQualifiedId *astObjectType = qualifiedTypeNameId(astNode);
AST::UiQualifiedId *astObjectType = qualifiedTypeNameId(astNode);
if (isCustomParserType(typeName)) if (isCustomParserType(typeName))
nodeSource = textAt(context->doc(), nodeSource = textAt(context->doc(),
@@ -1475,16 +1475,16 @@ ModelNode TextToModelMerger::createModelNode(const TypeName &typeName,
QStringList TextToModelMerger::syncGroupedProperties(ModelNode &modelNode, QStringList TextToModelMerger::syncGroupedProperties(ModelNode &modelNode,
const QString &name, const QString &name,
UiObjectMemberList *members, AST::UiObjectMemberList *members,
ReadingContext *context, ReadingContext *context,
DifferenceHandler &differenceHandler) DifferenceHandler &differenceHandler)
{ {
QStringList props; QStringList props;
for (UiObjectMemberList *iter = members; iter; iter = iter->next) { for (AST::UiObjectMemberList *iter = members; iter; iter = iter->next) {
UiObjectMember *member = iter->member; AST::UiObjectMember *member = iter->member;
if (UiScriptBinding *script = cast<UiScriptBinding *>(member)) { if (AST::UiScriptBinding *script = AST::cast<AST::UiScriptBinding *>(member)) {
const QString prop = syncScriptBinding(modelNode, name, script, context, differenceHandler); const QString prop = syncScriptBinding(modelNode, name, script, context, differenceHandler);
if (!prop.isEmpty()) if (!prop.isEmpty())
props.append(prop); props.append(prop);
@@ -1542,7 +1542,7 @@ void ModelValidator::shouldBeSignalHandlerProperty(AbstractProperty &modelProper
} }
void ModelValidator::shouldBeNodeListProperty(AbstractProperty &modelProperty, void ModelValidator::shouldBeNodeListProperty(AbstractProperty &modelProperty,
const QList<UiObjectMember *> /*arrayMembers*/, const QList<AST::UiObjectMember *> /*arrayMembers*/,
ReadingContext * /*context*/) ReadingContext * /*context*/)
{ {
Q_UNUSED(modelProperty) Q_UNUSED(modelProperty)
@@ -1577,7 +1577,7 @@ void ModelValidator::shouldBeNodeProperty(AbstractProperty &modelProperty,
const TypeName &/*typeName*/, const TypeName &/*typeName*/,
int /*majorVersion*/, int /*majorVersion*/,
int /*minorVersion*/, int /*minorVersion*/,
UiObjectMember * /*astNode*/, AST::UiObjectMember * /*astNode*/,
ReadingContext * /*context*/) ReadingContext * /*context*/)
{ {
Q_UNUSED(modelProperty) Q_UNUSED(modelProperty)
@@ -1596,7 +1596,7 @@ void ModelValidator::modelNodeAbsentFromQml(ModelNode &modelNode)
ModelNode ModelValidator::listPropertyMissingModelNode(NodeListProperty &/*modelProperty*/, ModelNode ModelValidator::listPropertyMissingModelNode(NodeListProperty &/*modelProperty*/,
ReadingContext * /*context*/, ReadingContext * /*context*/,
UiObjectMember * /*arrayMember*/) AST::UiObjectMember * /*arrayMember*/)
{ {
Q_ASSERT(0); Q_ASSERT(0);
return ModelNode(); return ModelNode();
@@ -1683,7 +1683,7 @@ void ModelAmender::shouldBeSignalHandlerProperty(AbstractProperty &modelProperty
} }
void ModelAmender::shouldBeNodeListProperty(AbstractProperty &modelProperty, void ModelAmender::shouldBeNodeListProperty(AbstractProperty &modelProperty,
const QList<UiObjectMember *> arrayMembers, const QList<AST::UiObjectMember *> arrayMembers,
ReadingContext *context) ReadingContext *context)
{ {
ModelNode theNode = modelProperty.parentModelNode(); ModelNode theNode = modelProperty.parentModelNode();
@@ -1724,7 +1724,7 @@ void ModelAmender::shouldBeNodeProperty(AbstractProperty &modelProperty,
const TypeName &typeName, const TypeName &typeName,
int majorVersion, int majorVersion,
int minorVersion, int minorVersion,
UiObjectMember *astNode, AST::UiObjectMember *astNode,
ReadingContext *context) ReadingContext *context)
{ {
ModelNode theNode = modelProperty.parentModelNode(); ModelNode theNode = modelProperty.parentModelNode();
@@ -1754,14 +1754,14 @@ void ModelAmender::modelNodeAbsentFromQml(ModelNode &modelNode)
ModelNode ModelAmender::listPropertyMissingModelNode(NodeListProperty &modelProperty, ModelNode ModelAmender::listPropertyMissingModelNode(NodeListProperty &modelProperty,
ReadingContext *context, ReadingContext *context,
UiObjectMember *arrayMember) AST::UiObjectMember *arrayMember)
{ {
UiQualifiedId *astObjectType = 0; AST::UiQualifiedId *astObjectType = 0;
UiObjectInitializer *astInitializer = 0; AST::UiObjectInitializer *astInitializer = 0;
if (UiObjectDefinition *def = cast<UiObjectDefinition *>(arrayMember)) { if (AST::UiObjectDefinition *def = AST::cast<AST::UiObjectDefinition *>(arrayMember)) {
astObjectType = def->qualifiedTypeNameId; astObjectType = def->qualifiedTypeNameId;
astInitializer = def->initializer; astInitializer = def->initializer;
} else if (UiObjectBinding *bin = cast<UiObjectBinding *>(arrayMember)) { } else if (AST::UiObjectBinding *bin = AST::cast<AST::UiObjectBinding *>(arrayMember)) {
astObjectType = bin->qualifiedTypeNameId; astObjectType = bin->qualifiedTypeNameId;
astInitializer = bin->initializer; astInitializer = bin->initializer;
} }
@@ -1815,7 +1815,7 @@ void ModelAmender::typeDiffers(bool isRootNode,
const TypeName &typeName, const TypeName &typeName,
int majorVersion, int majorVersion,
int minorVersion, int minorVersion,
QmlJS::AST::UiObjectMember *astNode, AST::UiObjectMember *astNode,
ReadingContext *context) ReadingContext *context)
{ {
const bool propertyTakesComponent = modelNode.hasParentProperty() && propertyIsComponentType(modelNode.parentProperty(), typeName, modelNode.model()); const bool propertyTakesComponent = modelNode.hasParentProperty() && propertyIsComponentType(modelNode.parentProperty(), typeName, modelNode.model());
@@ -1926,14 +1926,14 @@ void TextToModelMerger::delayedSetup()
} }
QString TextToModelMerger::textAt(const Document::Ptr &doc, QString TextToModelMerger::textAt(const Document::Ptr &doc,
const SourceLocation &location) const AST::SourceLocation &location)
{ {
return doc->source().mid(location.offset, location.length); return doc->source().mid(location.offset, location.length);
} }
QString TextToModelMerger::textAt(const Document::Ptr &doc, QString TextToModelMerger::textAt(const Document::Ptr &doc,
const SourceLocation &from, const AST::SourceLocation &from,
const SourceLocation &to) const AST::SourceLocation &to)
{ {
return doc->source().mid(from.offset, to.end() - from.begin()); return doc->source().mid(from.offset, to.end() - from.begin());
} }

View File

@@ -125,7 +125,7 @@ QmlExpressionUnderCursor::QmlExpressionUnderCursor()
: _expressionNode(0), _expressionOffset(0), _expressionLength(0) : _expressionNode(0), _expressionOffset(0), _expressionLength(0)
{} {}
QmlJS::AST::ExpressionNode *QmlExpressionUnderCursor::operator()(const QTextCursor &cursor) ExpressionNode *QmlExpressionUnderCursor::operator()(const QTextCursor &cursor)
{ {
_expressionNode = 0; _expressionNode = 0;
_expressionOffset = -1; _expressionOffset = -1;
@@ -152,4 +152,3 @@ ExpressionNode *QmlExpressionUnderCursor::expressionNode() const
{ {
return _expressionNode; return _expressionNode;
} }

View File

@@ -651,7 +651,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
// currently path-in-stringliteral is the only completion available in imports // currently path-in-stringliteral is the only completion available in imports
if (contextFinder.isInImport()) { if (contextFinder.isInImport()) {
QmlJS::ModelManagerInterface::ProjectInfo pInfo = QmlJS::ModelManagerInterface::instance() ModelManagerInterface::ProjectInfo pInfo = ModelManagerInterface::instance()
->projectInfo(ProjectExplorer::ProjectTree::currentProject()); ->projectInfo(ProjectExplorer::ProjectTree::currentProject());
QmlBundle platform = pInfo.extendedBundle.bundleForLanguage(document->language()); QmlBundle platform = pInfo.extendedBundle.bundleForLanguage(document->language());
if (!platform.supportedImports().isEmpty()) { if (!platform.supportedImports().isEmpty()) {
@@ -661,8 +661,8 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
expressionUnderCursor(tc); expressionUnderCursor(tc);
QString libVersion = contextFinder.libVersionImport(); QString libVersion = contextFinder.libVersionImport();
if (!libVersion.isNull()) { if (!libVersion.isNull()) {
QStringList completions=platform.supportedImports().complete(libVersion, QString(), QmlJS::PersistentTrie::LookupFlags(QmlJS::PersistentTrie::CaseInsensitive|QmlJS::PersistentTrie::SkipChars|QmlJS::PersistentTrie::SkipSpaces)); QStringList completions=platform.supportedImports().complete(libVersion, QString(), PersistentTrie::LookupFlags(PersistentTrie::CaseInsensitive|PersistentTrie::SkipChars|PersistentTrie::SkipSpaces));
completions = QmlJS::PersistentTrie::matchStrengthSort(libVersion, completions); completions = PersistentTrie::matchStrengthSort(libVersion, completions);
int toSkip = qMax(libVersion.lastIndexOf(QLatin1Char(' ')) int toSkip = qMax(libVersion.lastIndexOf(QLatin1Char(' '))
, libVersion.lastIndexOf(QLatin1Char('.'))); , libVersion.lastIndexOf(QLatin1Char('.')));
@@ -691,7 +691,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
tc.setPosition(m_startPosition - 1); tc.setPosition(m_startPosition - 1);
QmlExpressionUnderCursor expressionUnderCursor; QmlExpressionUnderCursor expressionUnderCursor;
QmlJS::AST::ExpressionNode *expression = expressionUnderCursor(tc); AST::ExpressionNode *expression = expressionUnderCursor(tc);
if (expression != 0 && ! isLiteral(expression)) { if (expression != 0 && ! isLiteral(expression)) {
// Evaluate the expression under cursor. // Evaluate the expression under cursor.

View File

@@ -134,8 +134,8 @@ void QmlJSEditorWidget::finalizeInitialization()
textDocument()->setCodec(QTextCodec::codecForName("UTF-8")); // qml files are defined to be utf-8 textDocument()->setCodec(QTextCodec::codecForName("UTF-8")); // qml files are defined to be utf-8
m_modelManager = QmlJS::ModelManagerInterface::instance(); m_modelManager = ModelManagerInterface::instance();
m_contextPane = ExtensionSystem::PluginManager::getObject<QmlJS::IContextPane>(); m_contextPane = ExtensionSystem::PluginManager::getObject<IContextPane>();
m_modelManager->activateScan(); m_modelManager->activateScan();
@@ -207,7 +207,7 @@ static void appendExtraSelectionsForMessages(
} }
} }
void QmlJSEditorWidget::updateCodeWarnings(QmlJS::Document::Ptr doc) void QmlJSEditorWidget::updateCodeWarnings(Document::Ptr doc)
{ {
if (doc->ast()) { if (doc->ast()) {
setExtraSelections(CodeWarningsSelection, QList<QTextEdit::ExtraSelection>()); setExtraSelections(CodeWarningsSelection, QList<QTextEdit::ExtraSelection>());
@@ -348,7 +348,7 @@ void QmlJSEditorWidget::updateUses()
continue; continue;
QTextEdit::ExtraSelection sel; QTextEdit::ExtraSelection sel;
sel.format = textDocument()->fontSettings().toTextCharFormat(TextEditor::C_OCCURRENCES); sel.format = textDocument()->fontSettings().toTextCharFormat(C_OCCURRENCES);
sel.cursor = textCursor(); sel.cursor = textCursor();
sel.cursor.setPosition(loc.begin()); sel.cursor.setPosition(loc.begin());
sel.cursor.setPosition(loc.end(), QTextCursor::KeepAnchor); sel.cursor.setPosition(loc.end(), QTextCursor::KeepAnchor);
@@ -791,7 +791,7 @@ void QmlJSEditorWidget::semanticInfoUpdated(const SemanticInfo &semanticInfo)
if (m_firstSementicInfo) { if (m_firstSementicInfo) {
m_firstSementicInfo = false; m_firstSementicInfo = false;
if (semanticInfo.document->language() == Dialect::QmlQtQuick2Ui) { if (semanticInfo.document->language() == Dialect::QmlQtQuick2Ui) {
Core::InfoBarEntry info(Core::Id(Constants::QML_UI_FILE_WARNING), InfoBarEntry info(Id(Constants::QML_UI_FILE_WARNING),
tr("This file should only be edited in <b>Design</b> mode.")); tr("This file should only be edited in <b>Design</b> mode."));
info.setCustomButtonInfo(tr("Switch Mode"), []() { ModeManager::activateMode(Core::Constants::MODE_DESIGN); }); info.setCustomButtonInfo(tr("Switch Mode"), []() { ModeManager::activateMode(Core::Constants::MODE_DESIGN); });
textDocument()->infoBar()->addInfo(info); textDocument()->infoBar()->addInfo(info);
@@ -840,16 +840,16 @@ bool QmlJSEditorWidget::hideContextPane()
} }
AssistInterface *QmlJSEditorWidget::createAssistInterface( AssistInterface *QmlJSEditorWidget::createAssistInterface(
TextEditor::AssistKind assistKind, AssistKind assistKind,
TextEditor::AssistReason reason) const AssistReason reason) const
{ {
if (assistKind == TextEditor::Completion) { if (assistKind == Completion) {
return new QmlJSCompletionAssistInterface(document(), return new QmlJSCompletionAssistInterface(document(),
position(), position(),
textDocument()->filePath().toString(), textDocument()->filePath().toString(),
reason, reason,
m_qmlJsEditorDocument->semanticInfo()); m_qmlJsEditorDocument->semanticInfo());
} else if (assistKind == TextEditor::QuickFix) { } else if (assistKind == QuickFix) {
return new QmlJSQuickFixAssistInterface(const_cast<QmlJSEditorWidget *>(this), reason); return new QmlJSQuickFixAssistInterface(const_cast<QmlJSEditorWidget *>(this), reason);
} }
return 0; return 0;
@@ -868,7 +868,7 @@ QString QmlJSEditorWidget::foldReplacementText(const QTextBlock &block) const
return QLatin1String("id: ") + objectId + QLatin1String("..."); return QLatin1String("id: ") + objectId + QLatin1String("...");
} }
return TextEditor::TextEditorWidget::foldReplacementText(block); return TextEditorWidget::foldReplacementText(block);
} }

View File

@@ -89,8 +89,8 @@ QmlJSEditorPlugin::QmlJSEditorPlugin() :
m_reformatFileAction(0), m_reformatFileAction(0),
m_currentDocument(0), m_currentDocument(0),
m_jsonManager(new Utils::JsonSchemaManager( m_jsonManager(new Utils::JsonSchemaManager(
QStringList() << Core::ICore::userResourcePath() + QLatin1String("/json/") QStringList() << ICore::userResourcePath() + QLatin1String("/json/")
<< Core::ICore::resourcePath() + QLatin1String("/json/"))) << ICore::resourcePath() + QLatin1String("/json/")))
{ {
m_instance = this; m_instance = this;
} }
@@ -119,63 +119,63 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e
connect(m_modelManager, SIGNAL(aboutToRemoveFiles(QStringList)), connect(m_modelManager, SIGNAL(aboutToRemoveFiles(QStringList)),
m_qmlTaskManager, SLOT(documentsRemoved(QStringList))); m_qmlTaskManager, SLOT(documentsRemoved(QStringList)));
Core::Context context(Constants::C_QMLJSEDITOR_ID); Context context(Constants::C_QMLJSEDITOR_ID);
addAutoReleasedObject(new QmlJSEditorFactory); addAutoReleasedObject(new QmlJSEditorFactory);
Core::ActionContainer *contextMenu = Core::ActionManager::createMenu(Constants::M_CONTEXT); ActionContainer *contextMenu = ActionManager::createMenu(Constants::M_CONTEXT);
Core::ActionContainer *qmlToolsMenu = Core::ActionManager::actionContainer(Core::Id(QmlJSTools::Constants::M_TOOLS_QMLJS)); ActionContainer *qmlToolsMenu = ActionManager::actionContainer(Id(QmlJSTools::Constants::M_TOOLS_QMLJS));
Core::Context globalContext(Core::Constants::C_GLOBAL); Context globalContext(Core::Constants::C_GLOBAL);
qmlToolsMenu->addSeparator(globalContext); qmlToolsMenu->addSeparator(globalContext);
Core::Command *cmd; Command *cmd;
cmd = Core::ActionManager::command(TextEditor::Constants::FOLLOW_SYMBOL_UNDER_CURSOR); cmd = ActionManager::command(TextEditor::Constants::FOLLOW_SYMBOL_UNDER_CURSOR);
contextMenu->addAction(cmd); contextMenu->addAction(cmd);
qmlToolsMenu->addAction(cmd); qmlToolsMenu->addAction(cmd);
QAction *findUsagesAction = new QAction(tr("Find Usages"), this); QAction *findUsagesAction = new QAction(tr("Find Usages"), this);
cmd = Core::ActionManager::registerAction(findUsagesAction, Constants::FIND_USAGES, context); cmd = ActionManager::registerAction(findUsagesAction, Constants::FIND_USAGES, context);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+U"))); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+U")));
connect(findUsagesAction, SIGNAL(triggered()), this, SLOT(findUsages())); connect(findUsagesAction, SIGNAL(triggered()), this, SLOT(findUsages()));
contextMenu->addAction(cmd); contextMenu->addAction(cmd);
qmlToolsMenu->addAction(cmd); qmlToolsMenu->addAction(cmd);
QAction *renameUsagesAction = new QAction(tr("Rename Symbol Under Cursor"), this); QAction *renameUsagesAction = new QAction(tr("Rename Symbol Under Cursor"), this);
cmd = Core::ActionManager::registerAction(renameUsagesAction, Constants::RENAME_USAGES, context); cmd = ActionManager::registerAction(renameUsagesAction, Constants::RENAME_USAGES, context);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+R"))); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+R")));
connect(renameUsagesAction, SIGNAL(triggered()), this, SLOT(renameUsages())); connect(renameUsagesAction, SIGNAL(triggered()), this, SLOT(renameUsages()));
contextMenu->addAction(cmd); contextMenu->addAction(cmd);
qmlToolsMenu->addAction(cmd); qmlToolsMenu->addAction(cmd);
QAction *semanticScan = new QAction(tr("Run Checks"), this); QAction *semanticScan = new QAction(tr("Run Checks"), this);
cmd = Core::ActionManager::registerAction(semanticScan, Core::Id(Constants::RUN_SEMANTIC_SCAN), globalContext); cmd = ActionManager::registerAction(semanticScan, Id(Constants::RUN_SEMANTIC_SCAN), globalContext);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+C"))); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+C")));
connect(semanticScan, SIGNAL(triggered()), this, SLOT(runSemanticScan())); connect(semanticScan, SIGNAL(triggered()), this, SLOT(runSemanticScan()));
qmlToolsMenu->addAction(cmd); qmlToolsMenu->addAction(cmd);
m_reformatFileAction = new QAction(tr("Reformat File"), this); m_reformatFileAction = new QAction(tr("Reformat File"), this);
cmd = Core::ActionManager::registerAction(m_reformatFileAction, Core::Id(Constants::REFORMAT_FILE), context); cmd = ActionManager::registerAction(m_reformatFileAction, Id(Constants::REFORMAT_FILE), context);
connect(m_reformatFileAction, SIGNAL(triggered()), this, SLOT(reformatFile())); connect(m_reformatFileAction, SIGNAL(triggered()), this, SLOT(reformatFile()));
qmlToolsMenu->addAction(cmd); qmlToolsMenu->addAction(cmd);
QAction *showQuickToolbar = new QAction(tr("Show Qt Quick Toolbar"), this); QAction *showQuickToolbar = new QAction(tr("Show Qt Quick Toolbar"), this);
cmd = Core::ActionManager::registerAction(showQuickToolbar, Constants::SHOW_QT_QUICK_HELPER, context); cmd = ActionManager::registerAction(showQuickToolbar, Constants::SHOW_QT_QUICK_HELPER, context);
cmd->setDefaultKeySequence(Core::UseMacShortcuts ? QKeySequence(Qt::META + Qt::ALT + Qt::Key_Space) cmd->setDefaultKeySequence(UseMacShortcuts ? QKeySequence(Qt::META + Qt::ALT + Qt::Key_Space)
: QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Space)); : QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Space));
connect(showQuickToolbar, SIGNAL(triggered()), this, SLOT(showContextPane())); connect(showQuickToolbar, SIGNAL(triggered()), this, SLOT(showContextPane()));
contextMenu->addAction(cmd); contextMenu->addAction(cmd);
qmlToolsMenu->addAction(cmd); qmlToolsMenu->addAction(cmd);
// Insert marker for "Refactoring" menu: // Insert marker for "Refactoring" menu:
Core::Command *sep = contextMenu->addSeparator(globalContext); Command *sep = contextMenu->addSeparator(globalContext);
sep->action()->setObjectName(QLatin1String(Constants::M_REFACTORING_MENU_INSERTION_POINT)); sep->action()->setObjectName(QLatin1String(Constants::M_REFACTORING_MENU_INSERTION_POINT));
contextMenu->addSeparator(globalContext); contextMenu->addSeparator(globalContext);
cmd = Core::ActionManager::command(TextEditor::Constants::AUTO_INDENT_SELECTION); cmd = ActionManager::command(TextEditor::Constants::AUTO_INDENT_SELECTION);
contextMenu->addAction(cmd); contextMenu->addAction(cmd);
cmd = Core::ActionManager::command(TextEditor::Constants::UN_COMMENT_SELECTION); cmd = ActionManager::command(TextEditor::Constants::UN_COMMENT_SELECTION);
contextMenu->addAction(cmd); contextMenu->addAction(cmd);
m_quickFixAssistProvider = new QmlJSQuickFixAssistProvider; m_quickFixAssistProvider = new QmlJSQuickFixAssistProvider;
@@ -183,14 +183,14 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e
errorMessage->clear(); errorMessage->clear();
Core::FileIconProvider::registerIconOverlayForSuffix(":/qmljseditor/images/qmlfile.png", "qml"); FileIconProvider::registerIconOverlayForSuffix(":/qmljseditor/images/qmlfile.png", "qml");
registerQuickFixes(this); registerQuickFixes(this);
addAutoReleasedObject(new QmlJSOutlineWidgetFactory); addAutoReleasedObject(new QmlJSOutlineWidgetFactory);
addAutoReleasedObject(new QuickToolBar); addAutoReleasedObject(new QuickToolBar);
addAutoReleasedObject(new Internal::QuickToolBarSettingsPage); addAutoReleasedObject(new QuickToolBarSettingsPage);
connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)), SLOT(currentEditorChanged(Core::IEditor*))); connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)), SLOT(currentEditorChanged(Core::IEditor*)));
@@ -217,13 +217,13 @@ Utils::JsonSchemaManager *QmlJSEditorPlugin::jsonManager() const
void QmlJSEditorPlugin::findUsages() void QmlJSEditorPlugin::findUsages()
{ {
if (QmlJSEditorWidget *editor = qobject_cast<QmlJSEditorWidget*>(Core::EditorManager::currentEditor()->widget())) if (QmlJSEditorWidget *editor = qobject_cast<QmlJSEditorWidget*>(EditorManager::currentEditor()->widget()))
editor->findUsages(); editor->findUsages();
} }
void QmlJSEditorPlugin::renameUsages() void QmlJSEditorPlugin::renameUsages()
{ {
if (QmlJSEditorWidget *editor = qobject_cast<QmlJSEditorWidget*>(Core::EditorManager::currentEditor()->widget())) if (QmlJSEditorWidget *editor = qobject_cast<QmlJSEditorWidget*>(EditorManager::currentEditor()->widget()))
editor->renameUsages(); editor->renameUsages();
} }
@@ -242,15 +242,15 @@ void QmlJSEditorPlugin::reformatFile()
void QmlJSEditorPlugin::showContextPane() void QmlJSEditorPlugin::showContextPane()
{ {
if (QmlJSEditorWidget *editor = qobject_cast<QmlJSEditorWidget*>(Core::EditorManager::currentEditor()->widget())) if (QmlJSEditorWidget *editor = qobject_cast<QmlJSEditorWidget*>(EditorManager::currentEditor()->widget()))
editor->showContextPane(); editor->showContextPane();
} }
Core::Command *QmlJSEditorPlugin::addToolAction(QAction *a, Command *QmlJSEditorPlugin::addToolAction(QAction *a,
Core::Context &context, Core::Id id, Context &context, Id id,
Core::ActionContainer *c1, const QString &keySequence) ActionContainer *c1, const QString &keySequence)
{ {
Core::Command *command = Core::ActionManager::registerAction(a, id, context); Command *command = ActionManager::registerAction(a, id, context);
if (!keySequence.isEmpty()) if (!keySequence.isEmpty())
command->setDefaultKeySequence(QKeySequence(keySequence)); command->setDefaultKeySequence(QKeySequence(keySequence));
c1->addAction(command); c1->addAction(command);
@@ -262,7 +262,7 @@ QmlJSQuickFixAssistProvider *QmlJSEditorPlugin::quickFixAssistProvider() const
return m_quickFixAssistProvider; return m_quickFixAssistProvider;
} }
void QmlJSEditorPlugin::currentEditorChanged(Core::IEditor *editor) void QmlJSEditorPlugin::currentEditorChanged(IEditor *editor)
{ {
QmlJSEditorDocument *document = 0; QmlJSEditorDocument *document = 0;
if (editor) if (editor)

View File

@@ -834,7 +834,7 @@ static void find_helper(QFutureInterface<FindReferences::Usage> &future,
if (!doc) if (!doc)
return; return;
QmlJS::ModelManagerInterface *modelManager = QmlJS::ModelManagerInterface::instance(); ModelManagerInterface *modelManager = ModelManagerInterface::instance();
Link link(snapshot, modelManager->defaultVContext(doc->language(), doc), modelManager->builtins(doc)); Link link(snapshot, modelManager->defaultVContext(doc->language(), doc), modelManager->builtins(doc));
ContextPtr context = link(); ContextPtr context = link();
@@ -957,12 +957,12 @@ void FindReferences::displayResults(int first, int last)
const QString label = tr("QML/JS Usages:"); const QString label = tr("QML/JS Usages:");
if (replacement.isEmpty()) { if (replacement.isEmpty()) {
m_currentSearch = Core::SearchResultWindow::instance()->startNewSearch( m_currentSearch = SearchResultWindow::instance()->startNewSearch(
label, QString(), symbolName, Core::SearchResultWindow::SearchOnly); label, QString(), symbolName, SearchResultWindow::SearchOnly);
} else { } else {
m_currentSearch = Core::SearchResultWindow::instance()->startNewSearch( m_currentSearch = SearchResultWindow::instance()->startNewSearch(
label, QString(), symbolName, Core::SearchResultWindow::SearchAndReplace, label, QString(), symbolName, SearchResultWindow::SearchAndReplace,
Core::SearchResultWindow::PreserveCaseDisabled); SearchResultWindow::PreserveCaseDisabled);
m_currentSearch->setTextToReplace(replacement); m_currentSearch->setTextToReplace(replacement);
connect(m_currentSearch, SIGNAL(replaceButtonClicked(QString,QList<Core::SearchResultItem>,bool)), connect(m_currentSearch, SIGNAL(replaceButtonClicked(QString,QList<Core::SearchResultItem>,bool)),
SLOT(onReplaceButtonClicked(QString,QList<Core::SearchResultItem>,bool))); SLOT(onReplaceButtonClicked(QString,QList<Core::SearchResultItem>,bool)));
@@ -971,7 +971,7 @@ void FindReferences::displayResults(int first, int last)
this, SLOT(openEditor(Core::SearchResultItem))); this, SLOT(openEditor(Core::SearchResultItem)));
connect(m_currentSearch, SIGNAL(cancelled()), this, SLOT(cancel())); connect(m_currentSearch, SIGNAL(cancelled()), this, SLOT(cancel()));
connect(m_currentSearch, SIGNAL(paused(bool)), this, SLOT(setPaused(bool))); connect(m_currentSearch, SIGNAL(paused(bool)), this, SLOT(setPaused(bool)));
Core::SearchResultWindow::instance()->popup(IOutputPane::Flags(IOutputPane::ModeSwitch | IOutputPane::WithFocus)); SearchResultWindow::instance()->popup(IOutputPane::Flags(IOutputPane::ModeSwitch | IOutputPane::WithFocus));
FutureProgress *progress = ProgressManager::addTask( FutureProgress *progress = ProgressManager::addTask(
m_watcher.future(), tr("Searching for Usages"), m_watcher.future(), tr("Searching for Usages"),
@@ -1014,7 +1014,7 @@ void FindReferences::setPaused(bool paused)
m_watcher.setPaused(paused); m_watcher.setPaused(paused);
} }
void FindReferences::openEditor(const Core::SearchResultItem &item) void FindReferences::openEditor(const SearchResultItem &item)
{ {
if (item.path.size() > 0) { if (item.path.size() > 0) {
EditorManager::openEditorAt(QDir::fromNativeSeparators(item.path.first()), EditorManager::openEditorAt(QDir::fromNativeSeparators(item.path.first()),
@@ -1024,7 +1024,7 @@ void FindReferences::openEditor(const Core::SearchResultItem &item)
} }
} }
void FindReferences::onReplaceButtonClicked(const QString &text, const QList<Core::SearchResultItem> &items, bool preserveCase) void FindReferences::onReplaceButtonClicked(const QString &text, const QList<SearchResultItem> &items, bool preserveCase)
{ {
const QStringList fileNames = TextEditor::BaseFileFind::replaceAll(text, items, preserveCase); const QStringList fileNames = TextEditor::BaseFileFind::replaceAll(text, items, preserveCase);
@@ -1039,9 +1039,9 @@ void FindReferences::onReplaceButtonClicked(const QString &text, const QList<Cor
} }
if (!changedOnDisk.isEmpty()) if (!changedOnDisk.isEmpty())
QmlJS::ModelManagerInterface::instance()->updateSourceFiles(changedOnDisk, true); ModelManagerInterface::instance()->updateSourceFiles(changedOnDisk, true);
if (!changedUnsavedEditors.isEmpty()) if (!changedUnsavedEditors.isEmpty())
QmlJS::ModelManagerInterface::instance()->updateSourceFiles(changedUnsavedEditors, false); ModelManagerInterface::instance()->updateSourceFiles(changedUnsavedEditors, false);
Core::SearchResultWindow::instance()->hide(); SearchResultWindow::instance()->hide();
} }

View File

@@ -47,15 +47,15 @@ QmlJSHighlighter::QmlJSHighlighter(QTextDocument *parent)
m_inMultilineComment(false) m_inMultilineComment(false)
{ {
m_currentBlockParentheses.reserve(20); m_currentBlockParentheses.reserve(20);
static QVector<TextEditor::TextStyle> categories; static QVector<TextStyle> categories;
if (categories.isEmpty()) { if (categories.isEmpty()) {
categories << TextEditor::C_NUMBER categories << C_NUMBER
<< TextEditor::C_STRING << C_STRING
<< TextEditor::C_TYPE << C_TYPE
<< TextEditor::C_KEYWORD << C_KEYWORD
<< TextEditor::C_FIELD << C_FIELD
<< TextEditor::C_COMMENT << C_COMMENT
<< TextEditor::C_VISUAL_WHITESPACE; << C_VISUAL_WHITESPACE;
} }
setTextFormatCategories(categories); setTextFormatCategories(categories);
} }

View File

@@ -94,7 +94,7 @@ namespace {
QmlJSHoverHandler::QmlJSHoverHandler() : m_modelManager(0) QmlJSHoverHandler::QmlJSHoverHandler() : m_modelManager(0)
{ {
m_modelManager = QmlJS::ModelManagerInterface::instance(); m_modelManager = ModelManagerInterface::instance();
} }
static inline QString getModuleName(const ScopeChain &scopeChain, const Document::Ptr &qmlDocument, static inline QString getModuleName(const ScopeChain &scopeChain, const Document::Ptr &qmlDocument,
@@ -377,8 +377,8 @@ void QmlJSHoverHandler::operateTooltip(TextEditorWidget *editorWidget, const QPo
Utils::ToolTip::show(point, toolTip(), editorWidget); Utils::ToolTip::show(point, toolTip(), editorWidget);
} }
void QmlJSHoverHandler::prettyPrintTooltip(const QmlJS::Value *value, void QmlJSHoverHandler::prettyPrintTooltip(const Value *value,
const QmlJS::ContextPtr &context) const ContextPtr &context)
{ {
if (! value) if (! value)
return; return;

View File

@@ -57,7 +57,7 @@ QmlJSQuickFixOperation::QmlJSQuickFixOperation(const QmlJSQuickFixInterface &int
void QmlJSQuickFixOperation::perform() void QmlJSQuickFixOperation::perform()
{ {
QmlJSRefactoringChanges refactoring(QmlJS::ModelManagerInterface::instance(), QmlJSRefactoringChanges refactoring(ModelManagerInterface::instance(),
m_interface->semanticInfo().snapshot); m_interface->semanticInfo().snapshot);
QmlJSRefactoringFilePtr current = refactoring.file(fileName()); QmlJSRefactoringFilePtr current = refactoring.file(fileName());

View File

@@ -48,7 +48,7 @@ using namespace Internal;
// QuickFixAssistInterface // QuickFixAssistInterface
// ----------------------- // -----------------------
QmlJSQuickFixAssistInterface::QmlJSQuickFixAssistInterface(QmlJSEditorWidget *editor, QmlJSQuickFixAssistInterface::QmlJSQuickFixAssistInterface(QmlJSEditorWidget *editor,
TextEditor::AssistReason reason) AssistReason reason)
: AssistInterface(editor->document(), editor->position(), : AssistInterface(editor->document(), editor->position(),
editor->textDocument()->filePath().toString(), reason) editor->textDocument()->filePath().toString(), reason)
, m_semanticInfo(editor->qmlJsEditorDocument()->semanticInfo()) , m_semanticInfo(editor->qmlJsEditorDocument()->semanticInfo())
@@ -94,7 +94,7 @@ IAssistProcessor *QmlJSQuickFixAssistProvider::createProcessor() const
QList<QuickFixFactory *> QmlJSQuickFixAssistProvider::quickFixFactories() const QList<QuickFixFactory *> QmlJSQuickFixAssistProvider::quickFixFactories() const
{ {
QList<TextEditor::QuickFixFactory *> results; QList<QuickFixFactory *> results;
foreach (QmlJSQuickFixFactory *f, ExtensionSystem::PluginManager::getObjects<QmlJSQuickFixFactory>()) foreach (QmlJSQuickFixFactory *f, ExtensionSystem::PluginManager::getObjects<QmlJSQuickFixFactory>())
results.append(f); results.append(f);
return results; return results;

View File

@@ -70,12 +70,12 @@ class SplitInitializerOp: public QmlJSQuickFixFactory
const int pos = interface->currentFile()->cursor().position(); const int pos = interface->currentFile()->cursor().position();
if (QmlJS::AST::Node *member = interface->semanticInfo().rangeAt(pos)) { if (Node *member = interface->semanticInfo().rangeAt(pos)) {
if (QmlJS::AST::UiObjectBinding *b = QmlJS::AST::cast<QmlJS::AST::UiObjectBinding *>(member)) { if (UiObjectBinding *b = AST::cast<UiObjectBinding *>(member)) {
if (b->initializer->lbraceToken.startLine == b->initializer->rbraceToken.startLine) if (b->initializer->lbraceToken.startLine == b->initializer->rbraceToken.startLine)
objectInitializer = b->initializer; objectInitializer = b->initializer;
} else if (QmlJS::AST::UiObjectDefinition *b = QmlJS::AST::cast<QmlJS::AST::UiObjectDefinition *>(member)) { } else if (UiObjectDefinition *b = AST::cast<UiObjectDefinition *>(member)) {
if (b->initializer->lbraceToken.startLine == b->initializer->rbraceToken.startLine) if (b->initializer->lbraceToken.startLine == b->initializer->rbraceToken.startLine)
objectInitializer = b->initializer; objectInitializer = b->initializer;
} }
@@ -106,9 +106,9 @@ class SplitInitializerOp: public QmlJSQuickFixFactory
Utils::ChangeSet changes; Utils::ChangeSet changes;
for (QmlJS::AST::UiObjectMemberList *it = _objectInitializer->members; it; it = it->next) { for (UiObjectMemberList *it = _objectInitializer->members; it; it = it->next) {
if (QmlJS::AST::UiObjectMember *member = it->member) { if (UiObjectMember *member = it->member) {
const QmlJS::AST::SourceLocation loc = member->firstSourceLocation(); const SourceLocation loc = member->firstSourceLocation();
// insert a newline at the beginning of this binding // insert a newline at the beginning of this binding
changes.insert(currentFile->startOf(loc), QLatin1String("\n")); changes.insert(currentFile->startOf(loc), QLatin1String("\n"));

View File

@@ -363,7 +363,7 @@ protected:
return false; return false;
} }
void addMessages(QList<QmlJS::DiagnosticMessage> messages, void addMessages(QList<DiagnosticMessage> messages,
const Document::Ptr &doc) const Document::Ptr &doc)
{ {
foreach (const DiagnosticMessage &d, messages) { foreach (const DiagnosticMessage &d, messages) {
@@ -399,10 +399,10 @@ protected:
} }
} }
void addMessages(const QList<QmlJS::StaticAnalysis::Message> &messages, void addMessages(const QList<StaticAnalysis::Message> &messages,
const Document::Ptr &doc) const Document::Ptr &doc)
{ {
foreach (const QmlJS::StaticAnalysis::Message &d, messages) { foreach (const StaticAnalysis::Message &d, messages) {
int line = d.location.startLine; int line = d.location.startLine;
int column = qMax(1U, d.location.startColumn); int column = qMax(1U, d.location.startColumn);
int length = d.location.length; int length = d.location.length;

View File

@@ -79,7 +79,7 @@ static inline const ObjectValue * getPropertyChangesTarget(Node *node, const Sco
} }
QuickToolBar::QuickToolBar(QObject *parent) QuickToolBar::QuickToolBar(QObject *parent)
: ::QmlJS::IContextPane(parent) : ::IContextPane(parent)
, m_editorWidget(0) , m_editorWidget(0)
, m_blockWriting(false) , m_blockWriting(false)
{ {
@@ -116,7 +116,7 @@ QuickToolBar::~QuickToolBar()
m_widget = 0; m_widget = 0;
} }
void QuickToolBar::apply(TextEditor::TextEditorWidget *editorWidget, Document::Ptr document, const ScopeChain *scopeChain, AST::Node *node, bool update, bool force) void QuickToolBar::apply(TextEditor::TextEditorWidget *editorWidget, Document::Ptr document, const ScopeChain *scopeChain, Node *node, bool update, bool force)
{ {
if (!QuickToolBarSettings::get().enableContextPane && !force && !update) { if (!QuickToolBarSettings::get().enableContextPane && !force && !update) {
contextWidget()->hide(); contextWidget()->hide();
@@ -246,7 +246,7 @@ void QuickToolBar::apply(TextEditor::TextEditorWidget *editorWidget, Document::P
} }
bool QuickToolBar::isAvailable(TextEditor::TextEditorWidget *, Document::Ptr document, AST::Node *node) bool QuickToolBar::isAvailable(TextEditor::TextEditorWidget *, Document::Ptr document, Node *node)
{ {
if (document.isNull()) if (document.isNull())
return false; return false;

View File

@@ -49,7 +49,7 @@ class QmlConsoleManagerPrivate
public: public:
Internal::QmlConsoleItemModel *qmlConsoleItemModel; Internal::QmlConsoleItemModel *qmlConsoleItemModel;
Internal::QmlConsolePane *qmlConsolePane; Internal::QmlConsolePane *qmlConsolePane;
QmlJS::IScriptEvaluator *scriptEvaluator; IScriptEvaluator *scriptEvaluator;
}; };
QmlConsoleManager::QmlConsoleManager(QObject *parent) QmlConsoleManager::QmlConsoleManager(QObject *parent)
@@ -81,7 +81,7 @@ ConsoleItem *QmlConsoleManager::rootItem() const
return d->qmlConsoleItemModel->root(); return d->qmlConsoleItemModel->root();
} }
void QmlConsoleManager::setScriptEvaluator(QmlJS::IScriptEvaluator *scriptEvaluator) void QmlConsoleManager::setScriptEvaluator(IScriptEvaluator *scriptEvaluator)
{ {
d->scriptEvaluator = scriptEvaluator; d->scriptEvaluator = scriptEvaluator;
if (!scriptEvaluator) if (!scriptEvaluator)

View File

@@ -40,10 +40,6 @@
namespace QmlJSTools { namespace QmlJSTools {
namespace {
typedef QmlJS::QmlBundle QmlBundle;
typedef QmlJS::QmlLanguageBundles QmlLanguageBundles;
}
using namespace QmlJS; using namespace QmlJS;
/*! /*!

View File

@@ -83,18 +83,18 @@ QmlJSCodeStylePreferencesWidget::~QmlJSCodeStylePreferencesWidget()
delete m_ui; delete m_ui;
} }
void QmlJSCodeStylePreferencesWidget::setPreferences(TextEditor::ICodeStylePreferences *preferences) void QmlJSCodeStylePreferencesWidget::setPreferences(ICodeStylePreferences *preferences)
{ {
m_preferences = preferences; m_preferences = preferences;
m_ui->tabPreferencesWidget->setPreferences(preferences); m_ui->tabPreferencesWidget->setPreferences(preferences);
if (m_preferences) if (m_preferences)
connect(m_preferences, &TextEditor::ICodeStylePreferences::currentTabSettingsChanged, connect(m_preferences, &ICodeStylePreferences::currentTabSettingsChanged,
this, &QmlJSCodeStylePreferencesWidget::slotSettingsChanged); this, &QmlJSCodeStylePreferencesWidget::slotSettingsChanged);
updatePreview(); updatePreview();
} }
void QmlJSCodeStylePreferencesWidget::decorateEditor(const TextEditor::FontSettings &fontSettings) void QmlJSCodeStylePreferencesWidget::decorateEditor(const FontSettings &fontSettings)
{ {
const ISnippetProvider *provider = ExtensionSystem::PluginManager::getObject<ISnippetProvider>( const ISnippetProvider *provider = ExtensionSystem::PluginManager::getObject<ISnippetProvider>(
[](ISnippetProvider *current) { [](ISnippetProvider *current) {
@@ -122,7 +122,7 @@ void QmlJSCodeStylePreferencesWidget::updatePreview()
{ {
QTextDocument *doc = m_ui->previewTextEdit->document(); QTextDocument *doc = m_ui->previewTextEdit->document();
const TextEditor::TabSettings &ts = m_preferences const TabSettings &ts = m_preferences
? m_preferences->currentTabSettings() ? m_preferences->currentTabSettings()
: TextEditorSettings::codeStyle()->tabSettings(); : TextEditorSettings::codeStyle()->tabSettings();
m_ui->previewTextEdit->textDocument()->setTabSettings(ts); m_ui->previewTextEdit->textDocument()->setTabSettings(ts);
@@ -157,9 +157,9 @@ QmlJSCodeStyleSettingsPage::QmlJSCodeStyleSettingsPage(/*QSharedPointer<CppFileS
QWidget *QmlJSCodeStyleSettingsPage::widget() QWidget *QmlJSCodeStyleSettingsPage::widget()
{ {
if (!m_widget) { if (!m_widget) {
TextEditor::SimpleCodeStylePreferences *originalTabPreferences SimpleCodeStylePreferences *originalTabPreferences
= QmlJSToolsSettings::globalCodeStyle(); = QmlJSToolsSettings::globalCodeStyle();
m_pageTabPreferences = new TextEditor::SimpleCodeStylePreferences(m_widget); m_pageTabPreferences = new SimpleCodeStylePreferences(m_widget);
m_pageTabPreferences->setDelegatingPool(originalTabPreferences->delegatingPool()); m_pageTabPreferences->setDelegatingPool(originalTabPreferences->delegatingPool());
m_pageTabPreferences->setTabSettings(originalTabPreferences->tabSettings()); m_pageTabPreferences->setTabSettings(originalTabPreferences->tabSettings());
m_pageTabPreferences->setCurrentDelegate(originalTabPreferences->currentDelegate()); m_pageTabPreferences->setCurrentDelegate(originalTabPreferences->currentDelegate());
@@ -175,7 +175,7 @@ void QmlJSCodeStyleSettingsPage::apply()
if (m_widget) { if (m_widget) {
QSettings *s = Core::ICore::settings(); QSettings *s = Core::ICore::settings();
TextEditor::SimpleCodeStylePreferences *originalTabPreferences = QmlJSToolsSettings::globalCodeStyle(); SimpleCodeStylePreferences *originalTabPreferences = QmlJSToolsSettings::globalCodeStyle();
if (originalTabPreferences->tabSettings() != m_pageTabPreferences->tabSettings()) { if (originalTabPreferences->tabSettings() != m_pageTabPreferences->tabSettings()) {
originalTabPreferences->setTabSettings(m_pageTabPreferences->tabSettings()); originalTabPreferences->setTabSettings(m_pageTabPreferences->tabSettings());
originalTabPreferences->toSettings(QLatin1String(QmlJSTools::Constants::QML_JS_SETTINGS_ID), s); originalTabPreferences->toSettings(QLatin1String(QmlJSTools::Constants::QML_JS_SETTINGS_ID), s);

View File

@@ -44,11 +44,11 @@ using namespace QmlJS::AST;
LocatorData::LocatorData(QObject *parent) LocatorData::LocatorData(QObject *parent)
: QObject(parent) : QObject(parent)
{ {
QmlJS::ModelManagerInterface *manager = QmlJS::ModelManagerInterface::instance(); ModelManagerInterface *manager = ModelManagerInterface::instance();
connect(manager, &QmlJS::ModelManagerInterface::documentUpdated, connect(manager, &ModelManagerInterface::documentUpdated,
this, &LocatorData::onDocumentUpdated); this, &LocatorData::onDocumentUpdated);
connect(manager, &QmlJS::ModelManagerInterface::aboutToRemoveFiles, connect(manager, &ModelManagerInterface::aboutToRemoveFiles,
this, &LocatorData::onAboutToRemoveFiles); this, &LocatorData::onAboutToRemoveFiles);
} }
@@ -185,7 +185,7 @@ QHash<QString, QList<LocatorData::Entry> > LocatorData::entries() const
return m_entries; return m_entries;
} }
void LocatorData::onDocumentUpdated(const QmlJS::Document::Ptr &doc) void LocatorData::onDocumentUpdated(const Document::Ptr &doc)
{ {
QList<Entry> entries = FunctionFinder().run(doc); QList<Entry> entries = FunctionFinder().run(doc);
QMutexLocker l(&m_mutex); QMutexLocker l(&m_mutex);

View File

@@ -71,7 +71,7 @@ using namespace QmlJSTools;
using namespace QmlJSTools::Internal; using namespace QmlJSTools::Internal;
ModelManagerInterface::ProjectInfo QmlJSTools::Internal::ModelManager::defaultProjectInfoForProject( ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject(
ProjectExplorer::Project *project) const ProjectExplorer::Project *project) const
{ {
ModelManagerInterface::ProjectInfo projectInfo(project); ModelManagerInterface::ProjectInfo projectInfo(project);
@@ -171,9 +171,9 @@ void QmlJSTools::setupProjectInfoQmlBundles(ModelManagerInterface::ProjectInfo &
} }
} }
QHash<QString,QmlJS::Dialect> ModelManager::languageForSuffix() const QHash<QString,Dialect> ModelManager::languageForSuffix() const
{ {
QHash<QString,QmlJS::Dialect> res = ModelManagerInterface::languageForSuffix(); QHash<QString,Dialect> res = ModelManagerInterface::languageForSuffix();
if (ICore::instance()) { if (ICore::instance()) {
Utils::MimeDatabase mdb; Utils::MimeDatabase mdb;
@@ -223,7 +223,7 @@ void ModelManager::delayedInitialization()
connect(ProjectExplorer::SessionManager::instance(), &ProjectExplorer::SessionManager::startupProjectChanged, connect(ProjectExplorer::SessionManager::instance(), &ProjectExplorer::SessionManager::startupProjectChanged,
this, &ModelManager::updateDefaultProjectInfo); this, &ModelManager::updateDefaultProjectInfo);
QmlJS::ViewerContext qbsVContext; ViewerContext qbsVContext;
qbsVContext.language = Dialect::QmlQbs; qbsVContext.language = Dialect::QmlQbs;
qbsVContext.maybeAddPath(ICore::resourcePath() + QLatin1String("/qbs")); qbsVContext.maybeAddPath(ICore::resourcePath() + QLatin1String("/qbs"));
setDefaultVContext(qbsVContext); setDefaultVContext(qbsVContext);

View File

@@ -40,7 +40,7 @@ CreatorCodeFormatter::CreatorCodeFormatter()
{ {
} }
CreatorCodeFormatter::CreatorCodeFormatter(const TextEditor::TabSettings &tabSettings) CreatorCodeFormatter::CreatorCodeFormatter(const TabSettings &tabSettings)
{ {
setTabSize(tabSettings.m_tabSize); setTabSize(tabSettings.m_tabSize);
setIndentSize(tabSettings.m_indentSize); setIndentSize(tabSettings.m_indentSize);

View File

@@ -39,9 +39,10 @@
#include <projectexplorer/editorconfiguration.h> #include <projectexplorer/editorconfiguration.h>
using namespace QmlJS; using namespace QmlJS;
using namespace QmlJSTools;
class QmlJSTools::QmlJSRefactoringChangesData : public TextEditor::RefactoringChangesData namespace QmlJSTools {
class QmlJSRefactoringChangesData : public TextEditor::RefactoringChangesData
{ {
public: public:
QmlJSRefactoringChangesData(ModelManagerInterface *modelManager, QmlJSRefactoringChangesData(ModelManagerInterface *modelManager,
@@ -90,8 +91,8 @@ public:
m_modelManager->updateSourceFiles(QStringList(fileName), true); m_modelManager->updateSourceFiles(QStringList(fileName), true);
} }
QmlJS::ModelManagerInterface *m_modelManager; ModelManagerInterface *m_modelManager;
QmlJS::Snapshot m_snapshot; Snapshot m_snapshot;
}; };
QmlJSRefactoringChanges::QmlJSRefactoringChanges(ModelManagerInterface *modelManager, QmlJSRefactoringChanges::QmlJSRefactoringChanges(ModelManagerInterface *modelManager,
@@ -129,7 +130,7 @@ QmlJSRefactoringFile::QmlJSRefactoringFile(const QString &fileName, const QShare
m_fileName.clear(); m_fileName.clear();
} }
QmlJSRefactoringFile::QmlJSRefactoringFile(TextEditor::TextEditorWidget *editor, QmlJS::Document::Ptr document) QmlJSRefactoringFile::QmlJSRefactoringFile(TextEditor::TextEditorWidget *editor, Document::Ptr document)
: RefactoringFile(editor) : RefactoringFile(editor)
, m_qmljsDocument(document) , m_qmljsDocument(document)
{ {
@@ -195,3 +196,5 @@ void QmlJSRefactoringFile::fileChanged()
m_qmljsDocument.clear(); m_qmljsDocument.clear();
RefactoringFile::fileChanged(); RefactoringFile::fileChanged();
} }
} // namespace QmlJSTools

View File

@@ -150,7 +150,7 @@ AST::Node *SemanticInfo::rangeAt(int cursorPosition) const
} }
// ### the name and behavior of this function is dubious // ### the name and behavior of this function is dubious
QmlJS::AST::Node *SemanticInfo::declaringMemberNoProperties(int cursorPosition) const Node *SemanticInfo::declaringMemberNoProperties(int cursorPosition) const
{ {
AST::Node *node = rangeAt(cursorPosition); AST::Node *node = rangeAt(cursorPosition);
@@ -191,7 +191,7 @@ QList<AST::Node *> SemanticInfo::rangePath(int cursorPosition) const
return path; return path;
} }
ScopeChain SemanticInfo::scopeChain(const QList<QmlJS::AST::Node *> &path) const ScopeChain SemanticInfo::scopeChain(const QList<Node *> &path) const
{ {
Q_ASSERT(m_rootScopeChain); Q_ASSERT(m_rootScopeChain);

View File

@@ -39,11 +39,13 @@
#include <QtTest> #include <QtTest>
using namespace QmlJS; using namespace QmlJS;
using namespace QmlJSTools;
void QmlJSTools::Internal::QmlJSToolsPlugin::test_basic() namespace QmlJSTools {
namespace Internal {
void QmlJSToolsPlugin::test_basic()
{ {
QmlJS::ModelManagerInterface *modelManager = QmlJS::ModelManagerInterface::instance(); ModelManagerInterface *modelManager = ModelManagerInterface::instance();
const QString welcomescreenRootPath = Core::ICore::resourcePath() + QLatin1String("/welcomescreen/welcomescreen.qml"); const QString welcomescreenRootPath = Core::ICore::resourcePath() + QLatin1String("/welcomescreen/welcomescreen.qml");
modelManager->updateSourceFiles(QStringList(welcomescreenRootPath), false); modelManager->updateSourceFiles(QStringList(welcomescreenRootPath), false);
@@ -88,3 +90,6 @@ void QmlJSTools::Internal::QmlJSToolsPlugin::test_basic()
QCOMPARE(qmlImageValue->className(), QLatin1String("Image")); QCOMPARE(qmlImageValue->className(), QLatin1String("Image"));
QCOMPARE(qmlImageValue->propertyType(QLatin1String("source")), QLatin1String("QUrl")); QCOMPARE(qmlImageValue->propertyType(QLatin1String("source")), QLatin1String("QUrl"));
} }
} // namespace Internal
} // namespace QmlJSTools

View File

@@ -131,13 +131,13 @@ ExtensionSystem::IPlugin::ShutdownFlag QmlJSToolsPlugin::aboutToShutdown()
return SynchronousShutdown; return SynchronousShutdown;
} }
void QmlJSToolsPlugin::onTaskStarted(Core::Id type) void QmlJSToolsPlugin::onTaskStarted(Id type)
{ {
if (type == QmlJS::Constants::TASK_INDEX) if (type == QmlJS::Constants::TASK_INDEX)
m_resetCodeModelAction->setEnabled(false); m_resetCodeModelAction->setEnabled(false);
} }
void QmlJSToolsPlugin::onAllTasksFinished(Core::Id type) void QmlJSToolsPlugin::onAllTasksFinished(Id type)
{ {
if (type == QmlJS::Constants::TASK_INDEX) if (type == QmlJS::Constants::TASK_INDEX)
m_resetCodeModelAction->setEnabled(true); m_resetCodeModelAction->setEnabled(true);

View File

@@ -49,7 +49,7 @@ namespace QmlJSTools {
const char idKey[] = "QmlJSGlobal"; const char idKey[] = "QmlJSGlobal";
static TextEditor::SimpleCodeStylePreferences *m_globalCodeStyle = 0; static SimpleCodeStylePreferences *m_globalCodeStyle = 0;
QmlJSToolsSettings::QmlJSToolsSettings(QObject *parent) QmlJSToolsSettings::QmlJSToolsSettings(QObject *parent)
: QObject(parent) : QObject(parent)

View File

@@ -50,8 +50,7 @@ LocalQmlProfilerRunner *LocalQmlProfilerRunner::createLocalRunner(
LocalApplicationRunConfiguration *larc = LocalApplicationRunConfiguration *larc =
qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration); qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration);
QTC_ASSERT(larc, return 0); QTC_ASSERT(larc, return 0);
ProjectExplorer::EnvironmentAspect *environment EnvironmentAspect *environment = runConfiguration->extraAspect<EnvironmentAspect>();
= runConfiguration->extraAspect<ProjectExplorer::EnvironmentAspect>();
QTC_ASSERT(environment, return 0); QTC_ASSERT(environment, return 0);
Configuration conf; Configuration conf;
conf.executable = larc->executable(); conf.executable = larc->executable();
@@ -102,8 +101,7 @@ void LocalQmlProfilerRunner::start()
m_launcher.setEnvironment(m_configuration.environment); m_launcher.setEnvironment(m_configuration.environment);
connect(&m_launcher, SIGNAL(processExited(int,QProcess::ExitStatus)), connect(&m_launcher, SIGNAL(processExited(int,QProcess::ExitStatus)),
this, SLOT(spontaneousStop(int,QProcess::ExitStatus))); this, SLOT(spontaneousStop(int,QProcess::ExitStatus)));
m_launcher.start(ProjectExplorer::ApplicationLauncher::Gui, m_configuration.executable, m_launcher.start(ApplicationLauncher::Gui, m_configuration.executable, arguments);
arguments);
emit started(); emit started();
} }

View File

@@ -96,7 +96,7 @@ void QmlProfilerAttachDialog::setPort(const int port)
d->portSpinBox->setValue(port); d->portSpinBox->setValue(port);
} }
ProjectExplorer::Kit *QmlProfilerAttachDialog::kit() const Kit *QmlProfilerAttachDialog::kit() const
{ {
return d->kitChooser->currentKit(); return d->kitChooser->currentKit();
} }

View File

@@ -342,7 +342,7 @@ void QmlProfilerClientManager::qmlComplete(qint64 maximumTime)
d->modelManager->traceTime()->increaseEndTime(maximumTime); d->modelManager->traceTime()->increaseEndTime(maximumTime);
d->qmlDataReady = true; d->qmlDataReady = true;
if (!d->v8clientplugin || if (!d->v8clientplugin ||
d->v8clientplugin.data()->state() != QmlDebug::QmlDebugClient::Enabled || d->v8clientplugin.data()->state() != QmlDebugClient::Enabled ||
d->v8DataReady) { d->v8DataReady) {
emit dataReadyForProcessing(); emit dataReadyForProcessing();
// once complete is sent, reset the flags // once complete is sent, reset the flags
@@ -355,7 +355,7 @@ void QmlProfilerClientManager::v8Complete()
{ {
d->v8DataReady = true; d->v8DataReady = true;
if (!d->qmlclientplugin || if (!d->qmlclientplugin ||
d->qmlclientplugin.data()->state() != QmlDebug::QmlDebugClient::Enabled || d->qmlclientplugin.data()->state() != QmlDebugClient::Enabled ||
d->qmlDataReady) { d->qmlDataReady) {
emit dataReadyForProcessing(); emit dataReadyForProcessing();
// once complete is sent, reset the flags // once complete is sent, reset the flags

View File

@@ -68,9 +68,9 @@ struct RootEventType : public QmlProfilerDataModel::QmlEventTypeData {
{ {
QString rootEventName = QmlProfilerEventsMainView::tr("<program>"); QString rootEventName = QmlProfilerEventsMainView::tr("<program>");
displayName = rootEventName; displayName = rootEventName;
location = QmlDebug::QmlEventLocation(rootEventName, 1, 1); location = QmlEventLocation(rootEventName, 1, 1);
message = QmlDebug::MaximumMessage; message = MaximumMessage;
rangeType = QmlDebug::MaximumRangeType; rangeType = MaximumRangeType;
detailType = -1; detailType = -1;
data = QmlProfilerEventsMainView::tr("Main Program"); data = QmlProfilerEventsMainView::tr("Main Program");
} }
@@ -339,30 +339,30 @@ bool QmlProfilerEventsWidget::showExtendedStatistics() const
void QmlProfilerEventsWidget::setShowJavaScript(bool show) void QmlProfilerEventsWidget::setShowJavaScript(bool show)
{ {
d->modelProxy->setEventTypeAccepted(QmlDebug::Javascript, show); d->modelProxy->setEventTypeAccepted(Javascript, show);
d->modelProxy->limitToRange(d->rangeStart, d->rangeEnd); d->modelProxy->limitToRange(d->rangeStart, d->rangeEnd);
} }
void QmlProfilerEventsWidget::setShowQml(bool show) void QmlProfilerEventsWidget::setShowQml(bool show)
{ {
d->modelProxy->setEventTypeAccepted(QmlDebug::Binding, show); d->modelProxy->setEventTypeAccepted(Binding, show);
d->modelProxy->setEventTypeAccepted(QmlDebug::HandlingSignal, show); d->modelProxy->setEventTypeAccepted(HandlingSignal, show);
d->modelProxy->setEventTypeAccepted(QmlDebug::Compiling, show); d->modelProxy->setEventTypeAccepted(Compiling, show);
d->modelProxy->setEventTypeAccepted(QmlDebug::Creating, show); d->modelProxy->setEventTypeAccepted(Creating, show);
d->modelProxy->limitToRange(d->rangeStart, d->rangeEnd); d->modelProxy->limitToRange(d->rangeStart, d->rangeEnd);
} }
bool QmlProfilerEventsWidget::showJavaScript() const bool QmlProfilerEventsWidget::showJavaScript() const
{ {
return d->modelProxy->eventTypeAccepted(QmlDebug::Javascript); return d->modelProxy->eventTypeAccepted(Javascript);
} }
bool QmlProfilerEventsWidget::showQml() const bool QmlProfilerEventsWidget::showQml() const
{ {
return d->modelProxy->eventTypeAccepted(QmlDebug::Binding) && return d->modelProxy->eventTypeAccepted(Binding) &&
d->modelProxy->eventTypeAccepted(QmlDebug::HandlingSignal) && d->modelProxy->eventTypeAccepted(HandlingSignal) &&
d->modelProxy->eventTypeAccepted(QmlDebug::Compiling) && d->modelProxy->eventTypeAccepted(Compiling) &&
d->modelProxy->eventTypeAccepted(QmlDebug::Creating); d->modelProxy->eventTypeAccepted(Creating);
} }
//////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////
@@ -700,15 +700,15 @@ void QmlProfilerEventsMainView::parseModelProxy()
} }
} }
QString QmlProfilerEventsMainView::nameForType(QmlDebug::RangeType typeNumber) QString QmlProfilerEventsMainView::nameForType(RangeType typeNumber)
{ {
switch (typeNumber) { switch (typeNumber) {
case QmlDebug::Painting: return QmlProfilerEventsMainView::tr("Paint"); case Painting: return QmlProfilerEventsMainView::tr("Paint");
case QmlDebug::Compiling: return QmlProfilerEventsMainView::tr("Compile"); case Compiling: return QmlProfilerEventsMainView::tr("Compile");
case QmlDebug::Creating: return QmlProfilerEventsMainView::tr("Create"); case Creating: return QmlProfilerEventsMainView::tr("Create");
case QmlDebug::Binding: return QmlProfilerEventsMainView::tr("Binding"); case Binding: return QmlProfilerEventsMainView::tr("Binding");
case QmlDebug::HandlingSignal: return QmlProfilerEventsMainView::tr("Signal"); case HandlingSignal: return QmlProfilerEventsMainView::tr("Signal");
case QmlDebug::Javascript: return QmlProfilerEventsMainView::tr("JavaScript"); case Javascript: return QmlProfilerEventsMainView::tr("JavaScript");
default: return QString(); default: return QString();
} }
} }

View File

@@ -44,12 +44,6 @@ using namespace Analyzer;
namespace QmlProfiler { namespace QmlProfiler {
namespace Internal { namespace Internal {
class QmlProfilerAction : public AnalyzerAction
{
public:
explicit QmlProfilerAction(QObject *parent = 0) : AnalyzerAction(parent) { }
};
bool QmlProfilerPlugin::debugOutput = false; bool QmlProfilerPlugin::debugOutput = false;
QmlProfilerPlugin *QmlProfilerPlugin::instance = 0; QmlProfilerPlugin *QmlProfilerPlugin::instance = 0;
@@ -58,26 +52,40 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
Q_UNUSED(arguments) Q_UNUSED(arguments)
Q_UNUSED(errorString) Q_UNUSED(errorString)
IAnalyzerTool *tool = new QmlProfilerTool(this); auto tool = new QmlProfilerTool(this);
auto toolStarter = [tool](StartMode mode) { return tool->startTool(mode); };
auto widgetCreator = [tool] { return tool->createWidgets(); };
auto runControlCreator = [tool](const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration) {
return tool->createRunControl(sp, runConfiguration);
};
QmlProfilerAction *action = 0; AnalyzerAction *action = 0;
QString description = QmlProfilerTool::tr( QString description = QmlProfilerTool::tr(
"The QML Profiler can be used to find performance bottlenecks in " "The QML Profiler can be used to find performance bottlenecks in "
"applications using QML."); "applications using QML.");
action = new QmlProfilerAction(this); action = new AnalyzerAction(this);
action->setId("QmlProfiler.Local"); action->setActionId("QmlProfiler.Local");
action->setTool(tool); action->setToolId(QmlProfilerToolId);
action->setWidgetCreator(widgetCreator);
action->setRunControlCreator(runControlCreator);
action->setToolStarter(toolStarter);
action->setRunMode(ProjectExplorer::QmlProfilerRunMode);
action->setText(tr("QML Profiler")); action->setText(tr("QML Profiler"));
action->setToolTip(description); action->setToolTip(description);
action->setStartMode(StartLocal); action->setStartMode(StartLocal);
action->setMenuGroup(Constants::G_ANALYZER_TOOLS); action->setMenuGroup(Constants::G_ANALYZER_TOOLS);
AnalyzerManager::addAction(action); AnalyzerManager::addAction(action);
action = new QmlProfilerAction(this); action = new AnalyzerAction(this);
action->setId("QmlProfiler.Remote"); action->setActionId("QmlProfiler.Remote");
action->setTool(tool); action->setToolId(QmlProfilerToolId);
action->setWidgetCreator(widgetCreator);
action->setRunControlCreator(runControlCreator);
action->setToolStarter(toolStarter);
action->setRunMode(ProjectExplorer::QmlProfilerRunMode);
action->setText(tr("QML Profiler (External)")); action->setText(tr("QML Profiler (External)"));
action->setToolTip(description); action->setToolTip(description);
action->setStartMode(StartRemote); action->setStartMode(StartRemote);

View File

@@ -121,11 +121,9 @@ public:
}; };
QmlProfilerTool::QmlProfilerTool(QObject *parent) QmlProfilerTool::QmlProfilerTool(QObject *parent)
: IAnalyzerTool(parent), d(new QmlProfilerToolPrivate) : QObject(parent), d(new QmlProfilerToolPrivate)
{ {
setObjectName(QLatin1String("QmlProfilerTool")); setObjectName(QLatin1String("QmlProfilerTool"));
setRunMode(QmlProfilerRunMode);
setToolMode(AnyMode);
d->m_profilerState = 0; d->m_profilerState = 0;
d->m_viewContainer = 0; d->m_viewContainer = 0;
@@ -488,7 +486,7 @@ void QmlProfilerTool::clearDisplay()
updateTimeDisplay(); updateTimeDisplay();
} }
static void startRemoteTool(IAnalyzerTool *tool, StartMode mode) static void startRemoteTool(QmlProfilerTool *tool, StartMode mode)
{ {
Id kitId; Id kitId;
quint16 port; quint16 port;
@@ -528,7 +526,7 @@ static void startRemoteTool(IAnalyzerTool *tool, StartMode mode)
AnalyzerRunControl *rc = tool->createRunControl(sp, 0); AnalyzerRunControl *rc = tool->createRunControl(sp, 0);
ProjectExplorerPlugin::startRunControl(rc, tool->runMode()); ProjectExplorerPlugin::startRunControl(rc, QmlProfilerRunMode);
} }
void QmlProfilerTool::startTool(StartMode mode) void QmlProfilerTool::startTool(StartMode mode)
@@ -546,9 +544,9 @@ void QmlProfilerTool::startTool(StartMode mode)
if (mode == StartLocal) { if (mode == StartLocal) {
// ### not sure if we're supposed to check if the RunConFiguration isEnabled // ### not sure if we're supposed to check if the RunConFiguration isEnabled
Project *pro = SessionManager::startupProject(); Project *pro = SessionManager::startupProject();
ProjectExplorerPlugin::instance()->runProject(pro, runMode()); ProjectExplorerPlugin::instance()->runProject(pro, QmlProfilerRunMode);
} else if (mode == StartRemote) { } else if (mode == StartRemote) {
startRemoteTool(this, mode); Internal::startRemoteTool(this, mode);
} }
} }
@@ -603,7 +601,7 @@ void QmlProfilerTool::showLoadDialog()
if (ModeManager::currentMode()->id() != MODE_ANALYZE) if (ModeManager::currentMode()->id() != MODE_ANALYZE)
AnalyzerManager::showMode(); AnalyzerManager::showMode();
AnalyzerManager::selectTool(this, StartRemote); AnalyzerManager::selectTool("QmlProfiler", StartRemote);
QString filename = QFileDialog::getOpenFileName(ICore::mainWindow(), tr("Load QML Trace"), QString(), QString filename = QFileDialog::getOpenFileName(ICore::mainWindow(), tr("Load QML Trace"), QString(),
tr("QML traces (*%1)").arg(QLatin1String(TraceFileExtension))); tr("QML traces (*%1)").arg(QLatin1String(TraceFileExtension)));
@@ -646,21 +644,21 @@ void QmlProfilerTool::clientsDisconnected()
// If the connection is closed while the app is still running, no special action is needed // If the connection is closed while the app is still running, no special action is needed
} }
template<QmlDebug::ProfileFeature feature> template<ProfileFeature feature>
void QmlProfilerTool::updateFeaturesMenu(quint64 features) void QmlProfilerTool::updateFeaturesMenu(quint64 features)
{ {
if (features & (1ULL << (feature))) { if (features & (1ULL << (feature))) {
QAction *action = d->m_featuresMenu->addAction(tr(QmlProfilerModelManager::featureName( QAction *action = d->m_featuresMenu->addAction(tr(QmlProfilerModelManager::featureName(
static_cast<QmlDebug::ProfileFeature>(feature)))); static_cast<ProfileFeature>(feature))));
action->setCheckable(true); action->setCheckable(true);
action->setData(static_cast<uint>(feature)); action->setData(static_cast<uint>(feature));
action->setChecked(d->m_profilerState->recordingFeatures() & (1ULL << (feature))); action->setChecked(d->m_profilerState->recordingFeatures() & (1ULL << (feature)));
} }
updateFeaturesMenu<static_cast<QmlDebug::ProfileFeature>(feature + 1)>(features); updateFeaturesMenu<static_cast<ProfileFeature>(feature + 1)>(features);
} }
template<> template<>
void QmlProfilerTool::updateFeaturesMenu<QmlDebug::MaximumProfileFeature>(quint64 features) void QmlProfilerTool::updateFeaturesMenu<MaximumProfileFeature>(quint64 features)
{ {
Q_UNUSED(features); Q_UNUSED(features);
return; return;
@@ -672,7 +670,7 @@ void QmlProfilerTool::setAvailableFeatures(quint64 features)
d->m_profilerState->setRecordingFeatures(features); // by default, enable them all. d->m_profilerState->setRecordingFeatures(features); // by default, enable them all.
if (d->m_featuresMenu) { if (d->m_featuresMenu) {
d->m_featuresMenu->clear(); d->m_featuresMenu->clear();
updateFeaturesMenu<static_cast<QmlDebug::ProfileFeature>(0)>(features); updateFeaturesMenu<static_cast<ProfileFeature>(0)>(features);
} }
} }

View File

@@ -42,7 +42,9 @@ QT_END_NAMESPACE
namespace QmlProfiler { namespace QmlProfiler {
namespace Internal { namespace Internal {
class QmlProfilerTool : public Analyzer::IAnalyzerTool const char QmlProfilerToolId[] = "QmlProfiler";
class QmlProfilerTool : public QObject
{ {
Q_OBJECT Q_OBJECT

View File

@@ -79,41 +79,41 @@ Q_STATIC_ASSERT(sizeof(MESSAGE_STRINGS) == QmlDebug::MaximumMessage * sizeof(con
namespace QmlProfiler { namespace QmlProfiler {
namespace Internal { namespace Internal {
static QPair<QmlDebug::Message, QmlDebug::RangeType> qmlTypeAsEnum(const QString &typeString) static QPair<Message, RangeType> qmlTypeAsEnum(const QString &typeString)
{ {
QPair<QmlDebug::Message, QmlDebug::RangeType> ret(QmlDebug::MaximumMessage, QPair<Message, RangeType> ret(MaximumMessage,
QmlDebug::MaximumRangeType); MaximumRangeType);
for (int i = 0; i < QmlDebug::MaximumMessage; ++i) { for (int i = 0; i < MaximumMessage; ++i) {
if (typeString == _(MESSAGE_STRINGS[i])) { if (typeString == _(MESSAGE_STRINGS[i])) {
ret.first = static_cast<QmlDebug::Message>(i); ret.first = static_cast<Message>(i);
break; break;
} }
} }
for (int i = 0; i < QmlDebug::MaximumRangeType; ++i) { for (int i = 0; i < MaximumRangeType; ++i) {
if (typeString == _(RANGE_TYPE_STRINGS[i])) { if (typeString == _(RANGE_TYPE_STRINGS[i])) {
ret.second = static_cast<QmlDebug::RangeType>(i); ret.second = static_cast<RangeType>(i);
break; break;
} }
} }
if (ret.first == QmlDebug::MaximumMessage && ret.second == QmlDebug::MaximumRangeType) { if (ret.first == MaximumMessage && ret.second == MaximumRangeType) {
bool isNumber = false; bool isNumber = false;
int type = typeString.toUInt(&isNumber); int type = typeString.toUInt(&isNumber);
if (isNumber && type < QmlDebug::MaximumRangeType) if (isNumber && type < MaximumRangeType)
// Allow saving ranges as numbers, but not messages. // Allow saving ranges as numbers, but not messages.
ret.second = static_cast<QmlDebug::RangeType>(type); ret.second = static_cast<RangeType>(type);
} }
return ret; return ret;
} }
static QString qmlTypeAsString(QmlDebug::Message message, QmlDebug::RangeType rangeType) static QString qmlTypeAsString(Message message, RangeType rangeType)
{ {
if (rangeType < QmlDebug::MaximumRangeType) if (rangeType < MaximumRangeType)
return _(RANGE_TYPE_STRINGS[rangeType]); return _(RANGE_TYPE_STRINGS[rangeType]);
else if (message != QmlDebug::MaximumMessage) else if (message != MaximumMessage)
return _(MESSAGE_STRINGS[message]); return _(MESSAGE_STRINGS[message]);
else else
return QString::number((int)rangeType); return QString::number((int)rangeType);
@@ -247,7 +247,7 @@ void QmlProfilerFileReader::loadEventData(QXmlStreamReader &stream)
} }
if (elementName == _("type")) { if (elementName == _("type")) {
QPair<QmlDebug::Message, QmlDebug::RangeType> enums = qmlTypeAsEnum(readData); QPair<Message, RangeType> enums = qmlTypeAsEnum(readData);
event.message = enums.first; event.message = enums.first;
event.rangeType = enums.second; event.rangeType = enums.second;
break; break;
@@ -513,14 +513,14 @@ void QmlProfilerFileWriter::save(QIODevice *device)
const QmlProfilerDataModel::QmlEventTypeData &event = m_qmlEvents[range.typeIndex]; const QmlProfilerDataModel::QmlEventTypeData &event = m_qmlEvents[range.typeIndex];
// special: animation event // special: animation event
if (event.message == QmlDebug::Event && event.detailType == QmlDebug::AnimationFrame) { if (event.message == Event && event.detailType == AnimationFrame) {
stream.writeAttribute(_("framerate"), QString::number(range.numericData1)); stream.writeAttribute(_("framerate"), QString::number(range.numericData1));
stream.writeAttribute(_("animationcount"), QString::number(range.numericData2)); stream.writeAttribute(_("animationcount"), QString::number(range.numericData2));
stream.writeAttribute(_("thread"), QString::number(range.numericData3)); stream.writeAttribute(_("thread"), QString::number(range.numericData3));
} }
// special: pixmap cache event // special: pixmap cache event
if (event.message == QmlDebug::PixmapCacheEvent) { if (event.message == PixmapCacheEvent) {
if (event.detailType == PixmapSizeKnown) { if (event.detailType == PixmapSizeKnown) {
stream.writeAttribute(_("width"), QString::number(range.numericData1)); stream.writeAttribute(_("width"), QString::number(range.numericData1));
stream.writeAttribute(_("height"), QString::number(range.numericData2)); stream.writeAttribute(_("height"), QString::number(range.numericData2));
@@ -531,7 +531,7 @@ void QmlProfilerFileWriter::save(QIODevice *device)
stream.writeAttribute(_("refCount"), QString::number(range.numericData3)); stream.writeAttribute(_("refCount"), QString::number(range.numericData3));
} }
if (event.message == QmlDebug::SceneGraphFrame) { if (event.message == SceneGraphFrame) {
// special: scenegraph frame events // special: scenegraph frame events
if (range.numericData1 > 0) if (range.numericData1 > 0)
stream.writeAttribute(_("timing1"), QString::number(range.numericData1)); stream.writeAttribute(_("timing1"), QString::number(range.numericData1));
@@ -546,7 +546,7 @@ void QmlProfilerFileWriter::save(QIODevice *device)
} }
// special: memory allocation event // special: memory allocation event
if (event.message == QmlDebug::MemoryAllocation) if (event.message == MemoryAllocation)
stream.writeAttribute(_("amount"), QString::number(range.numericData1)); stream.writeAttribute(_("amount"), QString::number(range.numericData1));
stream.writeEndElement(); stream.writeEndElement();

View File

@@ -77,7 +77,7 @@ public:
QmlProfilerTraceView *q; QmlProfilerTraceView *q;
QmlProfilerStateManager *m_profilerState; QmlProfilerStateManager *m_profilerState;
Analyzer::IAnalyzerTool *m_profilerTool; QmlProfilerTool *m_profilerTool;
QmlProfilerViewManager *m_viewContainer; QmlProfilerViewManager *m_viewContainer;
QSize m_sizeHint; QSize m_sizeHint;
@@ -90,7 +90,7 @@ public:
Timeline::TimelineZoomControl *m_zoomControl; Timeline::TimelineZoomControl *m_zoomControl;
}; };
QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerTool *profilerTool, QmlProfilerViewManager *container, QmlProfilerModelManager *modelManager, QmlProfilerStateManager *profilerState) QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, QmlProfilerTool *profilerTool, QmlProfilerViewManager *container, QmlProfilerModelManager *modelManager, QmlProfilerStateManager *profilerState)
: QWidget(parent), d(new QmlProfilerTraceViewPrivate(this)) : QWidget(parent), d(new QmlProfilerTraceViewPrivate(this))
{ {
setObjectName(QLatin1String("QML Profiler")); setObjectName(QLatin1String("QML Profiler"));
@@ -135,8 +135,8 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerT
d->m_modelProxy->addModel(new QmlProfilerAnimationsModel(modelManager, d->m_modelProxy)); d->m_modelProxy->addModel(new QmlProfilerAnimationsModel(modelManager, d->m_modelProxy));
for (int i = 0; i < QmlDebug::MaximumRangeType; ++i) for (int i = 0; i < MaximumRangeType; ++i)
d->m_modelProxy->addModel(new QmlProfilerRangeModel(modelManager, (QmlDebug::RangeType)i, d->m_modelProxy->addModel(new QmlProfilerRangeModel(modelManager, (RangeType)i,
d->m_modelProxy)); d->m_modelProxy));
// Connect this last so that it's executed after the models have updated their data. // Connect this last so that it's executed after the models have updated their data.

View File

@@ -35,14 +35,13 @@
#include <QWidget> #include <QWidget>
#include <QTimer> #include <QTimer>
namespace Analyzer { class IAnalyzerTool; }
namespace QmlProfiler { namespace QmlProfiler {
class QmlProfilerModelManager; class QmlProfilerModelManager;
namespace Internal { namespace Internal {
class QmlProfilerStateManager; class QmlProfilerStateManager;
class QmlProfilerTool;
class QmlProfilerViewManager; class QmlProfilerViewManager;
class QmlProfilerTraceView : public QWidget class QmlProfilerTraceView : public QWidget
@@ -50,7 +49,7 @@ class QmlProfilerTraceView : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerTool *profilerTool, explicit QmlProfilerTraceView(QWidget *parent, QmlProfilerTool *profilerTool,
QmlProfilerViewManager *container, QmlProfilerViewManager *container,
QmlProfilerModelManager *modelManager, QmlProfilerModelManager *modelManager,
QmlProfilerStateManager *profilerState); QmlProfilerStateManager *profilerState);

View File

@@ -124,11 +124,11 @@ void QmlProfilerViewManager::createViews()
d->v8profilerView, SLOT(selectBySourceLocation(QString,int,int))); d->v8profilerView, SLOT(selectBySourceLocation(QString,int,int)));
QDockWidget *eventsDock = AnalyzerManager::createDockWidget QDockWidget *eventsDock = AnalyzerManager::createDockWidget
(d->profilerTool, d->eventsView); (QmlProfilerToolId, d->eventsView);
QDockWidget *timelineDock = AnalyzerManager::createDockWidget QDockWidget *timelineDock = AnalyzerManager::createDockWidget
(d->profilerTool, d->traceView); (QmlProfilerToolId, d->traceView);
QDockWidget *v8profilerDock = AnalyzerManager::createDockWidget QDockWidget *v8profilerDock = AnalyzerManager::createDockWidget
(d->profilerTool, d->v8profilerView); (QmlProfilerToolId, d->v8profilerView);
eventsDock->show(); eventsDock->show();
timelineDock->show(); timelineDock->show();

View File

@@ -104,7 +104,7 @@ public:
QV8ProfilerEventsWidget *q; QV8ProfilerEventsWidget *q;
Analyzer::IAnalyzerTool *m_profilerTool; QmlProfilerTool *m_profilerTool;
QmlProfilerViewManager *m_viewContainer; QmlProfilerViewManager *m_viewContainer;
QV8ProfilerEventsMainView *m_eventTree; QV8ProfilerEventsMainView *m_eventTree;
@@ -115,7 +115,7 @@ public:
}; };
QV8ProfilerEventsWidget::QV8ProfilerEventsWidget(QWidget *parent, QV8ProfilerEventsWidget::QV8ProfilerEventsWidget(QWidget *parent,
Analyzer::IAnalyzerTool *profilerTool, QmlProfilerTool *profilerTool,
QmlProfilerViewManager *container, QmlProfilerViewManager *container,
QmlProfilerModelManager *profilerModelManager ) QmlProfilerModelManager *profilerModelManager )
: QWidget(parent), d(new QV8ProfilerEventsWidgetPrivate(this)) : QWidget(parent), d(new QV8ProfilerEventsWidgetPrivate(this))

View File

@@ -55,7 +55,7 @@ class QV8ProfilerEventsWidget : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit QV8ProfilerEventsWidget(QWidget *parent, explicit QV8ProfilerEventsWidget(QWidget *parent,
Analyzer::IAnalyzerTool *profilerTool, QmlProfilerTool *profilerTool,
QmlProfilerViewManager *container, QmlProfilerViewManager *container,
QmlProfilerModelManager *profilerModelManager ); QmlProfilerModelManager *profilerModelManager );
~QV8ProfilerEventsWidget(); ~QV8ProfilerEventsWidget();

View File

@@ -81,11 +81,11 @@ QmlApplicationWizard::QmlApplicationWizard()
QLatin1String(ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY_DISPLAY)); QLatin1String(ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY_DISPLAY));
setDisplayName(tr("Qt Quick UI")); setDisplayName(tr("Qt Quick UI"));
setDescription(tr("Creates a Qt Quick UI project.")); setDescription(tr("Creates a Qt Quick UI project."));
setRequiredFeatures(Core::Feature(QtSupport::Constants::FEATURE_QMLPROJECT) setRequiredFeatures(Feature(QtSupport::Constants::FEATURE_QMLPROJECT)
| Core::Feature(QtSupport::Constants::FEATURE_QT_QUICK)); | Feature(QtSupport::Constants::FEATURE_QT_QUICK));
} }
Core::BaseFileWizard *QmlApplicationWizard::create(QWidget *parent, const WizardDialogParameters &parameters) const BaseFileWizard *QmlApplicationWizard::create(QWidget *parent, const WizardDialogParameters &parameters) const
{ {
QmlApplicationWizardDialog *wizardDialog = new QmlApplicationWizardDialog(parent, parameters); QmlApplicationWizardDialog *wizardDialog = new QmlApplicationWizardDialog(parent, parameters);
@@ -113,7 +113,7 @@ GeneratedFiles QmlApplicationWizard::generateFiles(const QWizard *w,
bool QmlApplicationWizard::postGenerateFiles(const QWizard * /*wizard*/, const GeneratedFiles &l, bool QmlApplicationWizard::postGenerateFiles(const QWizard * /*wizard*/, const GeneratedFiles &l,
QString *errorMessage) QString *errorMessage)
{ {
return ProjectExplorer::CustomProjectWizard::postGenerateOpen(l, errorMessage); return CustomProjectWizard::postGenerateOpen(l, errorMessage);
} }
} // namespace Internal } // namespace Internal

View File

@@ -89,18 +89,18 @@ QmlProject::~QmlProject()
delete m_rootNode; delete m_rootNode;
} }
void QmlProject::addedTarget(ProjectExplorer::Target *target) void QmlProject::addedTarget(Target *target)
{ {
connect(target, SIGNAL(addedRunConfiguration(ProjectExplorer::RunConfiguration*)), connect(target, SIGNAL(addedRunConfiguration(ProjectExplorer::RunConfiguration*)),
this, SLOT(addedRunConfiguration(ProjectExplorer::RunConfiguration*))); this, SLOT(addedRunConfiguration(ProjectExplorer::RunConfiguration*)));
foreach (ProjectExplorer::RunConfiguration *rc, target->runConfigurations()) foreach (RunConfiguration *rc, target->runConfigurations())
addedRunConfiguration(rc); addedRunConfiguration(rc);
} }
void QmlProject::onActiveTargetChanged(ProjectExplorer::Target *target) void QmlProject::onActiveTargetChanged(Target *target)
{ {
if (m_activeTarget) if (m_activeTarget)
disconnect(m_activeTarget, &ProjectExplorer::Target::kitChanged, this, &QmlProject::onKitChanged); disconnect(m_activeTarget, &Target::kitChanged, this, &QmlProject::onKitChanged);
m_activeTarget = target; m_activeTarget = target;
if (m_activeTarget) if (m_activeTarget)
connect(target, SIGNAL(kitChanged()), this, SLOT(onKitChanged())); connect(target, SIGNAL(kitChanged()), this, SLOT(onKitChanged()));
@@ -115,7 +115,7 @@ void QmlProject::onKitChanged()
refresh(Configuration); refresh(Configuration);
} }
void QmlProject::addedRunConfiguration(ProjectExplorer::RunConfiguration *rc) void QmlProject::addedRunConfiguration(RunConfiguration *rc)
{ {
// The enabled state of qml runconfigurations can only be decided after // The enabled state of qml runconfigurations can only be decided after
// they have been added to a project // they have been added to a project
@@ -297,14 +297,14 @@ IDocument *QmlProject::document() const
return m_file; return m_file;
} }
ProjectExplorer::IProjectManager *QmlProject::projectManager() const IProjectManager *QmlProject::projectManager() const
{ {
return m_manager; return m_manager;
} }
bool QmlProject::supportsKit(ProjectExplorer::Kit *k, QString *errorMessage) const bool QmlProject::supportsKit(Kit *k, QString *errorMessage) const
{ {
Id deviceType = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(k); Id deviceType = DeviceTypeKitInformation::deviceTypeId(k);
if (deviceType != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) { if (deviceType != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
if (errorMessage) if (errorMessage)
*errorMessage = tr("Device type is not desktop."); *errorMessage = tr("Device type is not desktop.");
@@ -333,7 +333,7 @@ bool QmlProject::supportsKit(ProjectExplorer::Kit *k, QString *errorMessage) con
return true; return true;
} }
ProjectExplorer::ProjectNode *QmlProject::rootProjectNode() const ProjectNode *QmlProject::rootProjectNode() const
{ {
return m_rootNode; return m_rootNode;
} }

View File

@@ -13,7 +13,7 @@ QtcPlugin {
Depends { name: "CppTools" } Depends { name: "CppTools" }
cpp.includePaths: base.concat([ cpp.includePaths: base.concat([
"../../shared", project.sharedSourcesDir,
]) ])
cpp.defines: base.concat([ cpp.defines: base.concat([
@@ -28,7 +28,7 @@ QtcPlugin {
Group { Group {
name: "Shared" name: "Shared"
prefix: "../../shared/proparser/" prefix: project.sharedSourcesDir + "/proparser/"
files: [ files: [
"ioutils.cpp", "ioutils.cpp",
"ioutils.h", "ioutils.h",

Some files were not shown because too many files have changed in this diff Show More