forked from qt-creator/qt-creator
CppEditor: split CppEditor and CppEditorWidget
Change-Id: Id3c815184f7f3bace0276e947f6b6f76e61ec6de Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -86,6 +86,7 @@ QString CppAutoCompleter::insertParagraphSeparator(const QTextCursor &cursor) co
|
||||
#ifdef WITH_TESTS
|
||||
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppeditorconstants.h"
|
||||
#include "cppeditorplugin.h"
|
||||
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
#include "cppcodemodelinspectordialog.h"
|
||||
#include "ui_cppcodemodelinspectordialog.h"
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppeditordocument.h"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
|
@@ -23,6 +23,8 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppdoxygen_test.h"
|
||||
|
||||
#include "cppeditortestcase.h"
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -25,28 +25,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cppfunctiondecldeflink.h"
|
||||
|
||||
#include <texteditor/texteditor.h>
|
||||
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace CppTools {
|
||||
class CppEditorOutline;
|
||||
class RefactoringEngineInterface;
|
||||
class SemanticInfo;
|
||||
class ProjectPart;
|
||||
}
|
||||
|
||||
namespace CppEditor {
|
||||
namespace Internal {
|
||||
|
||||
class CppEditorDocument;
|
||||
|
||||
class CppEditorWidgetPrivate;
|
||||
class FollowSymbolUnderCursor;
|
||||
class FunctionDeclDefLink;
|
||||
|
||||
class CppEditor : public TextEditor::BaseTextEditor
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -55,103 +38,6 @@ public:
|
||||
CppEditor();
|
||||
|
||||
static void decorateEditor(TextEditor::TextEditorWidget *editor);
|
||||
|
||||
};
|
||||
|
||||
class CppEditorWidget : public TextEditor::TextEditorWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CppEditorWidget();
|
||||
~CppEditorWidget() override;
|
||||
|
||||
CppEditorDocument *cppEditorDocument() const;
|
||||
CppTools::CppEditorOutline *outline() const;
|
||||
|
||||
CppTools::SemanticInfo semanticInfo() const;
|
||||
bool isSemanticInfoValidExceptLocalUses() const;
|
||||
bool isSemanticInfoValid() const;
|
||||
|
||||
QSharedPointer<FunctionDeclDefLink> declDefLink() const;
|
||||
void applyDeclDefLinkChanges(bool jumpToMatch);
|
||||
|
||||
TextEditor::AssistInterface *createAssistInterface(
|
||||
TextEditor::AssistKind kind,
|
||||
TextEditor::AssistReason reason) const override;
|
||||
|
||||
FollowSymbolUnderCursor *followSymbolUnderCursorDelegate(); // exposed for tests
|
||||
|
||||
void encourageApply() override;
|
||||
|
||||
void paste() override;
|
||||
void cut() override;
|
||||
void selectAll() override;
|
||||
|
||||
void switchDeclarationDefinition(bool inNextSplit);
|
||||
void showPreProcessorWidget();
|
||||
|
||||
void findUsages();
|
||||
void renameSymbolUnderCursor();
|
||||
void renameUsages(const QString &replacement = QString());
|
||||
|
||||
bool selectBlockUp() override;
|
||||
bool selectBlockDown() override;
|
||||
|
||||
static void updateWidgetHighlighting(QWidget *widget, bool highlight);
|
||||
static bool isWidgetHighlighted(QWidget *widget);
|
||||
|
||||
protected:
|
||||
bool event(QEvent *e) override;
|
||||
void contextMenuEvent(QContextMenuEvent *) override;
|
||||
void keyPressEvent(QKeyEvent *e) override;
|
||||
bool handleStringSplitting(QKeyEvent *e) const;
|
||||
|
||||
Link findLinkAt(const QTextCursor &, bool resolveTarget = true,
|
||||
bool inNextSplit = false) override;
|
||||
|
||||
void onRefactorMarkerClicked(const TextEditor::RefactorMarker &marker) override;
|
||||
|
||||
void slotCodeStyleSettingsChanged(const QVariant &) override;
|
||||
|
||||
private:
|
||||
void updateFunctionDeclDefLink();
|
||||
void updateFunctionDeclDefLinkNow();
|
||||
void abortDeclDefLink();
|
||||
void onFunctionDeclDefLinkFound(QSharedPointer<FunctionDeclDefLink> link);
|
||||
|
||||
void onCppDocumentUpdated();
|
||||
|
||||
void onCodeWarningsUpdated(unsigned revision,
|
||||
const QList<QTextEdit::ExtraSelection> selections,
|
||||
const TextEditor::RefactorMarkers &refactorMarkers);
|
||||
void onIfdefedOutBlocksUpdated(unsigned revision,
|
||||
const QList<TextEditor::BlockRange> ifdefedOutBlocks);
|
||||
|
||||
void onShowInfoBarAction(const Core::Id &id, bool show);
|
||||
|
||||
void updateSemanticInfo(const CppTools::SemanticInfo &semanticInfo,
|
||||
bool updateUseSelectionSynchronously = false);
|
||||
void updatePreprocessorButtonTooltip();
|
||||
|
||||
void processKeyNormally(QKeyEvent *e);
|
||||
|
||||
void finalizeInitialization() override;
|
||||
void finalizeInitializationAfterDuplication(TextEditorWidget *other) override;
|
||||
|
||||
unsigned documentRevision() const;
|
||||
|
||||
TextEditor::RefactorMarkers refactorMarkersWithoutClangMarkers() const;
|
||||
|
||||
CppTools::RefactoringEngineInterface *refactoringEngine() const;
|
||||
|
||||
void renameSymbolUnderCursorClang();
|
||||
void renameSymbolUnderCursorBuiltin();
|
||||
|
||||
CppTools::ProjectPart *projectPart() const;
|
||||
|
||||
private:
|
||||
QScopedPointer<CppEditorWidgetPrivate> d;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -11,6 +11,7 @@ HEADERS += \
|
||||
cppeditorconstants.h \
|
||||
cppeditorenums.h \
|
||||
cppeditorplugin.h \
|
||||
cppeditorwidget.h \
|
||||
cppelementevaluator.h \
|
||||
cppfollowsymbolundercursor.h \
|
||||
cppfunctiondecldeflink.h \
|
||||
@@ -39,6 +40,7 @@ SOURCES += \
|
||||
cppeditor.cpp \
|
||||
cppeditordocument.cpp \
|
||||
cppeditorplugin.cpp \
|
||||
cppeditorwidget.cpp \
|
||||
cppelementevaluator.cpp \
|
||||
cppfollowsymbolundercursor.cpp \
|
||||
cppfunctiondecldeflink.cpp \
|
||||
|
@@ -29,6 +29,8 @@ QtcPlugin {
|
||||
"cppdocumentationcommenthelper.h",
|
||||
"cppeditor.cpp",
|
||||
"cppeditor.h",
|
||||
"cppeditorwidget.cpp",
|
||||
"cppeditorwidget.h",
|
||||
"cppeditor.qrc",
|
||||
"cppeditor_global.h",
|
||||
"cppeditorconstants.h",
|
||||
|
@@ -28,7 +28,7 @@
|
||||
#include "cppautocompleter.h"
|
||||
#include "cppcodemodelinspectordialog.h"
|
||||
#include "cppeditorconstants.h"
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppeditordocument.h"
|
||||
#include "cpphighlighter.h"
|
||||
#include "cpphoverhandler.h"
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include "cppeditortestcase.h"
|
||||
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppeditordocument.h"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
|
@@ -25,8 +25,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cppeditor.h"
|
||||
|
||||
#include <cpptools/cpptoolstestcase.h>
|
||||
|
||||
#include <QVector>
|
||||
|
1031
src/plugins/cppeditor/cppeditorwidget.cpp
Normal file
1031
src/plugins/cppeditor/cppeditorwidget.cpp
Normal file
File diff suppressed because it is too large
Load Diff
145
src/plugins/cppeditor/cppeditorwidget.h
Normal file
145
src/plugins/cppeditor/cppeditorwidget.h
Normal file
@@ -0,0 +1,145 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <texteditor/texteditor.h>
|
||||
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace CppTools {
|
||||
class CppEditorOutline;
|
||||
class RefactoringEngineInterface;
|
||||
class SemanticInfo;
|
||||
class ProjectPart;
|
||||
}
|
||||
|
||||
namespace CppEditor {
|
||||
namespace Internal {
|
||||
|
||||
class CppEditorDocument;
|
||||
|
||||
class CppEditorWidgetPrivate;
|
||||
class FollowSymbolUnderCursor;
|
||||
class FunctionDeclDefLink;
|
||||
|
||||
class CppEditorWidget : public TextEditor::TextEditorWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CppEditorWidget();
|
||||
~CppEditorWidget() override;
|
||||
|
||||
CppEditorDocument *cppEditorDocument() const;
|
||||
CppTools::CppEditorOutline *outline() const;
|
||||
|
||||
CppTools::SemanticInfo semanticInfo() const;
|
||||
bool isSemanticInfoValidExceptLocalUses() const;
|
||||
bool isSemanticInfoValid() const;
|
||||
|
||||
QSharedPointer<FunctionDeclDefLink> declDefLink() const;
|
||||
void applyDeclDefLinkChanges(bool jumpToMatch);
|
||||
|
||||
TextEditor::AssistInterface *createAssistInterface(
|
||||
TextEditor::AssistKind kind,
|
||||
TextEditor::AssistReason reason) const override;
|
||||
|
||||
FollowSymbolUnderCursor *followSymbolUnderCursorDelegate(); // exposed for tests
|
||||
|
||||
void encourageApply() override;
|
||||
|
||||
void paste() override;
|
||||
void cut() override;
|
||||
void selectAll() override;
|
||||
|
||||
void switchDeclarationDefinition(bool inNextSplit);
|
||||
void showPreProcessorWidget();
|
||||
|
||||
void findUsages();
|
||||
void renameSymbolUnderCursor();
|
||||
void renameUsages(const QString &replacement = QString());
|
||||
|
||||
bool selectBlockUp() override;
|
||||
bool selectBlockDown() override;
|
||||
|
||||
static void updateWidgetHighlighting(QWidget *widget, bool highlight);
|
||||
static bool isWidgetHighlighted(QWidget *widget);
|
||||
|
||||
protected:
|
||||
bool event(QEvent *e) override;
|
||||
void contextMenuEvent(QContextMenuEvent *) override;
|
||||
void keyPressEvent(QKeyEvent *e) override;
|
||||
bool handleStringSplitting(QKeyEvent *e) const;
|
||||
|
||||
Link findLinkAt(const QTextCursor &, bool resolveTarget = true,
|
||||
bool inNextSplit = false) override;
|
||||
|
||||
void onRefactorMarkerClicked(const TextEditor::RefactorMarker &marker) override;
|
||||
|
||||
void slotCodeStyleSettingsChanged(const QVariant &) override;
|
||||
|
||||
private:
|
||||
void updateFunctionDeclDefLink();
|
||||
void updateFunctionDeclDefLinkNow();
|
||||
void abortDeclDefLink();
|
||||
void onFunctionDeclDefLinkFound(QSharedPointer<FunctionDeclDefLink> link);
|
||||
|
||||
void onCppDocumentUpdated();
|
||||
|
||||
void onCodeWarningsUpdated(unsigned revision,
|
||||
const QList<QTextEdit::ExtraSelection> selections,
|
||||
const TextEditor::RefactorMarkers &refactorMarkers);
|
||||
void onIfdefedOutBlocksUpdated(unsigned revision,
|
||||
const QList<TextEditor::BlockRange> ifdefedOutBlocks);
|
||||
|
||||
void onShowInfoBarAction(const Core::Id &id, bool show);
|
||||
|
||||
void updateSemanticInfo(const CppTools::SemanticInfo &semanticInfo,
|
||||
bool updateUseSelectionSynchronously = false);
|
||||
void updatePreprocessorButtonTooltip();
|
||||
|
||||
void processKeyNormally(QKeyEvent *e);
|
||||
|
||||
void finalizeInitialization() override;
|
||||
void finalizeInitializationAfterDuplication(TextEditorWidget *other) override;
|
||||
|
||||
unsigned documentRevision() const;
|
||||
|
||||
TextEditor::RefactorMarkers refactorMarkersWithoutClangMarkers() const;
|
||||
|
||||
CppTools::RefactoringEngineInterface *refactoringEngine() const;
|
||||
|
||||
void renameSymbolUnderCursorClang();
|
||||
void renameSymbolUnderCursorBuiltin();
|
||||
|
||||
CppTools::ProjectPart *projectPart() const;
|
||||
|
||||
private:
|
||||
QScopedPointer<CppEditorWidgetPrivate> d;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace CppEditor
|
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "cppfollowsymbolundercursor.h"
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppeditordocument.h"
|
||||
#include "cppvirtualfunctionassistprovider.h"
|
||||
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
#include "cppfunctiondecldeflink.h"
|
||||
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppquickfixassistant.h"
|
||||
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include "cppincludehierarchy.h"
|
||||
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppeditorconstants.h"
|
||||
#include "cppeditorplugin.h"
|
||||
#include "cppelementevaluator.h"
|
||||
|
@@ -23,6 +23,8 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppeditorplugin.h"
|
||||
#include "cppeditortestcase.h"
|
||||
#include "cppincludehierarchy.h"
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
|
||||
#include <texteditor/ioutlinewidget.h>
|
||||
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
#include "cppparsecontext.h"
|
||||
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QDir>
|
||||
|
@@ -27,6 +27,7 @@
|
||||
#include "ui_cpppreprocessordialog.h"
|
||||
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppeditorconstants.h"
|
||||
|
||||
#include <projectexplorer/session.h>
|
||||
|
@@ -23,6 +23,8 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppeditorplugin.h"
|
||||
#include "cppeditortestcase.h"
|
||||
#include "cppquickfixassistant.h"
|
||||
|
@@ -26,7 +26,8 @@
|
||||
#include "cppquickfixassistant.h"
|
||||
|
||||
#include "cppeditorconstants.h"
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppquickfixes.h"
|
||||
|
||||
#include <cpptools/cppmodelmanager.h>
|
||||
#include <texteditor/textdocument.h>
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
#include "cppquickfixes.h"
|
||||
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppeditordocument.h"
|
||||
#include "cppfunctiondecldeflink.h"
|
||||
#include "cppquickfixassistant.h"
|
||||
|
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "cppeditorconstants.h"
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppelementevaluator.h"
|
||||
#include "cppeditorplugin.h"
|
||||
|
||||
|
@@ -24,6 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppeditorplugin.h"
|
||||
#include "cppeditortestcase.h"
|
||||
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
#include "cppuseselectionsupdater.h"
|
||||
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppeditordocument.h"
|
||||
|
||||
#include <cpptools/cpptoolsreuse.h>
|
||||
|
@@ -24,6 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppeditorplugin.h"
|
||||
#include "cppeditortestcase.h"
|
||||
#include "cppquickfix.h"
|
||||
|
@@ -23,6 +23,8 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppeditorplugin.h"
|
||||
#include "cppeditortestcase.h"
|
||||
#include "cppelementevaluator.h"
|
||||
|
Reference in New Issue
Block a user