Skip to content
GitLab
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
f3c2bbaa
Commit
f3c2bbaa
authored
Feb 10, 2009
by
Roberto Raggi
Committed by
Thorbjørn Lindeijer
Feb 11, 2009
Browse files
Less annoying syntax checker.
(cherry picked from commit
9539bb2b
)
parent
b6ca8da0
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/libs/cplusplus/CppDocument.cpp
View file @
f3c2bbaa
...
...
@@ -239,6 +239,9 @@ void Document::startSkippingBlocks(unsigned start)
void
Document
::
stopSkippingBlocks
(
unsigned
stop
)
{
if
(
_skippedBlocks
.
isEmpty
())
return
;
unsigned
start
=
_skippedBlocks
.
back
().
begin
();
if
(
start
>
stop
)
_skippedBlocks
.
removeLast
();
// Ignore this block, it's invalid.
...
...
src/plugins/cpptools/cppmodelmanager.cpp
View file @
f3c2bbaa
...
...
@@ -69,6 +69,7 @@
#include
<QtCore/QDebug>
#include
<QtCore/QMutexLocker>
#include
<QtCore/QTime>
#include
<QtCore/QTimer>
using
namespace
CppTools
;
using
namespace
CppTools
::
Internal
;
...
...
@@ -447,6 +448,12 @@ CppModelManager::CppModelManager(QObject *parent)
ProjectExplorer
::
SessionManager
*
session
=
m_projectExplorer
->
session
();
QTC_ASSERT
(
session
,
return
);
m_updateEditorSelectionsTimer
=
new
QTimer
(
this
);
m_updateEditorSelectionsTimer
->
setInterval
(
500
);
m_updateEditorSelectionsTimer
->
setSingleShot
(
true
);
connect
(
m_updateEditorSelectionsTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
updateEditorSelections
()));
connect
(
session
,
SIGNAL
(
projectAdded
(
ProjectExplorer
::
Project
*
)),
this
,
SLOT
(
onProjectAdded
(
ProjectExplorer
::
Project
*
)));
...
...
@@ -710,8 +717,8 @@ void CppModelManager::onDocumentUpdated(Document::Ptr doc)
continue
;
else
if
(
lines
.
contains
(
m
.
line
()))
continue
;
else
if
(
lines
.
size
()
==
MAX_SELECTION_COUNT
)
break
;
// we're done.
//
else if (lines.size() == MAX_SELECTION_COUNT)
//
break; // we're done.
lines
.
insert
(
m
.
line
());
...
...
@@ -733,12 +740,42 @@ void CppModelManager::onDocumentUpdated(Document::Ptr doc)
sel
.
cursor
=
c
;
selections
.
append
(
sel
);
}
ed
->
setExtraSelections
(
TextEditor
::
BaseTextEditor
::
CodeWarningsSelection
,
selections
);
QList
<
Editor
>
todo
;
foreach
(
Editor
e
,
todo
)
{
if
(
e
.
widget
!=
ed
)
todo
.
append
(
e
);
}
Editor
e
;
e
.
widget
=
ed
;
e
.
selections
=
selections
;
todo
.
append
(
e
);
m_todo
=
todo
;
postEditorUpdate
();
break
;
}
}
}
void
CppModelManager
::
postEditorUpdate
()
{
m_updateEditorSelectionsTimer
->
start
(
500
);
}
void
CppModelManager
::
updateEditorSelections
()
{
foreach
(
Editor
ed
,
m_todo
)
{
if
(
!
ed
.
widget
)
continue
;
ed
.
widget
->
setExtraSelections
(
TextEditor
::
BaseTextEditor
::
CodeWarningsSelection
,
ed
.
selections
);
}
m_todo
.
clear
();
}
void
CppModelManager
::
onProjectAdded
(
ProjectExplorer
::
Project
*
)
{
QMutexLocker
locker
(
&
mutex
);
...
...
src/plugins/cpptools/cppmodelmanager.h
View file @
f3c2bbaa
...
...
@@ -41,6 +41,8 @@
#include
<QMap>
#include
<QFutureInterface>
#include
<QMutex>
#include
<QTimer>
#include
<QTextEdit>
namespace
Core
{
class
ICore
;
...
...
@@ -49,6 +51,7 @@ class IEditor;
namespace
TextEditor
{
class
ITextEditor
;
class
BaseTextEditor
;
}
namespace
ProjectExplorer
{
...
...
@@ -86,6 +89,9 @@ public:
void
emitDocumentUpdated
(
CPlusPlus
::
Document
::
Ptr
doc
);
void
stopEditorSelectionsUpdate
()
{
m_updateEditorSelectionsTimer
->
stop
();
}
Q_SIGNALS:
void
projectPathChanged
(
const
QString
&
projectPath
);
...
...
@@ -102,6 +108,8 @@ private Q_SLOTS:
void
onAboutToRemoveProject
(
ProjectExplorer
::
Project
*
project
);
void
onSessionUnloaded
();
void
onProjectAdded
(
ProjectExplorer
::
Project
*
project
);
void
postEditorUpdate
();
void
updateEditorSelections
();
private:
QMap
<
QString
,
QByteArray
>
buildWorkingCopyList
();
...
...
@@ -163,6 +171,15 @@ private:
enum
{
MAX_SELECTION_COUNT
=
5
};
struct
Editor
{
QPointer
<
TextEditor
::
BaseTextEditor
>
widget
;
QList
<
QTextEdit
::
ExtraSelection
>
selections
;
};
QList
<
Editor
>
m_todo
;
QTimer
*
m_updateEditorSelectionsTimer
;
};
}
// namespace Internal
...
...
src/plugins/cpptools/cpptoolseditorsupport.cpp
View file @
f3c2bbaa
...
...
@@ -35,6 +35,7 @@
#include
"cppmodelmanager.h"
#include
<texteditor/itexteditor.h>
#include
<texteditor/basetexteditor.h>
#include
<QTimer>
...
...
@@ -68,12 +69,14 @@ void CppEditorSupport::setTextEditor(TextEditor::ITextEditor *textEditor)
updateDocument
();
}
QString
CppEditorSupport
::
contents
()
const
QString
CppEditorSupport
::
contents
()
{
if
(
!
_textEditor
)
return
QString
();
else
if
(
!
_cachedContents
.
isEmpty
())
_cachedContents
=
_textEditor
->
contents
();
return
_
textEditor
->
c
ontents
()
;
return
_
cachedC
ontents
;
}
int
CppEditorSupport
::
updateDocumentInterval
()
const
...
...
@@ -83,7 +86,20 @@ void CppEditorSupport::setUpdateDocumentInterval(int updateDocumentInterval)
{
_updateDocumentInterval
=
updateDocumentInterval
;
}
void
CppEditorSupport
::
updateDocument
()
{
_updateDocumentTimer
->
start
(
_updateDocumentInterval
);
}
{
if
(
TextEditor
::
BaseTextEditor
*
edit
=
qobject_cast
<
TextEditor
::
BaseTextEditor
*>
(
_textEditor
->
widget
()))
{
const
QList
<
QTextEdit
::
ExtraSelection
>
selections
=
edit
->
extraSelections
(
TextEditor
::
BaseTextEditor
::
CodeWarningsSelection
);
if
(
!
selections
.
isEmpty
())
edit
->
setExtraSelections
(
TextEditor
::
BaseTextEditor
::
CodeWarningsSelection
,
QList
<
QTextEdit
::
ExtraSelection
>
());
_modelManager
->
stopEditorSelectionsUpdate
();
}
_updateDocumentTimer
->
start
(
_updateDocumentInterval
);
}
void
CppEditorSupport
::
updateDocumentNow
()
{
...
...
@@ -91,7 +107,9 @@ void CppEditorSupport::updateDocumentNow()
_updateDocumentTimer
->
start
(
_updateDocumentInterval
);
}
else
{
_updateDocumentTimer
->
stop
();
QStringList
sourceFiles
(
_textEditor
->
file
()
->
fileName
());
_cachedContents
=
_textEditor
->
contents
();
_documentParser
=
_modelManager
->
refreshSourceFiles
(
sourceFiles
);
}
}
...
...
src/plugins/cpptools/cpptoolseditorsupport.h
View file @
f3c2bbaa
...
...
@@ -65,7 +65,7 @@ public:
int
updateDocumentInterval
()
const
;
void
setUpdateDocumentInterval
(
int
updateDocumentInterval
);
QString
contents
()
const
;
QString
contents
();
private
Q_SLOTS
:
void
updateDocument
();
...
...
@@ -79,6 +79,7 @@ private:
QTimer
*
_updateDocumentTimer
;
int
_updateDocumentInterval
;
QFuture
<
void
>
_documentParser
;
QString
_cachedContents
;
};
}
// namespace Internal
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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