Commit 0ad2d077 authored by Friedemann Kleint's avatar Friedemann Kleint

Exported header cleanup: Separate out CppQuickFixCollector.

parent 6063fb84
......@@ -34,6 +34,7 @@
#include "cppchecksymbols.h"
#include "cppquickfix.h"
#include "cpplocalsymbols.h"
#include "cppquickfixcollector.h"
#include <AST.h>
#include <Control.h>
......
......@@ -21,7 +21,8 @@ HEADERS += cppplugin.h \
cppinsertdecldef.h \
cpplocalsymbols.h \
cpptypehierarchy.h \
cppelementevaluator.h
cppelementevaluator.h \
cppquickfixcollector.h
SOURCES += cppplugin.cpp \
cppeditor.cpp \
cpphighlighter.cpp \
......@@ -36,7 +37,8 @@ SOURCES += cppplugin.cpp \
cppinsertdecldef.cpp \
cpplocalsymbols.cpp \
cpptypehierarchy.cpp \
cppelementevaluator.cpp
cppelementevaluator.cpp \
cppquickfixcollector.cpp
RESOURCES += cppeditor.qrc
OTHER_FILES += CppEditor.pluginspec \
CppEditor.mimetypes.xml
......@@ -35,6 +35,7 @@
#include <cplusplus/LookupContext.h>
#include <cplusplus/Overview.h>
#include <cpptools/insertionpointlocator.h>
#include <cpptools/cpprefactoringchanges.h>
#include <QtCore/QCoreApplication>
#include <QtCore/QDir>
......
......@@ -36,6 +36,7 @@
#include "cpphoverhandler.h"
#include "cppquickfix.h"
#include "cppoutline.h"
#include "cppquickfixcollector.h"
#include "cpptypehierarchy.h"
#include <coreplugin/icore.h>
......
......@@ -29,6 +29,7 @@
#include "cppquickfix.h"
#include "cppeditor.h"
#include "cppquickfixcollector.h"
#include <AST.h>
#include <TranslationUnit.h>
......@@ -42,11 +43,7 @@
#include <cplusplus/DependencyTable.h>
#include <cplusplus/CppRewriter.h>
#include <cppeditor/cppeditor.h>
#include <cpptools/cpprefactoringchanges.h>
#include <cpptools/cpptoolsconstants.h>
#include <cpptools/cppmodelmanagerinterface.h>
#include <extensionsystem/pluginmanager.h>
#include <QtGui/QTextBlock>
......@@ -91,6 +88,15 @@ const CppRefactoringFile CppQuickFixState::currentFile() const
return CppRefactoringFile(editor(), document());
}
bool CppQuickFixState::isCursorOn(unsigned tokenIndex) const
{
return currentFile().isCursorOn(tokenIndex);
}
bool CppQuickFixState::isCursorOn(const CPlusPlus::AST *ast) const
{
return currentFile().isCursorOn(ast);
}
CppQuickFixOperation::CppQuickFixOperation(const CppQuickFixState &state, int priority)
: QuickFixOperation(priority)
......@@ -143,54 +149,3 @@ QList<CppQuickFixOperation::Ptr> CppQuickFixFactory::noResult()
{
return QList<CppQuickFixOperation::Ptr>();
}
CppQuickFixCollector::CppQuickFixCollector()
{
}
CppQuickFixCollector::~CppQuickFixCollector()
{
}
bool CppQuickFixCollector::supportsEditor(TextEditor::ITextEditable *editor)
{
return CppTools::CppModelManagerInterface::instance()->isCppEditor(editor);
}
TextEditor::QuickFixState *CppQuickFixCollector::initializeCompletion(TextEditor::BaseTextEditor *editor)
{
if (CPPEditor *cppEditor = qobject_cast<CPPEditor *>(editor)) {
const SemanticInfo info = cppEditor->semanticInfo();
if (info.revision != cppEditor->editorRevision()) {
// outdated
qWarning() << "TODO: outdated semantic info, force a reparse.";
return 0;
}
if (info.doc) {
ASTPath astPath(info.doc);
const QList<AST *> path = astPath(cppEditor->textCursor());
if (! path.isEmpty()) {
CppQuickFixState *state = new CppQuickFixState(editor);
state->_path = path;
state->_semanticInfo = info;
state->_snapshot = CppTools::CppModelManagerInterface::instance()->snapshot();
state->_context = LookupContext(info.doc, state->snapshot());
return state;
}
}
}
return 0;
}
QList<TextEditor::QuickFixFactory *> CppQuickFixCollector::quickFixFactories() const
{
QList<TextEditor::QuickFixFactory *> results;
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
foreach (CppQuickFixFactory *f, pm->getObjects<CppEditor::CppQuickFixFactory>())
results.append(f);
return results;
}
......@@ -35,16 +35,12 @@
#include <ASTfwd.h>
#include <cplusplus/CppDocument.h>
#include <cpptools/cpprefactoringchanges.h>
#include <texteditor/icompletioncollector.h>
#include <texteditor/quickfix.h>
#include <utils/changeset.h>
#include <QtCore/QSharedPointer>
#include <QtGui/QTextCursor>
namespace CppTools {
class CppModelManagerInterface;
class CppRefactoringFile;
class CppRefactoringChanges;
} // end of namespace CppTools
namespace ExtensionSystem {
......@@ -72,10 +68,8 @@ public:
const CppTools::CppRefactoringFile currentFile() const;
bool isCursorOn(unsigned tokenIndex) const
{ return currentFile().isCursorOn(tokenIndex); }
bool isCursorOn(const CPlusPlus::AST *ast) const
{ return currentFile().isCursorOn(ast); }
bool isCursorOn(unsigned tokenIndex) const;
bool isCursorOn(const CPlusPlus::AST *ast) const;
private:
QList<CPlusPlus::AST *> _path;
......@@ -102,9 +96,6 @@ protected:
const CppQuickFixState &state() const;
protected: // Utility functions forwarding to CppQuickFixState
typedef Utils::ChangeSet::Range Range;
private:
CppQuickFixState _state;
};
......@@ -136,26 +127,6 @@ protected:
static QList<CppQuickFixOperation::Ptr> noResult();
};
namespace Internal {
class CppQuickFixCollector: public TextEditor::QuickFixCollector
{
Q_OBJECT
public:
CppQuickFixCollector();
virtual ~CppQuickFixCollector();
virtual bool supportsEditor(TextEditor::ITextEditable *editor);
virtual TextEditor::QuickFixState *initializeCompletion(TextEditor::BaseTextEditor *editor);
virtual QList<TextEditor::QuickFixFactory *> quickFixFactories() const;
/// Registers all quick-fixes in this plug-in as auto-released objects.
static void registerQuickFixes(ExtensionSystem::IPlugin *plugIn);
};
} // end of namespace Internal
} // end of namespace CppEditor
} // namespace CppEditor
#endif // CPPQUICKFIX_H
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "cppquickfixcollector.h"
#include "cppeditor.h"
#include <extensionsystem/pluginmanager.h>
#include <cpptools/cpprefactoringchanges.h>
#include <cpptools/cpptoolsconstants.h>
#include <cpptools/cppmodelmanagerinterface.h>
#include <AST.h>
#include <cplusplus/ASTPath.h>
namespace CppEditor {
namespace Internal {
CppQuickFixCollector::CppQuickFixCollector()
{
}
CppQuickFixCollector::~CppQuickFixCollector()
{
}
bool CppQuickFixCollector::supportsEditor(TextEditor::ITextEditable *editor)
{
return CppTools::CppModelManagerInterface::instance()->isCppEditor(editor);
}
TextEditor::QuickFixState *CppQuickFixCollector::initializeCompletion(TextEditor::BaseTextEditor *editor)
{
if (CPPEditor *cppEditor = qobject_cast<CPPEditor *>(editor)) {
const SemanticInfo info = cppEditor->semanticInfo();
if (info.revision != cppEditor->editorRevision()) {
// outdated
qWarning() << "TODO: outdated semantic info, force a reparse.";
return 0;
}
if (info.doc) {
CPlusPlus::ASTPath astPath(info.doc);
const QList<CPlusPlus::AST *> path = astPath(cppEditor->textCursor());
if (! path.isEmpty()) {
CppQuickFixState *state = new CppQuickFixState(editor);
state->_path = path;
state->_semanticInfo = info;
state->_snapshot = CppTools::CppModelManagerInterface::instance()->snapshot();
state->_context = CPlusPlus::LookupContext(info.doc, state->snapshot());
return state;
}
}
}
return 0;
}
QList<TextEditor::QuickFixFactory *> CppQuickFixCollector::quickFixFactories() const
{
QList<TextEditor::QuickFixFactory *> results;
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
foreach (CppQuickFixFactory *f, pm->getObjects<CppEditor::CppQuickFixFactory>())
results.append(f);
return results;
}
} // namespace Internal
} // namespace CppEditor
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef QUICKFIXCOLLECTOR_H
#define QUICKFIXCOLLECTOR_H
#include <texteditor/quickfix.h>
namespace ExtensionSystem {
class IPlugin;
}
namespace TextEditor {
class QuickFixState;
}
namespace CppEditor {
namespace Internal {
class CppQuickFixCollector: public TextEditor::QuickFixCollector
{
Q_OBJECT
public:
CppQuickFixCollector();
virtual ~CppQuickFixCollector();
virtual bool supportsEditor(TextEditor::ITextEditable *editor);
virtual TextEditor::QuickFixState *initializeCompletion(TextEditor::BaseTextEditor *editor);
virtual QList<TextEditor::QuickFixFactory *> quickFixFactories() const;
/// Registers all quick-fixes in this plug-in as auto-released objects.
static void registerQuickFixes(ExtensionSystem::IPlugin *plugIn);
};
} // namespace Internal
} // namespace CppEditor
#endif // QUICKFIXCOLLECTOR_H
......@@ -30,6 +30,7 @@
#include "cppeditor.h"
#include "cppquickfix.h"
#include "cppinsertdecldef.h"
#include "cppquickfixcollector.h"
#include <ASTVisitor.h>
#include <AST.h>
......@@ -50,6 +51,7 @@
#include <cplusplus/TypeOfExpression.h>
#include <cplusplus/CppRewriter.h>
#include <cpptools/cpptoolsconstants.h>
#include <cpptools/cpprefactoringchanges.h>
#include <extensionsystem/iplugin.h>
#include <QtGui/QApplication>
......@@ -521,7 +523,7 @@ private:
changes.insert(end, "\n}");
currentFile->change(changes);
currentFile->indent(Range(start, end));
currentFile->indent(Utils::ChangeSet::Range(start, end));
}
private:
......
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