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
3ebc3284
Commit
3ebc3284
authored
Sep 30, 2010
by
Erik Verbruggen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
C++: added quickfix to insert a method definition.
Reviewed-by: Christian Kamm
parent
44d87bf8
Changes
13
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
156 additions
and
196 deletions
+156
-196
src/libs/cplusplus/cplusplus-lib.pri
src/libs/cplusplus/cplusplus-lib.pri
+2
-4
src/plugins/cppeditor/cppeditor.pro
src/plugins/cppeditor/cppeditor.pro
+0
-2
src/plugins/cppeditor/cppinsertdecldef.cpp
src/plugins/cppeditor/cppinsertdecldef.cpp
+75
-151
src/plugins/cppeditor/cppinsertdecldef.h
src/plugins/cppeditor/cppinsertdecldef.h
+0
-5
src/plugins/cppeditor/cppquickfix.cpp
src/plugins/cppeditor/cppquickfix.cpp
+2
-1
src/plugins/cppeditor/cppquickfix.h
src/plugins/cppeditor/cppquickfix.h
+5
-3
src/plugins/cppeditor/cppquickfixes.cpp
src/plugins/cppeditor/cppquickfixes.cpp
+1
-0
src/plugins/cpptools/cpprefactoringchanges.cpp
src/plugins/cpptools/cpprefactoringchanges.cpp
+1
-1
src/plugins/cpptools/cpprefactoringchanges.h
src/plugins/cpptools/cpprefactoringchanges.h
+5
-5
src/plugins/cpptools/cpptools.pro
src/plugins/cpptools/cpptools.pro
+6
-2
src/plugins/cpptools/insertionpointlocator.cpp
src/plugins/cpptools/insertionpointlocator.cpp
+33
-7
src/plugins/cpptools/insertionpointlocator.h
src/plugins/cpptools/insertionpointlocator.h
+20
-11
src/plugins/designer/qtcreatorintegration.cpp
src/plugins/designer/qtcreatorintegration.cpp
+6
-4
No files found.
src/libs/cplusplus/cplusplus-lib.pri
View file @
3ebc3284
...
...
@@ -48,8 +48,7 @@ HEADERS += \
$$PWD/pp-cctype.h \
$$PWD/pp-engine.h \
$$PWD/pp-macro-expander.h \
$$PWD/pp-scanner.h \
$$PWD/InsertionPointLocator.h
$$PWD/pp-scanner.h
SOURCES += \
$$PWD/SimpleLexer.cpp \
...
...
@@ -73,7 +72,6 @@ SOURCES += \
$$PWD/Macro.cpp \
$$PWD/pp-engine.cpp \
$$PWD/pp-macro-expander.cpp \
$$PWD/pp-scanner.cpp \
$$PWD/InsertionPointLocator.cpp
$$PWD/pp-scanner.cpp
RESOURCES += $$PWD/cplusplus.qrc
src/plugins/cppeditor/cppeditor.pro
View file @
3ebc3284
...
...
@@ -15,7 +15,6 @@ HEADERS += cppplugin.h \
cppeditor_global
.
h
\
cppclasswizard
.
h
\
cppquickfix
.
h
\
cpprefactoringchanges
.
h
\
cppchecksymbols
.
h
\
cppsemanticinfo
.
h
\
cppoutline
.
h
\
...
...
@@ -31,7 +30,6 @@ SOURCES += cppplugin.cpp \
cppclasswizard
.
cpp
\
cppquickfix
.
cpp
\
cppquickfixes
.
cpp
\
cpprefactoringchanges
.
cpp
\
cppchecksymbols
.
cpp
\
cppsemanticinfo
.
cpp
\
cppoutline
.
cpp
\
...
...
src/plugins/cppeditor/cppinsertdecldef.cpp
View file @
3ebc3284
This diff is collapsed.
Click to expand it.
src/plugins/cppeditor/cppinsertdecldef.h
View file @
3ebc3284
...
...
@@ -56,11 +56,6 @@ class DefFromDecl: public CppQuickFixFactory
{
public:
virtual
QList
<
CppQuickFixOperation
::
Ptr
>
match
(
const
CppQuickFixState
&
state
);
protected:
static
QString
generateDefinition
(
const
CppQuickFixState
&
state
,
CPlusPlus
::
Function
*
method
,
CPlusPlus
::
ClassOrNamespace
*
targetBinding
);
};
}
// namespace Internal
...
...
src/plugins/cppeditor/cppquickfix.cpp
View file @
3ebc3284
...
...
@@ -43,7 +43,7 @@
#include <cplusplus/CppRewriter.h>
#include <cppeditor/cppeditor.h>
#include <cpp
editor
/cpprefactoringchanges.h>
#include <cpp
tools
/cpprefactoringchanges.h>
#include <cpptools/cpptoolsconstants.h>
#include <cpptools/cppmodelmanagerinterface.h>
#include <extensionsystem/pluginmanager.h>
...
...
@@ -52,6 +52,7 @@
using
namespace
CppEditor
;
using
namespace
CppEditor
::
Internal
;
using
namespace
CppTools
;
using
namespace
TextEditor
;
using
namespace
CPlusPlus
;
using
namespace
Utils
;
...
...
src/plugins/cppeditor/cppquickfix.h
View file @
3ebc3284
...
...
@@ -30,11 +30,12 @@
#ifndef CPPQUICKFIX_H
#define CPPQUICKFIX_H
#include "cpp
refactoringchanges
.h"
#include "cpp
editor_global
.h"
#include "cppsemanticinfo.h"
#include <ASTfwd.h>
#include <cplusplus/CppDocument.h>
#include <cpptools/cpprefactoringchanges.h>
#include <texteditor/icompletioncollector.h>
#include <texteditor/quickfix.h>
#include <utils/changeset.h>
...
...
@@ -69,7 +70,7 @@ public:
CppEditor
::
Internal
::
SemanticInfo
semanticInfo
()
const
;
const
CPlusPlus
::
LookupContext
&
context
()
const
;
const
CppRefactoringFile
currentFile
()
const
;
const
Cpp
Tools
::
Cpp
RefactoringFile
currentFile
()
const
;
bool
isCursorOn
(
unsigned
tokenIndex
)
const
{
return
currentFile
().
isCursorOn
(
tokenIndex
);
}
...
...
@@ -94,7 +95,8 @@ public:
virtual
void
perform
();
protected:
virtual
void
performChanges
(
CppRefactoringFile
*
currentFile
,
CppRefactoringChanges
*
refactoring
)
=
0
;
virtual
void
performChanges
(
CppTools
::
CppRefactoringFile
*
currentFile
,
CppTools
::
CppRefactoringChanges
*
refactoring
)
=
0
;
QString
fileName
()
const
;
...
...
src/plugins/cppeditor/cppquickfixes.cpp
View file @
3ebc3284
...
...
@@ -58,6 +58,7 @@
using
namespace
CppEditor
;
using
namespace
CppEditor
::
Internal
;
using
namespace
CppTools
;
using
namespace
TextEditor
;
using
namespace
CPlusPlus
;
using
namespace
Utils
;
...
...
src/plugins/cpp
editor
/cpprefactoringchanges.cpp
→
src/plugins/cpp
tools
/cpprefactoringchanges.cpp
View file @
3ebc3284
...
...
@@ -37,8 +37,8 @@
#include <QtGui/QTextBlock>
using
namespace
CppEditor
;
using
namespace
CPlusPlus
;
using
namespace
CppTools
;
using
namespace
Utils
;
CppRefactoringChanges
::
CppRefactoringChanges
(
const
Snapshot
&
snapshot
)
...
...
src/plugins/cpp
editor
/cpprefactoringchanges.h
→
src/plugins/cpp
tools
/cpprefactoringchanges.h
View file @
3ebc3284
...
...
@@ -35,15 +35,15 @@
#include <cplusplus/LookupContext.h>
#include <cpptools/cppmodelmanagerinterface.h>
#include <cpp
editor/cppeditor
_global.h>
#include <cpp
tools/cpptools
_global.h>
#include <texteditor/refactoringchanges.h>
namespace
Cpp
Editor
{
namespace
Cpp
Tools
{
class
CppRefactoringChanges
;
class
CPP
EDITOR
_EXPORT
CppRefactoringFile
:
public
TextEditor
::
RefactoringFile
class
CPP
TOOLS
_EXPORT
CppRefactoringFile
:
public
TextEditor
::
RefactoringFile
{
public:
CppRefactoringFile
();
...
...
@@ -79,7 +79,7 @@ private:
mutable
CPlusPlus
::
Document
::
Ptr
m_cppDocument
;
};
class
CPP
EDITOR
_EXPORT
CppRefactoringChanges
:
public
TextEditor
::
RefactoringChanges
class
CPP
TOOLS
_EXPORT
CppRefactoringChanges
:
public
TextEditor
::
RefactoringChanges
{
public:
CppRefactoringChanges
(
const
CPlusPlus
::
Snapshot
&
snapshot
);
...
...
@@ -99,6 +99,6 @@ private:
CppTools
::
CppModelManagerInterface
::
WorkingCopy
m_workingCopy
;
};
}
// namespace Cpp
Editor
}
// namespace Cpp
Tools
#endif // CPPREFACTORINGCHANGES_H
src/plugins/cpptools/cpptools.pro
View file @
3ebc3284
...
...
@@ -25,7 +25,9 @@ HEADERS += completionsettingspage.h \
cppfilesettingspage
.
h
\
cppfindreferences
.
h
\
cppcodeformatter
.
h
\
symbolsfindfilter
.
h
symbolsfindfilter
.
h
\
insertionpointlocator
.
h
\
cpprefactoringchanges
.
h
SOURCES
+=
completionsettingspage
.
cpp
\
cppclassesfilter
.
cpp
\
...
...
@@ -42,7 +44,9 @@ SOURCES += completionsettingspage.cpp \
abstracteditorsupport
.
cpp
\
cppfindreferences
.
cpp
\
cppcodeformatter
.
cpp
\
symbolsfindfilter
.
cpp
symbolsfindfilter
.
cpp
\
insertionpointlocator
.
cpp
\
cpprefactoringchanges
.
cpp
FORMS
+=
completionsettingspage
.
ui
\
cppfilesettingspage
.
ui
...
...
src/
libs/cplusplus/InsertionPointL
ocator.cpp
→
src/
plugins/cpptools/insertionpointl
ocator.cpp
View file @
3ebc3284
...
...
@@ -27,6 +27,8 @@
**
**************************************************************************/
#include "CppToolsPlugin.h"
#include "cpprefactoringchanges.h"
#include "InsertionPointLocator.h"
#include <AST.h>
...
...
@@ -34,6 +36,7 @@
#include <TranslationUnit.h>
using
namespace
CPlusPlus
;
using
namespace
CppTools
;
namespace
{
...
...
@@ -150,7 +153,8 @@ protected:
if
(
needsSuffix
)
suffix
=
QLatin1Char
(
'\n'
);
_result
=
InsertionLocation
(
prefix
,
suffix
,
line
,
column
);
_result
=
InsertionLocation
(
_doc
->
fileName
(),
prefix
,
suffix
,
line
,
column
);
return
false
;
}
...
...
@@ -264,16 +268,19 @@ InsertionLocation::InsertionLocation()
,
m_column
(
0
)
{}
InsertionLocation
::
InsertionLocation
(
const
QString
&
prefix
,
const
QString
&
suffix
,
InsertionLocation
::
InsertionLocation
(
const
QString
&
fileName
,
const
QString
&
prefix
,
const
QString
&
suffix
,
unsigned
line
,
unsigned
column
)
:
m_prefix
(
prefix
)
:
m_fileName
(
fileName
)
,
m_prefix
(
prefix
)
,
m_suffix
(
suffix
)
,
m_line
(
line
)
,
m_column
(
column
)
{}
InsertionPointLocator
::
InsertionPointLocator
(
const
Snapshot
&
snapshot
)
:
m_
snapshot
(
snapshot
)
InsertionPointLocator
::
InsertionPointLocator
(
CppRefactoringChanges
*
refactoringChanges
)
:
m_
refactoringChanges
(
refactoringChanges
)
{
}
...
...
@@ -282,7 +289,7 @@ InsertionLocation InsertionPointLocator::methodDeclarationInClass(
const
Class
*
clazz
,
AccessSpec
xsSpec
)
const
{
const
Document
::
Ptr
doc
=
m_
snapshot
.
document
(
fileName
);
const
Document
::
Ptr
doc
=
m_
refactoringChanges
->
file
(
fileName
).
cppDocument
(
);
if
(
doc
)
{
FindInClass
find
(
doc
,
clazz
,
xsSpec
);
return
find
();
...
...
@@ -293,11 +300,30 @@ InsertionLocation InsertionPointLocator::methodDeclarationInClass(
/// Currently, we return the end of fileName.cpp
QList
<
InsertionLocation
>
InsertionPointLocator
::
methodDefinition
(
const
QString
&
/*fileName*/
)
const
Declaration
*
declaration
)
const
{
QList
<
InsertionLocation
>
result
;
if
(
!
declaration
)
return
result
;
Internal
::
CppToolsPlugin
*
cpptools
=
Internal
::
CppToolsPlugin
::
instance
();
const
QString
declFileName
=
QLatin1String
(
declaration
->
fileName
());
QString
target
=
cpptools
->
correspondingHeaderOrSource
(
declFileName
);
Document
::
Ptr
doc
=
m_refactoringChanges
->
file
(
target
).
cppDocument
();
if
(
doc
.
isNull
())
return
result
;
TranslationUnit
*
xUnit
=
doc
->
translationUnit
();
unsigned
tokenCount
=
xUnit
->
tokenCount
();
if
(
tokenCount
<
2
)
// no tokens available
return
result
;
unsigned
line
=
0
,
column
=
0
;
xUnit
->
getTokenEndPosition
(
xUnit
->
tokenCount
()
-
2
,
&
line
,
&
column
);
const
QLatin1String
prefix
(
"
\n\n
"
);
result
.
append
(
InsertionLocation
(
target
,
prefix
,
QString
(),
line
,
column
));
return
result
;
}
src/
libs/cplusplus/InsertionPointL
ocator.h
→
src/
plugins/cpptools/insertionpointl
ocator.h
View file @
3ebc3284
...
...
@@ -30,19 +30,27 @@
#ifndef INSERTIONPOINTLOCATOR_H
#define INSERTIONPOINTLOCATOR_H
#include "cpptools_global.h"
#include <ASTfwd.h>
#include <CPlusPlusForwardDeclarations.h>
#include <Symbols.h>
#include "CppDocument.h"
#include <cplusplus/CppDocument.h>
namespace
CppTools
{
namespace
CPlusPlus
{
class
CppRefactoringChanges
;
class
CP
LUSPLU
S_EXPORT
InsertionLocation
class
CP
PTOOL
S_EXPORT
InsertionLocation
{
public:
InsertionLocation
();
InsertionLocation
(
const
QString
&
prefix
,
const
QString
&
suffix
,
unsigned
line
,
unsigned
column
);
InsertionLocation
(
const
QString
&
fileName
,
const
QString
&
prefix
,
const
QString
&
suffix
,
unsigned
line
,
unsigned
column
);
QString
fileName
()
const
{
return
m_fileName
;
}
/// \returns The prefix to insert before any other text.
QString
prefix
()
const
...
...
@@ -61,16 +69,17 @@ public:
{
return
m_column
;
}
bool
isValid
()
const
{
return
m_line
>
0
&&
m_column
>
0
;
}
{
return
!
m_fileName
.
isEmpty
()
&&
m_line
>
0
&&
m_column
>
0
;
}
private:
QString
m_fileName
;
QString
m_prefix
;
QString
m_suffix
;
unsigned
m_line
;
unsigned
m_column
;
};
class
CP
LUSPLU
S_EXPORT
InsertionPointLocator
class
CP
PTOOL
S_EXPORT
InsertionPointLocator
{
public:
enum
AccessSpec
{
...
...
@@ -89,18 +98,18 @@ public:
};
public:
InsertionPointLocator
(
const
Snapshot
&
snapshot
);
InsertionPointLocator
(
CppRefactoringChanges
*
refactoringChanges
);
InsertionLocation
methodDeclarationInClass
(
const
QString
&
fileName
,
const
Class
*
clazz
,
const
C
PlusPlus
::
C
lass
*
clazz
,
AccessSpec
xsSpec
)
const
;
QList
<
InsertionLocation
>
methodDefinition
(
const
QString
&
fileName
)
const
;
QList
<
InsertionLocation
>
methodDefinition
(
CPlusPlus
::
Declaration
*
declaration
)
const
;
private:
Snapshot
m_snapshot
;
CppRefactoringChanges
*
m_refactoringChanges
;
};
}
// namespace C
PlusPlu
s
}
// namespace C
ppTool
s
#endif // INSERTIONPOINTLOCATOR_H
src/plugins/designer/qtcreatorintegration.cpp
View file @
3ebc3284
...
...
@@ -37,8 +37,9 @@
#include <widgethost.h>
#include <cpptools/cppmodelmanagerinterface.h>
#include <cpptools/cpprefactoringchanges.h>
#include <cpptools/cpptoolsconstants.h>
#include <cp
lusplus/InsertionPointL
ocator.h>
#include <cp
ptools/insertionpointl
ocator.h>
#include <cplusplus/Symbols.h>
#include <cplusplus/Overview.h>
#include <cplusplus/CoreTypes.h>
...
...
@@ -282,9 +283,10 @@ static void addDeclaration(const Snapshot &snapshot,
declaration
+=
functionName
;
declaration
+=
QLatin1String
(
";
\n
"
);
InsertionPointLocator
find
(
snapshot
);
const
InsertionLocation
loc
=
find
.
methodDeclarationInClass
(
fileName
,
cl
,
InsertionPointLocator
::
PrivateSlot
);
CppTools
::
CppRefactoringChanges
refactoring
(
snapshot
);
CppTools
::
InsertionPointLocator
find
(
&
refactoring
);
const
CppTools
::
InsertionLocation
loc
=
find
.
methodDeclarationInClass
(
fileName
,
cl
,
CppTools
::
InsertionPointLocator
::
PrivateSlot
);
//
//! \todo change this to use the Refactoring changes.
...
...
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