Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
ca5076e5
Commit
ca5076e5
authored
Aug 12, 2010
by
Christian Kamm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
QuickFix: Don't separate createChanges from perform.
This will allow a more efficient and direct implementation.
parent
235f4d1d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
31 deletions
+39
-31
src/plugins/cppeditor/cppdeclfromdef.cpp
src/plugins/cppeditor/cppdeclfromdef.cpp
+2
-1
src/plugins/cppeditor/cppquickfixes.cpp
src/plugins/cppeditor/cppquickfixes.cpp
+32
-16
src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp
src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp
+2
-1
src/plugins/qmljseditor/qmljsquickfixes.cpp
src/plugins/qmljseditor/qmljsquickfixes.cpp
+2
-1
src/plugins/texteditor/quickfix.cpp
src/plugins/texteditor/quickfix.cpp
+0
-6
src/plugins/texteditor/quickfix.h
src/plugins/texteditor/quickfix.h
+1
-6
No files found.
src/plugins/cppeditor/cppdeclfromdef.cpp
View file @
ca5076e5
...
...
@@ -82,7 +82,7 @@ public:
"CppEditor::DeclFromDef"
).
arg
(
type
));
}
void
createChanges
()
void
perform
()
{
CppRefactoringChanges
*
changes
=
refactoringChanges
();
...
...
@@ -101,6 +101,7 @@ public:
targetFile
.
indent
(
Utils
::
ChangeSet
::
Range
(
targetPosition2
,
targetPosition1
));
changes
->
setActiveEditor
(
m_targetFileName
,
targetPosition1
);
changes
->
apply
();
}
private:
...
...
src/plugins/cppeditor/cppquickfixes.cpp
View file @
ca5076e5
...
...
@@ -148,7 +148,7 @@ private:
return
QApplication
::
translate
(
"CppTools::QuickFix"
,
"Rewrite Using %1"
).
arg
(
replacement
);
}
virtual
void
createChanges
()
virtual
void
perform
()
{
ChangeSet
changes
;
if
(
negation
)
{
...
...
@@ -162,6 +162,7 @@ private:
}
changes
.
replace
(
range
(
binary
->
binary_op_token
),
replacement
);
refactoringChanges
()
->
changeFile
(
fileName
(),
changes
);
refactoringChanges
()
->
apply
();
}
};
};
...
...
@@ -243,7 +244,7 @@ private:
return
QApplication
::
translate
(
"CppTools::QuickFix"
,
"Rewrite Using %1"
).
arg
(
replacement
);
}
virtual
void
createChanges
()
virtual
void
perform
()
{
ChangeSet
changes
;
...
...
@@ -252,6 +253,7 @@ private:
changes
.
replace
(
range
(
binary
->
binary_op_token
),
replacement
);
refactoringChanges
()
->
changeFile
(
fileName
(),
changes
);
refactoringChanges
()
->
apply
();
}
private:
...
...
@@ -321,7 +323,7 @@ private:
pattern
=
mk
->
BinaryExpression
(
left
,
right
);
}
virtual
void
createChanges
()
virtual
void
perform
()
{
ChangeSet
changes
;
changes
.
replace
(
range
(
pattern
->
binary_op_token
),
QLatin1String
(
"||"
));
...
...
@@ -334,6 +336,7 @@ private:
refactoringChanges
()
->
changeFile
(
fileName
(),
changes
);
refactoringChanges
()
->
reindent
(
fileName
(),
range
(
pattern
));
refactoringChanges
()
->
apply
();
}
};
...
...
@@ -422,7 +425,7 @@ private:
"Split Declaration"
));
}
virtual
void
createChanges
()
virtual
void
perform
()
{
ChangeSet
changes
;
...
...
@@ -450,6 +453,7 @@ private:
refactoringChanges
()
->
changeFile
(
fileName
(),
changes
);
refactoringChanges
()
->
reindent
(
fileName
(),
range
(
declaration
));
refactoringChanges
()
->
apply
();
}
private:
...
...
@@ -505,7 +509,7 @@ private:
"Add Curly Braces"
));
}
virtual
void
createChanges
()
virtual
void
perform
()
{
ChangeSet
changes
;
...
...
@@ -517,6 +521,7 @@ private:
refactoringChanges
()
->
changeFile
(
fileName
(),
changes
);
refactoringChanges
()
->
reindent
(
fileName
(),
range
(
start
,
end
));
refactoringChanges
()
->
apply
();
}
private:
...
...
@@ -576,7 +581,7 @@ private:
pattern
=
mk
.
IfStatement
(
condition
);
}
virtual
void
createChanges
()
virtual
void
perform
()
{
ChangeSet
changes
;
...
...
@@ -588,6 +593,7 @@ private:
refactoringChanges
()
->
changeFile
(
fileName
(),
changes
);
refactoringChanges
()
->
reindent
(
fileName
(),
range
(
pattern
));
refactoringChanges
()
->
apply
();
}
ASTMatcher
matcher
;
...
...
@@ -658,7 +664,7 @@ private:
pattern
=
mk
.
WhileStatement
(
condition
);
}
virtual
void
createChanges
()
virtual
void
perform
()
{
ChangeSet
changes
;
...
...
@@ -673,6 +679,7 @@ private:
refactoringChanges
()
->
changeFile
(
fileName
(),
changes
);
refactoringChanges
()
->
reindent
(
fileName
(),
range
(
pattern
));
refactoringChanges
()
->
apply
();
}
ASTMatcher
matcher
;
...
...
@@ -767,7 +774,7 @@ private:
"Split if Statement"
));
}
virtual
void
createChanges
()
virtual
void
perform
()
{
const
Token
binaryToken
=
state
().
tokenAt
(
condition
->
binary_op_token
);
...
...
@@ -775,6 +782,7 @@ private:
splitAndCondition
();
else
splitOrCondition
();
refactoringChanges
()
->
apply
();
}
void
splitAndCondition
()
...
...
@@ -905,7 +913,7 @@ private:
"Enclose in QLatin1String(...)"
));
}
virtual
void
createChanges
()
virtual
void
perform
()
{
ChangeSet
changes
;
...
...
@@ -921,6 +929,7 @@ private:
changes
.
insert
(
endOf
(
literal
),
")"
);
refactoringChanges
()
->
changeFile
(
fileName
(),
changes
);
refactoringChanges
()
->
apply
();
}
private:
...
...
@@ -1026,7 +1035,7 @@ private:
setDescription
(
QApplication
::
translate
(
"CppTools::QuickFix"
,
"Mark as translateable"
));
}
virtual
void
createChanges
()
virtual
void
perform
()
{
ChangeSet
changes
;
...
...
@@ -1044,6 +1053,7 @@ private:
changes
.
insert
(
endOf
(
m_literal
),
QLatin1String
(
")"
));
refactoringChanges
()
->
changeFile
(
fileName
(),
changes
);
refactoringChanges
()
->
apply
();
}
private:
...
...
@@ -1107,7 +1117,7 @@ private:
"Convert to Objective-C String Literal"
));
}
virtual
void
createChanges
()
virtual
void
perform
()
{
ChangeSet
changes
;
...
...
@@ -1119,6 +1129,7 @@ private:
}
refactoringChanges
()
->
changeFile
(
fileName
(),
changes
);
refactoringChanges
()
->
apply
();
}
private:
...
...
@@ -1255,11 +1266,12 @@ private:
,
replacement
(
replacement
)
{}
virtual
void
createChanges
()
virtual
void
perform
()
{
ChangeSet
changes
;
changes
.
replace
(
start
,
end
,
replacement
);
refactoringChanges
()
->
changeFile
(
fileName
(),
changes
);
refactoringChanges
()
->
apply
();
}
protected:
...
...
@@ -1409,7 +1421,7 @@ private:
}
virtual
void
createChanges
()
virtual
void
perform
()
{
ChangeSet
changes
;
int
start
=
endOf
(
compoundStatement
->
lbrace_token
);
...
...
@@ -1418,6 +1430,7 @@ private:
+
QLatin1String
(
":
\n
break;"
));
refactoringChanges
()
->
changeFile
(
fileName
(),
changes
);
refactoringChanges
()
->
reindent
(
fileName
(),
range
(
compoundStatement
));
refactoringChanges
()
->
apply
();
}
CompoundStatementAST
*
compoundStatement
;
...
...
@@ -1485,7 +1498,7 @@ private:
"#include header file"
));
}
virtual
void
createChanges
()
virtual
void
perform
()
{
Q_ASSERT
(
fwdClass
!=
0
);
...
...
@@ -1544,6 +1557,7 @@ private:
changes
.
insert
(
pos
,
QString
(
"#include <%1>
\n
"
).
arg
(
QFileInfo
(
best
).
fileName
()));
refactoringChanges
()
->
changeFile
(
fileName
(),
changes
);
}
refactoringChanges
()
->
apply
();
}
private:
...
...
@@ -1599,7 +1613,7 @@ private:
setDescription
(
QApplication
::
translate
(
"CppTools::QuickFix"
,
"Add local declaration"
));
}
virtual
void
createChanges
()
virtual
void
perform
()
{
TypeOfExpression
typeOfExpression
;
typeOfExpression
.
init
(
state
().
document
(),
state
().
snapshot
(),
state
().
context
().
bindings
());
...
...
@@ -1631,6 +1645,7 @@ private:
refactoringChanges
()
->
changeFile
(
fileName
(),
changes
);
}
}
refactoringChanges
()
->
apply
();
}
private:
...
...
@@ -1687,7 +1702,7 @@ private:
"Convert to Camel Case ..."
));
}
virtual
void
createChanges
()
virtual
void
perform
()
{
for
(
int
i
=
1
;
i
<
m_name
.
length
();
++
i
)
{
QCharRef
c
=
m_name
[
i
];
...
...
@@ -1700,6 +1715,7 @@ private:
}
}
static_cast
<
CppEditor
::
Internal
::
CPPEditor
*>
(
state
().
editor
())
->
renameUsagesNow
(
m_name
);
refactoringChanges
()
->
apply
();
}
static
bool
isConvertibleUnderscore
(
const
QString
&
name
,
int
pos
)
...
...
src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp
View file @
ca5076e5
...
...
@@ -92,7 +92,7 @@ public:
"Move Component into '%1.qml'"
).
arg
(
m_componentName
));
}
virtual
void
createChanges
()
virtual
void
perform
()
{
const
QString
newFileName
=
QFileInfo
(
fileName
()).
path
()
+
QDir
::
separator
()
+
m_componentName
+
QLatin1String
(
".qml"
);
...
...
@@ -117,6 +117,7 @@ public:
refactoringChanges
()
->
createFile
(
newFileName
,
txt
);
refactoringChanges
()
->
reindent
(
newFileName
,
range
(
0
,
txt
.
length
()
-
1
));
refactoringChanges
()
->
apply
();
}
};
...
...
src/plugins/qmljseditor/qmljsquickfixes.cpp
View file @
ca5076e5
...
...
@@ -88,7 +88,7 @@ private:
"Split initializer"
));
}
virtual
void
createChanges
()
virtual
void
perform
()
{
Q_ASSERT
(
_objectInitializer
!=
0
);
...
...
@@ -112,6 +112,7 @@ private:
file
.
indent
(
range
(
startPosition
(
_objectInitializer
->
lbraceToken
),
startPosition
(
_objectInitializer
->
rbraceToken
)));
refactoringChanges
()
->
apply
();
}
};
};
...
...
src/plugins/texteditor/quickfix.cpp
View file @
ca5076e5
...
...
@@ -123,12 +123,6 @@ void QuickFixOperation::setDescription(const QString &description)
_description
=
description
;
}
void
QuickFixOperation
::
perform
()
{
createChanges
();
refactoringChanges
()
->
apply
();
}
QuickFixFactory
::
QuickFixFactory
(
QObject
*
parent
)
:
QObject
(
parent
)
{
...
...
src/plugins/texteditor/quickfix.h
View file @
ca5076e5
...
...
@@ -136,15 +136,10 @@ public:
/*!
Perform this quick-fix's operation.
This implementation will call perform and then RefactoringChanges::apply() .
*/
virtual
void
perform
();
/*!
Subclasses should implement this method to do the actual changes by using the
RefactoringChanges.
*/
virtual
void
createChanges
()
=
0
;
virtual
void
perform
()
=
0
;
protected:
virtual
TextEditor
::
RefactoringChanges
*
refactoringChanges
()
const
=
0
;
...
...
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