forked from qt-creator/qt-creator
QmlJS: improve static initializings
Change-Id: Ifa37c912d0e43bcda896cb0ea851f97566c88d78 Reviewed-by: Marco Benelli <marco.benelli@qt.io>
This commit is contained in:
@@ -30,33 +30,33 @@
|
||||
using namespace QmlJS;
|
||||
|
||||
namespace {
|
||||
QString js_keywords[] = {
|
||||
static const QString js_keywords[] = {
|
||||
QLatin1String("break"),
|
||||
QString::fromLatin1("case"),
|
||||
QString::fromLatin1("catch"),
|
||||
QString::fromLatin1("continue"),
|
||||
QString::fromLatin1("debugger"),
|
||||
QString::fromLatin1("default"),
|
||||
QString::fromLatin1("delete"),
|
||||
QString::fromLatin1("do"),
|
||||
QString::fromLatin1("else"),
|
||||
QString::fromLatin1("finally"),
|
||||
QString::fromLatin1("for"),
|
||||
QString::fromLatin1("function"),
|
||||
QString::fromLatin1("if"),
|
||||
QString::fromLatin1("in"),
|
||||
QString::fromLatin1("instanceof"),
|
||||
QString::fromLatin1("new"),
|
||||
QString::fromLatin1("return"),
|
||||
QString::fromLatin1("switch"),
|
||||
QString::fromLatin1("this"),
|
||||
QString::fromLatin1("throw"),
|
||||
QString::fromLatin1("try"),
|
||||
QString::fromLatin1("typeof"),
|
||||
QString::fromLatin1("var"),
|
||||
QString::fromLatin1("void"),
|
||||
QString::fromLatin1("while"),
|
||||
QString::fromLatin1("with")
|
||||
QLatin1String("case"),
|
||||
QLatin1String("catch"),
|
||||
QLatin1String("continue"),
|
||||
QLatin1String("debugger"),
|
||||
QLatin1String("default"),
|
||||
QLatin1String("delete"),
|
||||
QLatin1String("do"),
|
||||
QLatin1String("else"),
|
||||
QLatin1String("finally"),
|
||||
QLatin1String("for"),
|
||||
QLatin1String("function"),
|
||||
QLatin1String("if"),
|
||||
QLatin1String("in"),
|
||||
QLatin1String("instanceof"),
|
||||
QLatin1String("new"),
|
||||
QLatin1String("return"),
|
||||
QLatin1String("switch"),
|
||||
QLatin1String("this"),
|
||||
QLatin1String("throw"),
|
||||
QLatin1String("try"),
|
||||
QLatin1String("typeof"),
|
||||
QLatin1String("var"),
|
||||
QLatin1String("void"),
|
||||
QLatin1String("while"),
|
||||
QLatin1String("with")
|
||||
};
|
||||
} // end of anonymous namespace
|
||||
|
||||
@@ -417,10 +417,10 @@ bool Scanner::isKeyword(const QString &text) const
|
||||
|
||||
QStringList Scanner::keywords()
|
||||
{
|
||||
static QStringList words;
|
||||
if (words.isEmpty()) {
|
||||
static QStringList words = [&]() {
|
||||
for (const QString *word = begin(js_keywords); word != end(js_keywords); ++word)
|
||||
words.append(*word);
|
||||
}
|
||||
return words;
|
||||
}();
|
||||
return words;
|
||||
}
|
||||
|
||||
@@ -853,17 +853,15 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
|
||||
|
||||
// add qml extra words
|
||||
if (doQmlKeywordCompletion && isQmlFile) {
|
||||
static QStringList qmlWords;
|
||||
static QStringList qmlWordsAlsoInJs;
|
||||
|
||||
if (qmlWords.isEmpty()) {
|
||||
qmlWords << QLatin1String("property")
|
||||
//<< QLatin1String("readonly")
|
||||
<< QLatin1String("signal")
|
||||
<< QLatin1String("import");
|
||||
}
|
||||
if (qmlWordsAlsoInJs.isEmpty())
|
||||
qmlWordsAlsoInJs << QLatin1String("default") << QLatin1String("function");
|
||||
static QStringList qmlWords{
|
||||
QLatin1String("property"),
|
||||
//QLatin1String("readonly")
|
||||
QLatin1String("signal"),
|
||||
QLatin1String("import")
|
||||
};
|
||||
static QStringList qmlWordsAlsoInJs{
|
||||
QLatin1String("default"), QLatin1String("function")
|
||||
};
|
||||
|
||||
addCompletions(&m_completions, qmlWords, m_interface->keywordIcon(), KeywordOrder);
|
||||
if (!doJsKeywordCompletion)
|
||||
|
||||
@@ -42,16 +42,10 @@ QmlJSHighlighter::QmlJSHighlighter(QTextDocument *parent)
|
||||
m_inMultilineComment(false)
|
||||
{
|
||||
m_currentBlockParentheses.reserve(20);
|
||||
static QVector<TextStyle> categories;
|
||||
if (categories.isEmpty()) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user