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
97f8850a
Commit
97f8850a
authored
Jul 09, 2009
by
Roberto Raggi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduced SemanticHighlighter
Done with Thorbjørn Lindeijer
parent
206adf2d
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
363 additions
and
194 deletions
+363
-194
src/plugins/cppeditor/cppeditor.cpp
src/plugins/cppeditor/cppeditor.cpp
+252
-153
src/plugins/cppeditor/cppeditor.h
src/plugins/cppeditor/cppeditor.h
+108
-3
src/shared/cplusplus/CPlusPlusForwardDeclarations.h
src/shared/cplusplus/CPlusPlusForwardDeclarations.h
+0
-1
src/shared/cplusplus/Scope.cpp
src/shared/cplusplus/Scope.cpp
+3
-31
src/shared/cplusplus/Scope.h
src/shared/cplusplus/Scope.h
+0
-6
No files found.
src/plugins/cppeditor/cppeditor.cpp
View file @
97f8850a
This diff is collapsed.
Click to expand it.
src/plugins/cppeditor/cppeditor.h
View file @
97f8850a
...
...
@@ -31,10 +31,14 @@
#define CPPEDITOR_H
#include "cppeditorenums.h"
#include <ASTfwd.h>
#include <cplusplus/CppDocument.h>
#include <texteditor/basetexteditor.h>
#include <QtCore/QThread>
#include <QtCore/QMutex>
#include <QtCore/QWaitCondition>
QT_BEGIN_NAMESPACE
class
QComboBox
;
class
QSortFilterProxyModel
;
...
...
@@ -57,6 +61,99 @@ namespace CppEditor {
namespace
Internal
{
class
CPPEditor
;
class
SemanticHighlighter
;
class
SemanticInfo
{
public:
struct
Use
{
CPlusPlus
::
NameAST
*
name
;
unsigned
line
;
unsigned
column
;
unsigned
length
;
Use
()
{}
Use
(
CPlusPlus
::
NameAST
*
name
,
unsigned
line
,
unsigned
column
,
unsigned
length
)
:
name
(
name
),
line
(
line
),
column
(
column
),
length
(
length
)
{}
};
typedef
QHash
<
CPlusPlus
::
Symbol
*
,
QList
<
Use
>
>
LocalUseMap
;
typedef
QHashIterator
<
CPlusPlus
::
Symbol
*
,
QList
<
Use
>
>
LocalUseIterator
;
typedef
QHash
<
CPlusPlus
::
Identifier
*
,
QList
<
Use
>
>
ExternalUseMap
;
typedef
QHashIterator
<
CPlusPlus
::
Identifier
*
,
QList
<
Use
>
>
ExternalUseIterator
;
SemanticInfo
()
:
revision
(
0
)
{
}
int
revision
;
CPlusPlus
::
Document
::
Ptr
doc
;
LocalUseMap
localUses
;
ExternalUseMap
externalUses
;
};
class
SemanticHighlighter
:
public
QThread
{
Q_OBJECT
public:
SemanticHighlighter
(
QObject
*
parent
=
0
);
virtual
~
SemanticHighlighter
();
void
abort
();
struct
Source
{
CPlusPlus
::
Snapshot
snapshot
;
QString
fileName
;
QString
code
;
int
line
;
int
column
;
int
revision
;
Source
()
:
line
(
0
),
column
(
0
),
revision
(
0
)
{
}
Source
(
const
CPlusPlus
::
Snapshot
&
snapshot
,
const
QString
&
fileName
,
const
QString
&
code
,
int
line
,
int
column
,
int
revision
)
:
snapshot
(
snapshot
),
fileName
(
fileName
),
code
(
code
),
line
(
line
),
column
(
column
),
revision
(
revision
)
{
}
void
clear
()
{
snapshot
.
clear
();
fileName
.
clear
();
code
.
clear
();
line
=
0
;
column
=
0
;
revision
=
0
;
}
};
SemanticInfo
semanticInfo
(
const
Source
&
source
)
const
;
void
rehighlight
(
const
Source
&
source
);
Q_SIGNALS:
void
changed
(
const
SemanticInfo
&
semanticInfo
);
protected:
virtual
void
run
();
private:
QMutex
m_mutex
;
QWaitCondition
m_condition
;
bool
m_done
;
Source
m_source
;
};
class
CPPEditorEditable
:
public
TextEditor
::
BaseTextEditorEditable
{
...
...
@@ -89,7 +186,7 @@ public:
void
indentInsertedText
(
const
QTextCursor
&
tc
);
public
slots
:
public
Q_SLOTS
:
virtual
void
setFontSettings
(
const
TextEditor
::
FontSettings
&
);
virtual
void
setDisplaySettings
(
const
TextEditor
::
DisplaySettings
&
);
void
setSortedMethodOverview
(
bool
sort
);
...
...
@@ -116,7 +213,7 @@ protected:
// Rertuns true if key triggers anindent.
virtual
bool
isElectricCharacter
(
const
QChar
&
ch
)
const
;
private
slots
:
private
Q_SLOTS
:
void
updateFileName
();
void
jumpToMethod
(
int
index
);
void
updateMethodBoxIndex
();
...
...
@@ -129,6 +226,9 @@ private slots:
void
renameInPlace
();
void
onContentsChanged
(
int
position
,
int
charsRemoved
,
int
charsAdded
);
void
semanticRehighlight
();
void
updateSemanticInfo
(
const
SemanticInfo
&
semanticInfo
);
private:
bool
sortedMethodOverview
()
const
;
CPlusPlus
::
Symbol
*
findDefinition
(
CPlusPlus
::
Symbol
*
symbol
);
...
...
@@ -141,6 +241,8 @@ private:
QTextCursor
moveToPreviousToken
(
QTextCursor
::
MoveMode
mode
)
const
;
QTextCursor
moveToNextToken
(
QTextCursor
::
MoveMode
mode
)
const
;
SemanticHighlighter
::
Source
currentSource
();
void
createToolBar
(
CPPEditorEditable
*
editable
);
enum
EditOperation
{
...
...
@@ -198,8 +300,11 @@ private:
QList
<
QTextEdit
::
ExtraSelection
>
m_renameSelections
;
int
m_currentRenameSelection
;
bool
m_inRename
;
SemanticHighlighter
*
m_semanticHighlighter
;
};
}
// namespace Internal
}
// namespace CppEditor
...
...
src/shared/cplusplus/CPlusPlusForwardDeclarations.h
View file @
97f8850a
...
...
@@ -131,7 +131,6 @@ class Class;
class
Enum
;
class
ForwardClassDeclaration
;
class
Use
;
class
Token
;
CPLUSPLUS_END_NAMESPACE
...
...
src/shared/cplusplus/Scope.cpp
View file @
97f8850a
...
...
@@ -63,10 +63,7 @@ Scope::Scope(ScopedSymbol *owner)
_allocatedSymbols
(
0
),
_symbolCount
(
-
1
),
_hash
(
0
),
_hashSize
(
0
),
_uses
(
0
),
_allocatedUses
(
0
),
_useCount
(
-
1
)
_hashSize
(
0
)
{
}
Scope
::~
Scope
()
...
...
@@ -75,8 +72,6 @@ Scope::~Scope()
free
(
_symbols
);
if
(
_hash
)
free
(
_hash
);
if
(
_uses
)
free
(
_uses
);
}
ScopedSymbol
*
Scope
::
owner
()
const
...
...
@@ -300,30 +295,7 @@ Scope::iterator Scope::firstSymbol() const
Scope
::
iterator
Scope
::
lastSymbol
()
const
{
return
_symbols
+
_symbolCount
+
1
;
}
unsigned
Scope
::
useCount
()
const
{
return
_useCount
+
1
;
}
Use
*
Scope
::
useAt
(
unsigned
index
)
const
{
return
&
_uses
[
index
];
}
void
Scope
::
addUse
(
unsigned
sourceOffset
,
Name
*
name
)
{
#ifdef CPLUSPLUS_WITH_USES
if
(
++
_useCount
==
_allocatedUses
)
{
_allocatedUses
+=
4
;
_uses
=
reinterpret_cast
<
Use
*>
(
realloc
(
_uses
,
_allocatedUses
*
sizeof
(
Use
)));
}
Symbol
*
lastVisibleSymbol
;
if
(
_symbolCount
==
-
1
)
lastVisibleSymbol
=
owner
();
else
lastVisibleSymbol
=
_symbols
[
_symbolCount
];
_uses
[
_useCount
].
init
(
sourceOffset
,
name
,
lastVisibleSymbol
);
#else
(
void
)
sourceOffset
;
(
void
)
name
;
#endif
}
void
Scope
::
addUse
(
unsigned
,
Name
*
)
{
}
CPLUSPLUS_END_NAMESPACE
src/shared/cplusplus/Scope.h
View file @
97f8850a
...
...
@@ -160,8 +160,6 @@ public:
Symbol
*
lookat
(
Identifier
*
id
)
const
;
Symbol
*
lookat
(
int
operatorId
)
const
;
unsigned
useCount
()
const
;
Use
*
useAt
(
unsigned
index
)
const
;
void
addUse
(
unsigned
sourceOffset
,
Name
*
name
);
private:
...
...
@@ -182,10 +180,6 @@ private:
Symbol
**
_hash
;
int
_hashSize
;
Use
*
_uses
;
int
_allocatedUses
;
int
_useCount
;
};
CPLUSPLUS_END_NAMESPACE
...
...
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