diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2010-11-26 15:50:55 +0100 |
---|---|---|
committer | Roberto Raggi <roberto.raggi@nokia.com> | 2010-11-26 15:52:59 +0100 |
commit | b19b2a71672ee172786e5d3c2c1ff307f9745a68 (patch) | |
tree | e9c341304b0aece191fb8a38337eebb4f552a520 /src/plugins/glsleditor | |
parent | 30e74df0baedcd3a5e2aa309892e2b98d435b0b0 (diff) | |
download | qt-creator-b19b2a71672ee172786e5d3c2c1ff307f9745a68.tar.gz |
Store the numbers and the identifiers in two different sets.
Diffstat (limited to 'src/plugins/glsleditor')
-rw-r--r-- | src/plugins/glsleditor/glslcodecompletion.cpp | 17 | ||||
-rw-r--r-- | src/plugins/glsleditor/glslcodecompletion.h | 2 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/plugins/glsleditor/glslcodecompletion.cpp b/src/plugins/glsleditor/glslcodecompletion.cpp index cfdc3a1f5f..a2ebe3e25c 100644 --- a/src/plugins/glsleditor/glslcodecompletion.cpp +++ b/src/plugins/glsleditor/glslcodecompletion.cpp @@ -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; diff --git a/src/plugins/glsleditor/glslcodecompletion.h b/src/plugins/glsleditor/glslcodecompletion.h index 3b7b665e6a..4e2d424ae4 100644 --- a/src/plugins/glsleditor/glslcodecompletion.h +++ b/src/plugins/glsleditor/glslcodecompletion.h @@ -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 |