2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-04-15 16:19:23 +02:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2011-04-15 16:19:23 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-04-15 16:19:23 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2011-04-15 16:19:23 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2011-04-15 16:19:23 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-04-15 16:19:23 +02:00
|
|
|
|
|
|
|
|
#include "qmljsquickfixassist.h"
|
|
|
|
|
#include "qmljseditorconstants.h"
|
2014-02-07 13:45:51 +01:00
|
|
|
#include "qmljseditordocument.h"
|
2011-04-15 16:19:23 +02:00
|
|
|
|
|
|
|
|
//temp
|
|
|
|
|
#include "qmljsquickfix.h"
|
|
|
|
|
|
|
|
|
|
#include <extensionsystem/pluginmanager.h>
|
|
|
|
|
|
|
|
|
|
using namespace QmlJSTools;
|
|
|
|
|
using namespace TextEditor;
|
|
|
|
|
|
2013-06-03 19:31:32 +02:00
|
|
|
namespace QmlJSEditor {
|
|
|
|
|
|
|
|
|
|
using namespace Internal;
|
|
|
|
|
|
2011-04-15 16:19:23 +02:00
|
|
|
// -----------------------
|
|
|
|
|
// QuickFixAssistInterface
|
|
|
|
|
// -----------------------
|
|
|
|
|
QmlJSQuickFixAssistInterface::QmlJSQuickFixAssistInterface(QmlJSTextEditorWidget *editor,
|
|
|
|
|
TextEditor::AssistReason reason)
|
2013-03-18 14:58:46 +01:00
|
|
|
: DefaultAssistInterface(editor->document(), editor->position(),
|
2013-12-12 15:07:54 +01:00
|
|
|
editor->baseTextDocument()->filePath(), reason)
|
2011-04-15 16:19:23 +02:00
|
|
|
, m_editor(editor)
|
2014-02-07 13:45:51 +01:00
|
|
|
, m_semanticInfo(editor->qmlJsEditorDocument()->semanticInfo())
|
2011-08-17 11:35:57 +02:00
|
|
|
, m_currentFile(QmlJSRefactoringChanges::file(m_editor, m_semanticInfo.document))
|
2011-04-15 16:19:23 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
QmlJSQuickFixAssistInterface::~QmlJSQuickFixAssistInterface()
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
const SemanticInfo &QmlJSQuickFixAssistInterface::semanticInfo() const
|
|
|
|
|
{
|
|
|
|
|
return m_semanticInfo;
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-17 11:35:57 +02:00
|
|
|
QmlJSRefactoringFilePtr QmlJSQuickFixAssistInterface::currentFile() const
|
2011-04-15 16:19:23 +02:00
|
|
|
{
|
2011-08-17 11:35:57 +02:00
|
|
|
return m_currentFile;
|
2011-04-15 16:19:23 +02:00
|
|
|
}
|
|
|
|
|
|
2011-10-19 13:48:10 +02:00
|
|
|
QmlJSTextEditorWidget *QmlJSQuickFixAssistInterface::editor() const
|
2011-04-15 16:19:23 +02:00
|
|
|
{
|
|
|
|
|
return m_editor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ----------------------
|
|
|
|
|
// QmlJSQuickFixProcessor
|
|
|
|
|
// ----------------------
|
|
|
|
|
QmlJSQuickFixProcessor::QmlJSQuickFixProcessor(const TextEditor::IAssistProvider *provider)
|
|
|
|
|
: m_provider(provider)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
QmlJSQuickFixProcessor::~QmlJSQuickFixProcessor()
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
const IAssistProvider *QmlJSQuickFixProcessor::provider() const
|
|
|
|
|
{
|
|
|
|
|
return m_provider;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ---------------------------
|
|
|
|
|
// QmlJSQuickFixAssistProvider
|
|
|
|
|
// ---------------------------
|
|
|
|
|
QmlJSQuickFixAssistProvider::QmlJSQuickFixAssistProvider()
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
QmlJSQuickFixAssistProvider::~QmlJSQuickFixAssistProvider()
|
|
|
|
|
{}
|
|
|
|
|
|
2013-09-17 13:25:39 +02:00
|
|
|
bool QmlJSQuickFixAssistProvider::isAsynchronous() const
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-10 11:36:51 +01:00
|
|
|
bool QmlJSQuickFixAssistProvider::supportsEditor(const Core::Id &editorId) const
|
2011-04-15 16:19:23 +02:00
|
|
|
{
|
2012-08-03 15:24:33 +02:00
|
|
|
return editorId == Constants::C_QMLJSEDITOR_ID;
|
2011-04-15 16:19:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IAssistProcessor *QmlJSQuickFixAssistProvider::createProcessor() const
|
|
|
|
|
{
|
|
|
|
|
return new QmlJSQuickFixProcessor(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<QuickFixFactory *> QmlJSQuickFixAssistProvider::quickFixFactories() const
|
|
|
|
|
{
|
|
|
|
|
QList<TextEditor::QuickFixFactory *> results;
|
2013-06-03 19:31:32 +02:00
|
|
|
foreach (QmlJSQuickFixFactory *f, ExtensionSystem::PluginManager::getObjects<QmlJSQuickFixFactory>())
|
2011-04-15 16:19:23 +02:00
|
|
|
results.append(f);
|
|
|
|
|
return results;
|
|
|
|
|
}
|
2013-06-03 19:31:32 +02:00
|
|
|
|
|
|
|
|
} // namespace QmlJSEditor
|