diff --git a/src/libs/glsl/glslengine.cpp b/src/libs/glsl/glslengine.cpp
index 73938e947ea1c325df0c502e579b61ebe3efbfdb..2b6ec6e03910cfdc0223ab1bc605ab376c7ef3d8 100644
--- a/src/libs/glsl/glslengine.cpp
+++ b/src/libs/glsl/glslengine.cpp
@@ -266,11 +266,12 @@ Argument *Engine::newArgument(Function *function, const QString &name, const Typ
return a;
}
-Variable *Engine::newVariable(Scope *scope, const QString &name, const Type *type)
+Variable *Engine::newVariable(Scope *scope, const QString &name, const Type *type, int qualifiers)
{
Variable *var = new Variable(scope);
var->setName(name);
var->setType(type);
+ var->setQualifiers(qualifiers);
_symbols.append(var);
return var;
}
diff --git a/src/libs/glsl/glslengine.h b/src/libs/glsl/glslengine.h
index ab73debf9e7d09d3907f2046da468199f16694f5..2d668ba37f06ec52bab940f04bbdba9fa381eb7b 100644
--- a/src/libs/glsl/glslengine.h
+++ b/src/libs/glsl/glslengine.h
@@ -120,7 +120,7 @@ public:
Block *newBlock(Scope *scope = 0);
Function *newFunction(Scope *scope = 0);
Argument *newArgument(Function *function, const QString &name, const Type *type);
- Variable *newVariable(Scope *scope, const QString &name, const Type *type);
+ Variable *newVariable(Scope *scope, const QString &name, const Type *type, int qualifiers = 0);
MemoryPool *pool();
diff --git a/src/libs/glsl/glslsemantic.cpp b/src/libs/glsl/glslsemantic.cpp
index 29760e2eecdb8aa5ce6bddd9216e185a48b5897c..ac07911ea5b3c3a142d93f6414ac9be419809586 100644
--- a/src/libs/glsl/glslsemantic.cpp
+++ b/src/libs/glsl/glslsemantic.cpp
@@ -751,7 +751,11 @@ bool Semantic::visit(VariableDeclarationAST *ast)
const Type *ty = type(ast->type);
ExprResult initializer = expression(ast->initializer);
if (ast->name) {
- Variable *var = _engine->newVariable(_scope, *ast->name, ty);
+ QualifiedTypeAST *qtype = ast->type->asQualifiedType();
+ int qualifiers = 0;
+ if (qtype)
+ qualifiers = qtype->qualifiers;
+ Variable *var = _engine->newVariable(_scope, *ast->name, ty, qualifiers);
_scope->add(var);
}
return false;
diff --git a/src/libs/glsl/glslsymbols.cpp b/src/libs/glsl/glslsymbols.cpp
index e4ede5f6c5ed5b80ce622d9cd6910b081c1a30d4..216086291774bc9f19ff4e9b00e71b1ea1bcc119 100644
--- a/src/libs/glsl/glslsymbols.cpp
+++ b/src/libs/glsl/glslsymbols.cpp
@@ -78,6 +78,7 @@ Symbol *Block::find(const QString &name) const
Variable::Variable(Scope *scope)
: Symbol(scope)
, _type(0)
+ , _qualifiers(0)
{
}
diff --git a/src/libs/glsl/glslsymbols.h b/src/libs/glsl/glslsymbols.h
index 6506c62fa7dbe1e7c5a7f4a62bbfa8bf3688decb..bf610dd3a249c95a738543590a0ceafcb835df11 100644
--- a/src/libs/glsl/glslsymbols.h
+++ b/src/libs/glsl/glslsymbols.h
@@ -59,10 +59,14 @@ public:
virtual const Type *type() const;
void setType(const Type *type);
+ int qualifiers() const { return _qualifiers; }
+ void setQualifiers(int qualifiers) { _qualifiers = qualifiers; }
+
virtual Variable *asVariable() { return this; }
private:
const Type *_type;
+ int _qualifiers;
};
class GLSL_EXPORT Block: public Scope
diff --git a/src/plugins/glsleditor/glslcodecompletion.cpp b/src/plugins/glsleditor/glslcodecompletion.cpp
index ff891802759e9ac48802bd68e37e66cb579a4ffc..042f4c8a778218fe8aaeec77c6e76df3f97c5594 100644
--- a/src/plugins/glsleditor/glslcodecompletion.cpp
+++ b/src/plugins/glsleditor/glslcodecompletion.cpp
@@ -492,6 +492,10 @@ CodeCompletion::CodeCompletion(QObject *parent)
m_varIcon(":/glsleditor/images/var.png"),
m_functionIcon(":/glsleditor/images/func.png"),
m_typeIcon(":/glsleditor/images/type.png"),
+ m_constIcon(":/glsleditor/images/const.png"),
+ m_attributeIcon(":/glsleditor/images/attribute.png"),
+ m_uniformIcon(":/glsleditor/images/uniform.png"),
+ m_varyingIcon(":/glsleditor/images/varying.png"),
m_otherIcon(":/glsleditor/images/other.png")
{
const QIcon keywordIcon(QLatin1String(":/glsleditor/images/keyword.png"));
@@ -678,14 +682,28 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
foreach (GLSL::Symbol *s, members) {
TextEditor::CompletionItem item(this);
- if (s->asVariable() || s->asArgument())
+ GLSL::Variable *var = s->asVariable();
+ if (var) {
+ int storageType = var->qualifiers() & GLSL::QualifiedTypeAST::StorageMask;
+ if (storageType == GLSL::QualifiedTypeAST::Attribute)
+ item.icon = m_attributeIcon;
+ else if (storageType == GLSL::QualifiedTypeAST::Uniform)
+ item.icon = m_uniformIcon;
+ else if (storageType == GLSL::QualifiedTypeAST::Varying)
+ item.icon = m_varyingIcon;
+ else if (storageType == GLSL::QualifiedTypeAST::Const)
+ item.icon = m_constIcon;
+ else
+ item.icon = m_varIcon;
+ } else if (s->asArgument()) {
item.icon = m_varIcon;
- else if (s->asFunction() || s->asOverloadSet())
+ } else if (s->asFunction() || s->asOverloadSet()) {
item.icon = m_functionIcon;
- else if (s->asStruct())
+ } else if (s->asStruct()) {
item.icon = m_typeIcon;
- else
+ } else {
item.icon = m_otherIcon;
+ }
item.text = s->name();
if (specialMembers.contains(item.text))
item.order = SpecialMemberOrder;
diff --git a/src/plugins/glsleditor/glslcodecompletion.h b/src/plugins/glsleditor/glslcodecompletion.h
index f8110bcffcb012e36917f11d95fac86845571f51..7eb3796e468d8d8ee0a3ceaf68b0c4439855e439 100644
--- a/src/plugins/glsleditor/glslcodecompletion.h
+++ b/src/plugins/glsleditor/glslcodecompletion.h
@@ -110,6 +110,10 @@ private:
QIcon m_varIcon;
QIcon m_functionIcon;
QIcon m_typeIcon;
+ QIcon m_constIcon;
+ QIcon m_attributeIcon;
+ QIcon m_uniformIcon;
+ QIcon m_varyingIcon;
QIcon m_otherIcon;
};
diff --git a/src/plugins/glsleditor/glsleditor.qrc b/src/plugins/glsleditor/glsleditor.qrc
index 40037911254e812a5e89ff5b169510845e133755..3455048e006772ad7c05992bc870749bf6e6cf36 100644
--- a/src/plugins/glsleditor/glsleditor.qrc
+++ b/src/plugins/glsleditor/glsleditor.qrc
@@ -6,6 +6,10 @@
images/var.png
images/func.png
images/type.png
+ images/const.png
+ images/attribute.png
+ images/uniform.png
+ images/varying.png
images/other.png
diff --git a/src/plugins/glsleditor/images/attribute.png b/src/plugins/glsleditor/images/attribute.png
new file mode 100644
index 0000000000000000000000000000000000000000..94f20ac42ac8b268d0d962e9e0ab86b1a518ae00
Binary files /dev/null and b/src/plugins/glsleditor/images/attribute.png differ
diff --git a/src/plugins/glsleditor/images/const.png b/src/plugins/glsleditor/images/const.png
new file mode 100644
index 0000000000000000000000000000000000000000..25fc49c6598a8a99c11ec688b4dc1d3153427507
Binary files /dev/null and b/src/plugins/glsleditor/images/const.png differ
diff --git a/src/plugins/glsleditor/images/uniform.png b/src/plugins/glsleditor/images/uniform.png
new file mode 100644
index 0000000000000000000000000000000000000000..c6452fc8c6ffe14c756a9423241df93ce34d361b
Binary files /dev/null and b/src/plugins/glsleditor/images/uniform.png differ
diff --git a/src/plugins/glsleditor/images/varying.png b/src/plugins/glsleditor/images/varying.png
new file mode 100644
index 0000000000000000000000000000000000000000..c2551c002577c415d539876c0c1e690319ca74d6
Binary files /dev/null and b/src/plugins/glsleditor/images/varying.png differ