Merge branch '0.9.1-beta' of git@scm.dev.nokia.troll.no:creator/mainline into 0.9.1-beta

This commit is contained in:
goro
2008-12-11 12:30:52 +01:00
11 changed files with 115 additions and 53 deletions

View File

@@ -23,6 +23,8 @@
\o \inlineimage qtcreator.png \o \inlineimage qtcreator.png
\o Qt Creator includes a wide range of useful features. Among them are: \o Qt Creator includes a wide range of useful features. Among them are:
\list 1 \list 1
\o \bold{Smart Code Editor}: The code editor provides syntax
highlighting as well as code completion.
\o \bold{Qt4 Project Generating Wizard}: This wizard allows the user \o \bold{Qt4 Project Generating Wizard}: This wizard allows the user
to generate a project for a console application, a GUI application, to generate a project for a console application, a GUI application,
or a C++ library. or a C++ library.
@@ -48,7 +50,7 @@
\o \l{Creating a Project in Qt Creator} \o \l{Creating a Project in Qt Creator}
\o \l{Build Settings} \o \l{Build Settings}
\o \l{Writing a Simple Program with Qt Creator} \o \l{Writing a Simple Program with Qt Creator}
\o \l{Quick Navigation} \o \l{Navigating Quickly Around Your Code}
\o \l{Debugging with Qt Creator} \o \l{Debugging with Qt Creator}
\o \l{Tips and Tricks} \o \l{Tips and Tricks}
\o \l{Glossary} \o \l{Glossary}
@@ -64,86 +66,85 @@
\title A Quick Tour Around Qt Creator \title A Quick Tour Around Qt Creator
The labeled screenshot below shows some of the components of Qt Creator, The labeled screenshot below shows some of the components of Qt Creator, in
in \gui Edit mode. \gui Edit mode.
\image qtcreator-breakdown.png \image qtcreator-breakdown.png
\section1 The Mode Selectors \section1 The Mode Selectors
When working in Qt Creator, you can be in one of five modes: \bold Project, When working in Qt Creator, you can be in one of six modes: \bold Welcome,
\bold Edit, \bold Debug, \bold Help, and \bold Output. \bold Edit, \bold Debug, \bold Projects, \bold Help, and \bold Output.
Mode selectors allow you to quickly switch between tasks: Editing, Mode selectors allow you to quickly switch between tasks: Editing, browsing
browsing the Qt manual, setting up the build environment, etc. You can the Qt Creator manual, setting up the build environment, etc. You can
activate a mode by either clicking on its mode selector, or using the activate a mode by either clicking on its mode selector, or using the
\l{keyboard-shortcuts}{corresponding shortcut}. Certain actions also \l{keyboard-shortcuts}{corresponding shortcut}. Certain actions also
trigger a mode change, e.g., \gui{Debug}/\gui{Start Debugging} will switch trigger a mode change, e.g., \gui{Debug}/\gui{Start Debugging} will switch
to the \gui Debug mode. to the \gui Debug mode.
\list \list
\o \gui{Welcome Mode} - Displays a welcome screen allowing you to quickly \o \gui{Welcome Mode} - Displays a welcome screen allowing you to quickly
load recent sessions or individual projects. This is the first mode load recent sessions or individual projects. This is the mode you will see
displayed if Qt Creator is run without command line switches. if Qt Creator is run without command line switches.
\o \gui{Edit Mode} - You can edit both project and source files here. An \o \gui{Edit Mode} - Lets you edit both project and source files. A sidebar
optional sidebar on the left provides different views to navigate between on the left provides different views to navigate between files.
files.
\o \gui{Debug Mode} - Provides various ways to inspect the state of the \o \gui{Debug Mode} - Provides various ways to inspect the state of the
program while debugging. See \l{qtcreator-debugging}{Debugging With Qt program while debugging. See \l{qtcreator-debugging}{Debugging With Qt
Creator} for a hands-on description of the mode. Creator} for a hands-on description of how to use this mode.
\o \gui{Build & Run Mode} - Lets you configure how projects can be built \o \gui{Projects Mode} - Lets you configure how projects can be built and
and executed. Under the list of projects, there are tabs to configure the executed. Under the list of projects, there are tabs to configure the
build and run settings. build, run, and editor settings.
\o \gui{Help Mode} - Shows any documentation registered by Qt Assistant, \o \gui{Help Mode} - Shows any documentation registered by Qt Assistant,
such as the Qt library and Qt Creator documentation. such as the Qt library and Qt Creator documentation.
\o \gui{Output Mode} - Lets you examine various logs in detail, for example \o \gui{Output Mode} - Lets you examine various data in detail, for example
the task list, the compiler and application output. Some of these logs can build issues as well as compile and application output. This information
also be viewed in the output panes. is also available in the output panes.
\endlist \endlist
\section1 The Output Panes \section1 The Output Panes
The task pane in Qt Creator can display one out of four different panes: The task pane in Qt Creator can display one of four different panes:
Task List, Search Results, Application Output, and Compile Output. These \gui{Build Issues}, \gui{Search Results}, \gui{Application Output}, and
panes are available in all modes. \gui{Compile}. These panes are available in all modes.
\section2 Task List \section2 Build Issues
The Task List provides a list of important tasks such as error messages The {Build Issues} pane provides a list of issues, e.g., error messages or
that need to be fixed. It filters out irrelevant output from the compiler warnings that need to be fixed. It filters out irrelevant output from the
and collects them in the form of tasks. compiler and collects them in an organized way.
\image qtcreator-task-list.png \image qtcreator-build-issues.png
\section2 Search Results \section2 Search Results
The Search Results pane displays the results for global searches such as The \gui{Search Results} pane displays the results for global searches such
searching within a current document, files on disk, or all projects. as searching within a current document, files on disk, or all projects. In
In the screenshot below, we searched for all occurrences of \c{textfinder} the screenshot below, we searched for all occurrences of \c{textfinder}
within the "/TextFinder" folder. within the \c{"/TextFinder"} folder.
\image qtcreator-search-pane.png \image qtcreator-search-pane.png
\section2 Application Output \section2 Application Output
This pane displays the status of the program when it is executed, as The \gui{Application Output} pane displays the status of the program when
well as debug output, for example, output from qDebug(). it is executed and debug output, e.g., output from qDebug().
\image qtcreator-application-output.png \image qtcreator-application-output.png
\section2 Compile Output \section2 Compile
The Compile Output provides all the output from the compiler. In other The \gui{Compile} pane provides all the output from the compiler. In other
words, it is a more verbose version of the Task List. words, it is a more verbose version of information displayed in the
\gui{Build Issues}
\image qtcreator-compile-pane.png \image qtcreator-compile-pane.png
@@ -521,7 +522,7 @@
\page creator-navigation.html \page creator-navigation.html
\nextpage creator-debugging.html \nextpage creator-debugging.html
\title Quick Navigation \title Navigating Quickly Around Your Code
With Qt Creator, navigating to different locations in your project or on With Qt Creator, navigating to different locations in your project or on
your disk, such as files, classes and methods, is trivial using the input your disk, such as files, classes and methods, is trivial using the input

View File

@@ -69,7 +69,7 @@ static const char *HELP_OPTION4 = "--help";
static const char *VERSION_OPTION = "-version"; static const char *VERSION_OPTION = "-version";
static const char *CLIENT_OPTION = "-client"; static const char *CLIENT_OPTION = "-client";
typedef QSet<ExtensionSystem::PluginSpec *> PluginSpecSet; typedef QList<ExtensionSystem::PluginSpec *> PluginSpecSet;
// Helpers for displaying messages. Note that there is no console on Windows. // Helpers for displaying messages. Note that there is no console on Windows.
#ifdef Q_WS_WIN #ifdef Q_WS_WIN

View File

@@ -37,6 +37,7 @@
#include <TranslationUnit.h> #include <TranslationUnit.h>
#include <cplusplus/LookupContext.h> #include <cplusplus/LookupContext.h>
#include <cplusplus/ResolveExpression.h> #include <cplusplus/ResolveExpression.h>
#include <cplusplus/pp.h>
using namespace CPlusPlus; using namespace CPlusPlus;
@@ -53,9 +54,13 @@ void TypeOfExpression::setDocuments(const QMap<QString, Document::Ptr> &document
QList<TypeOfExpression::Result> TypeOfExpression::operator()(const QString &expression, QList<TypeOfExpression::Result> TypeOfExpression::operator()(const QString &expression,
Document::Ptr document, Document::Ptr document,
Symbol *lastVisibleSymbol) Symbol *lastVisibleSymbol,
PreprocessMode mode)
{ {
Document::Ptr expressionDoc = documentForExpression(expression); QString code = expression;
if (mode == Preprocess)
code = preprocessedExpression(expression, m_documents, document);
Document::Ptr expressionDoc = documentForExpression(code);
m_ast = extractExpressionAST(expressionDoc); m_ast = extractExpressionAST(expressionDoc);
m_lookupContext = LookupContext(lastVisibleSymbol, expressionDoc, m_lookupContext = LookupContext(lastVisibleSymbol, expressionDoc,
@@ -97,3 +102,34 @@ Document::Ptr TypeOfExpression::documentForExpression(const QString &expression)
doc->parse(Document::ParseExpression); doc->parse(Document::ParseExpression);
return doc; return doc;
} }
void TypeOfExpression::processEnvironment(QMap<QString, Document::Ptr> documents,
Document::Ptr doc, Environment *env,
QSet<QString> *processed) const
{
if (processed->contains(doc->fileName()))
return;
processed->insert(doc->fileName());
foreach (const Document::Include &incl, doc->includes()) {
processEnvironment(documents,
documents.value(incl.fileName()),
env, processed);
}
foreach (const Macro &macro, doc->definedMacros())
env->bind(macro);
}
QString TypeOfExpression::preprocessedExpression(const QString &expression,
QMap<QString, Document::Ptr> documents,
Document::Ptr thisDocument) const
{
Environment env;
QSet<QString> processed;
processEnvironment(documents, thisDocument,
&env, &processed);
const QByteArray code = expression.toUtf8();
pp preproc(0, env);
QByteArray preprocessedCode;
preproc("<expression>", code, &preprocessedCode);
return QString::fromUtf8(preprocessedCode);
}

View File

@@ -43,6 +43,9 @@
namespace CPlusPlus { namespace CPlusPlus {
class Environment;
class Macro;
class CPLUSPLUS_EXPORT TypeOfExpression class CPLUSPLUS_EXPORT TypeOfExpression
{ {
public: public:
@@ -60,6 +63,11 @@ public:
*/ */
void setDocuments(const QMap<QString, Document::Ptr> &documents); void setDocuments(const QMap<QString, Document::Ptr> &documents);
enum PreprocessMode {
NoPreprocess,
Preprocess
};
/** /**
* Returns a list of possible fully specified types associated with the * Returns a list of possible fully specified types associated with the
* given expression. * given expression.
@@ -73,7 +81,8 @@ public:
* @param lastVisibleSymbol The last visible symbol in the document. * @param lastVisibleSymbol The last visible symbol in the document.
*/ */
QList<Result> operator()(const QString &expression, Document::Ptr document, QList<Result> operator()(const QString &expression, Document::Ptr document,
Symbol *lastVisibleSymbol); Symbol *lastVisibleSymbol,
PreprocessMode mode = NoPreprocess);
/** /**
* Returns the AST of the last evaluated expression. * Returns the AST of the last evaluated expression.
@@ -91,6 +100,14 @@ private:
ExpressionAST *extractExpressionAST(Document::Ptr doc) const; ExpressionAST *extractExpressionAST(Document::Ptr doc) const;
Document::Ptr documentForExpression(const QString &expression) const; Document::Ptr documentForExpression(const QString &expression) const;
void processEnvironment(QMap<QString, CPlusPlus::Document::Ptr> documents,
CPlusPlus::Document::Ptr doc, CPlusPlus::Environment *env,
QSet<QString> *processed) const;
QString preprocessedExpression(const QString &expression,
QMap<QString, CPlusPlus::Document::Ptr> documents,
CPlusPlus::Document::Ptr thisDocument) const;
QMap<QString, Document::Ptr> m_documents; QMap<QString, Document::Ptr> m_documents;
ExpressionAST *m_ast; ExpressionAST *m_ast;
LookupContext m_lookupContext; LookupContext m_lookupContext;

View File

@@ -129,7 +129,7 @@ bool OptionsParser::checkForNoLoadOption()
"The plugin '%1' does not exist.").arg(m_currentArg); "The plugin '%1' does not exist.").arg(m_currentArg);
m_hasError = true; m_hasError = true;
} else { } else {
m_pmPrivate->pluginSpecs.remove(spec); m_pmPrivate->pluginSpecs.removeAll(spec);
delete spec; delete spec;
m_isDependencyRefreshNeeded = true; m_isDependencyRefreshNeeded = true;
} }

View File

@@ -48,7 +48,7 @@
#include <QTest> #include <QTest>
#endif #endif
typedef QSet<ExtensionSystem::PluginSpec *> PluginSpecSet; typedef QList<ExtensionSystem::PluginSpec *> PluginSpecSet;
enum { debugLeaks = 0 }; enum { debugLeaks = 0 };
@@ -162,6 +162,11 @@ enum { debugLeaks = 0 };
using namespace ExtensionSystem; using namespace ExtensionSystem;
using namespace ExtensionSystem::Internal; using namespace ExtensionSystem::Internal;
static bool lessThanByPluginName(const PluginSpec *one, const PluginSpec *two)
{
return one->name() < two->name();
}
PluginManager *PluginManager::m_instance = 0; PluginManager *PluginManager::m_instance = 0;
/*! /*!
@@ -306,7 +311,7 @@ QStringList PluginManager::arguments() const
} }
/*! /*!
\fn QSet<PluginSpec *> PluginManager::plugins() const \fn QList<PluginSpec *> PluginManager::plugins() const
List of all plugin specifications that have been found in the plugin search paths. List of all plugin specifications that have been found in the plugin search paths.
This list is valid directly after the setPluginPaths() call. This list is valid directly after the setPluginPaths() call.
The plugin specifications contain the information from the plugins' xml description files The plugin specifications contain the information from the plugins' xml description files
@@ -315,7 +320,7 @@ QStringList PluginManager::arguments() const
\sa setPluginPaths() \sa setPluginPaths()
*/ */
QSet<PluginSpec *> PluginManager::plugins() const QList<PluginSpec *> PluginManager::plugins() const
{ {
return d->pluginSpecs; return d->pluginSpecs;
} }
@@ -703,9 +708,11 @@ void PluginManagerPrivate::readPluginPaths()
foreach (const QString &specFile, specFiles) { foreach (const QString &specFile, specFiles) {
PluginSpec *spec = new PluginSpec; PluginSpec *spec = new PluginSpec;
spec->d->read(specFile); spec->d->read(specFile);
pluginSpecs.insert(spec); pluginSpecs.append(spec);
} }
resolveDependencies(); resolveDependencies();
// ensure deterministic plugin load order by sorting
qSort(pluginSpecs.begin(), pluginSpecs.end(), lessThanByPluginName);
emit q->pluginsChanged(); emit q->pluginsChanged();
} }

View File

@@ -101,7 +101,7 @@ public:
void loadPlugins(); void loadPlugins();
QStringList pluginPaths() const; QStringList pluginPaths() const;
void setPluginPaths(const QStringList &paths); void setPluginPaths(const QStringList &paths);
QSet<PluginSpec *> plugins() const; QList<PluginSpec *> plugins() const;
void setFileExtension(const QString &extension); void setFileExtension(const QString &extension);
QString fileExtension() const; QString fileExtension() const;

View File

@@ -66,7 +66,7 @@ public:
void loadPlugin(PluginSpec *spec, PluginSpec::State destState); void loadPlugin(PluginSpec *spec, PluginSpec::State destState);
void resolveDependencies(); void resolveDependencies();
QSet<PluginSpec *> pluginSpecs; QList<PluginSpec *> pluginSpecs;
QList<PluginSpec *> testSpecs; QList<PluginSpec *> testSpecs;
QStringList pluginPaths; QStringList pluginPaths;
QString extension; QString extension;

View File

@@ -693,10 +693,10 @@ int PluginSpecPrivate::versionCompare(const QString &version1, const QString &ve
} }
/*! /*!
\fn bool PluginSpecPrivate::resolveDependencies(const QSet<PluginSpec *> &specs) \fn bool PluginSpecPrivate::resolveDependencies(const QList<PluginSpec *> &specs)
\internal \internal
*/ */
bool PluginSpecPrivate::resolveDependencies(const QSet<PluginSpec *> &specs) bool PluginSpecPrivate::resolveDependencies(const QList<PluginSpec *> &specs)
{ {
if (hasError) if (hasError)
return false; return false;

View File

@@ -56,7 +56,7 @@ public:
bool read(const QString &fileName); bool read(const QString &fileName);
bool provides(const QString &pluginName, const QString &version) const; bool provides(const QString &pluginName, const QString &version) const;
bool resolveDependencies(const QSet<PluginSpec *> &specs); bool resolveDependencies(const QList<PluginSpec *> &specs);
bool loadLibrary(); bool loadLibrary();
bool initializePlugin(); bool initializePlugin();
bool initializeExtensions(); bool initializeExtensions();

View File

@@ -439,7 +439,8 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
typeOfExpression.setDocuments(m_manager->documents()); typeOfExpression.setDocuments(m_manager->documents());
QList<TypeOfExpression::Result> resolvedTypes = typeOfExpression(expression, thisDocument, symbol); QList<TypeOfExpression::Result> resolvedTypes = typeOfExpression(expression, thisDocument, symbol,
TypeOfExpression::Preprocess);
LookupContext context = typeOfExpression.lookupContext(); LookupContext context = typeOfExpression.lookupContext();
if (!typeOfExpression.expressionAST() && (! m_completionOperator || if (!typeOfExpression.expressionAST() && (! m_completionOperator ||