forked from qt-creator/qt-creator
QmlEditor: show the id name when folding a block.
If the id of an element exists, it will be displayed instead of the normal "..." Change-Id: I4e6633743b0e2ae014b7fbad3c752ef318c73659 Reviewed-by: Christian Kamm <christian.d.kamm@nokia.com>
This commit is contained in:
committed by
Christian Kamm
parent
d136b011e1
commit
635ca2a51a
@@ -1692,3 +1692,31 @@ TextEditor::IAssistInterface *QmlJSTextEditorWidget::createAssistInterface(
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString QmlJSTextEditorWidget::foldReplacementText(const QTextBlock &block) const
|
||||
{
|
||||
int curlyIndex = block.text().indexOf(QLatin1Char('{'));
|
||||
|
||||
if ((curlyIndex == -1) || !m_semanticInfo.isValid())
|
||||
return TextEditor::BaseTextEditorWidget::foldReplacementText(block);
|
||||
|
||||
int pos = block.position() + curlyIndex;
|
||||
Node *node = m_semanticInfo.rangeAt(pos);
|
||||
|
||||
if (node) {
|
||||
UiObjectInitializer *objectInitializer = 0;
|
||||
if (UiObjectDefinition *def = cast<UiObjectDefinition *>(node))
|
||||
objectInitializer = def->initializer;
|
||||
else if (UiObjectBinding *binding = cast<UiObjectBinding *>(node))
|
||||
objectInitializer = binding->initializer;
|
||||
|
||||
// Get the id value, if it exists, and display it
|
||||
if (objectInitializer) {
|
||||
QString objectId = idOfObject(objectInitializer);
|
||||
if (!objectId.isEmpty())
|
||||
return QLatin1String("id: ") + objectId + QLatin1String("...");
|
||||
}
|
||||
}
|
||||
|
||||
return TextEditor::BaseTextEditorWidget::foldReplacementText(block);
|
||||
}
|
||||
|
Reference in New Issue
Block a user