QmlJSEditor: Modernize

modernize-*

Change-Id: I4dceb82c3904069a0d9848b2af61122d9282cb36
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Alessandro Portale
2018-11-24 02:45:30 +01:00
parent 00ec6dfb5d
commit 5242f58173
36 changed files with 298 additions and 333 deletions

View File

@@ -137,7 +137,7 @@ public:
if (const FunctionValue *func = value->asFunctionValue()) {
// constructors usually also have other interesting members,
// don't consider them pure functions and complete the '()'
if (!func->lookupMember(QLatin1String("prototype"), 0, 0, false))
if (!func->lookupMember(QLatin1String("prototype"), nullptr, nullptr, false))
data = QVariant::fromValue(CompleteFunctionCall(func->namedArgumentCount() || func->isVariadic()));
}
addCompletion(completions, name, icon, order, data);
@@ -184,21 +184,16 @@ public:
class ProcessProperties: private MemberProcessor
{
QSet<const ObjectValue *> _processed;
bool _globalCompletion;
bool _enumerateGeneratedSlots;
bool _enumerateSlots;
bool _globalCompletion = false;
bool _enumerateGeneratedSlots = false;
bool _enumerateSlots = true;
const ScopeChain *_scopeChain;
const ObjectValue *_currentObject;
PropertyProcessor *_propertyProcessor;
const ObjectValue *_currentObject = nullptr;
PropertyProcessor *_propertyProcessor = nullptr;
public:
ProcessProperties(const ScopeChain *scopeChain)
: _globalCompletion(false),
_enumerateGeneratedSlots(false),
_enumerateSlots(true),
_scopeChain(scopeChain),
_currentObject(0),
_propertyProcessor(0)
: _scopeChain(scopeChain)
{
}
@@ -294,7 +289,7 @@ private:
_currentObject = object;
object->processMembers(this);
_currentObject = 0;
_currentObject = nullptr;
}
};
@@ -303,16 +298,16 @@ const Value *getPropertyValue(const ObjectValue *object,
const ContextPtr &context)
{
if (propertyNames.isEmpty() || !object)
return 0;
return nullptr;
const Value *value = object;
foreach (const QString &name, propertyNames) {
if (const ObjectValue *objectValue = value->asObjectValue()) {
value = objectValue->lookupMember(name, context);
if (!value)
return 0;
return nullptr;
} else {
return 0;
return nullptr;
}
}
return value;
@@ -486,8 +481,7 @@ int FunctionHintProposalModel::activeArgument(const QString &prefix) const
int parcount = 0;
Scanner tokenize;
const QList<Token> tokens = tokenize(prefix);
for (int i = 0; i < tokens.count(); ++i) {
const Token &tk = tokens.at(i);
for (auto &tk : tokens) {
if (tk.is(Token::LeftParenthesis))
++parcount;
else if (tk.is(Token::RightParenthesis))
@@ -533,8 +527,7 @@ QmlJSCompletionAssistProcessor::QmlJSCompletionAssistProcessor()
, m_snippetCollector(QLatin1String(Constants::QML_SNIPPETS_GROUP_ID), iconForColor(Qt::red), SnippetOrder)
{}
QmlJSCompletionAssistProcessor::~QmlJSCompletionAssistProcessor()
{}
QmlJSCompletionAssistProcessor::~QmlJSCompletionAssistProcessor() = default;
IAssistProposal *QmlJSCompletionAssistProcessor::createContentProposal() const
{
@@ -556,7 +549,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
m_interface.reset(static_cast<const QmlJSCompletionAssistInterface *>(assistInterface));
if (assistInterface->reason() == IdleEditor && !acceptsIdleEditor())
return 0;
return nullptr;
const QString &fileName = m_interface->fileName();
@@ -567,11 +560,10 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
m_completions.clear();
const QmlJSCompletionAssistInterface *qmlInterface =
static_cast<const QmlJSCompletionAssistInterface *>(assistInterface);
auto qmlInterface = static_cast<const QmlJSCompletionAssistInterface *>(assistInterface);
const SemanticInfo &semanticInfo = qmlInterface->semanticInfo();
if (!semanticInfo.isValid())
return 0;
return nullptr;
const Document::Ptr document = semanticInfo.document;
const QFileInfo currentFileInfo(fileName);
@@ -597,7 +589,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
startPositionCursor.setPosition(m_startPosition);
CompletionContextFinder contextFinder(startPositionCursor);
const ObjectValue *qmlScopeType = 0;
const ObjectValue *qmlScopeType = nullptr;
if (contextFinder.isInQmlContext()) {
// find the enclosing qml object
// ### this should use semanticInfo.declaringMember instead, but that may also return functions
@@ -612,13 +604,13 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
}
// grouped property bindings change the scope type
for (i++; i < path.size(); ++i) {
AST::UiObjectDefinition *objDef = AST::cast<AST::UiObjectDefinition *>(path[i]);
auto objDef = AST::cast<AST::UiObjectDefinition *>(path[i]);
if (!objDef || !document->bind()->isGroupedPropertyBinding(objDef))
break;
const ObjectValue *newScopeType = qmlScopeType;
for (AST::UiQualifiedId *it = objDef->qualifiedTypeNameId; it; it = it->next) {
if (!newScopeType || it->name.isEmpty()) {
newScopeType = 0;
newScopeType = nullptr;
break;
}
const Value *v = newScopeType->lookupMember(it->name.toString(), context);
@@ -648,7 +640,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
if (!literalText.isEmpty()
&& literalText.at(0) != QLatin1Char('"')
&& literalText.at(0) != QLatin1Char('\'')) {
return 0;
return nullptr;
}
literalText = literalText.mid(1);
@@ -658,7 +650,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
patterns << QLatin1String("*.qml") << QLatin1String("*.js");
if (completeFileName(document->path(), literalText, patterns))
return createContentProposal();
return 0;
return nullptr;
}
const Value *value =
@@ -672,7 +664,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
// ### enum completion?
return 0;
return nullptr;
}
// currently path-in-stringliteral is the only completion available in imports
@@ -705,7 +697,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
return createContentProposal();
}
}
return 0;
return nullptr;
}
// member "a.bc<complete>" or function "foo(<complete>" completion
@@ -719,7 +711,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
QmlExpressionUnderCursor expressionUnderCursor;
AST::ExpressionNode *expression = expressionUnderCursor(tc);
if (expression != 0 && ! isLiteral(expression)) {
if (expression && ! isLiteral(expression)) {
// Evaluate the expression under cursor.
ValueOwner *interp = context->valueOwner();
const Value *value =
@@ -759,7 +751,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
if (! m_completions.isEmpty())
return createContentProposal();
return 0;
return nullptr;
}
// global completion
@@ -866,10 +858,10 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
if (! m_completions.isEmpty())
return createContentProposal();
return 0;
return nullptr;
}
return 0;
return nullptr;
}
bool QmlJSCompletionAssistProcessor::acceptsIdleEditor() const