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
Tobias Hunger
qt-creator
Commits
b19b2a71
Commit
b19b2a71
authored
Nov 26, 2010
by
Roberto Raggi
Browse files
Store the numbers and the identifiers in two different sets.
parent
30e74df0
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/libs/glsl/glslengine.cpp
View file @
b19b2a71
...
...
@@ -99,6 +99,26 @@ const QString *Engine::identifier(const char *s, int n)
return
&
(
*
_identifiers
.
insert
(
QString
::
fromLatin1
(
s
,
n
)));
}
QSet
<
QString
>
Engine
::
identifiers
()
const
{
return
_identifiers
;
}
const
QString
*
Engine
::
number
(
const
QString
&
s
)
{
return
&
(
*
_numbers
.
insert
(
s
));
}
const
QString
*
Engine
::
number
(
const
char
*
s
,
int
n
)
{
return
&
(
*
_numbers
.
insert
(
QString
::
fromLatin1
(
s
,
n
)));
}
QSet
<
QString
>
Engine
::
numbers
()
const
{
return
_numbers
;
}
MemoryPool
*
Engine
::
pool
()
{
return
&
_pool
;
...
...
@@ -199,11 +219,6 @@ void Engine::error(int line, const QString &message)
addDiagnosticMessage
(
m
);
}
QSet
<
QString
>
Engine
::
identifiers
()
const
{
return
_identifiers
;
}
bool
DiagnosticMessage
::
isError
()
const
{
return
_kind
==
Error
;
...
...
src/libs/glsl/glslengine.h
View file @
b19b2a71
...
...
@@ -98,6 +98,10 @@ public:
const
QString
*
identifier
(
const
char
*
s
,
int
n
);
QSet
<
QString
>
identifiers
()
const
;
const
QString
*
number
(
const
QString
&
s
);
const
QString
*
number
(
const
char
*
s
,
int
n
);
QSet
<
QString
>
numbers
()
const
;
// types
const
UndefinedType
*
undefinedType
();
const
VoidType
*
voidType
();
...
...
@@ -129,6 +133,7 @@ public:
private:
QSet
<
QString
>
_identifiers
;
QSet
<
QString
>
_numbers
;
TypeTable
<
VectorType
>
_vectorTypes
;
TypeTable
<
MatrixType
>
_matrixTypes
;
TypeTable
<
SamplerType
>
_samplerTypes
;
...
...
src/libs/glsl/glsllexer.cpp
View file @
b19b2a71
...
...
@@ -207,9 +207,12 @@ int Lexer::yylex_helper(const char **position, int *line)
// float constant
case
'.'
:
if
(
std
::
isdigit
(
_yychar
))
{
const
char
*
word
=
_it
-
2
;
while
(
std
::
isalnum
(
_yychar
))
{
yyinp
();
}
if
(
_engine
)
_yyval
.
string
=
_engine
->
number
(
word
,
_it
-
word
-
1
);
return
Parser
::
T_NUMBER
;
}
return
Parser
::
T_DOT
;
...
...
@@ -378,7 +381,7 @@ int Lexer::yylex_helper(const char **position, int *line)
yyinp
();
}
if
(
_engine
)
_yyval
.
string
=
_engine
->
identifi
er
(
word
,
_it
-
word
-
1
);
_yyval
.
string
=
_engine
->
numb
er
(
word
,
_it
-
word
-
1
);
return
Parser
::
T_NUMBER
;
}
...
...
src/plugins/glsleditor/glslcodecompletion.cpp
View file @
b19b2a71
...
...
@@ -28,12 +28,15 @@
**************************************************************************/
#include
"glslcodecompletion.h"
#include
"glsleditor.h"
#include
"glsleditorplugin.h"
#include
<glsl/glslengine.h>
#include
<texteditor/completionsettings.h>
#include
<QtGui/QIcon>
#include
<QtGui/QPainter>
#include
<QtCore/QDebug>
using
namespace
GLSLEditor
;
using
namespace
GLSLEditor
::
Internal
;
static
bool
isIdentifierChar
(
QChar
ch
)
{
...
...
@@ -310,14 +313,24 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
int
pos
=
editor
->
position
()
-
1
;
QChar
ch
=
editor
->
characterAt
(
pos
);
while
(
ch
.
isLetterOrNumber
())
while
(
ch
.
isLetterOrNumber
()
||
ch
==
QLatin1Char
(
'_'
)
)
ch
=
editor
->
characterAt
(
--
pos
);
const
QIcon
symbolIcon
=
iconForColor
(
Qt
::
darkCyan
);
m_completions
+=
m_keywordCompletions
;
if
(
GLSLTextEditor
*
ed
=
qobject_cast
<
GLSLTextEditor
*>
(
m_editor
->
widget
()))
{
foreach
(
const
QString
&
id
,
ed
->
identifiers
())
{
QSet
<
QString
>
identifiers
=
ed
->
identifiers
();
identifiers
+=
GLSLEditorPlugin
::
instance
()
->
shaderInit
()
->
engine
->
identifiers
();
if
(
ed
->
isVertexShader
())
identifiers
+=
GLSLEditorPlugin
::
instance
()
->
vertexShaderInit
()
->
engine
->
identifiers
();
if
(
ed
->
isFragmentShader
())
identifiers
+=
GLSLEditorPlugin
::
instance
()
->
fragmentShaderInit
()
->
engine
->
identifiers
();
foreach
(
const
QString
&
id
,
identifiers
)
{
TextEditor
::
CompletionItem
item
(
this
);
item
.
text
=
id
;
item
.
icon
=
symbolIcon
;
...
...
src/plugins/glsleditor/glslcodecompletion.h
View file @
b19b2a71
...
...
@@ -32,6 +32,7 @@
#include
<texteditor/icompletioncollector.h>
namespace
GLSLEditor
{
namespace
Internal
{
class
CodeCompletion
:
public
TextEditor
::
ICompletionCollector
{
...
...
@@ -100,6 +101,7 @@ private:
bool
m_restartCompletion
;
};
}
// namespace Internal
}
// namespace GLSLEditor
#endif // GLSLCODECOMPLETION_H
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