Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
d980e37e
Commit
d980e37e
authored
Jul 26, 2010
by
Erik Verbruggen
Browse files
Reworked the QuickFix infrastructure.
parent
5bf0ba0b
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
src/plugins/cppeditor/cppdeclfromdef.cpp
View file @
d980e37e
...
...
@@ -45,6 +45,7 @@
#include <QtCore/QCoreApplication>
using
namespace
CPlusPlus
;
using
namespace
CppEditor
;
using
namespace
CppEditor
::
Internal
;
using
namespace
CppTools
;
...
...
@@ -146,22 +147,54 @@ QString prettyMinimalType(const FullySpecifiedType &ty,
return
oo
(
ty
);
}
}
// anonymous namespace
class
Operation
:
public
CppQuickFixOperation
{
public:
Operation
(
const
CppQuickFixState
&
state
,
int
priority
,
const
QString
&
targetFileName
,
const
QString
&
targetSymbolName
,
const
QString
&
decl
)
:
CppQuickFixOperation
(
state
,
priority
)
,
m_targetFileName
(
targetFileName
)
,
m_targetSymbolName
(
targetSymbolName
)
,
m_decl
(
decl
)
{
setDescription
(
QCoreApplication
::
tr
(
"Create Declaration from Definition"
,
"CppEditor::DeclFromDef"
));
}
DeclFromDef
::
DeclFromDef
(
TextEditor
::
BaseTextEditor
*
editor
)
:
CppQuickFixOperation
(
editor
)
{}
void
createChanges
(
)
{
CppRefactoringChanges
*
changes
=
refactoringChanges
();
QString
DeclFromDef
::
description
()
const
{
return
QCoreApplication
::
tr
(
"Create Declaration from Definition"
,
"DeclFromDef"
);
}
Document
::
Ptr
targetDoc
=
changes
->
document
(
m_targetFileName
);
InsertionPointFinder
findInsertionPoint
(
targetDoc
,
m_targetSymbolName
);
int
line
=
0
,
column
=
0
;
findInsertionPoint
(
&
line
,
&
column
);
int
targetPosition1
=
changes
->
positionInFile
(
m_targetFileName
,
line
,
column
);
int
targetPosition2
=
changes
->
positionInFile
(
m_targetFileName
,
line
+
1
,
0
)
-
1
;
Utils
::
ChangeSet
target
;
target
.
insert
(
targetPosition1
,
m_decl
);
changes
->
changeFile
(
m_targetFileName
,
target
);
changes
->
reindent
(
m_targetFileName
,
Utils
::
ChangeSet
::
Range
(
targetPosition1
,
targetPosition2
));
changes
->
openEditor
(
m_targetFileName
,
line
,
column
);
}
private:
QString
m_targetFileName
;
QString
m_targetSymbolName
;
QString
m_decl
;
};
}
// anonymous namespace
int
DeclFromDef
::
match
(
const
QList
<
CPlusPlus
::
AST
*>
&
p
at
h
)
QList
<
CppQuickFixOperation
::
Ptr
>
DeclFromDef
::
match
(
const
CppQuickFixState
&
st
at
e
)
{
m_targetFileName
.
clear
();
m_targetSymbolName
.
clear
();
m_decl
.
clear
();
const
QList
<
AST
*>
&
path
=
state
.
path
();
FunctionDefinitionAST
*
funDef
=
0
;
int
idx
=
0
;
...
...
@@ -171,62 +204,40 @@ int DeclFromDef::match(const QList<CPlusPlus::AST *> &path)
if
(
!
funDef
)
funDef
=
candidate
;
}
else
if
(
node
->
asClassSpecifier
())
{
return
-
1
;
return
noResult
()
;
}
}
if
(
!
funDef
||
!
funDef
->
symbol
)
return
-
1
;
return
noResult
()
;
Function
*
method
=
funDef
->
symbol
;
LookupContext
context
(
document
(),
snapshot
());
if
(
ClassOrNamespace
*
targetBinding
=
context
.
lookupParent
(
method
))
{
if
(
ClassOrNamespace
*
targetBinding
=
state
.
context
()
.
lookupParent
(
method
))
{
foreach
(
Symbol
*
s
,
targetBinding
->
symbols
())
{
if
(
Class
*
clazz
=
s
->
asClass
())
{
m_targetFileName
=
QLatin1String
(
clazz
->
fileName
());
m_targetSymbolName
=
QLatin1String
(
clazz
->
identifier
()
->
chars
())
;
m_decl
=
generateDeclaration
(
method
,
targetBinding
);
return
idx
;
return
singleResult
(
new
Operation
(
state
,
idx
,
QLatin1String
(
clazz
->
fileName
())
,
QLatin1String
(
clazz
->
identifier
()
->
chars
()),
generateDeclaration
(
state
,
method
,
targetBinding
)))
;
}
// ### TODO: support insertion into namespaces
}
}
return
-
1
;
}
void
DeclFromDef
::
createChanges
()
{
CppRefactoringChanges
*
changes
=
refactoringChanges
();
Document
::
Ptr
targetDoc
=
changes
->
document
(
m_targetFileName
);
InsertionPointFinder
findInsertionPoint
(
targetDoc
,
m_targetSymbolName
);
int
line
=
0
,
column
=
0
;
findInsertionPoint
(
&
line
,
&
column
);
int
targetPosition1
=
changes
->
positionInFile
(
m_targetFileName
,
line
,
column
);
int
targetPosition2
=
changes
->
positionInFile
(
m_targetFileName
,
line
+
1
,
0
)
-
1
;
Utils
::
ChangeSet
target
;
target
.
insert
(
targetPosition1
,
m_decl
);
changes
->
changeFile
(
m_targetFileName
,
target
);
changes
->
reindent
(
m_targetFileName
,
Utils
::
ChangeSet
::
Range
(
targetPosition1
,
targetPosition2
));
changes
->
openEditor
(
m_targetFileName
,
line
,
column
);
return
noResult
();
}
QString
DeclFromDef
::
generateDeclaration
(
Function
*
method
,
ClassOrNamespace
*
targetBinding
)
QString
DeclFromDef
::
generateDeclaration
(
const
CppQuickFixState
&
state
,
Function
*
method
,
ClassOrNamespace
*
targetBinding
)
{
LookupContext
context
(
document
(),
snapshot
());
Overview
oo
;
QString
decl
;
decl
.
append
(
prettyMinimalType
(
method
->
returnType
(),
context
,
state
.
context
()
,
method
->
scope
(),
targetBinding
));
...
...
@@ -238,7 +249,7 @@ QString DeclFromDef::generateDeclaration(Function *method, ClassOrNamespace *tar
decl
.
append
(
QLatin1String
(
", "
));
Argument
*
arg
=
method
->
argumentAt
(
argIdx
)
->
asArgument
();
decl
.
append
(
prettyMinimalType
(
arg
->
type
(),
context
,
state
.
context
()
,
method
->
members
(),
targetBinding
));
decl
.
append
(
QLatin1Char
(
' '
));
...
...
src/plugins/cppeditor/cppdeclfromdef.h
View file @
d980e37e
...
...
@@ -41,23 +41,15 @@ class ClassOrNamespace;
namespace
CppEditor
{
namespace
Internal
{
class
DeclFromDef
:
public
CppQuickFix
Operation
class
DeclFromDef
:
public
CppQuickFix
Factory
{
public:
DeclFromDef
(
TextEditor
::
BaseTextEditor
*
editor
);
virtual
int
match
(
const
QList
<
CPlusPlus
::
AST
*>
&
path
);
virtual
QString
description
()
const
;
virtual
void
createChanges
();
virtual
QList
<
CppQuickFixOperation
::
Ptr
>
match
(
const
CppQuickFixState
&
state
);
protected:
virtual
QString
generateDeclaration
(
CPlusPlus
::
Function
*
method
,
CPlusPlus
::
ClassOrNamespace
*
targetBinding
);
private:
QString
m_targetFileName
;
QString
m_targetSymbolName
;
QString
m_decl
;
static
QString
generateDeclaration
(
const
CppQuickFixState
&
state
,
CPlusPlus
::
Function
*
method
,
CPlusPlus
::
ClassOrNamespace
*
targetBinding
);
};
...
...
src/plugins/cppeditor/cppeditor.pro
View file @
d980e37e
...
...
@@ -30,6 +30,7 @@ SOURCES += cppplugin.cpp \
cppfilewizard
.
cpp
\
cppclasswizard
.
cpp
\
cppquickfix
.
cpp
\
cppquickfixes
.
cpp
\
cpprefactoringchanges
.
cpp
\
cppchecksymbols
.
cpp
\
cppsemanticinfo
.
cpp
\
...
...
src/plugins/cppeditor/cppplugin.cpp
View file @
d980e37e
...
...
@@ -63,6 +63,7 @@
#include <QtGui/QMenu>
using
namespace
CppEditor
;
using
namespace
CppEditor
::
Internal
;
enum
{
QUICKFIX_INTERVAL
=
20
};
...
...
@@ -208,8 +209,7 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
m_quickFixCollector
=
new
CppQuickFixCollector
;
addAutoReleasedObject
(
m_quickFixCollector
);
addAutoReleasedObject
(
new
CppQuickFixFactory
);
CppQuickFixCollector
::
registerQuickFixes
(
this
);
CppFileWizard
::
BaseFileWizardParameters
wizardParameters
(
Core
::
IWizard
::
FileWizard
);
...
...
src/plugins/cppeditor/cppquickfix.cpp
View file @
d980e37e
This diff is collapsed.
Click to expand it.
src/plugins/cppeditor/cppquickfix.h
View file @
d980e37e
...
...
@@ -30,100 +30,142 @@
#ifndef CPPQUICKFIX_H
#define CPPQUICKFIX_H
#include
<texteditor/icompletioncollector
.h
>
#include
<texteditor/quickfix
.h
>
#include
"cpprefactoringchanges
.h
"
#include
"cppsemanticinfo
.h
"
#include <cplusplus/CppDocument.h>
#include <ASTfwd.h>
#include <cplusplus/CppDocument.h>
#include <texteditor/icompletioncollector.h>
#include <texteditor/quickfix.h>
#include <utils/changeset.h>
#include <QtCore/QSharedPointer>
#include <QtGui/QTextCursor>
#include "cpprefactoringchanges.h"
namespace
CppTools
{
class
CppModelManagerInterface
;
}
// end of namespace CppTools
namespace
ExtensionSystem
{
class
IPlugin
;
}
namespace
CppEditor
{
namespace
Internal
{
class
CppQuickFixCollector
;
}
// end of namespace Internal
class
CppQuickFix
Operation
:
public
TextEditor
::
QuickFix
Operation
class
CPPEDITOR_EXPORT
CppQuickFix
State
:
public
TextEditor
::
QuickFix
State
{
Q_DISABLE_COPY
(
CppQuickFix
Operation
)
friend
class
Internal
::
CppQuickFix
Collector
;
public:
CppQuickFixOperation
(
TextEditor
::
BaseTextEditor
*
editor
);
virtual
~
CppQuickFixOperation
();
virtual
int
match
(
const
QList
<
CPlusPlus
::
AST
*>
&
path
)
=
0
;
CppQuickFixState
(
TextEditor
::
BaseTextEditor
*
editor
);
typedef
Utils
::
ChangeSet
::
Range
Range
;
const
QList
<
CPlusPlus
::
AST
*>
&
path
()
const
;
CPlusPlus
::
Snapshot
snapshot
()
const
;
CPlusPlus
::
Document
::
Ptr
document
()
const
;
const
CPlusPlus
::
Snapshot
&
snapshot
()
const
;
const
CPlusPlus
::
LookupContext
&
context
()
const
;
CppEditor
::
Internal
::
SemanticInfo
semanticInfo
()
const
;
CPlusPlus
::
LookupContext
context
()
const
;
virtual
int
match
(
TextEditor
::
QuickFixState
*
state
);
using
TextEditor
::
QuickFixState
::
range
;
using
TextEditor
::
QuickFixState
::
textOf
;
using
TextEditor
::
QuickFixState
::
charAt
;
protected:
using
TextEditor
::
QuickFixOperation
::
range
;
using
TextEditor
::
QuickFixOperation
::
textOf
;
using
TextEditor
::
QuickFixOperation
::
charAt
;
Utils
::
ChangeSet
::
Range
range
(
unsigned
tokenIndex
)
const
;
Utils
::
ChangeSet
::
Range
range
(
CPlusPlus
::
AST
*
ast
)
const
;
CPlusPlus
::
Scope
*
scopeAt
(
unsigned
index
)
const
;
QString
fileName
()
const
;
bool
isCursorOn
(
unsigned
tokenIndex
)
const
;
bool
isCursorOn
(
const
CPlusPlus
::
AST
*
ast
)
const
;
virtual
void
apply
()
;
virtual
CppRefactoringChanges
*
refactoringChanges
(
)
const
;
Range
range
(
unsigned
tokenIndex
)
const
;
Range
range
(
CPlusPlus
::
AST
*
ast
)
const
;
const
CPlusPlus
::
Token
&
tokenAt
(
unsigned
index
)
const
;
CPlusPlus
::
Scope
*
scopeAt
(
unsigned
index
)
const
;
int
startOf
(
unsigned
index
)
const
;
int
startOf
(
const
CPlusPlus
::
AST
*
ast
)
const
;
int
endOf
(
unsigned
index
)
const
;
int
endOf
(
const
CPlusPlus
::
AST
*
ast
)
const
;
void
startAndEndOf
(
unsigned
index
,
int
*
start
,
int
*
end
)
const
;
bool
isCursorOn
(
unsigned
tokenIndex
)
const
;
bool
isCursorOn
(
const
CPlusPlus
::
AST
*
ast
)
const
;
QString
textOf
(
const
CPlusPlus
::
AST
*
ast
)
const
;
private:
CppRefactoringChanges
*
_refactoringChanges
;
CPlusPlus
::
Document
::
Ptr
_document
;
CPlusPlus
::
AST
*
_topLevelNode
;
QList
<
CPlusPlus
::
AST
*>
_path
;
CPlusPlus
::
Snapshot
_snapshot
;
CppEditor
::
Internal
::
SemanticInfo
_semanticInfo
;
CPlusPlus
::
LookupContext
_context
;
};
class
CppQuickFix
Collector
:
public
TextEditor
::
QuickFix
Collector
class
CPPEDITOR_EXPORT
CppQuickFix
Operation
:
public
TextEditor
::
QuickFix
Operation
{
Q_
OBJECT
Q_
DISABLE_COPY
(
CppQuickFixOperation
)
public:
CppQuickFix
Collector
(
);
virtual
~
CppQuickFix
Collector
();
CppQuickFix
Operation
(
const
CppQuickFixState
&
state
,
int
priority
=
-
1
);
virtual
~
CppQuickFix
Operation
();
virtual
bool
supportsEditor
(
TextEditor
::
ITextEditable
*
editor
);
virtual
TextEditor
::
QuickFixState
*
initializeCompletion
(
TextEditor
::
ITextEditable
*
editable
);
protected:
QString
fileName
()
const
;
CppRefactoringChanges
*
refactoringChanges
()
const
;
const
CppQuickFixState
&
state
()
const
;
protected:
// Utility functions forwarding to CppQuickFixState
typedef
Utils
::
ChangeSet
::
Range
Range
;
bool
isCursorOn
(
unsigned
tokenIndex
)
const
{
return
state
().
isCursorOn
(
tokenIndex
);
}
bool
isCursorOn
(
const
CPlusPlus
::
AST
*
ast
)
const
{
return
state
().
isCursorOn
(
ast
);
}
Range
range
(
int
start
,
int
end
)
const
{
return
CppQuickFixState
::
range
(
start
,
end
);
}
Range
range
(
unsigned
tokenIndex
)
const
{
return
state
().
range
(
tokenIndex
);
}
Range
range
(
CPlusPlus
::
AST
*
ast
)
const
{
return
state
().
range
(
ast
);
}
int
startOf
(
unsigned
index
)
const
{
return
state
().
startOf
(
index
);
}
int
startOf
(
const
CPlusPlus
::
AST
*
ast
)
const
{
return
state
().
startOf
(
ast
);
}
int
endOf
(
unsigned
index
)
const
{
return
state
().
endOf
(
index
);
}
int
endOf
(
const
CPlusPlus
::
AST
*
ast
)
const
{
return
state
().
endOf
(
ast
);
}
private:
CppQuickFixState
_state
;
QScopedPointer
<
CppRefactoringChanges
>
_refactoringChanges
;
};
class
CppQuickFixFactory
:
public
TextEditor
::
I
QuickFixFactory
class
CPPEDITOR_EXPORT
CppQuickFixFactory
:
public
TextEditor
::
QuickFixFactory
{
Q_OBJECT
public:
CppQuickFixFactory
(
QObject
*
parent
=
0
);
CppQuickFixFactory
();
virtual
~
CppQuickFixFactory
();
/*
* Returns true if this IQuickFixFactory can be used with the given editor.
*/
virtual
QList
<
TextEditor
::
QuickFixOperation
::
Ptr
>
quickFixOperations
(
TextEditor
::
BaseTextEditor
*
editor
);
virtual
QList
<
TextEditor
::
QuickFixOperation
::
Ptr
>
matchingOperations
(
TextEditor
::
QuickFixState
*
state
);
virtual
QList
<
CppQuickFixOperation
::
Ptr
>
match
(
const
CppQuickFixState
&
state
)
=
0
;
protected:
static
QList
<
CppQuickFixOperation
::
Ptr
>
singleResult
(
CppQuickFixOperation
*
operation
);
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
;
static
void
registerQuickFixes
(
ExtensionSystem
::
IPlugin
*
plugIn
);
};
}
// end of namespace Internal
...
...
src/plugins/cppeditor/cppquickfixes.cpp
0 → 100644
View file @
d980e37e
This diff is collapsed.
Click to expand it.
src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp
View file @
d980e37e
...
...
@@ -40,11 +40,10 @@
#include <QtCore/QFileInfo>
using
namespace
QmlJS
::
AST
;
using
namespace
QmlJSEditor
;
using
namespace
QmlJSEditor
::
Internal
;
ComponentFromObjectDef
::
ComponentFromObjectDef
(
TextEditor
::
BaseTextEditor
*
editor
)
:
QmlJSQuickFixOperation
(
editor
),
_objDef
(
0
)
{}
namespace
{
static
QString
getId
(
UiObjectDefinition
*
def
)
{
...
...
@@ -74,60 +73,71 @@ static QString getId(UiObjectDefinition *def)
return
QString
();
}
QString
ComponentFromObjectDef
::
description
()
const
class
Operation
:
public
QmlJSQuickFixOperation
{
return
QCoreApplication
::
translate
(
"QmlJSEditor::ComponentFromObjectDef"
,
"Extract Component"
);
}
UiObjectDefinition
*
_objDef
;
public:
Operation
(
const
QmlJSQuickFixState
&
state
,
UiObjectDefinition
*
objDef
)
:
QmlJSQuickFixOperation
(
state
,
0
)
,
_objDef
(
objDef
)
{
setDescription
(
QCoreApplication
::
translate
(
"QmlJSEditor::ComponentFromObjectDef"
,
"Extract Component"
));
}
void
ComponentFromObjectDef
::
createChanges
()
{
Q_ASSERT
(
_objDef
!=
0
);
virtual
void
createChanges
()
{
Q_ASSERT
(
_objDef
!=
0
);
QString
componentName
=
getId
(
_objDef
);
componentName
[
0
]
=
componentName
.
at
(
0
).
toUpper
();
QString
componentName
=
getId
(
_objDef
);
componentName
[
0
]
=
componentName
.
at
(
0
).
toUpper
();
const
QString
path
=
editor
()
->
file
()
->
fileName
();
const
QString
newFileName
=
QFileInfo
(
path
).
path
()
+
QDir
::
separator
()
+
componentName
+
QLatin1String
(
".qml"
);
const
QString
path
=
fileName
();
const
QString
newFileName
=
QFileInfo
(
path
).
path
()
+
QDir
::
separator
()
+
componentName
+
QLatin1String
(
".qml"
);
QString
imports
;
UiProgram
*
prog
=
semanticInfo
().
document
->
qmlProgram
();
if
(
prog
&&
prog
->
imports
)
{
const
int
start
=
startPosition
(
prog
->
imports
->
firstSourceLocation
());
const
int
end
=
startPosition
(
prog
->
members
->
member
->
firstSourceLocation
());
imports
=
textOf
(
start
,
end
);
}
QString
imports
;
UiProgram
*
prog
=
state
().
semanticInfo
().
document
->
qmlProgram
();
if
(
prog
&&
prog
->
imports
)
{
const
int
start
=
startPosition
(
prog
->
imports
->
firstSourceLocation
());
const
int
end
=
startPosition
(
prog
->
members
->
member
->
firstSourceLocation
());
imports
=
state
().
textOf
(
start
,
end
);
}
const
int
start
=
startPosition
(
_objDef
->
firstSourceLocation
());
const
int
end
=
startPosition
(
_objDef
->
lastSourceLocation
());
const
QString
txt
=
imports
+
textOf
(
start
,
end
)
+
QLatin1String
(
"}
\n
"
);
const
int
start
=
startPosition
(
_objDef
->
firstSourceLocation
());
const
int
end
=
startPosition
(
_objDef
->
lastSourceLocation
());
const
QString
txt
=
imports
+
state
().
textOf
(
start
,
end
)
+
QLatin1String
(
"}
\n
"
);
Utils
::
ChangeSet
changes
;
changes
.
replace
(
start
,
end
,
componentName
+
QLatin1String
(
" {
\n
"
));
qmljsR
efactoringChanges
()
->
changeFile
(
fileName
(),
changes
);
qmljsR
efactoringChanges
()
->
reindent
(
fileName
(),
range
(
start
,
end
+
1
));
Utils
::
ChangeSet
changes
;
changes
.
replace
(
start
,
end
,
componentName
+
QLatin1String
(
" {
\n
"
));
r
efactoringChanges
()
->
changeFile
(
fileName
(),
changes
);
r
efactoringChanges
()
->
reindent
(
fileName
(),
range
(
start
,
end
+
1
));
qmljsRefactoringChanges
()
->
createFile
(
newFileName
,
txt
);
qmljsRefactoringChanges
()
->
reindent
(
newFileName
,
range
(
0
,
txt
.
length
()
-
1
));
}
refactoringChanges
()
->
createFile
(
newFileName
,
txt
);
refactoringChanges
()
->
reindent
(
newFileName
,
range
(
0
,
txt
.
length
()
-
1
));
}
};
}
// end of anonymous namespace
int
ComponentFromObjectDef
::
check
(
)
QList
<
QmlJSQuickFixOperation
::
Ptr
>
ComponentFromObjectDef
::
match
(
const
QmlJSQuickFixState
&
state
)
{
_objDef
=
0
;
const
int
pos
=
textCursor
().
position
();
QList
<
QmlJSQuickFixOperation
::
Ptr
>
result
;
const
int
pos
=
state
.
textCursor
().
position
();
QList
<
Node
*>
path
=
semanticInfo
().
astPath
(
pos
);
QList
<
Node
*>
path
=
state
.
semanticInfo
().
astPath
(
pos
);
for
(
int
i
=
path
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
Node
*
node
=
path
.
at
(
i
);
if
(
UiObjectDefinition
*
objDef
=
cast
<
UiObjectDefinition
*>
(
node
))
{
if
(
i
>
0
&&
!
cast
<
UiProgram
*>
(
path
.
at
(
i
-
1
)))
{
// node is not the root node
if
(
!
getId
(
objDef
).
isEmpty
())
{
_objDef
=
objDef
;
return
0
;
result
.
append
(
QmlJSQuickFixOperation
::
Ptr
(
new
Operation
(
state
,
objDef
)))
;
return
result
;
}
}
}
}
return
-
1
;
return
result
;
}
src/plugins/qmljseditor/qmljscomponentfromobjectdef.h
View file @
d980e37e
...
...
@@ -35,17 +35,10 @@
namespace
QmlJSEditor
{
namespace
Internal
{
class
ComponentFromObjectDef
:
public
QmlJSQuickFix
Operation
class
ComponentFromObjectDef
:
public
QmlJSQuickFix
Factory
{
public:
ComponentFromObjectDef
(
TextEditor
::
BaseTextEditor
*
editor
);
virtual
QString
description
()
const
;
virtual
void
createChanges
();
virtual
int
check
();
private:
QmlJS
::
AST
::
UiObjectDefinition
*
_objDef
;
virtual
QList
<
QmlJSQuickFixOperation
::
Ptr
>
match
(
const
QmlJSQuickFixState
&
state
);
};
}
// namespace Internal
...
...
src/plugins/qmljseditor/qmljseditorplugin.cpp
View file @
d980e37e
...
...
@@ -179,6 +179,7 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e
m_quickFixCollector
=
new
QmlJSQuickFixCollector
;
addAutoReleasedObject
(
m_quickFixCollector
);
QmlJSQuickFixCollector
::
registerQuickFixes
(
this
);
addAutoReleasedObject
(
new
QmlJSOutlineWidgetFactory
);
...
...
src/plugins/qmljseditor/qmljsquickfix.cpp
View file @
d980e37e
...
...
@@ -33,6 +33,7 @@
#include "qmljsrefactoringchanges.h"
#include "qmljs/parser/qmljsast_p.h"
#include <extensionsystem/iplugin.h>
#include <extensionsystem/pluginmanager.h>
#include <qmljs/qmljsmodelmanagerinterface.h>
...
...
@@ -40,146 +41,157 @@
#include <QtGui/QApplication>
#include <QtCore/QDebug>
using
namespace
QmlJS
;
using
namespace
QmlJS
::
AST
;
using
namespace
QmlJSEditor
;
using
namespace
QmlJSEditor
::
Internal
;
using
namespace
TextEditor
;
using
TextEditor
::
RefactoringChanges
;
class
QmlJSQuickFixState
:
public
TextEditor
::
QuickFixState
{
public:
SemanticInfo
semanticInfo
;
};