forked from qt-creator/qt-creator
Clang: Add locator specific methods to SymbolQuery
... and implement LocatorFilter using these methods. Change-Id: Ie3e3ebb3a547e2b2bda49e76a199a3ccd8fe6403 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -18,7 +18,11 @@ HEADERS += \
|
||||
$$PWD/searchinterface.h \
|
||||
$$PWD/searchhandle.h \
|
||||
$$PWD/symbolsfindfilter.h \
|
||||
$$PWD/symbolqueryinterface.h
|
||||
$$PWD/symbolqueryinterface.h \
|
||||
$$PWD/symbol.h \
|
||||
$$PWD/class.h \
|
||||
$$PWD/enum.h \
|
||||
$$PWD/function.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/clangqueryexamplehighlighter.cpp \
|
||||
|
@@ -14,6 +14,10 @@ HEADERS += \
|
||||
clangqueryprojectsfindfilterwidget.h \
|
||||
clangquerytexteditorwidget.h \
|
||||
qtcreatorclangqueryfindfilter.h \
|
||||
qtcreatorclassesfilter.h \
|
||||
qtcreatorfunctionsfilter.h \
|
||||
qtcreatorincludesfilter.h \
|
||||
qtcreatorlocatorfilter.h \
|
||||
qtcreatorsearch.h \
|
||||
qtcreatorsearchhandle.h \
|
||||
qtcreatorsymbolsfindfilter.h \
|
||||
@@ -30,6 +34,10 @@ SOURCES += \
|
||||
clangqueryprojectsfindfilterwidget.cpp \
|
||||
clangquerytexteditorwidget.cpp \
|
||||
qtcreatorclangqueryfindfilter.cpp \
|
||||
qtcreatorclassesfilter.cpp \
|
||||
qtcreatorincludesfilter.cpp \
|
||||
qtcreatorfunctionsfilter.cpp \
|
||||
qtcreatorlocatorfilter.cpp \
|
||||
qtcreatorsearch.cpp \
|
||||
qtcreatorsearchhandle.cpp \
|
||||
qtcreatorsymbolsfindfilter.cpp \
|
||||
|
@@ -52,8 +52,11 @@ QtcPlugin {
|
||||
"clangquerytexteditorwidget.h",
|
||||
"clangrefactoringplugin.cpp",
|
||||
"clangrefactoringplugin.h",
|
||||
"class.h",
|
||||
"classesfilter.cpp",
|
||||
"classesfilter.h",
|
||||
"enum.h",
|
||||
"function.h",
|
||||
"functionsfilter.cpp",
|
||||
"functionsfilter.h",
|
||||
"includesfilter.cpp",
|
||||
@@ -64,6 +67,14 @@ QtcPlugin {
|
||||
"projectpartutilities.h",
|
||||
"qtcreatorclangqueryfindfilter.cpp",
|
||||
"qtcreatorclangqueryfindfilter.h",
|
||||
"qtcreatorclassfilter.cpp",
|
||||
"qtcreatorclassfilter.h",
|
||||
"qtcreatorfunctionsfiltre.cpp",
|
||||
"qtcreatorfunctionsfiltre.h",
|
||||
"qtcreatorincludesfilter.cpp",
|
||||
"qtcreatorincludesfilter.h",
|
||||
"qtcreatorlocatorfilter.cpp",
|
||||
"qtcreatorlocatorfilter.h",
|
||||
"qtcreatorsearch.cpp",
|
||||
"qtcreatorsearch.h",
|
||||
"qtcreatorsearchhandle.cpp",
|
||||
@@ -84,11 +95,13 @@ QtcPlugin {
|
||||
"searchinterface.cpp",
|
||||
"searchinterface.h",
|
||||
"sourcelocations.h",
|
||||
"symbol.h",
|
||||
"symbolsfindfilter.cpp",
|
||||
"symbolsfindfilter.h",
|
||||
"symbolsfindfilterconfigwidget.cpp",
|
||||
"symbolsfindfilterconfigwidget.h",
|
||||
"symbolquery.cpp",
|
||||
"symbolquery.h",
|
||||
"symbolqueryinterface.h"
|
||||
]
|
||||
}
|
||||
|
@@ -24,15 +24,15 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "clangrefactoringplugin.h"
|
||||
#include "classesfilter.h"
|
||||
#include "functionsfilter.h"
|
||||
#include "includesfilter.h"
|
||||
#include "locatorfilter.h"
|
||||
#include "symbolsfindfilter.h"
|
||||
#include "symbolquery.h"
|
||||
#include "sqlitereadstatement.h"
|
||||
#include "sqlitedatabase.h"
|
||||
#include "qtcreatorclassesfilter.h"
|
||||
#include "qtcreatorfunctionsfilter.h"
|
||||
#include "qtcreatorincludesfilter.h"
|
||||
#include "qtcreatorlocatorfilter.h"
|
||||
#include "qtcreatorsymbolsfindfilter.h"
|
||||
#include "querysqlitestatementfactory.h"
|
||||
#include "sqlitedatabase.h"
|
||||
#include "sqlitereadstatement.h"
|
||||
#include "symbolquery.h"
|
||||
|
||||
#include <clangpchmanager/qtcreatorprojectupdater.h>
|
||||
#include <clangsupport/refactoringdatabaseinitializer.h>
|
||||
@@ -172,11 +172,11 @@ void ClangRefactoringPlugin::initializeFilters()
|
||||
return;
|
||||
|
||||
CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance();
|
||||
modelManager->setLocatorFilter(std::make_unique<LocatorFilter>());
|
||||
modelManager->setClassesFilter(std::make_unique<ClassesFilter>());
|
||||
modelManager->setIncludesFilter(std::make_unique<IncludesFilter>());
|
||||
modelManager->setFunctionsFilter(std::make_unique<FunctionsFilter>());
|
||||
modelManager->setSymbolsFindFilter(std::make_unique<SymbolsFindFilter>());
|
||||
modelManager->setLocatorFilter(std::make_unique<QtcreatorLocatorFilter>(d->symbolQuery));
|
||||
modelManager->setClassesFilter(std::make_unique<QtcreatorClassesFilter>());
|
||||
modelManager->setIncludesFilter(std::make_unique<QtcreatorIncludesFilter>());
|
||||
modelManager->setFunctionsFilter(std::make_unique<QtcreatorFunctionsFilter>());
|
||||
modelManager->setSymbolsFindFilter(std::make_unique<QtcreatorSymbolsFindFilter>());
|
||||
}
|
||||
|
||||
} // namespace ClangRefactoring
|
||||
|
33
src/plugins/clangrefactoring/class.h
Normal file
33
src/plugins/clangrefactoring/class.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2018 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "symbol.h"
|
||||
|
||||
namespace ClangRefactoring {
|
||||
using Class = Symbol;
|
||||
using Classes = std::vector<Class>;
|
||||
} // namespace ClangRefactoring
|
33
src/plugins/clangrefactoring/enum.h
Normal file
33
src/plugins/clangrefactoring/enum.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2018 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "class.h"
|
||||
|
||||
namespace ClangRefactoring {
|
||||
using Enum = Class;
|
||||
using Enums = std::vector<Enum>;
|
||||
} // namespace ClangRefactoring
|
38
src/plugins/clangrefactoring/function.h
Normal file
38
src/plugins/clangrefactoring/function.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2018 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "symbol.h"
|
||||
|
||||
namespace ClangRefactoring {
|
||||
struct Function : public Symbol
|
||||
{
|
||||
SymbolString parentName;
|
||||
SymbolString returnValue;
|
||||
SymbolString paramsList;
|
||||
};
|
||||
using Functions = std::vector<Function>;
|
||||
} // namespace ClangRefactoring
|
@@ -27,9 +27,12 @@
|
||||
|
||||
#include <cpptools/cpptoolsconstants.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
namespace ClangRefactoring {
|
||||
|
||||
LocatorFilter::LocatorFilter()
|
||||
LocatorFilter::LocatorFilter(SymbolQueryInterface &symbolQuery)
|
||||
: m_symbolQuery(symbolQuery)
|
||||
{
|
||||
setId(CppTools::Constants::LOCATOR_FILTER_ID);
|
||||
setDisplayName(CppTools::Constants::LOCATOR_FILTER_DISPLAY_NAME);
|
||||
@@ -38,19 +41,44 @@ LocatorFilter::LocatorFilter()
|
||||
}
|
||||
|
||||
QList<Core::LocatorFilterEntry> LocatorFilter::matchesFor(
|
||||
QFutureInterface<Core::LocatorFilterEntry> &, const QString &)
|
||||
QFutureInterface<Core::LocatorFilterEntry> &, const QString &entry)
|
||||
{
|
||||
return QList<Core::LocatorFilterEntry>();
|
||||
SymbolString entryString(entry);
|
||||
const Classes classes = m_symbolQuery.symbolsContaining(SymbolType::Class, entryString);
|
||||
const Enums enums = m_symbolQuery.symbolsContaining(SymbolType::Enum, entryString);
|
||||
const Functions functions = m_symbolQuery.functionsContaining(entryString);
|
||||
|
||||
using EntryList = QList<Core::LocatorFilterEntry>;
|
||||
auto classEntries = Utils::transform<EntryList>(classes, [this](const Class &classInfo) {
|
||||
Core::LocatorFilterEntry entry{this,
|
||||
classInfo.name.toQString(),
|
||||
qVariantFromValue(classInfo)};
|
||||
entry.extraInfo = classInfo.path.path().toQString();
|
||||
return entry;
|
||||
});
|
||||
auto enumEntries = Utils::transform<EntryList>(enums, [this](const Enum &enumInfo) {
|
||||
Core::LocatorFilterEntry entry{this,
|
||||
enumInfo.name.toQString(),
|
||||
qVariantFromValue(enumInfo)};
|
||||
entry.extraInfo = enumInfo.path.path().toQString();
|
||||
return entry;
|
||||
});
|
||||
auto functionEntries = Utils::transform<EntryList>(functions, [this](const Function &function) {
|
||||
const auto data = qVariantFromValue(static_cast<const Symbol &>(function));
|
||||
Core::LocatorFilterEntry entry{this, function.name.toQString(), data};
|
||||
entry.extraInfo = function.path.path().toQString();
|
||||
return entry;
|
||||
});
|
||||
|
||||
return classEntries + enumEntries + functionEntries;
|
||||
}
|
||||
|
||||
void LocatorFilter::accept(Core::LocatorFilterEntry, QString *, int *, int *) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LocatorFilter::refresh(QFutureInterface<void> &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
} // namespace ClangRefactoring
|
||||
|
@@ -25,6 +25,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "symbolqueryinterface.h"
|
||||
|
||||
#include <coreplugin/locator/ilocatorfilter.h>
|
||||
|
||||
namespace ClangRefactoring {
|
||||
@@ -33,13 +35,15 @@ class LocatorFilter : public Core::ILocatorFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LocatorFilter();
|
||||
LocatorFilter(SymbolQueryInterface &symbolQuery);
|
||||
|
||||
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
|
||||
const QString &entry) override;
|
||||
void accept(Core::LocatorFilterEntry selection,
|
||||
QString *newText, int *selectionStart, int *selectionLength) const override;
|
||||
void refresh(QFutureInterface<void> &future) override;
|
||||
private:
|
||||
SymbolQueryInterface &m_symbolQuery;
|
||||
};
|
||||
|
||||
} // namespace ClangRefactoring
|
||||
|
35
src/plugins/clangrefactoring/qtcreatorclassesfilter.cpp
Normal file
35
src/plugins/clangrefactoring/qtcreatorclassesfilter.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qtcreatorclassesfilter.h"
|
||||
|
||||
namespace ClangRefactoring {
|
||||
|
||||
void QtcreatorClassesFilter::accept(Core::LocatorFilterEntry,
|
||||
QString *, int *, int *) const
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace ClangRefactoring
|
40
src/plugins/clangrefactoring/qtcreatorclassesfilter.h
Normal file
40
src/plugins/clangrefactoring/qtcreatorclassesfilter.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "classesfilter.h"
|
||||
|
||||
namespace ClangRefactoring {
|
||||
|
||||
class QtcreatorClassesFilter : public ClassesFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
void accept(Core::LocatorFilterEntry selection,
|
||||
QString *newText, int *selectionStart, int *selectionLength) const override;
|
||||
};
|
||||
|
||||
} // namespace ClangRefactoring
|
35
src/plugins/clangrefactoring/qtcreatorfunctionsfilter.cpp
Normal file
35
src/plugins/clangrefactoring/qtcreatorfunctionsfilter.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qtcreatorfunctionsfilter.h"
|
||||
|
||||
namespace ClangRefactoring {
|
||||
|
||||
void QtcreatorFunctionsFilter::accept(Core::LocatorFilterEntry,
|
||||
QString *, int *, int *) const
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace ClangRefactoring
|
40
src/plugins/clangrefactoring/qtcreatorfunctionsfilter.h
Normal file
40
src/plugins/clangrefactoring/qtcreatorfunctionsfilter.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "functionsfilter.h"
|
||||
|
||||
namespace ClangRefactoring {
|
||||
|
||||
class QtcreatorFunctionsFilter : public FunctionsFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
void accept(Core::LocatorFilterEntry selection,
|
||||
QString *newText, int *selectionStart, int *selectionLength) const override;
|
||||
};
|
||||
|
||||
} // namespace ClangRefactoring
|
35
src/plugins/clangrefactoring/qtcreatorincludesfilter.cpp
Normal file
35
src/plugins/clangrefactoring/qtcreatorincludesfilter.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qtcreatorincludesfilter.h"
|
||||
|
||||
namespace ClangRefactoring {
|
||||
|
||||
void QtcreatorIncludesFilter::accept(Core::LocatorFilterEntry,
|
||||
QString *, int *, int *) const
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace ClangRefactoring
|
40
src/plugins/clangrefactoring/qtcreatorincludesfilter.h
Normal file
40
src/plugins/clangrefactoring/qtcreatorincludesfilter.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "includesfilter.h"
|
||||
|
||||
namespace ClangRefactoring {
|
||||
|
||||
class QtcreatorIncludesFilter : public IncludesFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
void accept(Core::LocatorFilterEntry selection,
|
||||
QString *newText, int *selectionStart, int *selectionLength) const override;
|
||||
};
|
||||
|
||||
} // namespace ClangRefactoring
|
40
src/plugins/clangrefactoring/qtcreatorlocatorfilter.cpp
Normal file
40
src/plugins/clangrefactoring/qtcreatorlocatorfilter.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qtcreatorlocatorfilter.h"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
|
||||
namespace ClangRefactoring {
|
||||
|
||||
void QtcreatorLocatorFilter::accept(Core::LocatorFilterEntry selection,
|
||||
QString *, int *, int *) const
|
||||
{
|
||||
auto info = qvariant_cast<Symbol>(selection.internalData);
|
||||
Core::EditorManager::openEditorAt(info.path.path().toQString(), info.lineColumn.line,
|
||||
info.lineColumn.column);
|
||||
}
|
||||
|
||||
} // namespace ClangRefactoring
|
41
src/plugins/clangrefactoring/qtcreatorlocatorfilter.h
Normal file
41
src/plugins/clangrefactoring/qtcreatorlocatorfilter.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "locatorfilter.h"
|
||||
|
||||
namespace ClangRefactoring {
|
||||
|
||||
class QtcreatorLocatorFilter : public LocatorFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtcreatorLocatorFilter(SymbolQueryInterface &symbolQuery) : LocatorFilter(symbolQuery) {}
|
||||
void accept(Core::LocatorFilterEntry selection,
|
||||
QString *newText, int *selectionStart, int *selectionLength) const override;
|
||||
};
|
||||
|
||||
} // namespace ClangRefactoring
|
47
src/plugins/clangrefactoring/symbol.h
Normal file
47
src/plugins/clangrefactoring/symbol.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2018 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <clangsupport/filepath.h>
|
||||
|
||||
#include <utils/linecolumn.h>
|
||||
|
||||
namespace ClangRefactoring {
|
||||
|
||||
// Use proper name
|
||||
using SymbolString = Utils::PathString;
|
||||
|
||||
struct Symbol
|
||||
{
|
||||
SymbolString name;
|
||||
ClangBackEnd::FilePath path;
|
||||
Utils::LineColumn lineColumn;
|
||||
};
|
||||
using Symbols = std::vector<Symbol>;
|
||||
|
||||
} // namespace ClangRefactoring
|
||||
|
||||
Q_DECLARE_METATYPE(ClangRefactoring::Symbol)
|
@@ -47,7 +47,9 @@ public:
|
||||
: m_statementFactory(statementFactory)
|
||||
{}
|
||||
|
||||
SourceLocations locationsAt(ClangBackEnd::FilePathId filePathId, int line, int utf8Column) const override
|
||||
SourceLocations locationsAt(ClangBackEnd::FilePathId filePathId,
|
||||
int line,
|
||||
int utf8Column) const override
|
||||
{
|
||||
ReadStatement &locationsStatement = m_statementFactory.selectLocationsForSymbolLocation;
|
||||
|
||||
@@ -59,7 +61,9 @@ public:
|
||||
utf8Column);
|
||||
}
|
||||
|
||||
CppTools::Usages sourceUsagesAt(ClangBackEnd::FilePathId filePathId, int line, int utf8Column) const override
|
||||
CppTools::Usages sourceUsagesAt(ClangBackEnd::FilePathId filePathId,
|
||||
int line,
|
||||
int utf8Column) const override
|
||||
{
|
||||
ReadStatement &locationsStatement = m_statementFactory.selectSourceUsagesForSymbolLocation;
|
||||
|
||||
@@ -71,6 +75,19 @@ public:
|
||||
utf8Column);
|
||||
}
|
||||
|
||||
Symbols symbolsContaining(SymbolType symbolType,
|
||||
Utils::SmallStringView/*regularExpression*/) const override
|
||||
{
|
||||
// TODO: implement
|
||||
return Classes();
|
||||
}
|
||||
|
||||
Functions functionsContaining(Utils::SmallStringView/*regularExpression*/) const override
|
||||
{
|
||||
// TODO: implement
|
||||
return Functions();
|
||||
}
|
||||
|
||||
private:
|
||||
StatementFactory &m_statementFactory;
|
||||
};
|
||||
|
@@ -27,15 +27,34 @@
|
||||
|
||||
#include "sourcelocations.h"
|
||||
|
||||
#include "class.h"
|
||||
#include "enum.h"
|
||||
#include "function.h"
|
||||
#include "symbol.h"
|
||||
|
||||
#include <cpptools/usages.h>
|
||||
|
||||
namespace ClangRefactoring {
|
||||
|
||||
enum class SymbolType
|
||||
{
|
||||
Class = 0,
|
||||
Enum = 1
|
||||
};
|
||||
|
||||
class SymbolQueryInterface
|
||||
{
|
||||
public:
|
||||
virtual SourceLocations locationsAt(ClangBackEnd::FilePathId filePathId, int line, int utf8Column) const = 0;
|
||||
virtual CppTools::Usages sourceUsagesAt(ClangBackEnd::FilePathId filePathId, int line, int utf8Column) const = 0;
|
||||
virtual ~SymbolQueryInterface() {}
|
||||
virtual SourceLocations locationsAt(ClangBackEnd::FilePathId filePathId,
|
||||
int line,
|
||||
int utf8Column) const = 0;
|
||||
virtual CppTools::Usages sourceUsagesAt(ClangBackEnd::FilePathId filePathId,
|
||||
int line,
|
||||
int utf8Column) const = 0;
|
||||
virtual Symbols symbolsContaining(SymbolType symbolType,
|
||||
Utils::SmallStringView regularExpression) const = 0;
|
||||
virtual Functions functionsContaining(Utils::SmallStringView regularExpression) const = 0;
|
||||
};
|
||||
|
||||
} // namespace ClangRefactoring
|
||||
|
@@ -25,6 +25,8 @@
|
||||
|
||||
#include "googletest.h"
|
||||
|
||||
#include "mocksymbolquery.h"
|
||||
|
||||
#include <clangrefactoring/locatorfilter.h>
|
||||
|
||||
namespace {
|
||||
@@ -32,7 +34,8 @@ namespace {
|
||||
class LocatorFilter : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
ClangRefactoring::LocatorFilter locatorFilter;
|
||||
MockSymbolQuery mockSymbolQuery;
|
||||
ClangRefactoring::LocatorFilter locatorFilter {mockSymbolQuery};
|
||||
};
|
||||
|
||||
TEST_F(LocatorFilter, MatchesFor)
|
||||
|
@@ -34,4 +34,6 @@ class MockSymbolQuery : public ClangRefactoring::SymbolQueryInterface
|
||||
public:
|
||||
MOCK_CONST_METHOD3(locationsAt, ClangRefactoring::SourceLocations(ClangBackEnd::FilePathId filePathId, int line, int utf8Column));
|
||||
MOCK_CONST_METHOD3(sourceUsagesAt, CppTools::Usages(ClangBackEnd::FilePathId filePathId, int line, int utf8Column));
|
||||
MOCK_CONST_METHOD2(symbolsContaining, ClangRefactoring::Symbols(ClangRefactoring::SymbolType symbolType, Utils::SmallStringView regEx));
|
||||
MOCK_CONST_METHOD1(functionsContaining, ClangRefactoring::Functions(Utils::SmallStringView regEx));
|
||||
};
|
||||
|
Reference in New Issue
Block a user