forked from qt-creator/qt-creator
CppEditor: Put the locator filters into one file
These classes are strongly related, so no need to spread them around. Change-Id: I4258b0c4198b3c650454ac734d7e52e09f46a4eb Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -28,9 +28,8 @@
|
||||
#include "clangdclient.h"
|
||||
#include "clangmodelmanagersupport.h"
|
||||
|
||||
#include <cppeditor/cppclassesfilter.h>
|
||||
#include <cppeditor/cppeditorconstants.h>
|
||||
#include <cppeditor/cppfunctionsfilter.h>
|
||||
#include <cppeditor/cpplocatorfilter.h>
|
||||
#include <cppeditor/cppmodelmanager.h>
|
||||
#include <cppeditor/indexitem.h>
|
||||
#include <languageclient/locatorfilter.h>
|
||||
|
||||
@@ -23,7 +23,6 @@ add_qtc_plugin(CppEditor
|
||||
cppbuiltinmodelmanagersupport.cpp cppbuiltinmodelmanagersupport.h
|
||||
cppcanonicalsymbol.cpp cppcanonicalsymbol.h
|
||||
cppchecksymbols.cpp cppchecksymbols.h
|
||||
cppclassesfilter.cpp cppclassesfilter.h
|
||||
cppcodeformatter.cpp cppcodeformatter.h
|
||||
cppcodemodelinspectordialog.cpp cppcodemodelinspectordialog.h cppcodemodelinspectordialog.ui
|
||||
cppcodemodelinspectordumper.cpp cppcodemodelinspectordumper.h
|
||||
@@ -55,7 +54,6 @@ add_qtc_plugin(CppEditor
|
||||
cppfindreferences.cpp cppfindreferences.h
|
||||
cppfollowsymbolundercursor.cpp cppfollowsymbolundercursor.h
|
||||
cppfunctiondecldeflink.cpp cppfunctiondecldeflink.h
|
||||
cppfunctionsfilter.cpp cppfunctionsfilter.h
|
||||
cpphighlighter.cpp cpphighlighter.h
|
||||
cppincludehierarchy.cpp cppincludehierarchy.h
|
||||
cppincludesfilter.cpp cppincludesfilter.h
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 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 "cppclassesfilter.h"
|
||||
|
||||
#include "cppeditorconstants.h"
|
||||
|
||||
namespace CppEditor {
|
||||
|
||||
CppClassesFilter::CppClassesFilter(CppLocatorData *locatorData)
|
||||
: CppLocatorFilter(locatorData)
|
||||
{
|
||||
setId(Constants::CLASSES_FILTER_ID);
|
||||
setDisplayName(Constants::CLASSES_FILTER_DISPLAY_NAME);
|
||||
setDefaultShortcutString("c");
|
||||
setDefaultIncludedByDefault(false);
|
||||
}
|
||||
|
||||
CppClassesFilter::~CppClassesFilter() = default;
|
||||
|
||||
Core::LocatorFilterEntry CppClassesFilter::filterEntryFromIndexItem(IndexItem::Ptr info)
|
||||
{
|
||||
const QVariant id = QVariant::fromValue(info);
|
||||
Core::LocatorFilterEntry filterEntry(this, info->symbolName(), id, info->icon());
|
||||
filterEntry.extraInfo = info->symbolScope().isEmpty()
|
||||
? info->shortNativeFilePath()
|
||||
: info->symbolScope();
|
||||
filterEntry.filePath = Utils::FilePath::fromString(info->fileName());
|
||||
return filterEntry;
|
||||
}
|
||||
|
||||
} // namespace CppEditor
|
||||
@@ -1,47 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 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 "cppeditor_global.h"
|
||||
#include "cpplocatorfilter.h"
|
||||
|
||||
namespace CppEditor {
|
||||
class CppLocatorData;
|
||||
|
||||
class CPPEDITOR_EXPORT CppClassesFilter : public CppLocatorFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CppClassesFilter(CppLocatorData *locatorData);
|
||||
~CppClassesFilter() override;
|
||||
|
||||
protected:
|
||||
IndexItem::ItemType matchTypes() const override { return IndexItem::Class; }
|
||||
Core::LocatorFilterEntry filterEntryFromIndexItem(IndexItem::Ptr info) override;
|
||||
};
|
||||
|
||||
} // namespace CppEditor
|
||||
@@ -20,7 +20,6 @@ HEADERS += \
|
||||
cppbuiltinmodelmanagersupport.h \
|
||||
cppcanonicalsymbol.h \
|
||||
cppchecksymbols.h \
|
||||
cppclassesfilter.h \
|
||||
cppcodeformatter.h \
|
||||
cppcodemodelinspectordialog.h \
|
||||
cppcodemodelinspectordumper.h \
|
||||
@@ -51,7 +50,6 @@ HEADERS += \
|
||||
cppfindreferences.h \
|
||||
cppfollowsymbolundercursor.h \
|
||||
cppfunctiondecldeflink.h \
|
||||
cppfunctionsfilter.h \
|
||||
cpphighlighter.h \
|
||||
cppincludehierarchy.h \
|
||||
cppincludesfilter.h \
|
||||
@@ -140,7 +138,6 @@ SOURCES += \
|
||||
cppbuiltinmodelmanagersupport.cpp \
|
||||
cppcanonicalsymbol.cpp \
|
||||
cppchecksymbols.cpp \
|
||||
cppclassesfilter.cpp \
|
||||
cppcodeformatter.cpp \
|
||||
cppcodemodelinspectordialog.cpp \
|
||||
cppcodemodelinspectordumper.cpp \
|
||||
@@ -165,7 +162,6 @@ SOURCES += \
|
||||
cppfindreferences.cpp \
|
||||
cppfollowsymbolundercursor.cpp \
|
||||
cppfunctiondecldeflink.cpp \
|
||||
cppfunctionsfilter.cpp \
|
||||
cpphighlighter.cpp \
|
||||
cppincludehierarchy.cpp \
|
||||
cppincludesfilter.cpp \
|
||||
|
||||
@@ -63,8 +63,6 @@ QtcPlugin {
|
||||
"cppcanonicalsymbol.h",
|
||||
"cppchecksymbols.cpp",
|
||||
"cppchecksymbols.h",
|
||||
"cppclassesfilter.cpp",
|
||||
"cppclassesfilter.h",
|
||||
"cppcodeformatter.cpp",
|
||||
"cppcodeformatter.h",
|
||||
"cppcodemodelinspectordialog.cpp",
|
||||
@@ -125,8 +123,6 @@ QtcPlugin {
|
||||
"cppfollowsymbolundercursor.h",
|
||||
"cppfunctiondecldeflink.cpp",
|
||||
"cppfunctiondecldeflink.h",
|
||||
"cppfunctionsfilter.cpp",
|
||||
"cppfunctionsfilter.h",
|
||||
"cpphighlighter.cpp",
|
||||
"cpphighlighter.h",
|
||||
"cppincludehierarchy.cpp",
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 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 "cppfunctionsfilter.h"
|
||||
|
||||
#include "cppeditorconstants.h"
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
namespace CppEditor {
|
||||
|
||||
CppFunctionsFilter::CppFunctionsFilter(CppLocatorData *locatorData)
|
||||
: CppLocatorFilter(locatorData)
|
||||
{
|
||||
setId(Constants::FUNCTIONS_FILTER_ID);
|
||||
setDisplayName(Constants::FUNCTIONS_FILTER_DISPLAY_NAME);
|
||||
setDefaultShortcutString("m");
|
||||
setDefaultIncludedByDefault(false);
|
||||
}
|
||||
|
||||
CppFunctionsFilter::~CppFunctionsFilter() = default;
|
||||
|
||||
Core::LocatorFilterEntry CppFunctionsFilter::filterEntryFromIndexItem(IndexItem::Ptr info)
|
||||
{
|
||||
const QVariant id = QVariant::fromValue(info);
|
||||
|
||||
QString name = info->symbolName();
|
||||
QString extraInfo = info->symbolScope();
|
||||
info->unqualifiedNameAndScope(name, &name, &extraInfo);
|
||||
if (extraInfo.isEmpty()) {
|
||||
extraInfo = info->shortNativeFilePath();
|
||||
} else {
|
||||
extraInfo.append(" (" + Utils::FilePath::fromString(info->fileName()).fileName() + ')');
|
||||
}
|
||||
|
||||
Core::LocatorFilterEntry filterEntry(this, name + info->symbolType(), id, info->icon());
|
||||
filterEntry.extraInfo = extraInfo;
|
||||
|
||||
return filterEntry;
|
||||
}
|
||||
|
||||
} // namespace CppEditor
|
||||
@@ -1,46 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 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 "cpplocatordata.h"
|
||||
#include "cpplocatorfilter.h"
|
||||
|
||||
namespace CppEditor {
|
||||
|
||||
class CPPEDITOR_EXPORT CppFunctionsFilter : public CppLocatorFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CppFunctionsFilter(CppLocatorData *locatorData);
|
||||
~CppFunctionsFilter() override;
|
||||
|
||||
protected:
|
||||
IndexItem::ItemType matchTypes() const override { return IndexItem::Function; }
|
||||
Core::LocatorFilterEntry filterEntryFromIndexItem(IndexItem::Ptr info) override;
|
||||
};
|
||||
|
||||
} // namespace CppEditor
|
||||
@@ -146,4 +146,56 @@ void CppLocatorFilter::accept(Core::LocatorFilterEntry selection,
|
||||
Core::EditorManager::openEditorAt(info->fileName(), info->line(), info->column());
|
||||
}
|
||||
|
||||
CppClassesFilter::CppClassesFilter(CppLocatorData *locatorData)
|
||||
: CppLocatorFilter(locatorData)
|
||||
{
|
||||
setId(Constants::CLASSES_FILTER_ID);
|
||||
setDisplayName(Constants::CLASSES_FILTER_DISPLAY_NAME);
|
||||
setDefaultShortcutString("c");
|
||||
setDefaultIncludedByDefault(false);
|
||||
}
|
||||
|
||||
CppClassesFilter::~CppClassesFilter() = default;
|
||||
|
||||
Core::LocatorFilterEntry CppClassesFilter::filterEntryFromIndexItem(IndexItem::Ptr info)
|
||||
{
|
||||
const QVariant id = QVariant::fromValue(info);
|
||||
Core::LocatorFilterEntry filterEntry(this, info->symbolName(), id, info->icon());
|
||||
filterEntry.extraInfo = info->symbolScope().isEmpty()
|
||||
? info->shortNativeFilePath()
|
||||
: info->symbolScope();
|
||||
filterEntry.filePath = Utils::FilePath::fromString(info->fileName());
|
||||
return filterEntry;
|
||||
}
|
||||
|
||||
CppFunctionsFilter::CppFunctionsFilter(CppLocatorData *locatorData)
|
||||
: CppLocatorFilter(locatorData)
|
||||
{
|
||||
setId(Constants::FUNCTIONS_FILTER_ID);
|
||||
setDisplayName(Constants::FUNCTIONS_FILTER_DISPLAY_NAME);
|
||||
setDefaultShortcutString("m");
|
||||
setDefaultIncludedByDefault(false);
|
||||
}
|
||||
|
||||
CppFunctionsFilter::~CppFunctionsFilter() = default;
|
||||
|
||||
Core::LocatorFilterEntry CppFunctionsFilter::filterEntryFromIndexItem(IndexItem::Ptr info)
|
||||
{
|
||||
const QVariant id = QVariant::fromValue(info);
|
||||
|
||||
QString name = info->symbolName();
|
||||
QString extraInfo = info->symbolScope();
|
||||
info->unqualifiedNameAndScope(name, &name, &extraInfo);
|
||||
if (extraInfo.isEmpty()) {
|
||||
extraInfo = info->shortNativeFilePath();
|
||||
} else {
|
||||
extraInfo.append(" (" + Utils::FilePath::fromString(info->fileName()).fileName() + ')');
|
||||
}
|
||||
|
||||
Core::LocatorFilterEntry filterEntry(this, name + info->symbolType(), id, info->icon());
|
||||
filterEntry.extraInfo = extraInfo;
|
||||
|
||||
return filterEntry;
|
||||
}
|
||||
|
||||
} // namespace CppEditor
|
||||
|
||||
@@ -54,4 +54,30 @@ protected:
|
||||
CppLocatorData *m_data = nullptr;
|
||||
};
|
||||
|
||||
class CPPEDITOR_EXPORT CppClassesFilter : public CppLocatorFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CppClassesFilter(CppLocatorData *locatorData);
|
||||
~CppClassesFilter() override;
|
||||
|
||||
protected:
|
||||
IndexItem::ItemType matchTypes() const override { return IndexItem::Class; }
|
||||
Core::LocatorFilterEntry filterEntryFromIndexItem(IndexItem::Ptr info) override;
|
||||
};
|
||||
|
||||
class CPPEDITOR_EXPORT CppFunctionsFilter : public CppLocatorFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CppFunctionsFilter(CppLocatorData *locatorData);
|
||||
~CppFunctionsFilter() override;
|
||||
|
||||
protected:
|
||||
IndexItem::ItemType matchTypes() const override { return IndexItem::Function; }
|
||||
Core::LocatorFilterEntry filterEntryFromIndexItem(IndexItem::Ptr info) override;
|
||||
};
|
||||
|
||||
} // namespace CppEditor
|
||||
|
||||
@@ -25,9 +25,7 @@
|
||||
|
||||
#include "cpplocatorfilter_test.h"
|
||||
|
||||
#include "cppclassesfilter.h"
|
||||
#include "cppcurrentdocumentfilter.h"
|
||||
#include "cppfunctionsfilter.h"
|
||||
#include "cpplocatorfilter.h"
|
||||
#include "cppmodelmanager.h"
|
||||
#include "cpptoolstestcase.h"
|
||||
|
||||
@@ -29,13 +29,11 @@
|
||||
#include "abstractoverviewmodel.h"
|
||||
#include "baseeditordocumentprocessor.h"
|
||||
#include "builtinindexingsupport.h"
|
||||
#include "cppclassesfilter.h"
|
||||
#include "cppcodemodelinspectordumper.h"
|
||||
#include "cppcurrentdocumentfilter.h"
|
||||
#include "cppeditorconstants.h"
|
||||
#include "cppeditorplugin.h"
|
||||
#include "cppfindreferences.h"
|
||||
#include "cppfunctionsfilter.h"
|
||||
#include "cppincludesfilter.h"
|
||||
#include "cppindexingsupport.h"
|
||||
#include "cpplocatordata.h"
|
||||
|
||||
@@ -26,13 +26,13 @@
|
||||
#include "cppquickfixes.h"
|
||||
|
||||
#include "baseeditordocumentprocessor.h"
|
||||
#include "cppclassesfilter.h"
|
||||
#include "cppcodestylesettings.h"
|
||||
#include "cppeditorconstants.h"
|
||||
#include "cppeditordocument.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppfunctiondecldeflink.h"
|
||||
#include "cppinsertvirtualmethods.h"
|
||||
#include "cpplocatorfilter.h"
|
||||
#include "cpppointerdeclarationformatter.h"
|
||||
#include "cppquickfixassistant.h"
|
||||
#include "cppquickfixprojectsettings.h"
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#include "qmt/project/project.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <cppeditor/cppclassesfilter.h>
|
||||
#include <cppeditor/cpplocatorfilter.h>
|
||||
#include <cppeditor/indexitem.h>
|
||||
#include <cppeditor/searchsymbols.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
|
||||
Reference in New Issue
Block a user