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
f5dae8bc
Commit
f5dae8bc
authored
Jun 07, 2010
by
Roberto Raggi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored the quickfix engine.
parent
c3caf282
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
80 additions
and
10 deletions
+80
-10
src/plugins/cppeditor/cppquickfix.cpp
src/plugins/cppeditor/cppquickfix.cpp
+5
-0
src/plugins/cppeditor/cppquickfix.h
src/plugins/cppeditor/cppquickfix.h
+1
-0
src/plugins/cpptools/cppmodelmanager.h
src/plugins/cpptools/cppmodelmanager.h
+1
-1
src/plugins/cpptools/cppmodelmanagerinterface.h
src/plugins/cpptools/cppmodelmanagerinterface.h
+6
-0
src/plugins/qmljseditor/qmljseditorplugin.cpp
src/plugins/qmljseditor/qmljseditorplugin.cpp
+2
-1
src/plugins/qmljseditor/qmljsquickfix.cpp
src/plugins/qmljseditor/qmljsquickfix.cpp
+49
-4
src/plugins/qmljseditor/qmljsquickfix.h
src/plugins/qmljseditor/qmljsquickfix.h
+16
-0
src/plugins/texteditor/quickfix.cpp
src/plugins/texteditor/quickfix.cpp
+0
-3
src/plugins/texteditor/quickfix.h
src/plugins/texteditor/quickfix.h
+0
-1
No files found.
src/plugins/cppeditor/cppquickfix.cpp
View file @
f5dae8bc
...
@@ -1036,6 +1036,11 @@ CppQuickFixCollector::~CppQuickFixCollector()
...
@@ -1036,6 +1036,11 @@ CppQuickFixCollector::~CppQuickFixCollector()
{
{
}
}
bool
CppQuickFixCollector
::
supportsEditor
(
TextEditor
::
ITextEditable
*
editor
)
{
return
CppTools
::
CppModelManagerInterface
::
instance
()
->
isCppEditor
(
editor
);
}
TextEditor
::
QuickFixState
*
CppQuickFixCollector
::
initializeCompletion
(
TextEditor
::
ITextEditable
*
editable
)
TextEditor
::
QuickFixState
*
CppQuickFixCollector
::
initializeCompletion
(
TextEditor
::
ITextEditable
*
editable
)
{
{
if
(
CPPEditor
*
editor
=
qobject_cast
<
CPPEditor
*>
(
editable
->
widget
()))
{
if
(
CPPEditor
*
editor
=
qobject_cast
<
CPPEditor
*>
(
editable
->
widget
()))
{
...
...
src/plugins/cppeditor/cppquickfix.h
View file @
f5dae8bc
...
@@ -116,6 +116,7 @@ public:
...
@@ -116,6 +116,7 @@ public:
CppQuickFixCollector
();
CppQuickFixCollector
();
virtual
~
CppQuickFixCollector
();
virtual
~
CppQuickFixCollector
();
virtual
bool
supportsEditor
(
TextEditor
::
ITextEditable
*
editor
);
virtual
TextEditor
::
QuickFixState
*
initializeCompletion
(
TextEditor
::
ITextEditable
*
editable
);
virtual
TextEditor
::
QuickFixState
*
initializeCompletion
(
TextEditor
::
ITextEditable
*
editable
);
virtual
QList
<
TextEditor
::
QuickFixOperation
::
Ptr
>
quickFixOperations
(
TextEditor
::
BaseTextEditor
*
editor
)
const
;
virtual
QList
<
TextEditor
::
QuickFixOperation
::
Ptr
>
quickFixOperations
(
TextEditor
::
BaseTextEditor
*
editor
)
const
;
};
};
...
...
src/plugins/cpptools/cppmodelmanager.h
View file @
f5dae8bc
...
@@ -103,7 +103,7 @@ public:
...
@@ -103,7 +103,7 @@ public:
inline
Core
::
ICore
*
core
()
const
{
return
m_core
;
}
inline
Core
::
ICore
*
core
()
const
{
return
m_core
;
}
bool
isCppEditor
(
Core
::
IEditor
*
editor
)
const
;
// ### private
virtual
bool
isCppEditor
(
Core
::
IEditor
*
editor
)
const
;
CppEditorSupport
*
editorSupport
(
TextEditor
::
ITextEditor
*
editor
)
const
CppEditorSupport
*
editorSupport
(
TextEditor
::
ITextEditor
*
editor
)
const
{
return
m_editorSupport
.
value
(
editor
);
}
{
return
m_editorSupport
.
value
(
editor
);
}
...
...
src/plugins/cpptools/cppmodelmanagerinterface.h
View file @
f5dae8bc
...
@@ -38,6 +38,10 @@
...
@@ -38,6 +38,10 @@
#include <QtCore/QStringList>
#include <QtCore/QStringList>
#include <QtCore/QFuture>
#include <QtCore/QFuture>
namespace
Core
{
class
IEditor
;
}
namespace
CPlusPlus
{
namespace
CPlusPlus
{
class
LookupContext
;
class
LookupContext
;
}
}
...
@@ -110,6 +114,8 @@ public:
...
@@ -110,6 +114,8 @@ public:
static
CppModelManagerInterface
*
instance
();
static
CppModelManagerInterface
*
instance
();
virtual
bool
isCppEditor
(
Core
::
IEditor
*
editor
)
const
=
0
;
virtual
WorkingCopy
workingCopy
()
const
=
0
;
virtual
WorkingCopy
workingCopy
()
const
=
0
;
virtual
CPlusPlus
::
Snapshot
snapshot
()
const
=
0
;
virtual
CPlusPlus
::
Snapshot
snapshot
()
const
=
0
;
...
...
src/plugins/qmljseditor/qmljseditorplugin.cpp
View file @
f5dae8bc
...
@@ -253,8 +253,9 @@ void QmlJSEditorPlugin::quickFixNow()
...
@@ -253,8 +253,9 @@ void QmlJSEditorPlugin::quickFixNow()
// qDebug() << "TODO: outdated document" << editor->documentRevision() << editor->semanticInfo().revision();
// qDebug() << "TODO: outdated document" << editor->documentRevision() << editor->semanticInfo().revision();
// ### FIXME: m_quickFixTimer->start(QUICKFIX_INTERVAL);
// ### FIXME: m_quickFixTimer->start(QUICKFIX_INTERVAL);
m_quickFixTimer
->
stop
();
m_quickFixTimer
->
stop
();
}
else
}
else
{
TextEditor
::
Internal
::
CompletionSupport
::
instance
()
->
quickFix
(
m_currentTextEditable
);
TextEditor
::
Internal
::
CompletionSupport
::
instance
()
->
quickFix
(
m_currentTextEditable
);
}
}
}
}
}
}
}
...
...
src/plugins/qmljseditor/qmljsquickfix.cpp
View file @
f5dae8bc
...
@@ -29,10 +29,20 @@
...
@@ -29,10 +29,20 @@
#include "qmljsquickfix.h"
#include "qmljsquickfix.h"
#include "qmljseditor.h"
#include "qmljseditor.h"
#include "qmljs/parser/qmljsast_p.h"
#include <QtGui/QApplication>
#include <QtCore/QDebug>
#include <QtCore/QDebug>
using
namespace
QmlJSEditor
::
Internal
;
using
namespace
QmlJSEditor
::
Internal
;
class
QmlJSQuickFixState
:
public
TextEditor
::
QuickFixState
{
public:
SemanticInfo
semanticInfo
;
};
QmlJSQuickFixOperation
::
QmlJSQuickFixOperation
(
TextEditor
::
BaseTextEditor
*
editor
)
QmlJSQuickFixOperation
::
QmlJSQuickFixOperation
(
TextEditor
::
BaseTextEditor
*
editor
)
:
TextEditor
::
QuickFixOperation
(
editor
)
:
TextEditor
::
QuickFixOperation
(
editor
)
{
{
...
@@ -42,6 +52,33 @@ QmlJSQuickFixOperation::~QmlJSQuickFixOperation()
...
@@ -42,6 +52,33 @@ QmlJSQuickFixOperation::~QmlJSQuickFixOperation()
{
{
}
}
QmlJS
::
Document
::
Ptr
QmlJSQuickFixOperation
::
document
()
const
{
return
_semanticInfo
.
document
;
}
const
QmlJS
::
Snapshot
&
QmlJSQuickFixOperation
::
snapshot
()
const
{
return
_semanticInfo
.
snapshot
;
}
const
SemanticInfo
&
QmlJSQuickFixOperation
::
semanticInfo
()
const
{
return
_semanticInfo
;
}
int
QmlJSQuickFixOperation
::
match
(
TextEditor
::
QuickFixState
*
state
)
{
QmlJSQuickFixState
*
s
=
static_cast
<
QmlJSQuickFixState
*>
(
state
);
_semanticInfo
=
s
->
semanticInfo
;
return
check
();
}
unsigned
QmlJSQuickFixOperation
::
position
(
const
QmlJS
::
AST
::
SourceLocation
&
loc
)
const
{
return
position
(
loc
.
startLine
,
loc
.
startColumn
);
}
void
QmlJSQuickFixOperation
::
move
(
const
QmlJS
::
AST
::
SourceLocation
&
loc
,
int
to
)
void
QmlJSQuickFixOperation
::
move
(
const
QmlJS
::
AST
::
SourceLocation
&
loc
,
int
to
)
{
{
move
(
position
(
loc
.
startColumn
,
loc
.
startColumn
),
to
);
move
(
position
(
loc
.
startColumn
,
loc
.
startColumn
),
to
);
...
@@ -70,6 +107,14 @@ QmlJSQuickFixCollector::~QmlJSQuickFixCollector()
...
@@ -70,6 +107,14 @@ QmlJSQuickFixCollector::~QmlJSQuickFixCollector()
{
{
}
}
bool
QmlJSQuickFixCollector
::
supportsEditor
(
TextEditor
::
ITextEditable
*
editable
)
{
if
(
qobject_cast
<
QmlJSTextEditor
*>
(
editable
->
widget
())
!=
0
)
return
true
;
return
false
;
}
TextEditor
::
QuickFixState
*
QmlJSQuickFixCollector
::
initializeCompletion
(
TextEditor
::
ITextEditable
*
editable
)
TextEditor
::
QuickFixState
*
QmlJSQuickFixCollector
::
initializeCompletion
(
TextEditor
::
ITextEditable
*
editable
)
{
{
if
(
QmlJSTextEditor
*
editor
=
qobject_cast
<
QmlJSTextEditor
*>
(
editable
->
widget
()))
{
if
(
QmlJSTextEditor
*
editor
=
qobject_cast
<
QmlJSTextEditor
*>
(
editable
->
widget
()))
{
...
@@ -81,16 +126,16 @@ TextEditor::QuickFixState *QmlJSQuickFixCollector::initializeCompletion(TextEdit
...
@@ -81,16 +126,16 @@ TextEditor::QuickFixState *QmlJSQuickFixCollector::initializeCompletion(TextEdit
return
0
;
return
0
;
}
}
// ### TODO create the quickfix state
QmlJSQuickFixState
*
state
=
new
QmlJSQuickFixState
;
return
0
;
state
->
semanticInfo
=
info
;
return
state
;
}
}
return
0
;
return
0
;
}
}
QList
<
TextEditor
::
QuickFixOperation
::
Ptr
>
QmlJSQuickFixCollector
::
quickFixOperations
(
TextEditor
::
BaseTextEditor
*
)
const
QList
<
TextEditor
::
QuickFixOperation
::
Ptr
>
QmlJSQuickFixCollector
::
quickFixOperations
(
TextEditor
::
BaseTextEditor
*
editor
)
const
{
{
QList
<
TextEditor
::
QuickFixOperation
::
Ptr
>
quickFixOperations
;
QList
<
TextEditor
::
QuickFixOperation
::
Ptr
>
quickFixOperations
;
return
quickFixOperations
;
return
quickFixOperations
;
}
}
src/plugins/qmljseditor/qmljsquickfix.h
View file @
f5dae8bc
...
@@ -30,8 +30,10 @@
...
@@ -30,8 +30,10 @@
#ifndef QMLJSQUICKFIX_H
#ifndef QMLJSQUICKFIX_H
#define QMLJSQUICKFIX_H
#define QMLJSQUICKFIX_H
#include "qmljseditor.h"
#include <texteditor/quickfix.h>
#include <texteditor/quickfix.h>
#include <qmljs/parser/qmljsastfwd_p.h>
#include <qmljs/parser/qmljsastfwd_p.h>
#include <qmljs/qmljsdocument.h>
namespace
QmlJSEditor
{
namespace
QmlJSEditor
{
...
@@ -47,6 +49,13 @@ public:
...
@@ -47,6 +49,13 @@ public:
QmlJSQuickFixOperation
(
TextEditor
::
BaseTextEditor
*
editor
);
QmlJSQuickFixOperation
(
TextEditor
::
BaseTextEditor
*
editor
);
virtual
~
QmlJSQuickFixOperation
();
virtual
~
QmlJSQuickFixOperation
();
QmlJS
::
Document
::
Ptr
document
()
const
;
const
QmlJS
::
Snapshot
&
snapshot
()
const
;
const
SemanticInfo
&
semanticInfo
()
const
;
virtual
int
check
()
=
0
;
virtual
int
match
(
TextEditor
::
QuickFixState
*
state
);
protected:
protected:
using
TextEditor
::
QuickFixOperation
::
move
;
using
TextEditor
::
QuickFixOperation
::
move
;
using
TextEditor
::
QuickFixOperation
::
replace
;
using
TextEditor
::
QuickFixOperation
::
replace
;
...
@@ -56,12 +65,18 @@ protected:
...
@@ -56,12 +65,18 @@ protected:
using
TextEditor
::
QuickFixOperation
::
copy
;
using
TextEditor
::
QuickFixOperation
::
copy
;
using
TextEditor
::
QuickFixOperation
::
textOf
;
using
TextEditor
::
QuickFixOperation
::
textOf
;
using
TextEditor
::
QuickFixOperation
::
charAt
;
using
TextEditor
::
QuickFixOperation
::
charAt
;
using
TextEditor
::
QuickFixOperation
::
position
;
unsigned
position
(
const
QmlJS
::
AST
::
SourceLocation
&
loc
)
const
;
// token based operations
// token based operations
void
move
(
const
QmlJS
::
AST
::
SourceLocation
&
loc
,
int
to
);
void
move
(
const
QmlJS
::
AST
::
SourceLocation
&
loc
,
int
to
);
void
replace
(
const
QmlJS
::
AST
::
SourceLocation
&
loc
,
const
QString
&
replacement
);
void
replace
(
const
QmlJS
::
AST
::
SourceLocation
&
loc
,
const
QString
&
replacement
);
void
remove
(
const
QmlJS
::
AST
::
SourceLocation
&
loc
);
void
remove
(
const
QmlJS
::
AST
::
SourceLocation
&
loc
);
void
copy
(
const
QmlJS
::
AST
::
SourceLocation
&
loc
,
int
to
);
void
copy
(
const
QmlJS
::
AST
::
SourceLocation
&
loc
,
int
to
);
private:
SemanticInfo
_semanticInfo
;
};
};
class
QmlJSQuickFixCollector
:
public
TextEditor
::
QuickFixCollector
class
QmlJSQuickFixCollector
:
public
TextEditor
::
QuickFixCollector
...
@@ -72,6 +87,7 @@ public:
...
@@ -72,6 +87,7 @@ public:
QmlJSQuickFixCollector
();
QmlJSQuickFixCollector
();
virtual
~
QmlJSQuickFixCollector
();
virtual
~
QmlJSQuickFixCollector
();
virtual
bool
supportsEditor
(
TextEditor
::
ITextEditable
*
editor
);
virtual
TextEditor
::
QuickFixState
*
initializeCompletion
(
TextEditor
::
ITextEditable
*
editable
);
virtual
TextEditor
::
QuickFixState
*
initializeCompletion
(
TextEditor
::
ITextEditable
*
editable
);
virtual
QList
<
TextEditor
::
QuickFixOperation
::
Ptr
>
quickFixOperations
(
TextEditor
::
BaseTextEditor
*
editor
)
const
;
virtual
QList
<
TextEditor
::
QuickFixOperation
::
Ptr
>
quickFixOperations
(
TextEditor
::
BaseTextEditor
*
editor
)
const
;
};
};
...
...
src/plugins/texteditor/quickfix.cpp
View file @
f5dae8bc
...
@@ -181,9 +181,6 @@ TextEditor::ITextEditable *QuickFixCollector::editor() const
...
@@ -181,9 +181,6 @@ TextEditor::ITextEditable *QuickFixCollector::editor() const
int
QuickFixCollector
::
startPosition
()
const
int
QuickFixCollector
::
startPosition
()
const
{
return
_editable
->
position
();
}
{
return
_editable
->
position
();
}
bool
QuickFixCollector
::
supportsEditor
(
TextEditor
::
ITextEditable
*
)
{
return
true
;
}
bool
QuickFixCollector
::
triggersCompletion
(
TextEditor
::
ITextEditable
*
)
bool
QuickFixCollector
::
triggersCompletion
(
TextEditor
::
ITextEditable
*
)
{
return
false
;
}
{
return
false
;
}
...
...
src/plugins/texteditor/quickfix.h
View file @
f5dae8bc
...
@@ -125,7 +125,6 @@ public:
...
@@ -125,7 +125,6 @@ public:
virtual
TextEditor
::
ITextEditable
*
editor
()
const
;
virtual
TextEditor
::
ITextEditable
*
editor
()
const
;
virtual
int
startPosition
()
const
;
virtual
int
startPosition
()
const
;
virtual
bool
supportsEditor
(
TextEditor
::
ITextEditable
*
editor
);
virtual
bool
triggersCompletion
(
TextEditor
::
ITextEditable
*
editor
);
virtual
bool
triggersCompletion
(
TextEditor
::
ITextEditable
*
editor
);
virtual
int
startCompletion
(
TextEditor
::
ITextEditable
*
editor
);
virtual
int
startCompletion
(
TextEditor
::
ITextEditable
*
editor
);
virtual
void
completions
(
QList
<
TextEditor
::
CompletionItem
>
*
completions
);
virtual
void
completions
(
QList
<
TextEditor
::
CompletionItem
>
*
completions
);
...
...
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