forked from qt-creator/qt-creator
QmlJSEditor: Modernize
modernize-* Change-Id: I4dceb82c3904069a0d9848b2af61122d9282cb36 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -43,11 +43,8 @@ class ExpressionUnderCursor
|
|||||||
Scanner scanner;
|
Scanner scanner;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ExpressionUnderCursor()
|
int start = 0;
|
||||||
: start(0), end(0)
|
int end = 0;
|
||||||
{}
|
|
||||||
|
|
||||||
int start, end;
|
|
||||||
|
|
||||||
int startState(const QTextBlock &block) const
|
int startState(const QTextBlock &block) const
|
||||||
{
|
{
|
||||||
@@ -117,12 +114,12 @@ using namespace QmlJSEditor;
|
|||||||
using namespace QmlJSEditor::Internal;
|
using namespace QmlJSEditor::Internal;
|
||||||
|
|
||||||
QmlExpressionUnderCursor::QmlExpressionUnderCursor()
|
QmlExpressionUnderCursor::QmlExpressionUnderCursor()
|
||||||
: _expressionNode(0), _expressionOffset(0), _expressionLength(0)
|
: _expressionNode(nullptr), _expressionOffset(0), _expressionLength(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
ExpressionNode *QmlExpressionUnderCursor::operator()(const QTextCursor &cursor)
|
ExpressionNode *QmlExpressionUnderCursor::operator()(const QTextCursor &cursor)
|
||||||
{
|
{
|
||||||
_expressionNode = 0;
|
_expressionNode = nullptr;
|
||||||
_expressionOffset = -1;
|
_expressionOffset = -1;
|
||||||
_expressionLength = -1;
|
_expressionLength = -1;
|
||||||
|
|
||||||
|
@@ -133,11 +133,9 @@ static bool isCompleteStringLiteral(const QStringRef &text)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoCompleter::AutoCompleter()
|
AutoCompleter::AutoCompleter() = default;
|
||||||
{}
|
|
||||||
|
|
||||||
AutoCompleter::~AutoCompleter()
|
AutoCompleter::~AutoCompleter() = default;
|
||||||
{}
|
|
||||||
|
|
||||||
bool AutoCompleter::contextAllowsAutoBrackets(const QTextCursor &cursor,
|
bool AutoCompleter::contextAllowsAutoBrackets(const QTextCursor &cursor,
|
||||||
const QString &textToInsert) const
|
const QString &textToInsert) const
|
||||||
|
@@ -137,7 +137,7 @@ public:
|
|||||||
if (const FunctionValue *func = value->asFunctionValue()) {
|
if (const FunctionValue *func = value->asFunctionValue()) {
|
||||||
// constructors usually also have other interesting members,
|
// constructors usually also have other interesting members,
|
||||||
// don't consider them pure functions and complete the '()'
|
// 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()));
|
data = QVariant::fromValue(CompleteFunctionCall(func->namedArgumentCount() || func->isVariadic()));
|
||||||
}
|
}
|
||||||
addCompletion(completions, name, icon, order, data);
|
addCompletion(completions, name, icon, order, data);
|
||||||
@@ -184,21 +184,16 @@ public:
|
|||||||
class ProcessProperties: private MemberProcessor
|
class ProcessProperties: private MemberProcessor
|
||||||
{
|
{
|
||||||
QSet<const ObjectValue *> _processed;
|
QSet<const ObjectValue *> _processed;
|
||||||
bool _globalCompletion;
|
bool _globalCompletion = false;
|
||||||
bool _enumerateGeneratedSlots;
|
bool _enumerateGeneratedSlots = false;
|
||||||
bool _enumerateSlots;
|
bool _enumerateSlots = true;
|
||||||
const ScopeChain *_scopeChain;
|
const ScopeChain *_scopeChain;
|
||||||
const ObjectValue *_currentObject;
|
const ObjectValue *_currentObject = nullptr;
|
||||||
PropertyProcessor *_propertyProcessor;
|
PropertyProcessor *_propertyProcessor = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ProcessProperties(const ScopeChain *scopeChain)
|
ProcessProperties(const ScopeChain *scopeChain)
|
||||||
: _globalCompletion(false),
|
: _scopeChain(scopeChain)
|
||||||
_enumerateGeneratedSlots(false),
|
|
||||||
_enumerateSlots(true),
|
|
||||||
_scopeChain(scopeChain),
|
|
||||||
_currentObject(0),
|
|
||||||
_propertyProcessor(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,7 +289,7 @@ private:
|
|||||||
|
|
||||||
_currentObject = object;
|
_currentObject = object;
|
||||||
object->processMembers(this);
|
object->processMembers(this);
|
||||||
_currentObject = 0;
|
_currentObject = nullptr;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -303,16 +298,16 @@ const Value *getPropertyValue(const ObjectValue *object,
|
|||||||
const ContextPtr &context)
|
const ContextPtr &context)
|
||||||
{
|
{
|
||||||
if (propertyNames.isEmpty() || !object)
|
if (propertyNames.isEmpty() || !object)
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
const Value *value = object;
|
const Value *value = object;
|
||||||
foreach (const QString &name, propertyNames) {
|
foreach (const QString &name, propertyNames) {
|
||||||
if (const ObjectValue *objectValue = value->asObjectValue()) {
|
if (const ObjectValue *objectValue = value->asObjectValue()) {
|
||||||
value = objectValue->lookupMember(name, context);
|
value = objectValue->lookupMember(name, context);
|
||||||
if (!value)
|
if (!value)
|
||||||
return 0;
|
return nullptr;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
@@ -486,8 +481,7 @@ int FunctionHintProposalModel::activeArgument(const QString &prefix) const
|
|||||||
int parcount = 0;
|
int parcount = 0;
|
||||||
Scanner tokenize;
|
Scanner tokenize;
|
||||||
const QList<Token> tokens = tokenize(prefix);
|
const QList<Token> tokens = tokenize(prefix);
|
||||||
for (int i = 0; i < tokens.count(); ++i) {
|
for (auto &tk : tokens) {
|
||||||
const Token &tk = tokens.at(i);
|
|
||||||
if (tk.is(Token::LeftParenthesis))
|
if (tk.is(Token::LeftParenthesis))
|
||||||
++parcount;
|
++parcount;
|
||||||
else if (tk.is(Token::RightParenthesis))
|
else if (tk.is(Token::RightParenthesis))
|
||||||
@@ -533,8 +527,7 @@ QmlJSCompletionAssistProcessor::QmlJSCompletionAssistProcessor()
|
|||||||
, m_snippetCollector(QLatin1String(Constants::QML_SNIPPETS_GROUP_ID), iconForColor(Qt::red), SnippetOrder)
|
, m_snippetCollector(QLatin1String(Constants::QML_SNIPPETS_GROUP_ID), iconForColor(Qt::red), SnippetOrder)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QmlJSCompletionAssistProcessor::~QmlJSCompletionAssistProcessor()
|
QmlJSCompletionAssistProcessor::~QmlJSCompletionAssistProcessor() = default;
|
||||||
{}
|
|
||||||
|
|
||||||
IAssistProposal *QmlJSCompletionAssistProcessor::createContentProposal() const
|
IAssistProposal *QmlJSCompletionAssistProcessor::createContentProposal() const
|
||||||
{
|
{
|
||||||
@@ -556,7 +549,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
|
|||||||
m_interface.reset(static_cast<const QmlJSCompletionAssistInterface *>(assistInterface));
|
m_interface.reset(static_cast<const QmlJSCompletionAssistInterface *>(assistInterface));
|
||||||
|
|
||||||
if (assistInterface->reason() == IdleEditor && !acceptsIdleEditor())
|
if (assistInterface->reason() == IdleEditor && !acceptsIdleEditor())
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
const QString &fileName = m_interface->fileName();
|
const QString &fileName = m_interface->fileName();
|
||||||
|
|
||||||
@@ -567,11 +560,10 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
|
|||||||
|
|
||||||
m_completions.clear();
|
m_completions.clear();
|
||||||
|
|
||||||
const QmlJSCompletionAssistInterface *qmlInterface =
|
auto qmlInterface = static_cast<const QmlJSCompletionAssistInterface *>(assistInterface);
|
||||||
static_cast<const QmlJSCompletionAssistInterface *>(assistInterface);
|
|
||||||
const SemanticInfo &semanticInfo = qmlInterface->semanticInfo();
|
const SemanticInfo &semanticInfo = qmlInterface->semanticInfo();
|
||||||
if (!semanticInfo.isValid())
|
if (!semanticInfo.isValid())
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
const Document::Ptr document = semanticInfo.document;
|
const Document::Ptr document = semanticInfo.document;
|
||||||
const QFileInfo currentFileInfo(fileName);
|
const QFileInfo currentFileInfo(fileName);
|
||||||
@@ -597,7 +589,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
|
|||||||
startPositionCursor.setPosition(m_startPosition);
|
startPositionCursor.setPosition(m_startPosition);
|
||||||
CompletionContextFinder contextFinder(startPositionCursor);
|
CompletionContextFinder contextFinder(startPositionCursor);
|
||||||
|
|
||||||
const ObjectValue *qmlScopeType = 0;
|
const ObjectValue *qmlScopeType = nullptr;
|
||||||
if (contextFinder.isInQmlContext()) {
|
if (contextFinder.isInQmlContext()) {
|
||||||
// find the enclosing qml object
|
// find the enclosing qml object
|
||||||
// ### this should use semanticInfo.declaringMember instead, but that may also return functions
|
// ### 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
|
// grouped property bindings change the scope type
|
||||||
for (i++; i < path.size(); ++i) {
|
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))
|
if (!objDef || !document->bind()->isGroupedPropertyBinding(objDef))
|
||||||
break;
|
break;
|
||||||
const ObjectValue *newScopeType = qmlScopeType;
|
const ObjectValue *newScopeType = qmlScopeType;
|
||||||
for (AST::UiQualifiedId *it = objDef->qualifiedTypeNameId; it; it = it->next) {
|
for (AST::UiQualifiedId *it = objDef->qualifiedTypeNameId; it; it = it->next) {
|
||||||
if (!newScopeType || it->name.isEmpty()) {
|
if (!newScopeType || it->name.isEmpty()) {
|
||||||
newScopeType = 0;
|
newScopeType = nullptr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const Value *v = newScopeType->lookupMember(it->name.toString(), context);
|
const Value *v = newScopeType->lookupMember(it->name.toString(), context);
|
||||||
@@ -648,7 +640,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
|
|||||||
if (!literalText.isEmpty()
|
if (!literalText.isEmpty()
|
||||||
&& literalText.at(0) != QLatin1Char('"')
|
&& literalText.at(0) != QLatin1Char('"')
|
||||||
&& literalText.at(0) != QLatin1Char('\'')) {
|
&& literalText.at(0) != QLatin1Char('\'')) {
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
literalText = literalText.mid(1);
|
literalText = literalText.mid(1);
|
||||||
@@ -658,7 +650,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
|
|||||||
patterns << QLatin1String("*.qml") << QLatin1String("*.js");
|
patterns << QLatin1String("*.qml") << QLatin1String("*.js");
|
||||||
if (completeFileName(document->path(), literalText, patterns))
|
if (completeFileName(document->path(), literalText, patterns))
|
||||||
return createContentProposal();
|
return createContentProposal();
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Value *value =
|
const Value *value =
|
||||||
@@ -672,7 +664,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
|
|||||||
|
|
||||||
// ### enum completion?
|
// ### enum completion?
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// currently path-in-stringliteral is the only completion available in imports
|
// currently path-in-stringliteral is the only completion available in imports
|
||||||
@@ -705,7 +697,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
|
|||||||
return createContentProposal();
|
return createContentProposal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// member "a.bc<complete>" or function "foo(<complete>" completion
|
// member "a.bc<complete>" or function "foo(<complete>" completion
|
||||||
@@ -719,7 +711,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
|
|||||||
QmlExpressionUnderCursor expressionUnderCursor;
|
QmlExpressionUnderCursor expressionUnderCursor;
|
||||||
AST::ExpressionNode *expression = expressionUnderCursor(tc);
|
AST::ExpressionNode *expression = expressionUnderCursor(tc);
|
||||||
|
|
||||||
if (expression != 0 && ! isLiteral(expression)) {
|
if (expression && ! isLiteral(expression)) {
|
||||||
// Evaluate the expression under cursor.
|
// Evaluate the expression under cursor.
|
||||||
ValueOwner *interp = context->valueOwner();
|
ValueOwner *interp = context->valueOwner();
|
||||||
const Value *value =
|
const Value *value =
|
||||||
@@ -759,7 +751,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
|
|||||||
|
|
||||||
if (! m_completions.isEmpty())
|
if (! m_completions.isEmpty())
|
||||||
return createContentProposal();
|
return createContentProposal();
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// global completion
|
// global completion
|
||||||
@@ -866,10 +858,10 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
|
|||||||
|
|
||||||
if (! m_completions.isEmpty())
|
if (! m_completions.isEmpty())
|
||||||
return createContentProposal();
|
return createContentProposal();
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlJSCompletionAssistProcessor::acceptsIdleEditor() const
|
bool QmlJSCompletionAssistProcessor::acceptsIdleEditor() const
|
||||||
|
@@ -170,7 +170,7 @@ public:
|
|||||||
|
|
||||||
if (doc->isParsedCorrectly()) {
|
if (doc->isParsedCorrectly()) {
|
||||||
|
|
||||||
UiObjectMember *astRootNode = 0;
|
UiObjectMember *astRootNode = nullptr;
|
||||||
if (UiProgram *program = doc->qmlProgram())
|
if (UiProgram *program = doc->qmlProgram())
|
||||||
if (program->members)
|
if (program->members)
|
||||||
astRootNode = program->members->member;
|
astRootNode = program->members->member;
|
||||||
@@ -240,7 +240,7 @@ void matchComponentFromObjectDefQuickFix(const QmlJSQuickFixInterface &interface
|
|||||||
QList<Node *> path = interface->semanticInfo().rangePath(pos);
|
QList<Node *> path = interface->semanticInfo().rangePath(pos);
|
||||||
for (int i = path.size() - 1; i >= 0; --i) {
|
for (int i = path.size() - 1; i >= 0; --i) {
|
||||||
Node *node = path.at(i);
|
Node *node = path.at(i);
|
||||||
if (UiObjectDefinition *objDef = cast<UiObjectDefinition *>(node)) {
|
if (auto objDef = cast<UiObjectDefinition *>(node)) {
|
||||||
|
|
||||||
if (!interface->currentFile()->isCursorOn(objDef->qualifiedTypeNameId))
|
if (!interface->currentFile()->isCursorOn(objDef->qualifiedTypeNameId))
|
||||||
return;
|
return;
|
||||||
@@ -249,7 +249,7 @@ void matchComponentFromObjectDefQuickFix(const QmlJSQuickFixInterface &interface
|
|||||||
result << new Operation(interface, objDef);
|
result << new Operation(interface, objDef);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (UiObjectBinding *objBinding = cast<UiObjectBinding *>(node)) {
|
} else if (auto objBinding = cast<UiObjectBinding *>(node)) {
|
||||||
if (!interface->currentFile()->isCursorOn(objBinding->qualifiedTypeNameId))
|
if (!interface->currentFile()->isCursorOn(objBinding->qualifiedTypeNameId))
|
||||||
return;
|
return;
|
||||||
result << new Operation(interface, objBinding);
|
result << new Operation(interface, objBinding);
|
||||||
|
@@ -37,13 +37,13 @@ class ComponentNameDialog : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ComponentNameDialog(QWidget *parent = 0);
|
explicit ComponentNameDialog(QWidget *parent = nullptr);
|
||||||
~ComponentNameDialog();
|
~ComponentNameDialog() override;
|
||||||
|
|
||||||
static bool go(QString *proposedName, QString *proposedPath, QString *proposedSuffix,
|
static bool go(QString *proposedName, QString *proposedPath, QString *proposedSuffix,
|
||||||
const QStringList &properties, const QStringList &sourcePreview, const QString &oldFileName,
|
const QStringList &properties, const QStringList &sourcePreview, const QString &oldFileName,
|
||||||
QStringList *result,
|
QStringList *result,
|
||||||
QWidget *parent = 0);
|
QWidget *parent = nullptr);
|
||||||
|
|
||||||
void setProperties(const QStringList &properties);
|
void setProperties(const QStringList &properties);
|
||||||
|
|
||||||
|
@@ -161,8 +161,7 @@ QmlJsEditingSettings QmlJsEditingSettings::get()
|
|||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlJsEditingSettingsPage::QmlJsEditingSettingsPage() :
|
QmlJsEditingSettingsPage::QmlJsEditingSettingsPage()
|
||||||
m_widget(0)
|
|
||||||
{
|
{
|
||||||
setId("C.QmlJsEditing");
|
setId("C.QmlJsEditing");
|
||||||
setDisplayName(tr("QML/JS Editing"));
|
setDisplayName(tr("QML/JS Editing"));
|
||||||
|
@@ -82,7 +82,7 @@ class QmlJsEditingSettignsPageWidget : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit QmlJsEditingSettignsPageWidget(QWidget *parent = 0);
|
explicit QmlJsEditingSettignsPageWidget(QWidget *parent = nullptr);
|
||||||
|
|
||||||
QmlJsEditingSettings settings() const;
|
QmlJsEditingSettings settings() const;
|
||||||
void setSettings(const QmlJsEditingSettings &);
|
void setSettings(const QmlJsEditingSettings &);
|
||||||
@@ -101,9 +101,9 @@ class QmlJsEditingSettingsPage : public Core::IOptionsPage
|
|||||||
public:
|
public:
|
||||||
QmlJsEditingSettingsPage();
|
QmlJsEditingSettingsPage();
|
||||||
|
|
||||||
QWidget *widget();
|
QWidget *widget() override;
|
||||||
void apply();
|
void apply() override;
|
||||||
void finish();
|
void finish() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<QmlJsEditingSettignsPageWidget> m_widget;
|
QPointer<QmlJsEditingSettignsPageWidget> m_widget;
|
||||||
|
@@ -295,7 +295,7 @@ void QmlJSEditorWidget::updateContextPane()
|
|||||||
Node *oldNode = info.declaringMemberNoProperties(m_oldCursorPosition);
|
Node *oldNode = info.declaringMemberNoProperties(m_oldCursorPosition);
|
||||||
Node *newNode = info.declaringMemberNoProperties(position());
|
Node *newNode = info.declaringMemberNoProperties(position());
|
||||||
if (oldNode != newNode && m_oldCursorPosition != -1)
|
if (oldNode != newNode && m_oldCursorPosition != -1)
|
||||||
m_contextPane->apply(this, info.document, 0, newNode, false);
|
m_contextPane->apply(this, info.document, nullptr, newNode, false);
|
||||||
|
|
||||||
if (m_contextPane->isAvailable(this, info.document, newNode) &&
|
if (m_contextPane->isAvailable(this, info.document, newNode) &&
|
||||||
!m_contextPane->widget()->isVisible()) {
|
!m_contextPane->widget()->isVisible()) {
|
||||||
@@ -357,14 +357,11 @@ void QmlJSEditorWidget::updateUses()
|
|||||||
|
|
||||||
class SelectedElement: protected Visitor
|
class SelectedElement: protected Visitor
|
||||||
{
|
{
|
||||||
unsigned m_cursorPositionStart;
|
unsigned m_cursorPositionStart = 0;
|
||||||
unsigned m_cursorPositionEnd;
|
unsigned m_cursorPositionEnd = 0;
|
||||||
QList<UiObjectMember *> m_selectedMembers;
|
QList<UiObjectMember *> m_selectedMembers;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SelectedElement()
|
|
||||||
: m_cursorPositionStart(0), m_cursorPositionEnd(0) {}
|
|
||||||
|
|
||||||
QList<UiObjectMember *> operator()(const Document::Ptr &doc, unsigned startPosition, unsigned endPosition)
|
QList<UiObjectMember *> operator()(const Document::Ptr &doc, unsigned startPosition, unsigned endPosition)
|
||||||
{
|
{
|
||||||
m_cursorPositionStart = startPosition;
|
m_cursorPositionStart = startPosition;
|
||||||
@@ -390,7 +387,7 @@ protected:
|
|||||||
|
|
||||||
inline bool isIdBinding(UiObjectMember *member) const
|
inline bool isIdBinding(UiObjectMember *member) const
|
||||||
{
|
{
|
||||||
if (UiScriptBinding *script = cast<UiScriptBinding *>(member)) {
|
if (auto script = cast<const UiScriptBinding *>(member)) {
|
||||||
if (! script->qualifiedId)
|
if (! script->qualifiedId)
|
||||||
return false;
|
return false;
|
||||||
else if (script->qualifiedId->name.isEmpty())
|
else if (script->qualifiedId->name.isEmpty())
|
||||||
@@ -422,7 +419,7 @@ protected:
|
|||||||
return (m_cursorPositionStart != m_cursorPositionEnd);
|
return (m_cursorPositionStart != m_cursorPositionEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void postVisit(Node *ast)
|
void postVisit(Node *ast) override
|
||||||
{
|
{
|
||||||
if (!isRangeSelected() && !m_selectedMembers.isEmpty())
|
if (!isRangeSelected() && !m_selectedMembers.isEmpty())
|
||||||
return; // nothing to do, we already have the results.
|
return; // nothing to do, we already have the results.
|
||||||
@@ -511,9 +508,9 @@ void QmlJSEditorWidget::createToolBar()
|
|||||||
m_outlineCombo->setMinimumContentsLength(22);
|
m_outlineCombo->setMinimumContentsLength(22);
|
||||||
m_outlineCombo->setModel(m_qmlJsEditorDocument->outlineModel());
|
m_outlineCombo->setModel(m_qmlJsEditorDocument->outlineModel());
|
||||||
|
|
||||||
QTreeView *treeView = new QTreeView;
|
auto treeView = new QTreeView;
|
||||||
|
|
||||||
Utils::AnnotatedItemDelegate *itemDelegate = new Utils::AnnotatedItemDelegate(this);
|
auto itemDelegate = new Utils::AnnotatedItemDelegate(this);
|
||||||
itemDelegate->setDelimiter(QLatin1String(" "));
|
itemDelegate->setDelimiter(QLatin1String(" "));
|
||||||
itemDelegate->setAnnotationRole(QmlOutlineModel::AnnotationRole);
|
itemDelegate->setAnnotationRole(QmlOutlineModel::AnnotationRole);
|
||||||
treeView->setItemDelegateForColumn(0, itemDelegate);
|
treeView->setItemDelegateForColumn(0, itemDelegate);
|
||||||
@@ -620,13 +617,13 @@ static const CppComponentValue *findCppComponentToInspect(const SemanticInfo &se
|
|||||||
{
|
{
|
||||||
AST::Node *node = semanticInfo.astNodeAt(cursorPosition);
|
AST::Node *node = semanticInfo.astNodeAt(cursorPosition);
|
||||||
if (!node)
|
if (!node)
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
const ScopeChain scopeChain = semanticInfo.scopeChain(semanticInfo.rangePath(cursorPosition));
|
const ScopeChain scopeChain = semanticInfo.scopeChain(semanticInfo.rangePath(cursorPosition));
|
||||||
Evaluate evaluator(&scopeChain);
|
Evaluate evaluator(&scopeChain);
|
||||||
const Value *value = evaluator.reference(node);
|
const Value *value = evaluator.reference(node);
|
||||||
if (!value)
|
if (!value)
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
return value->asCppComponentValue();
|
return value->asCppComponentValue();
|
||||||
}
|
}
|
||||||
@@ -726,7 +723,7 @@ void QmlJSEditorWidget::findLinkAt(const QTextCursor &cursor,
|
|||||||
AST::Node *node = semanticInfo.astNodeAt(cursorPosition);
|
AST::Node *node = semanticInfo.astNodeAt(cursorPosition);
|
||||||
QTC_ASSERT(node, return;);
|
QTC_ASSERT(node, return;);
|
||||||
|
|
||||||
if (AST::UiImport *importAst = cast<AST::UiImport *>(node)) {
|
if (auto importAst = cast<const AST::UiImport *>(node)) {
|
||||||
// if it's a file import, link to the file
|
// if it's a file import, link to the file
|
||||||
foreach (const ImportInfo &import, semanticInfo.document->bind()->imports()) {
|
foreach (const ImportInfo &import, semanticInfo.document->bind()->imports()) {
|
||||||
if (import.ast() == importAst && import.type() == ImportType::File) {
|
if (import.ast() == importAst && import.type() == ImportType::File) {
|
||||||
@@ -742,7 +739,7 @@ void QmlJSEditorWidget::findLinkAt(const QTextCursor &cursor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// string literals that could refer to a file link to them
|
// string literals that could refer to a file link to them
|
||||||
if (StringLiteral *literal = cast<StringLiteral *>(node)) {
|
if (auto literal = cast<const StringLiteral *>(node)) {
|
||||||
const QString &text = literal->value.toString();
|
const QString &text = literal->value.toString();
|
||||||
Utils::Link link;
|
Utils::Link link;
|
||||||
link.linkTextStart = literal->literalToken.begin();
|
link.linkTextStart = literal->literalToken.begin();
|
||||||
@@ -777,8 +774,8 @@ void QmlJSEditorWidget::findLinkAt(const QTextCursor &cursor,
|
|||||||
link.targetLine = line;
|
link.targetLine = line;
|
||||||
link.targetColumn = column - 1; // adjust the column
|
link.targetColumn = column - 1; // adjust the column
|
||||||
|
|
||||||
if (AST::UiQualifiedId *q = AST::cast<AST::UiQualifiedId *>(node)) {
|
if (auto q = AST::cast<const AST::UiQualifiedId *>(node)) {
|
||||||
for (AST::UiQualifiedId *tail = q; tail; tail = tail->next) {
|
for (const AST::UiQualifiedId *tail = q; tail; tail = tail->next) {
|
||||||
if (! tail->next && cursorPosition <= tail->identifierToken.end()) {
|
if (! tail->next && cursorPosition <= tail->identifierToken.end()) {
|
||||||
link.linkTextStart = tail->identifierToken.begin();
|
link.linkTextStart = tail->identifierToken.begin();
|
||||||
link.linkTextEnd = tail->identifierToken.end();
|
link.linkTextEnd = tail->identifierToken.end();
|
||||||
@@ -787,13 +784,13 @@ void QmlJSEditorWidget::findLinkAt(const QTextCursor &cursor,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (AST::IdentifierExpression *id = AST::cast<AST::IdentifierExpression *>(node)) {
|
} else if (auto id = AST::cast<const AST::IdentifierExpression *>(node)) {
|
||||||
link.linkTextStart = id->firstSourceLocation().begin();
|
link.linkTextStart = id->firstSourceLocation().begin();
|
||||||
link.linkTextEnd = id->lastSourceLocation().end();
|
link.linkTextEnd = id->lastSourceLocation().end();
|
||||||
processLinkCallback(link);
|
processLinkCallback(link);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else if (AST::FieldMemberExpression *mem = AST::cast<AST::FieldMemberExpression *>(node)) {
|
} else if (auto mem = AST::cast<const AST::FieldMemberExpression *>(node)) {
|
||||||
link.linkTextStart = mem->lastSourceLocation().begin();
|
link.linkTextStart = mem->lastSourceLocation().begin();
|
||||||
link.linkTextEnd = mem->lastSourceLocation().end();
|
link.linkTextEnd = mem->lastSourceLocation().end();
|
||||||
processLinkCallback(link);
|
processLinkCallback(link);
|
||||||
@@ -842,7 +839,7 @@ void QmlJSEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
|||||||
if (!proposal.isNull()) {
|
if (!proposal.isNull()) {
|
||||||
GenericProposalModelPtr model = proposal->model().staticCast<GenericProposalModel>();
|
GenericProposalModelPtr model = proposal->model().staticCast<GenericProposalModel>();
|
||||||
for (int index = 0; index < model->size(); ++index) {
|
for (int index = 0; index < model->size(); ++index) {
|
||||||
AssistProposalItem *item = static_cast<AssistProposalItem *>(model->proposalItem(index));
|
auto item = static_cast<const AssistProposalItem *>(model->proposalItem(index));
|
||||||
QuickFixOperation::Ptr op = item->data().value<QuickFixOperation::Ptr>();
|
QuickFixOperation::Ptr op = item->data().value<QuickFixOperation::Ptr>();
|
||||||
QAction *action = refactoringMenu->addAction(op->description());
|
QAction *action = refactoringMenu->addAction(op->description());
|
||||||
connect(action, &QAction::triggered, this, [op]() { op->perform(); });
|
connect(action, &QAction::triggered, this, [op]() { op->perform(); });
|
||||||
@@ -902,7 +899,7 @@ void QmlJSEditorWidget::wheelEvent(QWheelEvent *event)
|
|||||||
TextEditorWidget::wheelEvent(event);
|
TextEditorWidget::wheelEvent(event);
|
||||||
|
|
||||||
if (visible)
|
if (visible)
|
||||||
m_contextPane->apply(this, m_qmlJsEditorDocument->semanticInfo().document, 0,
|
m_contextPane->apply(this, m_qmlJsEditorDocument->semanticInfo().document, nullptr,
|
||||||
m_qmlJsEditorDocument->semanticInfo().declaringMemberNoProperties(m_oldCursorPosition),
|
m_qmlJsEditorDocument->semanticInfo().declaringMemberNoProperties(m_oldCursorPosition),
|
||||||
false, true);
|
false, true);
|
||||||
}
|
}
|
||||||
@@ -934,7 +931,7 @@ void QmlJSEditorWidget::semanticInfoUpdated(const SemanticInfo &semanticInfo)
|
|||||||
if (m_contextPane) {
|
if (m_contextPane) {
|
||||||
Node *newNode = semanticInfo.declaringMemberNoProperties(position());
|
Node *newNode = semanticInfo.declaringMemberNoProperties(position());
|
||||||
if (newNode) {
|
if (newNode) {
|
||||||
m_contextPane->apply(this, semanticInfo.document, 0, newNode, true);
|
m_contextPane->apply(this, semanticInfo.document, nullptr, newNode, true);
|
||||||
m_contextPaneTimer.start(); //update text marker
|
m_contextPaneTimer.start(); //update text marker
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -976,7 +973,8 @@ bool QmlJSEditorWidget::hideContextPane()
|
|||||||
{
|
{
|
||||||
bool b = (m_contextPane) && m_contextPane->widget()->isVisible();
|
bool b = (m_contextPane) && m_contextPane->widget()->isVisible();
|
||||||
if (b)
|
if (b)
|
||||||
m_contextPane->apply(this, m_qmlJsEditorDocument->semanticInfo().document, 0, 0, false);
|
m_contextPane->apply(this, m_qmlJsEditorDocument->semanticInfo().document,
|
||||||
|
nullptr, nullptr, false);
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -993,7 +991,7 @@ AssistInterface *QmlJSEditorWidget::createAssistInterface(
|
|||||||
} else if (assistKind == QuickFix) {
|
} else if (assistKind == QuickFix) {
|
||||||
return new QmlJSQuickFixAssistInterface(const_cast<QmlJSEditorWidget *>(this), reason);
|
return new QmlJSQuickFixAssistInterface(const_cast<QmlJSEditorWidget *>(this), reason);
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QmlJSEditorWidget::foldReplacementText(const QTextBlock &block) const
|
QString QmlJSEditorWidget::foldReplacementText(const QTextBlock &block) const
|
||||||
|
@@ -58,23 +58,16 @@ enum {
|
|||||||
struct Declaration
|
struct Declaration
|
||||||
{
|
{
|
||||||
QString text;
|
QString text;
|
||||||
int startLine;
|
int startLine = 0;
|
||||||
int startColumn;
|
int startColumn = 0;
|
||||||
int endLine;
|
int endLine = 0;
|
||||||
int endColumn;
|
int endColumn = 0;
|
||||||
|
|
||||||
Declaration()
|
|
||||||
: startLine(0),
|
|
||||||
startColumn(0),
|
|
||||||
endLine(0),
|
|
||||||
endColumn(0)
|
|
||||||
{ }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class FindIdDeclarations: protected Visitor
|
class FindIdDeclarations: protected Visitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef QHash<QString, QList<AST::SourceLocation> > Result;
|
using Result = QHash<QString, QList<AST::SourceLocation> >;
|
||||||
|
|
||||||
Result operator()(Document::Ptr doc)
|
Result operator()(Document::Ptr doc)
|
||||||
{
|
{
|
||||||
@@ -111,8 +104,8 @@ protected:
|
|||||||
bool visit(AST::UiScriptBinding *node) override
|
bool visit(AST::UiScriptBinding *node) override
|
||||||
{
|
{
|
||||||
if (asString(node->qualifiedId) == QLatin1String("id")) {
|
if (asString(node->qualifiedId) == QLatin1String("id")) {
|
||||||
if (AST::ExpressionStatement *stmt = AST::cast<AST::ExpressionStatement*>(node->statement)) {
|
if (auto stmt = AST::cast<const AST::ExpressionStatement*>(node->statement)) {
|
||||||
if (AST::IdentifierExpression *idExpr = AST::cast<AST::IdentifierExpression *>(stmt->expression)) {
|
if (auto idExpr = AST::cast<const AST::IdentifierExpression *>(stmt->expression)) {
|
||||||
if (!idExpr->name.isEmpty()) {
|
if (!idExpr->name.isEmpty()) {
|
||||||
const QString &id = idExpr->name.toString();
|
const QString &id = idExpr->name.toString();
|
||||||
QList<AST::SourceLocation> *locs = &_ids[id];
|
QList<AST::SourceLocation> *locs = &_ids[id];
|
||||||
@@ -331,8 +324,8 @@ protected:
|
|||||||
|
|
||||||
bool visit(AST::BinaryExpression *ast) override
|
bool visit(AST::BinaryExpression *ast) override
|
||||||
{
|
{
|
||||||
AST::FieldMemberExpression *field = AST::cast<AST::FieldMemberExpression *>(ast->left);
|
auto field = AST::cast<const AST::FieldMemberExpression *>(ast->left);
|
||||||
AST::FunctionExpression *funcExpr = AST::cast<AST::FunctionExpression *>(ast->right);
|
auto funcExpr = AST::cast<const AST::FunctionExpression *>(ast->right);
|
||||||
|
|
||||||
if (field && funcExpr && funcExpr->body && (ast->op == QSOperator::Assign)) {
|
if (field && funcExpr && funcExpr->body && (ast->op == QSOperator::Assign)) {
|
||||||
Declaration decl;
|
Declaration decl;
|
||||||
@@ -368,7 +361,7 @@ public:
|
|||||||
{
|
{
|
||||||
_textDocument = textDocument;
|
_textDocument = textDocument;
|
||||||
_ranges.clear();
|
_ranges.clear();
|
||||||
if (doc && doc->ast() != 0)
|
if (doc && doc->ast() != nullptr)
|
||||||
doc->ast()->accept(this);
|
doc->ast()->accept(this);
|
||||||
return _ranges;
|
return _ranges;
|
||||||
}
|
}
|
||||||
@@ -414,7 +407,7 @@ protected:
|
|||||||
|
|
||||||
bool visit(AST::UiScriptBinding *ast) override
|
bool visit(AST::UiScriptBinding *ast) override
|
||||||
{
|
{
|
||||||
if (AST::Block *block = AST::cast<AST::Block *>(ast->statement))
|
if (auto block = AST::cast<AST::Block *>(ast->statement))
|
||||||
_ranges.append(createRange(ast, block));
|
_ranges.append(createRange(ast, block));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -50,7 +50,7 @@ class QmlJSEditorDocumentPrivate : public QObject
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
QmlJSEditorDocumentPrivate(QmlJSEditorDocument *parent);
|
QmlJSEditorDocumentPrivate(QmlJSEditorDocument *parent);
|
||||||
~QmlJSEditorDocumentPrivate();
|
~QmlJSEditorDocumentPrivate() override;
|
||||||
|
|
||||||
void invalidateFormatterCache();
|
void invalidateFormatterCache();
|
||||||
void reparseDocument();
|
void reparseDocument();
|
||||||
|
@@ -241,7 +241,7 @@ QuickToolBar *QmlJSEditorPlugin::quickToolBar()
|
|||||||
|
|
||||||
void QmlJSEditorPluginPrivate::renameUsages()
|
void QmlJSEditorPluginPrivate::renameUsages()
|
||||||
{
|
{
|
||||||
if (QmlJSEditorWidget *editor = qobject_cast<QmlJSEditorWidget*>(EditorManager::currentEditor()->widget()))
|
if (auto editor = qobject_cast<QmlJSEditorWidget*>(EditorManager::currentEditor()->widget()))
|
||||||
editor->renameUsages();
|
editor->renameUsages();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,7 +293,7 @@ void QmlJSEditorPluginPrivate::reformatFile()
|
|||||||
|
|
||||||
void QmlJSEditorPluginPrivate::showContextPane()
|
void QmlJSEditorPluginPrivate::showContextPane()
|
||||||
{
|
{
|
||||||
if (QmlJSEditorWidget *editor = qobject_cast<QmlJSEditorWidget*>(EditorManager::currentEditor()->widget()))
|
if (auto editor = qobject_cast<QmlJSEditorWidget*>(EditorManager::currentEditor()->widget()))
|
||||||
editor->showContextPane();
|
editor->showContextPane();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -70,7 +70,7 @@ namespace {
|
|||||||
class FindUsages: protected Visitor
|
class FindUsages: protected Visitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef QList<AST::SourceLocation> Result;
|
using Result = QList<AST::SourceLocation>;
|
||||||
|
|
||||||
FindUsages(Document::Ptr doc, const ContextPtr &context)
|
FindUsages(Document::Ptr doc, const ContextPtr &context)
|
||||||
: _doc(doc)
|
: _doc(doc)
|
||||||
@@ -276,7 +276,7 @@ private:
|
|||||||
|
|
||||||
bool checkLookup()
|
bool checkLookup()
|
||||||
{
|
{
|
||||||
const ObjectValue *scope = 0;
|
const ObjectValue *scope = nullptr;
|
||||||
_scopeChain.lookup(_name, &scope);
|
_scopeChain.lookup(_name, &scope);
|
||||||
return check(scope);
|
return check(scope);
|
||||||
}
|
}
|
||||||
@@ -288,13 +288,13 @@ private:
|
|||||||
ScopeBuilder _builder;
|
ScopeBuilder _builder;
|
||||||
|
|
||||||
QString _name;
|
QString _name;
|
||||||
const ObjectValue *_scope;
|
const ObjectValue *_scope = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FindTypeUsages: protected Visitor
|
class FindTypeUsages: protected Visitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef QList<AST::SourceLocation> Result;
|
using Result = QList<AST::SourceLocation>;
|
||||||
|
|
||||||
FindTypeUsages(Document::Ptr doc, const ContextPtr &context)
|
FindTypeUsages(Document::Ptr doc, const ContextPtr &context)
|
||||||
: _doc(doc)
|
: _doc(doc)
|
||||||
@@ -449,7 +449,7 @@ private:
|
|||||||
ScopeBuilder _builder;
|
ScopeBuilder _builder;
|
||||||
|
|
||||||
QString _name;
|
QString _name;
|
||||||
const ObjectValue *_typeValue;
|
const ObjectValue *_typeValue = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FindTargetExpression: protected Visitor
|
class FindTargetExpression: protected Visitor
|
||||||
@@ -468,8 +468,8 @@ public:
|
|||||||
void operator()(quint32 offset)
|
void operator()(quint32 offset)
|
||||||
{
|
{
|
||||||
_name.clear();
|
_name.clear();
|
||||||
_scope = 0;
|
_scope = nullptr;
|
||||||
_objectNode = 0;
|
_objectNode = nullptr;
|
||||||
_offset = offset;
|
_offset = offset;
|
||||||
_typeKind = ExpKind;
|
_typeKind = ExpKind;
|
||||||
if (_doc)
|
if (_doc)
|
||||||
@@ -587,7 +587,7 @@ protected:
|
|||||||
if (node->defaultToken.isValid()) {
|
if (node->defaultToken.isValid()) {
|
||||||
_name = node->memberType->name.toString();
|
_name = node->memberType->name.toString();
|
||||||
_targetValue = _scopeChain->context()->lookupType(_doc.data(), QStringList(_name));
|
_targetValue = _scopeChain->context()->lookupType(_doc.data(), QStringList(_name));
|
||||||
_scope = 0;
|
_scope = nullptr;
|
||||||
_typeKind = TypeKind;
|
_typeKind = TypeKind;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -648,7 +648,7 @@ private:
|
|||||||
for (UiQualifiedId *att = id; att; att = att->next) {
|
for (UiQualifiedId *att = id; att; att = att->next) {
|
||||||
if (!att->name.isEmpty() && containsOffset(att->identifierToken)) {
|
if (!att->name.isEmpty() && containsOffset(att->identifierToken)) {
|
||||||
_targetValue = _scopeChain->context()->lookupType(_doc.data(), id, att->next);
|
_targetValue = _scopeChain->context()->lookupType(_doc.data(), id, att->next);
|
||||||
_scope = 0;
|
_scope = nullptr;
|
||||||
_name = att->name.toString();
|
_name = att->name.toString();
|
||||||
_typeKind = TypeKind;
|
_typeKind = TypeKind;
|
||||||
return true;
|
return true;
|
||||||
@@ -666,13 +666,13 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString _name;
|
QString _name;
|
||||||
const ObjectValue *_scope;
|
const ObjectValue *_scope = nullptr;
|
||||||
const Value *_targetValue;
|
const Value *_targetValue = nullptr;
|
||||||
Node *_objectNode;
|
Node *_objectNode = nullptr;
|
||||||
Document::Ptr _doc;
|
Document::Ptr _doc;
|
||||||
const ScopeChain *_scopeChain;
|
const ScopeChain *_scopeChain = nullptr;
|
||||||
quint32 _offset;
|
quint32 _offset = 0;
|
||||||
Kind _typeKind;
|
Kind _typeKind = ExpKind;
|
||||||
};
|
};
|
||||||
|
|
||||||
static QString matchingLine(unsigned position, const QString &source)
|
static QString matchingLine(unsigned position, const QString &source)
|
||||||
@@ -687,8 +687,8 @@ static QString matchingLine(unsigned position, const QString &source)
|
|||||||
class ProcessFile
|
class ProcessFile
|
||||||
{
|
{
|
||||||
ContextPtr context;
|
ContextPtr context;
|
||||||
typedef FindReferences::Usage Usage;
|
using Usage = FindReferences::Usage;
|
||||||
QString name;
|
const QString name;
|
||||||
const ObjectValue *scope;
|
const ObjectValue *scope;
|
||||||
QFutureInterface<Usage> *future;
|
QFutureInterface<Usage> *future;
|
||||||
|
|
||||||
@@ -698,7 +698,7 @@ public:
|
|||||||
using result_type = QList<Usage>;
|
using result_type = QList<Usage>;
|
||||||
|
|
||||||
ProcessFile(const ContextPtr &context,
|
ProcessFile(const ContextPtr &context,
|
||||||
QString name,
|
const QString &name,
|
||||||
const ObjectValue *scope,
|
const ObjectValue *scope,
|
||||||
QFutureInterface<Usage> *future)
|
QFutureInterface<Usage> *future)
|
||||||
: context(context), name(name), scope(scope), future(future)
|
: context(context), name(name), scope(scope), future(future)
|
||||||
@@ -729,8 +729,8 @@ public:
|
|||||||
class SearchFileForType
|
class SearchFileForType
|
||||||
{
|
{
|
||||||
ContextPtr context;
|
ContextPtr context;
|
||||||
typedef FindReferences::Usage Usage;
|
using Usage = FindReferences::Usage;
|
||||||
QString name;
|
const QString name;
|
||||||
const ObjectValue *scope;
|
const ObjectValue *scope;
|
||||||
QFutureInterface<Usage> *future;
|
QFutureInterface<Usage> *future;
|
||||||
|
|
||||||
@@ -740,7 +740,7 @@ public:
|
|||||||
using result_type = QList<Usage>;
|
using result_type = QList<Usage>;
|
||||||
|
|
||||||
SearchFileForType(const ContextPtr &context,
|
SearchFileForType(const ContextPtr &context,
|
||||||
QString name,
|
const QString &name,
|
||||||
const ObjectValue *scope,
|
const ObjectValue *scope,
|
||||||
QFutureInterface<Usage> *future)
|
QFutureInterface<Usage> *future)
|
||||||
: context(context), name(name), scope(scope), future(future)
|
: context(context), name(name), scope(scope), future(future)
|
||||||
@@ -770,7 +770,7 @@ public:
|
|||||||
|
|
||||||
class UpdateUI
|
class UpdateUI
|
||||||
{
|
{
|
||||||
typedef FindReferences::Usage Usage;
|
using Usage = FindReferences::Usage;
|
||||||
QFutureInterface<Usage> *future;
|
QFutureInterface<Usage> *future;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -800,14 +800,12 @@ FindReferences::FindReferences(QObject *parent)
|
|||||||
connect(&m_watcher, &QFutureWatcherBase::finished, this, &FindReferences::searchFinished);
|
connect(&m_watcher, &QFutureWatcherBase::finished, this, &FindReferences::searchFinished);
|
||||||
}
|
}
|
||||||
|
|
||||||
FindReferences::~FindReferences()
|
FindReferences::~FindReferences() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static void find_helper(QFutureInterface<FindReferences::Usage> &future,
|
static void find_helper(QFutureInterface<FindReferences::Usage> &future,
|
||||||
const ModelManagerInterface::WorkingCopy workingCopy,
|
const ModelManagerInterface::WorkingCopy &workingCopy,
|
||||||
Snapshot snapshot,
|
Snapshot snapshot,
|
||||||
const QString fileName,
|
const QString &fileName,
|
||||||
quint32 offset,
|
quint32 offset,
|
||||||
QString replacement)
|
QString replacement)
|
||||||
{
|
{
|
||||||
@@ -925,7 +923,7 @@ void FindReferences::renameUsages(const QString &fileName, quint32 offset,
|
|||||||
m_watcher.setFuture(result);
|
m_watcher.setFuture(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<FindReferences::Usage> FindReferences::findUsageOfType(const QString &fileName, const QString typeName)
|
QList<FindReferences::Usage> FindReferences::findUsageOfType(const QString &fileName, const QString &typeName)
|
||||||
{
|
{
|
||||||
QList<Usage> usages;
|
QList<Usage> usages;
|
||||||
ModelManagerInterface *modelManager = ModelManagerInterface::instance();
|
ModelManagerInterface *modelManager = ModelManagerInterface::instance();
|
||||||
@@ -1006,7 +1004,7 @@ void FindReferences::searchFinished()
|
|||||||
{
|
{
|
||||||
if (m_currentSearch)
|
if (m_currentSearch)
|
||||||
m_currentSearch->finishSearch(m_watcher.isCanceled());
|
m_currentSearch->finishSearch(m_watcher.isCanceled());
|
||||||
m_currentSearch = 0;
|
m_currentSearch = nullptr;
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -49,18 +49,15 @@ public:
|
|||||||
class Usage
|
class Usage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Usage()
|
|
||||||
: line(0), col(0), len(0) {}
|
|
||||||
|
|
||||||
Usage(const QString &path, const QString &lineText, int line, int col, int len)
|
Usage(const QString &path, const QString &lineText, int line, int col, int len)
|
||||||
: path(path), lineText(lineText), line(line), col(col), len(len) {}
|
: path(path), lineText(lineText), line(line), col(col), len(len) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString path;
|
QString path;
|
||||||
QString lineText;
|
QString lineText;
|
||||||
int line;
|
int line = 0;
|
||||||
int col;
|
int col = 0;
|
||||||
int len;
|
int len = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -75,7 +72,7 @@ public:
|
|||||||
void renameUsages(const QString &fileName, quint32 offset,
|
void renameUsages(const QString &fileName, quint32 offset,
|
||||||
const QString &replacement = QString());
|
const QString &replacement = QString());
|
||||||
|
|
||||||
static QList<Usage> findUsageOfType(const QString &fileName, const QString typeName);
|
static QList<Usage> findUsageOfType(const QString &fileName, const QString &typeName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void displayResults(int first, int last);
|
void displayResults(int first, int last);
|
||||||
|
@@ -45,9 +45,7 @@ QmlJSHighlighter::QmlJSHighlighter(QTextDocument *parent)
|
|||||||
setDefaultTextFormatCategories();
|
setDefaultTextFormatCategories();
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlJSHighlighter::~QmlJSHighlighter()
|
QmlJSHighlighter::~QmlJSHighlighter() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QmlJSHighlighter::isQmlEnabled() const
|
bool QmlJSHighlighter::isQmlEnabled() const
|
||||||
{
|
{
|
||||||
@@ -167,8 +165,7 @@ void QmlJSHighlighter::highlightBlock(const QString &text)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int previousTokenEnd = 0;
|
int previousTokenEnd = 0;
|
||||||
for (int index = 0; index < tokens.size(); ++index) {
|
for (const auto &token : tokens) {
|
||||||
const Token &token = tokens.at(index);
|
|
||||||
setFormat(previousTokenEnd, token.begin() - previousTokenEnd, formatForCategory(C_VISUAL_WHITESPACE));
|
setFormat(previousTokenEnd, token.begin() - previousTokenEnd, formatForCategory(C_VISUAL_WHITESPACE));
|
||||||
|
|
||||||
switch (token.kind) {
|
switch (token.kind) {
|
||||||
|
@@ -39,14 +39,14 @@ class QMLJSEDITOR_EXPORT QmlJSHighlighter : public TextEditor::SyntaxHighlighter
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QmlJSHighlighter(QTextDocument *parent = 0);
|
QmlJSHighlighter(QTextDocument *parent = nullptr);
|
||||||
virtual ~QmlJSHighlighter();
|
~QmlJSHighlighter() override;
|
||||||
|
|
||||||
bool isQmlEnabled() const;
|
bool isQmlEnabled() const;
|
||||||
void setQmlEnabled(bool duiEnabled);
|
void setQmlEnabled(bool duiEnabled);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void highlightBlock(const QString &text);
|
void highlightBlock(const QString &text) override;
|
||||||
|
|
||||||
int onBlockStart();
|
int onBlockStart();
|
||||||
void onBlockEnd(int state);
|
void onBlockEnd(int state);
|
||||||
|
@@ -72,11 +72,10 @@ namespace {
|
|||||||
|
|
||||||
AST::UiObjectInitializer *nodeInitializer(AST::Node *node)
|
AST::UiObjectInitializer *nodeInitializer(AST::Node *node)
|
||||||
{
|
{
|
||||||
AST::UiObjectInitializer *initializer = 0;
|
AST::UiObjectInitializer *initializer = nullptr;
|
||||||
if (const AST::UiObjectBinding *binding = AST::cast<const AST::UiObjectBinding *>(node))
|
if (auto binding = AST::cast<const AST::UiObjectBinding*>(node))
|
||||||
initializer = binding->initializer;
|
initializer = binding->initializer;
|
||||||
else if (const AST::UiObjectDefinition *definition =
|
else if (auto definition = AST::cast<const AST::UiObjectDefinition*>(node))
|
||||||
AST::cast<const AST::UiObjectDefinition *>(node))
|
|
||||||
initializer = definition->initializer;
|
initializer = definition->initializer;
|
||||||
return initializer;
|
return initializer;
|
||||||
}
|
}
|
||||||
@@ -92,7 +91,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlJSHoverHandler::QmlJSHoverHandler() : m_modelManager(0)
|
QmlJSHoverHandler::QmlJSHoverHandler()
|
||||||
{
|
{
|
||||||
m_modelManager = ModelManagerInterface::instance();
|
m_modelManager = ModelManagerInterface::instance();
|
||||||
}
|
}
|
||||||
@@ -177,7 +176,7 @@ bool QmlJSHoverHandler::setQmlTypeHelp(const ScopeChain &scopeChain, const Docum
|
|||||||
if (!urlMap.isEmpty())
|
if (!urlMap.isEmpty())
|
||||||
break;
|
break;
|
||||||
return false;
|
return false;
|
||||||
} while (0);
|
} while (false);
|
||||||
|
|
||||||
// Check if the module name contains a major version.
|
// Check if the module name contains a major version.
|
||||||
QRegularExpression version("^([^\\d]*)(\\d+)\\.*\\d*$");
|
QRegularExpression version("^([^\\d]*)(\\d+)\\.*\\d*$");
|
||||||
@@ -211,7 +210,7 @@ void QmlJSHoverHandler::identifyMatch(TextEditorWidget *editorWidget, int pos, R
|
|||||||
if (!m_modelManager)
|
if (!m_modelManager)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QmlJSEditorWidget *qmlEditor = qobject_cast<QmlJSEditorWidget *>(editorWidget);
|
auto qmlEditor = qobject_cast<QmlJSEditorWidget*>(editorWidget);
|
||||||
QTC_ASSERT(qmlEditor, return);
|
QTC_ASSERT(qmlEditor, return);
|
||||||
|
|
||||||
const QmlJSTools::SemanticInfo &semanticInfo = qmlEditor->qmlJsEditorDocument()->semanticInfo();
|
const QmlJSTools::SemanticInfo &semanticInfo = qmlEditor->qmlJsEditorDocument()->semanticInfo();
|
||||||
@@ -230,7 +229,7 @@ void QmlJSHoverHandler::identifyMatch(TextEditorWidget *editorWidget, int pos, R
|
|||||||
if (rangePath.isEmpty()) {
|
if (rangePath.isEmpty()) {
|
||||||
// Is the cursor on an import? The ast path will have an UiImport
|
// Is the cursor on an import? The ast path will have an UiImport
|
||||||
// member in the last or second to last position!
|
// member in the last or second to last position!
|
||||||
AST::UiImport *import = 0;
|
AST::UiImport *import = nullptr;
|
||||||
if (astPath.size() >= 1)
|
if (astPath.size() >= 1)
|
||||||
import = AST::cast<AST::UiImport *>(astPath.last());
|
import = AST::cast<AST::UiImport *>(astPath.last());
|
||||||
if (!import && astPath.size() >= 2)
|
if (!import && astPath.size() >= 2)
|
||||||
@@ -305,7 +304,7 @@ bool QmlJSHoverHandler::matchColorItem(const ScopeChain &scopeChain,
|
|||||||
if (!initializer)
|
if (!initializer)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
AST::UiObjectMember *member = 0;
|
AST::UiObjectMember *member = nullptr;
|
||||||
for (AST::UiObjectMemberList *list = initializer->members; list; list = list->next) {
|
for (AST::UiObjectMemberList *list = initializer->members; list; list = list->next) {
|
||||||
if (posIsInSource(pos, list->member)) {
|
if (posIsInSource(pos, list->member)) {
|
||||||
member = list->member;
|
member = list->member;
|
||||||
@@ -316,8 +315,8 @@ bool QmlJSHoverHandler::matchColorItem(const ScopeChain &scopeChain,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
QString color;
|
QString color;
|
||||||
const Value *value = 0;
|
const Value *value = nullptr;
|
||||||
if (const AST::UiScriptBinding *binding = AST::cast<const AST::UiScriptBinding *>(member)) {
|
if (auto binding = AST::cast<const AST::UiScriptBinding *>(member)) {
|
||||||
if (binding->qualifiedId && posIsInSource(pos, binding->statement)) {
|
if (binding->qualifiedId && posIsInSource(pos, binding->statement)) {
|
||||||
value = scopeChain.evaluate(binding->qualifiedId);
|
value = scopeChain.evaluate(binding->qualifiedId);
|
||||||
if (value && value->asColorValue()) {
|
if (value && value->asColorValue()) {
|
||||||
@@ -326,8 +325,7 @@ bool QmlJSHoverHandler::matchColorItem(const ScopeChain &scopeChain,
|
|||||||
binding->statement->lastSourceLocation());
|
binding->statement->lastSourceLocation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (const AST::UiPublicMember *publicMember =
|
} else if (auto publicMember = AST::cast<const AST::UiPublicMember *>(member)) {
|
||||||
AST::cast<const AST::UiPublicMember *>(member)) {
|
|
||||||
if (!publicMember->name.isEmpty() && posIsInSource(pos, publicMember->statement)) {
|
if (!publicMember->name.isEmpty() && posIsInSource(pos, publicMember->statement)) {
|
||||||
value = scopeChain.lookup(publicMember->name.toString());
|
value = scopeChain.lookup(publicMember->name.toString());
|
||||||
if (const Reference *ref = value->asReference())
|
if (const Reference *ref = value->asReference())
|
||||||
@@ -440,33 +438,33 @@ void QmlJSHoverHandler::prettyPrintTooltip(const Value *value,
|
|||||||
static const ObjectValue *isMember(const ScopeChain &scopeChain,
|
static const ObjectValue *isMember(const ScopeChain &scopeChain,
|
||||||
AST::Node *node, QString *name)
|
AST::Node *node, QString *name)
|
||||||
{
|
{
|
||||||
const ObjectValue *owningObject = 0;
|
const ObjectValue *owningObject = nullptr;
|
||||||
if (AST::IdentifierExpression *identExp = AST::cast<AST::IdentifierExpression *>(node)) {
|
if (auto identExp = AST::cast<const AST::IdentifierExpression *>(node)) {
|
||||||
if (identExp->name.isEmpty())
|
if (identExp->name.isEmpty())
|
||||||
return 0;
|
return nullptr;
|
||||||
*name = identExp->name.toString();
|
*name = identExp->name.toString();
|
||||||
scopeChain.lookup(*name, &owningObject);
|
scopeChain.lookup(*name, &owningObject);
|
||||||
} else if (AST::FieldMemberExpression *fme = AST::cast<AST::FieldMemberExpression *>(node)) {
|
} else if (auto fme = AST::cast<const AST::FieldMemberExpression *>(node)) {
|
||||||
if (!fme->base || fme->name.isEmpty())
|
if (!fme->base || fme->name.isEmpty())
|
||||||
return 0;
|
return nullptr;
|
||||||
*name = fme->name.toString();
|
*name = fme->name.toString();
|
||||||
const Value *base = scopeChain.evaluate(fme->base);
|
const Value *base = scopeChain.evaluate(fme->base);
|
||||||
if (!base)
|
if (!base)
|
||||||
return 0;
|
return nullptr;
|
||||||
owningObject = base->asObjectValue();
|
owningObject = base->asObjectValue();
|
||||||
if (owningObject)
|
if (owningObject)
|
||||||
owningObject->lookupMember(*name, scopeChain.context(), &owningObject);
|
owningObject->lookupMember(*name, scopeChain.context(), &owningObject);
|
||||||
} else if (AST::UiQualifiedId *qid = AST::cast<AST::UiQualifiedId *>(node)) {
|
} else if (auto qid = AST::cast<const AST::UiQualifiedId *>(node)) {
|
||||||
if (qid->name.isEmpty())
|
if (qid->name.isEmpty())
|
||||||
return 0;
|
return nullptr;
|
||||||
*name = qid->name.toString();
|
*name = qid->name.toString();
|
||||||
const Value *value = scopeChain.lookup(*name, &owningObject);
|
const Value *value = scopeChain.lookup(*name, &owningObject);
|
||||||
for (AST::UiQualifiedId *it = qid->next; it; it = it->next) {
|
for (AST::UiQualifiedId *it = qid->next; it; it = it->next) {
|
||||||
if (!value)
|
if (!value)
|
||||||
return 0;
|
return nullptr;
|
||||||
const ObjectValue *next = value->asObjectValue();
|
const ObjectValue *next = value->asObjectValue();
|
||||||
if (!next || it->name.isEmpty())
|
if (!next || it->name.isEmpty())
|
||||||
return 0;
|
return nullptr;
|
||||||
*name = it->name.toString();
|
*name = it->name.toString();
|
||||||
value = next->lookupMember(*name, scopeChain.context(), &owningObject);
|
value = next->lookupMember(*name, scopeChain.context(), &owningObject);
|
||||||
}
|
}
|
||||||
@@ -483,7 +481,7 @@ bool QmlJSHoverHandler::setQmlHelpItem(const ScopeChain &scopeChain,
|
|||||||
if (const ObjectValue *scope = isMember(scopeChain, node, &name)) {
|
if (const ObjectValue *scope = isMember(scopeChain, node, &name)) {
|
||||||
// maybe it's a type?
|
// maybe it's a type?
|
||||||
if (!name.isEmpty() && name.at(0).isUpper()) {
|
if (!name.isEmpty() && name.at(0).isUpper()) {
|
||||||
if (AST::UiQualifiedId *qualifiedId = AST::cast<AST::UiQualifiedId *>(node)) {
|
if (auto qualifiedId = AST::cast<AST::UiQualifiedId *>(node)) {
|
||||||
const ObjectValue *value = scopeChain.context()->lookupType(qmlDocument.data(), qualifiedId);
|
const ObjectValue *value = scopeChain.context()->lookupType(qmlDocument.data(), qualifiedId);
|
||||||
if (setQmlTypeHelp(scopeChain, qmlDocument, value, QStringList(qualifiedId->name.toString())))
|
if (setQmlTypeHelp(scopeChain, qmlDocument, value, QStringList(qualifiedId->name.toString())))
|
||||||
return true;
|
return true;
|
||||||
@@ -513,7 +511,8 @@ bool QmlJSHoverHandler::setQmlHelpItem(const ScopeChain &scopeChain,
|
|||||||
if (!HelpManager::linksForIdentifier(helpId).isEmpty())
|
if (!HelpManager::linksForIdentifier(helpId).isEmpty())
|
||||||
break;
|
break;
|
||||||
helpId.clear();
|
helpId.clear();
|
||||||
} while (0);
|
} while (false);
|
||||||
|
|
||||||
if (!helpId.isEmpty()) {
|
if (!helpId.isEmpty()) {
|
||||||
setLastHelpItemIdentified(HelpItem(helpId, name, HelpItem::QmlProperty));
|
setLastHelpItemIdentified(HelpItem(helpId, name, HelpItem::QmlProperty));
|
||||||
return true;
|
return true;
|
||||||
@@ -525,7 +524,7 @@ bool QmlJSHoverHandler::setQmlHelpItem(const ScopeChain &scopeChain,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// it might be a type, but the scope chain is broken (mismatched braces)
|
// it might be a type, but the scope chain is broken (mismatched braces)
|
||||||
if (AST::UiQualifiedId *qualifiedId = AST::cast<AST::UiQualifiedId *>(node)) {
|
if (auto qualifiedId = AST::cast<AST::UiQualifiedId *>(node)) {
|
||||||
const ObjectValue *value = scopeChain.context()->lookupType(qmlDocument.data(),
|
const ObjectValue *value = scopeChain.context()->lookupType(qmlDocument.data(),
|
||||||
qualifiedId);
|
qualifiedId);
|
||||||
if (setQmlTypeHelp(scopeChain, qmlDocument, value,
|
if (setQmlTypeHelp(scopeChain, qmlDocument, value,
|
||||||
|
@@ -38,7 +38,7 @@ QT_END_NAMESPACE
|
|||||||
namespace QmlJS {
|
namespace QmlJS {
|
||||||
class ScopeChain;
|
class ScopeChain;
|
||||||
class Context;
|
class Context;
|
||||||
typedef QSharedPointer<const Context> ContextPtr;
|
using ContextPtr = QSharedPointer<const Context>;
|
||||||
class Value;
|
class Value;
|
||||||
class ObjectValue;
|
class ObjectValue;
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,7 @@ private:
|
|||||||
const QmlJS::Document::Ptr &qmlDocument,
|
const QmlJS::Document::Ptr &qmlDocument,
|
||||||
QmlJS::AST::Node *node);
|
QmlJS::AST::Node *node);
|
||||||
|
|
||||||
QmlJS::ModelManagerInterface *m_modelManager;
|
QmlJS::ModelManagerInterface *m_modelManager = nullptr;
|
||||||
QColor m_colorTip;
|
QColor m_colorTip;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -104,7 +104,7 @@ QmlJSOutlineWidget::QmlJSOutlineWidget(QWidget *parent)
|
|||||||
m_treeView->setModel(m_filterModel);
|
m_treeView->setModel(m_filterModel);
|
||||||
setFocusProxy(m_treeView);
|
setFocusProxy(m_treeView);
|
||||||
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout;
|
auto layout = new QVBoxLayout;
|
||||||
|
|
||||||
layout->setMargin(0);
|
layout->setMargin(0);
|
||||||
layout->setSpacing(0);
|
layout->setSpacing(0);
|
||||||
@@ -259,10 +259,10 @@ bool QmlJSOutlineWidgetFactory::supportsEditor(Core::IEditor *editor) const
|
|||||||
|
|
||||||
TextEditor::IOutlineWidget *QmlJSOutlineWidgetFactory::createWidget(Core::IEditor *editor)
|
TextEditor::IOutlineWidget *QmlJSOutlineWidgetFactory::createWidget(Core::IEditor *editor)
|
||||||
{
|
{
|
||||||
QmlJSOutlineWidget *widget = new QmlJSOutlineWidget;
|
auto widget = new QmlJSOutlineWidget;
|
||||||
|
|
||||||
QmlJSEditor *qmlJSEditable = qobject_cast<QmlJSEditor*>(editor);
|
auto qmlJSEditable = qobject_cast<const QmlJSEditor*>(editor);
|
||||||
QmlJSEditorWidget *qmlJSEditor = qobject_cast<QmlJSEditorWidget*>(qmlJSEditable->widget());
|
auto qmlJSEditor = qobject_cast<QmlJSEditorWidget*>(qmlJSEditable->widget());
|
||||||
Q_ASSERT(qmlJSEditor);
|
Q_ASSERT(qmlJSEditor);
|
||||||
|
|
||||||
widget->setEditor(qmlJSEditor);
|
widget->setEditor(qmlJSEditor);
|
||||||
|
@@ -51,29 +51,29 @@ public:
|
|||||||
QmlJSOutlineFilterModel(QObject *parent);
|
QmlJSOutlineFilterModel(QObject *parent);
|
||||||
// QSortFilterProxyModel
|
// QSortFilterProxyModel
|
||||||
bool filterAcceptsRow(int sourceRow,
|
bool filterAcceptsRow(int sourceRow,
|
||||||
const QModelIndex &sourceParent) const;
|
const QModelIndex &sourceParent) const override;
|
||||||
QVariant data(const QModelIndex &index, int role) const;
|
QVariant data(const QModelIndex &index, int role) const override;
|
||||||
Qt::DropActions supportedDragActions() const;
|
Qt::DropActions supportedDragActions() const override;
|
||||||
|
|
||||||
bool filterBindings() const;
|
bool filterBindings() const;
|
||||||
void setFilterBindings(bool filterBindings);
|
void setFilterBindings(bool filterBindings);
|
||||||
private:
|
private:
|
||||||
bool m_filterBindings;
|
bool m_filterBindings = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QmlJSOutlineWidget : public TextEditor::IOutlineWidget
|
class QmlJSOutlineWidget : public TextEditor::IOutlineWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
QmlJSOutlineWidget(QWidget *parent = 0);
|
QmlJSOutlineWidget(QWidget *parent = nullptr);
|
||||||
|
|
||||||
void setEditor(QmlJSEditorWidget *editor);
|
void setEditor(QmlJSEditorWidget *editor);
|
||||||
|
|
||||||
// IOutlineWidget
|
// IOutlineWidget
|
||||||
virtual QList<QAction*> filterMenuActions() const override;
|
QList<QAction*> filterMenuActions() const override;
|
||||||
virtual void setCursorSynchronization(bool syncWithCursor) override;
|
void setCursorSynchronization(bool syncWithCursor) override;
|
||||||
virtual void restoreSettings(const QVariantMap &map) override;
|
void restoreSettings(const QVariantMap &map) override;
|
||||||
virtual QVariantMap settings() const override;
|
QVariantMap settings() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateSelectionInTree(const QModelIndex &index);
|
void updateSelectionInTree(const QModelIndex &index);
|
||||||
@@ -98,8 +98,8 @@ class QmlJSOutlineWidgetFactory : public TextEditor::IOutlineWidgetFactory
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
bool supportsEditor(Core::IEditor *editor) const;
|
bool supportsEditor(Core::IEditor *editor) const override;
|
||||||
TextEditor::IOutlineWidget *createWidget(Core::IEditor *editor);
|
TextEditor::IOutlineWidget *createWidget(Core::IEditor *editor) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -44,7 +44,7 @@ QmlJSOutlineTreeView::QmlJSOutlineTreeView(QWidget *parent) :
|
|||||||
|
|
||||||
setRootIsDecorated(false);
|
setRootIsDecorated(false);
|
||||||
|
|
||||||
Utils::AnnotatedItemDelegate *itemDelegate = new Utils::AnnotatedItemDelegate(this);
|
auto itemDelegate = new Utils::AnnotatedItemDelegate(this);
|
||||||
itemDelegate->setDelimiter(QLatin1String(" "));
|
itemDelegate->setDelimiter(QLatin1String(" "));
|
||||||
itemDelegate->setAnnotationRole(QmlOutlineModel::AnnotationRole);
|
itemDelegate->setAnnotationRole(QmlOutlineModel::AnnotationRole);
|
||||||
setItemDelegateForColumn(0, itemDelegate);
|
setItemDelegateForColumn(0, itemDelegate);
|
||||||
|
@@ -34,9 +34,9 @@ class QmlJSOutlineTreeView : public Utils::NavigationTreeView
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit QmlJSOutlineTreeView(QWidget *parent = 0);
|
explicit QmlJSOutlineTreeView(QWidget *parent = nullptr);
|
||||||
|
|
||||||
void contextMenuEvent(QContextMenuEvent *event);
|
void contextMenuEvent(QContextMenuEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void collapseAllExceptRoot();
|
void collapseAllExceptRoot();
|
||||||
|
@@ -38,10 +38,10 @@ namespace QmlJSEditor {
|
|||||||
|
|
||||||
namespace Internal { class QmlJSQuickFixAssistInterface; }
|
namespace Internal { class QmlJSQuickFixAssistInterface; }
|
||||||
|
|
||||||
typedef QSharedPointer<const Internal::QmlJSQuickFixAssistInterface> QmlJSQuickFixInterface;
|
using QmlJSQuickFixInterface = QSharedPointer<const Internal::QmlJSQuickFixAssistInterface>;
|
||||||
typedef TextEditor::QuickFixOperation QuickFixOperation;
|
using TextEditor::QuickFixOperation;
|
||||||
typedef TextEditor::QuickFixOperations QuickFixOperations;
|
using TextEditor::QuickFixOperations;
|
||||||
typedef TextEditor::QuickFixInterface QuickFixInterface;
|
using TextEditor::QuickFixInterface;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
A quick-fix operation for the QML/JavaScript editor.
|
A quick-fix operation for the QML/JavaScript editor.
|
||||||
@@ -60,7 +60,7 @@ public:
|
|||||||
void perform() override;
|
void perform() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef Utils::ChangeSet::Range Range;
|
using Range = Utils::ChangeSet::Range;
|
||||||
|
|
||||||
virtual void performChanges(QmlJSTools::QmlJSRefactoringFilePtr currentFile,
|
virtual void performChanges(QmlJSTools::QmlJSRefactoringFilePtr currentFile,
|
||||||
const QmlJSTools::QmlJSRefactoringChanges &refactoring) = 0;
|
const QmlJSTools::QmlJSRefactoringChanges &refactoring) = 0;
|
||||||
|
@@ -53,8 +53,7 @@ QmlJSQuickFixAssistInterface::QmlJSQuickFixAssistInterface(QmlJSEditorWidget *ed
|
|||||||
, m_currentFile(QmlJSRefactoringChanges::file(editor, m_semanticInfo.document))
|
, m_currentFile(QmlJSRefactoringChanges::file(editor, m_semanticInfo.document))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QmlJSQuickFixAssistInterface::~QmlJSQuickFixAssistInterface()
|
QmlJSQuickFixAssistInterface::~QmlJSQuickFixAssistInterface() = default;
|
||||||
{}
|
|
||||||
|
|
||||||
const SemanticInfo &QmlJSQuickFixAssistInterface::semanticInfo() const
|
const SemanticInfo &QmlJSQuickFixAssistInterface::semanticInfo() const
|
||||||
{
|
{
|
||||||
|
@@ -39,7 +39,7 @@ class QmlJSQuickFixAssistInterface : public TextEditor::AssistInterface
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QmlJSQuickFixAssistInterface(QmlJSEditorWidget *editor, TextEditor::AssistReason reason);
|
QmlJSQuickFixAssistInterface(QmlJSEditorWidget *editor, TextEditor::AssistReason reason);
|
||||||
~QmlJSQuickFixAssistInterface();
|
~QmlJSQuickFixAssistInterface() override;
|
||||||
|
|
||||||
const QmlJSTools::SemanticInfo &semanticInfo() const;
|
const QmlJSTools::SemanticInfo &semanticInfo() const;
|
||||||
QmlJSTools::QmlJSRefactoringFilePtr currentFile() const;
|
QmlJSTools::QmlJSRefactoringFilePtr currentFile() const;
|
||||||
@@ -54,7 +54,7 @@ class QmlJSQuickFixAssistProvider : public TextEditor::IAssistProvider
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QmlJSQuickFixAssistProvider() = default;
|
QmlJSQuickFixAssistProvider() = default;
|
||||||
~QmlJSQuickFixAssistProvider() = default;
|
~QmlJSQuickFixAssistProvider() override = default;
|
||||||
|
|
||||||
IAssistProvider::RunType runType() const override;
|
IAssistProvider::RunType runType() const override;
|
||||||
TextEditor::IAssistProcessor *createProcessor() const override;
|
TextEditor::IAssistProcessor *createProcessor() const override;
|
||||||
|
@@ -73,9 +73,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void performChanges(QmlJSRefactoringFilePtr currentFile,
|
void performChanges(QmlJSRefactoringFilePtr currentFile,
|
||||||
const QmlJSRefactoringChanges &)
|
const QmlJSRefactoringChanges &) override
|
||||||
{
|
{
|
||||||
Q_ASSERT(_objectInitializer != 0);
|
Q_ASSERT(_objectInitializer);
|
||||||
|
|
||||||
Utils::ChangeSet changes;
|
Utils::ChangeSet changes;
|
||||||
|
|
||||||
@@ -101,16 +101,16 @@ public:
|
|||||||
|
|
||||||
void matchSplitInitializerQuickFix(const QmlJSQuickFixInterface &interface, QuickFixOperations &result)
|
void matchSplitInitializerQuickFix(const QmlJSQuickFixInterface &interface, QuickFixOperations &result)
|
||||||
{
|
{
|
||||||
UiObjectInitializer *objectInitializer = 0;
|
UiObjectInitializer *objectInitializer = nullptr;
|
||||||
|
|
||||||
const int pos = interface->currentFile()->cursor().position();
|
const int pos = interface->currentFile()->cursor().position();
|
||||||
|
|
||||||
if (Node *member = interface->semanticInfo().rangeAt(pos)) {
|
if (Node *member = interface->semanticInfo().rangeAt(pos)) {
|
||||||
if (UiObjectBinding *b = AST::cast<UiObjectBinding *>(member)) {
|
if (auto b = AST::cast<const UiObjectBinding *>(member)) {
|
||||||
if (b->initializer->lbraceToken.startLine == b->initializer->rbraceToken.startLine)
|
if (b->initializer->lbraceToken.startLine == b->initializer->rbraceToken.startLine)
|
||||||
objectInitializer = b->initializer;
|
objectInitializer = b->initializer;
|
||||||
|
|
||||||
} else if (UiObjectDefinition *b = AST::cast<UiObjectDefinition *>(member)) {
|
} else if (auto b = AST::cast<const UiObjectDefinition *>(member)) {
|
||||||
if (b->initializer->lbraceToken.startLine == b->initializer->rbraceToken.startLine)
|
if (b->initializer->lbraceToken.startLine == b->initializer->rbraceToken.startLine)
|
||||||
objectInitializer = b->initializer;
|
objectInitializer = b->initializer;
|
||||||
}
|
}
|
||||||
|
@@ -72,7 +72,7 @@ static bool isIdScope(const ObjectValue *scope, const QList<const QmlComponentCh
|
|||||||
class CollectStateNames : protected Visitor
|
class CollectStateNames : protected Visitor
|
||||||
{
|
{
|
||||||
QStringList m_stateNames;
|
QStringList m_stateNames;
|
||||||
bool m_inStateType;
|
bool m_inStateType = false;
|
||||||
ScopeChain m_scopeChain;
|
ScopeChain m_scopeChain;
|
||||||
const CppComponentValue *m_statePrototype;
|
const CppComponentValue *m_statePrototype;
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ protected:
|
|||||||
ast->accept(this);
|
ast->accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool preVisit(Node *ast)
|
bool preVisit(Node *ast) override
|
||||||
{
|
{
|
||||||
return ast->uiObjectMemberCast()
|
return ast->uiObjectMemberCast()
|
||||||
|| cast<UiProgram *>(ast)
|
|| cast<UiProgram *>(ast)
|
||||||
@@ -127,7 +127,7 @@ protected:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool visit(UiObjectDefinition *ast)
|
bool visit(UiObjectDefinition *ast) override
|
||||||
{
|
{
|
||||||
const bool old = m_inStateType;
|
const bool old = m_inStateType;
|
||||||
m_inStateType = hasStatePrototype(ast);
|
m_inStateType = hasStatePrototype(ast);
|
||||||
@@ -136,7 +136,7 @@ protected:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool visit(UiObjectBinding *ast)
|
bool visit(UiObjectBinding *ast) override
|
||||||
{
|
{
|
||||||
const bool old = m_inStateType;
|
const bool old = m_inStateType;
|
||||||
m_inStateType = hasStatePrototype(ast);
|
m_inStateType = hasStatePrototype(ast);
|
||||||
@@ -145,7 +145,7 @@ protected:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool visit(UiScriptBinding *ast)
|
bool visit(UiScriptBinding *ast) override
|
||||||
{
|
{
|
||||||
if (!m_inStateType)
|
if (!m_inStateType)
|
||||||
return false;
|
return false;
|
||||||
@@ -154,10 +154,10 @@ protected:
|
|||||||
if (ast->qualifiedId->name != QLatin1String("name"))
|
if (ast->qualifiedId->name != QLatin1String("name"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ExpressionStatement *expStmt = cast<ExpressionStatement *>(ast->statement);
|
auto expStmt = cast<const ExpressionStatement *>(ast->statement);
|
||||||
if (!expStmt)
|
if (!expStmt)
|
||||||
return false;
|
return false;
|
||||||
StringLiteral *strLit = cast<StringLiteral *>(expStmt->expression);
|
auto strLit = cast<const StringLiteral *>(expStmt->expression);
|
||||||
if (!strLit || strLit->value.isEmpty())
|
if (!strLit || strLit->value.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -237,7 +237,7 @@ protected:
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
const QString &nameStr = name.toString();
|
const QString &nameStr = name.toString();
|
||||||
const ObjectValue *scope = 0;
|
const ObjectValue *scope = nullptr;
|
||||||
const Value *value = m_scopeChain.lookup(nameStr, &scope);
|
const Value *value = m_scopeChain.lookup(nameStr, &scope);
|
||||||
if (!value || !scope)
|
if (!value || !scope)
|
||||||
return;
|
return;
|
||||||
@@ -284,13 +284,13 @@ protected:
|
|||||||
addUse(fullLocationForQualifiedId(localId), SemanticHighlighter::BindingNameType);
|
addUse(fullLocationForQualifiedId(localId), SemanticHighlighter::BindingNameType);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool visit(UiImport *ast)
|
bool visit(UiImport *ast) override
|
||||||
{
|
{
|
||||||
processName(ast->importId, ast->importIdToken);
|
processName(ast->importId, ast->importIdToken);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool visit(UiObjectDefinition *ast)
|
bool visit(UiObjectDefinition *ast) override
|
||||||
{
|
{
|
||||||
if (m_scopeChain.document()->bind()->isGroupedPropertyBinding(ast))
|
if (m_scopeChain.document()->bind()->isGroupedPropertyBinding(ast))
|
||||||
processBindingName(ast->qualifiedTypeNameId);
|
processBindingName(ast->qualifiedTypeNameId);
|
||||||
@@ -300,7 +300,7 @@ protected:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool visit(UiObjectBinding *ast)
|
bool visit(UiObjectBinding *ast) override
|
||||||
{
|
{
|
||||||
processTypeId(ast->qualifiedTypeNameId);
|
processTypeId(ast->qualifiedTypeNameId);
|
||||||
processBindingName(ast->qualifiedId);
|
processBindingName(ast->qualifiedId);
|
||||||
@@ -308,20 +308,20 @@ protected:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool visit(UiScriptBinding *ast)
|
bool visit(UiScriptBinding *ast) override
|
||||||
{
|
{
|
||||||
processBindingName(ast->qualifiedId);
|
processBindingName(ast->qualifiedId);
|
||||||
scopedAccept(ast, ast->statement);
|
scopedAccept(ast, ast->statement);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool visit(UiArrayBinding *ast)
|
bool visit(UiArrayBinding *ast) override
|
||||||
{
|
{
|
||||||
processBindingName(ast->qualifiedId);
|
processBindingName(ast->qualifiedId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool visit(UiPublicMember *ast)
|
bool visit(UiPublicMember *ast) override
|
||||||
{
|
{
|
||||||
if (ast->typeToken.isValid()) { // TODO: ast->isValid() ?
|
if (ast->typeToken.isValid()) { // TODO: ast->isValid() ?
|
||||||
if (m_scopeChain.context()->lookupType(m_scopeChain.document().data(), QStringList(ast->memberType->name.toString())))
|
if (m_scopeChain.context()->lookupType(m_scopeChain.document().data(), QStringList(ast->memberType->name.toString())))
|
||||||
@@ -338,32 +338,32 @@ protected:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool visit(FunctionExpression *ast)
|
bool visit(FunctionExpression *ast) override
|
||||||
{
|
{
|
||||||
processName(ast->name, ast->identifierToken);
|
processName(ast->name, ast->identifierToken);
|
||||||
scopedAccept(ast, ast->body);
|
scopedAccept(ast, ast->body);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool visit(FunctionDeclaration *ast)
|
bool visit(FunctionDeclaration *ast) override
|
||||||
{
|
{
|
||||||
return visit(static_cast<FunctionExpression *>(ast));
|
return visit(static_cast<FunctionExpression *>(ast));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool visit(PatternElement *ast)
|
bool visit(PatternElement *ast) override
|
||||||
{
|
{
|
||||||
if (ast->isVariableDeclaration())
|
if (ast->isVariableDeclaration())
|
||||||
processName(ast->bindingIdentifier, ast->identifierToken);
|
processName(ast->bindingIdentifier, ast->identifierToken);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool visit(IdentifierExpression *ast)
|
bool visit(IdentifierExpression *ast) override
|
||||||
{
|
{
|
||||||
processName(ast->name, ast->identifierToken);
|
processName(ast->name, ast->identifierToken);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool visit(StringLiteral *ast)
|
bool visit(StringLiteral *ast) override
|
||||||
{
|
{
|
||||||
if (ast->value.isEmpty())
|
if (ast->value.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
@@ -66,7 +66,7 @@ public:
|
|||||||
Max // number of the last used value (to generate the warning formats)
|
Max // number of the last used value (to generate the warning formats)
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef TextEditor::HighlightingResult Use;
|
using Use = TextEditor::HighlightingResult;
|
||||||
|
|
||||||
SemanticHighlighter(QmlJSEditorDocument *document);
|
SemanticHighlighter(QmlJSEditorDocument *document);
|
||||||
|
|
||||||
|
@@ -47,9 +47,7 @@ SemanticInfoUpdater::SemanticInfoUpdater(QObject *parent)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SemanticInfoUpdater::~SemanticInfoUpdater()
|
SemanticInfoUpdater::~SemanticInfoUpdater() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void SemanticInfoUpdater::abort()
|
void SemanticInfoUpdater::abort()
|
||||||
{
|
{
|
||||||
@@ -121,7 +119,7 @@ QmlJSTools::SemanticInfo SemanticInfoUpdater::makeNewSemanticInfo(const QmlJS::D
|
|||||||
Link link(semanticInfo.snapshot, modelManager->defaultVContext(doc->language(), doc), modelManager->builtins(doc));
|
Link link(semanticInfo.snapshot, modelManager->defaultVContext(doc->language(), doc), modelManager->builtins(doc));
|
||||||
semanticInfo.context = link(doc, &semanticInfo.semanticMessages);
|
semanticInfo.context = link(doc, &semanticInfo.semanticMessages);
|
||||||
|
|
||||||
ScopeChain *scopeChain = new ScopeChain(doc, semanticInfo.context);
|
auto scopeChain = new ScopeChain(doc, semanticInfo.context);
|
||||||
semanticInfo.setRootScopeChain(QSharedPointer<const ScopeChain>(scopeChain));
|
semanticInfo.setRootScopeChain(QSharedPointer<const ScopeChain>(scopeChain));
|
||||||
|
|
||||||
if (doc->language() == Dialect::Json) {
|
if (doc->language() == Dialect::Json) {
|
||||||
|
@@ -40,8 +40,8 @@ class SemanticInfoUpdater: public QThread
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SemanticInfoUpdater(QObject *parent = 0);
|
SemanticInfoUpdater(QObject *parent = nullptr);
|
||||||
virtual ~SemanticInfoUpdater();
|
~SemanticInfoUpdater() override;
|
||||||
|
|
||||||
void abort();
|
void abort();
|
||||||
void update(const QmlJS::Document::Ptr &doc, const QmlJS::Snapshot &snapshot);
|
void update(const QmlJS::Document::Ptr &doc, const QmlJS::Snapshot &snapshot);
|
||||||
@@ -51,7 +51,7 @@ signals:
|
|||||||
void updated(const QmlJSTools::SemanticInfo &semanticInfo);
|
void updated(const QmlJSTools::SemanticInfo &semanticInfo);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void run();
|
void run() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QmlJSTools::SemanticInfo makeNewSemanticInfo(const QmlJS::Document::Ptr &doc,
|
QmlJSTools::SemanticInfo makeNewSemanticInfo(const QmlJS::Document::Ptr &doc,
|
||||||
|
@@ -86,7 +86,7 @@ void QmlJSTextMark::removedFromEditor()
|
|||||||
m_removedFromEditorHandler(this);
|
m_removedFromEditorHandler(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSTextMark::init(bool warning, const QString message)
|
void QmlJSTextMark::init(bool warning, const QString &message)
|
||||||
{
|
{
|
||||||
setIcon(warning ? Utils::Icons::CODEMODEL_WARNING.icon()
|
setIcon(warning ? Utils::Icons::CODEMODEL_WARNING.icon()
|
||||||
: Utils::Icons::CODEMODEL_ERROR.icon());
|
: Utils::Icons::CODEMODEL_ERROR.icon());
|
||||||
|
@@ -47,7 +47,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void removedFromEditor() override;
|
void removedFromEditor() override;
|
||||||
void init(bool warning, const QString message);
|
void init(bool warning, const QString &message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RemovedFromEditorHandler m_removedFromEditorHandler;
|
RemovedFromEditorHandler m_removedFromEditorHandler;
|
||||||
|
@@ -52,7 +52,7 @@ namespace {
|
|||||||
class FindIds : protected Visitor
|
class FindIds : protected Visitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef QHash<QString, SourceLocation> Result;
|
using Result = QHash<QString, SourceLocation>;
|
||||||
|
|
||||||
Result operator()(Node *node)
|
Result operator()(Node *node)
|
||||||
{
|
{
|
||||||
@@ -87,7 +87,7 @@ public:
|
|||||||
: QmlJSQuickFixOperation(interface, 0)
|
: QmlJSQuickFixOperation(interface, 0)
|
||||||
, m_objDef(objDef)
|
, m_objDef(objDef)
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_objDef != 0);
|
Q_ASSERT(m_objDef);
|
||||||
|
|
||||||
setDescription(tr("Wrap Component in Loader"));
|
setDescription(tr("Wrap Component in Loader"));
|
||||||
}
|
}
|
||||||
@@ -96,7 +96,7 @@ public:
|
|||||||
{
|
{
|
||||||
QString tryName = base;
|
QString tryName = base;
|
||||||
int extraNumber = 1;
|
int extraNumber = 1;
|
||||||
const ObjectValue *found = 0;
|
const ObjectValue *found = nullptr;
|
||||||
const ScopeChain &scope = assistInterface()->semanticInfo().scopeChain();
|
const ScopeChain &scope = assistInterface()->semanticInfo().scopeChain();
|
||||||
forever {
|
forever {
|
||||||
scope.lookup(tryName, &found);
|
scope.lookup(tryName, &found);
|
||||||
@@ -181,7 +181,7 @@ void matchWrapInLoaderQuickFix(const QmlJSQuickFixInterface &interface, QuickFix
|
|||||||
QList<Node *> path = interface->semanticInfo().rangePath(pos);
|
QList<Node *> path = interface->semanticInfo().rangePath(pos);
|
||||||
for (int i = path.size() - 1; i >= 0; --i) {
|
for (int i = path.size() - 1; i >= 0; --i) {
|
||||||
Node *node = path.at(i);
|
Node *node = path.at(i);
|
||||||
if (UiObjectDefinition *objDef = cast<UiObjectDefinition *>(node)) {
|
if (auto objDef = cast<UiObjectDefinition *>(node)) {
|
||||||
if (!interface->currentFile()->isCursorOn(objDef->qualifiedTypeNameId))
|
if (!interface->currentFile()->isCursorOn(objDef->qualifiedTypeNameId))
|
||||||
return;
|
return;
|
||||||
// check that the node is not the root node
|
// check that the node is not the root node
|
||||||
@@ -189,7 +189,7 @@ void matchWrapInLoaderQuickFix(const QmlJSQuickFixInterface &interface, QuickFix
|
|||||||
result << new Operation<UiObjectDefinition>(interface, objDef);
|
result << new Operation<UiObjectDefinition>(interface, objDef);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (UiObjectBinding *objBinding = cast<UiObjectBinding *>(node)) {
|
} else if (auto objBinding = cast<UiObjectBinding *>(node)) {
|
||||||
if (!interface->currentFile()->isCursorOn(objBinding->qualifiedTypeNameId))
|
if (!interface->currentFile()->isCursorOn(objBinding->qualifiedTypeNameId))
|
||||||
return;
|
return;
|
||||||
result << new Operation<UiObjectBinding>(interface, objBinding);
|
result << new Operation<UiObjectBinding>(interface, objBinding);
|
||||||
|
@@ -131,14 +131,14 @@ private:
|
|||||||
QHash<AST::UiObjectMember*,AST::UiObjectMember*> parent;
|
QHash<AST::UiObjectMember*,AST::UiObjectMember*> parent;
|
||||||
QList<AST::UiObjectMember *> stack;
|
QList<AST::UiObjectMember *> stack;
|
||||||
|
|
||||||
bool preVisit(AST::Node *node)
|
bool preVisit(AST::Node *node) override
|
||||||
{
|
{
|
||||||
if (AST::UiObjectMember *objMember = node->uiObjectMemberCast())
|
if (AST::UiObjectMember *objMember = node->uiObjectMemberCast())
|
||||||
stack.append(objMember);
|
stack.append(objMember);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void postVisit(AST::Node *node)
|
void postVisit(AST::Node *node) override
|
||||||
{
|
{
|
||||||
if (AST::UiObjectMember *objMember = node->uiObjectMemberCast()) {
|
if (AST::UiObjectMember *objMember = node->uiObjectMemberCast()) {
|
||||||
stack.removeLast();
|
stack.removeLast();
|
||||||
@@ -169,7 +169,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool preVisit(AST::Node *node)
|
bool preVisit(AST::Node *node) override
|
||||||
{
|
{
|
||||||
if (!node)
|
if (!node)
|
||||||
return false;
|
return false;
|
||||||
@@ -178,37 +178,37 @@ private:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void postVisit(AST::Node *)
|
void postVisit(AST::Node *) override
|
||||||
{
|
{
|
||||||
indent--;
|
indent--;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef QPair<QString,QString> ElementType;
|
using ElementType = QPair<QString,QString>;
|
||||||
bool visit(AST::UiObjectDefinition *objDef)
|
bool visit(AST::UiObjectDefinition *objDef) override
|
||||||
{
|
{
|
||||||
QModelIndex index = m_model->enterObjectDefinition(objDef);
|
QModelIndex index = m_model->enterObjectDefinition(objDef);
|
||||||
m_nodeToIndex.insert(objDef, index);
|
m_nodeToIndex.insert(objDef, index);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void endVisit(AST::UiObjectDefinition * /*objDef*/)
|
void endVisit(AST::UiObjectDefinition * /*objDef*/) override
|
||||||
{
|
{
|
||||||
m_model->leaveObjectDefiniton();
|
m_model->leaveObjectDefiniton();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool visit(AST::UiObjectBinding *objBinding)
|
bool visit(AST::UiObjectBinding *objBinding) override
|
||||||
{
|
{
|
||||||
QModelIndex index = m_model->enterObjectBinding(objBinding);
|
QModelIndex index = m_model->enterObjectBinding(objBinding);
|
||||||
m_nodeToIndex.insert(objBinding, index);
|
m_nodeToIndex.insert(objBinding, index);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void endVisit(AST::UiObjectBinding * /*objBinding*/)
|
void endVisit(AST::UiObjectBinding * /*objBinding*/) override
|
||||||
{
|
{
|
||||||
m_model->leaveObjectBinding();
|
m_model->leaveObjectBinding();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool visit(AST::UiArrayBinding *arrayBinding)
|
bool visit(AST::UiArrayBinding *arrayBinding) override
|
||||||
{
|
{
|
||||||
QModelIndex index = m_model->enterArrayBinding(arrayBinding);
|
QModelIndex index = m_model->enterArrayBinding(arrayBinding);
|
||||||
m_nodeToIndex.insert(arrayBinding, index);
|
m_nodeToIndex.insert(arrayBinding, index);
|
||||||
@@ -216,12 +216,12 @@ private:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void endVisit(AST::UiArrayBinding * /*arrayBinding*/)
|
void endVisit(AST::UiArrayBinding * /*arrayBinding*/) override
|
||||||
{
|
{
|
||||||
m_model->leaveArrayBinding();
|
m_model->leaveArrayBinding();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool visit(AST::UiScriptBinding *scriptBinding)
|
bool visit(AST::UiScriptBinding *scriptBinding) override
|
||||||
{
|
{
|
||||||
QModelIndex index = m_model->enterScriptBinding(scriptBinding);
|
QModelIndex index = m_model->enterScriptBinding(scriptBinding);
|
||||||
m_nodeToIndex.insert(scriptBinding, index);
|
m_nodeToIndex.insert(scriptBinding, index);
|
||||||
@@ -229,12 +229,12 @@ private:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void endVisit(AST::UiScriptBinding * /*scriptBinding*/)
|
void endVisit(AST::UiScriptBinding * /*scriptBinding*/) override
|
||||||
{
|
{
|
||||||
m_model->leaveScriptBinding();
|
m_model->leaveScriptBinding();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool visit(AST::UiPublicMember *publicMember)
|
bool visit(AST::UiPublicMember *publicMember) override
|
||||||
{
|
{
|
||||||
QModelIndex index = m_model->enterPublicMember(publicMember);
|
QModelIndex index = m_model->enterPublicMember(publicMember);
|
||||||
m_nodeToIndex.insert(publicMember, index);
|
m_nodeToIndex.insert(publicMember, index);
|
||||||
@@ -242,12 +242,12 @@ private:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void endVisit(AST::UiPublicMember * /*publicMember*/)
|
void endVisit(AST::UiPublicMember * /*publicMember*/) override
|
||||||
{
|
{
|
||||||
m_model->leavePublicMember();
|
m_model->leavePublicMember();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool visit(AST::FunctionDeclaration *functionDeclaration)
|
bool visit(AST::FunctionDeclaration *functionDeclaration) override
|
||||||
{
|
{
|
||||||
QModelIndex index = m_model->enterFunctionDeclaration(functionDeclaration);
|
QModelIndex index = m_model->enterFunctionDeclaration(functionDeclaration);
|
||||||
m_nodeToIndex.insert(functionDeclaration, index);
|
m_nodeToIndex.insert(functionDeclaration, index);
|
||||||
@@ -255,15 +255,15 @@ private:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void endVisit(AST::FunctionDeclaration * /*functionDeclaration*/)
|
void endVisit(AST::FunctionDeclaration * /*functionDeclaration*/) override
|
||||||
{
|
{
|
||||||
m_model->leaveFunctionDeclaration();
|
m_model->leaveFunctionDeclaration();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool visit(AST::BinaryExpression *binExp)
|
bool visit(AST::BinaryExpression *binExp) override
|
||||||
{
|
{
|
||||||
AST::IdentifierExpression *lhsIdent = AST::cast<AST::IdentifierExpression *>(binExp->left);
|
auto lhsIdent = AST::cast<const AST::IdentifierExpression *>(binExp->left);
|
||||||
AST::ObjectPattern *rhsObjLit = AST::cast<AST::ObjectPattern *>(binExp->right);
|
auto rhsObjLit = AST::cast<AST::ObjectPattern *>(binExp->right);
|
||||||
|
|
||||||
if (lhsIdent && rhsObjLit && (lhsIdent->name == QLatin1String("testcase"))
|
if (lhsIdent && rhsObjLit && (lhsIdent->name == QLatin1String("testcase"))
|
||||||
&& (binExp->op == QSOperator::Assign)) {
|
&& (binExp->op == QSOperator::Assign)) {
|
||||||
@@ -295,8 +295,8 @@ private:
|
|||||||
while (properties) {
|
while (properties) {
|
||||||
QModelIndex index = m_model->enterTestCaseProperties(properties);
|
QModelIndex index = m_model->enterTestCaseProperties(properties);
|
||||||
m_nodeToIndex.insert(properties, index);
|
m_nodeToIndex.insert(properties, index);
|
||||||
if (AST::PatternProperty *assignment = AST::cast<AST::PatternProperty *>(properties->property))
|
if (auto assignment = AST::cast<const AST::PatternProperty *>(properties->property))
|
||||||
if (AST::ObjectPattern *objLiteral = AST::cast<AST::ObjectPattern *>(assignment->initializer))
|
if (auto objLiteral = AST::cast<const AST::ObjectPattern *>(assignment->initializer))
|
||||||
visitProperties(objLiteral->properties);
|
visitProperties(objLiteral->properties);
|
||||||
|
|
||||||
m_model->leaveTestCaseProperties();
|
m_model->leaveTestCaseProperties();
|
||||||
@@ -333,16 +333,14 @@ QStringList QmlOutlineModel::mimeTypes() const
|
|||||||
QMimeData *QmlOutlineModel::mimeData(const QModelIndexList &indexes) const
|
QMimeData *QmlOutlineModel::mimeData(const QModelIndexList &indexes) const
|
||||||
{
|
{
|
||||||
if (indexes.count() <= 0)
|
if (indexes.count() <= 0)
|
||||||
return 0;
|
return nullptr;
|
||||||
auto data = new Utils::DropMimeData;
|
auto data = new Utils::DropMimeData;
|
||||||
data->setOverrideFileDropAction(Qt::CopyAction);
|
data->setOverrideFileDropAction(Qt::CopyAction);
|
||||||
QByteArray encoded;
|
QByteArray encoded;
|
||||||
QDataStream stream(&encoded, QIODevice::WriteOnly);
|
QDataStream stream(&encoded, QIODevice::WriteOnly);
|
||||||
stream << indexes.size();
|
stream << indexes.size();
|
||||||
|
|
||||||
for (int i = 0; i < indexes.size(); ++i) {
|
for (const auto &index : indexes) {
|
||||||
QModelIndex index = indexes.at(i);
|
|
||||||
|
|
||||||
AST::SourceLocation location = sourceLocation(index);
|
AST::SourceLocation location = sourceLocation(index);
|
||||||
data->addFile(m_editorDocument->filePath().toString(), location.startLine,
|
data->addFile(m_editorDocument->filePath().toString(), location.startLine,
|
||||||
location.startColumn - 1 /*editors have 0-based column*/);
|
location.startColumn - 1 /*editors have 0-based column*/);
|
||||||
@@ -399,7 +397,7 @@ bool QmlOutlineModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
|
|||||||
itemsToMove << static_cast<QmlOutlineItem*>(itemFromIndex(index));
|
itemsToMove << static_cast<QmlOutlineItem*>(itemFromIndex(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlOutlineItem *targetItem = static_cast<QmlOutlineItem*>(itemFromIndex(parent));
|
auto targetItem = static_cast<QmlOutlineItem*>(itemFromIndex(parent));
|
||||||
reparentNodes(targetItem, row, itemsToMove);
|
reparentNodes(targetItem, row, itemsToMove);
|
||||||
|
|
||||||
// Prevent view from calling removeRow() on it's own
|
// Prevent view from calling removeRow() on it's own
|
||||||
@@ -474,7 +472,7 @@ QModelIndex QmlOutlineModel::enterObjectDefinition(AST::UiObjectDefinition *objD
|
|||||||
const QString typeName = asString(objDef->qualifiedTypeNameId);
|
const QString typeName = asString(objDef->qualifiedTypeNameId);
|
||||||
|
|
||||||
QMap<int, QVariant> data;
|
QMap<int, QVariant> data;
|
||||||
AST::UiQualifiedId *idNode = 0;
|
AST::UiQualifiedId *idNode = nullptr;
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
|
|
||||||
data.insert(Qt::DisplayRole, typeName);
|
data.insert(Qt::DisplayRole, typeName);
|
||||||
@@ -575,7 +573,7 @@ QModelIndex QmlOutlineModel::enterPublicMember(AST::UiPublicMember *publicMember
|
|||||||
objectData.insert(AnnotationRole, getAnnotation(publicMember->statement));
|
objectData.insert(AnnotationRole, getAnnotation(publicMember->statement));
|
||||||
objectData.insert(ItemTypeRole, NonElementBindingType);
|
objectData.insert(ItemTypeRole, NonElementBindingType);
|
||||||
|
|
||||||
QmlOutlineItem *item = enterNode(objectData, publicMember, 0, Icons::publicMemberIcon());
|
QmlOutlineItem *item = enterNode(objectData, publicMember, nullptr, Icons::publicMemberIcon());
|
||||||
|
|
||||||
return item->index();
|
return item->index();
|
||||||
}
|
}
|
||||||
@@ -610,7 +608,8 @@ QModelIndex QmlOutlineModel::enterFunctionDeclaration(AST::FunctionDeclaration *
|
|||||||
functionDeclaration->formals));
|
functionDeclaration->formals));
|
||||||
objectData.insert(ItemTypeRole, ElementBindingType);
|
objectData.insert(ItemTypeRole, ElementBindingType);
|
||||||
|
|
||||||
QmlOutlineItem *item = enterNode(objectData, functionDeclaration, 0, Icons::functionDeclarationIcon());
|
QmlOutlineItem *item = enterNode(objectData, functionDeclaration, nullptr,
|
||||||
|
Icons::functionDeclarationIcon());
|
||||||
|
|
||||||
return item->index();
|
return item->index();
|
||||||
}
|
}
|
||||||
@@ -640,7 +639,8 @@ QModelIndex QmlOutlineModel::enterFieldMemberExpression(AST::FieldMemberExpressi
|
|||||||
objectData.insert(Qt::DisplayRole, display);
|
objectData.insert(Qt::DisplayRole, display);
|
||||||
objectData.insert(ItemTypeRole, ElementBindingType);
|
objectData.insert(ItemTypeRole, ElementBindingType);
|
||||||
|
|
||||||
QmlOutlineItem *item = enterNode(objectData, expression, 0, m_icons->functionDeclarationIcon());
|
QmlOutlineItem *item = enterNode(objectData, expression, nullptr,
|
||||||
|
m_icons->functionDeclarationIcon());
|
||||||
|
|
||||||
return item->index();
|
return item->index();
|
||||||
}
|
}
|
||||||
@@ -657,7 +657,8 @@ QModelIndex QmlOutlineModel::enterTestCase(AST::ObjectPattern *objectLiteral)
|
|||||||
objectData.insert(Qt::DisplayRole, QLatin1String("testcase"));
|
objectData.insert(Qt::DisplayRole, QLatin1String("testcase"));
|
||||||
objectData.insert(ItemTypeRole, ElementBindingType);
|
objectData.insert(ItemTypeRole, ElementBindingType);
|
||||||
|
|
||||||
QmlOutlineItem *item = enterNode(objectData, objectLiteral, 0, Icons::objectDefinitionIcon());
|
QmlOutlineItem *item = enterNode(objectData, objectLiteral, nullptr,
|
||||||
|
Icons::objectDefinitionIcon());
|
||||||
|
|
||||||
return item->index();
|
return item->index();
|
||||||
}
|
}
|
||||||
@@ -670,29 +671,29 @@ void QmlOutlineModel::leaveTestCase()
|
|||||||
QModelIndex QmlOutlineModel::enterTestCaseProperties(AST::PatternPropertyList *propertyAssignmentList)
|
QModelIndex QmlOutlineModel::enterTestCaseProperties(AST::PatternPropertyList *propertyAssignmentList)
|
||||||
{
|
{
|
||||||
QMap<int, QVariant> objectData;
|
QMap<int, QVariant> objectData;
|
||||||
if (AST::PatternProperty *assignment = AST::cast<AST::PatternProperty *>(
|
if (auto assignment = AST::cast<AST::PatternProperty *>(
|
||||||
propertyAssignmentList->property)) {
|
propertyAssignmentList->property)) {
|
||||||
if (AST::IdentifierPropertyName *propertyName = AST::cast<AST::IdentifierPropertyName *>(assignment->name)) {
|
if (auto propertyName = AST::cast<const AST::IdentifierPropertyName *>(assignment->name)) {
|
||||||
objectData.insert(Qt::DisplayRole, propertyName->id.toString());
|
objectData.insert(Qt::DisplayRole, propertyName->id.toString());
|
||||||
objectData.insert(ItemTypeRole, ElementBindingType);
|
objectData.insert(ItemTypeRole, ElementBindingType);
|
||||||
QmlOutlineItem *item;
|
QmlOutlineItem *item;
|
||||||
if (assignment->initializer->kind == AST::Node::Kind_FunctionExpression)
|
if (assignment->initializer->kind == AST::Node::Kind_FunctionExpression)
|
||||||
item = enterNode(objectData, assignment, 0, Icons::functionDeclarationIcon());
|
item = enterNode(objectData, assignment, nullptr, Icons::functionDeclarationIcon());
|
||||||
else if (assignment->initializer->kind == AST::Node::Kind_ObjectPattern)
|
else if (assignment->initializer->kind == AST::Node::Kind_ObjectPattern)
|
||||||
item = enterNode(objectData, assignment, 0, Icons::objectDefinitionIcon());
|
item = enterNode(objectData, assignment, nullptr, Icons::objectDefinitionIcon());
|
||||||
else
|
else
|
||||||
item = enterNode(objectData, assignment, 0, Icons::scriptBindingIcon());
|
item = enterNode(objectData, assignment, nullptr, Icons::scriptBindingIcon());
|
||||||
|
|
||||||
return item->index();
|
return item->index();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (AST::PatternProperty *getterSetter = AST::cast<AST::PatternProperty *>(
|
if (auto getterSetter = AST::cast<AST::PatternProperty *>(
|
||||||
propertyAssignmentList->property)) {
|
propertyAssignmentList->property)) {
|
||||||
if (AST::IdentifierPropertyName *propertyName = AST::cast<AST::IdentifierPropertyName *>(getterSetter->name)) {
|
if (auto propertyName = AST::cast<const AST::IdentifierPropertyName *>(getterSetter->name)) {
|
||||||
objectData.insert(Qt::DisplayRole, propertyName->id.toString());
|
objectData.insert(Qt::DisplayRole, propertyName->id.toString());
|
||||||
objectData.insert(ItemTypeRole, ElementBindingType);
|
objectData.insert(ItemTypeRole, ElementBindingType);
|
||||||
QmlOutlineItem *item;
|
QmlOutlineItem *item;
|
||||||
item = enterNode(objectData, getterSetter, 0, Icons::functionDeclarationIcon());
|
item = enterNode(objectData, getterSetter, nullptr, Icons::functionDeclarationIcon());
|
||||||
|
|
||||||
return item->index();
|
return item->index();
|
||||||
|
|
||||||
@@ -708,14 +709,14 @@ void QmlOutlineModel::leaveTestCaseProperties()
|
|||||||
|
|
||||||
AST::Node *QmlOutlineModel::nodeForIndex(const QModelIndex &index) const
|
AST::Node *QmlOutlineModel::nodeForIndex(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(index.isValid() && (index.model() == this), return 0);
|
QTC_ASSERT(index.isValid() && (index.model() == this), return nullptr);
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
QmlOutlineItem *item = static_cast<QmlOutlineItem*>(itemFromIndex(index));
|
auto item = static_cast<QmlOutlineItem*>(itemFromIndex(index));
|
||||||
QTC_ASSERT(item, return 0);
|
QTC_ASSERT(item, return nullptr);
|
||||||
QTC_ASSERT(m_itemToNode.contains(item), return 0);
|
QTC_ASSERT(m_itemToNode.contains(item), return nullptr);
|
||||||
return m_itemToNode.value(item);
|
return m_itemToNode.value(item);
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
AST::SourceLocation QmlOutlineModel::sourceLocation(const QModelIndex &index) const
|
AST::SourceLocation QmlOutlineModel::sourceLocation(const QModelIndex &index) const
|
||||||
@@ -728,7 +729,7 @@ AST::SourceLocation QmlOutlineModel::sourceLocation(const QModelIndex &index) co
|
|||||||
location = getLocation(member);
|
location = getLocation(member);
|
||||||
else if (AST::ExpressionNode *expression = node->expressionCast())
|
else if (AST::ExpressionNode *expression = node->expressionCast())
|
||||||
location = getLocation(expression);
|
location = getLocation(expression);
|
||||||
else if (AST::PatternPropertyList *propertyAssignmentList = AST::cast<AST::PatternPropertyList *>(node))
|
else if (auto propertyAssignmentList = AST::cast<AST::PatternPropertyList *>(node))
|
||||||
location = getLocation(propertyAssignmentList);
|
location = getLocation(propertyAssignmentList);
|
||||||
}
|
}
|
||||||
return location;
|
return location;
|
||||||
@@ -736,22 +737,22 @@ AST::SourceLocation QmlOutlineModel::sourceLocation(const QModelIndex &index) co
|
|||||||
|
|
||||||
AST::UiQualifiedId *QmlOutlineModel::idNode(const QModelIndex &index) const
|
AST::UiQualifiedId *QmlOutlineModel::idNode(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(index.isValid() && (index.model() == this), return 0);
|
QTC_ASSERT(index.isValid() && (index.model() == this), return nullptr);
|
||||||
QmlOutlineItem *item = static_cast<QmlOutlineItem*>(itemFromIndex(index));
|
auto item = static_cast<QmlOutlineItem*>(itemFromIndex(index));
|
||||||
return m_itemToIdNode.value(item);
|
return m_itemToIdNode.value(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon QmlOutlineModel::icon(const QModelIndex &index) const
|
QIcon QmlOutlineModel::icon(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(index.isValid() && (index.model() == this), return QIcon());
|
QTC_ASSERT(index.isValid() && (index.model() == this), return QIcon());
|
||||||
QmlOutlineItem *item = static_cast<QmlOutlineItem*>(itemFromIndex(index));
|
auto item = static_cast<QmlOutlineItem*>(itemFromIndex(index));
|
||||||
return m_itemToIcon.value(item);
|
return m_itemToIcon.value(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlOutlineItem *QmlOutlineModel::enterNode(QMap<int, QVariant> data, AST::Node *node, AST::UiQualifiedId *idNode, const QIcon &icon)
|
QmlOutlineItem *QmlOutlineModel::enterNode(QMap<int, QVariant> data, AST::Node *node, AST::UiQualifiedId *idNode, const QIcon &icon)
|
||||||
{
|
{
|
||||||
int siblingIndex = m_treePos.last();
|
int siblingIndex = m_treePos.last();
|
||||||
QmlOutlineItem *newItem = 0;
|
QmlOutlineItem *newItem = nullptr;
|
||||||
if (siblingIndex == 0) {
|
if (siblingIndex == 0) {
|
||||||
// first child
|
// first child
|
||||||
if (!m_currentItem->hasChildren()) {
|
if (!m_currentItem->hasChildren()) {
|
||||||
@@ -827,19 +828,18 @@ void QmlOutlineModel::reparentNodes(QmlOutlineItem *targetItem, int row, QList<Q
|
|||||||
|
|
||||||
QList<Utils::ChangeSet::Range> changedRanges;
|
QList<Utils::ChangeSet::Range> changedRanges;
|
||||||
|
|
||||||
for (int i = 0; i < itemsToMove.size(); ++i) {
|
for (auto outlineItem : itemsToMove) {
|
||||||
QmlOutlineItem *outlineItem = itemsToMove.at(i);
|
|
||||||
AST::UiObjectMember *sourceObjectMember = m_itemToNode.value(outlineItem)->uiObjectMemberCast();
|
AST::UiObjectMember *sourceObjectMember = m_itemToNode.value(outlineItem)->uiObjectMemberCast();
|
||||||
if (!sourceObjectMember)
|
if (!sourceObjectMember)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool insertionOrderSpecified = true;
|
bool insertionOrderSpecified = true;
|
||||||
AST::UiObjectMember *memberToInsertAfter = 0;
|
AST::UiObjectMember *memberToInsertAfter = nullptr;
|
||||||
{
|
{
|
||||||
if (row == -1) {
|
if (row == -1) {
|
||||||
insertionOrderSpecified = false;
|
insertionOrderSpecified = false;
|
||||||
} else if (row > 0) {
|
} else if (row > 0) {
|
||||||
QmlOutlineItem *outlineItem = static_cast<QmlOutlineItem*>(targetItem->child(row - 1));
|
auto outlineItem = static_cast<QmlOutlineItem*>(targetItem->child(row - 1));
|
||||||
memberToInsertAfter = m_itemToNode.value(outlineItem)->uiObjectMemberCast();
|
memberToInsertAfter = m_itemToNode.value(outlineItem)->uiObjectMemberCast();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -888,8 +888,8 @@ void QmlOutlineModel::moveObjectMember(AST::UiObjectMember *toMove,
|
|||||||
|
|
||||||
Rewriter rewriter(documentText, changeSet, QStringList());
|
Rewriter rewriter(documentText, changeSet, QStringList());
|
||||||
|
|
||||||
if (AST::UiObjectDefinition *objDefinition = AST::cast<AST::UiObjectDefinition*>(newParent)) {
|
if (auto objDefinition = AST::cast<const AST::UiObjectDefinition*>(newParent)) {
|
||||||
AST::UiObjectMemberList *listInsertAfter = 0;
|
AST::UiObjectMemberList *listInsertAfter = nullptr;
|
||||||
if (insertionOrderSpecified) {
|
if (insertionOrderSpecified) {
|
||||||
if (insertAfter) {
|
if (insertAfter) {
|
||||||
listInsertAfter = objDefinition->initializer->members;
|
listInsertAfter = objDefinition->initializer->members;
|
||||||
@@ -898,7 +898,7 @@ void QmlOutlineModel::moveObjectMember(AST::UiObjectMember *toMove,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AST::UiScriptBinding *moveScriptBinding = AST::cast<AST::UiScriptBinding*>(toMove)) {
|
if (auto moveScriptBinding = AST::cast<const AST::UiScriptBinding*>(toMove)) {
|
||||||
const QString propertyName = asString(moveScriptBinding->qualifiedId);
|
const QString propertyName = asString(moveScriptBinding->qualifiedId);
|
||||||
QString propertyValue;
|
QString propertyValue;
|
||||||
{
|
{
|
||||||
@@ -925,8 +925,8 @@ void QmlOutlineModel::moveObjectMember(AST::UiObjectMember *toMove,
|
|||||||
else
|
else
|
||||||
*addedRange = rewriter.addObject(objDefinition->initializer, strToMove);
|
*addedRange = rewriter.addObject(objDefinition->initializer, strToMove);
|
||||||
}
|
}
|
||||||
} else if (AST::UiArrayBinding *arrayBinding = AST::cast<AST::UiArrayBinding*>(newParent)) {
|
} else if (auto arrayBinding = AST::cast<AST::UiArrayBinding*>(newParent)) {
|
||||||
AST::UiArrayMemberList *listInsertAfter = 0;
|
AST::UiArrayMemberList *listInsertAfter = nullptr;
|
||||||
if (insertionOrderSpecified) {
|
if (insertionOrderSpecified) {
|
||||||
if (insertAfter) {
|
if (insertAfter) {
|
||||||
listInsertAfter = arrayBinding->members;
|
listInsertAfter = arrayBinding->members;
|
||||||
@@ -1000,7 +1000,7 @@ AST::SourceLocation QmlOutlineModel::getLocation(AST::ExpressionNode *exprNode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
AST::SourceLocation QmlOutlineModel::getLocation(AST::PatternPropertyList *propertyNode) {
|
AST::SourceLocation QmlOutlineModel::getLocation(AST::PatternPropertyList *propertyNode) {
|
||||||
if (AST::PatternProperty *assignment = AST::cast<AST::PatternProperty *>(propertyNode->property))
|
if (auto assignment = AST::cast<AST::PatternProperty *>(propertyNode->property))
|
||||||
return getLocation(assignment);
|
return getLocation(assignment);
|
||||||
return propertyNode->firstSourceLocation(); // should never happen
|
return propertyNode->firstSourceLocation(); // should never happen
|
||||||
}
|
}
|
||||||
@@ -1045,7 +1045,7 @@ QString QmlOutlineModel::getAnnotation(AST::UiObjectInitializer *objectInitializ
|
|||||||
|
|
||||||
QString QmlOutlineModel::getAnnotation(AST::Statement *statement)
|
QString QmlOutlineModel::getAnnotation(AST::Statement *statement)
|
||||||
{
|
{
|
||||||
if (AST::ExpressionStatement *expr = AST::cast<AST::ExpressionStatement*>(statement))
|
if (auto expr = AST::cast<const AST::ExpressionStatement*>(statement))
|
||||||
return getAnnotation(expr->expression);
|
return getAnnotation(expr->expression);
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
@@ -1065,7 +1065,7 @@ QString QmlOutlineModel::getAnnotation(AST::ExpressionNode *expression)
|
|||||||
QHash<QString,QString> QmlOutlineModel::getScriptBindings(AST::UiObjectInitializer *objectInitializer) {
|
QHash<QString,QString> QmlOutlineModel::getScriptBindings(AST::UiObjectInitializer *objectInitializer) {
|
||||||
QHash <QString,QString> scriptBindings;
|
QHash <QString,QString> scriptBindings;
|
||||||
for (AST::UiObjectMemberList *it = objectInitializer->members; it; it = it->next) {
|
for (AST::UiObjectMemberList *it = objectInitializer->members; it; it = it->next) {
|
||||||
if (AST::UiScriptBinding *binding = AST::cast<AST::UiScriptBinding*>(it->member)) {
|
if (auto binding = AST::cast<const AST::UiScriptBinding*>(it->member)) {
|
||||||
const QString bindingName = asString(binding->qualifiedId);
|
const QString bindingName = asString(binding->qualifiedId);
|
||||||
scriptBindings.insert(bindingName, getAnnotation(binding->statement));
|
scriptBindings.insert(bindingName, getAnnotation(binding->statement));
|
||||||
}
|
}
|
||||||
|
@@ -48,8 +48,8 @@ public:
|
|||||||
QmlOutlineItem(QmlOutlineModel *model);
|
QmlOutlineItem(QmlOutlineModel *model);
|
||||||
|
|
||||||
// QStandardItem
|
// QStandardItem
|
||||||
QVariant data(int role = Qt::UserRole + 1) const;
|
QVariant data(int role = Qt::UserRole + 1) const override;
|
||||||
int type() const;
|
int type() const override;
|
||||||
|
|
||||||
void setItemData(const QMap<int, QVariant> &roles);
|
void setItemData(const QMap<int, QVariant> &roles);
|
||||||
|
|
||||||
@@ -79,12 +79,12 @@ public:
|
|||||||
QmlOutlineModel(QmlJSEditorDocument *document);
|
QmlOutlineModel(QmlJSEditorDocument *document);
|
||||||
|
|
||||||
// QStandardItemModel
|
// QStandardItemModel
|
||||||
QStringList mimeTypes() const;
|
QStringList mimeTypes() const override;
|
||||||
QMimeData *mimeData(const QModelIndexList &indexes) const;
|
QMimeData *mimeData(const QModelIndexList &indexes) const override;
|
||||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
|
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||||
Qt::DropActions supportedDragActions() const;
|
Qt::DropActions supportedDragActions() const override;
|
||||||
Qt::DropActions supportedDropActions() const;
|
Qt::DropActions supportedDropActions() const override;
|
||||||
|
|
||||||
QmlJS::Document::Ptr document() const;
|
QmlJS::Document::Ptr document() const;
|
||||||
void update(const QmlJSTools::SemanticInfo &semanticInfo);
|
void update(const QmlJSTools::SemanticInfo &semanticInfo);
|
||||||
|
@@ -57,7 +57,7 @@ static inline const ObjectValue * getPropertyChangesTarget(Node *node, const Sco
|
|||||||
UiObjectInitializer *initializer = initializerOfObject(node);
|
UiObjectInitializer *initializer = initializerOfObject(node);
|
||||||
if (initializer) {
|
if (initializer) {
|
||||||
for (UiObjectMemberList *members = initializer->members; members; members = members->next) {
|
for (UiObjectMemberList *members = initializer->members; members; members = members->next) {
|
||||||
if (UiScriptBinding *scriptBinding = cast<UiScriptBinding *>(members->member)) {
|
if (auto scriptBinding = cast<const UiScriptBinding *>(members->member)) {
|
||||||
if (scriptBinding->qualifiedId
|
if (scriptBinding->qualifiedId
|
||||||
&& scriptBinding->qualifiedId->name == QLatin1String("target")
|
&& scriptBinding->qualifiedId->name == QLatin1String("target")
|
||||||
&& ! scriptBinding->qualifiedId->next) {
|
&& ! scriptBinding->qualifiedId->next) {
|
||||||
@@ -66,12 +66,12 @@ static inline const ObjectValue * getPropertyChangesTarget(Node *node, const Sco
|
|||||||
if (const ObjectValue *targetObject = value_cast<ObjectValue>(targetValue))
|
if (const ObjectValue *targetObject = value_cast<ObjectValue>(targetValue))
|
||||||
return targetObject;
|
return targetObject;
|
||||||
else
|
else
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QuickToolBar::QuickToolBar()
|
QuickToolBar::QuickToolBar()
|
||||||
@@ -105,7 +105,7 @@ QuickToolBar::QuickToolBar()
|
|||||||
QuickToolBar::~QuickToolBar()
|
QuickToolBar::~QuickToolBar()
|
||||||
{
|
{
|
||||||
delete m_widget.data();
|
delete m_widget.data();
|
||||||
m_widget = 0;
|
m_widget = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickToolBar::apply(TextEditor::TextEditorWidget *editorWidget, Document::Ptr document, const ScopeChain *scopeChain, Node *node, bool update, bool force)
|
void QuickToolBar::apply(TextEditor::TextEditorWidget *editorWidget, Document::Ptr document, const ScopeChain *scopeChain, Node *node, bool update, bool force)
|
||||||
@@ -153,13 +153,13 @@ void QuickToolBar::apply(TextEditor::TextEditorWidget *editorWidget, Document::P
|
|||||||
contextWidget()->colorDialog()->setParent(editorWidget->parentWidget());
|
contextWidget()->colorDialog()->setParent(editorWidget->parentWidget());
|
||||||
|
|
||||||
if (cast<UiObjectDefinition*>(node) || cast<UiObjectBinding*>(node)) {
|
if (cast<UiObjectDefinition*>(node) || cast<UiObjectBinding*>(node)) {
|
||||||
UiObjectDefinition *objectDefinition = cast<UiObjectDefinition*>(node);
|
auto objectDefinition = cast<const UiObjectDefinition*>(node);
|
||||||
UiObjectBinding *objectBinding = cast<UiObjectBinding*>(node);
|
auto objectBinding = cast<const UiObjectBinding*>(node);
|
||||||
|
|
||||||
QString name;
|
QString name;
|
||||||
quint32 offset = 0;
|
quint32 offset = 0;
|
||||||
quint32 end = 0;
|
quint32 end = 0;
|
||||||
UiObjectInitializer *initializer = 0;
|
UiObjectInitializer *initializer = nullptr;
|
||||||
if (objectDefinition) {
|
if (objectDefinition) {
|
||||||
name = objectDefinition->qualifiedTypeNameId->name.toString();
|
name = objectDefinition->qualifiedTypeNameId->name.toString();
|
||||||
initializer = objectDefinition->initializer;
|
initializer = objectDefinition->initializer;
|
||||||
@@ -199,7 +199,7 @@ void QuickToolBar::apply(TextEditor::TextEditorWidget *editorWidget, Document::P
|
|||||||
reg = reg.intersected(rect);
|
reg = reg.intersected(rect);
|
||||||
|
|
||||||
if (contextWidget()->acceptsType(m_prototypes)) {
|
if (contextWidget()->acceptsType(m_prototypes)) {
|
||||||
m_node = 0;
|
m_node = nullptr;
|
||||||
PropertyReader propertyReader(document, initializer);
|
PropertyReader propertyReader(document, initializer);
|
||||||
QTextCursor tc = m_editorWidget->textCursor();
|
QTextCursor tc = m_editorWidget->textCursor();
|
||||||
tc.setPosition(offset);
|
tc.setPosition(offset);
|
||||||
@@ -224,12 +224,12 @@ void QuickToolBar::apply(TextEditor::TextEditorWidget *editorWidget, Document::P
|
|||||||
m_doc = document;
|
m_doc = document;
|
||||||
m_node = node;
|
m_node = node;
|
||||||
} else {
|
} else {
|
||||||
contextWidget()->setParent(0);
|
contextWidget()->setParent(nullptr);
|
||||||
contextWidget()->hide();
|
contextWidget()->hide();
|
||||||
contextWidget()->colorDialog()->hide();
|
contextWidget()->colorDialog()->hide();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
contextWidget()->setParent(0);
|
contextWidget()->setParent(nullptr);
|
||||||
contextWidget()->hide();
|
contextWidget()->hide();
|
||||||
contextWidget()->colorDialog()->hide();
|
contextWidget()->colorDialog()->hide();
|
||||||
}
|
}
|
||||||
@@ -248,8 +248,8 @@ bool QuickToolBar::isAvailable(TextEditor::TextEditorWidget *, Document::Ptr doc
|
|||||||
|
|
||||||
QString name;
|
QString name;
|
||||||
|
|
||||||
UiObjectDefinition *objectDefinition = cast<UiObjectDefinition*>(node);
|
auto objectDefinition = cast<const UiObjectDefinition*>(node);
|
||||||
UiObjectBinding *objectBinding = cast<UiObjectBinding*>(node);
|
auto objectBinding = cast<const UiObjectBinding*>(node);
|
||||||
if (objectDefinition)
|
if (objectDefinition)
|
||||||
name = objectDefinition->qualifiedTypeNameId->name.toString();
|
name = objectDefinition->qualifiedTypeNameId->name.toString();
|
||||||
|
|
||||||
@@ -281,10 +281,10 @@ void QuickToolBar::setProperty(const QString &propertyName, const QVariant &valu
|
|||||||
stringValue = QLatin1Char('\"') + value.toString() + QLatin1Char('\"');
|
stringValue = QLatin1Char('\"') + value.toString() + QLatin1Char('\"');
|
||||||
|
|
||||||
if (cast<UiObjectDefinition*>(m_node) || cast<UiObjectBinding*>(m_node)) {
|
if (cast<UiObjectDefinition*>(m_node) || cast<UiObjectBinding*>(m_node)) {
|
||||||
UiObjectDefinition *objectDefinition = cast<UiObjectDefinition*>(m_node);
|
auto objectDefinition = cast<const UiObjectDefinition*>(m_node);
|
||||||
UiObjectBinding *objectBinding = cast<UiObjectBinding*>(m_node);
|
auto objectBinding = cast<const UiObjectBinding*>(m_node);
|
||||||
|
|
||||||
UiObjectInitializer *initializer = 0;
|
UiObjectInitializer *initializer = nullptr;
|
||||||
if (objectDefinition)
|
if (objectDefinition)
|
||||||
initializer = objectDefinition->initializer;
|
initializer = objectDefinition->initializer;
|
||||||
else if (objectBinding)
|
else if (objectBinding)
|
||||||
@@ -326,10 +326,10 @@ void QuickToolBar::setProperty(const QString &propertyName, const QVariant &valu
|
|||||||
void QuickToolBar::removeProperty(const QString &propertyName)
|
void QuickToolBar::removeProperty(const QString &propertyName)
|
||||||
{
|
{
|
||||||
if (cast<UiObjectDefinition*>(m_node) || cast<UiObjectBinding*>(m_node)) {
|
if (cast<UiObjectDefinition*>(m_node) || cast<UiObjectBinding*>(m_node)) {
|
||||||
UiObjectDefinition *objectDefinition = cast<UiObjectDefinition*>(m_node);
|
auto objectDefinition = cast<const UiObjectDefinition*>(m_node);
|
||||||
UiObjectBinding *objectBinding = cast<UiObjectBinding*>(m_node);
|
auto objectBinding = cast<const UiObjectBinding*>(m_node);
|
||||||
|
|
||||||
UiObjectInitializer *initializer = 0;
|
UiObjectInitializer *initializer = nullptr;
|
||||||
if (objectDefinition)
|
if (objectDefinition)
|
||||||
initializer = objectDefinition->initializer;
|
initializer = objectDefinition->initializer;
|
||||||
else if (objectBinding)
|
else if (objectBinding)
|
||||||
|
@@ -39,13 +39,13 @@ class QuickToolBar : public QmlJS::IContextPane
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
QuickToolBar();
|
QuickToolBar();
|
||||||
~QuickToolBar();
|
~QuickToolBar() override;
|
||||||
void apply(TextEditor::TextEditorWidget *widget, QmlJS::Document::Ptr document, const QmlJS::ScopeChain *scopeChain, QmlJS::AST::Node *node, bool update, bool force = false);
|
void apply(TextEditor::TextEditorWidget *widget, QmlJS::Document::Ptr document, const QmlJS::ScopeChain *scopeChain, QmlJS::AST::Node *node, bool update, bool force = false) override;
|
||||||
bool isAvailable(TextEditor::TextEditorWidget *widget, QmlJS::Document::Ptr document, QmlJS::AST::Node *node);
|
bool isAvailable(TextEditor::TextEditorWidget *widget, QmlJS::Document::Ptr document, QmlJS::AST::Node *node) override;
|
||||||
void setProperty(const QString &propertyName, const QVariant &value);
|
void setProperty(const QString &propertyName, const QVariant &value);
|
||||||
void removeProperty(const QString &propertyName);
|
void removeProperty(const QString &propertyName);
|
||||||
void setEnabled(bool);
|
void setEnabled(bool) override;
|
||||||
QWidget* widget();
|
QWidget* widget() override;
|
||||||
|
|
||||||
void onPropertyChanged(const QString &, const QVariant &);
|
void onPropertyChanged(const QString &, const QVariant &);
|
||||||
void onPropertyRemoved(const QString &);
|
void onPropertyRemoved(const QString &);
|
||||||
|
Reference in New Issue
Block a user