aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/clangrefactoring
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2018-04-09 13:30:30 +0200
committerMarco Bubke <marco.bubke@qt.io>2018-04-12 13:12:24 +0000
commit4b0bcbdcb6b28e806de4ba31fa5fecd06fd9188e (patch)
tree14acb63657252b111007330cc3568ee063f3cb8e /src/plugins/clangrefactoring
parent18de1e3fcf4bc2715636c8f69b29e6177bcd552b (diff)
Clang: Locator filter for the symbol database
There are no symbol queries for the locator filters. The signature generation is still not implemented but for simple cases it should work. Change-Id: Ic6b04fbe1e7e057892f194ac139615c47d6ec33f Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'src/plugins/clangrefactoring')
-rw-r--r--src/plugins/clangrefactoring/clangrefactoring-source.pri19
-rw-r--r--src/plugins/clangrefactoring/clangrefactoring.pro14
-rw-r--r--src/plugins/clangrefactoring/clangrefactoringplugin.cpp39
-rw-r--r--src/plugins/clangrefactoring/classesfilter.cpp66
-rw-r--r--src/plugins/clangrefactoring/classesfilter.h49
-rw-r--r--src/plugins/clangrefactoring/editormanagerinterface.h (renamed from src/plugins/clangrefactoring/class.h)26
-rw-r--r--src/plugins/clangrefactoring/enum.h33
-rw-r--r--src/plugins/clangrefactoring/functionsfilter.cpp66
-rw-r--r--src/plugins/clangrefactoring/functionsfilter.h49
-rw-r--r--src/plugins/clangrefactoring/include.h33
-rw-r--r--src/plugins/clangrefactoring/includesfilter.cpp67
-rw-r--r--src/plugins/clangrefactoring/includesfilter.h49
-rw-r--r--src/plugins/clangrefactoring/locatorfilter.cpp50
-rw-r--r--src/plugins/clangrefactoring/locatorfilter.h20
-rw-r--r--src/plugins/clangrefactoring/qtcreatorclassesfilter.h41
-rw-r--r--src/plugins/clangrefactoring/qtcreatoreditormanager.cpp (renamed from src/plugins/clangrefactoring/qtcreatorclassesfilter.cpp)18
-rw-r--r--src/plugins/clangrefactoring/qtcreatoreditormanager.h (renamed from src/plugins/clangrefactoring/function.h)25
-rw-r--r--src/plugins/clangrefactoring/qtcreatorfunctionsfilter.cpp40
-rw-r--r--src/plugins/clangrefactoring/qtcreatorfunctionsfilter.h41
-rw-r--r--src/plugins/clangrefactoring/qtcreatorincludesfilter.cpp38
-rw-r--r--src/plugins/clangrefactoring/qtcreatorincludesfilter.h41
-rw-r--r--src/plugins/clangrefactoring/qtcreatorlocatorfilter.cpp40
-rw-r--r--src/plugins/clangrefactoring/qtcreatorlocatorfilter.h41
-rw-r--r--src/plugins/clangrefactoring/qtcreatorsymbolsfindfilter.cpp6
-rw-r--r--src/plugins/clangrefactoring/qtcreatorsymbolsfindfilter.h4
-rw-r--r--src/plugins/clangrefactoring/querysqlitestatementfactory.h12
-rw-r--r--src/plugins/clangrefactoring/sourcelocations.h16
-rw-r--r--src/plugins/clangrefactoring/symbol.h25
-rw-r--r--src/plugins/clangrefactoring/symbolquery.h48
-rw-r--r--src/plugins/clangrefactoring/symbolqueryinterface.h18
30 files changed, 215 insertions, 819 deletions
diff --git a/src/plugins/clangrefactoring/clangrefactoring-source.pri b/src/plugins/clangrefactoring/clangrefactoring-source.pri
index 198f736e43f..b12d4a9b986 100644
--- a/src/plugins/clangrefactoring/clangrefactoring-source.pri
+++ b/src/plugins/clangrefactoring/clangrefactoring-source.pri
@@ -6,10 +6,6 @@ HEADERS += \
$$PWD/clangqueryhighlighter.h \
$$PWD/clangqueryhighlightmarker.h \
$$PWD/clangqueryprojectsfindfilter.h \
- $$PWD/classesfilter.h \
- $$PWD/functionsfilter.h \
- $$PWD/includesfilter.h \
- $$PWD/locatorfilter.h \
$$PWD/projectpartutilities.h \
$$PWD/refactoringclient.h \
$$PWD/refactoringconnectionclient.h \
@@ -20,24 +16,19 @@ HEADERS += \
$$PWD/symbolsfindfilter.h \
$$PWD/symbolqueryinterface.h \
$$PWD/symbol.h \
- $$PWD/class.h \
- $$PWD/enum.h \
- $$PWD/function.h \
- $$PWD/include.h \
- $$PWD/projectpartproviderinterface.h
+ $$PWD/projectpartproviderinterface.h \
+ $$PWD/editormanagerinterface.h \
+ $$PWD/locatorfilter.h
SOURCES += \
$$PWD/clangqueryexamplehighlighter.cpp \
$$PWD/clangqueryhighlighter.cpp \
$$PWD/clangqueryprojectsfindfilter.cpp \
- $$PWD/classesfilter.cpp \
- $$PWD/functionsfilter.cpp \
- $$PWD/includesfilter.cpp \
- $$PWD/locatorfilter.cpp \
$$PWD/projectpartutilities.cpp \
$$PWD/refactoringclient.cpp \
$$PWD/refactoringconnectionclient.cpp \
$$PWD/refactoringengine.cpp \
$$PWD/refactoringprojectupdater.cpp \
$$PWD/searchhandle.cpp \
- $$PWD/symbolsfindfilter.cpp
+ $$PWD/symbolsfindfilter.cpp \
+ $$PWD/locatorfilter.cpp
diff --git a/src/plugins/clangrefactoring/clangrefactoring.pro b/src/plugins/clangrefactoring/clangrefactoring.pro
index cad6bac9792..e859631cbf7 100644
--- a/src/plugins/clangrefactoring/clangrefactoring.pro
+++ b/src/plugins/clangrefactoring/clangrefactoring.pro
@@ -14,17 +14,14 @@ HEADERS += \
clangqueryprojectsfindfilterwidget.h \
clangquerytexteditorwidget.h \
qtcreatorclangqueryfindfilter.h \
- qtcreatorclassesfilter.h \
- qtcreatorfunctionsfilter.h \
- qtcreatorincludesfilter.h \
- qtcreatorlocatorfilter.h \
qtcreatorsearch.h \
qtcreatorsearchhandle.h \
qtcreatorsymbolsfindfilter.h \
querysqlitestatementfactory.h \
sourcelocations.h \
symbolsfindfilterconfigwidget.h \
- symbolquery.h
+ symbolquery.h \
+ qtcreatoreditormanager.h
SOURCES += \
clangrefactoringplugin.cpp \
@@ -34,14 +31,11 @@ SOURCES += \
clangqueryprojectsfindfilterwidget.cpp \
clangquerytexteditorwidget.cpp \
qtcreatorclangqueryfindfilter.cpp \
- qtcreatorclassesfilter.cpp \
- qtcreatorincludesfilter.cpp \
- qtcreatorfunctionsfilter.cpp \
- qtcreatorlocatorfilter.cpp \
qtcreatorsearch.cpp \
qtcreatorsearchhandle.cpp \
qtcreatorsymbolsfindfilter.cpp \
- symbolsfindfilterconfigwidget.cpp
+ symbolsfindfilterconfigwidget.cpp \
+ qtcreatoreditormanager.cpp
FORMS += \
clangqueryprojectsfindfilter.ui
diff --git a/src/plugins/clangrefactoring/clangrefactoringplugin.cpp b/src/plugins/clangrefactoring/clangrefactoringplugin.cpp
index afbc2f1a9cc..93dcfa910c6 100644
--- a/src/plugins/clangrefactoring/clangrefactoringplugin.cpp
+++ b/src/plugins/clangrefactoring/clangrefactoringplugin.cpp
@@ -24,11 +24,9 @@
****************************************************************************/
#include "clangrefactoringplugin.h"
-#include "qtcreatorclassesfilter.h"
-#include "qtcreatorfunctionsfilter.h"
-#include "qtcreatorincludesfilter.h"
-#include "qtcreatorlocatorfilter.h"
+#include "locatorfilter.h"
#include "qtcreatorsymbolsfindfilter.h"
+#include "qtcreatoreditormanager.h"
#include "querysqlitestatementfactory.h"
#include "sqlitedatabase.h"
#include "sqlitereadstatement.h"
@@ -41,6 +39,7 @@
#include <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h>
+#include <cpptools/cpptoolsconstants.h>
#include <refactoringdatabaseinitializer.h>
#include <filepathcaching.h>
@@ -77,11 +76,11 @@ class ClangRefactoringPluginData
public:
using QuerySqliteReadStatementFactory = QuerySqliteStatementFactory<Sqlite::Database,
Sqlite::ReadStatement>;
-
Sqlite::Database database{Utils::PathString{Core::ICore::userResourcePath() + "/symbol-experimental-v1.db"}, 1000ms};
ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
ClangBackEnd::FilePathCaching filePathCache{database};
RefactoringClient refactoringClient;
+ QtCreatorEditorManager editorManager{filePathCache};
ClangBackEnd::RefactoringConnectionClient connectionClient{&refactoringClient};
QuerySqliteReadStatementFactory statementFactory{database};
SymbolQuery<QuerySqliteReadStatementFactory> symbolQuery{statementFactory};
@@ -110,7 +109,7 @@ static bool useClangFilters()
bool ClangRefactoringPlugin::initialize(const QStringList & /*arguments*/, QString * /*errorMessage*/)
{
- d.reset(new ClangRefactoringPluginData);
+ d = std::make_unique<ClangRefactoringPluginData>();
d->refactoringClient.setRefactoringEngine(&d->engine);
d->refactoringClient.setRefactoringConnectionClient(&d->connectionClient);
@@ -175,11 +174,29 @@ void ClangRefactoringPlugin::initializeFilters()
return;
CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance();
- modelManager->setLocatorFilter(std::make_unique<QtcreatorLocatorFilter>(d->symbolQuery));
- modelManager->setClassesFilter(std::make_unique<QtcreatorClassesFilter>(d->symbolQuery));
- modelManager->setIncludesFilter(std::make_unique<QtcreatorIncludesFilter>(d->symbolQuery));
- modelManager->setFunctionsFilter(std::make_unique<QtcreatorFunctionsFilter>(d->symbolQuery));
- modelManager->setSymbolsFindFilter(std::make_unique<QtcreatorSymbolsFindFilter>());
+ modelManager->setClassesFilter(std::make_unique<LocatorFilter>(
+ d->symbolQuery,
+ d->editorManager,
+ ClangBackEnd::SymbolKinds{ClangBackEnd::SymbolKind::Record},
+ CppTools::Constants::CLASSES_FILTER_ID,
+ CppTools::Constants::CLASSES_FILTER_DISPLAY_NAME,
+ "c"));
+ modelManager->setFunctionsFilter(std::make_unique<LocatorFilter>(
+ d->symbolQuery,
+ d->editorManager,
+ ClangBackEnd::SymbolKinds{ClangBackEnd::SymbolKind::Function},
+ CppTools::Constants::FUNCTIONS_FILTER_ID,
+ CppTools::Constants::FUNCTIONS_FILTER_DISPLAY_NAME,
+ "m"));
+ modelManager->setLocatorFilter(std::make_unique<LocatorFilter>(
+ d->symbolQuery,
+ d->editorManager,
+ ClangBackEnd::SymbolKinds{ClangBackEnd::SymbolKind::Record,
+ ClangBackEnd::SymbolKind::Enumeration,
+ ClangBackEnd::SymbolKind::Function},
+ CppTools::Constants::LOCATOR_FILTER_ID,
+ CppTools::Constants::LOCATOR_FILTER_DISPLAY_NAME,
+ ":"));
}
} // namespace ClangRefactoring
diff --git a/src/plugins/clangrefactoring/classesfilter.cpp b/src/plugins/clangrefactoring/classesfilter.cpp
deleted file mode 100644
index fb8a229afbb..00000000000
--- a/src/plugins/clangrefactoring/classesfilter.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** 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 "classesfilter.h"
-
-#include <cpptools/cpptoolsconstants.h>
-
-#include <utils/algorithm.h>
-
-namespace ClangRefactoring {
-
-ClassesFilter::ClassesFilter(SymbolQueryInterface &symbolQuery)
- : m_symbolQuery(symbolQuery)
-{
- setId(CppTools::Constants::CLASSES_FILTER_ID);
- setDisplayName(CppTools::Constants::CLASSES_FILTER_DISPLAY_NAME);
- setShortcutString(QLatin1String("c"));
- setIncludedByDefault(false);
-}
-
-QList<Core::LocatorFilterEntry> ClassesFilter::matchesFor(
- QFutureInterface<Core::LocatorFilterEntry> &, const QString &entry)
-{
- using EntryList = QList<Core::LocatorFilterEntry>;
- const SymbolString entryString(entry);
- const Classes classes = m_symbolQuery.symbolsContaining(SymbolType::Class, entryString);
- return 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;
- });
-}
-
-void ClassesFilter::accept(Core::LocatorFilterEntry, QString *, int *, int *) const
-{
-}
-
-void ClassesFilter::refresh(QFutureInterface<void> &)
-{
-}
-
-} // namespace ClangRefactoring
diff --git a/src/plugins/clangrefactoring/classesfilter.h b/src/plugins/clangrefactoring/classesfilter.h
deleted file mode 100644
index 00f827dff8d..00000000000
--- a/src/plugins/clangrefactoring/classesfilter.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/****************************************************************************
-**
-** 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 "symbolqueryinterface.h"
-
-#include <coreplugin/locator/ilocatorfilter.h>
-
-namespace ClangRefactoring {
-
-class ClassesFilter : public Core::ILocatorFilter
-{
- Q_OBJECT
-public:
- ClassesFilter(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
diff --git a/src/plugins/clangrefactoring/class.h b/src/plugins/clangrefactoring/editormanagerinterface.h
index 4775c8c8ffc..fbb196460e7 100644
--- a/src/plugins/clangrefactoring/class.h
+++ b/src/plugins/clangrefactoring/editormanagerinterface.h
@@ -25,9 +25,29 @@
#pragma once
-#include "symbol.h"
+#include <filepathid.h>
+
+#include <utils/linecolumn.h>
+#include <utils/smallstringfwd.h>
+
+namespace Core {
+class IEditor;
+}
namespace ClangRefactoring {
-using Class = Symbol;
-using Classes = std::vector<Class>;
+
+class EditorManagerInterface
+{
+public:
+ EditorManagerInterface() = default;
+ EditorManagerInterface(const EditorManagerInterface&) = delete;
+ EditorManagerInterface &operator=(const EditorManagerInterface&) = delete;
+ EditorManagerInterface(EditorManagerInterface&&) = delete;
+ EditorManagerInterface &operator=(EditorManagerInterface&&) = delete;
+
+ virtual Core::IEditor *openEditorAt(ClangBackEnd::FilePathId filePathId, Utils::LineColumn lineColumn) = 0;
+
+protected:
+ ~EditorManagerInterface() = default;
+};
} // namespace ClangRefactoring
diff --git a/src/plugins/clangrefactoring/enum.h b/src/plugins/clangrefactoring/enum.h
deleted file mode 100644
index 44de3c0b8c0..00000000000
--- a/src/plugins/clangrefactoring/enum.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/****************************************************************************
-**
-** 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
diff --git a/src/plugins/clangrefactoring/functionsfilter.cpp b/src/plugins/clangrefactoring/functionsfilter.cpp
deleted file mode 100644
index 4383b0eff0a..00000000000
--- a/src/plugins/clangrefactoring/functionsfilter.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** 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 "functionsfilter.h"
-
-#include <cpptools/cpptoolsconstants.h>
-
-#include <utils/algorithm.h>
-
-namespace ClangRefactoring {
-
-FunctionsFilter::FunctionsFilter(SymbolQueryInterface &symbolQuery)
- : m_symbolQuery(symbolQuery)
-{
- setId(CppTools::Constants::FUNCTIONS_FILTER_ID);
- setDisplayName(CppTools::Constants::FUNCTIONS_FILTER_DISPLAY_NAME);
- setShortcutString(QString(QLatin1Char('m')));
- setIncludedByDefault(false);
-}
-
-QList<Core::LocatorFilterEntry> FunctionsFilter::matchesFor(
- QFutureInterface<Core::LocatorFilterEntry> &, const QString &entry)
-{
- using EntryList = QList<Core::LocatorFilterEntry>;
- const SymbolString entryString(entry);
- const Functions functions = m_symbolQuery.functionsContaining(entryString);
- return 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;
- });
-}
-
-void FunctionsFilter::accept(Core::LocatorFilterEntry, QString *, int *, int *) const
-{
-}
-
-void FunctionsFilter::refresh(QFutureInterface<void> &)
-{
-}
-
-
-} // namespace ClangRefactoring
diff --git a/src/plugins/clangrefactoring/functionsfilter.h b/src/plugins/clangrefactoring/functionsfilter.h
deleted file mode 100644
index 6844350e2c3..00000000000
--- a/src/plugins/clangrefactoring/functionsfilter.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/****************************************************************************
-**
-** 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 "symbolqueryinterface.h"
-
-#include <coreplugin/locator/ilocatorfilter.h>
-
-namespace ClangRefactoring {
-
-class FunctionsFilter : public Core::ILocatorFilter
-{
- Q_OBJECT
-public:
- FunctionsFilter(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
diff --git a/src/plugins/clangrefactoring/include.h b/src/plugins/clangrefactoring/include.h
deleted file mode 100644
index 6f6bc9ebe4b..00000000000
--- a/src/plugins/clangrefactoring/include.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/****************************************************************************
-**
-** 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 Include = Symbol;
-using Includes = std::vector<Include>;
-} // namespace ClangRefactoring
diff --git a/src/plugins/clangrefactoring/includesfilter.cpp b/src/plugins/clangrefactoring/includesfilter.cpp
deleted file mode 100644
index f7a586b3126..00000000000
--- a/src/plugins/clangrefactoring/includesfilter.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/****************************************************************************
-**
-** 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 "includesfilter.h"
-
-#include <cpptools/cpptoolsconstants.h>
-
-#include <utils/algorithm.h>
-
-namespace ClangRefactoring {
-
-IncludesFilter::IncludesFilter(SymbolQueryInterface &symbolQuery)
- : m_symbolQuery(symbolQuery)
-{
- setId(CppTools::Constants::INCLUDES_FILTER_ID);
- setDisplayName(CppTools::Constants::INCLUDES_FILTER_DISPLAY_NAME);
- setShortcutString(QString(QLatin1Char('a')));
- setIncludedByDefault(true);
- setPriority(ILocatorFilter::Low);
-}
-
-QList<Core::LocatorFilterEntry> IncludesFilter::matchesFor(
- QFutureInterface<Core::LocatorFilterEntry> &, const QString &entry)
-{
- using EntryList = QList<Core::LocatorFilterEntry>;
- const SymbolString entryString(entry);
- const Includes includes = m_symbolQuery.symbolsContaining(SymbolType::Include, entryString);
- return Utils::transform<EntryList>(includes, [this](const Include &includeInfo) {
- Core::LocatorFilterEntry entry{this,
- includeInfo.name.toQString(),
- qVariantFromValue(includeInfo)};
- entry.extraInfo = includeInfo.path.path().toQString();
- return entry;
- });
-}
-
-void IncludesFilter::accept(Core::LocatorFilterEntry, QString *, int *, int *) const
-{
-}
-
-void IncludesFilter::refresh(QFutureInterface<void> &)
-{
-}
-
-} // namespace ClangRefactoring
diff --git a/src/plugins/clangrefactoring/includesfilter.h b/src/plugins/clangrefactoring/includesfilter.h
deleted file mode 100644
index e28608dc4fa..00000000000
--- a/src/plugins/clangrefactoring/includesfilter.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/****************************************************************************
-**
-** 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 "symbolqueryinterface.h"
-
-#include <coreplugin/locator/ilocatorfilter.h>
-
-namespace ClangRefactoring {
-
-class IncludesFilter : public Core::ILocatorFilter
-{
- Q_OBJECT
-public:
- IncludesFilter(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
diff --git a/src/plugins/clangrefactoring/locatorfilter.cpp b/src/plugins/clangrefactoring/locatorfilter.cpp
index be50fd008ae..15ecbb73d2f 100644
--- a/src/plugins/clangrefactoring/locatorfilter.cpp
+++ b/src/plugins/clangrefactoring/locatorfilter.cpp
@@ -31,50 +31,32 @@
namespace ClangRefactoring {
-LocatorFilter::LocatorFilter(SymbolQueryInterface &symbolQuery)
- : m_symbolQuery(symbolQuery)
-{
- setId(CppTools::Constants::LOCATOR_FILTER_ID);
- setDisplayName(CppTools::Constants::LOCATOR_FILTER_DISPLAY_NAME);
- setShortcutString(QString(QLatin1Char(':')));
- setIncludedByDefault(false);
-}
+
QList<Core::LocatorFilterEntry> LocatorFilter::matchesFor(
- QFutureInterface<Core::LocatorFilterEntry> &, const QString &entry)
+ QFutureInterface<Core::LocatorFilterEntry> &, const QString &searchTerm)
{
- 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) {
+ Utils::SmallString sqlSearchTerm{searchTerm};
+ sqlSearchTerm.replace('*', '%');
+ sqlSearchTerm.append("%");
+ const Symbols records = m_symbolQuery.symbols(m_symbolKinds, sqlSearchTerm);
+ return Utils::transform<EntryList>(records, [this](const Symbol &record) {
Core::LocatorFilterEntry entry{this,
- classInfo.name.toQString(),
- qVariantFromValue(classInfo)};
- entry.extraInfo = classInfo.path.path().toQString();
+ record.name.toQString(),
+ QVariant::fromValue(record)};
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::accept(Core::LocatorFilterEntry locatorFilterEntry, QString *, int *, int *) const
{
+ const Symbol symbol = locatorFilterEntry.internalData.value<Symbol>();
+
+ const auto sourceLocation = m_symbolQuery.locationForSymbolId(symbol.symbolId,
+ ClangBackEnd::SourceLocationKind::Definition);
+ if (sourceLocation)
+ m_editorManager.openEditorAt(sourceLocation->filePathId, sourceLocation->lineColumn);
}
void LocatorFilter::refresh(QFutureInterface<void> &)
diff --git a/src/plugins/clangrefactoring/locatorfilter.h b/src/plugins/clangrefactoring/locatorfilter.h
index d443d2c72a9..15eaf93f0e8 100644
--- a/src/plugins/clangrefactoring/locatorfilter.h
+++ b/src/plugins/clangrefactoring/locatorfilter.h
@@ -26,6 +26,7 @@
#pragma once
#include "symbolqueryinterface.h"
+#include "editormanagerinterface.h"
#include <coreplugin/locator/ilocatorfilter.h>
@@ -35,7 +36,22 @@ class LocatorFilter : public Core::ILocatorFilter
{
Q_OBJECT
public:
- LocatorFilter(SymbolQueryInterface &symbolQuery);
+ LocatorFilter(SymbolQueryInterface &symbolQuery,
+ EditorManagerInterface &editorManager,
+ ClangBackEnd::SymbolKinds &&symbolKinds,
+ Core::Id id,
+ const QString &displayName,
+ const QString &shortCut,
+ bool includedByDefault=false)
+ : m_symbolQuery(symbolQuery),
+ m_editorManager(editorManager),
+ m_symbolKinds(std::move(symbolKinds))
+ {
+ setId(id);
+ setDisplayName(displayName);
+ setShortcutString(shortCut);
+ setIncludedByDefault(includedByDefault);
+ }
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
const QString &entry) override;
@@ -44,6 +60,8 @@ public:
void refresh(QFutureInterface<void> &future) override;
private:
SymbolQueryInterface &m_symbolQuery;
+ EditorManagerInterface &m_editorManager;
+ ClangBackEnd::SymbolKinds m_symbolKinds;
};
} // namespace ClangRefactoring
diff --git a/src/plugins/clangrefactoring/qtcreatorclassesfilter.h b/src/plugins/clangrefactoring/qtcreatorclassesfilter.h
deleted file mode 100644
index 96cac20ff2d..00000000000
--- a/src/plugins/clangrefactoring/qtcreatorclassesfilter.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/****************************************************************************
-**
-** 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:
- QtcreatorClassesFilter(SymbolQueryInterface &symbolQuery) : ClassesFilter(symbolQuery) {}
- void accept(Core::LocatorFilterEntry selection,
- QString *newText, int *selectionStart, int *selectionLength) const override;
-};
-
-} // namespace ClangRefactoring
diff --git a/src/plugins/clangrefactoring/qtcreatorclassesfilter.cpp b/src/plugins/clangrefactoring/qtcreatoreditormanager.cpp
index 3e1c9899e49..4aef8baa5da 100644
--- a/src/plugins/clangrefactoring/qtcreatorclassesfilter.cpp
+++ b/src/plugins/clangrefactoring/qtcreatoreditormanager.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
@@ -23,18 +23,22 @@
**
****************************************************************************/
-#include "qtcreatorclassesfilter.h"
+#include "qtcreatoreditormanager.h"
#include <coreplugin/editormanager/editormanager.h>
+#include <filepathcachinginterface.h>
+
+#include <utils/smallstring.h>
+
namespace ClangRefactoring {
-void QtcreatorClassesFilter::accept(Core::LocatorFilterEntry selection,
- QString *, int *, int *) const
+Core::IEditor *ClangRefactoring::QtCreatorEditorManager::openEditorAt(ClangBackEnd::FilePathId filePathId,
+ Utils::LineColumn lineColumn)
{
- auto info = qvariant_cast<Symbol>(selection.internalData);
- Core::EditorManager::openEditorAt(info.path.path().toQString(), info.lineColumn.line,
- info.lineColumn.column);
+ const QString filePath = m_filePathCache.filePath(filePathId).toQString();
+
+ return Core::EditorManager::openEditorAt(filePath, lineColumn.line, lineColumn.column - 1);
}
} // namespace ClangRefactoring
diff --git a/src/plugins/clangrefactoring/function.h b/src/plugins/clangrefactoring/qtcreatoreditormanager.h
index 863ac1b3529..5c09cae082e 100644
--- a/src/plugins/clangrefactoring/function.h
+++ b/src/plugins/clangrefactoring/qtcreatoreditormanager.h
@@ -25,14 +25,25 @@
#pragma once
-#include "symbol.h"
+#include "editormanagerinterface.h"
+
+namespace ClangBackEnd {
+class FilePathCachingInterface;
+};
namespace ClangRefactoring {
-struct Function : public Symbol
+
+class QtCreatorEditorManager final : public EditorManagerInterface
{
- SymbolString parentName;
- SymbolString returnValue;
- SymbolString paramsList;
+public:
+ QtCreatorEditorManager(ClangBackEnd::FilePathCachingInterface &filePathCache)
+ : m_filePathCache(filePathCache)
+ {}
+
+ Core::IEditor *openEditorAt(ClangBackEnd::FilePathId filePathId, Utils::LineColumn lineColumn) override;
+
+private:
+ ClangBackEnd::FilePathCachingInterface &m_filePathCache;
};
-using Functions = std::vector<Function>;
-} // namespace ClangRefactoring
+
+}
diff --git a/src/plugins/clangrefactoring/qtcreatorfunctionsfilter.cpp b/src/plugins/clangrefactoring/qtcreatorfunctionsfilter.cpp
deleted file mode 100644
index 6a5a7938ce3..00000000000
--- a/src/plugins/clangrefactoring/qtcreatorfunctionsfilter.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/****************************************************************************
-**
-** 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"
-
-#include <coreplugin/editormanager/editormanager.h>
-
-namespace ClangRefactoring {
-
-void QtcreatorFunctionsFilter::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
diff --git a/src/plugins/clangrefactoring/qtcreatorfunctionsfilter.h b/src/plugins/clangrefactoring/qtcreatorfunctionsfilter.h
deleted file mode 100644
index 8c60db81d4a..00000000000
--- a/src/plugins/clangrefactoring/qtcreatorfunctionsfilter.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/****************************************************************************
-**
-** 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:
- QtcreatorFunctionsFilter(SymbolQueryInterface &symbolQuery) : FunctionsFilter(symbolQuery) {}
- void accept(Core::LocatorFilterEntry selection,
- QString *newText, int *selectionStart, int *selectionLength) const override;
-};
-
-} // namespace ClangRefactoring
diff --git a/src/plugins/clangrefactoring/qtcreatorincludesfilter.cpp b/src/plugins/clangrefactoring/qtcreatorincludesfilter.cpp
deleted file mode 100644
index 0acf39d02e6..00000000000
--- a/src/plugins/clangrefactoring/qtcreatorincludesfilter.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/****************************************************************************
-**
-** 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"
-
-#include <coreplugin/editormanager/editormanager.h>
-
-namespace ClangRefactoring {
-
-void QtcreatorIncludesFilter::accept(Core::LocatorFilterEntry selection,
- QString *, int *, int *) const
-{
- Core::EditorManager::openEditorAt(selection.displayName, 1, 1);
-}
-
-} // namespace ClangRefactoring
diff --git a/src/plugins/clangrefactoring/qtcreatorincludesfilter.h b/src/plugins/clangrefactoring/qtcreatorincludesfilter.h
deleted file mode 100644
index 3c28f0eed89..00000000000
--- a/src/plugins/clangrefactoring/qtcreatorincludesfilter.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/****************************************************************************
-**
-** 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:
- QtcreatorIncludesFilter(SymbolQueryInterface &symbolQuery) : IncludesFilter(symbolQuery) {}
- void accept(Core::LocatorFilterEntry selection,
- QString *newText, int *selectionStart, int *selectionLength) const override;
-};
-
-} // namespace ClangRefactoring
diff --git a/src/plugins/clangrefactoring/qtcreatorlocatorfilter.cpp b/src/plugins/clangrefactoring/qtcreatorlocatorfilter.cpp
deleted file mode 100644
index b2cae53e8cf..00000000000
--- a/src/plugins/clangrefactoring/qtcreatorlocatorfilter.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/****************************************************************************
-**
-** 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
diff --git a/src/plugins/clangrefactoring/qtcreatorlocatorfilter.h b/src/plugins/clangrefactoring/qtcreatorlocatorfilter.h
deleted file mode 100644
index 5543d997f53..00000000000
--- a/src/plugins/clangrefactoring/qtcreatorlocatorfilter.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/****************************************************************************
-**
-** 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
diff --git a/src/plugins/clangrefactoring/qtcreatorsymbolsfindfilter.cpp b/src/plugins/clangrefactoring/qtcreatorsymbolsfindfilter.cpp
index 9e5bd7a7500..eb049d8516a 100644
--- a/src/plugins/clangrefactoring/qtcreatorsymbolsfindfilter.cpp
+++ b/src/plugins/clangrefactoring/qtcreatorsymbolsfindfilter.cpp
@@ -29,11 +29,7 @@
namespace ClangRefactoring {
-QtcreatorSymbolsFindFilter::QtcreatorSymbolsFindFilter()
-{
-}
-
-QWidget *QtcreatorSymbolsFindFilter::createConfigWidget()
+QWidget *QtCreatorSymbolsFindFilter::createConfigWidget()
{
return new SymbolsFindFilterConfigWidget(this);
}
diff --git a/src/plugins/clangrefactoring/qtcreatorsymbolsfindfilter.h b/src/plugins/clangrefactoring/qtcreatorsymbolsfindfilter.h
index db9a856ffd2..cd09463088d 100644
--- a/src/plugins/clangrefactoring/qtcreatorsymbolsfindfilter.h
+++ b/src/plugins/clangrefactoring/qtcreatorsymbolsfindfilter.h
@@ -29,11 +29,11 @@
namespace ClangRefactoring {
-class QtcreatorSymbolsFindFilter : public SymbolsFindFilter
+class QtCreatorSymbolsFindFilter : public SymbolsFindFilter
{
Q_OBJECT
public:
- QtcreatorSymbolsFindFilter();
+ QtCreatorSymbolsFindFilter() = default;
QWidget *createConfigWidget() override;
};
diff --git a/src/plugins/clangrefactoring/querysqlitestatementfactory.h b/src/plugins/clangrefactoring/querysqlitestatementfactory.h
index 231287e84c1..21a1f022ec3 100644
--- a/src/plugins/clangrefactoring/querysqlitestatementfactory.h
+++ b/src/plugins/clangrefactoring/querysqlitestatementfactory.h
@@ -49,6 +49,18 @@ public:
"FROM locations NATURAL JOIN sources NATURAL JOIN directories "
"WHERE symbolId = (SELECT symbolId FROM locations WHERE sourceId=? AND line=? AND column=?)",
database};
+ ReadStatement selectSymbolsForKindAndStartsWith{
+ "SELECT symbolId, symbolName, signature FROM symbols WHERE symbolKind = ? AND symbolName LIKE ?",
+ database};
+ ReadStatement selectSymbolsForKindAndStartsWith2{
+ "SELECT symbolId, symbolName, signature FROM symbols WHERE symbolKind IN (?,?) AND symbolName LIKE ?",
+ database};
+ ReadStatement selectSymbolsForKindAndStartsWith3{
+ "SELECT symbolId, symbolName, signature FROM symbols WHERE symbolKind IN (?,?,?) AND symbolName LIKE ?",
+ database};
+ ReadStatement selectLocationOfSymbol{
+ "SELECT (SELECT directoryId FROM sources WHERE sourceId = l.sourceId), sourceId, line, column FROM locations AS l WHERE symbolId = ? AND locationKind = ?",
+ database};
};
} // namespace ClangRefactoring
diff --git a/src/plugins/clangrefactoring/sourcelocations.h b/src/plugins/clangrefactoring/sourcelocations.h
index fd0dcf7d7fa..9766a779b5d 100644
--- a/src/plugins/clangrefactoring/sourcelocations.h
+++ b/src/plugins/clangrefactoring/sourcelocations.h
@@ -29,6 +29,8 @@
#include <filepathid.h>
+#include <utils/linecolumn.h>
+
#include <vector>
namespace ClangRefactoring {
@@ -36,24 +38,26 @@ namespace ClangRefactoring {
class SourceLocation
{
public:
+ SourceLocation() = default;
+ SourceLocation(ClangBackEnd::FilePathId filePathId, Utils::LineColumn lineColumn)
+ : filePathId{filePathId}, lineColumn{lineColumn}
+ {}
SourceLocation(ClangBackEnd::FilePathId filePathId, int line, int column)
- : filePathId(filePathId), line(line), column(column)
+ : filePathId{filePathId}, lineColumn{line, column}
{}
SourceLocation(int directoryId, int sourceId, int line, int column)
- : filePathId{directoryId, sourceId}, line(line), column(column)
+ : filePathId{directoryId, sourceId}, lineColumn{line, column}
{}
friend bool operator==(SourceLocation first, SourceLocation second)
{
return first.filePathId == second.filePathId
- && first.line == second.line
- && first.column == second.column;
+ && first.lineColumn == second.lineColumn;
}
public:
ClangBackEnd::FilePathId filePathId;
- int line;
- int column;
+ Utils::LineColumn lineColumn;
};
using SourceLocations = std::vector<SourceLocation>;
diff --git a/src/plugins/clangrefactoring/symbol.h b/src/plugins/clangrefactoring/symbol.h
index 4f502248fe8..5c2df292720 100644
--- a/src/plugins/clangrefactoring/symbol.h
+++ b/src/plugins/clangrefactoring/symbol.h
@@ -31,15 +31,32 @@
namespace ClangRefactoring {
-// Use proper name
-using SymbolString = Utils::PathString;
+using SymbolString = Utils::BasicSmallString<63>;
+using SignatureString = Utils::BasicSmallString<126>;
+using SymbolId = long long;
struct Symbol
{
+ Symbol() = default;
+ Symbol(SymbolId symbolId, Utils::SmallStringView name)
+ : name(name), symbolId(symbolId)
+ {}
+ Symbol(SymbolId symbolId, Utils::SmallStringView name, Utils::SmallStringView signature)
+ : signature(signature), name(name), symbolId(symbolId)
+ {}
+ SignatureString signature;
SymbolString name;
- ClangBackEnd::FilePath path;
- Utils::LineColumn lineColumn;
+ SymbolId symbolId;
+
+ friend
+ bool operator==(const Symbol &first, const Symbol &second)
+ {
+ return first.symbolId == second.symbolId
+ && first.name == second.name
+ && first.signature == second.signature;
+ }
};
+
using Symbols = std::vector<Symbol>;
} // namespace ClangRefactoring
diff --git a/src/plugins/clangrefactoring/symbolquery.h b/src/plugins/clangrefactoring/symbolquery.h
index 96e9af891f4..507d032f06f 100644
--- a/src/plugins/clangrefactoring/symbolquery.h
+++ b/src/plugins/clangrefactoring/symbolquery.h
@@ -75,19 +75,53 @@ public:
utf8Column);
}
- Symbols symbolsContaining(SymbolType /*symbolType*/,
- Utils::SmallStringView/*regularExpression*/) const override
+ Symbols symbolsWithOneSymbolKinds(ClangBackEnd::SymbolKind symbolKind,
+ Utils::SmallStringView searchTerm) const
{
- // TODO: implement
- return Classes();
+ ReadStatement &statement = m_statementFactory.selectSymbolsForKindAndStartsWith;
+
+ return statement.template values<Symbol, 3>(100, int(symbolKind), searchTerm);
+ }
+
+ Symbols symbolsWithTwoSymbolKinds(ClangBackEnd::SymbolKind symbolKind1,
+ ClangBackEnd::SymbolKind symbolKind2,
+ Utils::SmallStringView searchTerm) const
+ {
+ ReadStatement &statement = m_statementFactory.selectSymbolsForKindAndStartsWith2;
+
+ return statement.template values<Symbol, 3>(100, int(symbolKind1), int(symbolKind2), searchTerm);
+ }
+
+ Symbols symbolsWithThreeSymbolKinds(ClangBackEnd::SymbolKind symbolKind1,
+ ClangBackEnd::SymbolKind symbolKind2,
+ ClangBackEnd::SymbolKind symbolKind3,
+ Utils::SmallStringView searchTerm) const
+ {
+ ReadStatement &statement = m_statementFactory.selectSymbolsForKindAndStartsWith3;
+
+ return statement.template values<Symbol, 3>(100, int(symbolKind1), int(symbolKind2), int(symbolKind3), searchTerm);
}
- Functions functionsContaining(Utils::SmallStringView/*regularExpression*/) const override
+ Symbols symbols(const ClangBackEnd::SymbolKinds &symbolKinds,
+ Utils::SmallStringView searchTerm) const override
{
- // TODO: implement
- return Functions();
+ switch (symbolKinds.size())
+ {
+ case 1: return symbolsWithOneSymbolKinds(symbolKinds[0], searchTerm);
+ case 2: return symbolsWithTwoSymbolKinds(symbolKinds[0], symbolKinds[1], searchTerm);
+ case 3: return symbolsWithThreeSymbolKinds(symbolKinds[0], symbolKinds[1], symbolKinds[2], searchTerm);
+ }
+
+ return Symbols();
}
+ Utils::optional<SourceLocation> locationForSymbolId(SymbolId symbolId,
+ ClangBackEnd::SourceLocationKind kind) const override
+ {
+ ReadStatement &statement = m_statementFactory.selectLocationOfSymbol;
+
+ return statement.template value<SourceLocation, 4>(symbolId, int(kind));
+ }
private:
StatementFactory &m_statementFactory;
};
diff --git a/src/plugins/clangrefactoring/symbolqueryinterface.h b/src/plugins/clangrefactoring/symbolqueryinterface.h
index 362ba5cc05c..568d26568fe 100644
--- a/src/plugins/clangrefactoring/symbolqueryinterface.h
+++ b/src/plugins/clangrefactoring/symbolqueryinterface.h
@@ -27,23 +27,12 @@
#include "sourcelocations.h"
-#include "class.h"
-#include "enum.h"
-#include "function.h"
-#include "include.h"
#include "symbol.h"
#include <cpptools/usages.h>
namespace ClangRefactoring {
-enum class SymbolType
-{
- Class = 0,
- Enum = 1,
- Include = 2
-};
-
class SymbolQueryInterface
{
public:
@@ -57,9 +46,10 @@ public:
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;
+ virtual Symbols symbols(const ClangBackEnd::SymbolKinds &symbolKinds,
+ Utils::SmallStringView searchTerm) const = 0;
+ virtual Utils::optional<SourceLocation> locationForSymbolId(SymbolId symbolId,
+ ClangBackEnd::SourceLocationKind kind) const = 0;
protected:
~SymbolQueryInterface() = default;