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

@@ -69,7 +69,7 @@ static const char *HELP_OPTION4 = "--help";
static const char *VERSION_OPTION = "-version";
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.
#ifdef Q_WS_WIN

View File

@@ -37,6 +37,7 @@
#include <TranslationUnit.h>
#include <cplusplus/LookupContext.h>
#include <cplusplus/ResolveExpression.h>
#include <cplusplus/pp.h>
using namespace CPlusPlus;
@@ -53,9 +54,13 @@ void TypeOfExpression::setDocuments(const QMap<QString, Document::Ptr> &document
QList<TypeOfExpression::Result> TypeOfExpression::operator()(const QString &expression,
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_lookupContext = LookupContext(lastVisibleSymbol, expressionDoc,
@@ -97,3 +102,34 @@ Document::Ptr TypeOfExpression::documentForExpression(const QString &expression)
doc->parse(Document::ParseExpression);
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 {
class Environment;
class Macro;
class CPLUSPLUS_EXPORT TypeOfExpression
{
public:
@@ -60,6 +63,11 @@ public:
*/
void setDocuments(const QMap<QString, Document::Ptr> &documents);
enum PreprocessMode {
NoPreprocess,
Preprocess
};
/**
* Returns a list of possible fully specified types associated with the
* given expression.
@@ -73,7 +81,8 @@ public:
* @param lastVisibleSymbol The last visible symbol in the 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.
@@ -91,6 +100,14 @@ private:
ExpressionAST *extractExpressionAST(Document::Ptr doc) 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;
ExpressionAST *m_ast;
LookupContext m_lookupContext;

View File

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

View File

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

View File

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

View File

@@ -66,7 +66,7 @@ public:
void loadPlugin(PluginSpec *spec, PluginSpec::State destState);
void resolveDependencies();
QSet<PluginSpec *> pluginSpecs;
QList<PluginSpec *> pluginSpecs;
QList<PluginSpec *> testSpecs;
QStringList pluginPaths;
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
*/
bool PluginSpecPrivate::resolveDependencies(const QSet<PluginSpec *> &specs)
bool PluginSpecPrivate::resolveDependencies(const QList<PluginSpec *> &specs)
{
if (hasError)
return false;

View File

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

View File

@@ -439,7 +439,8 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
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();
if (!typeOfExpression.expressionAST() && (! m_completionOperator ||