Skip to content
Snippets Groups Projects
Commit 6b389129 authored by dt's avatar dt
Browse files

Coding style fixes

parent 4d058088
No related branches found
No related tags found
No related merge requests found
......@@ -54,7 +54,6 @@ CMakeEditorEditable::CMakeEditorEditable(CMakeEditor *editor)
Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance();
m_context << uidm->uniqueIdentifier(CMakeProjectManager::Constants::C_CMAKEEDITOR);
m_context << uidm->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR);
// m_contexts << uidm->uniqueIdentifier(Qt4ProjectManager::Constants::PROJECT_KIND);
}
QList<int> CMakeEditorEditable::context() const
......@@ -103,23 +102,21 @@ TextEditor::BaseTextEditorEditable *CMakeEditor::createEditableInterface()
void CMakeEditor::setFontSettings(const TextEditor::FontSettings &fs)
{
// TextEditor::BaseTextEditor::setFontSettings(fs);
// return;
CMakeHighlighter *highlighter = qobject_cast<CMakeHighlighter*>(baseTextDocument()->syntaxHighlighter());
if (!highlighter)
return;
static QVector<QString> categories;
if (categories.isEmpty()) {
categories << QLatin1String(TextEditor::Constants::C_LABEL) // variables
<< QLatin1String(TextEditor::Constants::C_LINK) // functions
<< QLatin1String(TextEditor::Constants::C_COMMENT)
<< QLatin1String(TextEditor::Constants::C_STRING);
}
const QVector<QTextCharFormat> formats = fs.toTextCharFormats(categories);
highlighter->setFormats(formats.constBegin(), formats.constEnd());
highlighter->rehighlight();
CMakeHighlighter *highlighter = qobject_cast<CMakeHighlighter*>(baseTextDocument()->syntaxHighlighter());
if (!highlighter)
return;
static QVector<QString> categories;
if (categories.isEmpty()) {
categories << QLatin1String(TextEditor::Constants::C_LABEL) // variables
<< QLatin1String(TextEditor::Constants::C_LINK) // functions
<< QLatin1String(TextEditor::Constants::C_COMMENT)
<< QLatin1String(TextEditor::Constants::C_STRING);
}
const QVector<QTextCharFormat> formats = fs.toTextCharFormats(categories);
highlighter->setFormats(formats.constBegin(), formats.constEnd());
highlighter->rehighlight();
}
//
......
......@@ -74,7 +74,6 @@ public:
bool save(const QString &fileName = QString());
CMakeEditorFactory *factory() { return m_factory; }
TextEditor::TextEditorActionHandler *actionHandler() const { return m_ah; }
protected:
......
......@@ -39,11 +39,9 @@ using namespace CMakeProjectManager::Internal;
static bool isVariable(const QString &word)
{
if (word.length() < 4) { // must be at least "${.}"
return false;
}
return word.startsWith("${") && word.endsWith('}');
if (word.length() < 4) // must be at least "${.}"
return false;
return word.startsWith("${") && word.endsWith('}');
}
......@@ -65,44 +63,34 @@ void CMakeHighlighter::highlightBlock(const QString &text)
const QChar c = text.at(i);
if (inCommentMode) {
setFormat(i, 1, m_formats[CMakeCommentFormat]);
}
else {
} else {
if (c == '#') {
if (!inStringMode) {
inCommentMode = true;
setFormat(i, 1, m_formats[CMakeCommentFormat]);
buf.clear();
}
else {
} else {
buf += c;
}
}
else if (c == '(') {
} else if (c == '(') {
if (!inStringMode) {
if (!buf.isEmpty()) {
if (!buf.isEmpty())
setFormat(i - buf.length(), buf.length(), m_formats[CMakeFunctionFormat]);
}
buf.clear();
} else {
buf += c;
}
else {
buf += c;
}
}
else if (c.isSpace()) {
if (!inStringMode) {
} else if (c.isSpace()) {
if (!inStringMode)
buf.clear();
}
else {
else
buf += c;
}
}
else if (c == '\"') {
} else if (c == '\"') {
buf += c;
if (inStringMode) {
setFormat(i + 1 - buf.length(), buf.length(), m_formats[CMakeStringFormat]);
buf.clear();
}
else {
} else {
setFormat(i, 1, m_formats[CMakeStringFormat]);
}
inStringMode = !inStringMode;
......@@ -116,24 +104,19 @@ void CMakeHighlighter::highlightBlock(const QString &text)
setFormat(i, 1, emptyFormat);
buf += c;
}
}
else if (c == '$') {
if (inStringMode) {
setFormat(i - buf.length(), buf.length(), m_formats[CMakeStringFormat]);
}
buf.clear();
buf += c;
setFormat(i, 1, emptyFormat);
}
else if (c == '}') {
} else if (c == '$') {
if (inStringMode)
setFormat(i - buf.length(), buf.length(), m_formats[CMakeStringFormat]);
buf.clear();
buf += c;
if (isVariable(buf))
{
setFormat(i, 1, emptyFormat);
} else if (c == '}') {
buf += c;
if (isVariable(buf)) {
setFormat(i + 1 - buf.length(), buf.length(), m_formats[CMakeVariableFormat]);
buf.clear();
}
}
else {
} else {
buf += c;
setFormat(i, 1, emptyFormat);
}
......@@ -143,8 +126,7 @@ void CMakeHighlighter::highlightBlock(const QString &text)
if (inStringMode) {
setFormat(i - buf.length(), buf.length(), m_formats[CMakeStringFormat]);
setCurrentBlockState(1);
}
else {
} else {
setCurrentBlockState(0);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment