Commit a22ffb1c authored by hjk's avatar hjk

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

parents 4c358cc3 9394b4df
......@@ -1191,6 +1191,11 @@ bool Parser::parseClassSpecifier(SpecifierAST *&node)
NameAST *name = 0;
parseName(name);
bool parsed = false;
const bool previousInFunctionBody = _inFunctionBody;
_inFunctionBody = false;
if (LA() == T_COLON || LA() == T_LBRACE) {
BaseSpecifierAST *base_clause = 0;
if (LA() == T_COLON) {
......@@ -1233,9 +1238,12 @@ bool Parser::parseClassSpecifier(SpecifierAST *&node)
}
}
node = ast;
return true;
parsed = true;
}
return false;
_inFunctionBody = previousInFunctionBody;
return parsed;
}
bool Parser::parseAccessSpecifier(SpecifierAST *&node)
......
......@@ -146,7 +146,7 @@ unsigned TranslationUnit::matchingBrace(unsigned index) const
MemoryPool *TranslationUnit::memoryPool() const
{ return _pool; }
TranslationUnitAST *TranslationUnit::ast() const
AST *TranslationUnit::ast() const
{ return _ast; }
bool TranslationUnit::isTokenized() const
......@@ -218,17 +218,49 @@ bool TranslationUnit::skipFunctionBody() const
void TranslationUnit::setSkipFunctionBody(bool skipFunctionBody)
{ _skipFunctionBody = skipFunctionBody; }
void TranslationUnit::parse()
bool TranslationUnit::parse(ParseMode mode)
{
if (isParsed())
return;
return false;
if (! isTokenized())
tokenize();
Parser parser(this);
parser.setQtMocRunEnabled(_qtMocRunEnabled);
parser.parseTranslationUnit(_ast);
bool parsed = false;
switch (mode) {
case ParseTranlationUnit: {
TranslationUnitAST *node = 0;
parsed = parser.parseTranslationUnit(node);
_ast = node;
} break;
case ParseDeclaration: {
DeclarationAST *node = 0;
parsed = parser.parseDeclaration(node);
_ast = node;
} break;
case ParseExpression: {
ExpressionAST *node = 0;
parsed = parser.parseExpression(node);
_ast = node;
} break;
case ParseStatement: {
StatementAST *node = 0;
parsed = parser.parseStatement(node);
_ast = node;
} break;
default:
break;
} // switch
return parsed;
}
void TranslationUnit::pushLineOffset(unsigned offset)
......
......@@ -95,7 +95,7 @@ public:
NumericLiteral *numericLiteral(unsigned index) const;
MemoryPool *memoryPool() const;
TranslationUnitAST *ast() const;
AST *ast() const;
bool blockErrors(bool block);
......@@ -113,7 +113,15 @@ public:
void setSkipFunctionBody(bool skipFunctionBody);
bool isParsed() const;
void parse();
enum ParseMode {
ParseTranlationUnit,
ParseDeclaration,
ParseExpression,
ParseStatement
};
bool parse(ParseMode mode = ParseTranlationUnit);
void resetAST();
void release();
......@@ -169,7 +177,7 @@ private:
std::vector<unsigned> _lineOffsets;
std::vector<PPLine> _ppLines;
MemoryPool *_pool;
TranslationUnitAST *_ast;
AST *_ast;
TranslationUnit *_previousTranslationUnit;
union {
unsigned _flags;
......
......@@ -251,9 +251,31 @@ QSet<QByteArray> Document::macroNames() const
return _macroNames;
}
void Document::parse()
bool Document::parse(ParseMode mode)
{
_translationUnit->parse();
TranslationUnit::ParseMode m = TranslationUnit::ParseTranlationUnit;
switch (mode) {
case ParseTranlationUnit:
m = TranslationUnit::ParseTranlationUnit;
break;
case ParseDeclaration:
m = TranslationUnit::ParseDeclaration;
break;
case ParseExpression:
m = TranslationUnit::ParseExpression;
break;
case ParseStatement:
m = TranslationUnit::ParseStatement;
break;
default:
break;
}
return _translationUnit->parse(m);
}
void Document::check()
......@@ -264,7 +286,10 @@ void Document::check()
_globalNamespace = _control->newNamespace(0);
Scope *globals = _globalNamespace->members();
if (TranslationUnitAST *ast = _translationUnit->ast()) {
if (! _translationUnit->ast())
return; // nothing to do.
if (TranslationUnitAST *ast = _translationUnit->ast()->asTranslationUnit()) {
for (DeclarationAST *decl = ast->declarations; decl; decl = decl->next) {
semantic.check(decl, globals);
}
......
......@@ -85,7 +85,14 @@ public:
void startSkippingBlocks(unsigned offset);
void stopSkippingBlocks(unsigned offset);
void parse(); // ### remove
enum ParseMode { // ### keep in sync with CPlusPlus::TranslationUnit
ParseTranlationUnit,
ParseDeclaration,
ParseExpression,
ParseStatement
};
bool parse(ParseMode mode = ParseTranlationUnit);
void check();
void releaseTranslationUnit();
......
......@@ -81,34 +81,18 @@ ExpressionAST *TypeOfExpression::expressionAST() const
ExpressionAST *TypeOfExpression::extractExpressionAST(Document::Ptr doc) const
{
TranslationUnitAST *translationUnitAST = doc->translationUnit()->ast();
if (! doc->translationUnit()->ast())
return 0;
// ### evaluate the expression
ExpressionAST *expressionAST = 0;
if (translationUnitAST) {
DeclarationAST *declaration = translationUnitAST->declarations;
SimpleDeclarationAST *simpleDecl = 0;
if (declaration)
simpleDecl = declaration->asSimpleDeclaration();
if (simpleDecl && simpleDecl->decl_specifier_seq) {
if (TypeofSpecifierAST *typeOfSpec = simpleDecl->decl_specifier_seq->asTypeofSpecifier())
expressionAST = typeOfSpec->expression;
}
}
return expressionAST;
return doc->translationUnit()->ast()->asExpression();
}
Document::Ptr TypeOfExpression::documentForExpression(const QString &expression) const
{
// create a __typeof__ specifier
QByteArray declaration;
declaration += "__typeof__ ";
declaration += expression.toLatin1(); // C++ code needs to be in latin1
declaration += ";";
// create the expression's AST.
Document::Ptr doc = Document::create(QLatin1String("<completion>"));
doc->setSource(declaration);
doc->parse();
const QByteArray bytes = expression.toUtf8();
doc->setSource(bytes);
doc->parse(Document::ParseExpression);
return doc;
}
......@@ -19,6 +19,7 @@ CMakeStep::~CMakeStep()
bool CMakeStep::init(const QString &buildConfiguration)
{
// TODO
return true;
}
void CMakeStep::run(QFutureInterface<bool> &fi)
......
......@@ -342,13 +342,6 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) :
updateActions();
m_d->m_windowPopup = new OpenEditorsWindow(this);
#ifdef Q_OS_MAC
m_d->m_externalEditor = m_d->m_core->resourcePath()
+QLatin1String("/runInTerminal.command vi %f %l %c %W %H %x %y");
#elif defined(Q_OS_UNIX)
m_d->m_externalEditor = QLatin1String("xterm -geom %Wx%H+%x+%y -e vi %f +%l +\"normal %c|\"");
#endif
}
EditorManager::~EditorManager()
......@@ -381,6 +374,20 @@ QSize EditorManager::minimumSizeHint() const
return QSize(400, 300);
}
QString EditorManager::defaultExternalEditor() const
{
#ifdef Q_OS_MAC
return m_d->m_core->resourcePath()
+QLatin1String("/runInTerminal.command vi %f %l %c %W %H %x %y");
#elif defined(Q_OS_UNIX)
return QLatin1String("xterm -geom %Wx%H+%x+%y -e vi %f +%l +\"normal %c|\"");
#elif defined (Q_OS_WIN)
return QLatin1String("notepad %f");
#else
return QString();
#endif
}
EditorSplitter *EditorManager::editorSplitter() const
{
return m_d->m_splitter;
......@@ -1153,7 +1160,7 @@ void EditorManager::updateActions()
m_d->m_duplicateAction->setEnabled(curEditor != 0 && curEditor->duplicateSupported());
m_d->m_openInExternalEditorAction->setEnabled(curEditor != 0 && !m_d->m_externalEditor.isEmpty());
m_d->m_openInExternalEditorAction->setEnabled(curEditor != 0);
}
QList<IEditor*> EditorManager::openedEditors() const
......@@ -1364,7 +1371,7 @@ void EditorManager::saveSettings(QSettings *settings)
m_d->m_splitter->saveSettings(settings);
settings->setValue(QLatin1String("EditorManager/DocumentStates"),
m_d->m_editorStates);
settings->setValue(QLatin1String("EditorManager/ExternalEditor"),
settings->setValue(QLatin1String("EditorManager/ExternalEditorCommand"),
m_d->m_externalEditor);
}
......@@ -1375,7 +1382,7 @@ void EditorManager::readSettings(QSettings *settings)
m_d->m_editorStates = settings->value(QLatin1String("EditorManager/DocumentStates"))
.value<QMap<QString, QVariant> >();
if (settings->contains(QLatin1String("EditorManager/ExternalEditor")))
m_d->m_externalEditor = settings->value(QLatin1String("EditorManager/ExternalEditor")).toString();
m_d->m_externalEditor = settings->value(QLatin1String("EditorManager/ExternalEditorCommand")).toString();
}
QByteArray EditorManager::saveOpenEditorList() const
......@@ -1489,7 +1496,11 @@ QString EditorManager::externalEditorHelpText() const
void EditorManager::openInExternalEditor()
{
if (m_d->m_externalEditor.isEmpty())
QString command = m_d->m_externalEditor;
if (command.isEmpty())
command = defaultExternalEditor();
if (command.isEmpty())
return;
IEditor *editor = currentEditor();
......@@ -1508,7 +1519,7 @@ void EditorManager::openInExternalEditor()
QFontMetrics fm(font);
rect.moveTo(editor->widget()->mapToGlobal(QPoint(0,0)));
QString pre = m_d->m_externalEditor;
QString pre = command;
QString cmd;
for (int i = 0; i < pre.size(); ++i) {
QChar c = pre.at(i);
......@@ -1551,11 +1562,16 @@ void EditorManager::openInExternalEditor()
void EditorManager::setExternalEditor(const QString &editor)
{
m_d->m_externalEditor = editor;
if (editor.isEmpty() || editor == defaultExternalEditor())
m_d->m_externalEditor = defaultExternalEditor();
else
m_d->m_externalEditor = editor;
}
QString EditorManager::externalEditor() const
{
if (m_d->m_externalEditor.isEmpty())
return defaultExternalEditor();
return m_d->m_externalEditor;
}
......
......@@ -156,6 +156,7 @@ public:
void setExternalEditor(const QString &);
QString externalEditor() const;
QString defaultExternalEditor() const;
QString externalEditorHelpText() const;
signals:
......
......@@ -72,6 +72,8 @@ QWidget* GeneralSettings::createPage(QWidget *parent)
connect(m_page->resetButton, SIGNAL(clicked()),
this, SLOT(resetInterfaceColor()));
connect(m_page->resetEditorButton, SIGNAL(clicked()),
this, SLOT(resetExternalEditor()));
connect(m_page->helpExternalEditorButton, SIGNAL(clicked()),
this, SLOT(showHelpForExternalEditor()));
......@@ -95,6 +97,10 @@ void GeneralSettings::resetInterfaceColor()
m_page->colorButton->setColor(0x666666);
}
void GeneralSettings::resetExternalEditor()
{
m_page->externalEditorEdit->setText(EditorManager::instance()->defaultExternalEditor());
}
void GeneralSettings::showHelpForExternalEditor()
{
......
......@@ -59,6 +59,7 @@ public:
private slots:
void resetInterfaceColor();
void resetExternalEditor();
void showHelpForExternalEditor();
private:
......
......@@ -108,6 +108,20 @@
<item>
<widget class="QLineEdit" name="externalEditorEdit"/>
</item>
<item>
<widget class="QToolButton" name="resetEditorButton">
<property name="toolTip">
<string>Reset to default</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="core.qrc">
<normaloff>:/qworkbench/images/reset.png</normaloff>:/qworkbench/images/reset.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="helpExternalEditorButton">
<property name="text">
......
......@@ -640,9 +640,9 @@ void pp::operator()(const QByteArray &source, QByteArray *result)
const char *beginOfText = startOfToken(*identifierToken);
const char *endOfText = endOfToken(*_dot);
++_dot; // skip T_RPAREN
m->hidden = true;
//m->hidden = true;
expand(beginOfText, endOfText, result);
m->hidden = false;
//m->hidden = false;
}
}
}
......
......@@ -170,7 +170,7 @@ void GitClient::diff(const QString &workingDirectory, const QStringList &fileNam
if (Git::Constants::debug)
qDebug() << "diff" << workingDirectory << fileNames;
QStringList arguments;
arguments << QLatin1String("diff") << fileNames;
arguments << QLatin1String("diff") << QLatin1String("--") << fileNames;
const QString kind = QLatin1String(Git::Constants::GIT_DIFF_EDITOR_KIND);
const QString title = tr("Git Diff");
......@@ -187,7 +187,7 @@ void GitClient::diff(const QString &workingDirectory, const QString &fileName)
QStringList arguments;
arguments << QLatin1String("diff");
if (!fileName.isEmpty())
arguments << fileName;
arguments << QLatin1String("--") << fileName;
const QString kind = QLatin1String(Git::Constants::GIT_DIFF_EDITOR_KIND);
const QString title = tr("Git Diff %1").arg(fileName);
......@@ -246,7 +246,7 @@ void GitClient::blame(const QString &workingDirectory, const QString &fileName)
if (Git::Constants::debug)
qDebug() << "blame" << workingDirectory << fileName;
QStringList arguments(QLatin1String("blame"));
arguments << fileName;
arguments << QLatin1String("--") << fileName;
const QString kind = QLatin1String(Git::Constants::GIT_BLAME_EDITOR_KIND);
const QString title = tr("Git Blame %1").arg(fileName);
......@@ -314,7 +314,7 @@ bool GitClient::synchronousReset(const QString &workingDirectory,
QByteArray outputText;
QByteArray errorText;
QStringList arguments;
arguments << QLatin1String("reset") << QLatin1String("HEAD") << files;
arguments << QLatin1String("reset") << QLatin1String("HEAD") << QLatin1String("--") << files;
const bool rc = synchronousGit(workingDirectory, arguments, &outputText, &errorText);
const QString output = QString::fromLocal8Bit(outputText);
m_plugin->m_outputWindow->popup(false);
......@@ -643,9 +643,9 @@ GitCommand::~GitCommand()
{
}
void GitCommand::execute(const QStringList &arguments
, const QString &workingDirectory
, const ProjectExplorer::Environment &environment)
void GitCommand::execute(const QStringList &arguments,
const QString &workingDirectory,
const ProjectExplorer::Environment &environment)
{
if (Git::Constants::debug)
qDebug() << "GitCommand::execute" << workingDirectory << arguments;
......@@ -663,9 +663,9 @@ void GitCommand::execute(const QStringList &arguments
, Core::ProgressManagerInterface::CloseOnSuccess);
}
void GitCommand::run(const QStringList &arguments
, const QString &workingDirectory
, const ProjectExplorer::Environment &environment)
void GitCommand::run(const QStringList &arguments,
const QString &workingDirectory,
const ProjectExplorer::Environment &environment)
{
if (Git::Constants::debug)
qDebug() << "GitCommand::run" << workingDirectory << arguments;
......
......@@ -57,9 +57,9 @@ GitSubmitEditorPanelData GitSubmitEditorWidget::panelData() const
rc.author = m_gitSubmitPanelUi.authorLineEdit->text();
rc.email = m_gitSubmitPanelUi.emailLineEdit->text();
return rc;
};
}
void GitSubmitEditorWidget::setPanelData(const GitSubmitEditorPanelData &data)
void GitSubmitEditorWidget::setPanelData(const GitSubmitEditorPanelData &data)
{
m_gitSubmitPanelUi.authorLineEdit->setText(data.author);
m_gitSubmitPanelUi.emailLineEdit->setText(data.email);
......
......@@ -11,6 +11,9 @@
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="infoGroup">
<property name="title">
......
/***************************************************************************
**
** 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 "gitversioncontrol.h"
#include "gitclient.h"
namespace Git {
namespace Internal {
GitVersionControl::GitVersionControl(GitClient *client) :
m_enabled(true),
m_client(client)
{
}
QString GitVersionControl::name() const
{
return QLatin1String("git");
}
bool GitVersionControl::isEnabled() const
{
return m_enabled;
}
void GitVersionControl::setEnabled(bool enabled)
{
if (m_enabled != enabled) {
m_enabled = enabled;
emit enabledChanged(m_enabled);
}
}
bool GitVersionControl::supportsOperation(Operation operation) const
{
bool rc = false;
switch (operation) {
case AddOperation:
case DeleteOperation:
case OpenOperation:
break;
}
return rc;
}
bool GitVersionControl::vcsOpen(const QString & /*fileName*/)
{
return false;
}
bool GitVersionControl::vcsAdd(const QString & /*fileName*/)
{
return false;
}
bool GitVersionControl::vcsDelete(const QString & /*fileName*/)
{
// TODO: implement using 'git rm'.
return false;
}
bool GitVersionControl::managesDirectory(const QString &directory) const
{
return !GitClient::findRepositoryForDirectory(directory).isEmpty();
}
QString GitVersionControl::findTopLevelForDirectory(const QString &directory) const
{
return GitClient::findRepositoryForDirectory(directory);
}
} // Internal
} // Git
/***************************************************************************
**
** 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.
**
***************************************************************************/