aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/glsleditor
diff options
context:
space:
mode:
authorAlessandro Portale <alessandro.portale@qt.io>2018-11-11 00:24:20 +0100
committerAlessandro Portale <alessandro.portale@qt.io>2018-11-13 15:44:07 +0000
commit57d31b8ebc1b8c18ae01ab7f65e11269aca8aa5b (patch)
tree87023c1d7b222edd83f7d94b6c846d1547d2f4be /src/plugins/glsleditor
parent01d19b4f7059094019e4f861357dd54f2adbaeb7 (diff)
GlslEditor: Modernize
modernize-use-auto modernize-use-equals-default modernize-use-nullptr modernize-use-override modernize-use-using Change-Id: Ic83ce33890ef2d4916997671af6163228135b7b0 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'src/plugins/glsleditor')
-rw-r--r--src/plugins/glsleditor/glslcompletionassist.cpp32
-rw-r--r--src/plugins/glsleditor/glslcompletionassist.h14
-rw-r--r--src/plugins/glsleditor/glsleditor.cpp7
-rw-r--r--src/plugins/glsleditor/glslhighlighter.cpp2
-rw-r--r--src/plugins/glsleditor/glslhighlighter.h2
-rw-r--r--src/plugins/glsleditor/glslindenter.cpp6
-rw-r--r--src/plugins/glsleditor/glslindenter.h27
7 files changed, 35 insertions, 55 deletions
diff --git a/src/plugins/glsleditor/glslcompletionassist.cpp b/src/plugins/glsleditor/glslcompletionassist.cpp
index 4fb33ac17e..39ac8b9832 100644
--- a/src/plugins/glsleditor/glslcompletionassist.cpp
+++ b/src/plugins/glsleditor/glslcompletionassist.cpp
@@ -60,13 +60,6 @@ using namespace TextEditor;
namespace GlslEditor {
namespace Internal {
-Document::Document()
- : _engine(0)
- , _ast(0)
- , _globalScope(0)
-{
-}
-
Document::~Document()
{
delete _globalScope;
@@ -211,7 +204,7 @@ bool GlslCompletionAssistProvider::isActivationCharSequence(const QString &seque
struct FunctionItem
{
- FunctionItem() {}
+ FunctionItem() = default;
explicit FunctionItem(const GLSL::Function *function);
QString prettyPrint(int currentArgument) const;
QString returnValue;
@@ -279,7 +272,7 @@ int GlslFunctionHintProposalModel::activeArgument(const QString &prefix) const
const QByteArray &str = prefix.toLatin1();
int argnr = 0;
int parcount = 0;
- GLSL::Lexer lexer(0, str.constData(), str.length());
+ GLSL::Lexer lexer(nullptr, str.constData(), str.length());
GLSL::Token tk;
QList<GLSL::Token> tokens;
do {
@@ -308,16 +301,11 @@ int GlslFunctionHintProposalModel::activeArgument(const QString &prefix) const
// -----------------------------
// GLSLCompletionAssistProcessor
// -----------------------------
-GlslCompletionAssistProcessor::GlslCompletionAssistProcessor()
- : m_startPosition(0)
-{}
-
-GlslCompletionAssistProcessor::~GlslCompletionAssistProcessor()
-{}
+GlslCompletionAssistProcessor::~GlslCompletionAssistProcessor() = default;
static AssistProposalItem *createCompletionItem(const QString &text, const QIcon &icon, int order = 0)
{
- AssistProposalItem *item = new AssistProposalItem;
+ auto item = new AssistProposalItem;
item->setText(text);
item->setIcon(icon);
item->setOrder(order);
@@ -329,7 +317,7 @@ IAssistProposal *GlslCompletionAssistProcessor::perform(const AssistInterface *i
m_interface.reset(static_cast<const GlslCompletionAssistInterface *>(interface));
if (interface->reason() == IdleEditor && !acceptsIdleEditor())
- return 0;
+ return nullptr;
int pos = m_interface->position() - 1;
QChar ch = m_interface->characterAt(pos);
@@ -351,7 +339,7 @@ IAssistProposal *GlslCompletionAssistProcessor::perform(const AssistInterface *i
tc.setPosition(pos);
const int start = expressionUnderCursor.startOfFunctionCall(tc);
if (start == -1)
- return 0;
+ return nullptr;
if (m_interface->characterAt(start) == QLatin1Char('(')) {
pos = start;
@@ -448,7 +436,7 @@ IAssistProposal *GlslCompletionAssistProcessor::perform(const AssistInterface *i
"qt_MultiTexCoord0",
"qt_MultiTexCoord1",
"qt_MultiTexCoord2",
- 0
+ nullptr
};
static const char * const uniformNames[] = {
"qt_ModelViewProjectionMatrix",
@@ -460,7 +448,7 @@ IAssistProposal *GlslCompletionAssistProcessor::perform(const AssistInterface *i
"qt_Texture2",
"qt_Color",
"qt_Opacity",
- 0
+ nullptr
};
for (int index = 0; attributeNames[index]; ++index)
m_completions << createCompletionItem(QString::fromLatin1(attributeNames[index]), glslIcon(IconTypeAttribute));
@@ -542,8 +530,8 @@ bool GlslCompletionAssistProcessor::acceptsIdleEditor() const
const QString word = m_interface->textAt(pos, cursorPosition - pos);
if (word.length() > 2 && checkStartOfIdentifier(word)) {
- for (int i = 0; i < word.length(); ++i) {
- if (! isIdentifierChar(word.at(i)))
+ for (auto character : word) {
+ if (!isIdentifierChar(character))
return false;
}
return true;
diff --git a/src/plugins/glsleditor/glslcompletionassist.h b/src/plugins/glsleditor/glslcompletionassist.h
index d09537fec1..90a09c108a 100644
--- a/src/plugins/glsleditor/glslcompletionassist.h
+++ b/src/plugins/glsleditor/glslcompletionassist.h
@@ -51,9 +51,8 @@ namespace Internal {
class Document
{
public:
- typedef QSharedPointer<Document> Ptr;
+ using Ptr = QSharedPointer<Document>;
- Document();
~Document();
GLSL::Engine *engine() const { return _engine; }
@@ -69,9 +68,9 @@ private:
GLSL::Scope *scope;
};
- GLSL::Engine *_engine;
- GLSL::TranslationUnitAST *_ast;
- GLSL::Scope *_globalScope;
+ GLSL::Engine *_engine = nullptr;
+ GLSL::TranslationUnitAST *_ast = nullptr;
+ GLSL::Scope *_globalScope = nullptr;
QList<Range> _cursors;
friend class GlslEditorWidget;
@@ -93,8 +92,7 @@ public:
class GlslCompletionAssistProcessor : public TextEditor::IAssistProcessor
{
public:
- GlslCompletionAssistProcessor();
- ~GlslCompletionAssistProcessor();
+ ~GlslCompletionAssistProcessor() override;
TextEditor::IAssistProposal *perform(const TextEditor::AssistInterface *interface) override;
@@ -102,7 +100,7 @@ private:
TextEditor::IAssistProposal *createHintProposal(const QVector<GLSL::Function *> &symbols);
bool acceptsIdleEditor() const;
- int m_startPosition;
+ int m_startPosition = 0;
QScopedPointer<const GlslCompletionAssistInterface> m_interface;
};
diff --git a/src/plugins/glsleditor/glsleditor.cpp b/src/plugins/glsleditor/glsleditor.cpp
index 8280c9713e..33a4dafa47 100644
--- a/src/plugins/glsleditor/glsleditor.cpp
+++ b/src/plugins/glsleditor/glsleditor.cpp
@@ -125,14 +125,13 @@ private:
QString wordUnderCursor() const;
QTimer m_updateDocumentTimer;
- QComboBox *m_outlineCombo;
+ QComboBox *m_outlineCombo = nullptr;
Document::Ptr m_glslDocument;
};
GlslEditorWidget::GlslEditorWidget()
{
setAutoCompleter(new GlslCompleter);
- m_outlineCombo = 0;
m_updateDocumentTimer.setInterval(UPDATE_DOCUMENT_DEFAULT_INTERVAL);
m_updateDocumentTimer.setSingleShot(true);
@@ -147,7 +146,7 @@ GlslEditorWidget::GlslEditorWidget()
// ### m_outlineCombo->setModel(m_outlineModel);
- QTreeView *treeView = new QTreeView;
+ auto treeView = new QTreeView;
treeView->header()->hide();
treeView->setItemsExpandable(false);
treeView->setRootIsDecorated(false);
@@ -203,7 +202,7 @@ void GlslEditorWidget::updateDocumentNow()
doc->_engine = new Engine();
Parser parser(doc->_engine, preprocessedCode.constData(), preprocessedCode.size(), variant);
TranslationUnitAST *ast = parser.parse();
- if (ast != 0 || extraSelections(CodeWarningsSelection).isEmpty()) {
+ if (ast || extraSelections(CodeWarningsSelection).isEmpty()) {
Semantic sem;
Scope *globalScope = new Namespace();
doc->_globalScope = globalScope;
diff --git a/src/plugins/glsleditor/glslhighlighter.cpp b/src/plugins/glsleditor/glslhighlighter.cpp
index 1faf60d2c0..417525dac6 100644
--- a/src/plugins/glsleditor/glslhighlighter.cpp
+++ b/src/plugins/glsleditor/glslhighlighter.cpp
@@ -56,7 +56,7 @@ void GlslHighlighter::highlightBlock(const QString &text)
int braceDepth = initialBraceDepth;
const QByteArray data = text.toLatin1();
- GLSL::Lexer lex(/*engine=*/ 0, data.constData(), data.size());
+ GLSL::Lexer lex(/*engine=*/ nullptr, data.constData(), data.size());
lex.setState(state);
lex.setScanKeywords(false);
lex.setScanComments(true);
diff --git a/src/plugins/glsleditor/glslhighlighter.h b/src/plugins/glsleditor/glslhighlighter.h
index 0a8215c0f5..2b29818aca 100644
--- a/src/plugins/glsleditor/glslhighlighter.h
+++ b/src/plugins/glsleditor/glslhighlighter.h
@@ -38,7 +38,7 @@ public:
GlslHighlighter();
protected:
- void highlightBlock(const QString &text);
+ void highlightBlock(const QString &text) override;
void highlightLine(const QString &text, int position, int length, const QTextCharFormat &format);
bool isPPKeyword(const QStringRef &text) const;
};
diff --git a/src/plugins/glsleditor/glslindenter.cpp b/src/plugins/glsleditor/glslindenter.cpp
index a743d815f9..b2c533f1e2 100644
--- a/src/plugins/glsleditor/glslindenter.cpp
+++ b/src/plugins/glsleditor/glslindenter.cpp
@@ -38,11 +38,7 @@
namespace GlslEditor {
namespace Internal {
-GlslIndenter::GlslIndenter()
-{}
-
-GlslIndenter::~GlslIndenter()
-{}
+GlslIndenter::~GlslIndenter() = default;
bool GlslIndenter::isElectricCharacter(const QChar &ch) const
{
diff --git a/src/plugins/glsleditor/glslindenter.h b/src/plugins/glsleditor/glslindenter.h
index b5b55ccd13..75495f8303 100644
--- a/src/plugins/glsleditor/glslindenter.h
+++ b/src/plugins/glsleditor/glslindenter.h
@@ -33,20 +33,19 @@ namespace Internal {
class GlslIndenter : public TextEditor::Indenter
{
public:
- GlslIndenter();
- virtual ~GlslIndenter();
-
- virtual bool isElectricCharacter(const QChar &ch) const override;
- virtual void indentBlock(QTextDocument *doc,
- const QTextBlock &block,
- const QChar &typedChar,
- const TextEditor::TabSettings &tabSettings) override;
-
- virtual void indent(QTextDocument *doc,
- const QTextCursor &cursor,
- const QChar &typedChar,
- const TextEditor::TabSettings &tabSettings,
- bool autoTriggered = true) override;
+ ~GlslIndenter() override;
+
+ bool isElectricCharacter(const QChar &ch) const override;
+ void indentBlock(QTextDocument *doc,
+ const QTextBlock &block,
+ const QChar &typedChar,
+ const TextEditor::TabSettings &tabSettings) override;
+
+ void indent(QTextDocument *doc,
+ const QTextCursor &cursor,
+ const QChar &typedChar,
+ const TextEditor::TabSettings &tabSettings,
+ bool autoTriggered = true) override;
int indentFor(const QTextBlock &block, const TextEditor::TabSettings &tabSettings) override;
TextEditor::IndentationForBlock indentationForBlocks(const QVector<QTextBlock> &blocks,