Commit 9548b91b authored by hjk's avatar hjk

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

parents fff7187f 437bbd00
<ui version="4.0"> <ui version="4.0">
<class>%CLASS%Class</class> <class>%CLASS%</class>
<widget class="%BASECLASS%" name="%CLASS%" > <widget class="%BASECLASS%" name="%CLASS%" >
<property name="geometry" > <property name="geometry" >
<rect> <rect>
......
...@@ -1128,7 +1128,7 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item) ...@@ -1128,7 +1128,7 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item)
if (function->argumentCount() == 0) { if (function->argumentCount() == 0) {
extraChars += QLatin1Char('<'); extraChars += QLatin1Char('<');
} }
} else { } else if (! function->isAmbiguous()) {
extraChars += QLatin1Char('('); extraChars += QLatin1Char('(');
// If the function takes no arguments, automatically place the closing parenthesis // If the function takes no arguments, automatically place the closing parenthesis
......
...@@ -214,7 +214,6 @@ private: ...@@ -214,7 +214,6 @@ private:
Document::Ptr m_currentDoc; Document::Ptr m_currentDoc;
QSet<QString> m_todo; QSet<QString> m_todo;
QSet<QString> m_processed; QSet<QString> m_processed;
QFutureSynchronizer<void> m_synchronizer;
}; };
} // namespace Internal } // namespace Internal
...@@ -224,9 +223,7 @@ CppPreprocessor::CppPreprocessor(QPointer<CppModelManager> modelManager) ...@@ -224,9 +223,7 @@ CppPreprocessor::CppPreprocessor(QPointer<CppModelManager> modelManager)
: snapshot(modelManager->snapshot()), : snapshot(modelManager->snapshot()),
m_modelManager(modelManager), m_modelManager(modelManager),
preprocess(this, &env) preprocess(this, &env)
{ { }
m_synchronizer.setCancelOnWait(true);
}
CppPreprocessor::~CppPreprocessor() CppPreprocessor::~CppPreprocessor()
{ } { }
...@@ -510,7 +507,9 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type, ...@@ -510,7 +507,9 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type,
snapshot.insert(doc->fileName(), doc); snapshot.insert(doc->fileName(), doc);
m_todo.remove(fileName); m_todo.remove(fileName);
m_synchronizer.addFuture(QtConcurrent::run(Process(m_modelManager), doc)); Process process(m_modelManager);
process(doc);
(void) switchDocument(previousDoc); (void) switchDocument(previousDoc);
} }
......
...@@ -162,6 +162,7 @@ bool FormClassWizardParameters::generateCpp(QString *header, QString *source, in ...@@ -162,6 +162,7 @@ bool FormClassWizardParameters::generateCpp(QString *header, QString *source, in
if (languageChange) { if (languageChange) {
sourceStr << '\n' << namespaceIndent << "void " << unqualifiedClassName << "::" << "changeEvent(QEvent *e)\n" sourceStr << '\n' << namespaceIndent << "void " << unqualifiedClassName << "::" << "changeEvent(QEvent *e)\n"
<< namespaceIndent << "{\n" << namespaceIndent << "{\n"
<< namespaceIndent << indent << formBaseClass << "::changeEvent(e);\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; << namespaceIndent << indent << indent;
if (embedding != InheritedUiClass) if (embedding != InheritedUiClass)
......
...@@ -109,7 +109,8 @@ bool RemoteBranchModel::refreshBranches(const QString &workingDirectory, bool re ...@@ -109,7 +109,8 @@ bool RemoteBranchModel::refreshBranches(const QString &workingDirectory, bool re
int *currentBranch, QString *errorMessage) int *currentBranch, QString *errorMessage)
{ {
// Run branch command with verbose. // Run branch command with verbose.
QStringList branchArgs(QLatin1String("-v")); QStringList branchArgs;
branchArgs << QLatin1String(GitClient::noColorOption) << QLatin1String("-v");
QString output; QString output;
*currentBranch = -1; *currentBranch = -1;
if (remoteBranches) if (remoteBranches)
......
...@@ -57,8 +57,8 @@ ...@@ -57,8 +57,8 @@
using namespace Git; using namespace Git;
using namespace Git::Internal; using namespace Git::Internal;
const char *const kGitDirectoryC = ".git"; static const char *const kGitDirectoryC = ".git";
const char *const kBranchIndicatorC = "# On branch"; static const char *const kBranchIndicatorC = "# On branch";
static inline QString msgServerFailure() static inline QString msgServerFailure()
{ {
...@@ -108,6 +108,8 @@ GitClient::~GitClient() ...@@ -108,6 +108,8 @@ GitClient::~GitClient()
{ {
} }
const char *GitClient::noColorOption = "--no-color";
QString GitClient::findRepositoryForFile(const QString &fileName) QString GitClient::findRepositoryForFile(const QString &fileName)
{ {
const QString gitDirectory = QLatin1String(kGitDirectoryC); const QString gitDirectory = QLatin1String(kGitDirectoryC);
...@@ -201,22 +203,24 @@ void GitClient::diff(const QString &workingDirectory, ...@@ -201,22 +203,24 @@ void GitClient::diff(const QString &workingDirectory,
// when using the submit dialog. // when using the submit dialog.
GitCommand *command = createCommand(workingDirectory, editor); GitCommand *command = createCommand(workingDirectory, editor);
// Directory diff? // Directory diff?
QStringList commonDiffArgs;
commonDiffArgs << QLatin1String("diff") << QLatin1String(noColorOption);
if (unstagedFileNames.empty() && stagedFileNames.empty()) { if (unstagedFileNames.empty() && stagedFileNames.empty()) {
QStringList arguments; QStringList arguments(commonDiffArgs);
arguments << QLatin1String("diff") << diffArgs; arguments << diffArgs;
m_plugin->outputWindow()->append(formatCommand(binary, arguments)); m_plugin->outputWindow()->append(formatCommand(binary, arguments));
command->addJob(arguments, m_settings.timeout); command->addJob(arguments, m_settings.timeout);
} else { } else {
// Files diff. // Files diff.
if (!unstagedFileNames.empty()) { if (!unstagedFileNames.empty()) {
QStringList arguments; QStringList arguments(commonDiffArgs);
arguments << QLatin1String("diff") << diffArgs << QLatin1String("--") << unstagedFileNames; arguments << QLatin1String("--") << unstagedFileNames;
m_plugin->outputWindow()->append(formatCommand(binary, arguments)); m_plugin->outputWindow()->append(formatCommand(binary, arguments));
command->addJob(arguments, m_settings.timeout); command->addJob(arguments, m_settings.timeout);
} }
if (!stagedFileNames.empty()) { if (!stagedFileNames.empty()) {
QStringList arguments; QStringList arguments(commonDiffArgs);
arguments << QLatin1String("diff") << QLatin1String("--cached") << diffArgs << QLatin1String("--") << stagedFileNames; arguments << QLatin1String("--cached") << diffArgs << QLatin1String("--") << stagedFileNames;
m_plugin->outputWindow()->append(formatCommand(binary, arguments)); m_plugin->outputWindow()->append(formatCommand(binary, arguments));
command->addJob(arguments, m_settings.timeout); command->addJob(arguments, m_settings.timeout);
} }
...@@ -231,9 +235,9 @@ void GitClient::diff(const QString &workingDirectory, ...@@ -231,9 +235,9 @@ void GitClient::diff(const QString &workingDirectory,
if (Git::Constants::debug) if (Git::Constants::debug)
qDebug() << "diff" << workingDirectory << fileName; qDebug() << "diff" << workingDirectory << fileName;
QStringList arguments; QStringList arguments;
arguments << QLatin1String("diff"); arguments << QLatin1String("diff") << QLatin1String(noColorOption);
if (!fileName.isEmpty()) if (!fileName.isEmpty())
arguments << diffArgs << QLatin1String("--") << fileName; arguments << diffArgs << QLatin1String("--") << fileName;
const QString kind = QLatin1String(Git::Constants::GIT_DIFF_EDITOR_KIND); const QString kind = QLatin1String(Git::Constants::GIT_DIFF_EDITOR_KIND);
const QString title = tr("Git Diff %1").arg(fileName); const QString title = tr("Git Diff %1").arg(fileName);
...@@ -245,6 +249,7 @@ void GitClient::diff(const QString &workingDirectory, ...@@ -245,6 +249,7 @@ void GitClient::diff(const QString &workingDirectory,
void GitClient::status(const QString &workingDirectory) void GitClient::status(const QString &workingDirectory)
{ {
// @TODO: Use "--no-color" once it is supported
QStringList statusArgs(QLatin1String("status")); QStringList statusArgs(QLatin1String("status"));
statusArgs << QLatin1String("-u"); statusArgs << QLatin1String("-u");
executeGit(workingDirectory, statusArgs, 0, true); executeGit(workingDirectory, statusArgs, 0, true);
...@@ -255,7 +260,8 @@ void GitClient::log(const QString &workingDirectory, const QString &fileName) ...@@ -255,7 +260,8 @@ void GitClient::log(const QString &workingDirectory, const QString &fileName)
if (Git::Constants::debug) if (Git::Constants::debug)
qDebug() << "log" << workingDirectory << fileName; qDebug() << "log" << workingDirectory << fileName;
QStringList arguments(QLatin1String("log")); QStringList arguments;
arguments << QLatin1String("log") << QLatin1String(noColorOption);
if (m_settings.logCount > 0) if (m_settings.logCount > 0)
arguments << QLatin1String("-n") << QString::number(m_settings.logCount); arguments << QLatin1String("-n") << QString::number(m_settings.logCount);
...@@ -274,8 +280,8 @@ void GitClient::show(const QString &source, const QString &id) ...@@ -274,8 +280,8 @@ void GitClient::show(const QString &source, const QString &id)
{ {
if (Git::Constants::debug) if (Git::Constants::debug)
qDebug() << "show" << source << id; qDebug() << "show" << source << id;
QStringList arguments(QLatin1String("show")); QStringList arguments;
arguments << id; arguments << QLatin1String("show") << QLatin1String(noColorOption) << id;
const QString title = tr("Git Show %1").arg(id); const QString title = tr("Git Show %1").arg(id);
const QString kind = QLatin1String(Git::Constants::GIT_DIFF_EDITOR_KIND); const QString kind = QLatin1String(Git::Constants::GIT_DIFF_EDITOR_KIND);
...@@ -450,7 +456,7 @@ bool GitClient::synchronousShow(const QString &workingDirectory, const QString & ...@@ -450,7 +456,7 @@ bool GitClient::synchronousShow(const QString &workingDirectory, const QString &
if (Git::Constants::debug) if (Git::Constants::debug)
qDebug() << Q_FUNC_INFO << workingDirectory << id; qDebug() << Q_FUNC_INFO << workingDirectory << id;
QStringList args(QLatin1String("show")); QStringList args(QLatin1String("show"));
args << id; args << QLatin1String(noColorOption) << id;
QByteArray outputText; QByteArray outputText;
QByteArray errorText; QByteArray errorText;
const bool rc = synchronousGit(workingDirectory, args, &outputText, &errorText); const bool rc = synchronousGit(workingDirectory, args, &outputText, &errorText);
...@@ -633,10 +639,12 @@ GitClient::StatusResult GitClient::gitStatus(const QString &workingDirectory, ...@@ -633,10 +639,12 @@ GitClient::StatusResult GitClient::gitStatus(const QString &workingDirectory,
// Run 'status'. Note that git returns exitcode 1 if there are no added files. // Run 'status'. Note that git returns exitcode 1 if there are no added files.
QByteArray outputText; QByteArray outputText;
QByteArray errorText; QByteArray errorText;
// @TODO: Use "--no-color" once it is supported
QStringList statusArgs(QLatin1String("status")); QStringList statusArgs(QLatin1String("status"));
if (untracked) if (untracked)
statusArgs << QLatin1String("-u"); statusArgs << QLatin1String("-u");
const bool statusRc = synchronousGit(workingDirectory, statusArgs, &outputText, &errorText); const bool statusRc = synchronousGit(workingDirectory, statusArgs, &outputText, &errorText);
GitCommand::removeColorCodes(&outputText);
if (output) if (output)
*output = QString::fromLocal8Bit(outputText).remove(QLatin1Char('\r')); *output = QString::fromLocal8Bit(outputText).remove(QLatin1Char('\r'));
// Is it something really fatal? // Is it something really fatal?
...@@ -958,14 +966,14 @@ void GitClient::stashPop(const QString &workingDirectory) ...@@ -958,14 +966,14 @@ void GitClient::stashPop(const QString &workingDirectory)
void GitClient::branchList(const QString &workingDirectory) void GitClient::branchList(const QString &workingDirectory)
{ {
QStringList arguments(QLatin1String("branch")); QStringList arguments(QLatin1String("branch"));
arguments << QLatin1String("-r"); arguments << QLatin1String("-r") << QLatin1String(noColorOption);
executeGit(workingDirectory, arguments, 0, true); executeGit(workingDirectory, arguments, 0, true);
} }
void GitClient::stashList(const QString &workingDirectory) void GitClient::stashList(const QString &workingDirectory)
{ {
QStringList arguments(QLatin1String("stash")); QStringList arguments(QLatin1String("stash"));
arguments << QLatin1String("list"); arguments << QLatin1String("list") << QLatin1String(noColorOption);
executeGit(workingDirectory, arguments, 0, true); executeGit(workingDirectory, arguments, 0, true);
} }
......
...@@ -135,6 +135,8 @@ public: ...@@ -135,6 +135,8 @@ public:
static QString msgNoChangedFiles(); static QString msgNoChangedFiles();
static const char *noColorOption;
public slots: public slots:
void show(const QString &source, const QString &id); void show(const QString &source, const QString &id);
......
...@@ -121,6 +121,10 @@ void GitCommand::run() ...@@ -121,6 +121,10 @@ void GitCommand::run()
// Special hack: Always produce output for diff // Special hack: Always produce output for diff
if (ok && output.isEmpty() && m_jobs.front().arguments.at(0) == QLatin1String("diff")) { if (ok && output.isEmpty() && m_jobs.front().arguments.at(0) == QLatin1String("diff")) {
output += "The file does not differ from HEAD"; output += "The file does not differ from HEAD";
} else {
// @TODO: Remove, see below
if (ok && m_jobs.front().arguments.at(0) == QLatin1String("status"))
removeColorCodes(&output);
} }
if (ok && !output.isEmpty()) if (ok && !output.isEmpty())
...@@ -133,5 +137,28 @@ void GitCommand::run() ...@@ -133,5 +137,28 @@ void GitCommand::run()
this->deleteLater(); this->deleteLater();
} }
// Clean output from carriage return and ANSI color codes.
// @TODO: Remove once all relevant commands support "--no-color",
//("status" is missing it as of git 1.6.2)
void GitCommand::removeColorCodes(QByteArray *data)
{
// Remove ansi color codes that look like "ESC[<stuff>m"
const QByteArray ansiColorEscape("\033[");
int escapePos = 0;
while (true) {
const int nextEscapePos = data->indexOf(ansiColorEscape, escapePos);
if (nextEscapePos == -1)
break;
const int endEscapePos = data->indexOf('m', nextEscapePos + ansiColorEscape.size());
if (endEscapePos != -1) {
data->remove(nextEscapePos, endEscapePos - nextEscapePos + 1);
escapePos = nextEscapePos;
} else {
escapePos = nextEscapePos + ansiColorEscape.size();
}
}
}
} // namespace Internal } // namespace Internal
} // namespace Git } // namespace Git
...@@ -50,6 +50,10 @@ public: ...@@ -50,6 +50,10 @@ public:
void addJob(const QStringList &arguments, int timeout); void addJob(const QStringList &arguments, int timeout);
void execute(); void execute();
// Clean output from carriage return and ANSI color codes.
// Workaround until all relevant commands support "--no-color".
static void removeColorCodes(QByteArray *data);
private: private:
void run(); void run();
......
...@@ -1682,6 +1682,10 @@ FunctionDeclaratorAST *FunctionDeclaratorAST::clone(MemoryPool *pool) const ...@@ -1682,6 +1682,10 @@ FunctionDeclaratorAST *FunctionDeclaratorAST::clone(MemoryPool *pool) const
void FunctionDeclaratorAST::accept0(ASTVisitor *visitor) void FunctionDeclaratorAST::accept0(ASTVisitor *visitor)
{ {
if (visitor->visit(this)) { if (visitor->visit(this)) {
accept(parameters, visitor);
for (SpecifierAST *it = cv_qualifier_seq; it; it = it->next)
accept(it, visitor);
accept(exception_specification, visitor);
} }
visitor->endVisit(this); visitor->endVisit(this);
} }
......
...@@ -805,6 +805,7 @@ public: ...@@ -805,6 +805,7 @@ public:
unsigned rparen_token; unsigned rparen_token;
SpecifierAST *cv_qualifier_seq; SpecifierAST *cv_qualifier_seq;
ExceptionSpecificationAST *exception_specification; ExceptionSpecificationAST *exception_specification;
ExpressionAST *as_cpp_initializer;
public: // annotations public: // annotations
Function *symbol; Function *symbol;
......
...@@ -157,6 +157,7 @@ bool CheckDeclarator::visit(NestedDeclaratorAST *ast) ...@@ -157,6 +157,7 @@ bool CheckDeclarator::visit(NestedDeclaratorAST *ast)
bool CheckDeclarator::visit(FunctionDeclaratorAST *ast) bool CheckDeclarator::visit(FunctionDeclaratorAST *ast)
{ {
Function *fun = control()->newFunction(ast->firstToken()); Function *fun = control()->newFunction(ast->firstToken());
fun->setAmbiguous(ast->as_cpp_initializer != 0);
ast->symbol = fun; ast->symbol = fun;
fun->setReturnType(_fullySpecifiedType); fun->setReturnType(_fullySpecifiedType);
......
...@@ -977,7 +977,7 @@ bool Parser::parseCoreDeclarator(DeclaratorAST *&node) ...@@ -977,7 +977,7 @@ bool Parser::parseCoreDeclarator(DeclaratorAST *&node)
return false; return false;
} }
bool Parser::parseDeclarator(DeclaratorAST *&node) bool Parser::parseDeclarator(DeclaratorAST *&node, bool stopAtCppInitializer)
{ {
if (! parseCoreDeclarator(node)) if (! parseCoreDeclarator(node))
return false; return false;
...@@ -988,6 +988,47 @@ bool Parser::parseDeclarator(DeclaratorAST *&node) ...@@ -988,6 +988,47 @@ bool Parser::parseDeclarator(DeclaratorAST *&node)
unsigned startOfPostDeclarator = cursor(); unsigned startOfPostDeclarator = cursor();
if (LA() == T_LPAREN) { if (LA() == T_LPAREN) {
if (stopAtCppInitializer) {
unsigned lparen_token = cursor();
ExpressionAST *initializer = 0;
bool blocked = blockErrors(true);
if (parseInitializer(initializer)) {
if (NestedExpressionAST *expr = initializer->asNestedExpression()) {
if (expr->expression && expr->rparen_token && (LA() == T_COMMA || LA() == T_SEMICOLON)) {
rewind(lparen_token);
// check for ambiguous declarators.
consumeToken();
ParameterDeclarationClauseAST *parameter_declaration_clause = 0;
if (parseParameterDeclarationClause(parameter_declaration_clause) && LA() == T_RPAREN) {
unsigned rparen_token = consumeToken();
FunctionDeclaratorAST *ast = new (_pool) FunctionDeclaratorAST;
ast->lparen_token = lparen_token;
ast->parameters = parameter_declaration_clause;
ast->as_cpp_initializer = initializer;
ast->rparen_token = rparen_token;
*postfix_ptr = ast;
postfix_ptr = &(*postfix_ptr)->next;
blockErrors(blocked);
return true;
}
blockErrors(blocked);
rewind(lparen_token);
return true;
}
}
}
blockErrors(blocked);
rewind(lparen_token);
}
FunctionDeclaratorAST *ast = new (_pool) FunctionDeclaratorAST; FunctionDeclaratorAST *ast = new (_pool) FunctionDeclaratorAST;
ast->lparen_token = consumeToken(); ast->lparen_token = consumeToken();
parseParameterDeclarationClause(ast->parameters); parseParameterDeclarationClause(ast->parameters);
...@@ -1494,7 +1535,7 @@ bool Parser::parseInitDeclarator(DeclaratorAST *&node, ...@@ -1494,7 +1535,7 @@ bool Parser::parseInitDeclarator(DeclaratorAST *&node,
if (acceptStructDeclarator && LA() == T_COLON) { if (acceptStructDeclarator && LA() == T_COLON) {
// anonymous bit-field declaration. // anonymous bit-field declaration.
// ### TODO create the AST // ### TODO create the AST
} else if (! parseDeclarator(node)) { } else if (! parseDeclarator(node, /*stopAtCppInitializer = */ ! acceptStructDeclarator)) {
return false; return false;
} }
......
...@@ -107,7 +107,7 @@ public: ...@@ -107,7 +107,7 @@ public:
bool parseSimpleDeclaration(DeclarationAST *&node, bool acceptStructDeclarator = false); bool parseSimpleDeclaration(DeclarationAST *&node, bool acceptStructDeclarator = false);
bool parseDeclarationStatement(StatementAST *&node); bool parseDeclarationStatement(StatementAST *&node);
bool parseCoreDeclarator(DeclaratorAST *&node); bool parseCoreDeclarator(DeclaratorAST *&node);
bool parseDeclarator(DeclaratorAST *&node); bool parseDeclarator(DeclaratorAST *&node, bool stopAtCppInitializer = false);
bool parseDeleteExpression(ExpressionAST *&node); bool parseDeleteExpression(ExpressionAST *&node);
bool parseDoStatement(StatementAST *&node); bool parseDoStatement(StatementAST *&node);
bool parseElaboratedTypeSpecifier(SpecifierAST *&node); bool parseElaboratedTypeSpecifier(SpecifierAST *&node);
......
...@@ -255,6 +255,12 @@ bool Function::isPureVirtual() const ...@@ -255,6 +255,12 @@ bool Function::isPureVirtual() const
void Function::setPureVirtual(bool isPureVirtual) void Function::setPureVirtual(bool isPureVirtual)
{ _isPureVirtual = isPureVirtual; } { _isPureVirtual = isPureVirtual; }
bool Function::isAmbiguous() const
{ return _isAmbiguous; }
void Function::setAmbiguous(bool isAmbiguous)
{ _isAmbiguous = isAmbiguous; }
void Function::visitSymbol0(SymbolVisitor *visitor) void Function::visitSymbol0(SymbolVisitor *visitor)
{ {
if (visitor->visit(this)) { if (visitor->visit(this)) {
......
...@@ -322,6 +322,9 @@ public: ...@@ -322,6 +322,9 @@ public:
virtual Function *asFunctionType() virtual Function *asFunctionType()
{ return this; } { return this; }
bool isAmbiguous() const; // internal
void setAmbiguous(bool isAmbiguous); // internal
protected: protected:
virtual void visitSymbol0(SymbolVisitor *visitor); virtual void visitSymbol0(SymbolVisitor *visitor);
virtual void accept0(TypeVisitor *visitor); virtual void accept0(TypeVisitor *visitor);
...@@ -337,6 +340,7 @@ private: ...@@ -337,6 +340,7 @@ private:
unsigned _isPureVirtual: 1; unsigned _isPureVirtual: 1;
unsigned _isConst: 1; unsigned _isConst: 1;
unsigned _isVolatile: 1; unsigned _isVolatile: 1;
unsigned _isAmbiguous: 1;
unsigned _methodKey: 3; unsigned _methodKey: 3;
}; };
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment