forked from qt-creator/qt-creator
TextEditor: add text cursor to assist interface
This will allow us to request assistance for a specific selection instead of just the position. Change-Id: Ib8e5b32d4a8f2936e5a6f1b7ac968d7f1d8d9de6 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -334,10 +334,11 @@ QStringList qmlJSAutoComplete(QTextDocument *textDocument,
|
||||
{
|
||||
QStringList list;
|
||||
QmlJSCompletionAssistProcessor processor;
|
||||
QTextCursor cursor(textDocument);
|
||||
cursor.setPosition(position);
|
||||
QScopedPointer<IAssistProposal> proposal(processor.perform( /* The processor takes ownership. */
|
||||
new QmlJSCompletionAssistInterface(
|
||||
textDocument,
|
||||
position,
|
||||
cursor,
|
||||
fileName,
|
||||
reason,
|
||||
info)));
|
||||
@@ -978,12 +979,11 @@ bool QmlJSCompletionAssistProcessor::completeUrl(const QString &relativeBasePath
|
||||
// ------------------------------
|
||||
// QmlJSCompletionAssistInterface
|
||||
// ------------------------------
|
||||
QmlJSCompletionAssistInterface::QmlJSCompletionAssistInterface(QTextDocument *textDocument,
|
||||
int position,
|
||||
QmlJSCompletionAssistInterface::QmlJSCompletionAssistInterface(const QTextCursor &cursor,
|
||||
const Utils::FilePath &fileName,
|
||||
AssistReason reason,
|
||||
const SemanticInfo &info)
|
||||
: AssistInterface(textDocument, position, fileName, reason)
|
||||
: AssistInterface(cursor, fileName, reason)
|
||||
, m_semanticInfo(info)
|
||||
{}
|
||||
|
||||
|
||||
@@ -105,8 +105,7 @@ private:
|
||||
class QMLJSEDITOR_EXPORT QmlJSCompletionAssistInterface : public TextEditor::AssistInterface
|
||||
{
|
||||
public:
|
||||
QmlJSCompletionAssistInterface(QTextDocument *textDocument,
|
||||
int position,
|
||||
QmlJSCompletionAssistInterface(const QTextCursor &cursor,
|
||||
const Utils::FilePath &fileName,
|
||||
TextEditor::AssistReason reason,
|
||||
const QmlJSTools::SemanticInfo &info);
|
||||
|
||||
@@ -1021,11 +1021,8 @@ AssistInterface *QmlJSEditorWidget::createAssistInterface(
|
||||
AssistReason reason) const
|
||||
{
|
||||
if (assistKind == Completion) {
|
||||
return new QmlJSCompletionAssistInterface(document(),
|
||||
position(),
|
||||
textDocument()->filePath(),
|
||||
reason,
|
||||
m_qmlJsEditorDocument->semanticInfo());
|
||||
return new QmlJSCompletionAssistInterface(textCursor(), textDocument()->filePath(),
|
||||
reason, m_qmlJsEditorDocument->semanticInfo());
|
||||
} else if (assistKind == QuickFix) {
|
||||
return new Internal::QmlJSQuickFixAssistInterface(const_cast<QmlJSEditorWidget *>(this), reason);
|
||||
}
|
||||
|
||||
@@ -48,8 +48,7 @@ using namespace Internal;
|
||||
// -----------------------
|
||||
QmlJSQuickFixAssistInterface::QmlJSQuickFixAssistInterface(QmlJSEditorWidget *editor,
|
||||
AssistReason reason)
|
||||
: AssistInterface(editor->document(), editor->position(),
|
||||
editor->textDocument()->filePath(), reason)
|
||||
: AssistInterface(editor->textCursor(), editor->textDocument()->filePath(), reason)
|
||||
, m_semanticInfo(editor->qmlJsEditorDocument()->semanticInfo())
|
||||
, m_currentFile(QmlJSRefactoringChanges::file(editor, m_semanticInfo.document))
|
||||
{}
|
||||
|
||||
Reference in New Issue
Block a user