forked from qt-creator/qt-creator
improve static initializers
Change-Id: I304fdd6627f01fc216c84930da607127c52409d9 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -42,21 +42,20 @@ using namespace CPlusPlus;
|
||||
CppHighlighter::CppHighlighter(QTextDocument *document) :
|
||||
SyntaxHighlighter(document)
|
||||
{
|
||||
static QVector<TextStyle> categories;
|
||||
if (categories.isEmpty()) {
|
||||
categories << C_NUMBER
|
||||
<< C_STRING
|
||||
<< C_TYPE
|
||||
<< C_KEYWORD
|
||||
<< C_PRIMITIVE_TYPE
|
||||
<< C_OPERATOR
|
||||
<< C_PREPROCESSOR
|
||||
<< C_LABEL
|
||||
<< C_COMMENT
|
||||
<< C_DOXYGEN_COMMENT
|
||||
<< C_DOXYGEN_TAG
|
||||
<< C_VISUAL_WHITESPACE;
|
||||
}
|
||||
static const QVector<TextStyle> categories({
|
||||
C_NUMBER,
|
||||
C_STRING,
|
||||
C_TYPE,
|
||||
C_KEYWORD,
|
||||
C_PRIMITIVE_TYPE,
|
||||
C_OPERATOR,
|
||||
C_PREPROCESSOR,
|
||||
C_LABEL,
|
||||
C_COMMENT,
|
||||
C_DOXYGEN_COMMENT,
|
||||
C_DOXYGEN_TAG,
|
||||
C_VISUAL_WHITESPACE
|
||||
});
|
||||
setTextFormatCategories(categories);
|
||||
}
|
||||
|
||||
|
@@ -37,9 +37,7 @@ static const char CHANGE_PATTERN[] = "\\b[a-f0-9]{7,40}\\b";
|
||||
GitSubmitHighlighter::GitSubmitHighlighter(QTextEdit * parent) :
|
||||
TextEditor::SyntaxHighlighter(parent)
|
||||
{
|
||||
static QVector<TextEditor::TextStyle> categories;
|
||||
if (categories.isEmpty())
|
||||
categories << TextEditor::C_COMMENT;
|
||||
static const QVector<TextEditor::TextStyle> categories({TextEditor::C_COMMENT});
|
||||
|
||||
setTextFormatCategories(categories);
|
||||
m_keywordPattern.setPattern("^[\\w-]+:");
|
||||
@@ -98,18 +96,17 @@ GitRebaseHighlighter::GitRebaseHighlighter(QTextDocument *parent) :
|
||||
m_hashChar('#'),
|
||||
m_changeNumberPattern(CHANGE_PATTERN)
|
||||
{
|
||||
static QVector<TextEditor::TextStyle> categories;
|
||||
if (categories.isEmpty()) {
|
||||
categories << TextEditor::C_COMMENT
|
||||
<< TextEditor::C_DOXYGEN_COMMENT
|
||||
<< TextEditor::C_STRING
|
||||
<< TextEditor::C_KEYWORD
|
||||
<< TextEditor::C_FIELD
|
||||
<< TextEditor::C_TYPE
|
||||
<< TextEditor::C_ENUMERATION
|
||||
<< TextEditor::C_NUMBER
|
||||
<< TextEditor::C_LABEL;
|
||||
}
|
||||
static const QVector<TextEditor::TextStyle> categories({
|
||||
TextEditor::C_COMMENT,
|
||||
TextEditor::C_DOXYGEN_COMMENT,
|
||||
TextEditor::C_STRING,
|
||||
TextEditor::C_KEYWORD,
|
||||
TextEditor::C_FIELD,
|
||||
TextEditor::C_TYPE,
|
||||
TextEditor::C_ENUMERATION,
|
||||
TextEditor::C_NUMBER,
|
||||
TextEditor::C_LABEL
|
||||
});
|
||||
setTextFormatCategories(categories);
|
||||
|
||||
m_actions << RebaseAction("^(p|pick)\\b", Format_Pick);
|
||||
|
@@ -39,21 +39,20 @@ namespace Internal {
|
||||
|
||||
GlslHighlighter::GlslHighlighter()
|
||||
{
|
||||
static QVector<TextStyle> categories;
|
||||
if (categories.isEmpty()) {
|
||||
categories << C_NUMBER
|
||||
<< C_STRING
|
||||
<< C_TYPE
|
||||
<< C_KEYWORD
|
||||
<< C_OPERATOR
|
||||
<< C_PREPROCESSOR
|
||||
<< C_LABEL
|
||||
<< C_COMMENT
|
||||
<< C_DOXYGEN_COMMENT
|
||||
<< C_DOXYGEN_TAG
|
||||
<< C_VISUAL_WHITESPACE
|
||||
<< C_REMOVED_LINE;
|
||||
}
|
||||
static const QVector<TextStyle> categories({
|
||||
C_NUMBER,
|
||||
C_STRING,
|
||||
C_TYPE,
|
||||
C_KEYWORD,
|
||||
C_OPERATOR,
|
||||
C_PREPROCESSOR,
|
||||
C_LABEL,
|
||||
C_COMMENT,
|
||||
C_DOXYGEN_COMMENT,
|
||||
C_DOXYGEN_TAG,
|
||||
C_VISUAL_WHITESPACE,
|
||||
C_REMOVED_LINE
|
||||
});
|
||||
setTextFormatCategories(categories);
|
||||
}
|
||||
|
||||
|
@@ -157,17 +157,12 @@ void SearchWidget::showEvent(QShowEvent *event)
|
||||
|
||||
void SearchWidget::search() const
|
||||
{
|
||||
static QStringList charsToEscapeList;
|
||||
if (charsToEscapeList.isEmpty()) {
|
||||
charsToEscapeList << "\\" << "+"
|
||||
<< "-" << "!" << "("
|
||||
<< ")" << ":" << "^"
|
||||
<< "[" << "]" << "{"
|
||||
<< "}" << "~";
|
||||
}
|
||||
static const QStringList charsToEscapeList({
|
||||
"\\", "+", "-", "!", "(", ")", ":", "^", "[", "]", "{", "}", "~"
|
||||
});
|
||||
|
||||
static QString escapeChar("\\");
|
||||
static QRegExp regExp("[\\+\\-\\!\\(\\)\\^\\[\\]\\{\\}~:]");
|
||||
static const QString escapeChar("\\");
|
||||
static const QRegExp regExp("[\\+\\-\\!\\(\\)\\^\\[\\]\\{\\}~:]");
|
||||
|
||||
QList<QHelpSearchQuery> escapedQueries;
|
||||
const QList<QHelpSearchQuery> queries = searchEngine->queryWidget()->query();
|
||||
|
@@ -60,9 +60,7 @@ MercurialSubmitHighlighter::MercurialSubmitHighlighter(QTextEdit *parent) :
|
||||
TextEditor::SyntaxHighlighter(parent),
|
||||
m_keywordPattern(QLatin1String("^\\w+:"))
|
||||
{
|
||||
static QVector<TextEditor::TextStyle> categories;
|
||||
if (categories.isEmpty())
|
||||
categories << TextEditor::C_COMMENT;
|
||||
static const QVector<TextEditor::TextStyle> categories({TextEditor::C_COMMENT});
|
||||
|
||||
setTextFormatCategories(categories);
|
||||
QTC_CHECK(m_keywordPattern.isValid());
|
||||
|
@@ -280,8 +280,8 @@ bool AbstractMsvcToolChain::generateEnvironmentSettings(Utils::Environment &env,
|
||||
if (cmdPath.isEmpty())
|
||||
cmdPath = env.searchInPath(QLatin1String("cmd.exe"));
|
||||
// Windows SDK setup scripts require command line switches for environment expansion.
|
||||
QStringList cmdArguments;
|
||||
cmdArguments << QLatin1String("/E:ON") << QLatin1String("/V:ON") << QLatin1String("/c");
|
||||
QStringList cmdArguments({
|
||||
QLatin1String("/E:ON"), QLatin1String("/V:ON"), QLatin1String("/c")});
|
||||
cmdArguments << QDir::toNativeSeparators(saver.fileName());
|
||||
if (debug)
|
||||
qDebug() << "readEnvironmentSetting: " << call << cmdPath << cmdArguments.join(' ')
|
||||
|
@@ -1868,23 +1868,19 @@ static const char * const varExpandedKeys[] = {
|
||||
// Translate old-style ${} var expansions into new-style %{} ones
|
||||
static QVariant version8VarNodeTransform(const QVariant &var)
|
||||
{
|
||||
static const char * const vars[] = {
|
||||
"absoluteFilePath",
|
||||
"absolutePath",
|
||||
"baseName",
|
||||
"canonicalPath",
|
||||
"canonicalFilePath",
|
||||
"completeBaseName",
|
||||
"completeSuffix",
|
||||
"fileName",
|
||||
"filePath",
|
||||
"path",
|
||||
"suffix"
|
||||
};
|
||||
static QSet<QString> map;
|
||||
if (map.isEmpty())
|
||||
for (unsigned i = 0; i < sizeof(vars)/sizeof(vars[0]); ++i)
|
||||
map.insert(QLatin1String("CURRENT_DOCUMENT:") + QLatin1String(vars[i]));
|
||||
static const QSet<QString> map({
|
||||
"CURRENT_DOCUMENT:absoluteFilePath",
|
||||
"CURRENT_DOCUMENT:absolutePath",
|
||||
"CURRENT_DOCUMENT:baseName",
|
||||
"CURRENT_DOCUMENT:canonicalPath",
|
||||
"CURRENT_DOCUMENT:canonicalFilePath",
|
||||
"CURRENT_DOCUMENT:completeBaseName",
|
||||
"CURRENT_DOCUMENT:completeSuffix",
|
||||
"CURRENT_DOCUMENT:fileName",
|
||||
"CURRENT_DOCUMENT:filePath",
|
||||
"CURRENT_DOCUMENT:path",
|
||||
"CURRENT_DOCUMENT:suffix"
|
||||
});
|
||||
|
||||
QString str = var.toString();
|
||||
int pos = 0;
|
||||
|
@@ -38,9 +38,7 @@ namespace Internal {
|
||||
ProFileHighlighter::ProFileHighlighter(const Keywords &keywords)
|
||||
: m_keywords(keywords)
|
||||
{
|
||||
static QVector<TextStyle> categories;
|
||||
if (categories.isEmpty())
|
||||
categories << C_TYPE << C_KEYWORD << C_COMMENT << C_VISUAL_WHITESPACE;
|
||||
static const QVector<TextStyle> categories({C_TYPE, C_KEYWORD, C_COMMENT, C_VISUAL_WHITESPACE});
|
||||
setTextFormatCategories(categories);
|
||||
}
|
||||
|
||||
|
@@ -71,37 +71,33 @@ static inline bool isSupportedAttachedProperties(const QString &propertyName)
|
||||
static inline QStringList supportedVersionsList()
|
||||
{
|
||||
static const QStringList list = {
|
||||
QStringLiteral("2.0"), QStringLiteral("2.1"),
|
||||
QStringLiteral("2.2"), QStringLiteral("2.3"),
|
||||
QStringLiteral("2.4"), QStringLiteral("2.5"),
|
||||
QStringLiteral("2.6"), QStringLiteral("2.7"),
|
||||
QStringLiteral("2.8")
|
||||
"2.0", "2.1", "2.2", "2.3", "2.4", "2.5", "2.6", "2.7", "2.8"
|
||||
};
|
||||
return list;
|
||||
}
|
||||
|
||||
static inline QStringList globalQtEnums()
|
||||
{
|
||||
static QStringList list = QStringList() << QStringLiteral("Horizontal") << QStringLiteral("Vertical") << QStringLiteral("AlignVCenter")
|
||||
<< QStringLiteral("AlignLeft") << QStringLiteral("LeftToRight") << QStringLiteral("RightToLeft") << QStringLiteral("AlignHCenter")
|
||||
<< QStringLiteral("AlignRight") << QStringLiteral("AlignBottom") << QStringLiteral("AlignBaseline") << QStringLiteral("AlignTop")
|
||||
<< QStringLiteral("BottomLeft") << QStringLiteral("LeftEdge") << QStringLiteral("RightEdge") << QStringLiteral("BottomEdge");
|
||||
static const QStringList list = {
|
||||
"Horizontal", "Vertical", "AlignVCenter", "AlignLeft", "LeftToRight", "RightToLeft",
|
||||
"AlignHCenter", "AlignRight", "AlignBottom", "AlignBaseline", "AlignTop", "BottomLeft",
|
||||
"LeftEdge", "RightEdge", "BottomEdge"
|
||||
};
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static inline QStringList knownEnumScopes()
|
||||
{
|
||||
static QStringList list = QStringList() << QStringLiteral("TextInput") << QStringLiteral("TextEdit")
|
||||
<< QStringLiteral("Material") << QStringLiteral("Universal") ;;
|
||||
static const QStringList list = {
|
||||
"TextInput", "TextEdit", "Material", "Universal"
|
||||
};
|
||||
return list;
|
||||
}
|
||||
|
||||
static inline bool supportedQtQuickVersion(const QString &version)
|
||||
{
|
||||
static QStringList supportedVersions = supportedVersionsList();
|
||||
|
||||
return supportedVersions.contains(version);
|
||||
return supportedVersionsList().contains(version);
|
||||
}
|
||||
|
||||
static inline QString stripQuotes(const QString &str)
|
||||
|
@@ -142,7 +142,7 @@ void DocumentWarningWidget::refreshContent()
|
||||
|
||||
QString DocumentWarningWidget::generateNavigateLinks()
|
||||
{
|
||||
static QString link(QLatin1String("<a href=\"%1\">%2</a>"));
|
||||
static const QString link("<a href=\"%1\">%2</a>");
|
||||
QStringList links;
|
||||
if (m_messages.count() > 1) {
|
||||
if (m_currentMessage != 0)
|
||||
|
@@ -247,7 +247,7 @@ static void drawCubicSegments(const QList<CubicSegment> &cubicSegments, QPainter
|
||||
|
||||
static void drawControlLine(const CubicSegment &cubicSegment, QPainter *painter)
|
||||
{
|
||||
static QPen solidPen(QColor(104, 183, 214), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
|
||||
static const QPen solidPen(QColor(104, 183, 214), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
|
||||
painter->setPen(solidPen);
|
||||
painter->drawLine(cubicSegment.firstControlPoint().coordinate(),
|
||||
cubicSegment.secondControlPoint().coordinate());
|
||||
@@ -281,9 +281,9 @@ static QRectF controlPointShape(-2, -2, 5, 5);
|
||||
|
||||
static void drawControlPoint(const ControlPoint &controlPoint, const QList<ControlPoint> &selectionPoints, QPainter *painter)
|
||||
{
|
||||
static QColor editPointColor(0, 110, 255);
|
||||
static QColor controlVertexColor(0, 110, 255);
|
||||
static QColor selectionPointColor(0, 255, 0);
|
||||
static const QColor editPointColor(0, 110, 255);
|
||||
static const QColor controlVertexColor(0, 110, 255);
|
||||
static const QColor selectionPointColor(0, 255, 0);
|
||||
|
||||
double originX = controlPoint.coordinate().x();
|
||||
double originY = controlPoint.coordinate().y();
|
||||
|
@@ -42,10 +42,9 @@ QmlJSHighlighter::QmlJSHighlighter(QTextDocument *parent)
|
||||
m_inMultilineComment(false)
|
||||
{
|
||||
m_currentBlockParentheses.reserve(20);
|
||||
static const QVector<TextStyle> categories{
|
||||
C_NUMBER, C_STRING, C_TYPE,
|
||||
C_KEYWORD, C_FIELD, C_COMMENT,
|
||||
C_VISUAL_WHITESPACE};
|
||||
static const QVector<TextStyle> categories({
|
||||
C_NUMBER, C_STRING, C_TYPE, C_KEYWORD, C_FIELD, C_COMMENT, C_VISUAL_WHITESPACE
|
||||
});
|
||||
setTextFormatCategories(categories);
|
||||
}
|
||||
|
||||
|
@@ -85,37 +85,36 @@ Highlighter::Highlighter(QTextDocument *parent) :
|
||||
m_dynamicContextsCounter(0),
|
||||
m_isBroken(false)
|
||||
{
|
||||
static QVector<TextStyle> categories;
|
||||
if (categories.isEmpty()) {
|
||||
categories << C_TEXT // Normal
|
||||
<< C_VISUAL_WHITESPACE // VisualWhitespace
|
||||
<< C_KEYWORD // Keyword
|
||||
<< C_TYPE // DataType
|
||||
<< C_COMMENT // Comment
|
||||
<< C_NUMBER // Decimal
|
||||
<< C_NUMBER // BaseN
|
||||
<< C_NUMBER // Float
|
||||
<< C_STRING // Char
|
||||
<< C_STRING // SpecialChar
|
||||
<< C_STRING // String
|
||||
<< C_WARNING // Alert
|
||||
<< C_TEXT // Information
|
||||
<< C_WARNING // Warning
|
||||
<< C_ERROR // Error
|
||||
<< C_FUNCTION // Function
|
||||
<< C_TEXT // RegionMarker
|
||||
<< C_PREPROCESSOR // BuiltIn
|
||||
<< C_PRIMITIVE_TYPE // Extension
|
||||
<< C_OPERATOR // Operator
|
||||
<< C_LOCAL // Variable
|
||||
<< C_LABEL // Attribute
|
||||
<< C_TEXT // Annotation
|
||||
<< C_COMMENT // CommentVar
|
||||
<< C_PREPROCESSOR // Import
|
||||
<< C_TEXT // Others
|
||||
<< C_LOCAL // Identifier
|
||||
<< C_DOXYGEN_COMMENT; // Documentation
|
||||
}
|
||||
static const QVector<TextStyle> categories({
|
||||
C_TEXT, // Normal
|
||||
C_VISUAL_WHITESPACE, // VisualWhitespace
|
||||
C_KEYWORD, // Keyword
|
||||
C_TYPE, // DataType
|
||||
C_COMMENT, // Comment
|
||||
C_NUMBER, // Decimal
|
||||
C_NUMBER, // BaseN
|
||||
C_NUMBER, // Float
|
||||
C_STRING, // Char
|
||||
C_STRING, // SpecialChar
|
||||
C_STRING, // String
|
||||
C_WARNING, // Alert
|
||||
C_TEXT, // Information
|
||||
C_WARNING, // Warning
|
||||
C_ERROR, // Error
|
||||
C_FUNCTION, // Function
|
||||
C_TEXT, // RegionMarker
|
||||
C_PREPROCESSOR, // BuiltIn
|
||||
C_PRIMITIVE_TYPE, // Extension
|
||||
C_OPERATOR, // Operator
|
||||
C_LOCAL, // Variable
|
||||
C_LABEL, // Attribute
|
||||
C_TEXT, // Annotation
|
||||
C_COMMENT, // CommentVar
|
||||
C_PREPROCESSOR, // Import
|
||||
C_TEXT, // Others
|
||||
C_LOCAL, // Identifier
|
||||
C_DOXYGEN_COMMENT // Documentation
|
||||
});
|
||||
|
||||
setTextFormatCategories(categories);
|
||||
}
|
||||
|
@@ -76,9 +76,7 @@ BaseAnnotationHighlighter::BaseAnnotationHighlighter(const ChangeNumbers &change
|
||||
TextEditor::SyntaxHighlighter(document),
|
||||
d(new BaseAnnotationHighlighterPrivate(this))
|
||||
{
|
||||
static QVector<TextEditor::TextStyle> categories;
|
||||
if (categories.isEmpty())
|
||||
categories << TextEditor::C_TEXT;
|
||||
static const QVector<TextEditor::TextStyle> categories({TextEditor::C_TEXT});
|
||||
|
||||
setTextFormatCategories(categories);
|
||||
d->updateOtherFormats();
|
||||
|
@@ -155,15 +155,14 @@ DiffAndLogHighlighter::DiffAndLogHighlighter(const QRegExp &filePattern, const Q
|
||||
TextEditor::SyntaxHighlighter(static_cast<QTextDocument *>(0)),
|
||||
d(new DiffAndLogHighlighterPrivate(this, filePattern, changePattern))
|
||||
{
|
||||
static QVector<TextEditor::TextStyle> categories;
|
||||
if (categories.isEmpty()) {
|
||||
categories << TextEditor::C_TEXT
|
||||
<< TextEditor::C_ADDED_LINE
|
||||
<< TextEditor::C_REMOVED_LINE
|
||||
<< TextEditor::C_DIFF_FILE
|
||||
<< TextEditor::C_DIFF_LOCATION
|
||||
<< TextEditor::C_LOG_CHANGE_LINE;
|
||||
}
|
||||
static const QVector<TextEditor::TextStyle> categories({
|
||||
TextEditor::C_TEXT,
|
||||
TextEditor::C_ADDED_LINE,
|
||||
TextEditor::C_REMOVED_LINE,
|
||||
TextEditor::C_DIFF_FILE,
|
||||
TextEditor::C_DIFF_LOCATION,
|
||||
TextEditor::C_LOG_CHANGE_LINE
|
||||
});
|
||||
setTextFormatCategories(categories);
|
||||
d->updateOtherFormats();
|
||||
}
|
||||
|
Reference in New Issue
Block a user