Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
flatpak-qt-creator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
0ad2d077
Commit
0ad2d077
authored
Nov 01, 2010
by
Friedemann Kleint
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Exported header cleanup: Separate out CppQuickFixCollector.
parent
6063fb84
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
187 additions
and
92 deletions
+187
-92
src/plugins/cppeditor/cppeditor.cpp
src/plugins/cppeditor/cppeditor.cpp
+1
-0
src/plugins/cppeditor/cppeditor.pro
src/plugins/cppeditor/cppeditor.pro
+4
-2
src/plugins/cppeditor/cppinsertdecldef.cpp
src/plugins/cppeditor/cppinsertdecldef.cpp
+1
-0
src/plugins/cppeditor/cppplugin.cpp
src/plugins/cppeditor/cppplugin.cpp
+1
-0
src/plugins/cppeditor/cppquickfix.cpp
src/plugins/cppeditor/cppquickfix.cpp
+10
-55
src/plugins/cppeditor/cppquickfix.h
src/plugins/cppeditor/cppquickfix.h
+5
-34
src/plugins/cppeditor/cppquickfixcollector.cpp
src/plugins/cppeditor/cppquickfixcollector.cpp
+97
-0
src/plugins/cppeditor/cppquickfixcollector.h
src/plugins/cppeditor/cppquickfixcollector.h
+65
-0
src/plugins/cppeditor/cppquickfixes.cpp
src/plugins/cppeditor/cppquickfixes.cpp
+3
-1
No files found.
src/plugins/cppeditor/cppeditor.cpp
View file @
0ad2d077
...
...
@@ -34,6 +34,7 @@
#include "cppchecksymbols.h"
#include "cppquickfix.h"
#include "cpplocalsymbols.h"
#include "cppquickfixcollector.h"
#include <AST.h>
#include <Control.h>
...
...
src/plugins/cppeditor/cppeditor.pro
View file @
0ad2d077
...
...
@@ -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
src/plugins/cppeditor/cppinsertdecldef.cpp
View file @
0ad2d077
...
...
@@ -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>
...
...
src/plugins/cppeditor/cppplugin.cpp
View file @
0ad2d077
...
...
@@ -36,6 +36,7 @@
#include "cpphoverhandler.h"
#include "cppquickfix.h"
#include "cppoutline.h"
#include "cppquickfixcollector.h"
#include "cpptypehierarchy.h"
#include <coreplugin/icore.h>
...
...
src/plugins/cppeditor/cppquickfix.cpp
View file @
0ad2d077
...
...
@@ -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
;
}
src/plugins/cppeditor/cppquickfix.h
View file @
0ad2d077
...
...
@@ -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
src/plugins/cppeditor/cppquickfixcollector.cpp
0 → 100644
View file @
0ad2d077
/**************************************************************************
**
** 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
src/plugins/cppeditor/cppquickfixcollector.h
0 → 100644
View file @
0ad2d077
/**************************************************************************
**
** 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
src/plugins/cppeditor/cppquickfixes.cpp
View file @
0ad2d077
...
...
@@ -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:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment