--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#include "colorwidgets.h"
+#include <qdeclarative.h>
+
+#include "colorbox.h"
+#include "colorbutton.h"
+#include "huecontrol.h"
+#include "gradientline.h"
+
+namespace QmlEditorWidgets {
+
+void ColorWidgets::registerDeclarativeTypes() {
+ qmlRegisterType<QmlEditorWidgets::ColorButton>("Bauhaus",1,0,"ColorButton");
+ qmlRegisterType<QmlEditorWidgets::HueControl>("Bauhaus",1,0,"HueControl");
+ qmlRegisterType<QmlEditorWidgets::ColorBox>("Bauhaus",1,0,"ColorBox");
+ qmlRegisterType<QmlEditorWidgets::GradientLine>("Bauhaus",1,0,"GradientLine");
+}
+
+}
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#ifndef FILEINPROJECTFINDER_H
+#define FILEINPROJECTFINDER_H
+
+#include <utils/utils_global.h>
+
+#include <QtCore/QHash>
+#include <QtCore/QString>
+
+namespace Utils {
+
+class QTCREATOR_UTILS_EXPORT FileInProjectFinder
+{
+public:
+ FileInProjectFinder();
+
+ void setProjectDirectory(const QString &absoluteProjectPath);
+ QString projectDirectory() const;
+
+ QString findFile(const QString &originalPath, bool *success = 0) const;
+
+private:
+ QString m_projectDir;
+ mutable QHash<QString,QString> m_cache;
+};
+
+} // namespace Utils
+
+#endif // FILEINPROJECTFINDER_H
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#ifndef DEBUGGER_MEMORYAGENT_H
+#define DEBUGGER_MEMORYAGENT_H
+
+#include <QtCore/QObject>
+#include <QtCore/QPointer>
+
+namespace Core {
+class IEditor;
+}
+
+namespace Debugger {
+
+class DebuggerEngine;
+
+namespace Internal {
+
+class MemoryAgent : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit MemoryAgent(DebuggerEngine *engine);
+ ~MemoryAgent();
+
+ enum { BinBlockSize = 1024 };
+ bool hasVisibleEditor() const;
+
+public slots:
+ // Called by engine to create a new view.
+ void createBinEditor(quint64 startAddr);
+ // Called by engine to trigger update of contents.
+ void updateContents();
+ // Called by enine to pass updated contents.
+ void addLazyData(QObject *editorToken, quint64 addr, const QByteArray &data);
+
+private:
+ Q_SLOT void fetchLazyData(Core::IEditor *, quint64 block, bool sync);
+ Q_SLOT void provideNewRange(Core::IEditor *editor, quint64 address);
+ Q_SLOT void handleStartOfFileRequested(Core::IEditor *editor);
+ Q_SLOT void handleEndOfFileRequested(Core::IEditor *editor);
+
+ QList<QPointer<Core::IEditor> > m_editors;
+ QPointer<DebuggerEngine> m_engine;
+};
+
+} // namespace Internal
+} // namespace Debugger
+
+#endif // DEBUGGER_MEMORYAGENT_H
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#ifndef GLSLAUTOCOMPLETER_H
+#define GLSLAUTOCOMPLETER_H
+
+#include <texteditor/autocompleter.h>
+
+namespace GLSLEditor {
+namespace Internal {
+
+class GLSLCompleter : public TextEditor::AutoCompleter
+{
+public:
+ GLSLCompleter();
+ virtual ~GLSLCompleter();
+
+ virtual bool contextAllowsAutoParentheses(const QTextCursor &cursor,
+ const QString &textToInsert = QString()) const;
+ virtual bool contextAllowsElectricCharacters(const QTextCursor &cursor) const;
+ virtual bool isInComment(const QTextCursor &cursor) const;
+ virtual QString insertMatchingBrace(const QTextCursor &cursor,
+ const QString &text,
+ QChar la,
+ int *skippedChars) const;
+ virtual QString insertParagraphSeparator(const QTextCursor &cursor) const;
+};
+
+} // Internal
+} // GLSLEditor
+
+#endif // GLSLAUTOCOMPLETER_H
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+#ifndef GLSLHIGHLIGHTER_H
+#define GLSLHIGHLIGHTER_H
+
+#include <texteditor/syntaxhighlighter.h>
+
+namespace GLSLEditor {
+class GLSLTextEditor;
+
+namespace Internal {
+
+class Highlighter : public TextEditor::SyntaxHighlighter
+{
+ Q_OBJECT
+
+public:
+ enum Formats {
+ GLSLNumberFormat,
+ GLSLStringFormat,
+ GLSLTypeFormat,
+ GLSLKeywordFormat,
+ GLSLOperatorFormat,
+ GLSLPreprocessorFormat,
+ GLSLLabelFormat,
+ GLSLCommentFormat,
+ GLSLDoxygenCommentFormat,
+ GLSLDoxygenTagFormat,
+ GLSLVisualWhitespace,
+ GLSLReservedKeyword,
+ NumGLSLFormats
+ };
+
+ explicit Highlighter(GLSLTextEditor *editor, QTextDocument *parent);
+ virtual ~Highlighter();
+
+ void setFormats(const QVector<QTextCharFormat> &formats);
+
+protected:
+ void highlightBlock(const QString &text);
+ void highlightLine(const QString &text, int position, int length, const QTextCharFormat &format);
+ bool isPPKeyword(const QStringRef &text) const;
+
+private:
+ QTextCharFormat m_formats[NumGLSLFormats];
+ GLSLTextEditor *m_editor;
+};
+
+} // namespace Internal
+} // namespace GLSLEditor
+
+#endif // GLSLHIGHLIGHTER_H
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#include "glslhoverhandler.h"
+#include "glsleditor.h"
+
+#include <coreplugin/editormanager/ieditor.h>
+#include <coreplugin/editormanager/editormanager.h>
+#include <coreplugin/helpmanager.h>
+#include <extensionsystem/pluginmanager.h>
+#include <texteditor/itexteditor.h>
+#include <texteditor/basetexteditor.h>
+
+#include <QtGui/QTextCursor>
+#include <QtCore/QUrl>
+
+using namespace GLSLEditor;
+using namespace GLSLEditor::Internal;
+using namespace Core;
+
+GLSLHoverHandler::GLSLHoverHandler(QObject *parent) : BaseHoverHandler(parent)
+{}
+
+GLSLHoverHandler::~GLSLHoverHandler()
+{}
+
+bool GLSLHoverHandler::acceptEditor(IEditor *editor)
+{
+ if (qobject_cast<GLSLEditorEditable *>(editor) != 0)
+ return true;
+ return false;
+}
+
+void GLSLHoverHandler::identifyMatch(TextEditor::ITextEditor *editor, int pos)
+{
+ if (GLSLTextEditor *glslEditor = qobject_cast<GLSLTextEditor *>(editor->widget())) {
+ if (! glslEditor->extraSelectionTooltip(pos).isEmpty()) {
+ setToolTip(glslEditor->extraSelectionTooltip(pos));
+ }
+ }
+}
+
+void GLSLHoverHandler::decorateToolTip()
+{
+ if (Qt::mightBeRichText(toolTip()))
+ setToolTip(Qt::escape(toolTip()));
+}
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#ifndef GLSLINDENTER_H
+#define GLSLINDENTER_H
+
+#include <texteditor/indenter.h>
+
+namespace GLSLEditor {
+namespace Internal {
+
+class GLSLIndenter : public TextEditor::Indenter
+{
+public:
+ GLSLIndenter();
+ virtual ~GLSLIndenter();
+
+ virtual bool isElectricCharacter(const QChar &ch) const;
+ virtual void indentBlock(QTextDocument *doc,
+ const QTextBlock &block,
+ const QChar &typedChar,
+ TextEditor::BaseTextEditor *editor);
+
+ virtual void indent(QTextDocument *doc,
+ const QTextCursor &cursor,
+ const QChar &typedChar,
+ TextEditor::BaseTextEditor *editor);
+};
+
+} // Internal
+} // GLSLEditor
+
+#endif // GLSLINDENTER_H
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#include "localhelpmanager.h"
+#include "bookmarkmanager.h"
+
+#include <coreplugin/coreconstants.h>
+#include <coreplugin/helpmanager.h>
+
+#include <QtCore/QMutexLocker>
+
+#include <QtHelp/QHelpEngine>
+
+using namespace Help::Internal;
+
+QMutex LocalHelpManager::m_guiMutex;
+QHelpEngine* LocalHelpManager::m_guiEngine = 0;
+
+QMutex LocalHelpManager::m_bkmarkMutex;
+BookmarkManager* LocalHelpManager::m_bookmarkManager = 0;
+
+LocalHelpManager::LocalHelpManager(QObject *parent)
+ : QObject(parent)
+ , m_guiNeedsSetup(true)
+ , m_needsCollectionFile(true)
+{
+}
+
+LocalHelpManager::~LocalHelpManager()
+{
+ if (m_bookmarkManager) {
+ m_bookmarkManager->saveBookmarks();
+ delete m_bookmarkManager;
+ m_bookmarkManager = 0;
+ }
+
+ delete m_guiEngine;
+ m_guiEngine = 0;
+}
+
+void LocalHelpManager::setupGuiHelpEngine()
+{
+ if (m_needsCollectionFile) {
+ m_needsCollectionFile = false;
+ helpEngine().setCollectionFile(Core::HelpManager::collectionFilePath());
+ }
+
+ if (m_guiNeedsSetup) {
+ m_guiNeedsSetup = false;
+ helpEngine().setupData();
+ }
+}
+
+void LocalHelpManager::setEngineNeedsUpdate()
+{
+ m_guiNeedsSetup = true;
+}
+
+QHelpEngine &LocalHelpManager::helpEngine()
+{
+ if (!m_guiEngine) {
+ QMutexLocker _(&m_guiMutex);
+ if (!m_guiEngine) {
+ m_guiEngine = new QHelpEngine("");
+ m_guiEngine->setAutoSaveFilter(false);
+ }
+ }
+ return *m_guiEngine;
+}
+
+BookmarkManager& LocalHelpManager::bookmarkManager()
+{
+ if (!m_bookmarkManager) {
+ QMutexLocker _(&m_bkmarkMutex);
+ if (!m_bookmarkManager) {
+ m_bookmarkManager = new BookmarkManager;
+ m_bookmarkManager->setupBookmarkModels();
+ const QString &url = QString::fromLatin1("qthelp://com.nokia.qtcreator."
+ "%1%2%3/doc/index.html").arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR)
+ .arg(IDE_VERSION_RELEASE);
+ helpEngine().setCustomValue(QLatin1String("DefaultHomePage"), url);
+ }
+ }
+ return *m_bookmarkManager;
+}
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#ifndef SESSIONNODEIMPL_H
+#define SESSIONNODEIMPL_H
+
+#include "projectnodes.h"
+
+namespace ProjectExplorer {
+class SessionManager;
+
+namespace Internal {
+
+// Must be in a header as otherwise moc has issues
+// with ProjectExplorer::SessionNode on msvc2005
+class SessionNodeImpl : public ProjectExplorer::SessionNode
+{
+ Q_OBJECT
+public:
+ explicit SessionNodeImpl(SessionManager *manager);
+
+ void addProjectNode(ProjectNode *projectNode);
+ void removeProjectNode(ProjectNode *projectNode);
+
+ void setFileName(const QString &fileName);
+};
+
+} // namespace Internal
+} // namespace ProjectExplorer
+
+#endif // SESSIONNODEIMPL_H
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#include "itemlibrarycomponents.h"
+#include "customdraganddrop.h"
+
+#include <QtCore/QMimeData>
+#include <QtCore/QDebug>
+
+#include <QtGui/QImage>
+#include <QtGui/QPixmap>
+#include <QtGui/QDrag>
+#include <QPainter>
+#include <QLabel>
+#include <itemlibraryinfo.h>
+#include <QDirModel>
+#include <QProxyStyle>
+
+enum { debug = 0 };
+
+namespace QmlDesigner {
+
+namespace Internal {
+
+static void drawSelectionBackground(QPainter *painter, const QStyleOption &option)
+{
+ painter->save();
+ QLinearGradient gradient;
+ QColor highlight = option.palette.highlight().color();
+ gradient.setColorAt(0, highlight.lighter(130));
+ gradient.setColorAt(1, highlight.darker(130));
+ gradient.setStart(option.rect.topLeft());
+ gradient.setFinalStop(option.rect.bottomLeft());
+ painter->fillRect(option.rect, gradient);
+ painter->setPen(highlight.lighter());
+ painter->drawLine(option.rect.topLeft(),option.rect.topRight());
+ painter->setPen(highlight.darker());
+ painter->drawLine(option.rect.bottomLeft(),option.rect.bottomRight());
+ painter->restore();
+}
+
+// This style basically allows us to span the entire row
+// including the arrow indicators which would otherwise not be
+// drawn by the delegate
+class TreeViewStyle : public QProxyStyle
+{
+public:
+ void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget * = 0) const
+ {
+ if (element == QStyle::PE_PanelItemViewRow) {
+ if (option->state & QStyle::State_Selected)
+ drawSelectionBackground(painter, *option);
+ }
+ }
+ int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const {
+ if (hint == SH_ItemView_ShowDecorationSelected)
+ return 0;
+ else
+ return QProxyStyle::styleHint(hint, option, widget, returnData);
+ }
+};
+
+ItemLibraryTreeView::ItemLibraryTreeView(QWidget *parent) :
+ QTreeView(parent)
+{
+ setDragEnabled(true);
+ setDragDropMode(QAbstractItemView::DragOnly);
+ setUniformRowHeights(true);
+ connect(this, SIGNAL(clicked(const QModelIndex &)), this, SLOT(activateItem(const QModelIndex &)));
+ setHeaderHidden(true);
+ setIndentation(20);
+ setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setAttribute(Qt::WA_MacShowFocusRect, false);
+
+ TreeViewStyle *style = new TreeViewStyle;
+ setStyle(style);
+ style->setParent(this);
+ m_delegate = new ResourceItemDelegate(this);
+ setItemDelegateForColumn(0, m_delegate);
+}
+
+// We need to implement startDrag ourselves since we cannot
+// otherwise influence drag pixmap and hotspot in the standard
+// implementation.
+void ItemLibraryTreeView::startDrag(Qt::DropActions /* supportedActions */)
+{
+ if (debug)
+ qDebug() << Q_FUNC_INFO;
+ QMimeData *mimeData = model()->mimeData(selectedIndexes());
+ if (!mimeData)
+ return;
+
+ QDirModel *dirModel = qobject_cast<QDirModel*>(model());
+ Q_ASSERT(dirModel);
+ QFileInfo fileInfo = dirModel->fileInfo(selectedIndexes().front());
+ QPixmap pixmap(fileInfo.absoluteFilePath());
+ if (!pixmap.isNull()) {
+ CustomItemLibraryDrag *drag = new CustomItemLibraryDrag(this);
+ drag->setPreview(pixmap);
+ drag->setPixmap(QIcon(pixmap).pixmap(128, 128));
+ QMimeData *mimeData = new QMimeData;
+ mimeData->setData("application/vnd.bauhaus.libraryresource", fileInfo.absoluteFilePath().toLatin1());
+ drag->setMimeData(mimeData);
+ drag->exec();
+ }
+}
+
+void ItemLibraryTreeView::setModel(QAbstractItemModel *model)
+{
+ QDirModel *dirModel = dynamic_cast<QDirModel *>(model);
+ if (dirModel) {
+ QTreeView::setModel(model);
+ m_delegate->setModel(dirModel);
+ setColumnHidden(1, true);
+ setColumnHidden(2, true);
+ setColumnHidden(3, true);
+ setSortingEnabled(true);
+ }
+}
+
+void ItemLibraryTreeView::activateItem( const QModelIndex & /*index*/)
+{
+ QMimeData *mimeData = model()->mimeData(selectedIndexes());
+ if (!mimeData)
+ return;
+
+ QString name;
+ QDirModel *dirModel = qobject_cast<QDirModel*>(model());
+ Q_ASSERT(dirModel);
+ QFileInfo fileInfo = dirModel->fileInfo(selectedIndexes().front());
+ QPixmap pixmap(fileInfo.absoluteFilePath());
+ if (!pixmap.isNull()) {
+ name = "image^" + fileInfo.absoluteFilePath();
+ emit itemActivated(name);
+ }
+}
+
+void ResourceItemDelegate::paint(QPainter *painter,
+ const QStyleOptionViewItem &option, const QModelIndex &index) const
+{
+ if (option.state & QStyle::State_Selected)
+ drawSelectionBackground(painter, option);
+
+ painter->save();
+
+ QIcon icon(m_model->fileIcon(index));
+ QPixmap pixmap(icon.pixmap(icon.availableSizes().front()));
+ painter->drawPixmap(option.rect.x(),option.rect.y()+2,pixmap);
+ QString myString(m_model->fileName(index));
+
+ // Check text length does not exceed available space
+ int extraSpace=12+pixmap.width();
+ QFontMetrics fm(option.font);
+ myString = fm.elidedText(myString,Qt::ElideMiddle,option.rect.width()-extraSpace);
+
+ painter->drawText(option.rect.bottomLeft()+QPoint(3+pixmap.width(),-8),myString);
+
+ painter->restore();
+}
+
+QSize ResourceItemDelegate::sizeHint(const QStyleOptionViewItem &/*option*/,
+ const QModelIndex &index) const
+{
+ QIcon icon(m_model->fileIcon(index));
+ return icon.availableSizes().front() + QSize(25, 4);
+}
+
+void ResourceItemDelegate::setModel(QDirModel *model)
+{
+ m_model = model;
+}
+
+} // namespace Internal
+
+} // namespace QmlDesigner
+
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#include "itemlibrarywidget.h"
+
+#include <utils/filterlineedit.h>
+#include <coreplugin/coreconstants.h>
+#include "itemlibrarycomponents.h"
+#include "itemlibrarymodel.h"
+#include "itemlibraryimageprovider.h"
+#include "customdraganddrop.h"
+#include <model.h>
+#include <metainfo.h>
+
+#include <QFileInfo>
+#include <QFileIconProvider>
+#include <QDirModel>
+#include <QStackedWidget>
+#include <QGridLayout>
+#include <QTabBar>
+#include <QImageReader>
+#include <QMimeData>
+#include <QWheelEvent>
+#include <QMenu>
+#include <QApplication>
+
+#include <QDeclarativeView>
+#include <QDeclarativeItem>
+#include <private/qdeclarativeengine_p.h>
+
+
+namespace QmlDesigner {
+
+class MyFileIconProvider : public QFileIconProvider
+{
+public:
+ MyFileIconProvider(const QSize &iconSize)
+ : QFileIconProvider(),
+ m_iconSize(iconSize)
+ {}
+
+ virtual QIcon icon ( const QFileInfo & info ) const
+ {
+ QPixmap pixmap(info.absoluteFilePath());
+ if (pixmap.isNull()) {
+ QIcon defaultIcon(QFileIconProvider::icon(info));
+ pixmap = defaultIcon.pixmap(defaultIcon.actualSize(m_iconSize));
+ }
+
+ if (pixmap.width() == m_iconSize.width()
+ && pixmap.height() == m_iconSize.height())
+ return pixmap;
+
+ if ((pixmap.width() > m_iconSize.width())
+ || (pixmap.height() > m_iconSize.height()))
+ return pixmap.scaled(m_iconSize, Qt::KeepAspectRatio,
+ Qt::SmoothTransformation);
+
+ QPoint offset((m_iconSize.width() - pixmap.width()) / 2,
+ (m_iconSize.height() - pixmap.height()) / 2);
+ QImage newIcon(m_iconSize, QImage::Format_ARGB32_Premultiplied);
+ newIcon.fill(Qt::transparent);
+ QPainter painter(&newIcon);
+ painter.drawPixmap(offset, pixmap);
+ return QPixmap::fromImage(newIcon);
+ }
+
+private:
+ QSize m_iconSize;
+};
+
+
+// ---------- ItemLibraryPrivate
+class ItemLibraryWidgetPrivate {
+public:
+ ItemLibraryWidgetPrivate(QObject *object);
+
+ Internal::ItemLibraryModel *m_itemLibraryModel;
+ QDirModel *m_resourcesDirModel;
+
+ QStackedWidget *m_stackedWidget;
+ Utils::FilterLineEdit *m_lineEdit;
+ QDeclarativeView *m_itemsView;
+ Internal::ItemLibraryTreeView *m_resourcesView;
+ QWeakPointer<ItemLibraryInfo> m_itemLibraryInfo;
+
+ QSize m_itemIconSize, m_resIconSize;
+ MyFileIconProvider m_iconProvider;
+ Model *model;
+};
+
+ItemLibraryWidgetPrivate::ItemLibraryWidgetPrivate(QObject *object) :
+ m_itemLibraryModel(0),
+ m_resourcesDirModel(0),
+ m_stackedWidget(0),
+ m_lineEdit(0),
+ m_itemsView(0),
+ m_resourcesView(0),
+ m_itemIconSize(24, 24),
+ m_resIconSize(24, 24),
+ m_iconProvider(m_resIconSize),
+ model(0)
+{
+ Q_UNUSED(object);
+}
+
+ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) :
+ QFrame(parent),
+ m_d(new ItemLibraryWidgetPrivate(this)),
+ m_filterFlag(QtBasic)
+{
+ setWindowTitle(tr("Library", "Title of library view"));
+
+ /* create Items view and its model */
+ m_d->m_itemsView = new QDeclarativeView(this);
+ m_d->m_itemsView->setAttribute(Qt::WA_OpaquePaintEvent);
+ m_d->m_itemsView->setAttribute(Qt::WA_NoSystemBackground);
+ m_d->m_itemsView->setAcceptDrops(false);
+ m_d->m_itemsView->setFocusPolicy(Qt::ClickFocus);
+ m_d->m_itemsView->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+ m_d->m_itemLibraryModel = new Internal::ItemLibraryModel(QDeclarativeEnginePrivate::getScriptEngine(m_d->m_itemsView->engine()), this);
+ m_d->m_itemLibraryModel->setItemIconSize(m_d->m_itemIconSize);
+
+ QDeclarativeContext *rootContext = m_d->m_itemsView->rootContext();
+ rootContext->setContextProperty(QLatin1String("itemLibraryModel"), m_d->m_itemLibraryModel);
+ rootContext->setContextProperty(QLatin1String("itemLibraryIconWidth"), m_d->m_itemIconSize.width());
+ rootContext->setContextProperty(QLatin1String("itemLibraryIconHeight"), m_d->m_itemIconSize.height());
+
+ QColor highlightColor = palette().highlight().color();
+ if (0.5*highlightColor.saturationF()+0.75-highlightColor.valueF() < 0)
+ highlightColor.setHsvF(highlightColor.hsvHueF(),0.1 + highlightColor.saturationF()*2.0, highlightColor.valueF());
+ m_d->m_itemsView->rootContext()->setContextProperty(QLatin1String("highlightColor"), highlightColor);
+
+ // loading the qml has to come after all needed context properties are set
+ m_d->m_itemsView->setSource(QUrl("qrc:/ItemLibrary/qml/ItemsView.qml"));
+
+ QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(m_d->m_itemsView->rootObject());
+ connect(rootItem, SIGNAL(itemSelected(int)), this, SLOT(showItemInfo(int)));
+ connect(rootItem, SIGNAL(itemDragged(int)), this, SLOT(startDragAndDrop(int)));
+ connect(this, SIGNAL(scrollItemsView(QVariant)), rootItem, SLOT(scrollView(QVariant)));
+ connect(this, SIGNAL(resetItemsView()), rootItem, SLOT(resetView()));
+
+ /* create Resources view and its model */
+ m_d->m_resourcesDirModel = new QDirModel(this);
+ m_d->m_resourcesDirModel->setIconProvider(&m_d->m_iconProvider);
+ m_d->m_resourcesView = new Internal::ItemLibraryTreeView(this);
+ m_d->m_resourcesView->setModel(m_d->m_resourcesDirModel);
+ m_d->m_resourcesView->setIconSize(m_d->m_resIconSize);
+
+ /* create image provider for loading item icons */
+ m_d->m_itemsView->engine()->addImageProvider(QLatin1String("qmldesigner_itemlibrary"), new Internal::ItemLibraryImageProvider);
+
+ /* other widgets */
+ QTabBar *tabBar = new QTabBar(this);
+ tabBar->addTab(tr("Items", "Title of library items view"));
+ tabBar->addTab(tr("Resources", "Title of library resources view"));
+ tabBar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+
+ m_d->m_lineEdit = new Utils::FilterLineEdit(this);
+ m_d->m_lineEdit->setObjectName(QLatin1String("itemLibrarySearchInput"));
+ m_d->m_lineEdit->setPlaceholderText(tr("<Filter>", "Library search input hint text"));
+ m_d->m_lineEdit->setDragEnabled(false);
+ m_d->m_lineEdit->setMinimumWidth(75);
+ m_d->m_lineEdit->setTextMargins(0, 0, 20, 0);
+ QWidget *lineEditFrame = new QWidget(this);
+ lineEditFrame->setObjectName(QLatin1String("itemLibrarySearchInputFrame"));
+ QGridLayout *lineEditLayout = new QGridLayout(lineEditFrame);
+ lineEditLayout->setMargin(2);
+ lineEditLayout->setSpacing(0);
+ lineEditLayout->addItem(new QSpacerItem(5, 3, QSizePolicy::Fixed, QSizePolicy::Fixed), 0, 0, 1, 3);
+ lineEditLayout->addItem(new QSpacerItem(5, 5, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 0);
+ lineEditLayout->addWidget(m_d->m_lineEdit, 1, 1, 1, 1);
+ lineEditLayout->addItem(new QSpacerItem(5, 5, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 2);
+ connect(m_d->m_lineEdit, SIGNAL(filterChanged(QString)), this, SLOT(setSearchFilter(QString)));
+
+ m_d->m_stackedWidget = new QStackedWidget(this);
+ m_d->m_stackedWidget->addWidget(m_d->m_itemsView);
+ m_d->m_stackedWidget->addWidget(m_d->m_resourcesView);
+ connect(tabBar, SIGNAL(currentChanged(int)),
+ m_d->m_stackedWidget, SLOT(setCurrentIndex(int)));
+ connect(tabBar, SIGNAL(currentChanged(int)),
+ this, SLOT(updateSearch()));
+
+ QWidget *spacer = new QWidget(this);
+ spacer->setObjectName(QLatin1String("itemLibrarySearchInputSpacer"));
+ spacer->setFixedHeight(4);
+
+ QGridLayout *layout = new QGridLayout(this);
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->setSpacing(0);
+ layout->addWidget(tabBar, 0, 0, 1, 1);
+ layout->addWidget(spacer, 1, 0);
+ layout->addWidget(lineEditFrame, 2, 0, 1, 1);
+ layout->addWidget(m_d->m_stackedWidget, 3, 0, 1, 1);
+
+ setResourcePath(QDir::currentPath());
+ setSearchFilter(QString());
+
+ /* style sheets */
+ {
+ QFile file(":/qmldesigner/stylesheet.css");
+ file.open(QFile::ReadOnly);
+ QString styleSheet = QLatin1String(file.readAll());
+ setStyleSheet(styleSheet);
+ }
+
+ {
+ QFile file(":/qmldesigner/scrollbar.css");
+ file.open(QFile::ReadOnly);
+ QString styleSheet = QLatin1String(file.readAll());
+ m_d->m_resourcesView->setStyleSheet(styleSheet);
+ }
+}
+
+ItemLibraryWidget::~ItemLibraryWidget()
+{
+ /* workaround: delete the items view before the model is deleted.
+ This prevents qml warnings when the item library is destructed. */
+ delete m_d->m_itemsView;
+ delete m_d->m_resourcesView;
+ delete m_d;
+}
+
+void ItemLibraryWidget::setItemLibraryInfo(ItemLibraryInfo *itemLibraryInfo)
+{
+ if (m_d->m_itemLibraryInfo.data() == itemLibraryInfo)
+ return;
+
+ if (m_d->m_itemLibraryInfo)
+ disconnect(m_d->m_itemLibraryInfo.data(), SIGNAL(entriesChanged()),
+ this, SLOT(updateModel()));
+ m_d->m_itemLibraryInfo = itemLibraryInfo;
+ if (itemLibraryInfo)
+ connect(m_d->m_itemLibraryInfo.data(), SIGNAL(entriesChanged()),
+ this, SLOT(updateModel()));
+
+ updateModel();
+ updateSearch();
+}
+
+void ItemLibraryWidget::updateImports()
+{
+ FilterChangeFlag filter;
+ filter = QtBasic;
+ if (m_d->model) {
+ QStringList imports;
+ foreach (const Import &import, m_d->model->imports())
+ if (import.isLibraryImport())
+ imports << import.url();
+ if (imports.contains("Qt.labs.Symbian", Qt::CaseInsensitive))
+ filter = Symbian;
+ if (imports.contains("com.Meego", Qt::CaseInsensitive))
+ filter = Meego;
+ }
+
+ setImportFilter(filter);
+}
+
+QList<QToolButton *> ItemLibraryWidget::createToolBarWidgets()
+{
+ QList<QToolButton *> buttons;
+ buttons << new QToolButton();
+ buttons.first()->setText("I ");
+ buttons.first()->setIcon(QIcon(QLatin1String(Core::Constants::ICON_FILTER)));
+ buttons.first()->setToolTip("Manage imports for components");
+ buttons.first()->setPopupMode(QToolButton::InstantPopup);
+ QMenu * menu = new QMenu;
+ QAction * basicQtAction = new QAction(menu);
+ basicQtAction->setCheckable(true);
+ basicQtAction->setText("Basic Qt Quick only");
+ QAction * symbianAction = new QAction(menu);
+ symbianAction->setCheckable(true);
+ symbianAction->setText("Symbian Components");
+ QAction * meegoAction= new QAction(menu);
+ meegoAction->setCheckable(true);
+ meegoAction->setText("Meego Components");
+ menu->addAction(basicQtAction);
+ menu->addAction(meegoAction);
+ menu->addAction(symbianAction);
+ buttons.first()->setMenu(menu);
+
+ connect(basicQtAction, SIGNAL(toggled(bool)), this, SLOT(onQtBasicOnlyChecked(bool)));
+ connect(this, SIGNAL(qtBasicOnlyChecked(bool)), basicQtAction, SLOT(setChecked(bool)));
+
+ connect(symbianAction, SIGNAL(toggled(bool)), this, SLOT(onSymbianChecked(bool)));
+ connect(this, SIGNAL(symbianChecked(bool)), symbianAction, SLOT(setChecked(bool)));
+
+ connect(meegoAction, SIGNAL(toggled(bool)), this, SLOT(onMeegoChecked(bool)));
+ connect(this, SIGNAL(meegoChecked(bool)), meegoAction, SLOT(setChecked(bool)));
+
+ updateImports();
+
+ return buttons;
+}
+
+void ItemLibraryWidget::setSearchFilter(const QString &searchFilter)
+{
+ if (m_d->m_stackedWidget->currentIndex() == 0) {
+ m_d->m_itemLibraryModel->setSearchText(searchFilter);
+ emit resetItemsView();
+ m_d->m_itemsView->update();
+ } else {
+ QStringList nameFilterList;
+ if (searchFilter.contains('.')) {
+ nameFilterList.append(QString("*%1*").arg(searchFilter));
+ } else {
+ foreach (const QByteArray &extension, QImageReader::supportedImageFormats()) {
+ nameFilterList.append(QString("*%1*.%2").arg(searchFilter, QString::fromAscii(extension)));
+ }
+ }
+
+ m_d->m_resourcesDirModel->setFilter(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot);
+ m_d->m_resourcesDirModel->setNameFilters(nameFilterList);
+ m_d->m_resourcesView->expandToDepth(1);
+ m_d->m_resourcesView->scrollToTop();
+ }
+}
+
+void ItemLibraryWidget::setModel(Model *model)
+{
+ m_d->model = model;
+ if (!model)
+ return;
+ setItemLibraryInfo(model->metaInfo().itemLibraryInfo());
+ updateModel();
+}
+
+
+void ItemLibraryWidget::setImportFilter(FilterChangeFlag flag)
+{
+
+ static bool block = false;
+ if (!m_d->model)
+ return;
+ if (flag == m_filterFlag)
+ return;
+
+ if (block == true)
+ return;
+
+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+
+ block = true;
+ if (flag == QtBasic) {
+ removeImport(QLatin1String("com.meego"));
+ removeImport(QLatin1String("Qt.labs.Symbian"));
+ emit qtBasicOnlyChecked(true);
+ emit meegoChecked(false);
+ emit symbianChecked(false);
+ } else if (flag == Symbian) {
+ removeImport(QLatin1String("com.meego"));
+ addImport(QLatin1String("Qt.labs.Symbian"), QLatin1String("1.0"));
+ emit qtBasicOnlyChecked(false);
+ emit meegoChecked(false);
+ emit symbianChecked(true);
+ } else if (flag == Meego) {
+ removeImport(QLatin1String("Qt.labs.Symbian"));
+ addImport(QLatin1String("com.meego"), QLatin1String("1.0"));
+ emit qtBasicOnlyChecked(false);
+ emit meegoChecked(true);
+ emit symbianChecked(false);
+ }
+ QApplication::restoreOverrideCursor();
+ block = false;
+ m_filterFlag = flag;
+}
+
+void ItemLibraryWidget::onQtBasicOnlyChecked(bool b)
+{
+ if (b)
+ setImportFilter(QtBasic);
+
+}
+
+void ItemLibraryWidget::onMeegoChecked(bool b)
+{
+ if (b)
+ setImportFilter(Meego);
+}
+
+void ItemLibraryWidget::onSymbianChecked(bool b)
+{
+ if (b)
+ setImportFilter(Symbian);
+}
+
+
+
+void ItemLibraryWidget::updateModel()
+{
+ m_d->m_itemLibraryModel->update(m_d->m_itemLibraryInfo.data(), m_d->model);
+ updateImports();
+ updateSearch();
+}
+
+void ItemLibraryWidget::updateSearch()
+{
+ setSearchFilter(m_d->m_lineEdit->text());
+}
+
+void ItemLibraryWidget::setResourcePath(const QString &resourcePath)
+{
+ if (m_d->m_resourcesView->model() == m_d->m_resourcesDirModel)
+ m_d->m_resourcesView->setRootIndex(m_d->m_resourcesDirModel->index(resourcePath));
+ updateSearch();
+}
+
+void ItemLibraryWidget::startDragAndDrop(int itemLibId)
+{
+ QMimeData *mimeData = m_d->m_itemLibraryModel->getMimeData(itemLibId);
+ CustomItemLibraryDrag *drag = new CustomItemLibraryDrag(this);
+ const QImage image = qvariant_cast<QImage>(mimeData->imageData());
+
+ drag->setPixmap(m_d->m_itemLibraryModel->getIcon(itemLibId).pixmap(32, 32));
+ drag->setPreview(QPixmap::fromImage(image));
+ drag->setMimeData(mimeData);
+
+ QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(m_d->m_itemsView->rootObject());
+ connect(rootItem, SIGNAL(stopDragAndDrop()), drag, SLOT(stopDrag()));
+
+ drag->exec();
+}
+
+void ItemLibraryWidget::showItemInfo(int /*itemLibId*/)
+{
+// qDebug() << "showing item info about id" << itemLibId;
+}
+
+void ItemLibraryWidget::wheelEvent(QWheelEvent *event)
+{
+ if (m_d->m_stackedWidget->currentIndex() == 0 &&
+ m_d->m_itemsView->rect().contains(event->pos())) {
+ emit scrollItemsView(event->delta());
+ event->accept();
+ } else
+ QFrame::wheelEvent(event);
+}
+
+ void ItemLibraryWidget::removeImport(const QString &name)
+ {
+ if (!m_d->model)
+ return;
+ foreach (const Import &import, m_d->model->imports())
+ if (import.isLibraryImport() && import.url().compare(name, Qt::CaseInsensitive) == 0)
+ m_d->model->removeImport(import);
+ }
+
+ void ItemLibraryWidget::addImport(const QString &name, const QString &version)
+ {
+ if (!m_d->model)
+ return;
+
+ m_d->model->addImport(Import::createLibraryImport(name, version));
+
+ }
+
+}
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#ifndef ITEMLIBRARYWIDGET_H
+#define ITEMLIBRARYWIDGET_H
+
+#include "itemlibraryinfo.h"
+#include <QtGui/QFrame>
+#include <QtGui/QToolButton>
+
+namespace QmlDesigner {
+
+class ItemLibraryWidgetPrivate;
+class MetaInfo;
+class ItemLibraryEntry;
+class Model;
+
+class ItemLibraryWidget : public QFrame
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(ItemLibraryWidget)
+
+ enum FilterChangeFlag {
+ QtBasic = 0x0,
+ Meego = 0x1,
+ Symbian = 0x2
+ };
+
+public:
+ ItemLibraryWidget(QWidget *parent = 0);
+ virtual ~ItemLibraryWidget();
+
+ void setItemLibraryInfo(ItemLibraryInfo *itemLibraryInfo);
+ QList<QToolButton *> createToolBarWidgets();
+
+ void updateImports();
+
+public Q_SLOTS:
+ void setSearchFilter(const QString &searchFilter);
+ void updateModel();
+ void updateSearch();
+
+ void setResourcePath(const QString &resourcePath);
+
+ void startDragAndDrop(int itemLibId);
+ void showItemInfo(int itemLibId);
+
+ void setModel(Model *model);
+
+ void setImportFilter(FilterChangeFlag flag);
+
+ void onQtBasicOnlyChecked(bool b);
+ void onMeegoChecked(bool b);
+ void onSymbianChecked(bool b);
+
+protected:
+ void wheelEvent(QWheelEvent *event);
+ void removeImport(const QString &name);
+ void addImport(const QString &name, const QString &version);
+
+signals:
+ void itemActivated(const QString& itemName);
+ void scrollItemsView(QVariant delta);
+ void resetItemsView();
+ void qtBasicOnlyChecked(bool b);
+ void meegoChecked(bool b);
+ void symbianChecked(bool b);
+
+private:
+ ItemLibraryWidgetPrivate *m_d;
+ FilterChangeFlag m_filterFlag;
+};
+
+}
+
+#endif // ITEMLIBRARYWIDGET_H
+
-#ifndef NODEINSTANCE_H
-#define NODEINSTANCE_H
+ /**************************************************************************
+ **
+ ** This file is part of Qt Creator
+ **
+ ** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ **
+ ** Contact: Nokia Corporation (qt-info@nokia.com)
+ **
+ ** No Commercial Usage
+ **
+ ** This file contains pre-release code and may not be distributed.
+ ** You may use this file in accordance with the terms and conditions
+ ** contained in the Technology Preview License Agreement accompanying
+ ** this package.
+ **
+ ** GNU Lesser General Public License Usage
+ **
+ ** Alternatively, this file may be used under the terms of the GNU Lesser
+ ** General Public License version 2.1 as published by the Free Software
+ ** Foundation and appearing in the file LICENSE.LGPL included in the
+ ** packaging of this file. Please review the following information to
+ ** ensure the GNU Lesser General Public License version 2.1 requirements
+ ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+ **
+ ** In addition, as a special exception, Nokia gives you certain additional
+ ** rights. These rights are described in the Nokia Qt LGPL Exception
+ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+ **
+ ** If you have questions regarding the use of this file, please contact
+ ** Nokia at qt-info@nokia.com.
+ **
+ **************************************************************************/
+
+#ifndef PROXYNODEINSTANCE_H
+#define PROXYNODEINSTANCE_H
-#include "corelib_global.h"
#include <QSharedPointer>
-#include <QHash>
-#include <QRectF>
-#include <propertymetainfo.h>
-#include <qmlanchors.h>
+#include <QTransform>
+#include <QPointF>
+#include <QSizeF>
+#include <QPair>
-QT_BEGIN_NAMESPACE
-class QPainter;
-class QStyleOptionGraphicsItem;
-class QDeclarativeContext;
-class QGraphicsItem;
-class QGraphicsTransform;
-QT_END_NAMESPACE
+#include "commondefines.h"
namespace QmlDesigner {
+ /**************************************************************************
+ **
+ ** This file is part of Qt Creator
+ **
+ ** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ **
+ ** Contact: Nokia Corporation (qt-info@nokia.com)
+ **
+ ** No Commercial Usage
+ **
+ ** This file contains pre-release code and may not be distributed.
+ ** You may use this file in accordance with the terms and conditions
+ ** contained in the Technology Preview License Agreement accompanying
+ ** this package.
+ **
+ ** GNU Lesser General Public License Usage
+ **
+ ** Alternatively, this file may be used under the terms of the GNU Lesser
+ ** General Public License version 2.1 as published by the Free Software
+ ** Foundation and appearing in the file LICENSE.LGPL included in the
+ ** packaging of this file. Please review the following information to
+ ** ensure the GNU Lesser General Public License version 2.1 requirements
+ ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+ **
+ ** In addition, as a special exception, Nokia gives you certain additional
+ ** rights. These rights are described in the Nokia Qt LGPL Exception
+ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+ **
+ ** If you have questions regarding the use of this file, please contact
+ ** Nokia at qt-info@nokia.com.
+ **
+ **************************************************************************/
+
#include "nodeinstance.h"
-#include "objectnodeinstance.h"
-#include "metainfo.h"
-#include "graphicswidgetnodeinstance.h"
-#include "widgetnodeinstance.h"
-#include "qmlgraphicsitemnodeinstance.h"
-#include "graphicsscenenodeinstance.h"
-#include "graphicsviewnodeinstance.h"
-#include "nodeinstanceview.h"
-#include "qmlviewnodeinstance.h"
-#include "dummynodeinstance.h"
-#include "componentnodeinstance.h"
-#include "qmltransitionnodeinstance.h"
-#include "qmlpropertychangesnodeinstance.h"
-#include "positionernodeinstance.h"
-#include "behaviornodeinstance.h"
-#include "qmlstatenodeinstance.h"
-#include "nodeabstractproperty.h"
-#include "variantproperty.h"
-
-#include <invalidnodeinstanceexception.h>
-
-#include <QHash>
-#include <QSet>
-
-#include <QtDeclarative/QDeclarativeEngine>
-
-/*!
- \class QmlDesigner::NodeInstance
- \ingroup CoreInstance
- \brief NodeInstance is a common handle for the actual object representation of a ModelNode.
-
- NodeInstance abstracts away the differences e.g. in terms of position and size
- for QWidget, QGraphicsView, QLayout etc objects. Multiple NodeInstance objects can share
- the pointer to the same instance object. The actual instance will be deleted when
- the last NodeInstance object referencing to it is deleted. This can be disabled by
- setDeleteHeldInstance().
-
- \see QmlDesigner::NodeInstanceView
-*/
+#include <QPainter>
+#include <modelnode.h>
+#include "commondefines.h"
-namespace QmlDesigner {
+#include <QtDebug>
-/*!
-\brief Constructor - creates a invalid NodeInstance
+namespace QmlDesigner {
+class ProxyNodeInstanceData
+{
+public:
+ ProxyNodeInstanceData()
+ : parentInstanceId(-1),
+ penWidth(1),
+ isAnchoredBySibling(false),
+ isAnchoredByChildren(false),
+ hasContent(false),
+ isMovable(false),
+ isResizable(false),
+ isInPositioner(false)
+ {}
+
+ qint32 parentInstanceId;
+ ModelNode modelNode;
+ QRectF boundingRect;
+ QPointF position;
+ QSizeF size;
+ QTransform transform;
+ QTransform sceneTransform;
+ int penWidth;
+ bool isAnchoredBySibling;
+ bool isAnchoredByChildren;
+ bool hasContent;
+ bool isMovable;
+ bool isResizable;
+ bool isInPositioner;
+
+
+ QHash<QString, QVariant> propertyValues;
+ QHash<QString, bool> hasBindingForProperty;
+ QHash<QString, bool> hasAnchors;
+ QHash<QString, QString> instanceTypes;
+
+ QImage renderImage;
+ QHash<QString, QPair<QString, qint32> > anchors;
+};
-\see NodeInstanceView
-*/
NodeInstance::NodeInstance()
{
}
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#ifndef SymbianPLUGIN_H
+#define SymbianPLUGIN_H
+
+#include <iwidgetplugin.h>
+#include <QtDeclarative/qdeclarative.h>
+
+QT_BEGIN_NAMESPACE
+QT_END_NAMESPACE
+
+namespace QmlDesigner {
+
+class SymbianPlugin : public QObject, QmlDesigner::IWidgetPlugin
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(SymbianPlugin)
+ Q_INTERFACES(QmlDesigner::IWidgetPlugin)
+public:
+ SymbianPlugin();
+ ~SymbianPlugin() {}
+
+ QString metaInfo();
+ QString pluginName();
+
+};
+
+} // namespace QmlDesigner
+
+
+#endif // SymbianPLUGIN_H
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#ifndef QMLJSAUTOCOMPLETER_H
+#define QMLJSAUTOCOMPLETER_H
+
+#include <texteditor/autocompleter.h>
+
+namespace QmlJSEditor {
+namespace Internal {
+
+class AutoCompleter : public TextEditor::AutoCompleter
+{
+public:
+ AutoCompleter();
+ virtual ~AutoCompleter();
+
+ virtual bool contextAllowsAutoParentheses(const QTextCursor &cursor,
+ const QString &textToInsert = QString()) const;
+ virtual bool contextAllowsElectricCharacters(const QTextCursor &cursor) const;
+ virtual bool isInComment(const QTextCursor &cursor) const;
+ virtual QString insertMatchingBrace(const QTextCursor &tc,
+ const QString &text,
+ QChar la,
+ int *skippedChars) const;
+ virtual QString insertParagraphSeparator(const QTextCursor &tc) const;
+};
+
+} // Internal
+} // QmlJSEditor
+
+#endif // QMLJSAUTOCOMPLETER_H
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
+ ** In addition, as a special exception, Nokia gives you certain additional
+ ** rights. These rights are described in the Nokia Qt LGPL Exception
+ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+ **
+ ** If you have questions regarding the use of this file, please contact
+ ** Nokia at qt-info@nokia.com.
**
**************************************************************************/
+
#include "qmljsinspectorconstants.h"
#include "qmljsinspector.h"
#include "qmlinspectortoolbar.h"
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#include "qmljsmodelmanager.h"
+#include "qmljstoolsconstants.h"
+#include "qmljsplugindumper.h"
+
+#include <coreplugin/icore.h>
+#include <coreplugin/editormanager/editormanager.h>
+#include <coreplugin/progressmanager/progressmanager.h>
+#include <coreplugin/mimedatabase.h>
+#include <qmljs/qmljsinterpreter.h>
+#include <qmljs/qmljsbind.h>
+#include <qmljs/parser/qmldirparser_p.h>
+#include <texteditor/itexteditor.h>
+#include <texteditor/basetexteditor.h>
+#include <projectexplorer/project.h>
+#include <projectexplorer/projectexplorer.h>
+#include <projectexplorer/projectexplorerconstants.h>
+
+#include <QDir>
+#include <QFile>
+#include <QFileInfo>
+#include <QLibraryInfo>
+#include <QtConcurrentRun>
+#include <qtconcurrent/runextensions.h>
+#include <QTextStream>
+#include <QCoreApplication>
+
+#include <QDebug>
+
+using namespace QmlJS;
+using namespace QmlJSTools;
+using namespace QmlJSTools::Internal;
+
+static QStringList environmentImportPaths();
+
+ModelManager::ModelManager(QObject *parent):
+ ModelManagerInterface(parent),
+ m_core(Core::ICore::instance()),
+ m_pluginDumper(new PluginDumper(this))
+{
+ m_synchronizer.setCancelOnWait(true);
+
+ qRegisterMetaType<QmlJS::Document::Ptr>("QmlJS::Document::Ptr");
+ qRegisterMetaType<QmlJS::LibraryInfo>("QmlJS::LibraryInfo");
+
+ loadQmlTypeDescriptions();
+
+ m_defaultImportPaths << environmentImportPaths();
+ updateImportPaths();
+}
+
+void ModelManager::loadQmlTypeDescriptions()
+{
+ if (Core::ICore::instance()) {
+ loadQmlTypeDescriptions(Core::ICore::instance()->resourcePath());
+ loadQmlTypeDescriptions(Core::ICore::instance()->userResourcePath());
+ }
+}
+
+void ModelManager::loadQmlTypeDescriptions(const QString &resourcePath)
+{
+ const QDir typeFileDir(resourcePath + QLatin1String("/qml-type-descriptions"));
+ const QStringList xmlExtensions = QStringList() << QLatin1String("*.xml");
+ const QFileInfoList xmlFiles = typeFileDir.entryInfoList(xmlExtensions,
+ QDir::Files,
+ QDir::Name);
+
+ const QStringList errors = Interpreter::CppQmlTypesLoader::load(xmlFiles);
+ foreach (const QString &error, errors)
+ qWarning() << qPrintable(error);
+
+ // disabled for now: Prefer the xml file until the type dumping functionality
+ // has been moved into Qt.
+ // loads the builtin types
+ //loadQmlPluginTypes(QString());
+}
+
+ModelManagerInterface::WorkingCopy ModelManager::workingCopy() const
+{
+ WorkingCopy workingCopy;
+ if (!m_core)
+ return workingCopy;
+
+ Core::EditorManager *editorManager = m_core->editorManager();
+
+ foreach (Core::IEditor *editor, editorManager->openedEditors()) {
+ const QString key = editor->file()->fileName();
+
+ if (TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor*>(editor)) {
+ if (textEditor->context().contains(ProjectExplorer::Constants::LANG_QMLJS)) {
+ if (TextEditor::BaseTextEditor *ed = qobject_cast<TextEditor::BaseTextEditor *>(textEditor->widget())) {
+ workingCopy.insert(key, ed->toPlainText(), ed->document()->revision());
+ }
+ }
+ }
+ }
+
+ return workingCopy;
+}
+
+Snapshot ModelManager::snapshot() const
+{
+ QMutexLocker locker(&m_mutex);
+
+ return _snapshot;
+}
+
+void ModelManager::updateSourceFiles(const QStringList &files,
+ bool emitDocumentOnDiskChanged)
+{
+ refreshSourceFiles(files, emitDocumentOnDiskChanged);
+}
+
+QFuture<void> ModelManager::refreshSourceFiles(const QStringList &sourceFiles,
+ bool emitDocumentOnDiskChanged)
+{
+ if (sourceFiles.isEmpty()) {
+ return QFuture<void>();
+ }
+
+ QFuture<void> result = QtConcurrent::run(&ModelManager::parse,
+ workingCopy(), sourceFiles,
+ this,
+ emitDocumentOnDiskChanged);
+
+ if (m_synchronizer.futures().size() > 10) {
+ QList<QFuture<void> > futures = m_synchronizer.futures();
+
+ m_synchronizer.clearFutures();
+
+ foreach (QFuture<void> future, futures) {
+ if (! (future.isFinished() || future.isCanceled()))
+ m_synchronizer.addFuture(future);
+ }
+ }
+
+ m_synchronizer.addFuture(result);
+
+ if (sourceFiles.count() > 1) {
+ m_core->progressManager()->addTask(result, tr("Indexing"),
+ Constants::TASK_INDEX);
+ }
+
+ return result;
+}
+
+void ModelManager::fileChangedOnDisk(const QString &path)
+{
+ QtConcurrent::run(&ModelManager::parse,
+ workingCopy(), QStringList() << path,
+ this, true);
+}
+
+void ModelManager::removeFiles(const QStringList &files)
+{
+ emit aboutToRemoveFiles(files);
+
+ QMutexLocker locker(&m_mutex);
+
+ foreach (const QString &file, files)
+ _snapshot.remove(file);
+}
+
+QList<ModelManager::ProjectInfo> ModelManager::projectInfos() const
+{
+ QMutexLocker locker(&m_mutex);
+
+ return m_projects.values();
+}
+
+ModelManager::ProjectInfo ModelManager::projectInfo(ProjectExplorer::Project *project) const
+{
+ QMutexLocker locker(&m_mutex);
+
+ return m_projects.value(project, ProjectInfo(project));
+}
+
+void ModelManager::updateProjectInfo(const ProjectInfo &pinfo)
+{
+ if (! pinfo.isValid())
+ return;
+
+ Snapshot snapshot;
+ ProjectInfo oldInfo;
+ {
+ QMutexLocker locker(&m_mutex);
+ oldInfo = m_projects.value(pinfo.project);
+ m_projects.insert(pinfo.project, pinfo);
+ snapshot = _snapshot;
+
+ if (oldInfo.qmlDumpPath != pinfo.qmlDumpPath)
+ m_pluginDumper->scheduleCompleteRedump();
+ }
+
+ updateImportPaths();
+
+ // remove files that are no longer in the project and have been deleted
+ QStringList deletedFiles;
+ foreach (const QString &oldFile, oldInfo.sourceFiles) {
+ if (snapshot.document(oldFile)
+ && !pinfo.sourceFiles.contains(oldFile)
+ && !QFile::exists(oldFile)) {
+ deletedFiles += oldFile;
+ }
+ }
+ removeFiles(deletedFiles);
+
+ // parse any files not yet in the snapshot
+ QStringList newFiles;
+ foreach (const QString &file, pinfo.sourceFiles) {
+ if (!snapshot.document(file))
+ newFiles += file;
+ }
+ updateSourceFiles(newFiles, false);
+}
+
+void ModelManager::emitDocumentChangedOnDisk(Document::Ptr doc)
+{ emit documentChangedOnDisk(doc); }
+
+void ModelManager::updateDocument(Document::Ptr doc)
+{
+ {
+ QMutexLocker locker(&m_mutex);
+ _snapshot.insert(doc);
+ }
+ emit documentUpdated(doc);
+}
+
+void ModelManager::updateLibraryInfo(const QString &path, const LibraryInfo &info)
+{
+ {
+ QMutexLocker locker(&m_mutex);
+ _snapshot.insertLibraryInfo(path, info);
+ }
+ emit libraryInfoUpdated(path, info);
+}
+
+static QStringList qmlFilesInDirectory(const QString &path)
+{
+ QStringList pattern;
+ if (Core::ICore::instance()) {
+ // ### It would suffice to build pattern once. This function needs to be thread-safe.
+ Core::MimeDatabase *db = Core::ICore::instance()->mimeDatabase();
+ Core::MimeType jsSourceTy = db->findByType(Constants::JS_MIMETYPE);
+ Core::MimeType qmlSourceTy = db->findByType(Constants::QML_MIMETYPE);
+
+ QStringList pattern;
+ foreach (const Core::MimeGlobPattern &glob, jsSourceTy.globPatterns())
+ pattern << glob.regExp().pattern();
+ foreach (const Core::MimeGlobPattern &glob, qmlSourceTy.globPatterns())
+ pattern << glob.regExp().pattern();
+ } else {
+ pattern << "*.qml" << "*.js";
+ }
+
+ QStringList files;
+
+ const QDir dir(path);
+ foreach (const QFileInfo &fi, dir.entryInfoList(pattern, QDir::Files))
+ files += fi.absoluteFilePath();
+
+ return files;
+}
+
+static void findNewImplicitImports(const Document::Ptr &doc, const Snapshot &snapshot,
+ QStringList *importedFiles, QSet<QString> *scannedPaths)
+{
+ // scan files that could be implicitly imported
+ // it's important we also do this for JS files, otherwise the isEmpty check will fail
+ if (snapshot.documentsInDirectory(doc->path()).isEmpty()) {
+ if (! scannedPaths->contains(doc->path())) {
+ *importedFiles += qmlFilesInDirectory(doc->path());
+ scannedPaths->insert(doc->path());
+ }
+ }
+}
+
+static void findNewFileImports(const Document::Ptr &doc, const Snapshot &snapshot,
+ QStringList *importedFiles, QSet<QString> *scannedPaths)
+{
+ // scan files and directories that are explicitly imported
+ foreach (const Interpreter::ImportInfo &import, doc->bind()->imports()) {
+ const QString &importName = import.name();
+ if (import.type() == Interpreter::ImportInfo::FileImport) {
+ if (! snapshot.document(importName))
+ *importedFiles += importName;
+ } else if (import.type() == Interpreter::ImportInfo::DirectoryImport) {
+ if (snapshot.documentsInDirectory(importName).isEmpty()) {
+ if (! scannedPaths->contains(importName)) {
+ *importedFiles += qmlFilesInDirectory(importName);
+ scannedPaths->insert(importName);
+ }
+ }
+ }
+ }
+}
+
+static void findNewLibraryImports(const Document::Ptr &doc, const Snapshot &snapshot,
+ ModelManager *modelManager,
+ QStringList *importedFiles, QSet<QString> *scannedPaths)
+{
+ // scan library imports
+ const QStringList importPaths = modelManager->importPaths();
+ foreach (const Interpreter::ImportInfo &import, doc->bind()->imports()) {
+ if (import.type() != Interpreter::ImportInfo::LibraryImport)
+ continue;
+ foreach (const QString &importPath, importPaths) {
+ QDir dir(importPath);
+ dir.cd(import.name());
+ const QString targetPath = dir.absolutePath();
+
+ // if we know there is a library, done
+ if (snapshot.libraryInfo(targetPath).isValid())
+ break;
+
+ // if there is a qmldir file, we found a new library!
+ if (dir.exists("qmldir")) {
+ QFile qmldirFile(dir.filePath("qmldir"));
+ qmldirFile.open(QFile::ReadOnly);
+ QString qmldirData = QString::fromUtf8(qmldirFile.readAll());
+
+ QmlDirParser qmldirParser;
+ qmldirParser.setSource(qmldirData);
+ qmldirParser.parse();
+
+ modelManager->updateLibraryInfo(QFileInfo(qmldirFile).absolutePath(),
+ LibraryInfo(qmldirParser));
+
+ // scan the qml files in the library
+ foreach (const QmlDirParser::Component &component, qmldirParser.components()) {
+ if (! component.fileName.isEmpty()) {
+ QFileInfo componentFileInfo(dir.filePath(component.fileName));
+ const QString path = componentFileInfo.absolutePath();
+ if (! scannedPaths->contains(path)) {
+ *importedFiles += qmlFilesInDirectory(path);
+ scannedPaths->insert(path);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+static bool suffixMatches(const QString &fileName, const Core::MimeType &mimeType)
+{
+ foreach (const QString &suffix, mimeType.suffixes()) {
+ if (fileName.endsWith(suffix, Qt::CaseInsensitive))
+ return true;
+ }
+ return false;
+}
+
+void ModelManager::parse(QFutureInterface<void> &future,
+ WorkingCopy workingCopy,
+ QStringList files,
+ ModelManager *modelManager,
+ bool emitDocChangedOnDisk)
+{
+ Core::MimeDatabase *db = 0;
+ Core::MimeType jsSourceTy;
+ Core::MimeType qmlSourceTy;
+ if (Core::ICore::instance()) {
+ db = Core::ICore::instance()->mimeDatabase();
+ jsSourceTy = db->findByType(QLatin1String("application/javascript"));
+ qmlSourceTy = db->findByType(QLatin1String("application/x-qml"));
+ }
+
+ int progressRange = files.size();
+ future.setProgressRange(0, progressRange);
+
+ Snapshot snapshot = modelManager->_snapshot;
+
+ // paths we have scanned for files and added to the files list
+ QSet<QString> scannedPaths;
+
+ for (int i = 0; i < files.size(); ++i) {
+ future.setProgressValue(qreal(i) / files.size() * progressRange);
+
+ const QString fileName = files.at(i);
+
+ bool isQmlFile = true;
+ if (db) {
+ if (suffixMatches(fileName, jsSourceTy)) {
+ isQmlFile = false;
+ } else if (! suffixMatches(fileName, qmlSourceTy)) {
+ continue; // skip it. it's not a QML or a JS file.
+ }
+ } else {
+ if (fileName.contains(QLatin1String(".js"), Qt::CaseInsensitive))
+ isQmlFile = false;
+ else if (!fileName.contains(QLatin1String(".qml"), Qt::CaseInsensitive))
+ continue;
+ }
+
+ QString contents;
+ int documentRevision = 0;
+
+ if (workingCopy.contains(fileName)) {
+ QPair<QString, int> entry = workingCopy.get(fileName);
+ contents = entry.first;
+ documentRevision = entry.second;
+ } else {
+ QFile inFile(fileName);
+
+ if (inFile.open(QIODevice::ReadOnly)) {
+ QTextStream ins(&inFile);
+ contents = ins.readAll();
+ inFile.close();
+ }
+ }
+
+ Document::Ptr doc = Document::create(fileName);
+ doc->setEditorRevision(documentRevision);
+ doc->setSource(contents);
+ doc->parse();
+
+ // get list of referenced files not yet in snapshot or in directories already scanned
+ QStringList importedFiles;
+ findNewImplicitImports(doc, snapshot, &importedFiles, &scannedPaths);
+ findNewFileImports(doc, snapshot, &importedFiles, &scannedPaths);
+ findNewLibraryImports(doc, snapshot, modelManager, &importedFiles, &scannedPaths);
+
+ // add new files to parse list
+ foreach (const QString &file, importedFiles) {
+ if (! files.contains(file))
+ files.append(file);
+ }
+
+ modelManager->updateDocument(doc);
+ if (emitDocChangedOnDisk)
+ modelManager->emitDocumentChangedOnDisk(doc);
+ }
+
+ future.setProgressValue(progressRange);
+}
+
+// Check whether fileMimeType is the same or extends knownMimeType
+bool ModelManager::matchesMimeType(const Core::MimeType &fileMimeType, const Core::MimeType &knownMimeType)
+{
+ Core::MimeDatabase *db = Core::ICore::instance()->mimeDatabase();
+
+ const QStringList knownTypeNames = QStringList(knownMimeType.type()) + knownMimeType.aliases();
+
+ foreach (const QString knownTypeName, knownTypeNames)
+ if (fileMimeType.matchesType(knownTypeName))
+ return true;
+
+ // recursion to parent types of fileMimeType
+ foreach (const QString &parentMimeType, fileMimeType.subClassesOf()) {
+ if (matchesMimeType(db->findByType(parentMimeType), knownMimeType))
+ return true;
+ }
+
+ return false;
+}
+
+QStringList ModelManager::importPaths() const
+{
+ return m_allImportPaths;
+}
+
+static QStringList environmentImportPaths()
+{
+ QStringList paths;
+
+ QByteArray envImportPath = qgetenv("QML_IMPORT_PATH");
+
+#if defined(Q_OS_WIN)
+ QLatin1Char pathSep(';');
+#else
+ QLatin1Char pathSep(':');
+#endif
+ foreach (const QString &path, QString::fromLatin1(envImportPath).split(pathSep, QString::SkipEmptyParts)) {
+ QString canonicalPath = QDir(path).canonicalPath();
+ if (!canonicalPath.isEmpty() && !paths.contains(canonicalPath))
+ paths.append(canonicalPath);
+ }
+
+ return paths;
+}
+
+void ModelManager::updateImportPaths()
+{
+ m_allImportPaths.clear();
+ QMapIterator<ProjectExplorer::Project *, ProjectInfo> it(m_projects);
+ while (it.hasNext()) {
+ it.next();
+ m_allImportPaths += it.value().importPaths;
+ }
+ m_allImportPaths += m_defaultImportPaths;
+ m_allImportPaths.removeDuplicates();
+
+ // check if any file in the snapshot imports something new in the new paths
+ Snapshot snapshot = _snapshot;
+ QStringList importedFiles;
+ QSet<QString> scannedPaths;
+ foreach (const Document::Ptr &doc, snapshot)
+ findNewLibraryImports(doc, snapshot, this, &importedFiles, &scannedPaths);
+
+ updateSourceFiles(importedFiles, true);
+}
+
+void ModelManager::loadPluginTypes(const QString &libraryPath, const QString &importPath, const QString &importUri)
+{
+ m_pluginDumper->loadPluginTypes(libraryPath, importPath, importUri);
+}
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#ifndef QMLJSMODELMANAGER_H
+#define QMLJSMODELMANAGER_H
+
+#include "qmljstools_global.h"
+
+#include <qmljs/qmljsmodelmanagerinterface.h>
+#include <qmljs/qmljsdocument.h>
+
+#include <QFuture>
+#include <QFutureSynchronizer>
+#include <QMutex>
+#include <QProcess>
+
+namespace Core {
+class ICore;
+class MimeType;
+}
+
+namespace QmlJSTools {
+namespace Internal {
+
+class PluginDumper;
+
+class QMLJSTOOLS_EXPORT ModelManager: public QmlJS::ModelManagerInterface
+{
+ Q_OBJECT
+
+public:
+ ModelManager(QObject *parent = 0);
+
+ virtual WorkingCopy workingCopy() const;
+ virtual QmlJS::Snapshot snapshot() const;
+
+ virtual void updateSourceFiles(const QStringList &files,
+ bool emitDocumentOnDiskChanged);
+ virtual void fileChangedOnDisk(const QString &path);
+ virtual void removeFiles(const QStringList &files);
+
+ virtual QList<ProjectInfo> projectInfos() const;
+ virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const;
+ virtual void updateProjectInfo(const ProjectInfo &pinfo);
+
+ void updateDocument(QmlJS::Document::Ptr doc);
+ void updateLibraryInfo(const QString &path, const QmlJS::LibraryInfo &info);
+ void emitDocumentChangedOnDisk(QmlJS::Document::Ptr doc);
+
+ virtual QStringList importPaths() const;
+
+ virtual void loadPluginTypes(const QString &libraryPath, const QString &importPath, const QString &importUri);
+
+Q_SIGNALS:
+ void projectPathChanged(const QString &projectPath);
+
+protected:
+ QFuture<void> refreshSourceFiles(const QStringList &sourceFiles,
+ bool emitDocumentOnDiskChanged);
+
+ static void parse(QFutureInterface<void> &future,
+ WorkingCopy workingCopy,
+ QStringList files,
+ ModelManager *modelManager,
+ bool emitDocChangedOnDisk);
+
+ void loadQmlTypeDescriptions();
+ void loadQmlTypeDescriptions(const QString &path);
+
+ void updateImportPaths();
+
+private:
+ static bool matchesMimeType(const Core::MimeType &fileMimeType, const Core::MimeType &knownMimeType);
+
+ mutable QMutex m_mutex;
+ Core::ICore *m_core;
+ QmlJS::Snapshot _snapshot;
+ QStringList m_allImportPaths;
+ QStringList m_defaultImportPaths;
+
+ QFutureSynchronizer<void> m_synchronizer;
+
+ // project integration
+ QMap<ProjectExplorer::Project *, ProjectInfo> m_projects;
+
+ PluginDumper *m_pluginDumper;
+};
+
+} // namespace Internal
+} // namespace QmlJSTools
+
+#endif // QMLJSMODELMANAGER_H
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#include "qmljsqtstylecodeformatter.h"
+
+#include <texteditor/tabsettings.h>
+
+#include <QtCore/QDebug>
+
+using namespace QmlJS;
+using namespace QmlJSTools;
+using namespace TextEditor;
+
+QtStyleCodeFormatter::QtStyleCodeFormatter()
+ : m_indentSize(4)
+{
+}
+
+QtStyleCodeFormatter::QtStyleCodeFormatter(const TextEditor::TabSettings &tabSettings)
+ : m_indentSize(tabSettings.m_indentSize)
+{
+ setTabSize(tabSettings.m_tabSize);
+}
+
+void QtStyleCodeFormatter::setIndentSize(int size)
+{
+ m_indentSize = size;
+}
+
+void QtStyleCodeFormatter::saveBlockData(QTextBlock *block, const BlockData &data) const
+{
+ TextBlockUserData *userData = BaseTextDocumentLayout::userData(*block);
+ QmlJSCodeFormatterData *cppData = static_cast<QmlJSCodeFormatterData *>(userData->codeFormatterData());
+ if (!cppData) {
+ cppData = new QmlJSCodeFormatterData;
+ userData->setCodeFormatterData(cppData);
+ }
+ cppData->m_data = data;
+}
+
+bool QtStyleCodeFormatter::loadBlockData(const QTextBlock &block, BlockData *data) const
+{
+ TextBlockUserData *userData = BaseTextDocumentLayout::testUserData(block);
+ if (!userData)
+ return false;
+ QmlJSCodeFormatterData *cppData = static_cast<QmlJSCodeFormatterData *>(userData->codeFormatterData());
+ if (!cppData)
+ return false;
+
+ *data = cppData->m_data;
+ return true;
+}
+
+void QtStyleCodeFormatter::saveLexerState(QTextBlock *block, int state) const
+{
+ BaseTextDocumentLayout::setLexerState(*block, state);
+}
+
+int QtStyleCodeFormatter::loadLexerState(const QTextBlock &block) const
+{
+ return BaseTextDocumentLayout::lexerState(block);
+}
+
+void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedIndentDepth) const
+{
+ const State &parentState = state();
+ const Token &tk = currentToken();
+ const int tokenPosition = column(tk.begin());
+ const bool firstToken = (tokenIndex() == 0);
+ const bool lastToken = (tokenIndex() == tokenCount() - 1);
+
+ switch (newState) {
+ case objectdefinition_open: {
+ // special case for things like "gradient: Gradient {"
+ if (parentState.type == binding_assignment)
+ *savedIndentDepth = state(1).savedIndentDepth;
+
+ if (firstToken)
+ *savedIndentDepth = tokenPosition;
+
+ *indentDepth = *savedIndentDepth + m_indentSize;
+ break;
+ }
+
+ case binding_or_objectdefinition:
+ if (firstToken)
+ *indentDepth = *savedIndentDepth = tokenPosition;
+ break;
+
+ case binding_assignment:
+ if (lastToken)
+ *indentDepth = *savedIndentDepth + 4;
+ else
+ *indentDepth = column(tokenAt(tokenIndex() + 1).begin());
+ break;
+
+ case expression_or_objectdefinition:
+ *indentDepth = tokenPosition;
+ break;
+
+ case expression:
+ // expression_or_objectdefinition has already consumed the first token
+ // ternary already adjusts indents nicely
+ if (parentState.type != expression_or_objectdefinition
+ && parentState.type != binding_assignment
+ && parentState.type != ternary_op) {
+ *indentDepth += 2 * m_indentSize;
+ }
+ if (!firstToken && parentState.type != expression_or_objectdefinition) {
+ *indentDepth = tokenPosition;
+ }
+ break;
+
+ case expression_maybe_continuation:
+ // set indent depth to indent we'd get if the expression ended here
+ for (int i = 1; state(i).type != topmost_intro; ++i) {
+ const int type = state(i).type;
+ if (isExpressionEndState(type) && !isBracelessState(type)) {
+ *indentDepth = state(i - 1).savedIndentDepth;
+ break;
+ }
+ }
+ break;
+
+ case bracket_open:
+ if (parentState.type == expression && state(1).type == binding_assignment) {
+ *savedIndentDepth = state(2).savedIndentDepth;
+ *indentDepth = *savedIndentDepth + m_indentSize;
+ } else if (!lastToken) {
+ *indentDepth = tokenPosition + 1;
+ } else {
+ *indentDepth = *savedIndentDepth + m_indentSize;
+ }
+ break;
+
+ case function_start:
+ if (parentState.type == expression) {
+ // undo the continuation indent of the expression
+ *indentDepth = parentState.savedIndentDepth;
+ *savedIndentDepth = *indentDepth;
+ }
+ break;
+
+ case do_statement_while_paren_open:
+ case statement_with_condition_paren_open:
+ case signal_arglist_open:
+ case function_arglist_open:
+ case paren_open:
+ case condition_paren_open:
+ if (!lastToken)
+ *indentDepth = tokenPosition + 1;
+ else
+ *indentDepth += m_indentSize;
+ break;
+
+ case ternary_op:
+ if (!lastToken)
+ *indentDepth = tokenPosition + tk.length + 1;
+ else
+ *indentDepth += m_indentSize;
+ break;
+
+ case jsblock_open:
+ // closing brace should be aligned to case
+ if (parentState.type == case_cont) {
+ *savedIndentDepth = parentState.savedIndentDepth;
+ break;
+ }
+ // fallthrough
+ case substatement_open:
+ // special case for foo: {
+ if (parentState.type == binding_assignment && state(1).type == binding_or_objectdefinition)
+ *savedIndentDepth = state(1).savedIndentDepth;
+ *indentDepth = *savedIndentDepth + m_indentSize;
+ break;
+
+ case statement_with_condition:
+ case statement_with_block:
+ case if_statement:
+ case do_statement:
+ case switch_statement:
+ if (firstToken || parentState.type == binding_assignment)
+ *savedIndentDepth = tokenPosition;
+ // ### continuation
+ *indentDepth = *savedIndentDepth; // + 2*m_indentSize;
+ break;
+
+ case maybe_else: {
+ // set indent to outermost braceless savedIndent
+ int outermostBraceless = 0;
+ while (isBracelessState(state(outermostBraceless + 1).type))
+ ++outermostBraceless;
+ *indentDepth = state(outermostBraceless).savedIndentDepth;
+ // this is where the else should go, if one appears - aligned to if_statement
+ *savedIndentDepth = state().savedIndentDepth;
+ break;
+ }
+
+ case condition_open:
+ // fixed extra indent when continuing 'if (', but not for 'else if ('
+ if (tokenPosition <= *indentDepth + m_indentSize)
+ *indentDepth += 2*m_indentSize;
+ else
+ *indentDepth = tokenPosition + 1;
+ break;
+
+ case case_start:
+ *savedIndentDepth = tokenPosition;
+ break;
+
+ case case_cont:
+ *indentDepth += m_indentSize;
+ break;
+
+ case multiline_comment_start:
+ *indentDepth = tokenPosition + 2;
+ break;
+
+ case multiline_comment_cont:
+ *indentDepth = tokenPosition;
+ break;
+ }
+}
+
+void QtStyleCodeFormatter::adjustIndent(const QList<Token> &tokens, int lexerState, int *indentDepth) const
+{
+ Q_UNUSED(lexerState)
+
+ State topState = state();
+ State previousState = state(1);
+
+ // adjusting the indentDepth here instead of in enter() gives 'else if' the correct indentation
+ // ### could be moved?
+ if (topState.type == substatement)
+ *indentDepth += m_indentSize;
+
+ // keep user-adjusted indent in multiline comments
+ if (topState.type == multiline_comment_start
+ || topState.type == multiline_comment_cont) {
+ if (!tokens.isEmpty()) {
+ *indentDepth = column(tokens.at(0).begin());
+ return;
+ }
+ }
+
+ const int kind = extendedTokenKind(tokenAt(0));
+ switch (kind) {
+ case LeftBrace:
+ if (topState.type == substatement
+ || topState.type == binding_assignment
+ || topState.type == case_cont) {
+ *indentDepth = topState.savedIndentDepth;
+ }
+ break;
+ case RightBrace: {
+ if (topState.type == jsblock_open && previousState.type == case_cont) {
+ *indentDepth = previousState.savedIndentDepth;
+ break;
+ }
+ for (int i = 0; state(i).type != topmost_intro; ++i) {
+ const int type = state(i).type;
+ if (type == objectdefinition_open
+ || type == jsblock_open
+ || type == substatement_open) {
+ *indentDepth = state(i).savedIndentDepth;
+ break;
+ }
+ }
+ break;
+ }
+ case RightBracket:
+ for (int i = 0; state(i).type != topmost_intro; ++i) {
+ const int type = state(i).type;
+ if (type == bracket_open) {
+ *indentDepth = state(i).savedIndentDepth;
+ break;
+ }
+ }
+ break;
+
+ case LeftBracket:
+ case LeftParenthesis:
+ case Delimiter:
+ if (topState.type == expression_maybe_continuation)
+ *indentDepth = topState.savedIndentDepth;
+ break;
+
+ case Else:
+ if (topState.type == maybe_else) {
+ *indentDepth = topState.savedIndentDepth;
+ } else if (topState.type == expression_maybe_continuation) {
+ bool hasElse = false;
+ for (int i = 1; state(i).type != topmost_intro; ++i) {
+ const int type = state(i).type;
+ if (type == else_clause)
+ hasElse = true;
+ if (type == if_statement) {
+ if (hasElse) {
+ hasElse = false;
+ } else {
+ *indentDepth = state(i).savedIndentDepth;
+ break;
+ }
+ }
+ }
+ }
+ break;
+
+ case Colon:
+ if (topState.type == ternary_op) {
+ *indentDepth -= 2;
+ }
+ break;
+
+ case Question:
+ if (topState.type == expression_maybe_continuation)
+ *indentDepth = topState.savedIndentDepth;
+ break;
+
+ case Default:
+ case Case:
+ for (int i = 0; state(i).type != topmost_intro; ++i) {
+ const int type = state(i).type;
+ if (type == switch_statement || type == case_cont) {
+ *indentDepth = state(i).savedIndentDepth;
+ break;
+ } else if (type == topmost_intro) {
+ break;
+ }
+ }
+ break;
+ }
+}
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#ifndef QMLJSQTSTYLECODEFORMATTER_H
+#define QMLJSQTSTYLECODEFORMATTER_H
+
+#include "qmljstools_global.h"
+
+#include <texteditor/basetextdocumentlayout.h>
+#include <qmljs/qmljscodeformatter.h>
+
+namespace TextEditor {
+ class TabSettings;
+}
+
+namespace QmlJSTools {
+
+class QMLJSTOOLS_EXPORT QtStyleCodeFormatter : public QmlJS::CodeFormatter
+{
+public:
+ QtStyleCodeFormatter();
+ explicit QtStyleCodeFormatter(const TextEditor::TabSettings &tabSettings);
+
+ void setIndentSize(int size);
+
+protected:
+ virtual void onEnter(int newState, int *indentDepth, int *savedIndentDepth) const;
+ virtual void adjustIndent(const QList<QmlJS::Token> &tokens, int lexerState, int *indentDepth) const;
+
+ virtual void saveBlockData(QTextBlock *block, const BlockData &data) const;
+ virtual bool loadBlockData(const QTextBlock &block, BlockData *data) const;
+
+ virtual void saveLexerState(QTextBlock *block, int state) const;
+ virtual int loadLexerState(const QTextBlock &block) const;
+
+private:
+ int m_indentSize;
+
+ class QmlJSCodeFormatterData: public TextEditor::CodeFormatterData
+ {
+ public:
+ QmlJS::CodeFormatter::BlockData m_data;
+ };
+};
+
+} // namespace QmlJSTools
+
+#endif // QMLJSQTSTYLECODEFORMATTER_H
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#include "qmljsrefactoringchanges.h"
+#include "qmljsqtstylecodeformatter.h"
+
+#include <qmljs/parser/qmljsast_p.h>
+#include <qmljs/qmljsmodelmanagerinterface.h>
+#include <texteditor/texteditorsettings.h>
+#include <texteditor/tabsettings.h>
+
+using namespace QmlJS;
+using namespace QmlJSTools;
+
+QmlJSRefactoringChanges::QmlJSRefactoringChanges(ModelManagerInterface *modelManager,
+ const Snapshot &snapshot)
+ : m_modelManager(modelManager)
+ , m_snapshot(snapshot)
+{
+ Q_ASSERT(modelManager);
+}
+
+const Snapshot &QmlJSRefactoringChanges::snapshot() const
+{
+ return m_snapshot;
+}
+
+QmlJSRefactoringFile QmlJSRefactoringChanges::file(const QString &fileName)
+{
+ return QmlJSRefactoringFile(fileName, this);
+}
+
+void QmlJSRefactoringChanges::indentSelection(const QTextCursor &selection) const
+{
+ // ### shares code with QmlJSTextEditor::indent
+ QTextDocument *doc = selection.document();
+
+ QTextBlock block = doc->findBlock(selection.selectionStart());
+ const QTextBlock end = doc->findBlock(selection.selectionEnd()).next();
+
+ const TextEditor::TabSettings &tabSettings(TextEditor::TextEditorSettings::instance()->tabSettings());
+ QtStyleCodeFormatter codeFormatter(tabSettings);
+ codeFormatter.updateStateUntil(block);
+
+ do {
+ tabSettings.indentLine(block, codeFormatter.indentFor(block));
+ codeFormatter.updateLineStateChange(block);
+ block = block.next();
+ } while (block.isValid() && block != end);
+}
+
+void QmlJSRefactoringChanges::fileChanged(const QString &fileName)
+{
+ m_modelManager->updateSourceFiles(QStringList(fileName), true);
+}
+
+
+QmlJSRefactoringFile::QmlJSRefactoringFile()
+{ }
+
+QmlJSRefactoringFile::QmlJSRefactoringFile(const QString &fileName, QmlJSRefactoringChanges *refactoringChanges)
+ : RefactoringFile(fileName, refactoringChanges)
+{ }
+
+QmlJSRefactoringFile::QmlJSRefactoringFile(TextEditor::BaseTextEditor *editor, QmlJS::Document::Ptr document)
+ : RefactoringFile()
+ , m_qmljsDocument(document)
+{
+ m_fileName = document->fileName();
+ m_editor = editor;
+}
+
+Document::Ptr QmlJSRefactoringFile::qmljsDocument() const
+{
+ if (!m_qmljsDocument) {
+ const QString source = document()->toPlainText();
+ const QString name = fileName();
+ const Snapshot &snapshot = refactoringChanges()->snapshot();
+
+ m_qmljsDocument = snapshot.documentFromSource(source, name);
+ m_qmljsDocument->parse();
+ }
+
+ return m_qmljsDocument;
+}
+
+unsigned QmlJSRefactoringFile::startOf(const AST::SourceLocation &loc) const
+{
+ return position(loc.startLine, loc.startColumn);
+}
+
+bool QmlJSRefactoringFile::isCursorOn(AST::UiObjectMember *ast) const
+{
+ const unsigned pos = cursor().position();
+
+ return ast->firstSourceLocation().begin() <= pos
+ && pos <= ast->lastSourceLocation().end();
+}
+
+bool QmlJSRefactoringFile::isCursorOn(AST::UiQualifiedId *ast) const
+{
+ const unsigned pos = cursor().position();
+
+ if (ast->identifierToken.begin() > pos)
+ return false;
+
+ AST::UiQualifiedId *last = ast;
+ while (last->next)
+ last = last->next;
+
+ return pos <= ast->identifierToken.end();
+}
+
+QmlJSRefactoringChanges *QmlJSRefactoringFile::refactoringChanges() const
+{
+ return static_cast<QmlJSRefactoringChanges *>(m_refactoringChanges);
+}
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#ifndef QMLREFACTORINGCHANGES_H
+#define QMLREFACTORINGCHANGES_H
+
+#include "qmljstools_global.h"
+
+#include <qmljs/qmljsdocument.h>
+
+#include <texteditor/refactoringchanges.h>
+
+namespace QmlJS {
+class ModelManagerInterface;
+} // namespace QmlJS
+
+namespace QmlJSTools {
+
+class QmlJSRefactoringChanges;
+
+class QMLJSTOOLS_EXPORT QmlJSRefactoringFile: public TextEditor::RefactoringFile
+{
+public:
+ QmlJSRefactoringFile();
+ QmlJSRefactoringFile(const QString &fileName, QmlJSRefactoringChanges *refactoringChanges);
+ QmlJSRefactoringFile(TextEditor::BaseTextEditor *editor, QmlJS::Document::Ptr document);
+
+ QmlJS::Document::Ptr qmljsDocument() const;
+
+ /*!
+ \returns the offset in the document for the start position of the given
+ source location.
+ */
+ unsigned startOf(const QmlJS::AST::SourceLocation &loc) const;
+
+ bool isCursorOn(QmlJS::AST::UiObjectMember *ast) const;
+ bool isCursorOn(QmlJS::AST::UiQualifiedId *ast) const;
+
+private:
+ QmlJSRefactoringChanges *refactoringChanges() const;
+
+ mutable QmlJS::Document::Ptr m_qmljsDocument;
+};
+
+
+class QMLJSTOOLS_EXPORT QmlJSRefactoringChanges: public TextEditor::RefactoringChanges
+{
+public:
+ QmlJSRefactoringChanges(QmlJS::ModelManagerInterface *modelManager,
+ const QmlJS::Snapshot &snapshot);
+
+ const QmlJS::Snapshot &snapshot() const;
+
+ QmlJSRefactoringFile file(const QString &fileName);
+
+private:
+ virtual void indentSelection(const QTextCursor &selection) const;
+ virtual void fileChanged(const QString &fileName);
+
+private:
+ QmlJS::ModelManagerInterface *m_modelManager;
+ QmlJS::Snapshot m_snapshot;
+};
+
+} // namespace QmlJSTools
+
+#endif // QMLREFACTORINGCHANGES_H
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#ifndef QMLPROJECTRUNCONFIGURATIONWIDGET_H
+#define QMLPROJECTRUNCONFIGURATIONWIDGET_H
+
+#include <QWidget>
+
+QT_FORWARD_DECLARE_CLASS(QComboBox)
+QT_FORWARD_DECLARE_CLASS(QStandardItemModel)
+
+namespace ProjectExplorer {
+
+class EnvironmentWidget;
+
+} // namespace Qt4ProjectManager
+
+namespace QmlProjectManager {
+
+class QmlProjectRunConfiguration;
+
+namespace Internal {
+
+const char * const CURRENT_FILE = QT_TRANSLATE_NOOP("QmlManager", "<Current File>");
+
+class QmlProjectRunConfigurationWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit QmlProjectRunConfigurationWidget(QmlProjectRunConfiguration *rc);
+
+public slots:
+ void updateQtVersionComboBox();
+ void userEnvironmentChangesChanged();
+ void updateFileComboBox();
+
+private slots:
+
+ void setMainScript(int index);
+ void onQtVersionSelectionChanged();
+ void onViewerArgsChanged();
+ void useCppDebuggerToggled(bool toggled);
+ void useQmlDebuggerToggled(bool toggled);
+ void qmlDebugServerPortChanged(uint port);
+
+ void userChangesChanged();
+
+ void manageQtVersions();
+
+private:
+ QmlProjectRunConfiguration *m_runConfiguration;
+
+ QComboBox *m_qtVersionComboBox;
+ QComboBox *m_fileListCombo;
+ QStandardItemModel *m_fileListModel;
+
+ ProjectExplorer::EnvironmentWidget *m_environmentWidget;
+};
+
+} // namespace Internal
+} // namespace QmlProjectManager
+
+#endif // QMLPROJECTRUNCONFIGURATIONWIDGET_H
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+#ifndef MAEMOPUBLISHINGRESULTPAGEFREMANTLEFREE_H
+#define MAEMOPUBLISHINGRESULTPAGEFREMANTLEFREE_H
+
+#include "maemopublisherfremantlefree.h"
+#include <QtGui/QWizardPage>
+
+QT_BEGIN_NAMESPACE
+namespace Ui {
+ class MaemoPublishingResultPageFremantleFree;
+}
+QT_END_NAMESPACE
+
+namespace Qt4ProjectManager {
+namespace Internal {
+
+class MaemoPublishingResultPageFremantleFree : public QWizardPage
+{
+ Q_OBJECT
+
+public:
+ explicit MaemoPublishingResultPageFremantleFree(MaemoPublisherFremantleFree *publisher,
+ QWidget *parent = 0);
+ ~MaemoPublishingResultPageFremantleFree();
+
+private slots:
+ void handleFinished();
+ void handleProgress(const QString &text,
+ MaemoPublisherFremantleFree::OutputType type);
+ void handleCancelRequest();
+
+private:
+ virtual bool isComplete() const { return m_isComplete; }
+ virtual void initializePage();
+
+ QAbstractButton *cancelButton() const;
+
+ MaemoPublisherFremantleFree * const m_publisher;
+ bool m_isComplete;
+ MaemoPublisherFremantleFree::OutputType m_lastOutputType;
+ Ui::MaemoPublishingResultPageFremantleFree *ui;
+};
+
+} // namespace Internal
+} // namespace Qt4ProjectManager
+
+#endif // MAEMOPUBLISHINGRESULTPAGEFREMANTLEFREE_H
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#ifndef SUBDIRSPROJECTWIZARD_H
+#define SUBDIRSPROJECTWIZARD_H
+
+#include "qtwizard.h"
+
+namespace Qt4ProjectManager {
+namespace Internal {
+
+class SubdirsProjectWizard : public QtWizard
+{
+ Q_OBJECT
+
+public:
+ SubdirsProjectWizard();
+
+protected:
+ virtual QWizard *createWizardDialog(QWidget *parent,
+ const QString &defaultPath,
+ const WizardPageList &extensionPages) const;
+
+ virtual Core::GeneratedFiles generateFiles(const QWizard *w,
+ QString *errorMessage) const;
+ virtual bool postGenerateFiles(const QWizard *, const Core::GeneratedFiles &l, QString *errorMessage);
+};
+
+} // namespace Internal
+} // namespace Qt4ProjectManager
+
+#endif // SUBDIRSPROJECTWIZARD_H
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#include "subdirsprojectwizarddialog.h"
+#include "qtprojectparameters.h"
+
+namespace Qt4ProjectManager {
+namespace Internal {
+
+SubdirsProjectWizardDialog::SubdirsProjectWizardDialog(const QString &templateName,
+ const QIcon &icon,
+ const QList<QWizardPage*> &extensionPages,
+ QWidget *parent) :
+ BaseQt4ProjectWizardDialog(parent)
+{
+ setWindowIcon(icon);
+ setWindowTitle(templateName);
+
+ setIntroDescription(tr("This wizard generates Qt4 subdirs project. "
+ "Add subprojects to it later on by using the other wizards."));
+
+ addTargetSetupPage();
+
+ foreach (QWizardPage *p, extensionPages)
+ Core::BaseFileWizard::applyExtensionPageShortTitle(this, addPage(p));
+}
+
+QtProjectParameters SubdirsProjectWizardDialog::parameters() const
+{
+ QtProjectParameters rc;
+ rc.type = QtProjectParameters::EmptyProject;
+ rc.fileName = projectName();
+ rc.path = path();
+ return rc;
+}
+
+} // namespace Internal
+} // namespace Qt4ProjectManager
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#ifndef PLAINTEXTSNIPPETPROVIDER_H
+#define PLAINTEXTSNIPPETPROVIDER_H
+
+#include "isnippetprovider.h"
+
+namespace TextEditor {
+namespace Internal {
+
+class PlainTextSnippetProvider : public ISnippetProvider
+{
+public:
+ PlainTextSnippetProvider();
+ virtual ~PlainTextSnippetProvider();
+
+public:
+ virtual QString groupId() const;
+ virtual QString displayName() const;
+ virtual void decorateEditor(TextEditor::SnippetEditor *editor) const;
+};
+
+} // Internal
+} // TextEditor
+
+#endif // PLAINTEXTSNIPPETPROVIDER_H
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#include "snippetssettings.h"
+#include "reuse.h"
+
+#include <QtCore/QSettings>
+
+namespace {
+
+static const QLatin1String kGroupPostfix("SnippetsSettings");
+static const QLatin1String kLastUsedSnippetGroup("LastUsedSnippetGroup");
+
+} // Anonymous
+
+using namespace TextEditor;
+using namespace Internal;
+
+SnippetsSettings::SnippetsSettings()
+{}
+
+void SnippetsSettings::toSettings(const QString &category, QSettings *s) const
+{
+ const QString &group = category + kGroupPostfix;
+ s->beginGroup(group);
+ s->setValue(kLastUsedSnippetGroup, m_lastUsedSnippetGroup);
+ s->endGroup();
+}
+
+void SnippetsSettings::fromSettings(const QString &category, QSettings *s)
+{
+ const QString &group = category + kGroupPostfix;
+ s->beginGroup(group);
+ m_lastUsedSnippetGroup = s->value(kLastUsedSnippetGroup, QString()).toString();
+ s->endGroup();
+}
+
+void SnippetsSettings::setLastUsedSnippetGroup(const QString &lastUsed)
+{
+ m_lastUsedSnippetGroup = lastUsed;
+}
+
+const QString &SnippetsSettings::lastUsedSnippetGroup() const
+{
+ return m_lastUsedSnippetGroup;
+}
+
+bool SnippetsSettings::equals(const SnippetsSettings &snippetsSettings) const
+{
+ return m_lastUsedSnippetGroup == snippetsSettings.m_lastUsedSnippetGroup;
+}
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#ifndef SNIPPETSSETTINGS_H
+#define SNIPPETSSETTINGS_H
+
+#include <QtCore/QString>
+
+QT_BEGIN_NAMESPACE
+class QSettings;
+QT_END_NAMESPACE
+
+namespace TextEditor {
+
+class SnippetsSettings
+{
+public:
+ SnippetsSettings();
+
+ void toSettings(const QString &category, QSettings *s) const;
+ void fromSettings(const QString &category, QSettings *s);
+
+ void setLastUsedSnippetGroup(const QString &lastUsed);
+ const QString &lastUsedSnippetGroup() const;
+
+ bool equals(const SnippetsSettings &snippetsSettings) const;
+
+private:
+ QString m_lastUsedSnippetGroup;
+};
+
+inline bool operator==(const SnippetsSettings &a, const SnippetsSettings &b)
+{ return a.equals(b); }
+
+inline bool operator!=(const SnippetsSettings &a, const SnippetsSettings &b)
+{ return !a.equals(b); }
+
+} // TextEditor
+
+#endif // SNIPPETSSETTINGS_H
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#ifndef SNIPPETSSETTINGSPAGE_H
+#define SNIPPETSSETTINGSPAGE_H
+
+#include "texteditoroptionspage.h"
+
+namespace TextEditor {
+namespace Internal {
+
+class SnippetsSettingsPagePrivate;
+
+class SnippetsSettingsPage : public TextEditorOptionsPage
+{
+ Q_OBJECT
+public:
+ SnippetsSettingsPage(const QString &id, QObject *parent);
+ virtual ~SnippetsSettingsPage();
+
+ virtual QString id() const;
+ virtual QString displayName() const;
+ virtual bool matches(const QString &s) const;
+ virtual QWidget *createPage(QWidget *parent);
+ virtual void apply();
+ virtual void finish();
+
+private:
+ SnippetsSettingsPagePrivate *m_d;
+};
+
+} // Internal
+} // TextEditor
+
+#endif // SNIPPETSSETTINGSPAGE_H
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#include "plugin1.h"
+
+#include <QtCore/qplugin.h>
+#include <QStringList>
+
+using namespace Plugin1;
+
+MyPlugin1::MyPlugin1()
+{
+}
+
+bool MyPlugin1::initialize(const QStringList &arguments, QString *errorString)
+{
+ Q_UNUSED(arguments)
+ Q_UNUSED(errorString)
+ return true;
+}
+
+void MyPlugin1::extensionsInitialized()
+{
+}
+
+Q_EXPORT_PLUGIN(MyPlugin1)
+
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#include <extensionsystem/pluginmanager.h>
+#include <extensionsystem/pluginspec.h>
+#include <extensionsystem/iplugin.h>
+
+#include <QtTest/QtTest>
+
+#include <QtCore/QObject>
+
+using namespace ExtensionSystem;
+
+class SignalReceiver;
+
+class tst_PluginManager : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void init();
+ void cleanup();
+ void addRemoveObjects();
+ void getObject();
+ void getObjects();
+ void plugins();
+ void circularPlugins();
+ void correctPlugins1();
+
+private:
+ PluginManager *m_pm;
+ QSignalSpy *m_objectAdded;
+ QSignalSpy *m_aboutToRemoveObject;
+ QSignalSpy *m_pluginsChanged;
+};
+
+class MyClass1 : public QObject
+{
+ Q_OBJECT
+};
+
+class MyClass2 : public QObject
+{
+ Q_OBJECT
+};
+
+class MyClass11 : public MyClass1
+{
+ Q_OBJECT
+};
+
+void tst_PluginManager::init()
+{
+ m_pm = new PluginManager;
+ m_objectAdded = new QSignalSpy(m_pm, SIGNAL(objectAdded(QObject*)));
+ m_aboutToRemoveObject = new QSignalSpy(m_pm, SIGNAL(aboutToRemoveObject(QObject*)));
+ m_pluginsChanged = new QSignalSpy(m_pm, SIGNAL(pluginsChanged()));
+}
+
+void tst_PluginManager::cleanup()
+{
+ delete m_pm;
+ delete m_objectAdded;
+ delete m_aboutToRemoveObject;
+ delete m_pluginsChanged;
+}
+
+void tst_PluginManager::addRemoveObjects()
+{
+ QObject *object1 = new QObject;
+ QObject *object2 = new QObject;
+ QCOMPARE(m_pm->allObjects().size(), 0);
+ m_pm->addObject(object1);
+ QCOMPARE(m_objectAdded->count(), 1);
+ QCOMPARE(m_objectAdded->at(0).first().value<QObject *>(), object1);
+ QCOMPARE(m_aboutToRemoveObject->count(), 0);
+ QVERIFY(m_pm->allObjects().contains(object1));
+ QVERIFY(!m_pm->allObjects().contains(object2));
+ QCOMPARE(m_pm->allObjects().size(), 1);
+ m_pm->addObject(object2);
+ QCOMPARE(m_objectAdded->count(), 2);
+ QCOMPARE(m_objectAdded->at(1).first().value<QObject *>(), object2);
+ QCOMPARE(m_aboutToRemoveObject->count(), 0);
+ QVERIFY(m_pm->allObjects().contains(object1));
+ QVERIFY(m_pm->allObjects().contains(object2));
+ QCOMPARE(m_pm->allObjects().size(), 2);
+ m_pm->removeObject(object1);
+ QCOMPARE(m_objectAdded->count(), 2);
+ QCOMPARE(m_aboutToRemoveObject->count(), 1);
+ QCOMPARE(m_aboutToRemoveObject->at(0).first().value<QObject *>(), object1);
+ QVERIFY(!m_pm->allObjects().contains(object1));
+ QVERIFY(m_pm->allObjects().contains(object2));
+ QCOMPARE(m_pm->allObjects().size(), 1);
+ m_pm->removeObject(object2);
+ QCOMPARE(m_objectAdded->count(), 2);
+ QCOMPARE(m_aboutToRemoveObject->count(), 2);
+ QCOMPARE(m_aboutToRemoveObject->at(1).first().value<QObject *>(), object2);
+ QVERIFY(!m_pm->allObjects().contains(object1));
+ QVERIFY(!m_pm->allObjects().contains(object2));
+ QCOMPARE(m_pm->allObjects().size(), 0);
+ delete object1;
+ delete object2;
+}
+
+void tst_PluginManager::getObject()
+{
+ MyClass2 *object2 = new MyClass2;
+ MyClass11 *object11 = new MyClass11;
+ m_pm->addObject(object2);
+ QCOMPARE(m_pm->getObject<MyClass11>(), (MyClass11*)0);
+ QCOMPARE(m_pm->getObject<MyClass1>(), (MyClass1*)0);
+ QCOMPARE(m_pm->getObject<MyClass2>(), object2);
+ m_pm->addObject(object11);
+ QCOMPARE(m_pm->getObject<MyClass11>(), object11);
+ QCOMPARE(m_pm->getObject<MyClass1>(), qobject_cast<MyClass1*>(object11));
+ QCOMPARE(m_pm->getObject<MyClass2>(), object2);
+ m_pm->removeObject(object2);
+ m_pm->removeObject(object11);
+ delete object2;
+ delete object11;
+}
+
+void tst_PluginManager::getObjects()
+{
+ MyClass1 *object1 = new MyClass1;
+ MyClass2 *object2 = new MyClass2;
+ MyClass11 *object11 = new MyClass11;
+ m_pm->addObject(object2);
+ QCOMPARE(m_pm->getObjects<MyClass11>(), QList<MyClass11*>());
+ QCOMPARE(m_pm->getObjects<MyClass1>(), QList<MyClass1*>());
+ QCOMPARE(m_pm->getObjects<MyClass2>(), QList<MyClass2*>() << object2);
+ QCOMPARE(m_pm->allObjects(), QList<QObject*>() << object2);
+ m_pm->addObject(object11);
+ QCOMPARE(m_pm->getObjects<MyClass11>(), QList<MyClass11*>() << object11);
+ QCOMPARE(m_pm->getObjects<MyClass1>(), QList<MyClass1*>() << object11);
+ QCOMPARE(m_pm->getObjects<MyClass2>(), QList<MyClass2*>() << object2);
+ QCOMPARE(m_pm->allObjects(), QList<QObject*>() << object2 << object11);
+ m_pm->addObject(object1);
+ QCOMPARE(m_pm->getObjects<MyClass11>(), QList<MyClass11*>() << object11);
+ QCOMPARE(m_pm->getObjects<MyClass1>(), QList<MyClass1*>() << object11 << object1);
+ QCOMPARE(m_pm->getObjects<MyClass2>(), QList<MyClass2*>() << object2);
+ QCOMPARE(m_pm->allObjects(), QList<QObject*>() << object2 << object11 << object1);
+ m_pm->removeObject(object2);
+ m_pm->removeObject(object11);
+ m_pm->removeObject(object1);
+ delete object1;
+ delete object2;
+ delete object11;
+}
+
+void tst_PluginManager::plugins()
+{
+ m_pm->setPluginPaths(QStringList() << "plugins");
+ QCOMPARE(m_pluginsChanged->count(), 1);
+ QList<PluginSpec *> plugins = m_pm->plugins();
+ QCOMPARE(plugins.count(), 3);
+ foreach (const QString &expected, QStringList() << "helloworld" << "MyPlugin" << "dummyPlugin") {
+ bool found = false;
+ foreach (PluginSpec *spec, plugins) {
+ if (spec->name() == expected) {
+ found = true;
+ break;
+ }
+ }
+ QVERIFY2(found, QString("plugin '%1' not found").arg(expected).toLocal8Bit().constData());
+ }
+}
+
+void tst_PluginManager::circularPlugins()
+{
+ m_pm->setPluginPaths(QStringList() << "circularplugins");
+ m_pm->loadPlugins();
+ foreach (PluginSpec *spec, m_pm->plugins()) {
+ if (spec->name() == "plugin1") {
+ QVERIFY(spec->hasError());
+ QCOMPARE(spec->state(), PluginSpec::Resolved);
+ QCOMPARE(spec->plugin(), (IPlugin*)0);
+ } else if (spec->name() == "plugin2") {
+ QVERIFY(!spec->hasError());
+ QCOMPARE(spec->state(), PluginSpec::Running);
+ } else if (spec->name() == "plugin3") {
+ QVERIFY(spec->hasError());
+ QCOMPARE(spec->state(), PluginSpec::Resolved);
+ QCOMPARE(spec->plugin(), (IPlugin*)0);
+ }
+ }
+}
+
+void tst_PluginManager::correctPlugins1()
+{
+ m_pm->setFileExtension("spec");
+ m_pm->setPluginPaths(QStringList() << "correctplugins1");
+ m_pm->loadPlugins();
+ foreach (PluginSpec *spec, m_pm->plugins()) {
+ if (spec->hasError())
+ qDebug() << spec->errorString();
+ QVERIFY(!spec->hasError());
+ QCOMPARE(spec->state(), PluginSpec::Running);
+ }
+ bool plugin1running = false;
+ bool plugin2running = false;
+ bool plugin3running = false;
+ foreach (QObject *obj, m_pm->allObjects()) {
+ if (obj->objectName() == "MyPlugin1_running")
+ plugin1running = true;
+ else if (obj->objectName() == "MyPlugin2_running")
+ plugin2running = true;
+ else if (obj->objectName() == "MyPlugin3_running")
+ plugin3running = true;
+ }
+ QVERIFY(plugin1running);
+ QVERIFY(plugin2running);
+ QVERIFY(plugin3running);
+}
+
+QTEST_MAIN(tst_PluginManager)
+
+#include "tst_pluginmanager.moc"
+
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#ifndef TESTPLUGIN_H
+#define TESTPLUGIN_H
+
+#include "testplugin_global.h"
+#include <extensionsystem/iplugin.h>
+
+#include <QtCore/QObject>
+
+namespace MyPlugin {
+
+class MYPLUGIN_EXPORT MyPluginImpl : public ExtensionSystem::IPlugin
+{
+ Q_OBJECT
+
+public:
+ MyPluginImpl();
+
+ bool initialize(const QStringList &arguments, QString *errorString);
+ void extensionsInitialized();
+
+public slots:
+ bool isInitialized() { return m_isInitialized; }
+ bool isExtensionsInitialized() { return m_isExtensionsInitialized; }
+
+private:
+ bool m_isInitialized;
+ bool m_isExtensionsInitialized;
+};
+
+} // namespace
+
+#endif // TESTPLUGIN_H
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#include <extensionsystem/pluginspec.h>
+#include <extensionsystem/pluginspec_p.h>
+#include <extensionsystem/pluginmanager_p.h>
+#include <extensionsystem/pluginmanager.h>
+
+#include <QtCore/QObject>
+#include <QtCore/QMetaObject>
+#include <QtTest/QtTest>
+
+using namespace ExtensionSystem;
+
+class tst_PluginSpec : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void read();
+ void readError();
+ void isValidVersion();
+ void versionCompare();
+ void provides();
+ void experimental();
+ void locationAndPath();
+ void resolveDependencies();
+ void loadLibrary();
+ void initializePlugin();
+ void initializeExtensions();
+};
+
+void tst_PluginSpec::read()
+{
+ Internal::PluginSpecPrivate spec(0);
+ QCOMPARE(spec.state, PluginSpec::Invalid);
+ QVERIFY(spec.read("testspecs/spec1.xml"));
+ QCOMPARE(spec.state, PluginSpec::Read);
+ QVERIFY(!spec.hasError);
+ QVERIFY(spec.errorString.isEmpty());
+ QCOMPARE(spec.name, QString("test"));
+ QCOMPARE(spec.version, QString("1.0.1"));
+ QCOMPARE(spec.compatVersion, QString("1.0.0"));
+ QCOMPARE(spec.experimental, false);
+ QCOMPARE(spec.enabled, true);
+ QCOMPARE(spec.vendor, QString("Nokia Corporation"));
+ QCOMPARE(spec.copyright, QString("(C) 2007 Nokia Corporation"));
+ QCOMPARE(spec.license, QString("This is a default license bla\nblubbblubb\nend of terms"));
+ QCOMPARE(spec.description, QString("This plugin is just a test.\n it demonstrates the great use of the plugin spec."));
+ QCOMPARE(spec.url, QString("http://qt.noki.com"));
+ PluginDependency dep1;
+ dep1.name = QString("SomeOtherPlugin");
+ dep1.version = QString("2.3.0_2");
+ PluginDependency dep2;
+ dep2.name = QString("EvenOther");
+ dep2.version = QString("1.0.0");
+ QCOMPARE(spec.dependencies, QList<PluginDependency>() << dep1 << dep2);
+
+ // test missing compatVersion behavior
+ QVERIFY(spec.read("testspecs/spec2.xml"));
+ QCOMPARE(spec.version, QString("3.1.4_10"));
+ QCOMPARE(spec.compatVersion, QString("3.1.4_10"));
+}
+
+void tst_PluginSpec::readError()
+{
+ Internal::PluginSpecPrivate spec(0);
+ QCOMPARE(spec.state, PluginSpec::Invalid);
+ QVERIFY(!spec.read("non-existing-file.xml"));
+ QCOMPARE(spec.state, PluginSpec::Invalid);
+ QVERIFY(spec.hasError);
+ QVERIFY(!spec.errorString.isEmpty());
+ QVERIFY(!spec.read("testspecs/spec_wrong1.xml"));
+ QCOMPARE(spec.state, PluginSpec::Invalid);
+ QVERIFY(spec.hasError);
+ QVERIFY(!spec.errorString.isEmpty());
+ QVERIFY(!spec.read("testspecs/spec_wrong2.xml"));
+ QCOMPARE(spec.state, PluginSpec::Invalid);
+ QVERIFY(spec.hasError);
+ QVERIFY(!spec.errorString.isEmpty());
+ QVERIFY(!spec.read("testspecs/spec_wrong3.xml"));
+ QCOMPARE(spec.state, PluginSpec::Invalid);
+ QVERIFY(spec.hasError);
+ QVERIFY(!spec.errorString.isEmpty());
+ QVERIFY(!spec.read("testspecs/spec_wrong4.xml"));
+ QCOMPARE(spec.state, PluginSpec::Invalid);
+ QVERIFY(spec.hasError);
+ QVERIFY(!spec.errorString.isEmpty());
+ QVERIFY(!spec.read("testspecs/spec_wrong5.xml"));
+ QCOMPARE(spec.state, PluginSpec::Invalid);
+ QVERIFY(spec.hasError);
+ QVERIFY(!spec.errorString.isEmpty());
+}
+
+void tst_PluginSpec::isValidVersion()
+{
+ QVERIFY(Internal::PluginSpecPrivate::isValidVersion("2"));
+ QVERIFY(Internal::PluginSpecPrivate::isValidVersion("53"));
+ QVERIFY(Internal::PluginSpecPrivate::isValidVersion("52_1"));
+ QVERIFY(Internal::PluginSpecPrivate::isValidVersion("3.12"));
+ QVERIFY(Internal::PluginSpecPrivate::isValidVersion("31.1_12"));
+ QVERIFY(Internal::PluginSpecPrivate::isValidVersion("31.1.0"));
+ QVERIFY(Internal::PluginSpecPrivate::isValidVersion("1.0.2_1"));
+
+ QVERIFY(!Internal::PluginSpecPrivate::isValidVersion(""));
+ QVERIFY(!Internal::PluginSpecPrivate::isValidVersion("1..0"));
+ QVERIFY(!Internal::PluginSpecPrivate::isValidVersion("1.0_"));
+ QVERIFY(!Internal::PluginSpecPrivate::isValidVersion("1.0.0.0"));
+}
+
+void tst_PluginSpec::versionCompare()
+{
+ QVERIFY(Internal::PluginSpecPrivate::versionCompare("3", "3") == 0);
+ QVERIFY(Internal::PluginSpecPrivate::versionCompare("3.0.0", "3") == 0);
+ QVERIFY(Internal::PluginSpecPrivate::versionCompare("3.0", "3") == 0);
+ QVERIFY(Internal::PluginSpecPrivate::versionCompare("3.0.0_1", "3_1") == 0);
+ QVERIFY(Internal::PluginSpecPrivate::versionCompare("3.0_21", "3_21") == 0);
+
+ QVERIFY(Internal::PluginSpecPrivate::versionCompare("3", "1") > 0);
+ QVERIFY(Internal::PluginSpecPrivate::versionCompare("3", "1.0_12") > 0);
+ QVERIFY(Internal::PluginSpecPrivate::versionCompare("3_1", "3") > 0);
+ QVERIFY(Internal::PluginSpecPrivate::versionCompare("3.1.0_23", "3.1") > 0);
+ QVERIFY(Internal::PluginSpecPrivate::versionCompare("3.1_23", "3.1_12") > 0);
+
+ QVERIFY(Internal::PluginSpecPrivate::versionCompare("1", "3") < 0);
+ QVERIFY(Internal::PluginSpecPrivate::versionCompare("1.0_12", "3") < 0);
+ QVERIFY(Internal::PluginSpecPrivate::versionCompare("3", "3_1") < 0);
+ QVERIFY(Internal::PluginSpecPrivate::versionCompare("3.1", "3.1.0_23") < 0);
+ QVERIFY(Internal::PluginSpecPrivate::versionCompare("3.1_12", "3.1_23") < 0);
+}
+
+void tst_PluginSpec::provides()
+{
+ Internal::PluginSpecPrivate spec(0);
+ QVERIFY(spec.read("testspecs/simplespec.xml"));
+ QVERIFY(!spec.provides("SomeOtherPlugin", "2.2.3_9"));
+ QVERIFY(!spec.provides("MyPlugin", "2.2.3_10"));
+ QVERIFY(!spec.provides("MyPlugin", "2.2.4"));
+ QVERIFY(!spec.provides("MyPlugin", "2.3.11_1"));
+ QVERIFY(!spec.provides("MyPlugin", "2.3"));
+ QVERIFY(!spec.provides("MyPlugin", "3.0"));
+ QVERIFY(!spec.provides("MyPlugin", "1.9.9_99"));
+ QVERIFY(!spec.provides("MyPlugin", "1.9"));
+ QVERIFY(!spec.provides("MyPlugin", "0.9"));
+ QVERIFY(!spec.provides("MyPlugin", "1"));
+
+ QVERIFY(spec.provides("myplugin", "2.2.3_9"));
+ QVERIFY(spec.provides("MyPlugin", "2.2.3_9"));
+ QVERIFY(spec.provides("MyPlugin", "2.2.3_8"));
+ QVERIFY(spec.provides("MyPlugin", "2.2.3"));
+ QVERIFY(spec.provides("MyPlugin", "2.2.2"));
+ QVERIFY(spec.provides("MyPlugin", "2.1.2_10"));
+ QVERIFY(spec.provides("MyPlugin", "2.0_10"));
+ QVERIFY(spec.provides("MyPlugin", "2"));
+}
+
+void tst_PluginSpec::experimental()
+{
+ Internal::PluginSpecPrivate spec(0);
+ QVERIFY(spec.read("testspecs/simplespec_experimental.xml"));
+ QCOMPARE(spec.experimental, true);
+ QCOMPARE(spec.enabled, false);
+}
+
+void tst_PluginSpec::locationAndPath()
+{
+ Internal::PluginSpecPrivate spec(0);
+ QVERIFY(spec.read("testspecs/simplespec.xml"));
+ QCOMPARE(spec.location, QString(QDir::currentPath()+"/testspecs"));
+ QCOMPARE(spec.filePath, QString(QDir::currentPath()+"/testspecs/simplespec.xml"));
+ QVERIFY(spec.read("testdir/../testspecs/simplespec.xml"));
+ QCOMPARE(spec.location, QString(QDir::currentPath()+"/testspecs"));
+ QCOMPARE(spec.filePath, QString(QDir::currentPath()+"/testspecs/simplespec.xml"));
+ QVERIFY(spec.read("testdir/spec.xml"));
+ QCOMPARE(spec.location, QString(QDir::currentPath()+"/testdir"));
+ QCOMPARE(spec.filePath, QString(QDir::currentPath()+"/testdir/spec.xml"));
+}
+
+void tst_PluginSpec::resolveDependencies()
+{
+ QList<PluginSpec *> specs;
+ PluginSpec *spec1 = Internal::PluginManagerPrivate::createSpec();
+ specs.append(spec1);
+ Internal::PluginSpecPrivate *spec1Priv = Internal::PluginManagerPrivate::privateSpec(spec1);
+ spec1Priv->read("testdependencies/spec1.xml");
+ PluginSpec *spec2 = Internal::PluginManagerPrivate::createSpec();
+ specs.append(spec2);
+ Internal::PluginManagerPrivate::privateSpec(spec2)->read("testdependencies/spec2.xml");
+ PluginSpec *spec3 = Internal::PluginManagerPrivate::createSpec();
+ specs.append(spec3);
+ Internal::PluginManagerPrivate::privateSpec(spec3)->read("testdependencies/spec3.xml");
+ PluginSpec *spec4 = Internal::PluginManagerPrivate::createSpec();
+ specs.append(spec4);
+ Internal::PluginSpecPrivate *spec4Priv = Internal::PluginManagerPrivate::privateSpec(spec4);
+ spec4Priv->read("testdependencies/spec4.xml");
+ PluginSpec *spec5 = Internal::PluginManagerPrivate::createSpec();
+ specs.append(spec5);
+ Internal::PluginManagerPrivate::privateSpec(spec5)->read("testdependencies/spec5.xml");
+ QVERIFY(spec1Priv->resolveDependencies(specs));
+ QCOMPARE(spec1Priv->dependencySpecs.size(), 2);
+ QVERIFY(spec1Priv->dependencySpecs.contains(spec2));
+ QVERIFY(spec1Priv->dependencySpecs.contains(spec3));
+ QCOMPARE(spec1Priv->state, PluginSpec::Resolved);
+ QVERIFY(!spec4Priv->resolveDependencies(specs));
+ QVERIFY(spec4Priv->hasError);
+ QCOMPARE(spec4Priv->state, PluginSpec::Read);
+}
+
+void tst_PluginSpec::loadLibrary()
+{
+ PluginSpec *ps = Internal::PluginManagerPrivate::createSpec();
+ Internal::PluginSpecPrivate *spec = Internal::PluginManagerPrivate::privateSpec(ps);
+ PluginManager *manager = new PluginManager();
+ QVERIFY(spec->read("testplugin/testplugin.xml"));
+ QVERIFY(spec->resolveDependencies(QList<PluginSpec *>()));
+ QVERIFY(spec->loadLibrary());
+ QVERIFY(spec->plugin != 0);
+ QVERIFY(QString::fromLocal8Bit(spec->plugin->metaObject()->className()) == QString::fromLocal8Bit("MyPlugin::MyPluginImpl"));
+ QCOMPARE(spec->state, PluginSpec::Loaded);
+ QVERIFY(!spec->hasError);
+ QCOMPARE(spec->plugin->pluginSpec(), ps);
+ delete manager;
+ delete ps;
+}
+
+void tst_PluginSpec::initializePlugin()
+{
+ Internal::PluginSpecPrivate spec(0);
+ QVERIFY(spec.read("testplugin/testplugin.xml"));
+ QVERIFY(spec.resolveDependencies(QList<PluginSpec *>()));
+ QVERIFY(spec.loadLibrary());
+ bool isInitialized;
+ QMetaObject::invokeMethod(spec.plugin, "isInitialized",
+ Qt::DirectConnection, Q_RETURN_ARG(bool, isInitialized));
+ QVERIFY(!isInitialized);
+ QVERIFY(spec.initializePlugin());
+ QCOMPARE(spec.state, PluginSpec::Initialized);
+ QVERIFY(!spec.hasError);
+ QMetaObject::invokeMethod(spec.plugin, "isInitialized",
+ Qt::DirectConnection, Q_RETURN_ARG(bool, isInitialized));
+ QVERIFY(isInitialized);
+}
+
+void tst_PluginSpec::initializeExtensions()
+{
+ Internal::PluginSpecPrivate spec(0);
+ QVERIFY(spec.read("testplugin/testplugin.xml"));
+ QVERIFY(spec.resolveDependencies(QList<PluginSpec *>()));
+ QVERIFY(spec.loadLibrary());
+ bool isExtensionsInitialized;
+ QVERIFY(spec.initializePlugin());
+ QMetaObject::invokeMethod(spec.plugin, "isExtensionsInitialized",
+ Qt::DirectConnection, Q_RETURN_ARG(bool, isExtensionsInitialized));
+ QVERIFY(!isExtensionsInitialized);
+ QVERIFY(spec.initializeExtensions());
+ QCOMPARE(spec.state, PluginSpec::Running);
+ QVERIFY(!spec.hasError);
+ QMetaObject::invokeMethod(spec.plugin, "isExtensionsInitialized",
+ Qt::DirectConnection, Q_RETURN_ARG(bool, isExtensionsInitialized));
+ QVERIFY(isExtensionsInitialized);
+}
+
+QTEST_MAIN(tst_PluginSpec)
+
+#include "tst_pluginspec.moc"
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#include "../../../src/shared/proparser/ioutils.cpp"
+
+#include <QtTest/QtTest>
+
+class tst_IoUtils : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void quoteArg_data();
+ void quoteArg();
+};
+
+void tst_IoUtils::quoteArg_data()
+{
+ QTest::addColumn<QString>("in");
+ QTest::addColumn<QString>("out");
+
+ static const struct {
+ const char * const in;
+ const char * const out;
+ } vals[] = {
+#ifdef Q_OS_WIN
+ { "", "\"\"" },
+ { "hallo", "hallo" },
+ { "hallo du", "\"hallo du\"" },
+ { "hallo\\", "hallo\\" },
+ { "hallo du\\", "\"hallo du\"\\" },
+ { "ha\"llo", "\"ha\"\\^\"\"llo\"" },
+ { "ha\\\"llo", "\"ha\"\\\\\\^\"\"llo\"" },
+#else
+ { "", "\"\"" },
+ { "hallo", "hallo" },
+ { "hallo du", "'hallo du'" },
+ { "ha'llo", "'ha'\\''llo'" },
+#endif
+ };
+
+ for (unsigned i = 0; i < sizeof(vals)/sizeof(vals[0]); i++)
+ QTest::newRow(vals[i].in) << QString::fromLatin1(vals[i].in)
+ << QString::fromLatin1(vals[i].out);
+}
+
+void tst_IoUtils::quoteArg()
+{
+ QFETCH(QString, in);
+ QFETCH(QString, out);
+
+ QCOMPARE(IoUtils::shellQuote(in), out);
+}
+
+QTEST_MAIN(tst_IoUtils)
+
+#include "tst_ioutils.moc"
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#include "codaclientapplication.h"
+
+#include <cstdio>
+
+int main(int argc, char *argv[])
+{
+ CodaClientApplication app(argc, argv);
+
+ QString errorMessage;
+ const CodaClientApplication::ParseArgsResult ar = app.parseArguments(&errorMessage);
+ if (!errorMessage.isEmpty())
+ std::fprintf(stderr, "\nError: %s\n\n", qPrintable(errorMessage));
+ switch (ar) {
+ case CodaClientApplication::ParseArgsError:
+ std::printf("%s", qPrintable(CodaClientApplication::usage()));
+ return -1;
+ case CodaClientApplication::ParseArgsHelp:
+ std::printf("%s", qPrintable(CodaClientApplication::usage()));
+ return 0;
+ case CodaClientApplication::ParseInitError:
+ return -1;
+ case CodaClientApplication::ParseArgsOk:
+ break;
+ }
+ return app.start() ? app.exec() : 0;
+}
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is automatically generated.
+// Changes will be lost.
+//
+
+
+virtual bool visit(ObjCSelectorArgumentAST *ast)
+{
+ if (ast->name_token)
+ terminal(ast->name_token, ast);
+ if (ast->colon_token)
+ terminal(ast->colon_token, ast);
+ return false;
+}
+
+virtual bool visit(ObjCSelectorAST *ast)
+{
+ for (ObjCSelectorArgumentListAST *iter = ast->selector_argument_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ return false;
+}
+
+virtual bool visit(SimpleSpecifierAST *ast)
+{
+ if (ast->specifier_token)
+ terminal(ast->specifier_token, ast);
+ return false;
+}
+
+virtual bool visit(AttributeSpecifierAST *ast)
+{
+ if (ast->attribute_token)
+ terminal(ast->attribute_token, ast);
+ if (ast->first_lparen_token)
+ terminal(ast->first_lparen_token, ast);
+ if (ast->second_lparen_token)
+ terminal(ast->second_lparen_token, ast);
+ for (AttributeListAST *iter = ast->attribute_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->first_rparen_token)
+ terminal(ast->first_rparen_token, ast);
+ if (ast->second_rparen_token)
+ terminal(ast->second_rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(AttributeAST *ast)
+{
+ if (ast->identifier_token)
+ terminal(ast->identifier_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ if (ast->tag_token)
+ terminal(ast->tag_token, ast);
+ for (ExpressionListAST *iter = ast->expression_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(TypeofSpecifierAST *ast)
+{
+ if (ast->typeof_token)
+ terminal(ast->typeof_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->expression);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(DeclaratorAST *ast)
+{
+ for (SpecifierListAST *iter = ast->attribute_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ for (PtrOperatorListAST *iter = ast->ptr_operator_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ nonterminal(ast->core_declarator);
+ for (PostfixDeclaratorListAST *iter = ast->postfix_declarator_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ for (SpecifierListAST *iter = ast->post_attribute_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->equal_token)
+ terminal(ast->equal_token, ast);
+ nonterminal(ast->initializer);
+ return false;
+}
+
+virtual bool visit(SimpleDeclarationAST *ast)
+{
+ if (ast->qt_invokable_token)
+ terminal(ast->qt_invokable_token, ast);
+ for (SpecifierListAST *iter = ast->decl_specifier_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ for (DeclaratorListAST *iter = ast->declarator_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->semicolon_token)
+ terminal(ast->semicolon_token, ast);
+ return false;
+}
+
+virtual bool visit(EmptyDeclarationAST *ast)
+{
+ if (ast->semicolon_token)
+ terminal(ast->semicolon_token, ast);
+ return false;
+}
+
+virtual bool visit(AccessDeclarationAST *ast)
+{
+ if (ast->access_specifier_token)
+ terminal(ast->access_specifier_token, ast);
+ if (ast->slots_token)
+ terminal(ast->slots_token, ast);
+ if (ast->colon_token)
+ terminal(ast->colon_token, ast);
+ return false;
+}
+
+virtual bool visit(QtObjectTagAST *ast)
+{
+ if (ast->q_object_token)
+ terminal(ast->q_object_token, ast);
+ return false;
+}
+
+virtual bool visit(QtPrivateSlotAST *ast)
+{
+ if (ast->q_private_slot_token)
+ terminal(ast->q_private_slot_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ if (ast->dptr_token)
+ terminal(ast->dptr_token, ast);
+ if (ast->dptr_lparen_token)
+ terminal(ast->dptr_lparen_token, ast);
+ if (ast->dptr_rparen_token)
+ terminal(ast->dptr_rparen_token, ast);
+ if (ast->comma_token)
+ terminal(ast->comma_token, ast);
+ for (SpecifierListAST *iter = ast->type_specifier_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ nonterminal(ast->declarator);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(QtPropertyDeclarationItemAST *ast)
+{
+ if (ast->item_name_token)
+ terminal(ast->item_name_token, ast);
+ nonterminal(ast->expression);
+ return false;
+}
+
+virtual bool visit(QtPropertyDeclarationAST *ast)
+{
+ if (ast->property_specifier_token)
+ terminal(ast->property_specifier_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->type_id);
+ nonterminal(ast->property_name);
+ for (QtPropertyDeclarationItemListAST *iter = ast->property_declaration_item_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(QtEnumDeclarationAST *ast)
+{
+ if (ast->enum_specifier_token)
+ terminal(ast->enum_specifier_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ for (NameListAST *iter = ast->enumerator_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(QtFlagsDeclarationAST *ast)
+{
+ if (ast->flags_specifier_token)
+ terminal(ast->flags_specifier_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ for (NameListAST *iter = ast->flag_enums_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(QtInterfaceNameAST *ast)
+{
+ nonterminal(ast->interface_name);
+ for (NameListAST *iter = ast->constraint_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ return false;
+}
+
+virtual bool visit(QtInterfacesDeclarationAST *ast)
+{
+ if (ast->interfaces_token)
+ terminal(ast->interfaces_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ for (QtInterfaceNameListAST *iter = ast->interface_name_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(AsmDefinitionAST *ast)
+{
+ if (ast->asm_token)
+ terminal(ast->asm_token, ast);
+ if (ast->volatile_token)
+ terminal(ast->volatile_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ if (ast->semicolon_token)
+ terminal(ast->semicolon_token, ast);
+ return false;
+}
+
+virtual bool visit(BaseSpecifierAST *ast)
+{
+ if (ast->virtual_token)
+ terminal(ast->virtual_token, ast);
+ if (ast->access_specifier_token)
+ terminal(ast->access_specifier_token, ast);
+ nonterminal(ast->name);
+ return false;
+}
+
+virtual bool visit(IdExpressionAST *ast)
+{
+ nonterminal(ast->name);
+ return false;
+}
+
+virtual bool visit(CompoundExpressionAST *ast)
+{
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->statement);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(CompoundLiteralAST *ast)
+{
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->type_id);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ nonterminal(ast->initializer);
+ return false;
+}
+
+virtual bool visit(QtMethodAST *ast)
+{
+ if (ast->method_token)
+ terminal(ast->method_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->declarator);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(QtMemberDeclarationAST *ast)
+{
+ if (ast->q_token)
+ terminal(ast->q_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->type_id);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(BinaryExpressionAST *ast)
+{
+ nonterminal(ast->left_expression);
+ if (ast->binary_op_token)
+ terminal(ast->binary_op_token, ast);
+ nonterminal(ast->right_expression);
+ return false;
+}
+
+virtual bool visit(CastExpressionAST *ast)
+{
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->type_id);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ nonterminal(ast->expression);
+ return false;
+}
+
+virtual bool visit(ClassSpecifierAST *ast)
+{
+ if (ast->classkey_token)
+ terminal(ast->classkey_token, ast);
+ for (SpecifierListAST *iter = ast->attribute_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ nonterminal(ast->name);
+ if (ast->colon_token)
+ terminal(ast->colon_token, ast);
+ for (BaseSpecifierListAST *iter = ast->base_clause_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->dot_dot_dot_token)
+ terminal(ast->dot_dot_dot_token, ast);
+ if (ast->lbrace_token)
+ terminal(ast->lbrace_token, ast);
+ for (DeclarationListAST *iter = ast->member_specifier_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->rbrace_token)
+ terminal(ast->rbrace_token, ast);
+ return false;
+}
+
+virtual bool visit(CaseStatementAST *ast)
+{
+ if (ast->case_token)
+ terminal(ast->case_token, ast);
+ nonterminal(ast->expression);
+ if (ast->colon_token)
+ terminal(ast->colon_token, ast);
+ nonterminal(ast->statement);
+ return false;
+}
+
+virtual bool visit(CompoundStatementAST *ast)
+{
+ if (ast->lbrace_token)
+ terminal(ast->lbrace_token, ast);
+ for (StatementListAST *iter = ast->statement_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->rbrace_token)
+ terminal(ast->rbrace_token, ast);
+ return false;
+}
+
+virtual bool visit(ConditionAST *ast)
+{
+ for (SpecifierListAST *iter = ast->type_specifier_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ nonterminal(ast->declarator);
+ return false;
+}
+
+virtual bool visit(ConditionalExpressionAST *ast)
+{
+ nonterminal(ast->condition);
+ if (ast->question_token)
+ terminal(ast->question_token, ast);
+ nonterminal(ast->left_expression);
+ if (ast->colon_token)
+ terminal(ast->colon_token, ast);
+ nonterminal(ast->right_expression);
+ return false;
+}
+
+virtual bool visit(CppCastExpressionAST *ast)
+{
+ if (ast->cast_token)
+ terminal(ast->cast_token, ast);
+ if (ast->less_token)
+ terminal(ast->less_token, ast);
+ nonterminal(ast->type_id);
+ if (ast->greater_token)
+ terminal(ast->greater_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->expression);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(CtorInitializerAST *ast)
+{
+ if (ast->colon_token)
+ terminal(ast->colon_token, ast);
+ for (MemInitializerListAST *iter = ast->member_initializer_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->dot_dot_dot_token)
+ terminal(ast->dot_dot_dot_token, ast);
+ return false;
+}
+
+virtual bool visit(DeclarationStatementAST *ast)
+{
+ nonterminal(ast->declaration);
+ return false;
+}
+
+virtual bool visit(DeclaratorIdAST *ast)
+{
+ if (ast->dot_dot_dot_token)
+ terminal(ast->dot_dot_dot_token, ast);
+ nonterminal(ast->name);
+ return false;
+}
+
+virtual bool visit(NestedDeclaratorAST *ast)
+{
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->declarator);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(FunctionDeclaratorAST *ast)
+{
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->parameter_declaration_clause);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ for (SpecifierListAST *iter = ast->cv_qualifier_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ nonterminal(ast->exception_specification);
+ nonterminal(ast->trailing_return_type);
+ nonterminal(ast->as_cpp_initializer);
+ return false;
+}
+
+virtual bool visit(ArrayDeclaratorAST *ast)
+{
+ if (ast->lbracket_token)
+ terminal(ast->lbracket_token, ast);
+ nonterminal(ast->expression);
+ if (ast->rbracket_token)
+ terminal(ast->rbracket_token, ast);
+ return false;
+}
+
+virtual bool visit(DeleteExpressionAST *ast)
+{
+ if (ast->scope_token)
+ terminal(ast->scope_token, ast);
+ if (ast->delete_token)
+ terminal(ast->delete_token, ast);
+ if (ast->lbracket_token)
+ terminal(ast->lbracket_token, ast);
+ if (ast->rbracket_token)
+ terminal(ast->rbracket_token, ast);
+ nonterminal(ast->expression);
+ return false;
+}
+
+virtual bool visit(DoStatementAST *ast)
+{
+ if (ast->do_token)
+ terminal(ast->do_token, ast);
+ nonterminal(ast->statement);
+ if (ast->while_token)
+ terminal(ast->while_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->expression);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ if (ast->semicolon_token)
+ terminal(ast->semicolon_token, ast);
+ return false;
+}
+
+virtual bool visit(NamedTypeSpecifierAST *ast)
+{
+ nonterminal(ast->name);
+ return false;
+}
+
+virtual bool visit(ElaboratedTypeSpecifierAST *ast)
+{
+ if (ast->classkey_token)
+ terminal(ast->classkey_token, ast);
+ for (SpecifierListAST *iter = ast->attribute_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ nonterminal(ast->name);
+ return false;
+}
+
+virtual bool visit(EnumSpecifierAST *ast)
+{
+ if (ast->enum_token)
+ terminal(ast->enum_token, ast);
+ nonterminal(ast->name);
+ if (ast->lbrace_token)
+ terminal(ast->lbrace_token, ast);
+ for (EnumeratorListAST *iter = ast->enumerator_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->stray_comma_token)
+ terminal(ast->stray_comma_token, ast);
+ if (ast->rbrace_token)
+ terminal(ast->rbrace_token, ast);
+ return false;
+}
+
+virtual bool visit(EnumeratorAST *ast)
+{
+ if (ast->identifier_token)
+ terminal(ast->identifier_token, ast);
+ if (ast->equal_token)
+ terminal(ast->equal_token, ast);
+ nonterminal(ast->expression);
+ return false;
+}
+
+virtual bool visit(ExceptionDeclarationAST *ast)
+{
+ for (SpecifierListAST *iter = ast->type_specifier_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ nonterminal(ast->declarator);
+ if (ast->dot_dot_dot_token)
+ terminal(ast->dot_dot_dot_token, ast);
+ return false;
+}
+
+virtual bool visit(ExceptionSpecificationAST *ast)
+{
+ if (ast->throw_token)
+ terminal(ast->throw_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ if (ast->dot_dot_dot_token)
+ terminal(ast->dot_dot_dot_token, ast);
+ for (ExpressionListAST *iter = ast->type_id_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(ExpressionOrDeclarationStatementAST *ast)
+{
+ nonterminal(ast->expression);
+ nonterminal(ast->declaration);
+ return false;
+}
+
+virtual bool visit(ExpressionStatementAST *ast)
+{
+ nonterminal(ast->expression);
+ if (ast->semicolon_token)
+ terminal(ast->semicolon_token, ast);
+ return false;
+}
+
+virtual bool visit(FunctionDefinitionAST *ast)
+{
+ if (ast->qt_invokable_token)
+ terminal(ast->qt_invokable_token, ast);
+ for (SpecifierListAST *iter = ast->decl_specifier_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ nonterminal(ast->declarator);
+ nonterminal(ast->ctor_initializer);
+ nonterminal(ast->function_body);
+ return false;
+}
+
+virtual bool visit(ForeachStatementAST *ast)
+{
+ if (ast->foreach_token)
+ terminal(ast->foreach_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ for (SpecifierListAST *iter = ast->type_specifier_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ nonterminal(ast->declarator);
+ nonterminal(ast->initializer);
+ if (ast->comma_token)
+ terminal(ast->comma_token, ast);
+ nonterminal(ast->expression);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ nonterminal(ast->statement);
+ return false;
+}
+
+virtual bool visit(ForStatementAST *ast)
+{
+ if (ast->for_token)
+ terminal(ast->for_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->initializer);
+ nonterminal(ast->condition);
+ if (ast->semicolon_token)
+ terminal(ast->semicolon_token, ast);
+ nonterminal(ast->expression);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ nonterminal(ast->statement);
+ return false;
+}
+
+virtual bool visit(IfStatementAST *ast)
+{
+ if (ast->if_token)
+ terminal(ast->if_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->condition);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ nonterminal(ast->statement);
+ if (ast->else_token)
+ terminal(ast->else_token, ast);
+ nonterminal(ast->else_statement);
+ return false;
+}
+
+virtual bool visit(ArrayInitializerAST *ast)
+{
+ if (ast->lbrace_token)
+ terminal(ast->lbrace_token, ast);
+ for (ExpressionListAST *iter = ast->expression_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->rbrace_token)
+ terminal(ast->rbrace_token, ast);
+ return false;
+}
+
+virtual bool visit(LabeledStatementAST *ast)
+{
+ if (ast->label_token)
+ terminal(ast->label_token, ast);
+ if (ast->colon_token)
+ terminal(ast->colon_token, ast);
+ nonterminal(ast->statement);
+ return false;
+}
+
+virtual bool visit(LinkageBodyAST *ast)
+{
+ if (ast->lbrace_token)
+ terminal(ast->lbrace_token, ast);
+ for (DeclarationListAST *iter = ast->declaration_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->rbrace_token)
+ terminal(ast->rbrace_token, ast);
+ return false;
+}
+
+virtual bool visit(LinkageSpecificationAST *ast)
+{
+ if (ast->extern_token)
+ terminal(ast->extern_token, ast);
+ if (ast->extern_type_token)
+ terminal(ast->extern_type_token, ast);
+ nonterminal(ast->declaration);
+ return false;
+}
+
+virtual bool visit(MemInitializerAST *ast)
+{
+ nonterminal(ast->name);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ for (ExpressionListAST *iter = ast->expression_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(NestedNameSpecifierAST *ast)
+{
+ nonterminal(ast->class_or_namespace_name);
+ if (ast->scope_token)
+ terminal(ast->scope_token, ast);
+ return false;
+}
+
+virtual bool visit(QualifiedNameAST *ast)
+{
+ if (ast->global_scope_token)
+ terminal(ast->global_scope_token, ast);
+ for (NestedNameSpecifierListAST *iter = ast->nested_name_specifier_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ nonterminal(ast->unqualified_name);
+ return false;
+}
+
+virtual bool visit(OperatorFunctionIdAST *ast)
+{
+ if (ast->operator_token)
+ terminal(ast->operator_token, ast);
+ nonterminal(ast->op);
+ return false;
+}
+
+virtual bool visit(ConversionFunctionIdAST *ast)
+{
+ if (ast->operator_token)
+ terminal(ast->operator_token, ast);
+ for (SpecifierListAST *iter = ast->type_specifier_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ for (PtrOperatorListAST *iter = ast->ptr_operator_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ return false;
+}
+
+virtual bool visit(SimpleNameAST *ast)
+{
+ if (ast->identifier_token)
+ terminal(ast->identifier_token, ast);
+ return false;
+}
+
+virtual bool visit(DestructorNameAST *ast)
+{
+ if (ast->tilde_token)
+ terminal(ast->tilde_token, ast);
+ if (ast->identifier_token)
+ terminal(ast->identifier_token, ast);
+ return false;
+}
+
+virtual bool visit(TemplateIdAST *ast)
+{
+ if (ast->template_token)
+ terminal(ast->template_token, ast);
+ if (ast->identifier_token)
+ terminal(ast->identifier_token, ast);
+ if (ast->less_token)
+ terminal(ast->less_token, ast);
+ for (ExpressionListAST *iter = ast->template_argument_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->greater_token)
+ terminal(ast->greater_token, ast);
+ return false;
+}
+
+virtual bool visit(NamespaceAST *ast)
+{
+ if (ast->namespace_token)
+ terminal(ast->namespace_token, ast);
+ if (ast->identifier_token)
+ terminal(ast->identifier_token, ast);
+ for (SpecifierListAST *iter = ast->attribute_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ nonterminal(ast->linkage_body);
+ return false;
+}
+
+virtual bool visit(NamespaceAliasDefinitionAST *ast)
+{
+ if (ast->namespace_token)
+ terminal(ast->namespace_token, ast);
+ if (ast->namespace_name_token)
+ terminal(ast->namespace_name_token, ast);
+ if (ast->equal_token)
+ terminal(ast->equal_token, ast);
+ nonterminal(ast->name);
+ if (ast->semicolon_token)
+ terminal(ast->semicolon_token, ast);
+ return false;
+}
+
+virtual bool visit(NewPlacementAST *ast)
+{
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ for (ExpressionListAST *iter = ast->expression_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(NewArrayDeclaratorAST *ast)
+{
+ if (ast->lbracket_token)
+ terminal(ast->lbracket_token, ast);
+ nonterminal(ast->expression);
+ if (ast->rbracket_token)
+ terminal(ast->rbracket_token, ast);
+ return false;
+}
+
+virtual bool visit(NewExpressionAST *ast)
+{
+ if (ast->scope_token)
+ terminal(ast->scope_token, ast);
+ if (ast->new_token)
+ terminal(ast->new_token, ast);
+ nonterminal(ast->new_placement);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->type_id);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ nonterminal(ast->new_type_id);
+ nonterminal(ast->new_initializer);
+ return false;
+}
+
+virtual bool visit(NewInitializerAST *ast)
+{
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->expression);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(NewTypeIdAST *ast)
+{
+ for (SpecifierListAST *iter = ast->type_specifier_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ for (PtrOperatorListAST *iter = ast->ptr_operator_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ for (NewArrayDeclaratorListAST *iter = ast->new_array_declarator_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ return false;
+}
+
+virtual bool visit(OperatorAST *ast)
+{
+ if (ast->op_token)
+ terminal(ast->op_token, ast);
+ if (ast->open_token)
+ terminal(ast->open_token, ast);
+ if (ast->close_token)
+ terminal(ast->close_token, ast);
+ return false;
+}
+
+virtual bool visit(ParameterDeclarationAST *ast)
+{
+ for (SpecifierListAST *iter = ast->type_specifier_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ nonterminal(ast->declarator);
+ if (ast->equal_token)
+ terminal(ast->equal_token, ast);
+ nonterminal(ast->expression);
+ return false;
+}
+
+virtual bool visit(ParameterDeclarationClauseAST *ast)
+{
+ for (ParameterDeclarationListAST *iter = ast->parameter_declaration_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->dot_dot_dot_token)
+ terminal(ast->dot_dot_dot_token, ast);
+ return false;
+}
+
+virtual bool visit(CallAST *ast)
+{
+ nonterminal(ast->base_expression);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ for (ExpressionListAST *iter = ast->expression_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(ArrayAccessAST *ast)
+{
+ nonterminal(ast->base_expression);
+ if (ast->lbracket_token)
+ terminal(ast->lbracket_token, ast);
+ nonterminal(ast->expression);
+ if (ast->rbracket_token)
+ terminal(ast->rbracket_token, ast);
+ return false;
+}
+
+virtual bool visit(PostIncrDecrAST *ast)
+{
+ nonterminal(ast->base_expression);
+ if (ast->incr_decr_token)
+ terminal(ast->incr_decr_token, ast);
+ return false;
+}
+
+virtual bool visit(MemberAccessAST *ast)
+{
+ nonterminal(ast->base_expression);
+ if (ast->access_token)
+ terminal(ast->access_token, ast);
+ if (ast->template_token)
+ terminal(ast->template_token, ast);
+ nonterminal(ast->member_name);
+ return false;
+}
+
+virtual bool visit(TypeidExpressionAST *ast)
+{
+ if (ast->typeid_token)
+ terminal(ast->typeid_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->expression);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(TypenameCallExpressionAST *ast)
+{
+ if (ast->typename_token)
+ terminal(ast->typename_token, ast);
+ nonterminal(ast->name);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ for (ExpressionListAST *iter = ast->expression_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(TypeConstructorCallAST *ast)
+{
+ for (SpecifierListAST *iter = ast->type_specifier_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ for (ExpressionListAST *iter = ast->expression_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(PointerToMemberAST *ast)
+{
+ if (ast->global_scope_token)
+ terminal(ast->global_scope_token, ast);
+ for (NestedNameSpecifierListAST *iter = ast->nested_name_specifier_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->star_token)
+ terminal(ast->star_token, ast);
+ for (SpecifierListAST *iter = ast->cv_qualifier_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ return false;
+}
+
+virtual bool visit(PointerAST *ast)
+{
+ if (ast->star_token)
+ terminal(ast->star_token, ast);
+ for (SpecifierListAST *iter = ast->cv_qualifier_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ return false;
+}
+
+virtual bool visit(ReferenceAST *ast)
+{
+ if (ast->reference_token)
+ terminal(ast->reference_token, ast);
+ return false;
+}
+
+virtual bool visit(BreakStatementAST *ast)
+{
+ if (ast->break_token)
+ terminal(ast->break_token, ast);
+ if (ast->semicolon_token)
+ terminal(ast->semicolon_token, ast);
+ return false;
+}
+
+virtual bool visit(ContinueStatementAST *ast)
+{
+ if (ast->continue_token)
+ terminal(ast->continue_token, ast);
+ if (ast->semicolon_token)
+ terminal(ast->semicolon_token, ast);
+ return false;
+}
+
+virtual bool visit(GotoStatementAST *ast)
+{
+ if (ast->goto_token)
+ terminal(ast->goto_token, ast);
+ if (ast->identifier_token)
+ terminal(ast->identifier_token, ast);
+ if (ast->semicolon_token)
+ terminal(ast->semicolon_token, ast);
+ return false;
+}
+
+virtual bool visit(ReturnStatementAST *ast)
+{
+ if (ast->return_token)
+ terminal(ast->return_token, ast);
+ nonterminal(ast->expression);
+ if (ast->semicolon_token)
+ terminal(ast->semicolon_token, ast);
+ return false;
+}
+
+virtual bool visit(SizeofExpressionAST *ast)
+{
+ if (ast->sizeof_token)
+ terminal(ast->sizeof_token, ast);
+ if (ast->dot_dot_dot_token)
+ terminal(ast->dot_dot_dot_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->expression);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(NumericLiteralAST *ast)
+{
+ if (ast->literal_token)
+ terminal(ast->literal_token, ast);
+ return false;
+}
+
+virtual bool visit(BoolLiteralAST *ast)
+{
+ if (ast->literal_token)
+ terminal(ast->literal_token, ast);
+ return false;
+}
+
+virtual bool visit(ThisExpressionAST *ast)
+{
+ if (ast->this_token)
+ terminal(ast->this_token, ast);
+ return false;
+}
+
+virtual bool visit(NestedExpressionAST *ast)
+{
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->expression);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(StringLiteralAST *ast)
+{
+ if (ast->literal_token)
+ terminal(ast->literal_token, ast);
+ nonterminal(ast->next);
+ return false;
+}
+
+virtual bool visit(SwitchStatementAST *ast)
+{
+ if (ast->switch_token)
+ terminal(ast->switch_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->condition);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ nonterminal(ast->statement);
+ return false;
+}
+
+virtual bool visit(TemplateDeclarationAST *ast)
+{
+ if (ast->export_token)
+ terminal(ast->export_token, ast);
+ if (ast->template_token)
+ terminal(ast->template_token, ast);
+ if (ast->less_token)
+ terminal(ast->less_token, ast);
+ for (DeclarationListAST *iter = ast->template_parameter_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->greater_token)
+ terminal(ast->greater_token, ast);
+ nonterminal(ast->declaration);
+ return false;
+}
+
+virtual bool visit(ThrowExpressionAST *ast)
+{
+ if (ast->throw_token)
+ terminal(ast->throw_token, ast);
+ nonterminal(ast->expression);
+ return false;
+}
+
+virtual bool visit(TranslationUnitAST *ast)
+{
+ for (DeclarationListAST *iter = ast->declaration_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ return false;
+}
+
+virtual bool visit(TryBlockStatementAST *ast)
+{
+ if (ast->try_token)
+ terminal(ast->try_token, ast);
+ nonterminal(ast->statement);
+ for (CatchClauseListAST *iter = ast->catch_clause_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ return false;
+}
+
+virtual bool visit(CatchClauseAST *ast)
+{
+ if (ast->catch_token)
+ terminal(ast->catch_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->exception_declaration);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ nonterminal(ast->statement);
+ return false;
+}
+
+virtual bool visit(TypeIdAST *ast)
+{
+ for (SpecifierListAST *iter = ast->type_specifier_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ nonterminal(ast->declarator);
+ return false;
+}
+
+virtual bool visit(TypenameTypeParameterAST *ast)
+{
+ if (ast->classkey_token)
+ terminal(ast->classkey_token, ast);
+ if (ast->dot_dot_dot_token)
+ terminal(ast->dot_dot_dot_token, ast);
+ nonterminal(ast->name);
+ if (ast->equal_token)
+ terminal(ast->equal_token, ast);
+ nonterminal(ast->type_id);
+ return false;
+}
+
+virtual bool visit(TemplateTypeParameterAST *ast)
+{
+ if (ast->template_token)
+ terminal(ast->template_token, ast);
+ if (ast->less_token)
+ terminal(ast->less_token, ast);
+ for (DeclarationListAST *iter = ast->template_parameter_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->greater_token)
+ terminal(ast->greater_token, ast);
+ if (ast->class_token)
+ terminal(ast->class_token, ast);
+ if (ast->dot_dot_dot_token)
+ terminal(ast->dot_dot_dot_token, ast);
+ nonterminal(ast->name);
+ if (ast->equal_token)
+ terminal(ast->equal_token, ast);
+ nonterminal(ast->type_id);
+ return false;
+}
+
+virtual bool visit(UnaryExpressionAST *ast)
+{
+ if (ast->unary_op_token)
+ terminal(ast->unary_op_token, ast);
+ nonterminal(ast->expression);
+ return false;
+}
+
+virtual bool visit(UsingAST *ast)
+{
+ if (ast->using_token)
+ terminal(ast->using_token, ast);
+ if (ast->typename_token)
+ terminal(ast->typename_token, ast);
+ nonterminal(ast->name);
+ if (ast->semicolon_token)
+ terminal(ast->semicolon_token, ast);
+ return false;
+}
+
+virtual bool visit(UsingDirectiveAST *ast)
+{
+ if (ast->using_token)
+ terminal(ast->using_token, ast);
+ if (ast->namespace_token)
+ terminal(ast->namespace_token, ast);
+ nonterminal(ast->name);
+ if (ast->semicolon_token)
+ terminal(ast->semicolon_token, ast);
+ return false;
+}
+
+virtual bool visit(WhileStatementAST *ast)
+{
+ if (ast->while_token)
+ terminal(ast->while_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->condition);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ nonterminal(ast->statement);
+ return false;
+}
+
+virtual bool visit(ObjCClassForwardDeclarationAST *ast)
+{
+ for (SpecifierListAST *iter = ast->attribute_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->class_token)
+ terminal(ast->class_token, ast);
+ for (NameListAST *iter = ast->identifier_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->semicolon_token)
+ terminal(ast->semicolon_token, ast);
+ return false;
+}
+
+virtual bool visit(ObjCClassDeclarationAST *ast)
+{
+ for (SpecifierListAST *iter = ast->attribute_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->interface_token)
+ terminal(ast->interface_token, ast);
+ if (ast->implementation_token)
+ terminal(ast->implementation_token, ast);
+ nonterminal(ast->class_name);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->category_name);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ if (ast->colon_token)
+ terminal(ast->colon_token, ast);
+ nonterminal(ast->superclass);
+ nonterminal(ast->protocol_refs);
+ nonterminal(ast->inst_vars_decl);
+ for (DeclarationListAST *iter = ast->member_declaration_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->end_token)
+ terminal(ast->end_token, ast);
+ return false;
+}
+
+virtual bool visit(ObjCProtocolForwardDeclarationAST *ast)
+{
+ for (SpecifierListAST *iter = ast->attribute_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->protocol_token)
+ terminal(ast->protocol_token, ast);
+ for (NameListAST *iter = ast->identifier_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->semicolon_token)
+ terminal(ast->semicolon_token, ast);
+ return false;
+}
+
+virtual bool visit(ObjCProtocolDeclarationAST *ast)
+{
+ for (SpecifierListAST *iter = ast->attribute_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->protocol_token)
+ terminal(ast->protocol_token, ast);
+ nonterminal(ast->name);
+ nonterminal(ast->protocol_refs);
+ for (DeclarationListAST *iter = ast->member_declaration_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->end_token)
+ terminal(ast->end_token, ast);
+ return false;
+}
+
+virtual bool visit(ObjCProtocolRefsAST *ast)
+{
+ if (ast->less_token)
+ terminal(ast->less_token, ast);
+ for (NameListAST *iter = ast->identifier_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->greater_token)
+ terminal(ast->greater_token, ast);
+ return false;
+}
+
+virtual bool visit(ObjCMessageArgumentAST *ast)
+{
+ nonterminal(ast->parameter_value_expression);
+ return false;
+}
+
+virtual bool visit(ObjCMessageExpressionAST *ast)
+{
+ if (ast->lbracket_token)
+ terminal(ast->lbracket_token, ast);
+ nonterminal(ast->receiver_expression);
+ nonterminal(ast->selector);
+ for (ObjCMessageArgumentListAST *iter = ast->argument_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->rbracket_token)
+ terminal(ast->rbracket_token, ast);
+ return false;
+}
+
+virtual bool visit(ObjCProtocolExpressionAST *ast)
+{
+ if (ast->protocol_token)
+ terminal(ast->protocol_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ if (ast->identifier_token)
+ terminal(ast->identifier_token, ast);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(ObjCTypeNameAST *ast)
+{
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ if (ast->type_qualifier_token)
+ terminal(ast->type_qualifier_token, ast);
+ nonterminal(ast->type_id);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(ObjCEncodeExpressionAST *ast)
+{
+ if (ast->encode_token)
+ terminal(ast->encode_token, ast);
+ nonterminal(ast->type_name);
+ return false;
+}
+
+virtual bool visit(ObjCSelectorExpressionAST *ast)
+{
+ if (ast->selector_token)
+ terminal(ast->selector_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->selector);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(ObjCInstanceVariablesDeclarationAST *ast)
+{
+ if (ast->lbrace_token)
+ terminal(ast->lbrace_token, ast);
+ for (DeclarationListAST *iter = ast->instance_variable_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->rbrace_token)
+ terminal(ast->rbrace_token, ast);
+ return false;
+}
+
+virtual bool visit(ObjCVisibilityDeclarationAST *ast)
+{
+ if (ast->visibility_token)
+ terminal(ast->visibility_token, ast);
+ return false;
+}
+
+virtual bool visit(ObjCPropertyAttributeAST *ast)
+{
+ if (ast->attribute_identifier_token)
+ terminal(ast->attribute_identifier_token, ast);
+ if (ast->equals_token)
+ terminal(ast->equals_token, ast);
+ nonterminal(ast->method_selector);
+ return false;
+}
+
+virtual bool visit(ObjCPropertyDeclarationAST *ast)
+{
+ for (SpecifierListAST *iter = ast->attribute_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->property_token)
+ terminal(ast->property_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ for (ObjCPropertyAttributeListAST *iter = ast->property_attribute_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ nonterminal(ast->simple_declaration);
+ return false;
+}
+
+virtual bool visit(ObjCMessageArgumentDeclarationAST *ast)
+{
+ nonterminal(ast->type_name);
+ for (SpecifierListAST *iter = ast->attribute_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ nonterminal(ast->param_name);
+ return false;
+}
+
+virtual bool visit(ObjCMethodPrototypeAST *ast)
+{
+ if (ast->method_type_token)
+ terminal(ast->method_type_token, ast);
+ nonterminal(ast->type_name);
+ nonterminal(ast->selector);
+ for (ObjCMessageArgumentDeclarationListAST *iter = ast->argument_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->dot_dot_dot_token)
+ terminal(ast->dot_dot_dot_token, ast);
+ for (SpecifierListAST *iter = ast->attribute_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ return false;
+}
+
+virtual bool visit(ObjCMethodDeclarationAST *ast)
+{
+ nonterminal(ast->method_prototype);
+ nonterminal(ast->function_body);
+ if (ast->semicolon_token)
+ terminal(ast->semicolon_token, ast);
+ return false;
+}
+
+virtual bool visit(ObjCSynthesizedPropertyAST *ast)
+{
+ if (ast->property_identifier_token)
+ terminal(ast->property_identifier_token, ast);
+ if (ast->equals_token)
+ terminal(ast->equals_token, ast);
+ if (ast->alias_identifier_token)
+ terminal(ast->alias_identifier_token, ast);
+ return false;
+}
+
+virtual bool visit(ObjCSynthesizedPropertiesDeclarationAST *ast)
+{
+ if (ast->synthesized_token)
+ terminal(ast->synthesized_token, ast);
+ for (ObjCSynthesizedPropertyListAST *iter = ast->property_identifier_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->semicolon_token)
+ terminal(ast->semicolon_token, ast);
+ return false;
+}
+
+virtual bool visit(ObjCDynamicPropertiesDeclarationAST *ast)
+{
+ if (ast->dynamic_token)
+ terminal(ast->dynamic_token, ast);
+ for (NameListAST *iter = ast->property_identifier_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->semicolon_token)
+ terminal(ast->semicolon_token, ast);
+ return false;
+}
+
+virtual bool visit(ObjCFastEnumerationAST *ast)
+{
+ if (ast->for_token)
+ terminal(ast->for_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ for (SpecifierListAST *iter = ast->type_specifier_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ nonterminal(ast->declarator);
+ nonterminal(ast->initializer);
+ if (ast->in_token)
+ terminal(ast->in_token, ast);
+ nonterminal(ast->fast_enumeratable_expression);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ nonterminal(ast->statement);
+ return false;
+}
+
+virtual bool visit(ObjCSynchronizedStatementAST *ast)
+{
+ if (ast->synchronized_token)
+ terminal(ast->synchronized_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->synchronized_object);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ nonterminal(ast->statement);
+ return false;
+}
+
+virtual bool visit(LambdaExpressionAST *ast)
+{
+ nonterminal(ast->lambda_introducer);
+ nonterminal(ast->lambda_declarator);
+ nonterminal(ast->statement);
+ return false;
+}
+
+virtual bool visit(LambdaIntroducerAST *ast)
+{
+ if (ast->lbracket_token)
+ terminal(ast->lbracket_token, ast);
+ nonterminal(ast->lambda_capture);
+ if (ast->rbracket_token)
+ terminal(ast->rbracket_token, ast);
+ return false;
+}
+
+virtual bool visit(LambdaCaptureAST *ast)
+{
+ if (ast->default_capture_token)
+ terminal(ast->default_capture_token, ast);
+ for (CaptureListAST *iter = ast->capture_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ return false;
+}
+
+virtual bool visit(CaptureAST *ast)
+{
+ return false;
+}
+
+virtual bool visit(LambdaDeclaratorAST *ast)
+{
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->parameter_declaration_clause);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ for (SpecifierListAST *iter = ast->attributes; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->mutable_token)
+ terminal(ast->mutable_token, ast);
+ nonterminal(ast->exception_specification);
+ nonterminal(ast->trailing_return_type);
+ return false;
+}
+
+virtual bool visit(TrailingReturnTypeAST *ast)
+{
+ if (ast->arrow_token)
+ terminal(ast->arrow_token, ast);
+ for (SpecifierListAST *iter = ast->attributes; iter; iter = iter->next)
+ nonterminal(iter->value);
+ for (SpecifierListAST *iter = ast->type_specifier_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ nonterminal(ast->declarator);
+ return false;
+}
+
+virtual bool visit(BracedInitializerAST *ast)
+{
+ if (ast->lbrace_token)
+ terminal(ast->lbrace_token, ast);
+ for (ExpressionListAST *iter = ast->expression_list; iter; iter = iter->next)
+ nonterminal(iter->value);
+ if (ast->comma_token)
+ terminal(ast->comma_token, ast);
+ if (ast->rbrace_token)
+ terminal(ast->rbrace_token, ast);
+ return false;
+}
+
--- /dev/null
- ** Commercial Usage
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
- ** Licensees holding valid Qt Commercial licenses may use this file in
- ** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Nokia.
++** No Commercial Usage
+**
- ** If you are unsure which license is appropriate for your use, please
- ** contact the sales department at http://qt.nokia.com/contact.
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
+**
+**************************************************************************/
+
+#include <qmljs/parser/qmljsast_p.h>
+#include <qmljs/parser/qmljsastvisitor_p.h>
+#include <qmljs/qmljsdocument.h>
+
+#include <QFile>
+#include <QList>
+#include <QCoreApplication>
+#include <QStringList>
+#include <QFileInfo>
+#include <QTime>
+#include <QtDebug>
+
+#include <cstdio>
+#include <cstdlib>
+#include <fstream>
+#include <iostream>
+#ifdef __GNUC__
+# include <cxxabi.h>
+#endif
+
+using namespace QmlJS;
+using namespace QmlJS::AST;
+using namespace std;
+
+class ASTDump: protected Visitor
+{
+public:
+ void operator()(const QString &fileName, const QByteArray &src, Node *ast) {
+ _src = src;
+ QString basename = fileName;
+ int dotIdx = basename.lastIndexOf('.');
+ if (dotIdx != -1)
+ basename.truncate(dotIdx);
+ basename.append(QLatin1String(".ast.dot"));
+ out.open(basename.toUtf8().constData());
+
+ out << "digraph AST { ordering=out;" << endl;
+ // cout << "rankdir = \"LR\";" << endl;
+ Node::accept(ast, this);
+
+ typedef QPair<QByteArray, QByteArray> Pair;
+
+ foreach (const Pair &conn, _connections)
+ out << conn.first.constData() << " -> " << conn.second.constData() << endl;
+
+ alignTerminals();
+
+ out << "}" << endl;
+ out.close();
+ cout << qPrintable(basename) << endl;
+ }
+
+protected:
+ void alignTerminals() {
+ out<<"{ rank=same;" << endl;
+ foreach (const QByteArray &terminalShape, _terminalShapes) {
+ out << " " << string(terminalShape) << ";" << endl;
+ }
+ out<<"}"<<endl;
+ }
+
+ static QByteArray name(Node *ast) {
+#ifdef __GNUC__
+ QByteArray name = abi::__cxa_demangle(typeid(*ast).name(), 0, 0, 0) + 12;
+#else
+ QByteArray name = typeid(*ast).name();
+#endif
+ return name;
+ }
+
+ QString spell(const SourceLocation &token) {
+ return _src.mid(token.offset, token.length).replace('\'', "\\\\").replace('"', "\\\"");
+ }
+
+ void terminal(const SourceLocation &token) {
+ if (!token.isValid())
+ return;
+
+ static int count = 1;
+ QByteArray id = 't' + QByteArray::number(count++);
+ Node *node = _stack.last();
+ _connections.append(qMakePair(_id[node], id));
+
+ QByteArray t;
+ t.append(id);
+ t.append(" [label = \"");
+ t.append(spell(token).toUtf8());
+ t.append("\" shape=rect]");
+ _terminalShapes.append(t);
+ }
+
+ virtual void nonterminal(Node *ast) {
+ Node::accept(ast, this);
+ }
+
+ virtual void node(Node *ast) {
+ out << _id[ast].constData() << " [label=\"" << name(ast).constData() << "\"];" << endl;
+ }
+
+ virtual bool preVisit(Node *ast) {
+ static int count = 1;
+ const QByteArray id = 'n' + QByteArray::number(count++);
+ _id[ast] = id;
+
+
+ if (! _stack.isEmpty())
+ _connections.append(qMakePair(_id[_stack.last()], id));
+
+ _stack.append(ast);
+
+ node(ast);
+
+ return true;
+ }
+
+ virtual void postVisit(Node *) {
+ _stack.removeLast();
+ }
+
+protected: // visiting methods:
+ virtual bool visit(UiImport *ast) {
+ terminal(ast->importToken);
+
+ if (ast->importUri)
+ nonterminal(ast->importUri);
+ else
+ terminal(ast->fileNameToken);
+
+ terminal(ast->versionToken);
+ terminal(ast->asToken);
+ terminal(ast->importIdToken);
+ terminal(ast->semicolonToken);
+ return false;
+ }
+
+ virtual bool visit(UiObjectBinding *ast) {
+ if (ast->hasOnToken) {
+ nonterminal(ast->qualifiedTypeNameId);
+ terminal(ast->colonToken);
+ nonterminal(ast->qualifiedId);
+ } else {
+ nonterminal(ast->qualifiedId);
+ terminal(ast->colonToken);
+ nonterminal(ast->qualifiedTypeNameId);
+ }
+ nonterminal(ast->initializer);
+ return false;
+ }
+
+ virtual bool visit(UiObjectDefinition *ast) {
+ nonterminal(ast->qualifiedTypeNameId);
+ nonterminal(ast->initializer);
+ return false;
+ }
+
+ virtual bool visit(UiObjectInitializer *ast) {
+ terminal(ast->lbraceToken);
+ nonterminal(ast->members);
+ terminal(ast->rbraceToken);
+ return false;
+ }
+
+ virtual bool visit(UiScriptBinding *ast) {
+ nonterminal(ast->qualifiedId);
+ terminal(ast->colonToken);
+ nonterminal(ast->statement);
+ return false;
+ }
+
+ virtual bool visit(UiArrayBinding *ast) {
+ nonterminal(ast->qualifiedId);
+ terminal(ast->colonToken);
+ terminal(ast->lbracketToken);
+ nonterminal(ast->members);
+ terminal(ast->rbracketToken);
+ return false;
+ }
+
+ virtual bool visit(UiArrayMemberList *ast) {
+ terminal(ast->commaToken);
+ nonterminal(ast->member);
+ nonterminal(ast->next);
+ return false;
+ }
+
+ virtual bool visit(UiQualifiedId *ast) {
+ terminal(ast->identifierToken);
+ nonterminal(ast->next);
+ return false;
+ }
+
+ virtual bool visit(UiPublicMember *ast) {
+ // TODO: place the parameters...
+// UiParameterList *parameters;
+
+ terminal(ast->defaultToken);
+ terminal(ast->readonlyToken);
+ terminal(ast->propertyToken);
+ terminal(ast->typeModifierToken);
+ terminal(ast->typeToken);
+ terminal(ast->identifierToken);
+ terminal(ast->colonToken);
+ nonterminal(ast->expression);
+ nonterminal(ast->binding);
+ terminal(ast->semicolonToken);
+ return false;
+ }
+
+ virtual bool visit(UiFormal *ast) { terminal(ast->identifierToken); terminal(ast->asToken); terminal(ast->aliasToken); return false; }
+ virtual bool visit(UiSignature *ast) { terminal(ast->lparenToken); nonterminal(ast->formals); terminal(ast->rparenToken); return false; }
+
+ virtual bool visit(StringLiteral *ast) { terminal(ast->literalToken); return false; }
+ virtual bool visit(NumericLiteral *ast) { terminal(ast->literalToken); return false; }
+ virtual bool visit(TrueLiteral *ast) { terminal(ast->trueToken); return false; }
+ virtual bool visit(FalseLiteral *ast) { terminal(ast->falseToken); return false; }
+ virtual bool visit(IdentifierExpression *ast) { terminal(ast->identifierToken); return false; }
+ virtual bool visit(FieldMemberExpression *ast) { nonterminal(ast->base); terminal(ast->dotToken); terminal(ast->identifierToken); return false; }
+ virtual bool visit(BinaryExpression *ast) { nonterminal(ast->left); terminal(ast->operatorToken); nonterminal(ast->right); return false; }
+ virtual bool visit(UnaryPlusExpression *ast) { terminal(ast->plusToken); nonterminal(ast->expression); return false; }
+ virtual bool visit(UnaryMinusExpression *ast) { terminal(ast->minusToken); nonterminal(ast->expression); return false; }
+ virtual bool visit(NestedExpression *ast) { terminal(ast->lparenToken); nonterminal(ast->expression); terminal(ast->rparenToken); return false; }
+ virtual bool visit(ThisExpression *ast) { terminal(ast->thisToken); return false; }
+ virtual bool visit(NullExpression *ast) { terminal(ast->nullToken); return false; }
+ virtual bool visit(RegExpLiteral *ast) { terminal(ast->literalToken); return false; }
+ virtual bool visit(ArrayLiteral *ast) { terminal(ast->lbracketToken); nonterminal(ast->elements); terminal(ast->commaToken); nonterminal(ast->elision); terminal(ast->rbracketToken); return false; }
+ virtual bool visit(ObjectLiteral *ast) { terminal(ast->lbraceToken); nonterminal(ast->properties); terminal(ast->rbraceToken); return false; }
+ virtual bool visit(ElementList *ast) { nonterminal(ast->next); terminal(ast->commaToken); nonterminal(ast->elision); nonterminal(ast->expression); return false; }
+ virtual bool visit(Elision *ast) { nonterminal(ast->next); terminal(ast->commaToken); return false; }
+ virtual bool visit(PropertyNameAndValueList *ast) { nonterminal(ast->name); terminal(ast->colonToken); nonterminal(ast->value); terminal(ast->commaToken); nonterminal(ast->next); return false; }
+ virtual bool visit(IdentifierPropertyName *ast) { terminal(ast->propertyNameToken); return false; }
+ virtual bool visit(StringLiteralPropertyName *ast) { terminal(ast->propertyNameToken); return false; }
+ virtual bool visit(NumericLiteralPropertyName *ast) { terminal(ast->propertyNameToken); return false; }
+ virtual bool visit(ArrayMemberExpression *ast) { nonterminal(ast->base); terminal(ast->lbracketToken); nonterminal(ast->expression); terminal(ast->rbracketToken); return false; }
+ virtual bool visit(NewMemberExpression *ast) { terminal(ast->newToken); nonterminal(ast->base); terminal(ast->lparenToken); nonterminal(ast->arguments); terminal(ast->rparenToken); return false; }
+ virtual bool visit(NewExpression *ast) { terminal(ast->newToken); nonterminal(ast->expression); return false; }
+ virtual bool visit(CallExpression *ast) { nonterminal(ast->base); terminal(ast->lparenToken); nonterminal(ast->arguments); terminal(ast->rparenToken); return false; }
+ virtual bool visit(ArgumentList *ast) { nonterminal(ast->expression); terminal(ast->commaToken); nonterminal(ast->next); return false; }
+ virtual bool visit(PostIncrementExpression *ast) { nonterminal(ast->base); terminal(ast->incrementToken); return false; }
+ virtual bool visit(PostDecrementExpression *ast) { nonterminal(ast->base); terminal(ast->decrementToken); return false; }
+ virtual bool visit(DeleteExpression *ast) { terminal(ast->deleteToken); nonterminal(ast->expression); return false; }
+ virtual bool visit(VoidExpression *ast) { terminal(ast->voidToken); nonterminal(ast->expression); return false; }
+ virtual bool visit(TypeOfExpression *ast) { terminal(ast->typeofToken); nonterminal(ast->expression); return false; }
+ virtual bool visit(PreIncrementExpression *ast) { terminal(ast->incrementToken); nonterminal(ast->expression); return false; }
+ virtual bool visit(PreDecrementExpression *ast) { terminal(ast->decrementToken); nonterminal(ast->expression); return false; }
+ virtual bool visit(TildeExpression *ast) { terminal(ast->tildeToken); nonterminal(ast->expression); return false; }
+ virtual bool visit(NotExpression *ast) { terminal(ast->notToken); nonterminal(ast->expression); return false; }
+ virtual bool visit(ConditionalExpression *ast) { nonterminal(ast->expression); terminal(ast->questionToken); nonterminal(ast->ok); terminal(ast->colonToken); nonterminal(ast->ko); return false; }
+ virtual bool visit(Expression *ast) { nonterminal(ast->left); terminal(ast->commaToken); nonterminal(ast->right); return false; }
+ virtual bool visit(Block *ast) { terminal(ast->lbraceToken); nonterminal(ast->statements); terminal(ast->rbraceToken); return false; }
+ virtual bool visit(VariableStatement *ast) { terminal(ast->declarationKindToken); nonterminal(ast->declarations); terminal(ast->semicolonToken); return false; }
+ virtual bool visit(VariableDeclaration *ast) { terminal(ast->identifierToken); nonterminal(ast->expression); return false; }
+ virtual bool visit(VariableDeclarationList *ast) { nonterminal(ast->declaration); terminal(ast->commaToken); nonterminal(ast->next); return false; }
+ virtual bool visit(EmptyStatement* ast) { terminal(ast->semicolonToken); return false; }
+ virtual bool visit(ExpressionStatement *ast) { nonterminal(ast->expression); terminal(ast->semicolonToken); return false; }
+ virtual bool visit(IfStatement *ast) { terminal(ast->ifToken); terminal(ast->lparenToken); nonterminal(ast->expression); terminal(ast->rparenToken); nonterminal(ast->ok); terminal(ast->elseToken); nonterminal(ast->ko); return false; }
+ virtual bool visit(DoWhileStatement *ast) { terminal(ast->doToken); nonterminal(ast->statement); terminal(ast->whileToken); terminal(ast->lparenToken); nonterminal(ast->expression); terminal(ast->rparenToken); terminal(ast->semicolonToken); return false; }
+
+// TODO: visitors for:
+// WhileStatement
+// ForStatement
+// LocalForStatement
+// ForEachStatement
+// LocalForEachStatement
+// ContinueStatement
+// BreakStatement
+// ReturnStatement
+// WithStatement
+// CaseBlock
+// SwitchStatement
+// CaseClause
+// DefaultClause
+// LabelledStatement
+// ThrowStatement
+// Catch
+// Finally
+// TryStatement
+// FunctionExpression
+// FunctionDeclaration
+// DebuggerStatement
+// UiParameterList
+
+private:
+ QHash<Node *, QByteArray> _id;
+ QList<QPair<QByteArray, QByteArray> > _connections;
+ QList<Node *> _stack;
+ QList<QByteArray> _terminalShapes;
+ ofstream out;
+ QByteArray _src;
+};
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication app(argc, argv);
+
+ QStringList files = app.arguments();
+ files.removeFirst();
+
+ foreach (const QString &fileName, files) {
+ QFile file(fileName);
+ if (! file.open(QFile::ReadOnly)) {
+ cerr << "Cannot open \"" << qPrintable(fileName)
+ << "\", skipping it." << endl;
+ continue;
+ }
+
+ const QByteArray source = file.readAll();
+ file.close();
+
+ Document::Ptr doc = Document::create(fileName);
+ doc->setSource(source);
+ doc->parseQml();
+
+ foreach (const DiagnosticMessage &m, doc->diagnosticMessages()) {
+ ostream *os;
+ if (m.isError()) {
+ os = &cerr;
+ *os << "Error:";
+ } else {
+ os = &cout;
+ *os << "Warning:";
+ }
+
+ if (m.loc.isValid())
+ *os << m.loc.startLine << ':' << m.loc.startColumn << ':';
+ *os << ' ';
+ *os << qPrintable(m.message) << endl;
+ }
+
+ ASTDump dump;
+ dump(fileName, source, doc->qmlProgram());
+ }
+
+ return EXIT_SUCCESS;
+}