Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline

This commit is contained in:
Jarek Kobus
2008-12-11 13:49:12 +01:00
262 changed files with 4081 additions and 2621 deletions

View File

@@ -222,7 +222,7 @@ void BinEditor::scrollContentsBy(int dx, int dy)
void BinEditor::changeEvent(QEvent *e)
{
QAbstractScrollArea::changeEvent(e);
if(e->type() == QEvent::ActivationChange) {
if (e->type() == QEvent::ActivationChange) {
if (!isActiveWindow())
m_autoScrollTimer.stop();
}
@@ -450,7 +450,7 @@ void BinEditor::paintEvent(QPaintEvent *e)
for (int c = 0; c < 16; ++c) {
int pos = line * 16 + c;
if (pos >= m_data.size()) {
while(c < 16) {
while (c < 16) {
itemStringData[c*3] = itemStringData[c*3+1] = ' ';
++c;
}

View File

@@ -32,6 +32,7 @@
***************************************************************************/
#include "bookmarkmanager.h"
#include "bookmark.h"
#include "bookmarksplugin.h"
#include "bookmarks_global.h"
@@ -41,12 +42,14 @@
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/uniqueidmanager.h>
#include <texteditor/basetexteditor.h>
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtCore/QFileInfo>
#include <QtGui/QAction>
#include <QtCore/QFileInfo>
#include <QtCore/QDebug>
#include <QtGui/QPainter>
#include <QtGui/QContextMenuEvent>
#include <QtGui/QPainter>
Q_DECLARE_METATYPE(Bookmarks::Internal::Bookmark*)
@@ -173,7 +176,7 @@ void BookmarkDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
// int idx;
// forever {
// idx = directory.lastIndexOf("/", pos-1);
// if(idx == -1) {
// if (idx == -1) {
// // Can't happen, this means the string did fit after all?
// break;
// }
@@ -272,7 +275,7 @@ void BookmarkView::removeAll()
void BookmarkView::setModel(QAbstractItemModel *model)
{
BookmarkManager *manager = qobject_cast<BookmarkManager *>(model);
Q_ASSERT(manager);
QTC_ASSERT(manager, return);
QListView::setModel(model);
setSelectionModel(manager->selectionModel());
setSelectionMode(QAbstractItemView::SingleSelection);
@@ -396,11 +399,16 @@ void BookmarkManager::toggleBookmark()
if (!editor)
return;
const QFileInfo fi(editor->file()->fileName());
const int editorLine = editor->currentLine();
toggleBookmark(editor->file()->fileName(), editor->currentLine());
}
void BookmarkManager::toggleBookmark(const QString &fileName, int lineNumber)
{
const QFileInfo fi(fileName);
const int editorLine = lineNumber;
// Remove any existing bookmark on this line
if (Bookmark *mark = findBookmark(fi.path(), fi.fileName(), editorLine)) {
if (Bookmark *mark = findBookmark(fi.path(), fi.fileName(), lineNumber)) {
// TODO check if the bookmark is really on the same markable Interface
removeBookmark(mark);
return;

View File

@@ -34,15 +34,15 @@
#ifndef BOOKMARKMANAGER_H
#define BOOKMARKMANAGER_H
#include <QtCore/QAbstractItemModel>
#include <QtGui/QListView>
#include <QtCore/QList>
#include <QtGui/QPixmap>
#include <QtGui/QStyledItemDelegate>
#include <coreplugin/icontext.h>
#include <coreplugin/inavigationwidgetfactory.h>
#include <QtCore/QAbstractItemModel>
#include <QtCore/QList>
#include <QtGui/QListView>
#include <QtGui/QPixmap>
#include <QtGui/QStyledItemDelegate>
namespace ProjectExplorer {
class SessionManager;
}
@@ -89,10 +89,16 @@ public:
// this QItemSelectionModel is shared by all views
QItemSelectionModel *selectionModel() const;
enum Roles {Filename = Qt::UserRole, LineNumber = Qt::UserRole + 1, Directory = Qt::UserRole + 2, LineText = Qt::UserRole + 3};
enum Roles {
Filename = Qt::UserRole,
LineNumber = Qt::UserRole + 1,
Directory = Qt::UserRole + 2,
LineText = Qt::UserRole + 3
};
public slots:
void toggleBookmark();
void toggleBookmark(const QString &fileName, int lineNumber);
void nextInDocument();
void prevInDocument();
void next();
@@ -108,6 +114,7 @@ private slots:
void updateActionStatus();
void gotoBookmark(Bookmark *bookmark);
void loadBookmarks();
private:
TextEditor::ITextEditor *currentTextEditor() const;
ProjectExplorer::SessionManager* sessionManager() const;
@@ -120,8 +127,8 @@ private:
static QString bookmarkToString(const Bookmark *b);
void saveBookmarks();
typedef QMultiMap<QString, Bookmark*> FileNameBookmarksMap;
typedef QMap<QString, FileNameBookmarksMap*> DirectoryFileBookmarksMap;
typedef QMultiMap<QString, Bookmark *> FileNameBookmarksMap;
typedef QMap<QString, FileNameBookmarksMap *> DirectoryFileBookmarksMap;
DirectoryFileBookmarksMap m_bookmarksMap;
Core::ICore *m_core;
@@ -138,7 +145,7 @@ class BookmarkView : public QListView
public:
BookmarkView(QWidget *parent = 0);
~BookmarkView();
void setModel(QAbstractItemModel * model);
void setModel(QAbstractItemModel *model);
public slots:
void gotoBookmark(const QModelIndex &index);
protected slots:
@@ -146,7 +153,7 @@ protected slots:
void removeAll();
protected:
void contextMenuEvent(QContextMenuEvent *event);
void removeBookmark(const QModelIndex& index);
void removeBookmark(const QModelIndex &index);
private:
BookmarkContext *m_bookmarkContext;
QModelIndex m_contextMenuIndex;

View File

@@ -36,17 +36,22 @@
#include "bookmarks_global.h"
#include <texteditor/texteditorconstants.h>
#include <texteditor/itexteditor.h>
#include <coreplugin/icore.h>
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/actionmanager/actionmanagerinterface.h>
#include <QtCore/qplugin.h>
#include <QtCore/QDebug>
#include <QtGui/QMenu>
#include <QDebug>
using namespace Bookmarks::Constants;
using namespace Bookmarks::Internal;
using namespace TextEditor;
BookmarksPlugin *BookmarksPlugin::m_instance = 0;
@@ -159,6 +164,19 @@ bool BookmarksPlugin::initialize(const QStringList & /*arguments*/, QString *)
updateActions(m_bookmarkManager->state());
addAutoReleasedObject(new BookmarkViewFactory(m_bookmarkManager));
m_bookmarkMarginAction = new QAction(this);
m_bookmarkMarginAction->setText("Toggle Bookmark");
//m_bookmarkAction->setIcon(QIcon(":/gdbdebugger/images/breakpoint.svg"));
connect(m_bookmarkMarginAction, SIGNAL(triggered()),
this, SLOT(bookmarkMarginActionTriggered()));
// EditorManager
QObject *editorManager = m_core->editorManager();
connect(editorManager, SIGNAL(editorAboutToClose(Core::IEditor*)),
this, SLOT(editorAboutToClose(Core::IEditor*)));
connect(editorManager, SIGNAL(editorOpened(Core::IEditor*)),
this, SLOT(editorOpened(Core::IEditor*)));
return true;
}
@@ -169,7 +187,6 @@ BookmarksPlugin::~BookmarksPlugin()
void BookmarksPlugin::updateActions(int state)
{
const bool hasbm = state >= BookmarkManager::HasBookMarks;
const bool hasdocbm = state == BookmarkManager::HasBookmarksInDocument;
@@ -182,4 +199,32 @@ void BookmarksPlugin::updateActions(int state)
m_moveDownAction->setEnabled(hasbm);
}
void BookmarksPlugin::editorOpened(Core::IEditor *editor)
{
connect(editor, SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)),
this, SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*)));
}
void BookmarksPlugin::editorAboutToClose(Core::IEditor *editor)
{
disconnect(editor, SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)),
this, SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*)));
}
void BookmarksPlugin::requestContextMenu(TextEditor::ITextEditor *editor,
int lineNumber, QMenu *menu)
{
m_bookmarkMarginActionLineNumber = lineNumber;
m_bookmarkMarginActionFileName = editor->file()->fileName();
menu->addAction(m_bookmarkMarginAction);
}
void BookmarksPlugin::bookmarkMarginActionTriggered()
{
m_bookmarkManager->toggleBookmark(
m_bookmarkMarginActionFileName,
m_bookmarkMarginActionLineNumber
);
}
Q_EXPORT_PLUGIN(BookmarksPlugin)

View File

@@ -31,18 +31,26 @@
**
***************************************************************************/
#ifndef BOOKMARKS_H
#define BOOKMARKS_H
#ifndef BOOKMARKSPLUGIN_H
#define BOOKMARKSPLUGIN_H
#include <extensionsystem/iplugin.h>
#include <QtCore/QObject>
#include <QtCore/QMultiMap>
#include <extensionsystem/iplugin.h>
QT_FORWARD_DECLARE_CLASS(QAction)
QT_BEGIN_NAMESPACE
class QAction;
class QMenu;
QT_END_NAMESPACE
namespace Core {
class ICore;
class IEditor;
}
namespace TextEditor {
class ITextEditor;
}
namespace Bookmarks {
@@ -67,6 +75,13 @@ public:
public slots:
void updateActions(int stateMask);
private slots:
void editorOpened(Core::IEditor *editor);
void editorAboutToClose(Core::IEditor *editor);
void requestContextMenu(TextEditor::ITextEditor *editor,
int lineNumber, QMenu *menu);
void bookmarkMarginActionTriggered();
private:
static BookmarksPlugin *m_instance;
BookmarkManager *m_bookmarkManager;
@@ -79,6 +94,10 @@ private:
QAction *m_docNextAction;
QAction *m_moveUpAction;
QAction *m_moveDownAction;
QAction *m_bookmarkMarginAction;
int m_bookmarkMarginActionLineNumber;
QString m_bookmarkMarginActionFileName;
};
} // namespace Internal

View File

@@ -32,13 +32,20 @@
***************************************************************************/
#include "cmakeproject.h"
#include "cmakeprojectconstants.h"
#include "cmakeprojectnodes.h"
#include "cmakerunconfiguration.h"
#include "cmakestep.h"
#include "makestep.h"
#include <extensionsystem/pluginmanager.h>
#include <cpptools/cppmodelmanagerinterface.h>
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QProcess>
using namespace CMakeProjectManager;
using namespace CMakeProjectManager::Internal;
@@ -46,27 +53,40 @@ using namespace CMakeProjectManager::Internal;
CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
: m_manager(manager), m_fileName(fileName), m_rootNode(new CMakeProjectNode(m_fileName))
{
//TODO
m_file = new CMakeFile(this, fileName);
QDir dir = QFileInfo(m_fileName).absoluteDir();
QString cbpFile = findCbpFile(dir);
if (cbpFile.isEmpty())
cbpFile = createCbpFile(dir);
//TODO move this parsing to a seperate method, which is also called if the CMakeList.txt is updated
CMakeCbpParser cbpparser;
if (cbpparser.parseCbpFile(cbpFile)) {
// TODO do a intelligent updating of the tree
buildTree(m_rootNode, cbpparser.fileList());
foreach(ProjectExplorer::FileNode *fn, cbpparser.fileList())
foreach (ProjectExplorer::FileNode *fn, cbpparser.fileList())
m_files.append(fn->path());
m_files.sort();
m_targets = cbpparser.targets();
qDebug()<<"Printing targets";
foreach(CMakeTarget ct, m_targets) {
qDebug()<<ct.title<<" with executable:"<<ct.executable;
qDebug()<<"WD:"<<ct.workingDirectory;
qDebug()<<ct.makeCommand<<ct.makeCleanCommand;
qDebug()<<"";
}
CppTools::CppModelManagerInterface *modelmanager = ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>();
if (modelmanager) {
CppTools::CppModelManagerInterface::ProjectInfo *pinfo = modelmanager->projectInfo(this);
pinfo->includePaths = cbpparser.includeFiles();
CppTools::CppModelManagerInterface::ProjectInfo pinfo = modelmanager->projectInfo(this);
pinfo.includePaths = cbpparser.includeFiles();
// TODO we only want C++ files, not all other stuff that might be in the project
pinfo->sourceFiles = m_files;
pinfo.sourceFiles = m_files;
// TODO defines
// TODO gcc preprocessor files
modelmanager->updateProjectInfo(pinfo);
}
} else {
// TODO report error
@@ -84,25 +104,27 @@ QString CMakeProject::findCbpFile(const QDir &directory)
// TODO the cbp file is named like the project() command in the CMakeList.txt file
// so this method below could find the wrong cbp file, if the user changes the project()
// name
foreach(const QString &cbpFile , directory.entryList())
{
if (cbpFile.endsWith(".cbp")) {
foreach (const QString &cbpFile , directory.entryList()) {
if (cbpFile.endsWith(".cbp"))
return directory.path() + "/" + cbpFile;
}
}
return QString::null;
}
QString CMakeProject::createCbpFile(const QDir &)
QString CMakeProject::createCbpFile(const QDir &directory)
{
// TODO create a cbp file.
// Issue: Where to create it? We want to do that in the build directory
// but at this stage we don't know the build directory yet
// So create it in a temp directory?
// Issue: We want to reuse whatever CMakeCache.txt that is alread there, which
// would indicate, creating it in the build directory
// Or we could use a temp directory and use -C builddirectory
// We create a cbp file, only if we didn't find a cbp file in the base directory
// Yet that can still override cbp files in subdirectories
// And we are creating tons of files in the source directories
// All of that is not really nice.
// The mid term plan is to move away from the CodeBlocks Generator and use our own
// QtCreator generator, which actually can be very similar to the CodeBlock Generator
// TODO we need to pass on the same paremeters as the cmakestep
QProcess cmake;
cmake.setWorkingDirectory(directory.absolutePath());
cmake.start("cmake", QStringList() << "-GCodeBlocks - Unix Makefiles");
return QString::null;
}
@@ -110,7 +132,7 @@ void CMakeProject::buildTree(CMakeProjectNode *rootNode, QList<ProjectExplorer::
{
//m_rootNode->addFileNodes(fileList, m_rootNode);
qSort(list.begin(), list.end(), ProjectExplorer::ProjectNode::sortNodesByPath);
foreach( ProjectExplorer::FileNode *fn, list) {
foreach (ProjectExplorer::FileNode *fn, list) {
// Get relative path to rootNode
QString parentDir = QFileInfo(fn->path()).absolutePath();
ProjectExplorer::FolderNode *folder = findOrCreateFolder(rootNode, parentDir);
@@ -124,10 +146,10 @@ ProjectExplorer::FolderNode *CMakeProject::findOrCreateFolder(CMakeProjectNode *
QString relativePath = QDir(QFileInfo(rootNode->path()).path()).relativeFilePath(directory);
QStringList parts = relativePath.split("/");
ProjectExplorer::FolderNode *parent = rootNode;
foreach(const QString &part, parts) {
foreach (const QString &part, parts) {
// Find folder in subFolders
bool found = false;
foreach(ProjectExplorer::FolderNode *folder, parent->subFolderNodes()) {
foreach (ProjectExplorer::FolderNode *folder, parent->subFolderNodes()) {
if (QFileInfo(folder->path()).fileName() == part) {
// yeah found something :)
parent = folder;
@@ -187,7 +209,7 @@ QString CMakeProject::buildDirectory(const QString &buildConfiguration) const
{
Q_UNUSED(buildConfiguration)
//TODO
return "";
return QFileInfo(m_fileName).absolutePath();
}
ProjectExplorer::BuildStepConfigWidget *CMakeProject::createConfigWidget()
@@ -224,13 +246,37 @@ QStringList CMakeProject::files(FilesMode fileMode) const
void CMakeProject::saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer)
{
// TODO
Q_UNUSED(writer)
Project::saveSettingsImpl(writer);
}
void CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader)
{
// TODO
Q_UNUSED(reader)
Project::restoreSettingsImpl(reader);
if (buildConfigurations().isEmpty()) {
// No build configuration, adding those
CMakeStep *cmakeStep = new CMakeStep(this);
MakeStep *makeStep = new MakeStep(this);
insertBuildStep(0, cmakeStep);
insertBuildStep(1, makeStep);
// Create build configurations of m_targets
qDebug()<<"Create build configurations of m_targets";
foreach(const CMakeTarget &ct, m_targets) {
addBuildConfiguration(ct.title);
makeStep->setValue(ct.title, "makeCommand", ct.makeCommand);
makeStep->setValue(ct.title, "makeCleanCommand", ct.makeCleanCommand);
QSharedPointer<ProjectExplorer::RunConfiguration> rc(new CMakeRunConfiguration(this, ct.executable, ct.workingDirectory));
// TODO set build configuration to build before it can be run
addRunConfiguration(rc);
setActiveRunConfiguration(rc); // TODO what exactly shall be the active run configuration?
}
setActiveBuildConfiguration("all");
}
// Restoring is fine
}
@@ -313,7 +359,7 @@ bool CMakeCbpParser::parseCbpFile(const QString &fileName)
if (fi.exists() && fi.open(QFile::ReadOnly)) {
setDevice(&fi);
while(!atEnd()) {
while (!atEnd()) {
readNext();
if (name() == "CodeBlocks_project_file") {
parseCodeBlocks_project_file();
@@ -331,7 +377,7 @@ bool CMakeCbpParser::parseCbpFile(const QString &fileName)
void CMakeCbpParser::parseCodeBlocks_project_file()
{
while(!atEnd()) {
while (!atEnd()) {
readNext();
if (isEndElement()) {
return;
@@ -345,7 +391,7 @@ void CMakeCbpParser::parseCodeBlocks_project_file()
void CMakeCbpParser::parseProject()
{
while(!atEnd()) {
while (!atEnd()) {
readNext();
if (isEndElement()) {
return;
@@ -361,7 +407,7 @@ void CMakeCbpParser::parseProject()
void CMakeCbpParser::parseBuild()
{
while(!atEnd()) {
while (!atEnd()) {
readNext();
if (isEndElement()) {
return;
@@ -375,12 +421,86 @@ void CMakeCbpParser::parseBuild()
void CMakeCbpParser::parseTarget()
{
while(!atEnd()) {
m_targetType = false;
m_target.clear();
if (attributes().hasAttribute("title"))
m_target.title = attributes().value("title").toString();
while (!atEnd()) {
readNext();
if (isEndElement()) {
if (m_targetType || m_target.title == "all") {
m_targets.append(m_target);
}
return;
} else if (name() == "Compiler") {
parseCompiler();
} else if (name() == "Option") {
parseTargetOption();
} else if (isStartElement()) {
parseUnknownElement();
}
}
}
void CMakeCbpParser::parseTargetOption()
{
if (attributes().hasAttribute("output"))
m_target.executable = attributes().value("output").toString();
else if (attributes().hasAttribute("type") && attributes().value("type") == "1")
m_targetType = true;
else if (attributes().hasAttribute("working_dir"))
m_target.workingDirectory = attributes().value("working_dir").toString();
while (!atEnd()) {
readNext();
if (isEndElement()) {
return;
} else if (name() == "MakeCommand") {
parseMakeCommand();
} else if (isStartElement()) {
parseUnknownElement();
}
}
}
void CMakeCbpParser::parseMakeCommand()
{
while (!atEnd()) {
readNext();
if (isEndElement()) {
return;
} else if (name() == "Build") {
parseTargetBuild();
} else if (name() == "Clean") {
parseTargetClean();
} else if (isStartElement()) {
parseUnknownElement();
}
}
}
void CMakeCbpParser::parseTargetBuild()
{
if (attributes().hasAttribute("command"))
m_target.makeCommand = attributes().value("command").toString();
while (!atEnd()) {
readNext();
if (isEndElement()) {
return;
} else if (isStartElement()) {
parseUnknownElement();
}
}
}
void CMakeCbpParser::parseTargetClean()
{
if (attributes().hasAttribute("command"))
m_target.makeCleanCommand = attributes().value("command").toString();
while (!atEnd()) {
readNext();
if (isEndElement()) {
return;
} else if (isStartElement()) {
parseUnknownElement();
}
@@ -389,7 +509,7 @@ void CMakeCbpParser::parseTarget()
void CMakeCbpParser::parseCompiler()
{
while(!atEnd()) {
while (!atEnd()) {
readNext();
if (isEndElement()) {
return;
@@ -404,7 +524,7 @@ void CMakeCbpParser::parseCompiler()
void CMakeCbpParser::parseAdd()
{
m_includeFiles.append(attributes().value("directory").toString());
while(!atEnd()) {
while (!atEnd()) {
readNext();
if (isEndElement()) {
return;
@@ -420,7 +540,7 @@ void CMakeCbpParser::parseUnit()
QString fileName = attributes().value("filename").toString();
if (!fileName.endsWith(".rule"))
m_fileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::SourceType, false));
while(!atEnd()) {
while (!atEnd()) {
readNext();
if (isEndElement()) {
return;
@@ -432,7 +552,7 @@ void CMakeCbpParser::parseUnit()
void CMakeCbpParser::parseUnknownElement()
{
Q_ASSERT(isStartElement());
QTC_ASSERT(isStartElement(), /**/);
while (!atEnd()) {
readNext();
@@ -454,3 +574,18 @@ QStringList CMakeCbpParser::includeFiles()
{
return m_includeFiles;
}
QList<CMakeTarget> CMakeCbpParser::targets()
{
return m_targets;
}
void CMakeTarget::clear()
{
executable = QString::null;
makeCommand = QString::null;
makeCleanCommand = QString::null;
workingDirectory = QString::null;
title = QString::null;
}

View File

@@ -49,6 +49,16 @@ namespace Internal{
class CMakeFile;
struct CMakeTarget
{
QString title;
QString executable;
QString workingDirectory;
QString makeCommand;
QString makeCleanCommand;
void clear();
};
class CMakeProject : public ProjectExplorer::Project
{
Q_OBJECT
@@ -105,6 +115,7 @@ private:
// TODO probably need a CMake specific node structure
CMakeProjectNode* m_rootNode;
QStringList m_files;
QList<CMakeTarget> m_targets;
protected:
virtual void saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer);
@@ -118,11 +129,16 @@ public:
bool parseCbpFile(const QString &fileName);
QList<ProjectExplorer::FileNode *> fileList();
QStringList includeFiles();
QList<CMakeTarget> targets();
private:
void parseCodeBlocks_project_file();
void parseProject();
void parseBuild();
void parseTarget();
void parseTargetOption();
void parseMakeCommand();
void parseTargetBuild();
void parseTargetClean();
void parseCompiler();
void parseAdd();
void parseUnit();
@@ -130,6 +146,10 @@ private:
QList<ProjectExplorer::FileNode *> m_fileList;
QStringList m_includeFiles;
CMakeTarget m_target;
bool m_targetType;
QList<CMakeTarget> m_targets;
};
class CMakeFile : public Core::IFile

View File

@@ -41,6 +41,7 @@ const char * const PROJECTCONTEXT = "CMakeProject.ProjectContext";
const char * const CMAKEMIMETYPE = "text/x-cmake"; // TOOD check that this is correct
const char * const CMAKESTEP = "CMakeProjectManager.CMakeStep";
const char * const MAKESTEP = "CMakeProjectManager.MakeStep";
const char * const CMAKERUNCONFIGURATION = "CMakeProjectManager.CMakeRunConfiguration";
} // namespace Constants

View File

@@ -8,11 +8,13 @@ HEADERS = cmakeproject.h \
cmakeprojectconstants.h \
cmakeprojectnodes.h \
cmakestep.h \
makestep.h
makestep.h \
cmakerunconfiguration.h
SOURCES = cmakeproject.cpp \
cmakeprojectplugin.cpp \
cmakeprojectmanager.cpp \
cmakeprojectnodes.cpp \
cmakestep.cpp \
makestep.cpp
makestep.cpp \
cmakerunconfiguration.cpp
RESOURCES += cmakeproject.qrc

View File

@@ -33,6 +33,7 @@
#include "cmakeprojectplugin.h"
#include "cmakeprojectmanager.h"
#include "cmakerunconfiguration.h"
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
@@ -57,6 +58,7 @@ bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *
if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":cmakeproject/CMakeProject.mimetypes.xml"), errorMessage))
return false;
addAutoReleasedObject(new CMakeManager());
addAutoReleasedObject(new CMakeRunConfigurationFactory());
return true;
}

View File

@@ -0,0 +1,157 @@
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
#include "cmakerunconfiguration.h"
#include "cmakeproject.h"
#include "cmakeprojectconstants.h"
#include <projectexplorer/environment.h>
#include <utils/qtcassert.h>
using namespace CMakeProjectManager;
using namespace CMakeProjectManager::Internal;
CMakeRunConfiguration::CMakeRunConfiguration(CMakeProject *pro, const QString &target, const QString &workingDirectory)
: ProjectExplorer::ApplicationRunConfiguration(pro), m_target(target), m_workingDirectory(workingDirectory)
{
setName(target);
}
CMakeRunConfiguration::~CMakeRunConfiguration()
{
}
QString CMakeRunConfiguration::type() const
{
return Constants::CMAKERUNCONFIGURATION;
}
QString CMakeRunConfiguration::executable() const
{
return m_target;
}
ProjectExplorer::ApplicationRunConfiguration::RunMode CMakeRunConfiguration::runMode() const
{
return ProjectExplorer::ApplicationRunConfiguration::Gui;
}
QString CMakeRunConfiguration::workingDirectory() const
{
return m_workingDirectory;
}
QStringList CMakeRunConfiguration::commandLineArguments() const
{
// TODO
return QStringList();
}
ProjectExplorer::Environment CMakeRunConfiguration::environment() const
{
// TODO
return ProjectExplorer::Environment::systemEnvironment();
}
void CMakeRunConfiguration::save(ProjectExplorer::PersistentSettingsWriter &writer) const
{
ProjectExplorer::ApplicationRunConfiguration::save(writer);
}
void CMakeRunConfiguration::restore(const ProjectExplorer::PersistentSettingsReader &reader)
{
ProjectExplorer::ApplicationRunConfiguration::restore(reader);
}
QWidget *CMakeRunConfiguration::configurationWidget()
{
//TODO
return new QWidget();
}
// Factory
CMakeRunConfigurationFactory::CMakeRunConfigurationFactory()
{
}
CMakeRunConfigurationFactory::~CMakeRunConfigurationFactory()
{
}
// used to recreate the runConfigurations when restoring settings
bool CMakeRunConfigurationFactory::canCreate(const QString &type) const
{
if (type.startsWith(Constants::CMAKERUNCONFIGURATION))
return true;
return false;
}
// used to show the list of possible additons to a project, returns a list of types
QStringList CMakeRunConfigurationFactory::canCreate(ProjectExplorer::Project *project) const
{
CMakeProject *pro = qobject_cast<CMakeProject *>(project);
if (!pro)
return QStringList();
// TODO gather all targets and return them here
return QStringList();
}
// used to translate the types to names to display to the user
QString CMakeRunConfigurationFactory::nameForType(const QString &type) const
{
QTC_ASSERT(type.startsWith(Constants::CMAKERUNCONFIGURATION), /**/);
if (type == Constants::CMAKERUNCONFIGURATION)
return "CMake"; // Doesn't happen
else
return type.mid(QString(Constants::CMAKERUNCONFIGURATION).length());
}
QSharedPointer<ProjectExplorer::RunConfiguration> CMakeRunConfigurationFactory::create(ProjectExplorer::Project *project, const QString &type)
{
CMakeProject *pro = qobject_cast<CMakeProject *>(project);
QTC_ASSERT(pro, /**/);
if (type == Constants::CMAKERUNCONFIGURATION) {
// Restoring, filename will be added by restoreSettings
QSharedPointer<ProjectExplorer::RunConfiguration> rc(new CMakeRunConfiguration(pro, QString::null, QString::null));
return rc;
} else {
// Adding new
QString file = type.mid(QString(Constants::CMAKERUNCONFIGURATION).length());
QSharedPointer<ProjectExplorer::RunConfiguration> rc(new CMakeRunConfiguration(pro, file, QString::null));
return rc;
}
}

View File

@@ -0,0 +1,93 @@
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
#ifndef CMAKERUNCONFIGURATION_H
#define CMAKERUNCONFIGURATION_H
#include <projectexplorer/applicationrunconfiguration.h>
#include <projectexplorer/environment.h>
#include <projectexplorer/persistentsettings.h>
namespace CMakeProjectManager {
namespace Internal {
class CMakeProject;
class CMakeRunConfiguration : public ProjectExplorer::ApplicationRunConfiguration
{
public:
CMakeRunConfiguration(CMakeProject *pro, const QString &target, const QString &workingDirectory);
virtual ~CMakeRunConfiguration();
virtual QString type() const;
virtual QString executable() const;
virtual RunMode runMode() const;
virtual QString workingDirectory() const;
virtual QStringList commandLineArguments() const;
virtual ProjectExplorer::Environment environment() const;
virtual QWidget *configurationWidget();
virtual void save(ProjectExplorer::PersistentSettingsWriter &writer) const;
virtual void restore(const ProjectExplorer::PersistentSettingsReader &reader);
private:
QString m_target;
QString m_workingDirectory;
};
/* The run configuration factory is used for restoring run configurations from
* settings. And used to create new runconfigurations in the "Run Settings" Dialog.
* For the first case bool canCreate(const QString &type) and
* QSharedPointer<RunConfiguration> create(Project *project, QString type) are used.
* For the second type the functions QStringList canCreate(Project *pro) and
* QString nameForType(const QString&) are used to generate a list of creatable
* RunConfigurations, and create(..) is used to create it.
*/
class CMakeRunConfigurationFactory : public QObject
{
Q_OBJECT;
public:
CMakeRunConfigurationFactory();
virtual ~CMakeRunConfigurationFactory();
// used to recreate the runConfigurations when restoring settings
virtual bool canCreate(const QString &type) const;
// used to show the list of possible additons to a project, returns a list of types
virtual QStringList canCreate(ProjectExplorer::Project *pro) const;
// used to translate the types to names to display to the user
virtual QString nameForType(const QString &type) const;
virtual QSharedPointer<ProjectExplorer::RunConfiguration> create(ProjectExplorer::Project *project, const QString &type);
};
}
}
#endif // CMAKERUNCONFIGURATION_H

View File

@@ -32,8 +32,11 @@
***************************************************************************/
#include "cmakestep.h"
#include "cmakeprojectconstants.h"
#include "cmakeproject.h"
#include "cmakeprojectconstants.h"
#include <utils/qtcassert.h>
using namespace CMakeProjectManager;
using namespace CMakeProjectManager::Internal;
@@ -41,12 +44,10 @@ using namespace CMakeProjectManager::Internal;
CMakeStep::CMakeStep(CMakeProject *pro)
: AbstractProcessStep(pro), m_pro(pro)
{
}
CMakeStep::~CMakeStep()
{
}
bool CMakeStep::init(const QString &buildConfiguration)
@@ -54,13 +55,18 @@ bool CMakeStep::init(const QString &buildConfiguration)
setEnabled(buildConfiguration, true);
setWorkingDirectory(buildConfiguration, m_pro->buildDirectory(buildConfiguration));
setCommand(buildConfiguration, "cmake"); // TODO give full path here?
setArguments(buildConfiguration, QStringList()); // TODO
setArguments(buildConfiguration, QStringList() << "-GUnix Makefiles"); // TODO
setEnvironment(buildConfiguration, m_pro->environment(buildConfiguration));
return AbstractProcessStep::init(buildConfiguration);
}
void CMakeStep::run(QFutureInterface<bool> &fi)
{
// TODO we want to only run cmake if the command line arguments or
// the CmakeLists.txt has actually changed
// And we want all of them to share the SAME command line arguments
// Shadow building ruins this, hmm, hmm
//
AbstractProcessStep::run(fi);
}
@@ -109,9 +115,9 @@ bool CMakeBuildStepFactory::canCreate(const QString &name) const
ProjectExplorer::BuildStep *CMakeBuildStepFactory::create(ProjectExplorer::Project *project, const QString &name) const
{
Q_ASSERT(name == Constants::CMAKESTEP);
QTC_ASSERT(name == Constants::CMAKESTEP, /**/);
CMakeProject *pro = qobject_cast<CMakeProject *>(project);
Q_ASSERT(pro);
QTC_ASSERT(pro, /**/);
return new CMakeStep(pro);
}

View File

@@ -35,18 +35,18 @@
#include "cmakeprojectconstants.h"
#include "cmakeproject.h"
#include <utils/qtcassert.h>
using namespace CMakeProjectManager;
using namespace CMakeProjectManager::Internal;
MakeStep::MakeStep(CMakeProject *pro)
: AbstractProcessStep(pro), m_pro(pro)
{
}
MakeStep::~MakeStep()
{
}
bool MakeStep::init(const QString &buildConfiguration)
@@ -109,9 +109,9 @@ bool MakeBuildStepFactory::canCreate(const QString &name) const
ProjectExplorer::BuildStep *MakeBuildStepFactory::create(ProjectExplorer::Project *project, const QString &name) const
{
Q_ASSERT(name == Constants::MAKESTEP);
QTC_ASSERT(name == Constants::MAKESTEP, return 0);
CMakeProject *pro = qobject_cast<CMakeProject *>(project);
Q_ASSERT(pro);
QTC_ASSERT(pro, return 0);
return new MakeStep(pro);
}

View File

@@ -456,7 +456,7 @@ QStringList BaseFileWizard::runWizard(const QString &path, QWidget *parent)
}
}
if (firstExtensionPageHit)
foreach(IFileWizardExtension *ex, extensions)
foreach (IFileWizardExtension *ex, extensions)
ex->firstExtensionPageShown(files);
if (accepted)
break;
@@ -486,7 +486,7 @@ QStringList BaseFileWizard::runWizard(const QString &path, QWidget *parent)
}
}
// Run the extensions
foreach(IFileWizardExtension *ex, extensions)
foreach (IFileWizardExtension *ex, extensions)
if (!ex->process(files, &errorMessage)) {
QMessageBox::critical(parent, tr("File Generation Failure"), errorMessage);
return QStringList();

View File

@@ -47,6 +47,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &initialCategory,
setupUi(this);
buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
splitter->setCollapsible(1, false);
pageTree->header()->setVisible(false);
connect(pageTree, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
@@ -58,8 +59,8 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &initialCategory,
CoreImpl::instance()->pluginManager()->getObjects<IOptionsPage>();
int index = 0;
foreach(IOptionsPage *page, pages) {
QTreeWidgetItem *item = new QTreeWidgetItem();
foreach (IOptionsPage *page, pages) {
QTreeWidgetItem *item = new QTreeWidgetItem;
item->setText(0, page->name());
item->setData(0, Qt::UserRole, index);
@@ -77,7 +78,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &initialCategory,
int catCount = 1;
while (catCount < categoriesId.count()) {
if(!categories.contains(currentCategory + QLatin1Char('|') + categoriesId.at(catCount))) {
if (!categories.contains(currentCategory + QLatin1Char('|') + categoriesId.at(catCount))) {
treeitem = new QTreeWidgetItem(categories.value(currentCategory));
currentCategory += QLatin1Char('|') + categoriesId.at(catCount);
treeitem->setText(0, trCategories.at(catCount));
@@ -123,14 +124,14 @@ void SettingsDialog::pageSelected(QTreeWidgetItem *)
void SettingsDialog::accept()
{
foreach(IOptionsPage *page, m_pages)
foreach (IOptionsPage *page, m_pages)
page->finished(true);
done(QDialog::Accepted);
}
void SettingsDialog::reject()
{
foreach(IOptionsPage *page, m_pages)
foreach (IOptionsPage *page, m_pages)
page->finished(false);
done(QDialog::Rejected);
}

View File

@@ -123,7 +123,7 @@ QWidget *ShortcutSettings::createPage(QWidget *parent)
void ShortcutSettings::finished(bool accepted)
{
if (accepted) {
foreach(ShortcutItem *item, m_scitems) {
foreach (ShortcutItem *item, m_scitems) {
item->m_cmd->setKeySequence(item->m_key);
}
}
@@ -196,7 +196,7 @@ bool ShortcutSettings::filter(const QString &f, const QTreeWidgetItem *item)
if (f.isEmpty())
return false;
for (int i = 0; i < item->columnCount(); ++i) {
if(item->text(i).contains(f, Qt::CaseInsensitive))
if (item->text(i).contains(f, Qt::CaseInsensitive))
return false;
}
return true;
@@ -242,7 +242,7 @@ void ShortcutSettings::importAction()
CommandsFile cf(fileName);
QMap<QString, QKeySequence> mapping = cf.importCommands();
foreach(ShortcutItem *item, m_scitems) {
foreach (ShortcutItem *item, m_scitems) {
QString sid = uidm->stringForUniqueIdentifier(item->m_cmd->id());
if (mapping.contains(sid)) {
item->m_key = mapping.value(sid);
@@ -256,7 +256,7 @@ void ShortcutSettings::importAction()
void ShortcutSettings::defaultAction()
{
foreach(ShortcutItem *item, m_scitems) {
foreach (ShortcutItem *item, m_scitems) {
item->m_key = item->m_cmd->defaultKeySequence();
item->m_item->setText(2, item->m_key);
if (item->m_item == m_page->commandList->currentItem())

View File

@@ -32,15 +32,18 @@
***************************************************************************/
#include "editorgroup.h"
#include "editormanager.h"
#include <coreplugin/coreconstants.h>
#include <utils/qtcassert.h>
#include <QtCore/QDir>
#include <QtCore/QDebug>
#include <QtGui/QPainter>
#include <QtGui/QStyle>
#include <QtGui/QStyleOption>
#include <QtCore/QtDebug>
#ifdef Q_WS_MAC
#include <QtGui/QMacStyle>
#endif
@@ -107,20 +110,20 @@ QVariant EditorModel::data(const QModelIndex &index, int role) const
if (!index.isValid())
return QVariant();
IEditor *editor = m_editors.at(index.row());
Q_ASSERT(editor);
QTC_ASSERT(editor, return QVariant());
switch (role) {
case Qt::DisplayRole:
return editor->file()->isModified()
?editor->displayName()+QLatin1String("*")
:editor->displayName();
? editor->displayName() + QLatin1String("*")
: editor->displayName();
case Qt::DecorationRole:
return editor->file()->isReadOnly()
?QIcon(QLatin1String(":/qworkbench/images/locked.png"))
:QIcon();
? QIcon(QLatin1String(":/qworkbench/images/locked.png"))
: QIcon();
case Qt::ToolTipRole:
return editor->file()->fileName().isEmpty()
?editor->displayName()
:QDir::toNativeSeparators(editor->file()->fileName());
? editor->displayName()
: QDir::toNativeSeparators(editor->file()->fileName());
case Qt::UserRole:
return qVariantFromValue(editor);
default:
@@ -145,6 +148,7 @@ EditorGroupContext::EditorGroupContext(EditorGroup *editorGroup)
m_editorGroup(editorGroup)
{
}
QList<int> EditorGroupContext::context() const
{
return m_context;

View File

@@ -53,21 +53,23 @@
#include <coreplugin/baseview.h>
#include <coreplugin/imode.h>
#include <QtCore/QFileInfo>
#include <QtCore/QSettings>
#include <QtCore/QMap>
#include <QtCore/QSet>
#include <QtCore/QProcess>
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtCore/QFileInfo>
#include <QtCore/QMap>
#include <QtCore/QProcess>
#include <QtCore/QSet>
#include <QtCore/QSettings>
#include <QtGui/QAction>
#include <QtGui/QLayout>
#include <QtGui/QApplication>
#include <QtGui/QSplitter>
#include <QtGui/QFileDialog>
#include <QtGui/QLayout>
#include <QtGui/QMenu>
#include <QtGui/QMessageBox>
#include <QtGui/QPushButton>
#include <QtGui/QSplitter>
using namespace Core;
using namespace Core::Internal;
@@ -961,11 +963,10 @@ bool EditorManager::hasEditor(const QString &fileName) const
void EditorManager::restoreEditorState(IEditor *editor)
{
Q_ASSERT(editor);
QTC_ASSERT(editor, return);
QString fileName = editor->file()->fileName();
if (m_d->m_editorStates.contains(fileName)) {
if (m_d->m_editorStates.contains(fileName))
editor->restoreState(m_d->m_editorStates.value(fileName).toByteArray());
}
}
bool EditorManager::saveEditor(IEditor *editor)
@@ -1089,7 +1090,7 @@ bool EditorManager::saveFileAs(IEditor *editor)
const bool success = editor->file()->save(absoluteFilePath);
m_d->m_core->fileManager()->unblockFileChange(editor->file());
if(success)
if (success)
m_d->m_core->fileManager()->addToRecentFiles(editor->file()->fileName());
updateActions();

View File

@@ -32,16 +32,19 @@
***************************************************************************/
#include "editorsplitter.h"
#include "editormanager.h"
#include "minisplitter.h"
#include "openeditorswindow.h"
#include "stackededitorgroup.h"
#include "minisplitter.h"
#include <coreplugin/icore.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/actionmanager/actionmanagerinterface.h>
#include <utils/qtcassert.h>
#include <QtGui/QHBoxLayout>
#include <QtGui/QMenu>
#include <QtGui/QApplication>
@@ -160,7 +163,7 @@ void EditorSplitter::registerActions()
void EditorSplitter::updateActions()
{
const bool hasMultipleGroups = (qobject_cast<QSplitter*>(m_root) != 0);
Q_ASSERT(currentGroup());
QTC_ASSERT(currentGroup(), return);
const bool hasEditors = (currentGroup()->editorCount() != 0);
m_unsplitAction->setEnabled(hasMultipleGroups);
#if 0
@@ -245,7 +248,7 @@ void EditorSplitter::collectGroups(QWidget *widget, QList<EditorGroup*> &groups)
return;
}
QSplitter *splitter = qobject_cast<QSplitter*>(widget);
Q_ASSERT(splitter);
QTC_ASSERT(splitter, return);
collectGroups(splitter->widget(LEFT), groups);
collectGroups(splitter->widget(RIGHT), groups);
}
@@ -330,7 +333,7 @@ void EditorSplitter::unsplit()
if (!curGroup)
return;
QWidget *curGroupWidget = curGroup->widget();
Q_ASSERT(curGroupWidget);
QTC_ASSERT(curGroupWidget, return);
IEditor *selectedEditor = curGroup->currentEditor();
QSplitter *parentSplitter = qobject_cast<QSplitter*>(curGroupWidget->parentWidget());
@@ -454,25 +457,25 @@ EditorGroup *EditorSplitter::groupFarthestOnSide(QWidget *node, Side side) const
void EditorSplitter::selectNextGroup()
{
EditorGroup *curGroup = currentGroup();
Q_ASSERT(curGroup);
QTC_ASSERT(curGroup, return);
setCurrentGroup(nextGroup(curGroup, RIGHT));
}
void EditorSplitter::selectPreviousGroup()
{
EditorGroup *curGroup = currentGroup();
Q_ASSERT(curGroup);
QTC_ASSERT(curGroup, return);
setCurrentGroup(nextGroup(curGroup, LEFT));
}
EditorGroup *EditorSplitter::nextGroup(EditorGroup *curGroup, Side side) const
{
Q_ASSERT(curGroup);
QTC_ASSERT(curGroup, return 0);
QWidget *curWidget = curGroup->widget();
QWidget *parent = curWidget->parentWidget();
while (curWidget != m_root) {
QSplitter *splitter = qobject_cast<QSplitter *>(parent);
Q_ASSERT(splitter);
QTC_ASSERT(splitter, return 0);
if (splitter->widget(side) != curWidget) {
curWidget = splitter->widget(side);
break;
@@ -486,7 +489,7 @@ EditorGroup *EditorSplitter::nextGroup(EditorGroup *curGroup, Side side) const
void EditorSplitter::moveDocToAdjacentGroup(Side side)
{
EditorGroup *curGroup = currentGroup();
Q_ASSERT(curGroup);
QTC_ASSERT(curGroup, return);
IEditor *editor = curGroup->currentEditor();
if (!editor)
return;
@@ -510,7 +513,7 @@ QWidget *EditorSplitter::recreateGroupTree(QWidget *node)
QSplitter *splitter = qobject_cast<QSplitter *>(node);
if (!splitter) {
EditorGroup *group = qobject_cast<EditorGroup *>(node);
Q_ASSERT(group);
QTC_ASSERT(group, return 0);
IEditor *currentEditor = group->currentEditor();
EditorGroup *newGroup = createGroup();
bool block = newGroup->widget()->blockSignals(true);
@@ -588,7 +591,7 @@ void EditorSplitter::saveState(QWidget *current, QDataStream &stream) const
saveState(splitter->widget(1), stream);
} else {
EditorGroup *group = qobject_cast<EditorGroup *>(current);
Q_ASSERT(group);
QTC_ASSERT(group, /**/);
if (group != currentGroup())
type = 1;
else
@@ -639,7 +642,7 @@ void EditorSplitter::fillPathGroupMap(QWidget *current, QString currentPath,
map.insert(currentPath, group);
} else {
QSplitter *splitter = qobject_cast<QSplitter *>(current);
Q_ASSERT(splitter);
QTC_ASSERT(splitter, return);
fillPathGroupMap(splitter->widget(0), currentPath+"0", map);
fillPathGroupMap(splitter->widget(1), currentPath+"1", map);
}

View File

@@ -100,4 +100,4 @@ signals:
} // namespace Core
#endif //IEDITOR_H
#endif // IEDITOR_H

View File

@@ -39,6 +39,7 @@
#include <coreplugin/coreconstants.h>
#include <coreplugin/filemanager.h>
#include <coreplugin/uniqueidmanager.h>
#include <utils/qtcassert.h>
#include <QtCore/QTimer>
#include <QtGui/QMenu>
@@ -70,7 +71,7 @@ OpenEditorsWidget::OpenEditorsWidget()
m_ui.editorList->installEventFilter(this);
m_ui.editorList->setFrameStyle(QFrame::NoFrame);
EditorManager *em = EditorManager::instance();
foreach(IEditor *editor, em->openedEditors()) {
foreach (IEditor *editor, em->openedEditors()) {
registerEditor(editor);
}
connect(em, SIGNAL(editorOpened(Core::IEditor*)),
@@ -197,7 +198,7 @@ void OpenEditorsWidget::selectEditor(QTreeWidgetItem *item)
void OpenEditorsWidget::updateEditor()
{
IEditor *editor = qobject_cast<IEditor *>(sender());
Q_ASSERT(editor);
QTC_ASSERT(editor, return);
int num = m_ui.editorList->topLevelItemCount();
for (int i = 0; i < num; ++i) {
QTreeWidgetItem *item = m_ui.editorList->topLevelItem(i);

View File

@@ -35,21 +35,24 @@
#include "editormanager.h"
#include "coreimpl.h"
#include <QtCore/QFileInfo>
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
#include <QtCore/QMimeData>
#include <QtGui/QApplication>
#include <QtGui/QComboBox>
#include <QtGui/QHBoxLayout>
#include <QtGui/QLabel>
#include <QtGui/QMouseEvent>
#include <QtGui/QPainter>
#include <QtGui/QStackedWidget>
#include <QtGui/QStyle>
#include <QtGui/QStyleOption>
#include <QtGui/QMouseEvent>
#include <QtGui/QApplication>
#include <QtGui/QToolBar>
#include <QtGui/QToolButton>
#include <QtGui/QLabel>
#include <QtGui/QStackedWidget>
#include <QtDebug>
#ifdef Q_WS_MAC
#include <qmacstyle_mac.h>
#endif
@@ -240,7 +243,7 @@ void StackedEditorGroup::sendCloseRequest()
void StackedEditorGroup::removeEditor(IEditor *editor)
{
Q_ASSERT(editor);
QTC_ASSERT(editor, return);
EditorGroup::removeEditor(editor);
const int index = m_container->indexOf(editor->widget());
if (index != -1) {
@@ -280,7 +283,7 @@ void StackedEditorGroup::setCurrentEditor(IEditor *editor)
return;
m_toplevel->setVisible(true);
const int idx = m_container->indexOf(editor->widget());
Q_ASSERT(idx >= 0);
QTC_ASSERT(idx >= 0, return);
if (m_container->currentIndex() != idx) {
m_container->setCurrentIndex(idx);
@@ -298,10 +301,11 @@ void StackedEditorGroup::setCurrentEditor(IEditor *editor)
}
}
void StackedEditorGroup::updateEditorStatus(IEditor *editor) {
void StackedEditorGroup::updateEditorStatus(IEditor *editor)
{
if (!editor)
editor = qobject_cast<IEditor *>(sender());
Q_ASSERT(editor);
QTC_ASSERT(editor, return);
static const QIcon lockedIcon(QLatin1String(":/qworkbench/images/locked.png"));
static const QIcon unlockedIcon(QLatin1String(":/qworkbench/images/unlocked.png"));
@@ -371,6 +375,6 @@ int StackedEditorGroup::indexOf(IEditor *editor)
if (editor == model->data(model->index(i, 0), Qt::UserRole).value<IEditor*>())
return i;
}
Q_ASSERT(false);
QTC_ASSERT(false, /**/);
return 0;
}

View File

@@ -96,7 +96,7 @@ void FileIconProvider::registerIconForSuffix(const QIcon &icon, const QString &s
{
// delete old icon, if it exists
QList<QPair<QString,QIcon> >::iterator iter = m_cache.begin();
for(; iter != m_cache.end(); ++iter) {
for (; iter != m_cache.end(); ++iter) {
if ((*iter).first == suffix) {
iter = m_cache.erase(iter);
break;
@@ -118,7 +118,7 @@ QIcon FileIconProvider::iconForSuffix(const QString &suffix) const
return icon;
QList<QPair<QString,QIcon> >::const_iterator iter = m_cache.constBegin();
for(; iter != m_cache.constEnd(); ++iter) {
for (; iter != m_cache.constEnd(); ++iter) {
if ((*iter).first == suffix) {
icon = (*iter).second;
break;

View File

@@ -32,6 +32,7 @@
***************************************************************************/
#include "filemanager.h"
#include "ifile.h"
#include "mainwindow.h"
#include "saveitemsdialog.h"
@@ -40,6 +41,8 @@
#include "mimedatabase.h"
#include "iversioncontrol.h"
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtCore/QSettings>
#include <QtCore/QFileInfo>
@@ -177,22 +180,20 @@ bool FileManager::removeFile(IFile *file)
void FileManager::addWatch(const QString &filename)
{
if (!filename.isEmpty() && managedFiles(filename).isEmpty()) {
if (!filename.isEmpty() && managedFiles(filename).isEmpty())
m_fileWatcher->addPath(filename);
}
}
void FileManager::removeWatch(const QString &filename)
{
if (!filename.isEmpty() && managedFiles(filename).isEmpty()) {
if (!filename.isEmpty() && managedFiles(filename).isEmpty())
m_fileWatcher->removePath(filename);
}
}
void FileManager::checkForNewFileName()
{
IFile *file = qobject_cast<IFile *>(sender());
Q_ASSERT(file);
QTC_ASSERT(file, return);
const QString newfilename = fixFileName(file->fileName());
const QString oldfilename = m_managedFiles.value(file).fileName;
if (!newfilename.isEmpty() && newfilename != oldfilename) {

View File

@@ -896,7 +896,7 @@ void MainWindow::removeContextObject(IContext *context)
return;
m_contextWidgets.remove(widget);
if(m_activeContext == context)
if (m_activeContext == context)
updateContextObject(0);
}
@@ -957,10 +957,11 @@ void MainWindow::resetContext()
updateContextObject(0);
}
QMenu *MainWindow::createPopupMenu() {
QMenu *MainWindow::createPopupMenu()
{
QMenu *menu = new QMenu(this);
QList<ActionContainer *> containers = m_actionManager->containers();
foreach(ActionContainer *c, containers) {
foreach (ActionContainer *c, containers) {
if (c->toolBar())
menu->addAction(c->toolBar()->toggleViewAction());
}

View File

@@ -33,30 +33,34 @@
#include "manhattanstyle.h"
#include <QStyleOption>
#include <QPainter>
#include <QScrollArea>
#include <QMainWindow>
#include <QDockWidget>
#include <QPixmapCache>
#include <QDialogButtonBox>
#include <QPixmap>
#include <QToolBar>
#include <QDialog>
#include <QLineEdit>
#include <QComboBox>
#include <QLibrary>
#include <QStatusBar>
#include <QApplication>
#include <QStyleFactory>
#include <QToolButton>
#include <QLabel>
#include <QPushButton>
#include <QSplitter>
#include <QMenuBar>
#include "stylehelper.h"
#include "styleanimator.h"
#include <qdebug.h>
#include <QtCore/QDebug>
#include <QtCore/QLibrary>
#include <QtGui/QApplication>
#include <QtGui/QComboBox>
#include <QtGui/QDialog>
#include <QtGui/QDialogButtonBox>
#include <QtGui/QDockWidget>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QMainWindow>
#include <QtGui/QMenuBar>
#include <QtGui/QPainter>
#include <QtGui/QPixmap>
#include <QtGui/QPixmapCache>
#include <QtGui/QPushButton>
#include <QtGui/QScrollArea>
#include <QtGui/QSplitter>
#include <QtGui/QStatusBar>
#include <QtGui/QStyleFactory>
#include <QtGui/QStyleOption>
#include <QtGui/QToolBar>
#include <QtGui/QToolButton>
#include <utils/qtcassert.h>
// We define a currently unused state for indicating animations
#define State_Animating 0x00000040
@@ -97,7 +101,7 @@ public:
ManhattanStylePrivate(const QString &baseStyleName)
{
style = QStyleFactory::create(baseStyleName);
Q_ASSERT(style);
QTC_ASSERT(style, /**/);
buttonImage_pressed = QImage(":/qworkbench/images/pushbutton_pressed.png");
buttonImage = QImage(":/qworkbench/images/pushbutton.png");
@@ -105,12 +109,15 @@ public:
lineeditImage_disabled = QImage(":/qworkbench/images/inputfield_disabled.png");
}
~ManhattanStylePrivate() {
~ManhattanStylePrivate()
{
delete style;
style = 0;
}
void init();
public:
QStyle *style;
QImage buttonImage;
QImage buttonImage_pressed;
@@ -140,7 +147,7 @@ void drawCornerImage(const QImage &img, QPainter *painter, QRect rect,
if (top > 0) { //top
painter->drawImage(QRect(rect.left() + left, rect.top(), rect.width() -right - left, top), img,
QRect(left, 0, size.width() -right - left, top));
if(left > 0) //top-left
if (left > 0) //top-left
painter->drawImage(QRect(rect.left(), rect.top(), left, top), img,
QRect(0, 0, left, top));
if (right > 0) //top-right

View File

@@ -33,19 +33,22 @@
#include "mimedatabase.h"
#include <QtCore/QStringList>
#include <utils/qtcassert.h>
#include <QtCore/QByteArray>
#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QLocale>
#include <QtCore/QMap>
#include <QtCore/QMultiHash>
#include <QtCore/QDebug>
#include <QtCore/QRegExp>
#include <QtCore/QCoreApplication>
#include <QtCore/QFileInfo>
#include <QtCore/QByteArray>
#include <QtCore/QSharedData>
#include <QtCore/QSharedPointer>
#include <QtCore/QStringList>
#include <QtCore/QTextStream>
#include <QtCore/QLocale>
#include <QtXml/QXmlStreamReader>
enum { debugMimeDB = 0 };
@@ -299,7 +302,7 @@ void MimeTypeData::debug(QTextStream &str, int indent) const
str << indentS << "SubClassesOf: " << subClassesOf.join(comma) << '\n';
if (!globPatterns.empty()) {
str << indentS << "Glob: ";
foreach(const QRegExp &r, globPatterns)
foreach (const QRegExp &r, globPatterns)
str << r.pattern() << ' ';
str << '\n';
if (!suffixes.empty()) {
@@ -574,7 +577,7 @@ BaseMimeTypeParser:: BaseMimeTypeParser() :
// "*.log[1-9]"
m_suffixPattern(QLatin1String("^\\*\\.[\\w]+$"))
{
Q_ASSERT(m_suffixPattern.isValid());
QTC_ASSERT(m_suffixPattern.isValid(), /**/);
}
void BaseMimeTypeParser::addGlobPattern(const QString &pattern, MimeTypeData *d) const

View File

@@ -32,11 +32,13 @@
***************************************************************************/
#include "modemanager.h"
#include "fancytabwidget.h"
#include "fancyactionbar.h"
#include "mainwindow.h"
#include <aggregation/aggregate.h>
#include <coreplugin/actionmanager/actionmanagerinterface.h>
#include <coreplugin/actionmanager/icommand.h>
#include <coreplugin/coreconstants.h>
@@ -44,9 +46,12 @@
#include <coreplugin/imode.h>
#include <coreplugin/uniqueidmanager.h>
#include <utils/qtcassert.h>
#include <QtCore/QObject>
#include <QtCore/QDebug>
#include <QtCore/QSignalMapper>
#include <QtGui/QAction>
#include <QtGui/QTabWidget>
#include <QtGui/QVBoxLayout>
@@ -225,7 +230,7 @@ void ModeManager::currentTabChanged(int index)
void ModeManager::setFocusToCurrentMode()
{
IMode *mode = currentMode();
Q_ASSERT(mode);
QTC_ASSERT(mode, return);
QWidget *widget = mode->widget();
if (widget) {
QWidget *focusWidget = widget->focusWidget();

View File

@@ -87,8 +87,8 @@ void NavigationWidgetPlaceHolder::applyStoredSize(int width)
QList<int> sizes = splitter->sizes();
int index = splitter->indexOf(this);
int diff = width - sizes.at(index);
int adjust = sizes.count() > 1? ( diff / (sizes.count() - 1)) : 0;
for(int i=0; i<sizes.count(); ++i) {
int adjust = sizes.count() > 1 ? (diff / (sizes.count() - 1)) : 0;
for (int i = 0; i < sizes.count(); ++i) {
if (i != index)
sizes[i] += adjust;
}

View File

@@ -277,7 +277,7 @@ void OutputPane::init(ICore *core, ExtensionSystem::PluginManager *pm)
connect(cmd->action(), SIGNAL(triggered()), this, SLOT(shortcutTriggered()));
connect(cmd->action(), SIGNAL(changed()), this, SLOT(updateToolTip()));
} while(it != begin);
} while (it != begin);
changePage();
}
@@ -293,7 +293,7 @@ void OutputPane::shortcutTriggered()
// but the outputpane doesn't have focus
// then just give it focus
// else do the same as clicking on the button does
if(OutputPanePlaceHolder::m_current
if (OutputPanePlaceHolder::m_current
&& OutputPanePlaceHolder::m_current->isVisible()
&& m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt() == idx) {
if (!outputPane->hasFocus() && outputPane->canFocus())

View File

@@ -40,11 +40,13 @@
#include "uniqueidmanager.h"
#include "viewmanagerinterface.h"
#include <utils/qtcassert.h>
using namespace Core;
using namespace Core::Internal;
ProgressManager::ProgressManager(QObject *parent) :
ProgressManagerInterface(parent)
ProgressManager::ProgressManager(QObject *parent)
: ProgressManagerInterface(parent)
{
m_progressView = new ProgressView;
ICore *core = CoreImpl::instance();
@@ -103,7 +105,7 @@ QWidget *ProgressManager::progressView()
void ProgressManager::taskFinished()
{
QObject *taskObject = sender();
Q_ASSERT(taskObject);
QTC_ASSERT(taskObject, return);
QFutureWatcher<void> *task = static_cast<QFutureWatcher<void> *>(taskObject);
m_runningTasks.remove(task);
delete task;

View File

@@ -101,9 +101,9 @@ void ProgressBar::paintEvent(QPaintEvent *)
double percent = 0.50;
if (range != 0)
percent = (value() - minimum()) / range;
if(percent > 1)
if (percent > 1)
percent = 1;
else if(percent < 0)
else if (percent < 0)
percent = 0;
QPainter p(this);

View File

@@ -34,6 +34,8 @@
#include "progressview.h"
#include "futureprogress.h"
#include <utils/qtcassert.h>
#include <QtGui/QHBoxLayout>
using namespace Core;
@@ -136,7 +138,7 @@ void ProgressView::removeTask(FutureProgress *task)
void ProgressView::slotFinished()
{
FutureProgress *progress = qobject_cast<FutureProgress *>(sender());
Q_ASSERT(progress);
QTC_ASSERT(progress, return);
if (m_keep.contains(progress) && !m_keep.value(progress) && !progress->hasError())
removeTask(progress);
removeOldTasks(m_type.value(progress), true);

View File

@@ -76,8 +76,8 @@ void RightPanePlaceHolder::applyStoredSize(int width)
QList<int> sizes = splitter->sizes();
int index = splitter->indexOf(this);
int diff = width - sizes.at(index);
int adjust = sizes.count() > 1? ( diff / (sizes.count() - 1)) : 0;
for(int i=0; i<sizes.count(); ++i) {
int adjust = sizes.count() > 1 ? (diff / (sizes.count() - 1)) : 0;
for (int i = 0; i < sizes.count(); ++i) {
if (i != index)
sizes[i] -= adjust;
}
@@ -125,7 +125,7 @@ void RightPanePlaceHolder::currentModeChanged(Core::IMode *mode)
RightPaneWidget *RightPaneWidget::m_instance = 0;
RightPaneWidget::RightPaneWidget()
:m_shown(true), m_width(0)
: m_shown(true), m_width(0)
{
m_instance = this;

View File

@@ -38,12 +38,15 @@
#include <coreplugin/messagemanager.h>
#include <coreplugin/editormanager/editorgroup.h>
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtCore/QSettings>
#include <QtGui/QMainWindow>
#include <QtGui/QStatusBar>
#include <QtGui/QToolBar>
#include <QtScript/QScriptEngine>
namespace {
@@ -107,7 +110,7 @@ QString CorePrototype::toString() const
CorePrototype::ICore *CorePrototype::callee() const
{
ICore *rc = qscriptvalue_cast<ICore *>(thisObject());
Q_ASSERT(rc);
QTC_ASSERT(rc, return 0);
return rc;
}
@@ -121,14 +124,14 @@ MessageManagerPrototype::MessageManagerPrototype(QObject *parent) :
void MessageManagerPrototype::displayStatusBarMessage(const QString &text, int ms)
{
MessageManager *mm = qscriptvalue_cast<MessageManager *>(thisObject());
Q_ASSERT(mm);
QTC_ASSERT(mm, return);
mm->displayStatusBarMessage(text, ms);
}
void MessageManagerPrototype::printToOutputPane(const QString &text, bool bringToForeground)
{
MessageManager *mm = qscriptvalue_cast<MessageManager *>(thisObject());
Q_ASSERT(mm);
QTC_ASSERT(mm, return);
mm->printToOutputPane(text, bringToForeground);
}
@@ -147,28 +150,66 @@ FileManagerPrototype::FileManagerPrototype(QObject *parent) :
FileManager *FileManagerPrototype::callee() const
{
FileManager *rc = qscriptvalue_cast<FileManager *>(thisObject());
Q_ASSERT(rc);
QTC_ASSERT(rc, return 0);
return rc;
}
bool FileManagerPrototype::addFiles(const QList<Core::IFile *> &files) { return callee()->addFiles(files); }
bool FileManagerPrototype::addFile(Core::IFile *file) { return callee()->addFile(file); }
bool FileManagerPrototype::removeFile(Core::IFile *file) { return callee()->removeFile(file); }
bool FileManagerPrototype::addFiles(const QList<Core::IFile *> &files)
{
return callee()->addFiles(files);
}
bool FileManagerPrototype::addFile(Core::IFile *file)
{
return callee()->addFile(file);
}
bool FileManagerPrototype::removeFile(Core::IFile *file)
{
return callee()->removeFile(file);
}
QList<Core::IFile*>
FileManagerPrototype::saveModifiedFilesSilently(const QList<Core::IFile*> &files) { return callee()->saveModifiedFilesSilently(files); }
FileManagerPrototype::saveModifiedFilesSilently(const QList<Core::IFile*> &files)
{
return callee()->saveModifiedFilesSilently(files);
}
QString FileManagerPrototype::getSaveAsFileName(Core::IFile *file) { return callee()->getSaveAsFileName(file); }
QString FileManagerPrototype::getSaveAsFileName(Core::IFile *file)
{
return callee()->getSaveAsFileName(file);
}
bool FileManagerPrototype::isFileManaged(const QString &fileName) const
{
return callee()->isFileManaged(fileName);
}
bool FileManagerPrototype::isFileManaged(const QString &fileName) const { return callee()->isFileManaged(fileName); }
QList<Core::IFile *>
FileManagerPrototype::managedFiles(const QString &fileName) const { return callee()->managedFiles(fileName); }
FileManagerPrototype::managedFiles(const QString &fileName) const
{
return callee()->managedFiles(fileName);
}
void FileManagerPrototype::blockFileChange(Core::IFile *file) { callee()->blockFileChange(file); }
void FileManagerPrototype::unblockFileChange(Core::IFile *file) { return callee()->unblockFileChange(file); }
void FileManagerPrototype::blockFileChange(Core::IFile *file)
{
callee()->blockFileChange(file);
}
void FileManagerPrototype::addToRecentFiles(const QString &fileName) { return callee()->addToRecentFiles(fileName); }
QStringList FileManagerPrototype::recentFiles() const { return callee()->recentFiles(); }
void FileManagerPrototype::unblockFileChange(Core::IFile *file)
{
return callee()->unblockFileChange(file);
}
void FileManagerPrototype::addToRecentFiles(const QString &fileName)
{
return callee()->addToRecentFiles(fileName);
}
QStringList FileManagerPrototype::recentFiles() const
{
return callee()->recentFiles();
}
QString FileManagerPrototype::toString() const
{
@@ -185,7 +226,7 @@ FilePrototype::FilePrototype(QObject *parent) :
IFile *FilePrototype::callee() const
{
IFile *rc = qscriptvalue_cast<IFile *>(thisObject());
Q_ASSERT(rc);
QTC_ASSERT(rc, return 0);
return rc;
}
@@ -270,39 +311,66 @@ QString EditorManagerPrototype::toString() const
EditorManagerPrototype::EditorManager *EditorManagerPrototype::callee() const
{
EditorManager *rc = qscriptvalue_cast<EditorManager *>(thisObject());
Q_ASSERT(rc);
QTC_ASSERT(rc, return 0);
return rc;
}
// ------------- EditorPrototype
EditorPrototype::EditorPrototype(QObject *parent) :
QObject(parent)
EditorPrototype::EditorPrototype(QObject *parent)
: QObject(parent)
{
}
QString EditorPrototype::displayName() const { return callee()->displayName(); }
void EditorPrototype::setDisplayName(const QString &title) { callee()->setDisplayName(title); }
QString EditorPrototype::displayName() const
{
return callee()->displayName();
}
QString EditorPrototype::kind() const { return QLatin1String(callee()->kind()); }
bool EditorPrototype::duplicateSupported() const { return callee()->duplicateSupported(); }
void EditorPrototype::setDisplayName(const QString &title)
{
callee()->setDisplayName(title);
}
bool EditorPrototype::createNew(const QString &contents) { return callee()->createNew(contents); }
bool EditorPrototype::open(const QString &fileName) { return callee()->open(fileName); }
QString EditorPrototype::kind() const
{
return QLatin1String(callee()->kind());
}
bool EditorPrototype::duplicateSupported() const
{
return callee()->duplicateSupported();
}
bool EditorPrototype::createNew(const QString &contents)
{
return callee()->createNew(contents);
}
bool EditorPrototype::open(const QString &fileName)
{
return callee()->open(fileName);
}
Core::IEditor *EditorPrototype::duplicate(QWidget *parent)
{
return callee()->duplicate(parent);
}
Core::IFile *EditorPrototype::file() const { return callee()->file(); }
QToolBar* EditorPrototype::toolBar() const { return callee()->toolBar();}
Core::IFile *EditorPrototype::file() const
{
return callee()->file();
}
QToolBar* EditorPrototype::toolBar() const
{
return callee()->toolBar();
}
Core::IEditor *EditorPrototype::callee() const
{
IEditor *rc = qscriptvalue_cast<IEditor *>(thisObject());
Q_ASSERT(rc);
QTC_ASSERT(rc, return 0);
return rc;
}
@@ -375,7 +443,7 @@ QString EditorGroupPrototype::toString() const
Core::EditorGroup *EditorGroupPrototype::callee() const
{
EditorGroup *rc = qscriptvalue_cast<EditorGroup *>(thisObject());
Q_ASSERT(rc);
QTC_ASSERT(rc, return 0);
return rc;
}

View File

@@ -36,8 +36,10 @@
#include "metatypedeclarations.h"
#include <extensionsystem/ExtensionSystemInterfaces>
#include <utils/qtcassert.h>
#include <interface_wrap_helpers.h>
#include <wrap_helpers.h>
#include <limits.h>
#include <QtCore/QDebug>
@@ -154,7 +156,7 @@ static QScriptValue inputDialogGetItem(QScriptContext *context, QScriptEngine *e
// Script function template to pop up a file box
// with a certain icon and buttons.
template <int TAcceptMode, int TFileMode>
static QScriptValue fileBox(QScriptContext *context, QScriptEngine *engine)
static QScriptValue fileBox(QScriptContext *context, QScriptEngine *engine)
{
const int argumentCount = context->argumentCount();
if (argumentCount < 2)
@@ -170,7 +172,7 @@ template <int TAcceptMode, int TFileMode>
if (fileDialog.exec() == QDialog::Rejected)
return QScriptValue(engine, QScriptValue::NullValue);
const QStringList rc = fileDialog.selectedFiles();
Q_ASSERT(!rc.empty());
QTC_ASSERT(!rc.empty(), /**/);
return TFileMode == QFileDialog::ExistingFiles ?
engine->toScriptValue(rc) : engine->toScriptValue(rc.front());
}
@@ -249,7 +251,7 @@ void ScriptManager::ensureEngineInitialized()
{
if (m_initialized)
return;
Q_ASSERT(m_core);
QTC_ASSERT(m_core, return);
// register QObjects that occur as properties
SharedTools::registerQObject<QMainWindow>(m_engine);
SharedTools::registerQObject<QStatusBar>(m_engine);

View File

@@ -52,7 +52,8 @@ void Animation::paint(QPainter *painter, const QStyleOption *option)
Q_UNUSED(painter);
}
void Animation::drawBlendedImage(QPainter *painter, QRect rect, float alpha) {
void Animation::drawBlendedImage(QPainter *painter, QRect rect, float alpha)
{
if (_secondaryImage.isNull() || _primaryImage.isNull())
return;
@@ -64,7 +65,7 @@ void Animation::drawBlendedImage(QPainter *painter, QRect rect, float alpha) {
const int sw = _primaryImage.width();
const int sh = _primaryImage.height();
const int bpl = _primaryImage.bytesPerLine();
switch(_primaryImage.depth()) {
switch (_primaryImage.depth()) {
case 32:
{
uchar *mixed_data = _tempImage.bits();

View File

@@ -77,7 +77,7 @@ void VCSManager::setVCSEnabled(const QString &directory)
qDebug() << Q_FUNC_INFO << directory;
IVersionControl* managingVCS = findVersionControlForDirectory(directory);
const VersionControlList versionControls = allVersionControls();
foreach(IVersionControl *versionControl, versionControls) {
foreach (IVersionControl *versionControl, versionControls) {
const bool newEnabled = versionControl == managingVCS;
if (newEnabled != versionControl->isEnabled())
versionControl->setEnabled(newEnabled);
@@ -89,7 +89,7 @@ void VCSManager::setAllVCSEnabled()
if (debug)
qDebug() << Q_FUNC_INFO;
const VersionControlList versionControls = allVersionControls();
foreach(IVersionControl *versionControl, versionControls)
foreach (IVersionControl *versionControl, versionControls)
if (!versionControl->isEnabled())
versionControl->setEnabled(true);
}
@@ -106,7 +106,7 @@ IVersionControl* VCSManager::findVersionControlForDirectory(const QString &direc
int pos = 0;
const QChar slash = QLatin1Char('/');
while(true) {
while (true) {
int index = directory.indexOf(slash, pos);
if (index == -1)
break;
@@ -119,7 +119,7 @@ IVersionControl* VCSManager::findVersionControlForDirectory(const QString &direc
// ah nothing so ask the IVersionControls directly
const VersionControlList versionControls = allVersionControls();
foreach(IVersionControl * versionControl, versionControls) {
foreach (IVersionControl * versionControl, versionControls) {
if (versionControl->managesDirectory(directory)) {
m_d->m_cachedMatches.insert(versionControl->findTopLevelForDirectory(directory), versionControl);
return versionControl;

View File

@@ -32,21 +32,25 @@
***************************************************************************/
#include "versiondialog.h"
#include "coreconstants.h"
#include "coreimpl.h"
#include <utils/qtcassert.h>
#include <QtCore/QDate>
#include <QtCore/QFile>
#include <QtGui/QDialogButtonBox>
#include <QtGui/QGridLayout>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
#include <QtGui/QTextBrowser>
using namespace Core;
using namespace Core::Internal;
using namespace Core::Constants;
#include <QtCore/QDate>
#include <QtCore/QFile>
#include <QtGui/QGridLayout>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
#include <QtGui/QDialogButtonBox>
#include <QtGui/QTextBrowser>
VersionDialog::VersionDialog(QWidget *parent)
: QDialog(parent)
{
@@ -90,7 +94,7 @@ VersionDialog::VersionDialog(QWidget *parent)
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
QPushButton *closeButton = buttonBox->button(QDialogButtonBox::Close);
Q_ASSERT(closeButton);
QTC_ASSERT(closeButton, /**/);
buttonBox->addButton(closeButton, QDialogButtonBox::ButtonRole(QDialogButtonBox::RejectRole | QDialogButtonBox::AcceptRole));
connect(buttonBox , SIGNAL(rejected()), this, SLOT(reject()));
@@ -118,7 +122,7 @@ void VersionDialog::popupLicense()
// Read file into string
ICore * core = CoreImpl::instance();
Q_ASSERT(core != NULL);
QTC_ASSERT(core, return);
QString fileName = core->resourcePath() + "/license.txt";
QFile file(fileName);

View File

@@ -63,7 +63,7 @@ ViewManager::ViewManager(MainWindow *mainWnd) :
ViewManagerInterface(mainWnd),
m_mainWnd(mainWnd)
{
for(int i = 0; i< 3; ++i) {
for (int i = 0; i < 3; ++i) {
QWidget *w = new QWidget();
m_mainWnd->statusBar()->insertPermanentWidget(i, w);
w->setLayout(new QHBoxLayout);
@@ -89,7 +89,7 @@ void ViewManager::init()
void ViewManager::objectAdded(QObject *obj)
{
IView * view = Aggregation::query<IView>(obj);
IView *view = Aggregation::query<IView>(obj);
if (!view)
return;
@@ -104,8 +104,8 @@ void ViewManager::objectAdded(QObject *obj)
void ViewManager::aboutToRemoveObject(QObject *obj)
{
IView * view = Aggregation::query<IView>(obj);
if(!view)
IView *view = Aggregation::query<IView>(obj);
if (!view)
return;
m_mainWnd->removeContextObject(view);
}
@@ -121,10 +121,10 @@ void ViewManager::saveSettings(QSettings *settings)
settings->setValue(QLatin1String("ViewGroup_Default"), m_mainWnd->saveState());
}
IView * ViewManager::view(const QString & id)
IView *ViewManager::view(const QString &id)
{
QList<IView *> list = m_mainWnd->pluginManager()->getObjects<IView>();
foreach (IView * view, list) {
foreach (IView *view, list) {
if (view->uniqueViewName() == id)
return view;
}

View File

@@ -1,4 +1,4 @@
<plugin name="CodePaster" version="0.1" compatVersion="0.1">
<plugin name="CodePaster" version="0.9.1" compatVersion="0.9.1">
<vendor>Nokia Corporation</vendor>
<copyright>(C) 2008 Nokia Corporation</copyright>
<license>Nokia Technology Preview License Agreement</license>

View File

@@ -36,12 +36,14 @@
#include <utils/codegeneration.h>
#include <utils/newclasswidget.h>
#include <utils/qtcassert.h>
#include <QtCore/QTextStream>
#include <QtCore/QDir>
#include <QtCore/QDebug>
#include <QtGui/QComboBox>
#include <QtCore/QDir>
#include <QtCore/QTextStream>
#include <QtGui/QCheckBox>
#include <QtGui/QComboBox>
#include <QtGui/QLabel>
#include <QtGui/QVBoxLayout>
#include <QtGui/QWizard>
@@ -73,6 +75,7 @@ ClassNamePage::ClassNamePage(const QString &sourceSuffix,
m_newClassWidget->setBaseClassEditable(true);
m_newClassWidget->setFormInputVisible(false);
m_newClassWidget->setNamespacesEnabled(true);
m_newClassWidget->setAllowDirectories(true);
connect(m_newClassWidget, SIGNAL(validChanged()),
this, SLOT(slotValidChanged()));
@@ -195,7 +198,7 @@ bool CppClassWizard::generateHeaderAndSource(const CppClassWizardParameters &par
<< "\n#define " << guard << '\n' << '\n';
const QRegExp qtClassExpr(QLatin1String("^Q[A-Z3].+"));
Q_ASSERT(qtClassExpr.isValid());
QTC_ASSERT(qtClassExpr.isValid(), /**/);
const bool superIsQtClass = qtClassExpr.exactMatch(params.baseClass);
if (superIsQtClass) {
Core::Utils::writeIncludeFileDirective(params.baseClass, true, headerStr);

View File

@@ -79,6 +79,7 @@
#include <QtGui/QComboBox>
#include <QtGui/QTreeView>
#include <QtGui/QHeaderView>
#include <QtGui/QStringListModel>
using namespace CPlusPlus;
using namespace CppEditor::Internal;
@@ -344,11 +345,11 @@ void CPPEditor::updateMethodBoxIndex()
QModelIndex lastIndex;
const int rc = m_overviewModel->rowCount(QModelIndex());
const int rc = m_overviewModel->rowCount();
for (int row = 0; row < rc; ++row) {
const QModelIndex index = m_overviewModel->index(row, 0, QModelIndex());
Symbol *symbol = m_overviewModel->symbolFromIndex(index);
if (symbol->line() > unsigned(line))
if (symbol && symbol->line() > unsigned(line))
break;
lastIndex = index;
}
@@ -519,6 +520,15 @@ void CPPEditor::jumpToDefinition()
#endif
}
} else {
foreach (const Document::MacroUse use, doc->macroUses()) {
if (use.contains(endOfName - 1)) {
const Macro &macro = use.macro();
const QString fileName = QString::fromUtf8(macro.fileName);
if (TextEditor::BaseTextEditor::openEditorAt(fileName, macro.line, 0))
return; // done
}
}
qDebug() << "No results for expression:" << expression;
}
}

View File

@@ -42,6 +42,7 @@
QT_BEGIN_NAMESPACE
class QAction;
class QComboBox;
class QStringListModel;
QT_END_NAMESPACE
namespace Core {

View File

@@ -42,6 +42,7 @@ CppClassesFilter::CppClassesFilter(CppModelManager *manager, Core::EditorManager
setIncludedByDefault(false);
search.setSymbolsToSearchFor(SearchSymbols::Classes);
search.setSeparateScope(true);
}
CppClassesFilter::~CppClassesFilter()

View File

@@ -32,6 +32,7 @@
***************************************************************************/
#include "cppcodecompletion.h"
#include "cppmodelmanager.h"
#include <Control.h>
@@ -45,6 +46,7 @@
#include <SymbolVisitor.h>
#include <Scope.h>
#include <TranslationUnit.h>
#include <cplusplus/ResolveExpression.h>
#include <cplusplus/LookupContext.h>
#include <cplusplus/Overview.h>
@@ -55,6 +57,7 @@
#include <coreplugin/editormanager/editormanager.h>
#include <texteditor/itexteditor.h>
#include <texteditor/itexteditable.h>
#include <utils/qtcassert.h>
#include <texteditor/basetexteditor.h>
#include <QtCore/QDebug>
@@ -540,7 +543,7 @@ bool CppCodeCompletion::completeMember(FullySpecifiedType,
const QList<TypeOfExpression::Result> &results,
const LookupContext &context)
{
Q_ASSERT(! results.isEmpty());
QTC_ASSERT(!results.isEmpty(), return false);
QList<Symbol *> classObjectCandidates;
@@ -699,7 +702,9 @@ void CppCodeCompletion::addMacros(const LookupContext &context)
continue;
processed.insert(fn);
if (Document::Ptr doc = context.document(fn)) {
macroNames += doc->macroNames();
foreach (const Macro macro, doc->definedMacros()) {
macroNames.insert(macro.name);
}
todo += doc->includedFiles();
}
}
@@ -936,7 +941,7 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item)
if (m_completionOperator == T_LPAREN) {
if (symbol) {
Function *function = symbol->type()->asFunction();
Q_ASSERT(function != 0);
QTC_ASSERT(function, return);
m_functionArgumentWidget = new FunctionArgumentWidget(m_core);
m_functionArgumentWidget->showFunctionHint(function);
@@ -1025,6 +1030,10 @@ bool CppCodeCompletion::partiallyComplete(const QList<TextEditor::CompletionItem
void CppCodeCompletion::cleanup()
{
m_completions.clear();
// Set empty map in order to avoid referencing old versions of the documents
// until the next completion
typeOfExpression.setDocuments(QMap<QString, Document::Ptr>());
}
int CppCodeCompletion::findStartOfName(const TextEditor::ITextEditor *editor)

View File

@@ -31,16 +31,20 @@
**
***************************************************************************/
#ifndef DEBUGGER_QWB_ASSERT_H
#define DEBUGGER_QWB_ASSERT_H
#include "cppfunctionsfilter.h"
#ifdef Q_OS_UNIX
#define QWB_ASSERT(cond, action) \
if(cond){}else{qDebug()<<"ASSERTION"<<#cond<<"FAILED"<<__FILE__<<__LINE__;action;}
#else
#define QWB_ASSERT(cond, action) \
if(cond){}else{qDebug()<<"ASSERTION"<<#cond<<"FAILED";action;}
#endif
using namespace CppTools::Internal;
#endif // DEBUGGER_QWB_ASSERT_H
CppFunctionsFilter::CppFunctionsFilter(CppModelManager *manager, Core::EditorManager *editorManager)
: CppQuickOpenFilter(manager, editorManager)
{
setShortcutString("m");
setIncludedByDefault(false);
search.setSymbolsToSearchFor(SearchSymbols::Functions);
search.setSeparateScope(true);
}
CppFunctionsFilter::~CppFunctionsFilter()
{
}

View File

@@ -31,49 +31,28 @@
**
***************************************************************************/
#ifndef PP_CLIENT_H
#define PP_CLIENT_H
#ifndef CPPFUNCTIONSFILTER_H
#define CPPFUNCTIONSFILTER_H
#include <QByteArray>
#include <QString>
#include <QFile>
#include <cppquickopenfilter.h>
namespace rpp {
namespace CppTools {
namespace Internal {
class Macro;
class Client
class CppFunctionsFilter : public CppQuickOpenFilter
{
Client(const Client &other);
void operator=(const Client &other);
Q_OBJECT
public:
enum IncludeType {
IncludeLocal,
IncludeGlobal
};
CppFunctionsFilter(CppModelManager *manager, Core::EditorManager *editorManager);
~CppFunctionsFilter();
public:
Client()
{ }
virtual ~Client()
{ }
virtual void macroAdded(const QByteArray &macroId, const QByteArray &text) = 0;
virtual void sourceNeeded(QString &fileName, IncludeType mode) = 0; // ### FIX the signature.
virtual void startExpandingMacro(unsigned offset,
const Macro &macro,
const QByteArray &originalTextt) = 0;
virtual void stopExpandingMacro(unsigned offset,
const Macro &macro) = 0;
virtual void startSkippingBlocks(unsigned offset) = 0;
virtual void stopSkippingBlocks(unsigned offset) = 0;
QString trName() const { return tr("Methods"); }
QString name() const { return QLatin1String("Methods"); }
Priority priority() const { return Medium; }
};
} // namespace rpp
} // namespace Internal
} // namespace CppTools
#endif // PP_CLIENT_H
#endif // CPPFUNCTIONSFILTER_H

View File

@@ -37,6 +37,7 @@
#include <coreplugin/icore.h>
#include <coreplugin/uniqueidmanager.h>
#include <texteditor/itexteditor.h>
#include <texteditor/basetexteditor.h>
#include <debugger/debuggerconstants.h>
#include <CoreTypes.h>
@@ -51,13 +52,13 @@
#include <cplusplus/TypeOfExpression.h>
#include <QtGui/QToolTip>
#include <QtGui/QPlainTextEdit>
#include <QtGui/QTextCursor>
#include <QtGui/QTextBlock>
#include <QtHelp/QHelpEngineCore>
#include <QtCore/QtCore>
using namespace CppTools::Internal;
using namespace CPlusPlus;
CppHoverHandler::CppHoverHandler(CppModelManager *manager, QObject *parent)
: QObject(parent), m_manager(manager), m_helpEngineNeedsSetup(false)
@@ -104,11 +105,9 @@ void CppHoverHandler::showToolTip(TextEditor::ITextEditor *editor, const QPoint
}
}
static QString buildHelpId(const CPlusPlus::FullySpecifiedType &type,
const CPlusPlus::Symbol *symbol)
static QString buildHelpId(const FullySpecifiedType &type,
const Symbol *symbol)
{
using namespace CPlusPlus;
Name *name = 0;
Scope *scope = 0;
@@ -156,12 +155,10 @@ static QString buildHelpId(const CPlusPlus::FullySpecifiedType &type,
void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, int pos)
{
using namespace CPlusPlus;
m_helpId.clear();
m_toolTip.clear();
QPlainTextEdit *edit = qobject_cast<QPlainTextEdit *>(editor->widget());
TextEditor::BaseTextEditor *edit = qobject_cast<TextEditor::BaseTextEditor *>(editor->widget());
if (!edit)
return;
@@ -169,8 +166,7 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
tc.setPosition(pos);
const int lineNumber = tc.block().blockNumber() + 1;
QString fileName = editor->file()->fileName();
const QString fileName = editor->file()->fileName();
Document::Ptr doc = m_manager->document(fileName);
if (doc) {
foreach (Document::DiagnosticMessage m, doc->diagnosticMessages()) {
@@ -235,6 +231,16 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
}
}
if (doc && m_toolTip.isEmpty()) {
foreach (const Document::MacroUse &use, doc->macroUses()) {
if (use.contains(pos)) {
m_toolTip = use.macro().toString();
m_helpId = use.macro().name;
break;
}
}
}
if (m_helpEngineNeedsSetup
&& m_helpEngine->registeredDocumentations().count() > 0) {
m_helpEngine->setupData();
@@ -243,7 +249,8 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
if (!m_helpId.isEmpty() && !m_helpEngine->linksForIdentifier(m_helpId).isEmpty()) {
m_toolTip = QString(QLatin1String("<table><tr><td valign=middle><nobr>%1</td>"
"<td><img src=\":/cpptools/images/f1.svg\"></td></tr></table>")).arg(Qt::escape(m_toolTip));
"<td><img src=\":/cpptools/images/f1.svg\"></td></tr></table>"))
.arg(Qt::escape(m_toolTip));
editor->setContextHelpId(m_helpId);
} else if (!m_toolTip.isEmpty()) {
m_toolTip = QString(QLatin1String("<nobr>%1")).arg(Qt::escape(m_toolTip));

View File

@@ -31,8 +31,7 @@
**
***************************************************************************/
#define _SCL_SECURE_NO_WARNINGS 1
#include "pp.h"
#include <cplusplus/pp.h>
#include "cppmodelmanager.h"
#include "cpphoverhandler.h"
@@ -53,6 +52,8 @@
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <utils/qtcassert.h>
#include <TranslationUnit.h>
#include <Semantic.h>
#include <AST.h>
@@ -65,15 +66,16 @@
#include <Lexer.h>
#include <Token.h>
#include <QPlainTextEdit>
#include <QTime>
#include <QDebug>
#include <QtCore/QDebug>
#include <QtCore/QMutexLocker>
#include <QtCore/QTime>
//#include <QtGui/QPlainTextEdit>
using namespace CppTools;
using namespace CppTools::Internal;
using namespace CPlusPlus;
namespace CppTools {
namespace Internal {
static const char pp_configuration_file[] = "<configuration>";
static const char pp_configuration[] =
@@ -105,299 +107,322 @@ static const char pp_configuration[] =
"#define __declspec(a)\n"
"#define STDMETHOD(method) virtual HRESULT STDMETHODCALLTYPE method\n";
class CppPreprocessor: public rpp::Client
namespace CppTools {
namespace Internal {
class CppPreprocessor: public CPlusPlus::Client
{
public:
CppPreprocessor(QPointer<CppModelManager> modelManager)
: m_modelManager(modelManager),
m_documents(modelManager->documents()),
m_proc(this, env)
{ }
CppPreprocessor(QPointer<CppModelManager> modelManager);
void setWorkingCopy(const QMap<QString, QByteArray> &workingCopy)
{ m_workingCopy = workingCopy; }
void setIncludePaths(const QStringList &includePaths)
{ m_includePaths = includePaths; }
void setFrameworkPaths(const QStringList &frameworkPaths)
{ m_frameworkPaths = frameworkPaths; }
void addIncludePath(const QString &path)
{ m_includePaths.append(path); }
void setProjectFiles(const QStringList &files)
{ m_projectFiles = files; }
void run(QString &fileName)
{ sourceNeeded(fileName, IncludeGlobal); }
void operator()(QString &fileName)
{ run(fileName); }
void setWorkingCopy(const QMap<QString, QByteArray> &workingCopy);
void setIncludePaths(const QStringList &includePaths);
void setFrameworkPaths(const QStringList &frameworkPaths);
void setProjectFiles(const QStringList &files);
void run(QString &fileName);
void operator()(QString &fileName);
protected:
bool includeFile(const QString &absoluteFilePath, QByteArray *result)
{
if (absoluteFilePath.isEmpty() || m_included.contains(absoluteFilePath)) {
return true;
}
CPlusPlus::Document::Ptr switchDocument(CPlusPlus::Document::Ptr doc);
if (m_workingCopy.contains(absoluteFilePath)) {
m_included.insert(absoluteFilePath);
*result = m_workingCopy.value(absoluteFilePath);
return true;
}
bool includeFile(const QString &absoluteFilePath, QByteArray *result);
QByteArray tryIncludeFile(QString &fileName, IncludeType type);
QFileInfo fileInfo(absoluteFilePath);
if (! fileInfo.isFile())
return false;
QFile file(absoluteFilePath);
if (file.open(QFile::ReadOnly)) {
m_included.insert(absoluteFilePath);
QTextStream stream(&file);
const QString contents = stream.readAll();
*result = contents.toUtf8();
file.close();
return true;
}
return false;
}
QByteArray tryIncludeFile(QString &fileName, IncludeType type)
{
QFileInfo fileInfo(fileName);
if (fileName == QLatin1String(pp_configuration_file) || fileInfo.isAbsolute()) {
QByteArray contents;
includeFile(fileName, &contents);
return contents;
}
if (type == IncludeLocal && m_currentDoc) {
QFileInfo currentFileInfo(m_currentDoc->fileName());
QString path = currentFileInfo.absolutePath();
path += QLatin1Char('/');
path += fileName;
path = QDir::cleanPath(path);
QByteArray contents;
if (includeFile(path, &contents)) {
fileName = path;
return contents;
}
}
foreach (const QString &includePath, m_includePaths) {
QString path = includePath;
path += QLatin1Char('/');
path += fileName;
path = QDir::cleanPath(path);
QByteArray contents;
if (includeFile(path, &contents)) {
fileName = path;
return contents;
}
}
// look in the system include paths
foreach (const QString &includePath, m_systemIncludePaths) {
QString path = includePath;
path += QLatin1Char('/');
path += fileName;
path = QDir::cleanPath(path);
QByteArray contents;
if (includeFile(path, &contents)) {
fileName = path;
return contents;
}
}
int index = fileName.indexOf(QLatin1Char('/'));
if (index != -1) {
QString frameworkName = fileName.left(index);
QString name = fileName.mid(index + 1);
foreach (const QString &frameworkPath, m_frameworkPaths) {
QString path = frameworkPath;
path += QLatin1Char('/');
path += frameworkName;
path += QLatin1String(".framework/Headers/");
path += name;
QByteArray contents;
if (includeFile(path, &contents)) {
fileName = path;
return contents;
}
}
}
QString path = fileName;
if (path.at(0) != QLatin1Char('/'))
path.prepend(QLatin1Char('/'));
foreach (const QString &projectFile, m_projectFiles) {
if (projectFile.endsWith(path)) {
fileName = projectFile;
QByteArray contents;
includeFile(fileName, &contents);
return contents;
}
}
//qDebug() << "**** file" << fileName << "not found!";
return QByteArray();
}
virtual void macroAdded(const QByteArray &macroName, const QByteArray &macroText)
{
if (! m_currentDoc)
return;
m_currentDoc->appendMacro(macroName, macroText);
}
void mergeEnvironment(CPlusPlus::Document::Ptr doc);
void mergeEnvironment(CPlusPlus::Document::Ptr doc, QSet<QString> *processed);
virtual void macroAdded(const Macro &macro);
virtual void startExpandingMacro(unsigned offset,
const rpp::Macro &,
const QByteArray &originalText)
{
if (! m_currentDoc)
return;
//qDebug() << "start expanding:" << macro.name << "text:" << originalText;
m_currentDoc->addMacroUse(offset, originalText.length());
}
virtual void stopExpandingMacro(unsigned, const rpp::Macro &)
{
if (! m_currentDoc)
return;
//qDebug() << "stop expanding:" << macro.name;
}
void mergeEnvironment(Document::Ptr doc)
{
QSet<QString> processed;
mergeEnvironment(doc, &processed);
}
void mergeEnvironment(Document::Ptr doc, QSet<QString> *processed)
{
if (! doc)
return;
const QString fn = doc->fileName();
if (processed->contains(fn))
return;
processed->insert(fn);
foreach (QString includedFile, doc->includedFiles())
mergeEnvironment(m_documents.value(includedFile), processed);
const QByteArray macros = doc->definedMacros();
QByteArray localFileName = doc->fileName().toUtf8();
QByteArray dummy;
m_proc(localFileName, macros, &dummy);
}
virtual void startSkippingBlocks(unsigned offset)
{
//qDebug() << "start skipping blocks:" << offset;
if (m_currentDoc)
m_currentDoc->startSkippingBlocks(offset);
}
virtual void stopSkippingBlocks(unsigned offset)
{
//qDebug() << "stop skipping blocks:" << offset;
if (m_currentDoc)
m_currentDoc->stopSkippingBlocks(offset);
}
virtual void sourceNeeded(QString &fileName, IncludeType type)
{
if (fileName.isEmpty())
return;
QByteArray contents = tryIncludeFile(fileName, type);
if (m_currentDoc) {
m_currentDoc->addIncludeFile(fileName);
if (contents.isEmpty() && ! QFileInfo(fileName).isAbsolute()) {
QString msg;
msg += fileName;
msg += QLatin1String(": No such file or directory");
Document::DiagnosticMessage d(Document::DiagnosticMessage::Warning,
m_currentDoc->fileName(),
env.currentLine, /*column = */ 0,
msg);
m_currentDoc->addDiagnosticMessage(d);
//qWarning() << "file not found:" << fileName << m_currentDoc->fileName() << env.current_line;
}
}
if (! contents.isEmpty()) {
Document::Ptr cachedDoc = m_documents.value(fileName);
if (cachedDoc && m_currentDoc) {
mergeEnvironment(cachedDoc);
} else {
Document::Ptr previousDoc = switchDocument(Document::create(fileName));
const QByteArray previousFile = env.current_file;
const unsigned previousLine = env.currentLine;
env.current_file = QByteArray(m_currentDoc->translationUnit()->fileName(),
m_currentDoc->translationUnit()->fileNameLength());
QByteArray preprocessedCode;
m_proc(contents, &preprocessedCode);
//qDebug() << preprocessedCode;
env.current_file = previousFile;
env.currentLine = previousLine;
m_currentDoc->setSource(preprocessedCode);
m_currentDoc->parse();
m_currentDoc->check();
m_currentDoc->releaseTranslationUnit(); // release the AST and the token stream.
if (m_modelManager)
m_modelManager->emitDocumentUpdated(m_currentDoc);
(void) switchDocument(previousDoc);
}
}
}
Document::Ptr switchDocument(Document::Ptr doc)
{
Document::Ptr previousDoc = m_currentDoc;
m_currentDoc = doc;
return previousDoc;
}
const Macro &macro,
const QByteArray &originalText);
virtual void stopExpandingMacro(unsigned offset, const Macro &macro);
virtual void startSkippingBlocks(unsigned offset);
virtual void stopSkippingBlocks(unsigned offset);
virtual void sourceNeeded(QString &fileName, IncludeType type);
private:
QPointer<CppModelManager> m_modelManager;
CppModelManager::DocumentTable m_documents;
rpp::Environment env;
rpp::pp m_proc;
Environment env;
pp m_proc;
QStringList m_includePaths;
QStringList m_systemIncludePaths;
QMap<QString, QByteArray> m_workingCopy;
QStringList m_projectFiles;
QStringList m_frameworkPaths;
QSet<QString> m_included;
Document::Ptr m_currentDoc;
CPlusPlus::Document::Ptr m_currentDoc;
};
} // namespace Internal
} // namespace CppTools
CppPreprocessor::CppPreprocessor(QPointer<CppModelManager> modelManager)
: m_modelManager(modelManager),
m_documents(modelManager->documents()),
m_proc(this, env)
{ }
void CppPreprocessor::setWorkingCopy(const QMap<QString, QByteArray> &workingCopy)
{ m_workingCopy = workingCopy; }
void CppPreprocessor::setIncludePaths(const QStringList &includePaths)
{ m_includePaths = includePaths; }
void CppPreprocessor::setFrameworkPaths(const QStringList &frameworkPaths)
{ m_frameworkPaths = frameworkPaths; }
void CppPreprocessor::setProjectFiles(const QStringList &files)
{ m_projectFiles = files; }
void CppPreprocessor::run(QString &fileName)
{ sourceNeeded(fileName, IncludeGlobal); }
void CppPreprocessor::operator()(QString &fileName)
{ run(fileName); }
bool CppPreprocessor::includeFile(const QString &absoluteFilePath, QByteArray *result)
{
if (absoluteFilePath.isEmpty() || m_included.contains(absoluteFilePath)) {
return true;
}
if (m_workingCopy.contains(absoluteFilePath)) {
m_included.insert(absoluteFilePath);
*result = m_workingCopy.value(absoluteFilePath);
return true;
}
QFileInfo fileInfo(absoluteFilePath);
if (! fileInfo.isFile())
return false;
QFile file(absoluteFilePath);
if (file.open(QFile::ReadOnly)) {
m_included.insert(absoluteFilePath);
QTextStream stream(&file);
const QString contents = stream.readAll();
*result = contents.toUtf8();
file.close();
return true;
}
return false;
}
QByteArray CppPreprocessor::tryIncludeFile(QString &fileName, IncludeType type)
{
QFileInfo fileInfo(fileName);
if (fileName == QLatin1String(pp_configuration_file) || fileInfo.isAbsolute()) {
QByteArray contents;
includeFile(fileName, &contents);
return contents;
}
if (type == IncludeLocal && m_currentDoc) {
QFileInfo currentFileInfo(m_currentDoc->fileName());
QString path = currentFileInfo.absolutePath();
path += QLatin1Char('/');
path += fileName;
path = QDir::cleanPath(path);
QByteArray contents;
if (includeFile(path, &contents)) {
fileName = path;
return contents;
}
}
foreach (const QString &includePath, m_includePaths) {
QString path = includePath;
path += QLatin1Char('/');
path += fileName;
path = QDir::cleanPath(path);
QByteArray contents;
if (includeFile(path, &contents)) {
fileName = path;
return contents;
}
}
// look in the system include paths
foreach (const QString &includePath, m_systemIncludePaths) {
QString path = includePath;
path += QLatin1Char('/');
path += fileName;
path = QDir::cleanPath(path);
QByteArray contents;
if (includeFile(path, &contents)) {
fileName = path;
return contents;
}
}
int index = fileName.indexOf(QLatin1Char('/'));
if (index != -1) {
QString frameworkName = fileName.left(index);
QString name = fileName.mid(index + 1);
foreach (const QString &frameworkPath, m_frameworkPaths) {
QString path = frameworkPath;
path += QLatin1Char('/');
path += frameworkName;
path += QLatin1String(".framework/Headers/");
path += name;
QByteArray contents;
if (includeFile(path, &contents)) {
fileName = path;
return contents;
}
}
}
QString path = fileName;
if (path.at(0) != QLatin1Char('/'))
path.prepend(QLatin1Char('/'));
foreach (const QString &projectFile, m_projectFiles) {
if (projectFile.endsWith(path)) {
fileName = projectFile;
QByteArray contents;
includeFile(fileName, &contents);
return contents;
}
}
//qDebug() << "**** file" << fileName << "not found!";
return QByteArray();
}
void CppPreprocessor::macroAdded(const Macro &macro)
{
if (! m_currentDoc)
return;
m_currentDoc->appendMacro(macro);
}
void CppPreprocessor::startExpandingMacro(unsigned offset,
const Macro &macro,
const QByteArray &originalText)
{
if (! m_currentDoc)
return;
//qDebug() << "start expanding:" << macro.name << "text:" << originalText;
m_currentDoc->addMacroUse(macro, offset, originalText.length());
}
void CppPreprocessor::stopExpandingMacro(unsigned, const Macro &)
{
if (! m_currentDoc)
return;
//qDebug() << "stop expanding:" << macro.name;
}
void CppPreprocessor::mergeEnvironment(Document::Ptr doc)
{
QSet<QString> processed;
mergeEnvironment(doc, &processed);
}
void CppPreprocessor::mergeEnvironment(Document::Ptr doc, QSet<QString> *processed)
{
if (! doc)
return;
const QString fn = doc->fileName();
if (processed->contains(fn))
return;
processed->insert(fn);
foreach (QString includedFile, doc->includedFiles()) {
mergeEnvironment(m_documents.value(includedFile), processed);
}
foreach (const Macro macro, doc->definedMacros()) {
env.bind(macro);
}
}
void CppPreprocessor::startSkippingBlocks(unsigned offset)
{
//qDebug() << "start skipping blocks:" << offset;
if (m_currentDoc)
m_currentDoc->startSkippingBlocks(offset);
}
void CppPreprocessor::stopSkippingBlocks(unsigned offset)
{
//qDebug() << "stop skipping blocks:" << offset;
if (m_currentDoc)
m_currentDoc->stopSkippingBlocks(offset);
}
void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type)
{
if (fileName.isEmpty())
return;
QByteArray contents = tryIncludeFile(fileName, type);
if (m_currentDoc) {
m_currentDoc->addIncludeFile(fileName);
if (contents.isEmpty() && ! QFileInfo(fileName).isAbsolute()) {
QString msg;
msg += fileName;
msg += QLatin1String(": No such file or directory");
Document::DiagnosticMessage d(Document::DiagnosticMessage::Warning,
m_currentDoc->fileName(),
env.currentLine, /*column = */ 0,
msg);
m_currentDoc->addDiagnosticMessage(d);
//qWarning() << "file not found:" << fileName << m_currentDoc->fileName() << env.current_line;
}
}
if (! contents.isEmpty()) {
Document::Ptr cachedDoc = m_documents.value(fileName);
if (cachedDoc && m_currentDoc) {
mergeEnvironment(cachedDoc);
} else {
Document::Ptr previousDoc = switchDocument(Document::create(fileName));
const QByteArray previousFile = env.currentFile;
const unsigned previousLine = env.currentLine;
env.currentFile = QByteArray(m_currentDoc->translationUnit()->fileName(),
m_currentDoc->translationUnit()->fileNameLength());
QByteArray preprocessedCode;
m_proc(contents, &preprocessedCode);
//qDebug() << preprocessedCode;
env.currentFile = previousFile;
env.currentLine = previousLine;
m_currentDoc->setSource(preprocessedCode);
m_currentDoc->parse();
m_currentDoc->check();
m_currentDoc->releaseTranslationUnit(); // release the AST and the token stream.
if (m_modelManager)
m_modelManager->emitDocumentUpdated(m_currentDoc);
(void) switchDocument(previousDoc);
}
}
}
Document::Ptr CppPreprocessor::switchDocument(Document::Ptr doc)
{
Document::Ptr previousDoc = m_currentDoc;
m_currentDoc = doc;
return previousDoc;
}
using namespace CppTools;
using namespace CppTools::Internal;
/*!
\class CppTools::CppModelManager
@@ -417,10 +442,10 @@ CppModelManager::CppModelManager(QObject *parent) :
m_projectExplorer = ExtensionSystem::PluginManager::instance()
->getObject<ProjectExplorer::ProjectExplorerPlugin>();
Q_ASSERT(m_projectExplorer);
QTC_ASSERT(m_projectExplorer, return);
ProjectExplorer::SessionManager *session = m_projectExplorer->session();
Q_ASSERT(session != 0);
QTC_ASSERT(session, return);
connect(session, SIGNAL(projectAdded(ProjectExplorer::Project*)),
this, SLOT(onProjectAdded(ProjectExplorer::Project*)));
@@ -450,13 +475,26 @@ CppModelManager::CppModelManager(QObject *parent) :
CppModelManager::~CppModelManager()
{ }
Document::Ptr CppModelManager::document(const QString &fileName)
Document::Ptr CppModelManager::document(const QString &fileName) const
{ return m_documents.value(fileName); }
CppModelManager::DocumentTable CppModelManager::documents()
CppModelManager::DocumentTable CppModelManager::documents() const
{ return m_documents; }
QStringList CppModelManager::updateProjectFiles() const
void CppModelManager::ensureUpdated()
{
QMutexLocker locker(&mutex);
if (! m_dirty)
return;
m_projectFiles = internalProjectFiles();
m_includePaths = internalIncludePaths();
m_frameworkPaths = internalFrameworkPaths();
m_definedMacros = internalDefinedMacros();
m_dirty = false;
}
QStringList CppModelManager::internalProjectFiles() const
{
QStringList files;
QMapIterator<ProjectExplorer::Project *, ProjectInfo> it(m_projects);
@@ -465,10 +503,11 @@ QStringList CppModelManager::updateProjectFiles() const
ProjectInfo pinfo = it.value();
files += pinfo.sourceFiles;
}
files.removeDuplicates();
return files;
}
QStringList CppModelManager::updateIncludePaths() const
QStringList CppModelManager::internalIncludePaths() const
{
QStringList includePaths;
QMapIterator<ProjectExplorer::Project *, ProjectInfo> it(m_projects);
@@ -477,10 +516,11 @@ QStringList CppModelManager::updateIncludePaths() const
ProjectInfo pinfo = it.value();
includePaths += pinfo.includePaths;
}
includePaths.removeDuplicates();
return includePaths;
}
QStringList CppModelManager::updateFrameworkPaths() const
QStringList CppModelManager::internalFrameworkPaths() const
{
QStringList frameworkPaths;
QMapIterator<ProjectExplorer::Project *, ProjectInfo> it(m_projects);
@@ -489,10 +529,11 @@ QStringList CppModelManager::updateFrameworkPaths() const
ProjectInfo pinfo = it.value();
frameworkPaths += pinfo.frameworkPaths;
}
frameworkPaths.removeDuplicates();
return frameworkPaths;
}
QByteArray CppModelManager::updateDefinedMacros() const
QByteArray CppModelManager::internalDefinedMacros() const
{
QByteArray macros;
QMapIterator<ProjectExplorer::Project *, ProjectInfo> it(m_projects);
@@ -527,8 +568,30 @@ QMap<QString, QByteArray> CppModelManager::buildWorkingCopyList()
void CppModelManager::updateSourceFiles(const QStringList &sourceFiles)
{ (void) refreshSourceFiles(sourceFiles); }
CppModelManager::ProjectInfo *CppModelManager::projectInfo(ProjectExplorer::Project *project)
{ return &m_projects[project]; }
QList<CppModelManager::ProjectInfo> CppModelManager::projectInfos() const
{
QMutexLocker locker(&mutex);
return m_projects.values();
}
CppModelManager::ProjectInfo CppModelManager::projectInfo(ProjectExplorer::Project *project) const
{
QMutexLocker locker(&mutex);
return m_projects.value(project, ProjectInfo(project));
}
void CppModelManager::updateProjectInfo(const ProjectInfo &pinfo)
{
QMutexLocker locker(&mutex);
if (! pinfo.isValid())
return;
m_projects.insert(pinfo.project, pinfo);
m_dirty = true;
}
QFuture<void> CppModelManager::refreshSourceFiles(const QStringList &sourceFiles)
{
@@ -566,7 +629,7 @@ void CppModelManager::editorOpened(Core::IEditor *editor)
{
if (isCppEditor(editor)) {
TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor *>(editor);
Q_ASSERT(textEditor != 0);
QTC_ASSERT(textEditor, return);
CppEditorSupport *editorSupport = new CppEditorSupport(this);
editorSupport->setTextEditor(textEditor);
@@ -586,7 +649,7 @@ void CppModelManager::editorAboutToClose(Core::IEditor *editor)
{
if (isCppEditor(editor)) {
TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor *>(editor);
Q_ASSERT(textEditor != 0);
QTC_ASSERT(textEditor, return);
CppEditorSupport *editorSupport = m_editorSupport.value(textEditor);
m_editorSupport.remove(textEditor);
@@ -683,7 +746,7 @@ void CppModelManager::onDocumentUpdated(Document::Ptr doc)
sel.cursor = c;
selections.append(sel);
}
ed->setExtraExtraSelections(selections);
ed->setExtraSelections(TextEditor::BaseTextEditor::CodeWarningsSelection, selections);
break;
}
}
@@ -691,13 +754,18 @@ void CppModelManager::onDocumentUpdated(Document::Ptr doc)
void CppModelManager::onProjectAdded(ProjectExplorer::Project *)
{
QMutexLocker locker(&mutex);
m_dirty = true;
}
void CppModelManager::onAboutToRemoveProject(ProjectExplorer::Project *project)
{
m_dirty = true;
m_projects.remove(project);
do {
QMutexLocker locker(&mutex);
m_dirty = true;
m_projects.remove(project);
} while (0);
GC();
}
@@ -705,15 +773,22 @@ void CppModelManager::onSessionUnloaded()
{
if (m_core->progressManager()) {
m_core->progressManager()->cancelTasks(CppTools::Constants::TASK_INDEX);
m_dirty = true;
}
do {
QMutexLocker locker(&mutex);
m_projects.clear();
m_dirty = true;
} while (0);
GC();
}
void CppModelManager::parse(QFutureInterface<void> &future,
CppPreprocessor *preproc,
QStringList files)
{
Q_ASSERT(! files.isEmpty());
QTC_ASSERT(!files.isEmpty(), return);
// Change the priority of the background parser thread to idle.
QThread::currentThread()->setPriority(QThread::IdlePriority);

View File

@@ -40,6 +40,7 @@
#include <QMap>
#include <QFutureInterface>
#include <QMutex>
namespace Core {
class ICore;
@@ -70,9 +71,13 @@ public:
virtual ~CppModelManager();
virtual void updateSourceFiles(const QStringList &sourceFiles);
virtual ProjectInfo *projectInfo(ProjectExplorer::Project *project);
virtual CPlusPlus::Document::Ptr document(const QString &fileName);
virtual DocumentTable documents();
virtual QList<ProjectInfo> projectInfos() const;
virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const;
virtual void updateProjectInfo(const ProjectInfo &pinfo);
virtual CPlusPlus::Document::Ptr document(const QString &fileName) const;
virtual DocumentTable documents() const;
virtual void GC();
QFuture<void> refreshSourceFiles(const QStringList &sourceFiles);
@@ -127,21 +132,11 @@ private:
return m_definedMacros;
}
QStringList updateProjectFiles() const;
QStringList updateIncludePaths() const;
QStringList updateFrameworkPaths() const;
QByteArray updateDefinedMacros() const;
void ensureUpdated() {
if (! m_dirty)
return;
m_projectFiles = updateProjectFiles();
m_includePaths = updateIncludePaths();
m_frameworkPaths = updateFrameworkPaths();
m_definedMacros = updateDefinedMacros();
m_dirty = false;
}
void ensureUpdated();
QStringList internalProjectFiles() const;
QStringList internalIncludePaths() const;
QStringList internalFrameworkPaths() const;
QByteArray internalDefinedMacros() const;
static void parse(QFutureInterface<void> &future,
CppPreprocessor *preproc,
@@ -166,6 +161,8 @@ private:
// project integration
QMap<ProjectExplorer::Project *, ProjectInfo> m_projects;
mutable QMutex mutex;
enum {
MAX_SELECTION_COUNT = 5
};

View File

@@ -38,6 +38,7 @@
#include <cplusplus/CppDocument.h>
#include <QtCore/QObject>
#include <QtCore/QMap>
#include <QtCore/QPointer>
namespace ProjectExplorer {
class Project;
@@ -51,10 +52,29 @@ class CPPTOOLS_EXPORT CppModelManagerInterface
Q_OBJECT
public:
typedef QMap<QString, CPlusPlus::Document::Ptr> DocumentTable;
typedef QMap<QString, CPlusPlus::Document::Ptr> DocumentTable; // ### remove me
struct ProjectInfo
class ProjectInfo
{
public:
ProjectInfo()
{ }
ProjectInfo(QPointer<ProjectExplorer::Project> project)
: project(project)
{ }
operator bool() const
{ return ! project.isNull(); }
bool isValid() const
{ return ! project.isNull(); }
bool isNull() const
{ return project.isNull(); }
public: // attributes
QPointer<ProjectExplorer::Project> project;
QString projectPath;
QByteArray defines;
QStringList sourceFiles;
@@ -69,10 +89,12 @@ public:
virtual void GC() = 0;
virtual void updateSourceFiles(const QStringList &sourceFiles) = 0;
virtual CPlusPlus::Document::Ptr document(const QString &fileName) = 0;
virtual DocumentTable documents() = 0;
virtual CPlusPlus::Document::Ptr document(const QString &fileName) const = 0;
virtual DocumentTable documents() const = 0;
virtual ProjectInfo *projectInfo(ProjectExplorer::Project *project) = 0;
virtual QList<ProjectInfo> projectInfos() const = 0;
virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const = 0;
virtual void updateProjectInfo(const ProjectInfo &pinfo) = 0;
};
} // namespace CppTools

View File

@@ -75,6 +75,12 @@ void CppQuickOpenFilter::refresh(QFutureInterface<void> &future)
Q_UNUSED(future);
}
static bool compareLexigraphically(const QuickOpen::FilterEntry &a,
const QuickOpen::FilterEntry &b)
{
return a.displayName < b.displayName;
}
QList<QuickOpen::FilterEntry> CppQuickOpenFilter::matchesFor(const QString &origEntry)
{
QString entry = trimWildcards(origEntry);
@@ -109,6 +115,9 @@ QList<QuickOpen::FilterEntry> CppQuickOpenFilter::matchesFor(const QString &orig
}
}
if (entries.size() < 1000)
qSort(entries.begin(), entries.end(), compareLexigraphically);
return entries;
}

View File

@@ -34,6 +34,7 @@
#include "cpptools.h"
#include "cppclassesfilter.h"
#include "cppcodecompletion.h"
#include "cppfunctionsfilter.h"
#include "cpphoverhandler.h"
#include "cppmodelmanager.h"
#include "cpptoolsconstants.h"
@@ -89,6 +90,7 @@ bool CppToolsPlugin::initialize(const QStringList & /*arguments*/, QString *)
m_core->editorManager());
addAutoReleasedObject(quickOpenFilter);
addAutoReleasedObject(new CppClassesFilter(m_modelManager, m_core->editorManager()));
addAutoReleasedObject(new CppFunctionsFilter(m_modelManager, m_core->editorManager()));
// Menus
Core::IActionContainer *mtools = am->actionContainer(Core::Constants::M_TOOLS);

View File

@@ -10,15 +10,16 @@ unix:QMAKE_CXXFLAGS_DEBUG += -O3
INCLUDEPATH += .
DEFINES += CPPTOOLS_LIBRARY
CONFIG += help
include(rpp/rpp.pri)|error("Can't find RPP")
HEADERS += cpptools_global.h \
cppquickopenfilter.h \
cppclassesfilter.h \
searchsymbols.h
searchsymbols.h \
cppfunctionsfilter.h
SOURCES += cppquickopenfilter.cpp \
cpptoolseditorsupport.cpp \
cppclassesfilter.cpp \
searchsymbols.cpp
searchsymbols.cpp \
cppfunctionsfilter.cpp
# Input
SOURCES += cpptools.cpp \

View File

@@ -1,74 +0,0 @@
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
/*
Copyright 2005 Roberto Raggi <roberto@kdevelop.org>
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
KDEVELOP TEAM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef PP_CCTYPE_H
#define PP_CCTYPE_H
#include <cctype>
namespace rpp {
inline bool pp_isalpha (int __ch)
{ return std::isalpha ((unsigned char) __ch) != 0; }
inline bool pp_isalnum (int __ch)
{ return std::isalnum ((unsigned char) __ch) != 0; }
inline bool pp_isdigit (int __ch)
{ return std::isdigit ((unsigned char) __ch) != 0; }
inline bool pp_isspace (int __ch)
{ return std::isspace ((unsigned char) __ch) != 0; }
} // namespace rpp
#endif // PP_CCTYPE_H

File diff suppressed because it is too large Load Diff

View File

@@ -1,231 +0,0 @@
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
/*
Copyright 2005 Roberto Raggi <roberto@kdevelop.org>
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
KDEVELOP TEAM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef PP_ENGINE_H
#define PP_ENGINE_H
#include "pp-client.h"
#include <Token.h>
#include <QVector>
namespace CPlusPlus {
class Token;
}
namespace rpp {
struct Value
{
enum Kind {
Kind_Long,
Kind_ULong,
};
Kind kind;
union {
long l;
unsigned long ul;
};
Value()
: kind(Kind_Long), l(0)
{ }
inline bool is_ulong () const
{ return kind == Kind_ULong; }
inline void set_ulong (unsigned long v)
{
ul = v;
kind = Kind_ULong;
}
inline void set_long (long v)
{
l = v;
kind = Kind_Long;
}
inline bool is_zero () const
{ return l == 0; }
#define PP_DEFINE_BIN_OP(name, op) \
inline Value operator op(const Value &other) const \
{ \
Value v = *this; \
if (v.is_ulong () || other.is_ulong ()) \
v.set_ulong (v.ul op other.ul); \
else \
v.set_long (v.l op other.l); \
return v; \
}
PP_DEFINE_BIN_OP(op_add, +)
PP_DEFINE_BIN_OP(op_sub, -)
PP_DEFINE_BIN_OP(op_mult, *)
PP_DEFINE_BIN_OP(op_div, /)
PP_DEFINE_BIN_OP(op_mod, %)
PP_DEFINE_BIN_OP(op_lhs, <<)
PP_DEFINE_BIN_OP(op_rhs, >>)
PP_DEFINE_BIN_OP(op_lt, <)
PP_DEFINE_BIN_OP(op_gt, >)
PP_DEFINE_BIN_OP(op_le, <=)
PP_DEFINE_BIN_OP(op_ge, >=)
PP_DEFINE_BIN_OP(op_eq, ==)
PP_DEFINE_BIN_OP(op_ne, !=)
PP_DEFINE_BIN_OP(op_bit_and, &)
PP_DEFINE_BIN_OP(op_bit_or, |)
PP_DEFINE_BIN_OP(op_bit_xor, ^)
PP_DEFINE_BIN_OP(op_and, &&)
PP_DEFINE_BIN_OP(op_or, ||)
#undef PP_DEFINE_BIN_OP
};
class pp
{
Client *client;
Environment &env;
MacroExpander expand;
enum { MAX_LEVEL = 512 };
bool _skipping[MAX_LEVEL]; // ### move in state
bool _true_test[MAX_LEVEL]; // ### move in state
int iflevel; // ### move in state
enum PP_DIRECTIVE_TYPE
{
PP_UNKNOWN_DIRECTIVE,
PP_DEFINE,
PP_INCLUDE,
PP_INCLUDE_NEXT,
PP_ELIF,
PP_ELSE,
PP_ENDIF,
PP_IF,
PP_IFDEF,
PP_IFNDEF,
PP_UNDEF
};
typedef const CPlusPlus::Token *TokenIterator;
struct State {
QByteArray source;
QVector<CPlusPlus::Token> tokens;
TokenIterator dot;
};
QList<State> _savedStates;
State state() const;
void pushState(const State &state);
void popState();
QByteArray _source;
QVector<CPlusPlus::Token> _tokens;
TokenIterator _dot;
State createStateFromSource(const QByteArray &source) const;
public:
pp(Client *client, Environment &env);
void operator()(const QByteArray &filename,
const QByteArray &source,
QByteArray *result);
void operator()(const QByteArray &source,
QByteArray *result);
private:
void resetIfLevel();
bool testIfLevel();
int skipping() const;
PP_DIRECTIVE_TYPE classifyDirective(const QByteArray &directive) const;
Value evalExpression(TokenIterator firstToken,
TokenIterator lastToken,
const QByteArray &source) const;
QVector<CPlusPlus::Token> tokenize(const QByteArray &text) const;
const char *startOfToken(const CPlusPlus::Token &token) const;
const char *endOfToken(const CPlusPlus::Token &token) const;
QByteArray tokenSpell(const CPlusPlus::Token &token) const;
QByteArray tokenText(const CPlusPlus::Token &token) const; // does a deep copy
void processDirective(TokenIterator dot, TokenIterator lastToken);
void processInclude(bool skipCurrentPath,
TokenIterator dot, TokenIterator lastToken,
bool acceptMacros = true);
void processDefine(TokenIterator dot, TokenIterator lastToken);
void processIf(TokenIterator dot, TokenIterator lastToken);
void processElse(TokenIterator dot, TokenIterator lastToken);
void processElif(TokenIterator dot, TokenIterator lastToken);
void processEndif(TokenIterator dot, TokenIterator lastToken);
void processIfdef(bool checkUndefined,
TokenIterator dot, TokenIterator lastToken);
void processUndef(TokenIterator dot, TokenIterator lastToken);
bool isQtReservedWord(const QByteArray &name) const;
};
} // namespace rpp
#endif // PP_ENGINE_H

View File

@@ -1,231 +0,0 @@
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
/*
Copyright 2005 Roberto Raggi <roberto@kdevelop.org>
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
KDEVELOP TEAM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "pp-environment.h"
#include "pp.h"
#include <cstring>
using namespace rpp;
Environment::Environment ()
: currentLine(0),
hide_next(false),
_macros(0),
_allocated_macros(0),
_macro_count(-1),
_hash(0),
_hash_count(401)
{
}
Environment::~Environment ()
{
if (_macros) {
qDeleteAll(firstMacro(), lastMacro());
free(_macros);
}
if (_hash)
free(_hash);
}
unsigned Environment::macroCount () const
{ return _macro_count + 1; }
Macro *Environment::macroAt (unsigned index) const
{ return _macros[index]; }
Macro *Environment::bind(const Macro &__macro)
{
Q_ASSERT(! __macro.name.isEmpty());
Macro *m = new Macro (__macro);
m->hashcode = hash_code(m->name);
m->fileName = current_file;
m->line = currentLine;
if (++_macro_count == _allocated_macros) {
if (! _allocated_macros)
_allocated_macros = 401;
else
_allocated_macros <<= 1;
_macros = (Macro **) realloc(_macros, sizeof(Macro *) * _allocated_macros);
}
_macros[_macro_count] = m;
if (! _hash || _macro_count > (_hash_count >> 1)) {
rehash();
} else {
const unsigned h = m->hashcode % _hash_count;
m->next = _hash[h];
_hash[h] = m;
}
return m;
}
void Environment::remove (const QByteArray &name)
{
Macro macro;
macro.name = name;
macro.hidden = true;
bind(macro);
}
bool Environment::isBuiltinMacro(const QByteArray &s) const
{
if (s.length() != 8)
return false;
if (s[0] == '_') {
if (s[1] == '_') {
if (s[2] == 'D') {
if (s[3] == 'A') {
if (s[4] == 'T') {
if (s[5] == 'E') {
if (s[6] == '_') {
if (s[7] == '_') {
return true;
}
}
}
}
}
}
else if (s[2] == 'F') {
if (s[3] == 'I') {
if (s[4] == 'L') {
if (s[5] == 'E') {
if (s[6] == '_') {
if (s[7] == '_') {
return true;
}
}
}
}
}
}
else if (s[2] == 'L') {
if (s[3] == 'I') {
if (s[4] == 'N') {
if (s[5] == 'E') {
if (s[6] == '_') {
if (s[7] == '_') {
return true;
}
}
}
}
}
}
else if (s[2] == 'T') {
if (s[3] == 'I') {
if (s[4] == 'M') {
if (s[5] == 'E') {
if (s[6] == '_') {
if (s[7] == '_') {
return true;
}
}
}
}
}
}
}
}
return false;
}
Macro *Environment::resolve (const QByteArray &name) const
{
if (! _macros)
return 0;
Macro *it = _hash[hash_code (name) % _hash_count];
for (; it; it = it->next) {
if (it->name != name)
continue;
else if (it->hidden)
return 0;
else break;
}
return it;
}
unsigned Environment::hash_code (const QByteArray &s)
{
unsigned hash_value = 0;
for (int i = 0; i < s.size (); ++i)
hash_value = (hash_value << 5) - hash_value + s.at (i);
return hash_value;
}
void Environment::rehash()
{
if (_hash) {
free(_hash);
_hash_count <<= 1;
}
_hash = (Macro **) calloc(_hash_count, sizeof(Macro *));
for (Macro **it = firstMacro(); it != lastMacro(); ++it) {
Macro *m= *it;
const unsigned h = m->hashcode % _hash_count;
m->next = _hash[h];
_hash[h] = m;
}
}

View File

@@ -1,109 +0,0 @@
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
/*
Copyright 2005 Roberto Raggi <roberto@kdevelop.org>
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
KDEVELOP TEAM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef PP_ENVIRONMENT_H
#define PP_ENVIRONMENT_H
#include <QVector>
#include <QByteArray>
namespace rpp {
struct Macro;
class Environment
{
public:
Environment();
~Environment();
unsigned macroCount() const;
Macro *macroAt(unsigned index) const;
Macro *bind(const Macro &macro);
void remove(const QByteArray &name);
Macro *resolve(const QByteArray &name) const;
bool isBuiltinMacro(const QByteArray &name) const;
const Macro *const *firstMacro() const
{ return _macros; }
Macro **firstMacro()
{ return _macros; }
const Macro *const *lastMacro() const
{ return _macros + _macro_count + 1; }
Macro **lastMacro()
{ return _macros + _macro_count + 1; }
private:
static unsigned hash_code (const QByteArray &s);
void rehash();
public:
QByteArray current_file;
unsigned currentLine;
bool hide_next;
private:
Macro **_macros;
int _allocated_macros;
int _macro_count;
Macro **_hash;
int _hash_count;
};
} // namespace rpp
#endif // PP_ENVIRONMENT_H

View File

@@ -1,78 +0,0 @@
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
/*
Copyright 2005 Roberto Raggi <roberto@kdevelop.org>
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
KDEVELOP TEAM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef PP_INTERNAL_H
#define PP_INTERNAL_H
#include <QByteArray>
namespace rpp {
namespace _PP_internal {
inline bool comment_p (const char *__first, const char *__last)
{
if (__first == __last)
return false;
if (*__first != '/')
return false;
if (++__first == __last)
return false;
return (*__first == '/' || *__first == '*');
}
} // _PP_internal
} // namespace rpp
#endif // PP_INTERNAL_H

View File

@@ -1,361 +0,0 @@
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
#include "pp.h"
#include "pp-macro-expander.h"
#include <QDateTime>
using namespace rpp;
MacroExpander::MacroExpander (Environment &env, pp_frame *frame)
: env(env), frame(frame),
lines(0), generated_lines(0)
{ }
const QByteArray *MacroExpander::resolve_formal(const QByteArray &__name)
{
if (! (frame && frame->expanding_macro))
return 0;
const QVector<QByteArray> &formals = frame->expanding_macro->formals;
for (int index = 0; index < formals.size(); ++index) {
const QByteArray formal = formals.at(index);
if (formal == __name && index < frame->actuals.size())
return &frame->actuals.at(index);
}
return 0;
}
const char *MacroExpander::operator () (const char *__first, const char *__last,
QByteArray *__result)
{
generated_lines = 0;
__first = skip_blanks (__first, __last);
lines = skip_blanks.lines;
while (__first != __last)
{
if (*__first == '\n')
{
__result->append("\n# ");
__result->append(QByteArray::number(env.currentLine));
__result->append(' ');
__result->append('"');
__result->append(env.current_file);
__result->append('"');
__result->append('\n');
++lines;
__first = skip_blanks (++__first, __last);
lines += skip_blanks.lines;
if (__first != __last && *__first == '#')
break;
}
else if (*__first == '#')
{
__first = skip_blanks (++__first, __last);
lines += skip_blanks.lines;
const char *end_id = skip_identifier (__first, __last);
const QByteArray fast_name(__first, end_id - __first);
__first = end_id;
if (const QByteArray *actual = resolve_formal (fast_name))
{
__result->append('\"');
const char *actual_begin = actual->constData ();
const char *actual_end = actual_begin + actual->size ();
for (const char *it = skip_whitespaces (actual_begin, actual_end);
it != actual_end; ++it)
{
if (*it == '"' || *it == '\\')
{
__result->append('\\');
__result->append(*it);
}
else if (*it == '\n')
{
__result->append('"');
__result->append('\n');
__result->append('"');
}
else
__result->append(*it);
}
__result->append('\"');
}
else
__result->append('#'); // ### warning message?
}
else if (*__first == '\"')
{
const char *next_pos = skip_string_literal (__first, __last);
lines += skip_string_literal.lines;
__result->append(__first, next_pos - __first);
__first = next_pos;
}
else if (*__first == '\'')
{
const char *next_pos = skip_char_literal (__first, __last);
lines += skip_char_literal.lines;
__result->append(__first, next_pos - __first);
__first = next_pos;
}
else if (_PP_internal::comment_p (__first, __last))
{
__first = skip_comment_or_divop (__first, __last);
int n = skip_comment_or_divop.lines;
lines += n;
while (n-- > 0)
__result->append('\n');
}
else if (pp_isspace (*__first))
{
for (; __first != __last; ++__first)
{
if (*__first == '\n' || !pp_isspace (*__first))
break;
}
__result->append(' ');
}
else if (pp_isdigit (*__first))
{
const char *next_pos = skip_number (__first, __last);
lines += skip_number.lines;
__result->append(__first, next_pos - __first);
__first = next_pos;
}
else if (pp_isalpha (*__first) || *__first == '_')
{
const char *name_begin = __first;
const char *name_end = skip_identifier (__first, __last);
__first = name_end; // advance
// search for the paste token
const char *next = skip_blanks (__first, __last);
bool paste = false;
if (next != __last && *next == '#')
{
paste = true;
++next;
if (next != __last && *next == '#')
__first = skip_blanks(++next, __last);
}
const QByteArray fast_name(name_begin, name_end - name_begin);
if (const QByteArray *actual = resolve_formal (fast_name))
{
const char *begin = actual->constData ();
const char *end = begin + actual->size ();
if (paste) {
for (--end; end != begin - 1; --end) {
if (! pp_isspace(*end))
break;
}
++end;
}
__result->append(begin, end - begin);
continue;
}
Macro *macro = env.resolve (fast_name);
if (! macro || macro->hidden || env.hide_next)
{
if (fast_name.size () == 7 && fast_name [0] == 'd' && fast_name == "defined")
env.hide_next = true;
else
env.hide_next = false;
if (fast_name.size () == 8 && fast_name [0] == '_' && fast_name [1] == '_')
{
if (fast_name == "__LINE__")
{
char buf [16];
const size_t count = qsnprintf (buf, 16, "%d", env.currentLine + lines);
__result->append(buf, count);
continue;
}
else if (fast_name == "__FILE__")
{
__result->append('"');
__result->append(env.current_file);
__result->append('"');
continue;
}
else if (fast_name == "__DATE__")
{
__result->append('"');
__result->append(QDate::currentDate().toString().toUtf8());
__result->append('"');
continue;
}
else if (fast_name == "__TIME__")
{
__result->append('"');
__result->append(QTime::currentTime().toString().toUtf8());
__result->append('"');
continue;
}
}
__result->append(name_begin, name_end - name_begin);
continue;
}
if (! macro->function_like)
{
Macro *m = 0;
if (! macro->definition.isEmpty())
{
macro->hidden = true;
QByteArray __tmp;
__tmp.reserve (256);
MacroExpander expand_macro (env);
expand_macro (macro->definition.constBegin (), macro->definition.constEnd (), &__tmp);
generated_lines += expand_macro.lines;
if (! __tmp.isEmpty ())
{
const char *__tmp_begin = __tmp.constBegin();
const char *__tmp_end = __tmp.constEnd();
const char *__begin_id = skip_whitespaces (__tmp_begin, __tmp_end);
const char *__end_id = skip_identifier (__begin_id, __tmp_end);
if (__end_id == __tmp_end)
{
const QByteArray __id (__begin_id, __end_id - __begin_id);
m = env.resolve (__id);
}
if (! m)
*__result += __tmp;
}
macro->hidden = false;
}
if (! m)
continue;
macro = m;
}
// function like macro
const char *arg_it = skip_whitespaces (__first, __last);
if (arg_it == __last || *arg_it != '(')
{
__result->append(name_begin, name_end - name_begin);
lines += skip_whitespaces.lines;
__first = arg_it;
continue;
}
QVector<QByteArray> actuals;
actuals.reserve (5);
++arg_it; // skip '('
MacroExpander expand_actual (env, frame);
const char *arg_end = skip_argument_variadics (actuals, macro, arg_it, __last);
if (arg_it != arg_end)
{
const QByteArray actual (arg_it, arg_end - arg_it);
QByteArray expanded;
expand_actual (actual.constBegin (), actual.constEnd (), &expanded);
actuals.push_back (expanded);
arg_it = arg_end;
}
while (arg_it != __last && *arg_end == ',')
{
++arg_it; // skip ','
arg_end = skip_argument_variadics (actuals, macro, arg_it, __last);
const QByteArray actual (arg_it, arg_end - arg_it);
QByteArray expanded;
expand_actual (actual.constBegin (), actual.constEnd (), &expanded);
actuals.push_back (expanded);
arg_it = arg_end;
}
if (! (arg_it != __last && *arg_it == ')'))
return __last;
++arg_it; // skip ')'
__first = arg_it;
pp_frame frame (macro, actuals);
MacroExpander expand_macro (env, &frame);
macro->hidden = true;
expand_macro (macro->definition.constBegin (), macro->definition.constEnd (), __result);
macro->hidden = false;
generated_lines += expand_macro.lines;
}
else
__result->append(*__first++);
}
return __first;
}
const char *MacroExpander::skip_argument_variadics (QVector<QByteArray> const &__actuals,
Macro *__macro,
const char *__first, const char *__last)
{
const char *arg_end = skip_argument (__first, __last);
while (__macro->variadics && __first != arg_end && arg_end != __last && *arg_end == ','
&& (__actuals.size () + 1) == __macro->formals.size ())
{
arg_end = skip_argument (++arg_end, __last);
}
return arg_end;
}

View File

@@ -1,103 +0,0 @@
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
/*
Copyright 2005 Roberto Raggi <roberto@kdevelop.org>
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
KDEVELOP TEAM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef PP_MACRO_EXPANDER_H
#define PP_MACRO_EXPANDER_H
namespace rpp {
struct pp_frame
{
Macro *expanding_macro;
const QVector<QByteArray> actuals;
pp_frame (Macro *expanding_macro, const QVector<QByteArray> &actuals)
: expanding_macro (expanding_macro),
actuals (actuals)
{ }
};
class MacroExpander
{
Environment &env;
pp_frame *frame;
pp_skip_number skip_number;
pp_skip_identifier skip_identifier;
pp_skip_string_literal skip_string_literal;
pp_skip_char_literal skip_char_literal;
pp_skip_argument skip_argument;
pp_skip_comment_or_divop skip_comment_or_divop;
pp_skip_blanks skip_blanks;
pp_skip_whitespaces skip_whitespaces;
const QByteArray *resolve_formal (const QByteArray &name);
public:
MacroExpander (Environment &env, pp_frame *frame = 0);
const char *operator () (const char *first, const char *last,
QByteArray *result);
const char *skip_argument_variadics (const QVector<QByteArray> &actuals,
Macro *macro,
const char *first, const char *last);
public: // attributes
int lines;
int generated_lines;
};
} // namespace rpp
#endif // PP_MACRO_EXPANDER_H

View File

@@ -1,95 +0,0 @@
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
/*
Copyright 2005 Roberto Raggi <roberto@kdevelop.org>
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
KDEVELOP TEAM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef PP_MACRO_H
#define PP_MACRO_H
#include <QByteArray>
#include <QVector>
namespace rpp {
struct Macro
{
QByteArray name;
QByteArray definition;
QVector<QByteArray> formals;
QByteArray fileName;
int line;
int lines;
Macro *next;
unsigned hashcode;
union
{
unsigned state;
struct
{
unsigned hidden: 1;
unsigned function_like: 1;
unsigned variadics: 1;
};
};
inline Macro():
line(0),
lines(0),
next(0),
hashcode(0),
state(0)
{ }
};
} // namespace rpp
#endif // PP_MACRO_H

View File

@@ -1,380 +0,0 @@
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
/*
Copyright 2005 Roberto Raggi <roberto@kdevelop.org>
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
KDEVELOP TEAM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef PP_SCANNER_H
#define PP_SCANNER_H
namespace rpp {
struct pp_skip_blanks
{
int lines;
const char *operator () (const char *__first, const char *__last)
{
lines = 0;
for (; __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first)
{
if (*__first == '\\')
{
const char *__begin = __first;
++__begin;
if (__begin != __last && *__begin == '\n')
++__first;
else
break;
}
else if (*__first == '\n' || !pp_isspace (*__first))
break;
}
return __first;
}
};
struct pp_skip_whitespaces
{
int lines;
const char *operator () (const char *__first, const char *__last)
{
lines = 0;
for (; __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first)
{
if (! pp_isspace (*__first))
break;
}
return __first;
}
};
struct pp_skip_comment_or_divop
{
int lines;
const char *operator () (const char *__first, const char *__last)
{
enum {
MAYBE_BEGIN,
BEGIN,
MAYBE_END,
END,
IN_COMMENT,
IN_CXX_COMMENT
} state (MAYBE_BEGIN);
lines = 0;
for (; __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first)
{
switch (state)
{
default:
assert (0);
break;
case MAYBE_BEGIN:
if (*__first != '/')
return __first;
state = BEGIN;
break;
case BEGIN:
if (*__first == '*')
state = IN_COMMENT;
else if (*__first == '/')
state = IN_CXX_COMMENT;
else
return __first;
break;
case IN_COMMENT:
if (*__first == '*')
state = MAYBE_END;
break;
case IN_CXX_COMMENT:
if (*__first == '\n')
return __first;
break;
case MAYBE_END:
if (*__first == '/')
state = END;
else if (*__first != '*')
state = IN_COMMENT;
break;
case END:
return __first;
}
}
return __first;
}
};
struct pp_skip_identifier
{
int lines;
const char *operator () (const char *__first, const char *__last)
{
lines = 0;
for (; __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first)
{
if (! pp_isalnum (*__first) && *__first != '_')
break;
}
return __first;
}
};
struct pp_skip_number
{
int lines;
const char *operator () (const char *__first, const char *__last)
{
lines = 0;
for (; __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first)
{
if (! pp_isalnum (*__first) && *__first != '.')
break;
}
return __first;
}
};
struct pp_skip_string_literal
{
int lines;
const char *operator () (const char *__first, const char *__last)
{
enum {
BEGIN,
IN_STRING,
QUOTE,
END
} state (BEGIN);
lines = 0;
for (; __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first)
{
switch (state)
{
default:
assert (0);
break;
case BEGIN:
if (*__first != '\"')
return __first;
state = IN_STRING;
break;
case IN_STRING:
if (! (*__first != '\n'))
return __last;
if (*__first == '\"')
state = END;
else if (*__first == '\\')
state = QUOTE;
break;
case QUOTE:
state = IN_STRING;
break;
case END:
return __first;
}
}
return __first;
}
};
struct pp_skip_char_literal
{
int lines;
const char *operator () (const char *__first, const char *__last)
{
enum {
BEGIN,
IN_STRING,
QUOTE,
END
} state (BEGIN);
lines = 0;
for (; state != END && __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first)
{
switch (state)
{
default:
assert (0);
break;
case BEGIN:
if (*__first != '\'')
return __first;
state = IN_STRING;
break;
case IN_STRING:
if (! (*__first != '\n'))
return __last;
if (*__first == '\'')
state = END;
else if (*__first == '\\')
state = QUOTE;
break;
case QUOTE:
state = IN_STRING;
break;
}
}
return __first;
}
};
struct pp_skip_argument
{
pp_skip_identifier skip_number;
pp_skip_identifier skip_identifier;
pp_skip_string_literal skip_string_literal;
pp_skip_char_literal skip_char_literal;
pp_skip_comment_or_divop skip_comment_or_divop;
int lines;
const char *operator () (const char *__first, const char *__last)
{
int depth = 0;
lines = 0;
while (__first != __last)
{
if (!depth && (*__first == ')' || *__first == ','))
break;
else if (*__first == '(')
++depth, ++__first;
else if (*__first == ')')
--depth, ++__first;
else if (*__first == '\"')
{
__first = skip_string_literal (__first, __last);
lines += skip_string_literal.lines;
}
else if (*__first == '\'')
{
__first = skip_char_literal (__first, __last);
lines += skip_char_literal.lines;
}
else if (*__first == '/')
{
__first = skip_comment_or_divop (__first, __last);
lines += skip_comment_or_divop.lines;
}
else if (pp_isalpha (*__first) || *__first == '_')
{
__first = skip_identifier (__first, __last);
lines += skip_identifier.lines;
}
else if (pp_isdigit (*__first))
{
__first = skip_number (__first, __last);
lines += skip_number.lines;
}
else if (*__first == '\n')
{
++__first;
++lines;
}
else
++__first;
}
return __first;
}
};
} // namespace rpp
#endif // PP_SCANNER_H
// kate: space-indent on; indent-width 2; replace-tabs on;

View File

@@ -1,69 +0,0 @@
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
/*
Copyright 2005 Roberto Raggi <roberto@kdevelop.org>
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
KDEVELOP TEAM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef PP_H
#define PP_H
#include <cassert>
#include <cstring>
#include <cctype>
#include "pp-cctype.h"
#include "pp-internal.h"
#include "pp-macro.h"
#include "pp-environment.h"
#include "pp-scanner.h"
#include "pp-macro-expander.h"
#include "pp-engine.h"
#include "pp-client.h"
#endif // PP_H

View File

@@ -1,18 +0,0 @@
DEPENDPATH += $$PWD
INCLUDEPATH += $$PWD
HEADERS += $$PWD/pp-cctype.h \
$$PWD/pp-engine.h \
$$PWD/pp-environment.h \
$$PWD/pp-internal.h \
$$PWD/pp-macro-expander.h \
$$PWD/pp-macro.h \
$$PWD/pp-scanner.h \
$$PWD/pp.h \
$$PWD/pp-client.h
SOURCES += $$PWD/pp-engine.cpp \
$$PWD/pp-environment.cpp \
$$PWD/pp-macro-expander.cpp

View File

@@ -35,12 +35,14 @@
#include <Literals.h>
#include <Scope.h>
#include <Names.h>
using namespace CPlusPlus;
using namespace CppTools::Internal;
SearchSymbols::SearchSymbols():
symbolsToSearchFor(Classes | Functions | Enums)
symbolsToSearchFor(Classes | Functions | Enums),
separateScope(false)
{
}
@@ -49,6 +51,11 @@ void SearchSymbols::setSymbolsToSearchFor(SymbolTypes types)
symbolsToSearchFor = types;
}
void SearchSymbols::setSeparateScope(bool separateScope)
{
this->separateScope = separateScope;
}
QList<ModelItemInfo> SearchSymbols::operator()(Document::Ptr doc, const QString &scope)
{
QString previousScope = switchScope(scope);
@@ -73,13 +80,12 @@ bool SearchSymbols::visit(Enum *symbol)
return false;
QString name = symbolName(symbol);
QString previousScope = switchScope(name);
QIcon icon = icons.iconForSymbol(symbol);
QString scopedName = scopedSymbolName(name);
QString previousScope = switchScope(scopedName);
appendItem(separateScope ? name : scopedName,
separateScope ? previousScope : QString(),
ModelItemInfo::Enum, symbol);
Scope *members = symbol->members();
items.append(ModelItemInfo(name, QString(), ModelItemInfo::Enum,
QString::fromUtf8(symbol->fileName(), symbol->fileNameLength()),
symbol->line(),
icon));
for (unsigned i = 0; i < members->symbolCount(); ++i) {
accept(members->symbolAt(i));
}
@@ -92,19 +98,31 @@ bool SearchSymbols::visit(Function *symbol)
if (!(symbolsToSearchFor & Functions))
return false;
QString extraScope;
if (Name *name = symbol->name()) {
if (QualifiedNameId *nameId = name->asQualifiedNameId()) {
if (nameId->nameCount() > 1) {
extraScope = overview.prettyName(nameId->nameAt(nameId->nameCount() - 2));
}
}
}
QString fullScope = _scope;
if (!_scope.isEmpty() && !extraScope.isEmpty())
fullScope += QLatin1String("::");
fullScope += extraScope;
QString name = symbolName(symbol);
QString type = overview.prettyType(symbol->type());
QIcon icon = icons.iconForSymbol(symbol);
items.append(ModelItemInfo(name, type, ModelItemInfo::Method,
QString::fromUtf8(symbol->fileName(), symbol->fileNameLength()),
symbol->line(),
icon));
QString scopedName = scopedSymbolName(name);
QString type = overview.prettyType(symbol->type(),
separateScope ? symbol->identity() : 0);
appendItem(separateScope ? type : scopedName,
separateScope ? fullScope : type,
ModelItemInfo::Method, symbol);
return false;
}
bool SearchSymbols::visit(Namespace *symbol)
{
QString name = symbolName(symbol);
QString name = findOrInsert(scopedSymbolName(symbol));
QString previousScope = switchScope(name);
Scope *members = symbol->members();
for (unsigned i = 0; i < members->symbolCount(); ++i) {
@@ -118,12 +136,9 @@ bool SearchSymbols::visit(Namespace *symbol)
bool SearchSymbols::visit(Declaration *symbol)
{
if (symbol->type()->isFunction()) {
QString name = symbolName(symbol);
QString name = scopedSymbolName(symbol);
QString type = overview.prettyType(symbol->type());
//QIcon icon = ...;
items.append(ModelItemInfo(name, type, ModelItemInfo::Method,
QString::fromUtf8(symbol->fileName(), symbol->line()),
symbol->line()));
appendItems(name, type, ModelItemInfo::Method, symbol->fileName());
}
return false;
}
@@ -135,12 +150,11 @@ bool SearchSymbols::visit(Class *symbol)
return false;
QString name = symbolName(symbol);
QString previousScope = switchScope(name);
QIcon icon = icons.iconForSymbol(symbol);
items.append(ModelItemInfo(name, QString(), ModelItemInfo::Class,
QString::fromUtf8(symbol->fileName(), symbol->fileNameLength()),
symbol->line(),
icon));
QString scopedName = scopedSymbolName(name);
QString previousScope = switchScope(scopedName);
appendItem(separateScope ? name : scopedName,
separateScope ? previousScope : QString(),
ModelItemInfo::Class, symbol);
Scope *members = symbol->members();
for (unsigned i = 0; i < members->symbolCount(); ++i) {
accept(members->symbolAt(i));
@@ -149,11 +163,22 @@ bool SearchSymbols::visit(Class *symbol)
return false;
}
QString SearchSymbols::symbolName(const Symbol *symbol) const
QString SearchSymbols::scopedSymbolName(const QString &symbolName) const
{
QString name = _scope;
if (! name.isEmpty())
if (!name.isEmpty())
name += QLatin1String("::");
name += symbolName;
return name;
}
QString SearchSymbols::scopedSymbolName(const Symbol *symbol) const
{
return scopedSymbolName(symbolName(symbol));
}
QString SearchSymbols::symbolName(const Symbol *symbol) const
{
QString symbolName = overview.prettyName(symbol->name());
if (symbolName.isEmpty()) {
QString type;
@@ -176,6 +201,20 @@ QString SearchSymbols::symbolName(const Symbol *symbol) const
symbolName += type;
symbolName += QLatin1String(">");
}
name += symbolName;
return name;
return symbolName;
}
void SearchSymbols::appendItem(const QString &name,
const QString &info,
ModelItemInfo::ItemType type,
const Symbol *symbol)
{
if (!symbol->name())
return;
const QIcon icon = icons.iconForSymbol(symbol);
items.append(ModelItemInfo(name, info, type,
QString::fromUtf8(symbol->fileName(), symbol->fileNameLength()),
symbol->line(),
icon));
}

View File

@@ -44,6 +44,8 @@
#include <QMetaType>
#include <QString>
#include <functional>
namespace CppTools {
namespace Internal {
@@ -90,6 +92,7 @@ public:
SearchSymbols();
void setSymbolsToSearchFor(SymbolTypes types);
void setSeparateScope(bool separateScope);
QList<ModelItemInfo> operator()(CPlusPlus::Document::Ptr doc)
{ return operator()(doc, QString()); }
@@ -111,14 +114,27 @@ protected:
virtual bool visit(CPlusPlus::Declaration *symbol);
#endif
virtual bool visit(CPlusPlus::Class *symbol);
QString scopedSymbolName(const QString &symbolName) const;
QString scopedSymbolName(const CPlusPlus::Symbol *symbol) const;
QString symbolName(const CPlusPlus::Symbol *symbol) const;
void appendItem(const QString &name,
const QString &info,
ModelItemInfo::ItemType type,
const CPlusPlus::Symbol *symbol);
private:
QString findOrInsert(const QString &s)
{ return *strings.insert(s); }
QSet<QString> strings; // Used to avoid QString duplication
QString _scope;
CPlusPlus::Overview overview;
CPlusPlus::Icons icons;
QList<ModelItemInfo> items;
SymbolTypes symbolsToSearchFor;
bool separateScope;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(SearchSymbols::SymbolTypes)

View File

@@ -152,13 +152,12 @@ void AttachExternalDialog::rebuildProcessList()
#ifdef Q_OS_WINDOWS
// Forward declarations:
BOOL GetProcessList( );
BOOL ListProcessModules( DWORD dwPID );
BOOL ListProcessThreads( DWORD dwOwnerPID );
void printError( TCHAR* msg );
BOOL GetProcessList();
BOOL ListProcessModules(DWORD dwPID);
BOOL ListProcessThreads(DWORD dwOwnerPID);
void printError(TCHAR *msg);
BOOL GetProcessList( )
BOOL GetProcessList()
{
HANDLE hProcessSnap;
HANDLE hProcess;
@@ -167,7 +166,7 @@ BOOL GetProcessList( )
// Take a snapshot of all processes in the system.
hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
if( hProcessSnap == INVALID_HANDLE_VALUE )
if (hProcessSnap == INVALID_HANDLE_VALUE)
{
printError( TEXT("CreateToolhelp32Snapshot (of processes)") );
return( FALSE );
@@ -178,7 +177,7 @@ BOOL GetProcessList( )
// Retrieve information about the first process,
// and exit if unsuccessful
if( !Process32First( hProcessSnap, &pe32 ) )
if (!Process32First( hProcessSnap, &pe32 ))
{
printError( TEXT("Process32First") ); // show cause of failure
CloseHandle( hProcessSnap ); // clean the snapshot object
@@ -196,12 +195,12 @@ BOOL GetProcessList( )
// Retrieve the priority class.
dwPriorityClass = 0;
hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID );
if( hProcess == NULL )
if (hProcess == NULL)
printError( TEXT("OpenProcess") );
else
{
dwPriorityClass = GetPriorityClass( hProcess );
if( !dwPriorityClass )
if (!dwPriorityClass)
printError( TEXT("GetPriorityClass") );
CloseHandle( hProcess );
}
@@ -210,31 +209,30 @@ BOOL GetProcessList( )
printf( "\n Thread count = %d", pe32.cntThreads );
printf( "\n Parent process ID = 0x%08X", pe32.th32ParentProcessID );
printf( "\n Priority base = %d", pe32.pcPriClassBase );
if( dwPriorityClass )
if (dwPriorityClass)
printf( "\n Priority class = %d", dwPriorityClass );
// List the modules and threads associated with this process
ListProcessModules( pe32.th32ProcessID );
ListProcessThreads( pe32.th32ProcessID );
} while( Process32Next( hProcessSnap, &pe32 ) );
} while (Process32Next(hProcessSnap, &pe32));
CloseHandle( hProcessSnap );
return( TRUE );
CloseHandle(hProcessSnap);
return TRUE;
}
BOOL ListProcessModules( DWORD dwPID )
BOOL ListProcessModules(DWORD dwPID)
{
HANDLE hModuleSnap = INVALID_HANDLE_VALUE;
MODULEENTRY32 me32;
// Take a snapshot of all modules in the specified process.
hModuleSnap = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, dwPID );
if( hModuleSnap == INVALID_HANDLE_VALUE )
{
printError( TEXT("CreateToolhelp32Snapshot (of modules)") );
return( FALSE );
if (hModuleSnap == INVALID_HANDLE_VALUE) {
printError(TEXT("CreateToolhelp32Snapshot (of modules)"));
return FALSE;
}
// Set the size of the structure before using it.
@@ -242,7 +240,7 @@ BOOL ListProcessModules( DWORD dwPID )
// Retrieve information about the first module,
// and exit if unsuccessful
if( !Module32First( hModuleSnap, &me32 ) )
if (!Module32First( hModuleSnap, &me32))
{
printError( TEXT("Module32First") ); // show cause of failure
CloseHandle( hModuleSnap ); // clean the snapshot object
@@ -261,10 +259,10 @@ BOOL ListProcessModules( DWORD dwPID )
printf( "\n Base address = 0x%08X", (DWORD) me32.modBaseAddr );
printf( "\n Base size = %d", me32.modBaseSize );
} while( Module32Next( hModuleSnap, &me32 ) );
} while (Module32Next(hModuleSnap, &me32));
CloseHandle( hModuleSnap );
return( TRUE );
CloseHandle(hModuleSnap);
return TRUE;
}
BOOL ListProcessThreads( DWORD dwOwnerPID )
@@ -274,7 +272,7 @@ BOOL ListProcessThreads( DWORD dwOwnerPID )
// Take a snapshot of all running threads
hThreadSnap = CreateToolhelp32Snapshot( TH32CS_SNAPTHREAD, 0 );
if( hThreadSnap == INVALID_HANDLE_VALUE )
if (hThreadSnap == INVALID_HANDLE_VALUE)
return( FALSE );
// Fill in the size of the structure before using it.
@@ -282,7 +280,7 @@ BOOL ListProcessThreads( DWORD dwOwnerPID )
// Retrieve information about the first thread,
// and exit if unsuccessful
if( !Thread32First( hThreadSnap, &te32 ) )
if (!Thread32First( hThreadSnap, &te32 ))
{
printError( TEXT("Thread32First") ); // show cause of failure
CloseHandle( hThreadSnap ); // clean the snapshot object
@@ -294,13 +292,13 @@ BOOL ListProcessThreads( DWORD dwOwnerPID )
// associated with the specified process
do
{
if( te32.th32OwnerProcessID == dwOwnerPID )
if (te32.th32OwnerProcessID == dwOwnerPID)
{
printf( "\n\n THREAD ID = 0x%08X", te32.th32ThreadID );
printf( "\n Base priority = %d", te32.tpBasePri );
printf( "\n Delta priority = %d", te32.tpDeltaPri );
}
} while( Thread32Next(hThreadSnap, &te32 ) );
} while (Thread32Next(hThreadSnap, &te32));
CloseHandle( hThreadSnap );
return( TRUE );
@@ -308,22 +306,24 @@ BOOL ListProcessThreads( DWORD dwOwnerPID )
void printError( TCHAR* msg )
{
DWORD eNum;
TCHAR sysMsg[256];
TCHAR* p;
DWORD eNum;
TCHAR sysMsg[256];
TCHAR* p;
eNum = GetLastError( );
FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
eNum = GetLastError( );
FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, eNum,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
sysMsg, 256, NULL );
// Trim the end of the line and terminate it with a null
p = sysMsg;
while( ( *p > 31 ) || ( *p == 9 ) )
++p;
do { *p-- = 0; } while( ( p >= sysMsg ) &&
( ( *p == '.' ) || ( *p < 33 ) ) );
// Trim the end of the line and terminate it with a null
p = sysMsg;
while (*p > 31 || *p == 9 )
++p;
do {
*p-- = 0;
} while( p >= sysMsg && (*p == '.' || *p < 33));
// Display the message
_tprintf( TEXT("\n WARNING: %s failed with error %d (%s)"), msg, eNum, sysMsg );
@@ -331,7 +331,6 @@ void printError( TCHAR* msg )
#endif
void AttachExternalDialog::procSelected(const QModelIndex &index0)
{
QModelIndex index = index0.sibling(index0.row(), 0);

View File

@@ -150,10 +150,10 @@ void AttachRemoteDialog::rebuildProcessList()
#include <stdio.h>
// Forward declarations:
BOOL GetProcessList( );
BOOL ListProcessModules( DWORD dwPID );
BOOL ListProcessThreads( DWORD dwOwnerPID );
void printError( TCHAR* msg );
BOOL GetProcessList();
BOOL ListProcessModules(DWORD dwPID);
BOOL ListProcessThreads(DWORD dwOwnerPID);
void printError(TCHAR* msg);
BOOL GetProcessList( )
{
@@ -164,7 +164,7 @@ BOOL GetProcessList( )
// Take a snapshot of all processes in the system.
hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
if( hProcessSnap == INVALID_HANDLE_VALUE )
if (hProcessSnap == INVALID_HANDLE_VALUE)
{
printError( TEXT("CreateToolhelp32Snapshot (of processes)") );
return( FALSE );
@@ -175,7 +175,7 @@ BOOL GetProcessList( )
// Retrieve information about the first process,
// and exit if unsuccessful
if( !Process32First( hProcessSnap, &pe32 ) )
if (!Process32First( hProcessSnap, &pe32 ))
{
printError( TEXT("Process32First") ); // show cause of failure
CloseHandle( hProcessSnap ); // clean the snapshot object
@@ -193,12 +193,12 @@ BOOL GetProcessList( )
// Retrieve the priority class.
dwPriorityClass = 0;
hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID );
if( hProcess == NULL )
if (hProcess == NULL)
printError( TEXT("OpenProcess") );
else
{
dwPriorityClass = GetPriorityClass( hProcess );
if( !dwPriorityClass )
if (!dwPriorityClass)
printError( TEXT("GetPriorityClass") );
CloseHandle( hProcess );
}
@@ -207,7 +207,7 @@ BOOL GetProcessList( )
printf( "\n Thread count = %d", pe32.cntThreads );
printf( "\n Parent process ID = 0x%08X", pe32.th32ParentProcessID );
printf( "\n Priority base = %d", pe32.pcPriClassBase );
if( dwPriorityClass )
if (dwPriorityClass)
printf( "\n Priority class = %d", dwPriorityClass );
// List the modules and threads associated with this process
@@ -228,7 +228,7 @@ BOOL ListProcessModules( DWORD dwPID )
// Take a snapshot of all modules in the specified process.
hModuleSnap = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, dwPID );
if( hModuleSnap == INVALID_HANDLE_VALUE )
if (hModuleSnap == INVALID_HANDLE_VALUE)
{
printError( TEXT("CreateToolhelp32Snapshot (of modules)") );
return( FALSE );
@@ -239,7 +239,7 @@ BOOL ListProcessModules( DWORD dwPID )
// Retrieve information about the first module,
// and exit if unsuccessful
if( !Module32First( hModuleSnap, &me32 ) )
if (!Module32First( hModuleSnap, &me32 ))
{
printError( TEXT("Module32First") ); // show cause of failure
CloseHandle( hModuleSnap ); // clean the snapshot object
@@ -271,7 +271,7 @@ BOOL ListProcessThreads( DWORD dwOwnerPID )
// Take a snapshot of all running threads
hThreadSnap = CreateToolhelp32Snapshot( TH32CS_SNAPTHREAD, 0 );
if( hThreadSnap == INVALID_HANDLE_VALUE )
if (hThreadSnap == INVALID_HANDLE_VALUE)
return( FALSE );
// Fill in the size of the structure before using it.
@@ -279,7 +279,7 @@ BOOL ListProcessThreads( DWORD dwOwnerPID )
// Retrieve information about the first thread,
// and exit if unsuccessful
if( !Thread32First( hThreadSnap, &te32 ) )
if (!Thread32First( hThreadSnap, &te32 ))
{
printError( TEXT("Thread32First") ); // show cause of failure
CloseHandle( hThreadSnap ); // clean the snapshot object
@@ -291,7 +291,7 @@ BOOL ListProcessThreads( DWORD dwOwnerPID )
// associated with the specified process
do
{
if( te32.th32OwnerProcessID == dwOwnerPID )
if (te32.th32OwnerProcessID == dwOwnerPID)
{
printf( "\n\n THREAD ID = 0x%08X", te32.th32ThreadID );
printf( "\n Base priority = %d", te32.tpBasePri );

View File

@@ -33,9 +33,10 @@
#include "breakhandler.h"
#include "assert.h"
#include "imports.h" // TextEditor::BaseTextMark
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtCore/QFileInfo>
@@ -371,7 +372,7 @@ QVariant BreakHandler::data(const QModelIndex &mi, int role) const
static const QIcon icon2(":/gdbdebugger/images/breakpoint_pending.svg");
static const QString empty = QString(QLatin1Char('-'));
QWB_ASSERT(mi.isValid(), return QVariant());
QTC_ASSERT(mi.isValid(), return QVariant());
if (mi.row() >= size())
return QVariant();
@@ -550,7 +551,7 @@ void BreakHandler::breakByFunction(const QString &functionName)
// One per function is enough for now
for (int index = size(); --index >= 0;) {
const BreakpointData *data = at(index);
QWB_ASSERT(data, break);
QTC_ASSERT(data, break);
if (data->funcName == functionName && data->condition.isEmpty()
&& data->ignoreCount.isEmpty())
return;

View File

@@ -13,8 +13,7 @@ include(../../libs/cplusplus/cplusplus.pri)
# DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII
QT += gui network script
HEADERS += assert.h \
attachexternaldialog.h \
HEADERS += attachexternaldialog.h \
attachremotedialog.h \
breakhandler.h \
breakwindow.h \

View File

@@ -62,6 +62,7 @@
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
#include <QtCore/QTime>
#include <QtCore/QTimer>
#include <QtGui/QAction>
#include <QtGui/QComboBox>
@@ -145,6 +146,7 @@ void DebuggerManager::init()
m_modulesHandler = 0;
m_registerHandler = 0;
m_statusLabel = new QLabel;
m_breakWindow = new BreakWindow;
m_disassemblerWindow = new DisassemblerWindow;
m_modulesWindow = new ModulesWindow;
@@ -157,6 +159,7 @@ void DebuggerManager::init()
//m_tooltipWindow = new WatchWindow(WatchWindow::TooltipType);
//m_watchersWindow = new QTreeView;
m_tooltipWindow = new QTreeView;
m_statusTimer = new QTimer(this);
m_mainWindow = new QMainWindow;
m_mainWindow->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
@@ -349,6 +352,15 @@ void DebuggerManager::init()
m_useFastStartAction->setCheckable(true);
m_useFastStartAction->setChecked(true);
m_useToolTipsAction = new QAction(this);
m_useToolTipsAction->setText(tr("Use Tooltips While Debugging"));
m_useToolTipsAction->setToolTip(tr("Checking this will make enable "
"tooltips for variable values during debugging. Since this can slow "
"down debugging and does not provide reliable information as it does "
"not use scope information, it is switched off by default."));
m_useToolTipsAction->setCheckable(true);
m_useToolTipsAction->setChecked(false);
// FIXME
m_useFastStartAction->setChecked(false);
m_useFastStartAction->setEnabled(false);
@@ -408,6 +420,8 @@ void DebuggerManager::init()
this, SLOT(saveSessionData()));
connect(m_dumpLogAction, SIGNAL(triggered()),
this, SLOT(dumpLog()));
connect(m_statusTimer, SIGNAL(timeout()),
this, SLOT(clearStatusMessage()));
connect(m_outputWindow, SIGNAL(commandExecutionRequested(QString)),
this, SLOT(executeDebuggerCommand(QString)));
@@ -553,24 +567,24 @@ QAbstractItemModel *DebuggerManager::threadsModel()
return qobject_cast<ThreadsWindow*>(m_threadsWindow)->model();
}
void DebuggerManager::clearStatusMessage()
{
m_statusLabel->setText(m_lastPermanentStatusMessage);
}
void DebuggerManager::showStatusMessage(const QString &msg, int timeout)
{
Q_UNUSED(timeout)
//qDebug() << "STATUS: " << msg;
showDebuggerOutput("status:", msg);
mainWindow()->statusBar()->showMessage(msg, timeout);
#if 0
QString currentTime = QTime::currentTime().toString("hh:mm:ss.zzz");
ICore *core = m_pm->getObject<Core::ICore>();
//qDebug() << qPrintable(currentTime) << "Setting status: " << msg;
if (msg.isEmpty())
core->messageManager()->displayStatusBarMessage(msg);
else if (timeout == -1)
core->messageManager()->displayStatusBarMessage(tr("Debugger: ") + msg);
else
core->messageManager()->displayStatusBarMessage(tr("Debugger: ") + msg, timeout);
#endif
m_statusLabel->setText(" " + msg);
if (timeout > 0) {
m_statusTimer->setSingleShot(true);
m_statusTimer->start(timeout);
} else {
m_lastPermanentStatusMessage = msg;
m_statusTimer->stop();
}
}
void DebuggerManager::notifyStartupFinished()
@@ -938,6 +952,8 @@ void DebuggerManager::loadSessionData()
QVariant value;
querySessionValue(QLatin1String("UseFastStart"), &value);
m_useFastStartAction->setChecked(value.toBool());
querySessionValue(QLatin1String("UseToolTips"), &value);
m_useToolTipsAction->setChecked(value.toBool());
querySessionValue(QLatin1String("UseCustomDumpers"), &value);
m_useCustomDumpersAction->setChecked(!value.isValid() || value.toBool());
querySessionValue(QLatin1String("SkipKnownFrames"), &value);
@@ -951,6 +967,8 @@ void DebuggerManager::saveSessionData()
setSessionValue(QLatin1String("UseFastStart"),
m_useFastStartAction->isChecked());
setSessionValue(QLatin1String("UseToolTips"),
m_useToolTipsAction->isChecked());
setSessionValue(QLatin1String("UseCustomDumpers"),
m_useCustomDumpersAction->isChecked());
setSessionValue(QLatin1String("SkipKnownFrames"),

View File

@@ -44,9 +44,11 @@ QT_BEGIN_NAMESPACE
class QAction;
class QAbstractItemModel;
class QDockWidget;
class QLabel;
class QMainWindow;
class QModelIndex;
class QSplitter;
class QTimer;
class QWidget;
QT_END_NAMESPACE
@@ -190,7 +192,8 @@ public:
private:
friend class DebugMode;
virtual QWidget *threadsWindow() = 0;
virtual QWidget *threadsWindow() const = 0;
virtual QLabel *statusLabel() const = 0;
virtual QList<QDockWidget*> dockWidgets() const = 0;
virtual void createDockWidgets() = 0;
};
@@ -213,6 +216,7 @@ public:
IDebuggerManagerAccessForEngines *engineInterface();
IDebuggerManagerAccessForDebugMode *debugModeInterface();
QMainWindow *mainWindow() const { return m_mainWindow; }
QLabel *statusLabel() const { return m_statusLabel; }
enum StartMode { startInternal, startExternal, attachExternal };
enum DebuggerType { GdbDebugger, ScriptDebugger, WinDebugger };
@@ -272,7 +276,7 @@ public slots:
void assignValueInDebugger(const QString &expr, const QString &value);
void executeDebuggerCommand(const QString &command);
void showStatusMessage(const QString &msg, int timeout); // -1 forever
void showStatusMessage(const QString &msg, int timeout = -1); // -1 forever
private slots:
void showDebuggerOutput(const QString &prefix, const QString &msg);
@@ -290,6 +294,7 @@ private slots:
void reloadRegisters();
void registerDockToggled(bool on);
void setStatus(int status);
void clearStatusMessage();
private:
//
@@ -303,6 +308,7 @@ private:
ThreadsHandler *threadsHandler() { return m_threadsHandler; }
WatchHandler *watchHandler() { return m_watchHandler; }
QAction *useCustomDumpersAction() const { return m_useCustomDumpersAction; }
QAction *useToolTipsAction() const { return m_useToolTipsAction; }
QAction *debugDumpersAction() const { return m_debugDumpersAction; }
bool skipKnownFrames() const;
bool debugDumpers() const;
@@ -322,7 +328,7 @@ private:
//
// Implementation of IDebuggerManagerAccessForDebugMode
//
QWidget *threadsWindow() { return m_threadsWindow; }
QWidget *threadsWindow() const { return m_threadsWindow; }
QList<QDockWidget*> dockWidgets() const { return m_dockWidgets; }
void createDockWidgets();
@@ -382,6 +388,7 @@ private:
/// Views
QMainWindow *m_mainWindow;
QLabel *m_statusLabel;
QDockWidget *m_breakDock;
QDockWidget *m_disassemblerDock;
QDockWidget *m_modulesDock;
@@ -425,6 +432,7 @@ private:
QAction *m_debugDumpersAction;
QAction *m_useCustomDumpersAction;
QAction *m_useFastStartAction;
QAction *m_useToolTipsAction;
QAction *m_dumpLogAction;
QWidget *m_breakWindow;
@@ -440,6 +448,8 @@ private:
int m_status;
bool m_busy;
QTimer *m_statusTimer;
QString m_lastPermanentStatusMessage;
IDebuggerEngine *engine();
IDebuggerEngine *m_engine;

View File

@@ -285,6 +285,7 @@ void DebuggerOutputWindow::showOutput(const QString &prefix, const QString &outp
void DebuggerOutputWindow::showInput(const QString &prefix, const QString &input)
{
Q_UNUSED(prefix);
m_inputText->append(input);
QTextCursor cursor = m_inputText->textCursor();
cursor.movePosition(QTextCursor::End);

View File

@@ -33,7 +33,6 @@
#include "debuggerplugin.h"
#include "assert.h"
#include "debuggerconstants.h"
#include "debuggermanager.h"
#include "debuggerrunner.h"
@@ -48,20 +47,27 @@
#include <coreplugin/messagemanager.h>
#include <coreplugin/modemanager.h>
#include <coreplugin/uniqueidmanager.h>
#include <cplusplus/ExpressionUnderCursor.h>
#include <cppeditor/cppeditorconstants.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/session.h>
#include <texteditor/basetexteditor.h>
#include <texteditor/basetextmark.h>
#include <texteditor/itexteditor.h>
#include <texteditor/texteditorconstants.h>
#include <texteditor/basetexteditor.h>
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtCore/qplugin.h>
#include <QtCore/QObject>
#include <QtCore/QPoint>
#include <QtCore/QSettings>
#include <QtGui/QPlainTextEdit>
#include <QtGui/QTextBlock>
#include <QtGui/QTextCursor>
@@ -91,6 +97,7 @@ const char * const DEBUG_DUMPERS = "Debugger.DebugDumpers";
const char * const ADD_TO_WATCH = "Debugger.AddToWatch";
const char * const USE_CUSTOM_DUMPERS = "Debugger.UseCustomDumpers";
const char * const USE_FAST_START = "Debugger.UseFastStart";
const char * const USE_TOOL_TIPS = "Debugger.UseToolTips";
const char * const SKIP_KNOWN_FRAMES = "Debugger.SkipKnownFrames";
const char * const DUMP_LOG = "Debugger.DumpLog";
@@ -188,7 +195,7 @@ void DebuggerPlugin::shutdown()
{
if (m_debugMode)
m_debugMode->shutdown(); // saves state including manager information
QWB_ASSERT(m_manager, /**/);
QTC_ASSERT(m_manager, /**/);
if (m_manager)
m_manager->shutdown();
@@ -225,13 +232,13 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *error_mes
m_pm = ExtensionSystem::PluginManager::instance();
ICore *core = m_pm->getObject<Core::ICore>();
QWB_ASSERT(core, return false);
QTC_ASSERT(core, return false);
Core::ActionManagerInterface *actionManager = core->actionManager();
QWB_ASSERT(actionManager, return false);
QTC_ASSERT(actionManager, return false);
Core::UniqueIDManager *uidm = core->uniqueIDManager();
QWB_ASSERT(uidm, return false);
QTC_ASSERT(uidm, return false);
QList<int> globalcontext;
globalcontext << Core::Constants::C_GLOBAL_ID;
@@ -250,6 +257,12 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *error_mes
m_gdbRunningContext = uidm->uniqueIdentifier(Constants::GDBRUNNING);
m_breakpointMarginAction = new QAction(this);
m_breakpointMarginAction->setText("Toggle Breakpoint");
//m_breakpointMarginAction->setIcon(QIcon(":/gdbdebugger/images/breakpoint.svg"));
connect(m_breakpointMarginAction, SIGNAL(triggered()),
this, SLOT(breakpointMarginActionTriggered()));
//Core::IActionContainer *mcppcontext =
// actionManager->actionContainer(CppEditor::Constants::M_CONTEXT);
@@ -368,13 +381,17 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *error_mes
Constants::USE_FAST_START, globalcontext);
mdebug->addAction(cmd);
cmd = actionManager->registerAction(m_manager->m_useToolTipsAction,
Constants::USE_TOOL_TIPS, globalcontext);
mdebug->addAction(cmd);
#ifdef QT_DEBUG
cmd = actionManager->registerAction(m_manager->m_dumpLogAction,
Constants::DUMP_LOG, globalcontext);
//cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+D,Ctrl+L")));
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F11")));
mdebug->addAction(cmd);
#ifdef QT_DEBUG
cmd = actionManager->registerAction(m_manager->m_debugDumpersAction,
Constants::DEBUG_DUMPERS, debuggercontext);
mdebug->addAction(cmd);
@@ -502,6 +519,8 @@ void DebuggerPlugin::editorOpened(Core::IEditor *editor)
this, SLOT(requestMark(TextEditor::ITextEditor*,int)));
connect(editor, SIGNAL(tooltipRequested(TextEditor::ITextEditor*,QPoint,int)),
this, SLOT(showToolTip(TextEditor::ITextEditor*,QPoint,int)));
connect(textEditor, SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)),
this, SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*)));
}
}
@@ -512,9 +531,27 @@ void DebuggerPlugin::editorAboutToClose(Core::IEditor *editor)
this, SLOT(requestMark(TextEditor::ITextEditor*,int)));
disconnect(editor, SIGNAL(tooltipRequested(TextEditor::ITextEditor*,QPoint,int)),
this, SLOT(showToolTip(TextEditor::ITextEditor*,QPoint,int)));
disconnect(textEditor, SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)),
this, SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*)));
}
}
void DebuggerPlugin::requestContextMenu(TextEditor::ITextEditor *editor,
int lineNumber, QMenu *menu)
{
m_breakpointMarginActionLineNumber = lineNumber;
m_breakpointMarginActionFileName = editor->file()->fileName();
menu->addAction(m_breakpointMarginAction);
}
void DebuggerPlugin::breakpointMarginActionTriggered()
{
m_manager->toggleBreakpoint(
m_breakpointMarginActionFileName,
m_breakpointMarginActionLineNumber
);
}
void DebuggerPlugin::requestMark(TextEditor::ITextEditor *editor, int lineNumber)
{
m_manager->toggleBreakpoint(editor->file()->fileName(), lineNumber);
@@ -523,6 +560,9 @@ void DebuggerPlugin::requestMark(TextEditor::ITextEditor *editor, int lineNumber
void DebuggerPlugin::showToolTip(TextEditor::ITextEditor *editor,
const QPoint &point, int pos)
{
if (!m_manager->useToolTipsAction()->isChecked())
return;
QPlainTextEdit *plaintext = qobject_cast<QPlainTextEdit*>(editor->widget());
if (!plaintext)
return;
@@ -564,13 +604,13 @@ void DebuggerPlugin::querySessionValue(const QString &name, QVariant *value)
void DebuggerPlugin::setConfigValue(const QString &name, const QVariant &value)
{
QWB_ASSERT(m_debugMode, return);
QTC_ASSERT(m_debugMode, return);
m_debugMode->settings()->setValue(name, value);
}
void DebuggerPlugin::queryConfigValue(const QString &name, QVariant *value)
{
QWB_ASSERT(m_debugMode, return);
QTC_ASSERT(m_debugMode, return);
*value = m_debugMode->settings()->value(name);
}

View File

@@ -84,10 +84,14 @@ private slots:
void setSessionValue(const QString &name, const QVariant &value);
void queryConfigValue(const QString &name, QVariant *value);
void setConfigValue(const QString &name, const QVariant &value);
void requestContextMenu(TextEditor::ITextEditor *editor,
int lineNumber, QMenu *menu);
void resetLocation();
void gotoLocation(const QString &fileName, int line, bool setMarker);
void breakpointMarginActionTriggered();
private:
friend class DebuggerManager;
friend class DebugMode; // FIXME: Just a hack now so that it can access the views
@@ -104,6 +108,10 @@ private:
QString m_previousMode;
LocationMark *m_locationMark;
int m_gdbRunningContext;
QAction *m_breakpointMarginAction;
int m_breakpointMarginActionLineNumber;
QString m_breakpointMarginActionFileName;
};
} // namespace Internal

View File

@@ -33,7 +33,6 @@
#include "debuggerrunner.h"
#include "assert.h"
#include "debuggermanager.h"
#include <projectexplorer/applicationrunconfiguration.h>
@@ -41,9 +40,12 @@
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
#include <QtGui/QTextDocument>
using namespace Debugger::Internal;
@@ -76,11 +78,10 @@ QString DebuggerRunner::displayName() const
RunControl* DebuggerRunner::run(RunConfigurationPtr runConfiguration, const QString &mode)
{
Q_UNUSED(mode);
Q_ASSERT(mode == ProjectExplorer::Constants::DEBUGMODE);
QTC_ASSERT(mode == ProjectExplorer::Constants::DEBUGMODE, return 0);
ApplicationRunConfigurationPtr rc =
qSharedPointerCast<ApplicationRunConfiguration>(runConfiguration);
Q_ASSERT(rc);
QTC_ASSERT(rc, return 0);
//qDebug() << "***** Debugging" << rc->name() << rc->executable();
return new DebuggerRunControl(m_manager, rc);
}
@@ -118,9 +119,9 @@ void DebuggerRunControl::start()
m_running = true;
ApplicationRunConfigurationPtr rc =
qSharedPointerCast<ApplicationRunConfiguration>(runConfiguration());
QWB_ASSERT(rc, return);
QTC_ASSERT(rc, return);
ProjectExplorer::Project *project = rc->project();
QWB_ASSERT(project, return);
QTC_ASSERT(project, return);
m_manager->m_executable = rc->executable();
m_manager->m_environment = rc->environment().toStringList();

View File

@@ -33,7 +33,6 @@
#include "gdbengine.h"
#include "assert.h"
#include "debuggerconstants.h"
#include "debuggermanager.h"
#include "gdbmi.h"
@@ -49,6 +48,8 @@
#include "startexternaldialog.h"
#include "attachexternaldialog.h"
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
@@ -278,25 +279,8 @@ void GdbEngine::init()
connect(&m_gdbProc, SIGNAL(finished(int, QProcess::ExitStatus)), q,
SLOT(exitDebugger()));
// Custom dumpers
//m_dumperServerConnection = 0;
//m_dumperServer = new DumperServer(this);
//QString name = "gdb-" +
// QDateTime::currentDateTime().toString("yyyy_MM_dd-hh_mm_ss_zzz");
//m_dumperServer->listen(name);
//connect(m_dumperServer, SIGNAL(newConnection()),
// this, SLOT(acceptConnection()));
//if (!m_dumperServer->isListening()) {
// QMessageBox::critical(q->mainWindow(), tr("Dumper Server Setup Failed"),
// tr("Unable to create server listening for data: %1.\n"
// "Server name: %2").arg(m_dumperServer->errorString(), name),
// QMessageBox::Retry | QMessageBox::Cancel);
// }
connect(qq->debugDumpersAction(), SIGNAL(toggled(bool)),
this, SLOT(setDebugDumpers(bool)));
connect(qq->useCustomDumpersAction(), SIGNAL(toggled(bool)),
this, SLOT(setCustomDumpersWanted(bool)));
@@ -347,7 +331,7 @@ void GdbEngine::gdbProcError(QProcess::ProcessError error)
"This is the default return value of error().");
}
q->showStatusMessage(msg, 5000);
q->showStatusMessage(msg);
QMessageBox::critical(q->mainWindow(), tr("Error"), msg);
// act as if it was closed by the core
q->exitDebugger();
@@ -451,7 +435,7 @@ void GdbEngine::handleResponse()
while (from != to && *from != '\n')
s += *from++;
//qDebug() << "UNREQUESTED DATA " << s << " TAKEN AS APPLICATION OUTPUT";
s += '\n';
//s += '\n';
m_inbuffer = QByteArray(from, to - from);
emit applicationOutputAvailable("app-stdout: ", s);
@@ -470,7 +454,7 @@ void GdbEngine::handleResponse()
for (; from != to; ++from) {
const char c = *from;
if (!isNameChar(c))
break;
break;
asyncClass += *from;
}
//qDebug() << "ASYNCCLASS" << asyncClass;
@@ -647,7 +631,7 @@ void GdbEngine::readGdbStandardOutput()
#endif
m_inbuffer.append(out);
//QWB_ASSERT(!m_inbuffer.isEmpty(), return);
//QTC_ASSERT(!m_inbuffer.isEmpty(), return);
char c = m_inbuffer[m_inbuffer.size() - 1];
static const QByteArray termArray("(gdb) ");
@@ -710,7 +694,7 @@ void GdbEngine::sendCommand(const QString &command, int type,
bool temporarilyStopped = false;
if (needStop && q->status() == DebuggerInferiorRunning) {
q->showStatusMessage(tr("Temporarily stopped"), -1);
q->showStatusMessage(tr("Temporarily stopped"));
interruptInferior();
temporarilyStopped = true;
}
@@ -1055,7 +1039,7 @@ void GdbEngine::handleExecJumpToLine(const GdbResultRecord &record)
// ~"242\t x *= 2;"
//109^done"
qq->notifyInferiorStopped();
q->showStatusMessage(tr("Jumped. Stopped."), -1);
q->showStatusMessage(tr("Jumped. Stopped."));
QString output = record.data.findChild("logstreamoutput").data();
if (!output.isEmpty())
return;
@@ -1074,7 +1058,7 @@ void GdbEngine::handleExecRunToFunction(const GdbResultRecord &record)
// func="foo",args=[{name="str",value="@0x7fff0f450460"}],
// file="main.cpp",fullname="/tmp/g/main.cpp",line="37"}
qq->notifyInferiorStopped();
q->showStatusMessage(tr("Run to Function finished. Stopped."), -1);
q->showStatusMessage(tr("Run to Function finished. Stopped."));
GdbMi frame = record.data.findChild("frame");
QString file = frame.findChild("fullname").data();
int line = frame.findChild("line").data().toInt();
@@ -1212,7 +1196,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
}
} else {
// slow start requested.
q->showStatusMessage("Loading " + data.toString(), -1);
q->showStatusMessage(tr("Loading %1...").arg(QString(data.toString())));
continueInferior();
}
return;
@@ -1231,7 +1215,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
msg = "Program exited after receiving signal "
+ data.findChild("signal-name").toString();
}
q->showStatusMessage(msg, -1);
q->showStatusMessage(msg);
q->exitDebugger();
return;
}
@@ -1271,17 +1255,19 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
if (isStoppedReason(reason) || reason.isEmpty()) {
// Need another round trip
if (reason == "breakpoint-hit") {
q->showStatusMessage(tr("Stopped at breakpoint"));
GdbMi frame = data.findChild("frame");
//qDebug() << frame.toString();
m_currentFrame = frame.findChild("addr").data() + '%' +
frame.findChild("func").data() + '%';
QApplication::alert(q->mainWindow(), 200);
QApplication::alert(q->mainWindow(), 3000);
sendCommand("-file-list-exec-source-files", GdbQuerySources);
sendCommand("-break-list", BreakList);
QVariant var = QVariant::fromValue<GdbMi>(data);
sendCommand("p 0", GdbAsyncOutput2, var); // dummy
} else {
q->showStatusMessage(tr("Stopped: \"%1\"").arg(reason));
handleAsyncOutput2(data);
}
return;
@@ -1303,7 +1289,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
// system="0.00136",start="1218810678.805432",end="1218810678.812011"}
q->resetLocation();
qq->notifyInferiorStopped();
q->showStatusMessage(tr("Run to Function finished. Stopped."), -1);
q->showStatusMessage(tr("Run to Function finished. Stopped."));
GdbMi frame = data.findChild("frame");
QString file = frame.findChild("fullname").data();
int line = frame.findChild("line").data().toInt();
@@ -1376,8 +1362,9 @@ void GdbEngine::handleShowVersion(const GdbResultRecord &response)
if (response.resultClass == GdbResultDone) {
m_gdbVersion = 100;
QString msg = response.data.findChild("consolestreamoutput").data();
QRegExp supported("GNU gdb 6.[6789]");
if (msg.indexOf(supported) == -1) {
QRegExp supported("GNU gdb(.*) (\\d+)\\.(\\d+)\\.(\\d+)");
if (supported.indexIn(msg) == -1) {
qDebug() << "UNSUPPORTED GDB VERSION " << msg;
QStringList list = msg.split("\n");
while (list.size() > 2)
list.removeLast();
@@ -1394,11 +1381,11 @@ void GdbEngine::handleShowVersion(const GdbResultRecord &response)
#else
//QMessageBox::information(m_mainWindow, tr("Warning"), msg);
#endif
}
int pos = msg.indexOf("GNU gdb 6.");
if (pos != -1) {
m_gdbVersion = 600 + (msg.at(pos + 10).unicode() - '0') * 10;
//qDebug() << "GDB VERSION " << m_gdbVersion << msg;
} else {
m_gdbVersion = 10000 * supported.cap(2).toInt()
+ 100 * supported.cap(3).toInt()
+ 1 * supported.cap(4).toInt();
//qDebug() << "GDB VERSION " << m_gdbVersion;
}
}
}
@@ -1412,7 +1399,7 @@ void GdbEngine::handleFileExecAndSymbols
QString msg = response.data.findChild("msg").data();
QMessageBox::critical(q->mainWindow(), tr("Error"),
tr("Starting executable failed:\n") + msg);
QWB_ASSERT(q->status() == DebuggerInferiorRunning, /**/);
QTC_ASSERT(q->status() == DebuggerInferiorRunning, /**/);
interruptInferior();
}
}
@@ -1421,19 +1408,19 @@ void GdbEngine::handleExecRun(const GdbResultRecord &response)
{
if (response.resultClass == GdbResultRunning) {
qq->notifyInferiorRunning();
q->showStatusMessage(tr("Running..."), -1);
q->showStatusMessage(tr("Running..."));
//reloadModules();
} else if (response.resultClass == GdbResultError) {
QString msg = response.data.findChild("msg").data();
if (msg == "Cannot find bounds of current function") {
qq->notifyInferiorStopped();
//q->showStatusMessage(tr("No debug information available. "
// "Leaving function..."), -1);
// "Leaving function..."));
//stepOutExec();
} else {
QMessageBox::critical(q->mainWindow(), tr("Error"),
tr("Starting executable failed:\n") + msg);
QWB_ASSERT(q->status() == DebuggerInferiorRunning, /**/);
QTC_ASSERT(q->status() == DebuggerInferiorRunning, /**/);
interruptInferior();
}
}
@@ -1556,7 +1543,7 @@ bool GdbEngine::startDebugger()
qDebug() << "ExeFile: " << q->m_executable;
#endif
q->showStatusMessage("Starting Debugger", -1);
q->showStatusMessage(tr("Starting Debugger"));
emit gdbInputAvailable(QString(), theGdbSettings().m_gdbCmd + ' ' + gdbArgs.join(" "));
m_gdbProc.start(theGdbSettings().m_gdbCmd, gdbArgs);
@@ -1565,7 +1552,7 @@ bool GdbEngine::startDebugger()
if (m_gdbProc.state() != QProcess::Running)
return false;
q->showStatusMessage(tr("Gdb Running"), -1);
q->showStatusMessage(tr("Gdb Running"));
sendCommand("show version", GdbShowVersion);
if (qq->useFastStart()) {
@@ -2335,8 +2322,8 @@ void GdbEngine::handleModulesList(const GdbResultRecord &record)
void GdbEngine::handleStackSelectThread(const GdbResultRecord &record, int)
{
Q_UNUSED(record);
qDebug("FIXME: StackHandler::handleOutput: SelectThread");
q->showStatusMessage(tr("Retrieving data for stack view..."), -1);
//qDebug("FIXME: StackHandler::handleOutput: SelectThread");
q->showStatusMessage(tr("Retrieving data for stack view..."), 3000);
sendCommand("-stack-list-frames", StackListFrames);
}
@@ -2428,9 +2415,9 @@ void GdbEngine::selectThread(int index)
threadsHandler->setCurrentThread(index);
QList<ThreadData> threads = threadsHandler->threads();
QWB_ASSERT(index < threads.size(), return);
QTC_ASSERT(index < threads.size(), return);
int id = threads.at(index).id;
q->showStatusMessage(tr("Retrieving data for stack view..."), -1);
q->showStatusMessage(tr("Retrieving data for stack view..."), 10000);
sendCommand(QLatin1String("-thread-select ") + QString::number(id),
StackSelectThread);
}
@@ -2445,7 +2432,7 @@ void GdbEngine::activateFrame(int frameIndex)
//qDebug() << "ACTIVATE FRAME: " << frameIndex << oldIndex
// << stackHandler->currentIndex();
QWB_ASSERT(frameIndex < stackHandler->stackSize(), return);
QTC_ASSERT(frameIndex < stackHandler->stackSize(), return);
if (oldIndex != frameIndex) {
// Assuming this always succeeds saves a roundtrip.
@@ -2543,7 +2530,7 @@ bool GdbEngine::supportsThreads() const
{
// 6.3 crashes happily on -thread-list-ids. So don't use it.
// The test below is a semi-random pick, 6.8 works fine
return m_gdbVersion > 650;
return m_gdbVersion > 60500;
}
//////////////////////////////////////////////////////////////////////
@@ -2966,7 +2953,7 @@ bool GdbEngine::isCustomValueDumperAvailable(const QString &type) const
void GdbEngine::runCustomDumper(const WatchData & data0, bool dumpChildren)
{
WatchData data = data0;
QWB_ASSERT(!data.exp.isEmpty(), return);
QTC_ASSERT(!data.exp.isEmpty(), return);
QString tmplate;
QString inner;
bool isTemplate = extractTemplate(data.type, &tmplate, &inner);
@@ -3079,7 +3066,7 @@ void GdbEngine::runCustomDumper(const WatchData & data0, bool dumpChildren)
q->showStatusMessage(
tr("Retrieving data for watch view (%1 requests pending)...")
.arg(m_pendingRequests + 1), -1);
.arg(m_pendingRequests + 1), 10000);
// create response slot for socket data
QVariant var;
var.setValue(data);
@@ -3107,7 +3094,7 @@ void GdbEngine::updateSubItem(const WatchData &data0)
#if DEBUG_SUBITEM
qDebug() << "UPDATE SUBITEM: " << data.toString();
#endif
QWB_ASSERT(data.isValid(), return);
QTC_ASSERT(data.isValid(), return);
// in any case we need the type first
if (data.isTypeNeeded()) {
@@ -3135,7 +3122,7 @@ void GdbEngine::updateSubItem(const WatchData &data0)
}
// we should have a type now. this is relied upon further below
QWB_ASSERT(!data.type.isEmpty(), return);
QTC_ASSERT(!data.type.isEmpty(), return);
// a common case that can be easily solved
if (data.isChildrenNeeded() && isPointerType(data.type)
@@ -3193,7 +3180,7 @@ void GdbEngine::updateSubItem(const WatchData &data0)
}
if (data.isValueNeeded()) {
QWB_ASSERT(!data.variable.isEmpty(), return); // tested above
QTC_ASSERT(!data.variable.isEmpty(), return); // tested above
#if DEBUG_SUBITEM
qDebug() << "UPDATE SUBITEM: VALUE";
#endif
@@ -3222,7 +3209,7 @@ void GdbEngine::updateSubItem(const WatchData &data0)
}
if (data.isChildrenNeeded()) {
QWB_ASSERT(!data.variable.isEmpty(), return); // tested above
QTC_ASSERT(!data.variable.isEmpty(), return); // tested above
QString cmd = "-var-list-children --all-values \"" + data.variable + "\"";
sendSynchronizedCommand(cmd, WatchVarListChildren, QVariant::fromValue(data));
return;
@@ -3247,14 +3234,14 @@ void GdbEngine::updateSubItem(const WatchData &data0)
}
if (data.isChildCountNeeded()) {
QWB_ASSERT(!data.variable.isEmpty(), return); // tested above
QTC_ASSERT(!data.variable.isEmpty(), return); // tested above
QString cmd = "-var-list-children --all-values \"" + data.variable + "\"";
sendCommand(cmd, WatchVarListChildren, QVariant::fromValue(data));
return;
}
qDebug() << "FIXME: UPDATE SUBITEM: " << data.toString();
QWB_ASSERT(false, return);
QTC_ASSERT(false, return);
}
void GdbEngine::updateWatchModel()
@@ -3268,7 +3255,7 @@ void GdbEngine::updateWatchModel2()
{
PENDING_DEBUG("UPDATE WATCH MODEL");
QList<WatchData> incomplete = qq->watchHandler()->takeCurrentIncompletes();
//QWB_ASSERT(incomplete.isEmpty(), /**/);
//QTC_ASSERT(incomplete.isEmpty(), /**/);
if (!incomplete.isEmpty()) {
#if DEBUG_PENDING
qDebug() << "##############################################";
@@ -3297,7 +3284,7 @@ void GdbEngine::updateWatchModel2()
PENDING_DEBUG("REBUILDING MODEL")
emit gdbInputAvailable(QString(),
"[" + currentTime() + "] <Rebuild Watchmodel>");
q->showStatusMessage(tr("Finished retrieving data."), -1);
q->showStatusMessage(tr("Finished retrieving data."), 400);
qq->watchHandler()->rebuildModel();
if (!m_toolTipExpression.isEmpty()) {
@@ -3311,9 +3298,6 @@ void GdbEngine::updateWatchModel2()
"Cannot evaluate expression: " + m_toolTipExpression);
}
}
//qDebug() << "INSERT DATA" << data0.toString();
//q->showStatusMessage(tr("Stopped."), 5000);
}
void GdbEngine::handleQueryDataDumper1(const GdbResultRecord &record)
@@ -3436,7 +3420,7 @@ void GdbEngine::handleEvaluateExpression(const GdbResultRecord &record,
const WatchData &data0)
{
WatchData data = data0;
QWB_ASSERT(data.isValid(), qDebug() << "HUH?");
QTC_ASSERT(data.isValid(), qDebug() << "HUH?");
if (record.resultClass == GdbResultDone) {
//if (col == 0)
// data.name = record.data.findChild("value").data();
@@ -3464,7 +3448,7 @@ void GdbEngine::handleDumpCustomValue1(const GdbResultRecord &record,
const WatchData &data0)
{
WatchData data = data0;
QWB_ASSERT(data.isValid(), return);
QTC_ASSERT(data.isValid(), return);
if (record.resultClass == GdbResultDone) {
// ignore this case, data will follow
} else if (record.resultClass == GdbResultError) {
@@ -3498,7 +3482,7 @@ void GdbEngine::handleDumpCustomValue2(const GdbResultRecord &record,
const WatchData &data0)
{
WatchData data = data0;
QWB_ASSERT(data.isValid(), return);
QTC_ASSERT(data.isValid(), return);
//qDebug() << "CUSTOM VALUE RESULT: " << record.toString();
//qDebug() << "FOR DATA: " << data.toString() << record.resultClass;
if (record.resultClass == GdbResultDone) {
@@ -3659,10 +3643,20 @@ void GdbEngine::setLocals(const QList<GdbMi> &locals)
QHash<QString, int> seen;
foreach (const GdbMi &item, locals) {
// Local variables of inlined code are reported as
// 26^done,locals={varobj={exp="this",value="",name="var4",exp="this",
// numchild="1",type="const QtSharedPointer::Basic<CPlusPlus::..."
// We do not want these at all. Current hypotheses is that those
// "spurious" locals have _two_ "exp" field. Try to filter them:
#ifdef Q_OS_MAC
QString name = item.findChild("exp").data();
int numExps = 0;
foreach (const GdbMi &child, item.children())
numExps += int(child.name() == "exp");
if (numExps > 1)
continue;
QString name = item.findChild("exp").data();
#else
QString name = item.findChild("name").data();
QString name = item.findChild("name").data();
#endif
int n = seen.value(name);
if (n) {
@@ -3895,7 +3889,7 @@ void GdbEngine::handleToolTip(const GdbResultRecord &record,
if (isCustomValueDumperAvailable(m_toolTip.type))
runCustomDumper(m_toolTip, false);
else
q->showStatusMessage(tr("Retrieving data for tooltip..."), -1);
q->showStatusMessage(tr("Retrieving data for tooltip..."), 10000);
sendCommand("-data-evaluate-expression " + m_toolTip.exp,
WatchToolTip, "evaluate");
//sendToolTipCommand("-var-evaluate-expression tooltip")
@@ -3970,7 +3964,7 @@ void GdbEngine::tryLoadCustomDumpers()
if (qq->useFastStart())
sendCommand("set stop-on-solib-events 0");
QString flag = QString::number(RTLD_NOW);
sendCommand("call dlopen(\"" + lib + "\", " + flag + ")");
sendCommand("call (void)dlopen(\"" + lib + "\", " + flag + ")");
sendCommand("sharedlibrary " + dotEscape(lib));
if (qq->useFastStart())
sendCommand("set stop-on-solib-events 1");

View File

@@ -34,6 +34,9 @@
#ifndef DEBUGGER_GDBENGINE_H
#define DEBUGGER_GDBENGINE_H
#include "idebuggerengine.h"
#include "gdbmi.h"
#include <QtCore/QByteArray>
#include <QtCore/QHash>
#include <QtCore/QMap>
@@ -48,9 +51,6 @@ class QAbstractItemModel;
class QWidget;
QT_END_NAMESPACE
#include "idebuggerengine.h"
#include "gdbmi.h"
namespace Debugger {
namespace Internal {

View File

@@ -32,10 +32,10 @@
***************************************************************************/
#include "gdbmi.h"
#include "assert.h"
#include <utils/qtcassert.h>
#include <QtCore/QByteArray>
#include <QtCore/QDebug>
#include <QtCore/QTextStream>
namespace Debugger {
@@ -138,7 +138,7 @@ void GdbMi::parseValue(const Char *&from, const Char *to)
void GdbMi::parseTuple(const Char *&from, const Char *to)
{
//qDebug() << "parseTuple: " << QByteArray::fromUtf16(from, to - from);
QWB_ASSERT(*from == '{', /**/);
QTC_ASSERT(*from == '{', /**/);
++from;
parseTuple_helper(from, to);
}
@@ -166,7 +166,7 @@ void GdbMi::parseTuple_helper(const Char *&from, const Char *to)
void GdbMi::parseList(const Char *&from, const Char *to)
{
//qDebug() << "parseList: " << QByteArray::fromUtf16(from, to - from);
QWB_ASSERT(*from == '[', /**/);
QTC_ASSERT(*from == '[', /**/);
++from;
m_type = List;
while (from < to) {

View File

@@ -59,10 +59,10 @@ TypeMacroPage::TypeMacroPage(GdbSettings *settings)
//insert qt4 defaults
m_settings->m_scriptFile = coreIFace->resourcePath() +
QLatin1String("/gdb/qt4macros");
for (int i=0; i<3; ++i) {
for (int i = 0; i < 3; ++i) {
QByteArray data;
QDataStream stream(&data, QIODevice::WriteOnly);
switch(i) {
switch (i) {
case 0:
stream << QString("printqstring") << (int)1;
m_settings->m_typeMacros.insert(QLatin1String("QString"), data);
@@ -154,7 +154,7 @@ void TypeMacroPage::finished(bool accepted)
m_settings->m_typeMacros.clear();
m_settings->m_scriptFile = m_ui.scriptEdit->text();
for (int i=0; i<m_ui.treeWidget->topLevelItemCount(); ++i) {
for (int i = 0; i < m_ui.treeWidget->topLevelItemCount(); ++i) {
QTreeWidgetItem *item = m_ui.treeWidget->topLevelItem(i);
QByteArray data;
QDataStream stream(&data, QIODevice::WriteOnly);

View File

@@ -36,6 +36,11 @@
#include <QtCore/QObject>
QT_BEGIN_NAMESPACE
class QPoint;
class QString;
QT_END_NAMESPACE
namespace Debugger {
namespace Internal {

View File

@@ -33,7 +33,6 @@
#include "mode.h"
#include "assert.h"
#include "debuggerconstants.h"
#include "debuggermanager.h"
@@ -48,10 +47,14 @@
#include <coreplugin/outputpane.h>
#include <coreplugin/navigationwidget.h>
#include <coreplugin/rightpane.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtCore/QSettings>
#include <QtGui/QDockWidget>
#include <QtGui/QLabel>
#include <QtGui/QMainWindow>
@@ -169,6 +172,8 @@ QToolBar *DebugMode::createToolBar()
managerAccess->threadsWindow(), SIGNAL(threadSelected(int)));
debugToolBar->addWidget(threadBox);
debugToolBar->addWidget(managerAccess->statusLabel());
QWidget *stretch = new QWidget;
stretch->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
debugToolBar->addWidget(stretch);
@@ -211,8 +216,8 @@ void DebugMode::focusCurrentEditor(IMode *mode)
void DebugMode::writeSettings() const
{
QSettings *s = settings();
QWB_ASSERT(m_manager, return);
QWB_ASSERT(m_manager->mainWindow(), return);
QTC_ASSERT(m_manager, return);
QTC_ASSERT(m_manager->mainWindow(), return);
s->beginGroup(QLatin1String("DebugMode"));
s->setValue(QLatin1String("State"), m_manager->mainWindow()->saveState());
s->setValue(QLatin1String("Locked"), m_toggleLockedAction->isChecked());

View File

@@ -33,19 +33,18 @@
#include "scriptengine.h"
#include "assert.h"
#include "attachexternaldialog.h"
#include "breakhandler.h"
#include "debuggerconstants.h"
#include "debuggermanager.h"
#include "disassemblerhandler.h"
#include "breakhandler.h"
#include "moduleshandler.h"
#include "registerhandler.h"
#include "stackhandler.h"
#include "startexternaldialog.h"
#include "watchhandler.h"
#include "startexternaldialog.h"
#include "attachexternaldialog.h"
#include <utils/qtcassert.h>
#include <QtCore/QDateTime>
#include <QtCore/QDebug>
@@ -574,7 +573,7 @@ void ScriptEngine::updateSubItem(const WatchData &data0)
{
WatchData data = data0;
//qDebug() << "\nUPDATE SUBITEM: " << data.toString();
QWB_ASSERT(data.isValid(), return);
QTC_ASSERT(data.isValid(), return);
if (data.isTypeNeeded() || data.isValueNeeded()) {
QScriptValue ob = data.scriptValue;
@@ -667,7 +666,7 @@ void ScriptEngine::updateSubItem(const WatchData &data0)
return;
}
QWB_ASSERT(false, return);
QTC_ASSERT(false, return);
}
IDebuggerEngine *createScriptEngine(DebuggerManager *parent)

View File

@@ -33,7 +33,7 @@
#include "stackhandler.h"
#include "assert.h"
#include <utils/qtcassert.h>
#include <QtCore/QAbstractTableModel>
#include <QtCore/QDebug>
@@ -128,8 +128,8 @@ Qt::ItemFlags StackHandler::flags(const QModelIndex &index) const
StackFrame StackHandler::currentFrame() const
{
QWB_ASSERT(m_currentIndex >= 0, return StackFrame());
QWB_ASSERT(m_currentIndex < m_stackFrames.size(), return StackFrame());
QTC_ASSERT(m_currentIndex >= 0, return StackFrame());
QTC_ASSERT(m_currentIndex < m_stackFrames.size(), return StackFrame());
return m_stackFrames.at(m_currentIndex);
}

View File

@@ -88,7 +88,7 @@ QString StartExternalDialog::executableArguments() const
result << QLatin1String("--args");
result << execEdit->text();
for(int i=0; i<args.length(); ++i) {
for (int i = 0; i < args.length(); ++i) {
current = args.at(i);
if (current == QLatin1Char('\"') && last != QLatin1Char('\\')) {

View File

@@ -37,7 +37,7 @@
#include "modeltest.h"
#endif
#include "assert.h"
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtCore/QEvent>
@@ -118,7 +118,7 @@ static QByteArray quoteUnprintable(const QByteArray &ba)
QByteArray res;
char buf[10];
for (int i = 0, n = ba.size(); i != n; ++i) {
char c = ba.at(i);
unsigned char c = ba.at(i);
if (isprint(c)) {
res += c;
} else {
@@ -320,6 +320,51 @@ static WatchData take(const QString &iname, QList<WatchData> *list)
}
static QList<WatchData> initialSet()
{
QList<WatchData> result;
WatchData root;
root.state = 0;
root.level = 0;
root.row = 0;
root.name = "Root";
root.parentIndex = -1;
root.childIndex.append(1);
root.childIndex.append(2);
root.childIndex.append(3);
result.append(root);
WatchData local;
local.iname = "local";
local.name = "Locals";
local.state = 0;
local.level = 1;
local.row = 0;
local.parentIndex = 0;
result.append(local);
WatchData tooltip;
tooltip.iname = "tooltip";
tooltip.name = "Tooltip";
tooltip.state = 0;
tooltip.level = 1;
tooltip.row = 1;
tooltip.parentIndex = 0;
result.append(tooltip);
WatchData watch;
watch.iname = "watch";
watch.name = "Watchers";
watch.state = 0;
watch.level = 1;
watch.row = 2;
watch.parentIndex = 0;
result.append(watch);
return result;
}
///////////////////////////////////////////////////////////////////////
//
// WatchHandler
@@ -332,7 +377,8 @@ WatchHandler::WatchHandler()
m_inFetchMore = false;
m_inChange = false;
cleanModel();
m_completeSet = initialSet();
m_incompleteSet.clear();
m_displaySet = m_completeSet;
}
@@ -380,6 +426,7 @@ QVariant WatchHandler::data(const QModelIndex &idx, int role) const
int node = idx.internalId();
if (node < 0)
return QVariant();
QTC_ASSERT(node < m_displaySet.size(), return QVariant());
const WatchData &data = m_displaySet.at(node);
@@ -441,6 +488,13 @@ QVariant WatchHandler::data(const QModelIndex &idx, int role) const
case VisualRole:
return m_displayedINames.contains(data.iname);
case ExpandedRole:
//qDebug() << " FETCHING: " << data.iname
// << m_expandedINames.contains(data.iname)
// << m_expandedINames;
// Level 0 and 1 are always expanded
return node < 4 || m_expandedINames.contains(data.iname);
default:
break;
}
@@ -558,10 +612,13 @@ void WatchHandler::rebuildModel()
MODEL_DEBUG("RECREATE MODEL, CURRENT SET:\n" << toString());
#endif
QHash<QString, int> oldTopINames;
QHash<QString, QString> oldValues;
for (int i = 0, n = m_oldSet.size(); i != n; ++i) {
WatchData &data = m_oldSet[i];
oldValues[data.iname] = data.value;
if (data.level == 2)
++oldTopINames[data.iname];
}
#ifdef DEBUG_PENDING
MODEL_DEBUG("OLD VALUES: " << oldValues);
@@ -575,6 +632,9 @@ void WatchHandler::rebuildModel()
qSort(m_completeSet.begin(), m_completeSet.end(), &iNameSorter);
// This helps to decide whether the view has completely changed or not.
QHash<QString, int> topINames;
QHash<QString, int> iname2idx;
for (int i = m_completeSet.size(); --i > 0; ) {
@@ -582,7 +642,10 @@ void WatchHandler::rebuildModel()
data.parentIndex = 0;
data.childIndex.clear();
iname2idx[data.iname] = i;
if (data.level == 2)
++topINames[data.iname];
}
//qDebug() << "TOPINAMES: " << topINames << "\nOLD: " << oldTopINames;
for (int i = 1; i < m_completeSet.size(); ++i) {
WatchData &data = m_completeSet[i];
@@ -603,7 +666,13 @@ void WatchHandler::rebuildModel()
&& data.value != strNotInScope;
}
//emit layoutAboutToBeChanged();
emit layoutAboutToBeChanged();
if (oldTopINames != topINames) {
m_displaySet = initialSet();
m_expandedINames.clear();
emit reset();
}
m_displaySet = m_completeSet;
@@ -633,10 +702,10 @@ void WatchHandler::rebuildModel()
// Possibly append dummy items to prevent empty views
bool ok = true;
QWB_ASSERT(m_displaySet.size() >= 2, ok = false);
QWB_ASSERT(m_displaySet.at(1).iname == "local", ok = false);
QWB_ASSERT(m_displaySet.at(2).iname == "tooltip", ok = false);
QWB_ASSERT(m_displaySet.at(3).iname == "watch", ok = false);
QTC_ASSERT(m_displaySet.size() >= 2, ok = false);
QTC_ASSERT(m_displaySet.at(1).iname == "local", ok = false);
QTC_ASSERT(m_displaySet.at(2).iname == "tooltip", ok = false);
QTC_ASSERT(m_displaySet.at(3).iname == "watch", ok = false);
if (ok) {
for (int i = 1; i <= 3; ++i) {
WatchData &data = m_displaySet[i];
@@ -668,11 +737,6 @@ void WatchHandler::rebuildModel()
emit reset();
//qDebug() << "WATCHHANDLER: RESET EMITTED";
m_inChange = false;
//emit layoutChanged();
//QSet<QString> einames = m_expandedINames;
//einames.insert("local");
//einames.insert("watch");
//emit expandedItems(einames);
#if DEBUG_MODEL
#if USE_MODEL_TEST
@@ -691,8 +755,11 @@ void WatchHandler::cleanup()
m_oldSet.clear();
m_expandedINames.clear();
m_displayedINames.clear();
cleanModel();
m_incompleteSet.clear();
m_completeSet = initialSet();
m_displaySet = m_completeSet;
#if 0
for (EditWindows::ConstIterator it = m_editWindows.begin();
it != m_editWindows.end(); ++it) {
@@ -707,10 +774,10 @@ void WatchHandler::cleanup()
void WatchHandler::collapseChildren(const QModelIndex &idx)
{
if (m_inChange || m_completeSet.isEmpty()) {
//qDebug() << "WATCHHANDLER: COLLAPSE IGNORED" << idx;
qDebug() << "WATCHHANDLER: COLLAPSE IGNORED" << idx;
return;
}
QWB_ASSERT(checkIndex(idx.internalId()), return);
QTC_ASSERT(checkIndex(idx.internalId()), return);
#if 0
QString iname0 = m_displaySet.at(idx.internalId()).iname;
MODEL_DEBUG("COLLAPSE NODE" << iname0);
@@ -739,11 +806,11 @@ void WatchHandler::expandChildren(const QModelIndex &idx)
int index = idx.internalId();
if (index == 0)
return;
QWB_ASSERT(index >= 0, qDebug() << toString() << index; return);
QWB_ASSERT(index < m_completeSet.size(), qDebug() << toString() << index; return);
QTC_ASSERT(index >= 0, qDebug() << toString() << index; return);
QTC_ASSERT(index < m_completeSet.size(), qDebug() << toString() << index; return);
const WatchData &display = m_displaySet.at(index);
QWB_ASSERT(index >= 0, qDebug() << toString() << index; return);
QWB_ASSERT(index < m_completeSet.size(), qDebug() << toString() << index; return);
QTC_ASSERT(index >= 0, qDebug() << toString() << index; return);
QTC_ASSERT(index < m_completeSet.size(), qDebug() << toString() << index; return);
const WatchData &complete = m_completeSet.at(index);
MODEL_DEBUG("\n\nEXPAND" << display.iname);
if (display.iname.isEmpty()) {
@@ -781,7 +848,7 @@ void WatchHandler::expandChildren(const QModelIndex &idx)
void WatchHandler::insertData(const WatchData &data)
{
//MODEL_DEBUG("INSERTDATA: " << data.toString());
QWB_ASSERT(data.isValid(), return);
QTC_ASSERT(data.isValid(), return);
if (data.isSomethingNeeded())
insertDataHelper(m_incompleteSet, data);
else
@@ -879,56 +946,10 @@ void WatchHandler::removeWatchExpression(const QString &iname)
emit watchModelUpdateRequested();
}
void WatchHandler::cleanModel()
{
// This uses data stored in m_oldSet to re-create a new set
// one-by-one
m_completeSet.clear();
m_incompleteSet.clear();
WatchData root;
root.state = 0;
root.level = 0;
root.row = 0;
root.name = "Root";
root.parentIndex = -1;
root.childIndex.append(1);
root.childIndex.append(2);
root.childIndex.append(3);
m_completeSet.append(root);
WatchData local;
local.iname = "local";
local.name = "Locals";
local.state = 0;
local.level = 1;
local.row = 0;
local.parentIndex = 0;
m_completeSet.append(local);
WatchData tooltip;
tooltip.iname = "tooltip";
tooltip.name = "Tooltip";
tooltip.state = 0;
tooltip.level = 1;
tooltip.row = 1;
tooltip.parentIndex = 0;
m_completeSet.append(tooltip);
WatchData watch;
watch.iname = "watch";
watch.name = "Watchers";
watch.state = 0;
watch.level = 1;
watch.row = 2;
watch.parentIndex = 0;
m_completeSet.append(watch);
}
void WatchHandler::reinitializeWatchers()
{
cleanModel();
m_completeSet = initialSet();
m_incompleteSet.clear();
// copy over all watchers and mark all watchers as incomplete
for (int i = 0, n = m_oldSet.size(); i < n; ++i) {
@@ -956,7 +977,7 @@ bool WatchHandler::canFetchMore(const QModelIndex &parent) const
// needs to be made synchronous to be useful. Busy loop is no good.
if (!parent.isValid())
return false;
QWB_ASSERT(checkIndex(parent.internalId()), return false);
QTC_ASSERT(checkIndex(parent.internalId()), return false);
const WatchData &data = m_displaySet.at(parent.internalId());
MODEL_DEBUG("CAN FETCH MORE: " << parent << " children: " << data.childCount
<< data.iname);
@@ -969,7 +990,7 @@ void WatchHandler::fetchMore(const QModelIndex &parent)
MODEL_DEBUG("FETCH MORE: " << parent);
return;
QWB_ASSERT(checkIndex(parent.internalId()), return);
QTC_ASSERT(checkIndex(parent.internalId()), return);
QString iname = m_displaySet.at(parent.internalId()).iname;
if (m_inFetchMore) {
@@ -1028,15 +1049,15 @@ QModelIndex WatchHandler::index(int row, int col, const QModelIndex &parent) con
MODEL_DEBUG(" -> " << QModelIndex() << " (2) ");
return QModelIndex();
}
QWB_ASSERT(checkIndex(parentIndex), return QModelIndex());
QTC_ASSERT(checkIndex(parentIndex), return QModelIndex());
const WatchData &data = m_displaySet.at(parentIndex);
QWB_ASSERT(row >= 0, qDebug() << "ROW: " << row << "PARENT: " << parent
QTC_ASSERT(row >= 0, qDebug() << "ROW: " << row << "PARENT: " << parent
<< data.toString() << toString(); return QModelIndex());
QWB_ASSERT(row < data.childIndex.size(),
QTC_ASSERT(row < data.childIndex.size(),
MODEL_DEBUG("ROW: " << row << data.toString() << toString());
return QModelIndex());
QModelIndex idx = createIndex(row, col, data.childIndex.at(row));
QWB_ASSERT(idx.row() == m_displaySet.at(idx.internalId()).row,
QTC_ASSERT(idx.row() == m_displaySet.at(idx.internalId()).row,
return QModelIndex());
MODEL_DEBUG(" -> " << idx << " (A) ");
return idx;
@@ -1050,15 +1071,15 @@ QModelIndex WatchHandler::parent(const QModelIndex &idx) const
}
MODEL_DEBUG("PARENT " << idx);
int currentIndex = idx.internalId();
QWB_ASSERT(checkIndex(currentIndex), return QModelIndex());
QWB_ASSERT(idx.row() == m_displaySet.at(currentIndex).row,
QTC_ASSERT(checkIndex(currentIndex), return QModelIndex());
QTC_ASSERT(idx.row() == m_displaySet.at(currentIndex).row,
MODEL_DEBUG("IDX: " << idx << toString(); return QModelIndex()));
int parentIndex = m_displaySet.at(currentIndex).parentIndex;
if (parentIndex < 0) {
MODEL_DEBUG(" -> " << QModelIndex() << " (2) ");
return QModelIndex();
}
QWB_ASSERT(checkIndex(parentIndex), return QModelIndex());
QTC_ASSERT(checkIndex(parentIndex), return QModelIndex());
QModelIndex parent =
createIndex(m_displaySet.at(parentIndex).row, 0, parentIndex);
MODEL_DEBUG(" -> " << parent);
@@ -1073,7 +1094,7 @@ int WatchHandler::rowCount(const QModelIndex &idx) const
return 0;
}
int thisIndex = idx.internalId();
QWB_ASSERT(checkIndex(thisIndex), return 0);
QTC_ASSERT(checkIndex(thisIndex), return 0);
if (idx.row() == -1 && idx.column() == -1) {
MODEL_DEBUG(" -> " << 3 << " (B) ");
return 1;
@@ -1108,7 +1129,7 @@ int WatchHandler::columnCount(const QModelIndex &idx) const
return 0;
}
MODEL_DEBUG(" -> " << 3 << " (B) ");
QWB_ASSERT(checkIndex(idx.internalId()), return 3);
QTC_ASSERT(checkIndex(idx.internalId()), return 3);
return 3;
}
@@ -1118,7 +1139,7 @@ bool WatchHandler::hasChildren(const QModelIndex &idx) const
bool base = rowCount(idx) > 0 && columnCount(idx) > 0;
MODEL_DEBUG("HAS CHILDREN: " << idx << base);
return base;
QWB_ASSERT(checkIndex(idx.internalId()), return false);
QTC_ASSERT(checkIndex(idx.internalId()), return false);
const WatchData &data = m_displaySet.at(idx.internalId());
MODEL_DEBUG("HAS CHILDREN: " << idx << data.toString());
return data.childCount > 0; // || data.childIndex.size() > 0;

View File

@@ -135,7 +135,7 @@ public:
bool changed;
};
enum { INameRole = Qt::UserRole, VisualRole };
enum { INameRole = Qt::UserRole, VisualRole, ExpandedRole };
class WatchHandler : public QAbstractItemModel
@@ -192,7 +192,6 @@ signals:
private:
WatchData takeData(const QString &iname);
QString toString() const;
void cleanModel();
bool m_expandPointers;
bool m_inChange;

View File

@@ -46,7 +46,7 @@
using namespace Debugger::Internal;
enum { INameRole = Qt::UserRole, VisualRole };
enum { INameRole = Qt::UserRole, VisualRole, ExpandedRole };
/////////////////////////////////////////////////////////////////////
//
@@ -57,7 +57,6 @@ enum { INameRole = Qt::UserRole, VisualRole };
WatchWindow::WatchWindow(Type type, QWidget *parent)
: QTreeView(parent), m_type(type)
{
m_blocked = false;
setWindowTitle(tr("Locals and Watchers"));
setAlternatingRowColors(true);
setIndentation(indentation() * 9/10);
@@ -76,12 +75,6 @@ void WatchWindow::expandNode(const QModelIndex &idx)
//QModelIndex mi0 = idx.sibling(idx.row(), 0);
//QString iname = model()->data(mi0, INameRole).toString();
//QString name = model()->data(mi0, Qt::DisplayRole).toString();
//qDebug() << "\n\nEXPAND NODE " // << iname << name
// << idx << (m_blocked ? "blocked" : "passed");
//if (isExpanded(idx))
// return;
//if (m_blocked)
// return;
emit requestExpandChildren(idx);
}
@@ -91,8 +84,6 @@ void WatchWindow::collapseNode(const QModelIndex &idx)
//QString iname = model()->data(mi0, INameRole).toString();
//QString name = model()->data(mi0, Qt::DisplayRole).toString();
//qDebug() << "COLLAPSE NODE " << idx;
if (m_blocked)
return;
emit requestCollapseChildren(idx);
}
@@ -181,6 +172,7 @@ void WatchWindow::reset()
QTreeView::reset();
setRootIndex(model()->index(row, 0, model()->index(0, 0)));
//setRootIndex(model()->index(0, 0));
resetHelper(model()->index(0, 0));
}
void WatchWindow::setModel(QAbstractItemModel *model)
@@ -192,55 +184,15 @@ void WatchWindow::setModel(QAbstractItemModel *model)
header()->setResizeMode(QHeaderView::ResizeToContents);
if (m_type != LocalsType)
header()->hide();
connect(model, SIGNAL(modelAboutToBeReset()),
this, SLOT(modelAboutToBeReset()));
connect(model, SIGNAL(modelReset()),
this, SLOT(modelReset()));
}
void WatchWindow::modelAboutToBeReset()
void WatchWindow::resetHelper(const QModelIndex &idx)
{
m_blocked = true;
//qDebug() << "Model about to be reset";
m_expandedItems.clear();
m_expandedItems.insert("local");
m_expandedItems.insert("watch");
modelAboutToBeResetHelper(model()->index(0, 0));
//qDebug() << " expanded: " << m_expandedItems;
}
void WatchWindow::modelAboutToBeResetHelper(const QModelIndex &idx)
{
QString iname = model()->data(idx, INameRole).toString();
//qDebug() << "Model about to be reset helper" << iname << idx
// << isExpanded(idx);
if (isExpanded(idx))
m_expandedItems.insert(iname);
for (int i = 0, n = model()->rowCount(idx); i != n; ++i) {
QModelIndex idx1 = model()->index(i, 0, idx);
modelAboutToBeResetHelper(idx1);
}
}
void WatchWindow::modelReset()
{
//qDebug() << "Model reset";
expand(model()->index(0, 0));
modelResetHelper(model()->index(0, 0));
m_blocked = false;
}
void WatchWindow::modelResetHelper(const QModelIndex &idx)
{
QString name = model()->data(idx, Qt::DisplayRole).toString();
QString iname = model()->data(idx, INameRole).toString();
//qDebug() << "Model reset helper" << iname << name;
if (m_expandedItems.contains(iname)) {
if (model()->data(idx, ExpandedRole).toBool()) {
expand(idx);
for (int i = 0, n = model()->rowCount(idx); i != n; ++i) {
QModelIndex idx1 = model()->index(i, 0, idx);
modelResetHelper(idx1);
resetHelper(idx1);
}
}
}

View File

@@ -72,21 +72,16 @@ private slots:
void handleChangedItem(QWidget *);
void expandNode(const QModelIndex &index);
void collapseNode(const QModelIndex &index);
void modelAboutToBeReset();
void modelReset();
private:
void contextMenuEvent(QContextMenuEvent *ev);
void editItem(const QModelIndex &idx);
void reset(); /* reimpl */
void modelAboutToBeResetHelper(const QModelIndex &idx);
void modelResetHelper(const QModelIndex &idx);
void resetHelper(const QModelIndex &idx);
bool m_alwaysResizeColumnsToContents;
Type m_type;
bool m_blocked;
QSet<QString> m_expandedItems;
};

View File

@@ -63,6 +63,7 @@ FormClassWizardPage::FormClassWizardPage(QWidget * parent) :
m_ui->newClassWidget->setBaseClassInputVisible(false);
m_ui->newClassWidget->setNamespacesEnabled(true);
m_ui->newClassWidget->setAllowDirectories(true);
connect(m_ui->newClassWidget, SIGNAL(validChanged()), this, SLOT(slotValidChanged()));

View File

@@ -156,7 +156,7 @@ bool FormClassWizardParameters::generateCpp(QString *header, QString *source, in
if (languageChange) {
sourceStr << '\n' << namespaceIndent << "void " << unqualifiedClassName << "::" << "changeEvent(QEvent *e)\n"
<< namespaceIndent << "{\n"
<< namespaceIndent << indent << "switch(e->type()) {\n" << namespaceIndent << indent << "case QEvent::LanguageChange:\n"
<< namespaceIndent << indent << "switch (e->type()) {\n" << namespaceIndent << indent << "case QEvent::LanguageChange:\n"
<< namespaceIndent << indent << indent;
if (embedding != InheritedUiClass)
sourceStr << uiMemberC << (embedding == PointerAggregatedUiClass ? "->" : ".");

View File

@@ -35,6 +35,7 @@
#include "formeditorw.h"
#include <coreplugin/minisplitter.h>
#include <utils/qtcassert.h>
#include <QtCore/QEvent>
#include <QtGui/QVBoxLayout>
@@ -54,7 +55,7 @@ SharedSubWindow::SharedSubWindow(QWidget *shared, QWidget *parent) :
m_shared(shared),
m_layout(new QVBoxLayout)
{
Q_ASSERT(m_shared);
QTC_ASSERT(m_shared, /**/);
m_layout->setContentsMargins(0, 0, 0, 0);
setLayout(m_layout);
}
@@ -62,14 +63,14 @@ SharedSubWindow::SharedSubWindow(QWidget *shared, QWidget *parent) :
void SharedSubWindow::activate()
{
// Take the widget off the other parent
Q_ASSERT(m_shared);
QTC_ASSERT(m_shared, return);
QWidget *currentParent = m_shared->parentWidget();
if (currentParent == this)
return;
if (currentParent) {
QVBoxLayout *lt = qobject_cast<QVBoxLayout *>(currentParent->layout());
Q_ASSERT(lt);
QTC_ASSERT(lt, return);
m_shared->setParent(0);
delete lt->takeAt(0);
}

View File

@@ -43,6 +43,7 @@
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/actionmanager/actionmanagerinterface.h>
#include <coreplugin/editormanager/editormanager.h>
#include <utils/qtcassert.h>
#include <QtDesigner/QDesignerFormEditorPluginInterface>
#include <QtDesigner/private/pluginmanager_p.h>
@@ -169,9 +170,9 @@ FormEditorW::FormEditorW() :
{
if (debugFormEditor)
qDebug() << Q_FUNC_INFO;
Q_ASSERT(!m_self);
QTC_ASSERT(!m_self, return);
m_self = this;
Q_ASSERT(m_core);
QTC_ASSERT(m_core, return);
qFill(m_designerSubWindows, m_designerSubWindows + Designer::Constants::DesignerSubWindowCount,
static_cast<QWidget *>(0));
@@ -180,7 +181,7 @@ FormEditorW::FormEditorW() :
m_formeditor->setSettingsManager(new SettingsManager());
m_fwm = qobject_cast<qdesigner_internal::QDesignerFormWindowManager*>(m_formeditor->formWindowManager());
Q_ASSERT(m_fwm);
QTC_ASSERT(m_fwm, return);
const int uid = m_core->uniqueIDManager()->uniqueIdentifier(QLatin1String(C_FORMEDITOR));
m_context << uid;
@@ -216,7 +217,7 @@ FormEditorW::~FormEditorW()
void FormEditorW::fullInit()
{
Q_ASSERT(m_initStage == RegisterPlugins);
QTC_ASSERT(m_initStage == RegisterPlugins, return);
QTime *initTime = 0;
if (debugFormEditor) {
initTime = new QTime;
@@ -410,7 +411,7 @@ void FormEditorW::setupActions()
createSeparator(this, am, m_context, mformtools, QLatin1String("FormEditor.Menu.Tools.Separator2"));
m_actionPreview = m_fwm->actionDefaultPreview();
Q_ASSERT(m_actionPreview);
QTC_ASSERT(m_actionPreview, return);
addToolAction(m_actionPreview, am, m_context,
QLatin1String("FormEditor.Preview"), mformtools, tr("Ctrl+Alt+R"));
@@ -445,8 +446,8 @@ QToolBar *FormEditorW::createEditorToolBar() const
Core::ActionManagerInterface *am = m_core->actionManager();
const QStringList::const_iterator cend = m_toolActionIds.constEnd();
for (QStringList::const_iterator it = m_toolActionIds.constBegin(); it != cend; ++it) {
Core::ICommand *cmd = am->command(*it);
Q_ASSERT(cmd);
Core::ICommand *cmd = am->command(*it);
QTC_ASSERT(cmd, continue);
QAction *action = cmd->action();
if (!action->icon().isNull()) // Simplify grid has no action yet
rc->addAction(action);
@@ -472,7 +473,7 @@ Core::IActionContainer *FormEditorW::createPreviewStyleMenu(Core::ActionManagerI
const QString deviceProfilePrefix = QLatin1String("DeviceProfile");
const QChar dot = QLatin1Char('.');
foreach(QAction* a, actions) {
foreach (QAction* a, actions) {
QString name = menuId;
name += dot;
const QVariant data = a->data();
@@ -591,7 +592,7 @@ void FormEditorW::currentEditorChanged(Core::IEditor *editor)
// Deactivate Designer if a non-form is being edited
if (editor && !qstrcmp(editor->kind(), Constants::C_FORMWINDOW)) {
FormWindowEditor *fw = qobject_cast<FormWindowEditor *>(editor);
Q_ASSERT(fw);
QTC_ASSERT(fw, return);
fw->activate();
m_fwm->setActiveFormWindow(fw->formWindow());
} else {

View File

@@ -33,6 +33,8 @@
#include "basetextfind.h"
#include <utils/qtcassert.h>
#include <QtGui/QTextBlock>
using namespace Find;
@@ -49,26 +51,26 @@ BaseTextFind::BaseTextFind(QPlainTextEdit *editor)
QTextCursor BaseTextFind::textCursor() const
{
Q_ASSERT(m_editor || m_plaineditor);
QTC_ASSERT(m_editor || m_plaineditor, return QTextCursor());
return m_editor ? m_editor->textCursor() : m_plaineditor->textCursor();
}
void BaseTextFind::setTextCursor(const QTextCursor& cursor)
{
Q_ASSERT(m_editor || m_plaineditor);
QTC_ASSERT(m_editor || m_plaineditor, return);
m_editor ? m_editor->setTextCursor(cursor) : m_plaineditor->setTextCursor(cursor);
}
QTextDocument *BaseTextFind::document() const
{
Q_ASSERT(m_editor || m_plaineditor);
QTC_ASSERT(m_editor || m_plaineditor, return 0);
return m_editor ? m_editor->document() : m_plaineditor->document();
}
bool BaseTextFind::isReadOnly() const
{
Q_ASSERT(m_editor || m_plaineditor);
QTC_ASSERT(m_editor || m_plaineditor, return true);
return m_editor ? m_editor->isReadOnly() : m_plaineditor->isReadOnly();
}
@@ -101,7 +103,7 @@ QString BaseTextFind::currentFindString() const
cursor.movePosition(QTextCursor::StartOfWord);
cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
QString s = cursor.selectedText();
foreach(QChar c, s) {
foreach (QChar c, s) {
if (!c.isLetterOrNumber() && c != QLatin1Char('_')) {
s.clear();
break;

View File

@@ -36,16 +36,17 @@
#include <aggregation/aggregate.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/modemanager.h>
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtGui/QApplication>
#include <QtDebug>
using namespace Core;
using namespace Find;
using namespace Find::Internal;
CurrentDocumentFind::CurrentDocumentFind(ICore *core)
: m_core(core), m_currentFind(0)
: m_core(core), m_currentFind(0)
{
connect(qApp, SIGNAL(focusChanged(QWidget*, QWidget*)),
this, SLOT(updateCurrentFindFilter(QWidget*,QWidget*)));
@@ -59,16 +60,14 @@ void CurrentDocumentFind::removeConnections()
void CurrentDocumentFind::resetIncrementalSearch()
{
Q_ASSERT(m_currentFind);
if (m_currentFind)
m_currentFind->resetIncrementalSearch();
QTC_ASSERT(m_currentFind, return);
m_currentFind->resetIncrementalSearch();
}
void CurrentDocumentFind::clearResults()
{
Q_ASSERT(m_currentFind);
if (m_currentFind)
m_currentFind->clearResults();
QTC_ASSERT(m_currentFind, return);
m_currentFind->clearResults();
}
bool CurrentDocumentFind::isEnabled() const
@@ -78,67 +77,64 @@ bool CurrentDocumentFind::isEnabled() const
bool CurrentDocumentFind::supportsReplace() const
{
Q_ASSERT(m_currentFind);
return m_currentFind ? m_currentFind->supportsReplace() : false;
QTC_ASSERT(m_currentFind, return false);
return m_currentFind->supportsReplace();
}
QString CurrentDocumentFind::currentFindString() const
{
Q_ASSERT(m_currentFind);
return m_currentFind ? m_currentFind->currentFindString() : QString();
QTC_ASSERT(m_currentFind, return QString());
return m_currentFind->currentFindString();
}
QString CurrentDocumentFind::completedFindString() const
{
Q_ASSERT(m_currentFind);
return m_currentFind ? m_currentFind->completedFindString() : QString();
QTC_ASSERT(m_currentFind, return QString());
return m_currentFind->completedFindString();
}
void CurrentDocumentFind::highlightAll(const QString &txt, QTextDocument::FindFlags findFlags)
{
Q_ASSERT(m_currentFind);
if (m_currentFind)
m_currentFind->highlightAll(txt, findFlags);
QTC_ASSERT(m_currentFind, return);
m_currentFind->highlightAll(txt, findFlags);
}
bool CurrentDocumentFind::findIncremental(const QString &txt, QTextDocument::FindFlags findFlags)
{
Q_ASSERT(m_currentFind);
return (m_currentFind? m_currentFind->findIncremental(txt, findFlags) : false);
QTC_ASSERT(m_currentFind, return false);
return m_currentFind->findIncremental(txt, findFlags);
}
bool CurrentDocumentFind::findStep(const QString &txt, QTextDocument::FindFlags findFlags)
{
Q_ASSERT(m_currentFind);
return (m_currentFind? m_currentFind->findStep(txt, findFlags) : false);
QTC_ASSERT(m_currentFind, return false);
return m_currentFind->findStep(txt, findFlags);
}
bool CurrentDocumentFind::replaceStep(const QString &before, const QString &after,
QTextDocument::FindFlags findFlags)
{
Q_ASSERT(m_currentFind);
return (m_currentFind? m_currentFind->replaceStep(before, after, findFlags) : false);
QTC_ASSERT(m_currentFind, return false);
return m_currentFind->replaceStep(before, after, findFlags);
}
int CurrentDocumentFind::replaceAll(const QString &before, const QString &after,
QTextDocument::FindFlags findFlags)
{
Q_ASSERT(m_currentFind);
return (m_currentFind? m_currentFind->replaceAll(before, after, findFlags) : 0);
QTC_ASSERT(m_currentFind, return 0);
return m_currentFind->replaceAll(before, after, findFlags);
}
void CurrentDocumentFind::defineFindScope()
{
Q_ASSERT(m_currentFind);
if (m_currentFind)
m_currentFind->defineFindScope();
QTC_ASSERT(m_currentFind, return);
m_currentFind->defineFindScope();
}
void CurrentDocumentFind::clearFindScope()
{
Q_ASSERT(m_currentFind);
if (m_currentFind)
m_currentFind->clearFindScope();
QTC_ASSERT(m_currentFind, return);
m_currentFind->clearFindScope();
}
void CurrentDocumentFind::updateCurrentFindFilter(QWidget *old, QWidget *now)

View File

@@ -30,6 +30,7 @@
** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
#include "findplugin.h"
#include "textfindconstants.h"
@@ -42,6 +43,8 @@
#include <coreplugin/actionmanager/icommand.h>
#include <coreplugin/coreconstants.h>
#include <utils/qtcassert.h>
#include <QtCore/qplugin.h>
#include <QtCore/QSettings>
@@ -102,24 +105,18 @@ void FindPlugin::filterChanged()
{
IFindFilter *changedFilter = qobject_cast<IFindFilter *>(sender());
QAction *action = m_filterActions.value(changedFilter);
Q_ASSERT(changedFilter);
Q_ASSERT(action);
if (!changedFilter || !action)
return;
QTC_ASSERT(changedFilter, return);
QTC_ASSERT(action, return);
action->setEnabled(changedFilter->isEnabled());
}
void FindPlugin::openFindFilter()
{
QAction *action = qobject_cast<QAction*>(sender());
Q_ASSERT(action);
if (!action)
return;
QTC_ASSERT(action, return);
IFindFilter *filter = action->data().value<IFindFilter *>();
Q_ASSERT(filter);
Q_ASSERT(filter->isEnabled());
if (!filter || !filter->isEnabled())
return;
QTC_ASSERT(filter, return);
QTC_ASSERT(filter->isEnabled(), return);
QString currentFindString = (m_currentDocumentFind->isEnabled() ? m_currentDocumentFind->currentFindString() : "");
if (!currentFindString.isEmpty())
m_findDialog->setFindText(currentFindString);

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