Commit 25d024da authored by Sergey Kalinichev's avatar Sergey Kalinichev

Use config values from setings pages.

The parser is not uses it yet.

Review 124139
parent 561cd012
set( clangsettings_SRCS
add_library(settingsmanager
STATIC
clangsettingsmanager.cpp
)
target_link_libraries(settingsmanager
LINK_PUBLIC
KDev::Project
KDev::Util
)
set(clangsettings_SRCS
clangconfigpage.cpp
clangsettingsplugin.cpp
configwidget.cpp
clangsettingsmanager.cpp
sessionsettings/sessionsettings.cpp
)
)
ki18n_wrap_ui(clangsettings_SRCS
configwidget.ui
......@@ -15,6 +25,11 @@ ki18n_wrap_ui(clangsettings_SRCS
kconfig_add_kcfg_files( clangsettings_SRCS clangprojectconfig.kcfgc sessionsettings/sessionconfig.kcfgc)
kdevplatform_add_plugin(kdevclangsettings JSON kdevclangsettings.json SOURCES ${clangsettings_SRCS})
target_link_libraries( kdevclangsettings LINK_PRIVATE
target_link_libraries(kdevclangsettings
LINK_PUBLIC
KDev::Project
KDev::Util)
KDev::Util
LINK_PRIVATE
settingsmanager
)
......@@ -39,16 +39,6 @@ ClangConfigPage::ClangConfigPage(KDevelop::IPlugin* plugin, const KDevelop::Proj
ClangConfigPage::~ClangConfigPage()
{}
void ClangConfigPage::loadFrom(KConfig* /*cfg*/)
{
// Nothing to do here so far
}
void ClangConfigPage::saveTo(KConfig* /*cfg*/)
{
configWidget->writeSettings();
}
void ClangConfigPage::reset()
{
ProjectConfigPage::reset();
......@@ -58,7 +48,7 @@ void ClangConfigPage::reset()
void ClangConfigPage::apply()
{
ProjectConfigPage::apply();
saveTo(ClangProjectConfig::self()->config());
configWidget->writeSettings();
}
QString ClangConfigPage::name() const
......
......@@ -43,9 +43,6 @@ public:
virtual void reset() override;
private:
class ConfigWidget* configWidget;
void loadFrom( KConfig* cfg );
void saveTo( KConfig* cfg );
};
#endif
......@@ -46,22 +46,16 @@ namespace
const QString parserPath = QStringLiteral("path");
const QString parserOptions = QStringLiteral("options");
const QString overrideHelper = QStringLiteral("overrideHelper");
const QString implementHelper = QStringLiteral("implementHelper");
const QString macros = QStringLiteral("macros");
const QString forwardDeclare = QStringLiteral("forwardDeclare");
const QString includePath = QStringLiteral("includePath");
const QString adaptSignature = QStringLiteral("adaptSignature");
AssistantsSettings readAssistantsSettings(KConfig* cfg)
{
auto grp = cfg->group(settingsGroup);
AssistantsSettings settings;
settings.adaptSignature = grp.readEntry(adaptSignature, true);
settings.forwardDeclare = grp.readEntry(forwardDeclare, true);
settings.includePath = grp.readEntry(includePath, true);
return settings;
}
......@@ -71,9 +65,7 @@ CodeCompletionSettings readCodeCompletionSettings(KConfig* cfg)
auto grp = cfg->group(settingsGroup);
CodeCompletionSettings settings;
settings.implementHelper = grp.readEntry(implementHelper, true);
settings.macros = grp.readEntry(macros, true);
settings.overrideHelper = grp.readEntry(overrideHelper, true);
return settings;
}
......@@ -165,8 +157,8 @@ QList<ParserSettingsEntry> ClangSettingsManager::readPaths(KDevelop::IProject* p
if(path.path.isEmpty()){
continue;
}
// TODO: default value
path.settings.parserOptions = pathgrp.readEntry(parserOptions, "");
path.settings.parserOptions = pathgrp.readEntry(parserOptions, "-fspell-checking -Wdocumentation ");
paths.append(path);
}
......
......@@ -47,15 +47,11 @@ struct ParserSettingsEntry
struct CodeCompletionSettings
{
bool macros = true;
bool overrideHelper = true;
bool implementHelper = true;
};
struct AssistantsSettings
{
bool forwardDeclare = true;
bool includePath = true;
bool adaptSignature = true;
};
class ClangSettingsManager
......
......@@ -5,29 +5,11 @@
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
<kcfgfile name="kdeveloprc"/>
<group name="Clang Settings">
<entry name="enableCodeCompletion" key="enableCodeCompletion" type="Bool">
<default>true</default>
</entry>
<entry name="macros" key="macros" type="Bool">
<default>true</default>
</entry>
<entry name="overrideHelper" key="overrideHelper" type="Bool">
<default>true</default>
</entry>
<entry name="implementHelper" key="implementHelper" type="Bool">
<default>true</default>
</entry>
<entry name="enableAssistants" key="enableAssistants" type="Bool">
<default>true</default>
</entry>
<entry name="forwardDeclareHelper" key="forwardDeclare" type="Bool">
<default>true</default>
</entry>
<entry name="includePathAssistant" key="includePath" type="Bool">
<default>true</default>
</entry>
<entry name="adaptSignature" key="adaptSignature" type="Bool">
<entry name="forwardDeclare" key="forwardDeclare" type="Bool">
<default>true</default>
</entry>
</group>
......
......@@ -13,152 +13,73 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Code-completion</string>
</property>
<widget class="QWidget" name="codeCompletion">
<attribute name="title">
<string>Code completion</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Fine tuning</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QCheckBox" name="kcfg_macros">
<property name="text">
<string>Add macros to code-completion</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_overrideHelper">
<property name="text">
<string>Override helper</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_implementHelper">
<property name="text">
<string>Implement helper</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="kcfg_enableCodeCompletion">
<property name="text">
<string>Enabled</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="assistants">
<attribute name="title">
<string>Assistants</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Fine tuning</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="kcfg_forwardDeclareHelper">
<property name="text">
<string>Forward declare helper</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_includePathAssistant">
<property name="text">
<string>Include path assistant</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_adaptSignature">
<property name="text">
<string>Adapt signature</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="kcfg_enableAssistants">
<property name="text">
<string>Enabled</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QCheckBox" name="kcfg_macros">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If disabled, macros will not be included in the code-completion results. This can improve the responsiveness of code-completion in some cases.&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Add macros to code-completion</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Assistants</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QCheckBox" name="kcfg_forwardDeclare">
<property name="text">
<string>Forward declare assistant</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
......
......@@ -36,6 +36,7 @@
#include "../util/clangtypes.h"
#include "../duchain/parsesession.h"
#include "../duchain/navigationwidget.h"
#include "../clangsettings/clangsettingsmanager.h"
#include <memory>
......@@ -521,6 +522,11 @@ ClangCodeCompletionContext::ClangCodeCompletionContext(const DUContextPointer& c
qCWarning(KDEV_CLANG) << "Something went wrong during 'clang_codeCompleteAt' for file" << file;
return;
}
auto addMacros = ClangSettingsManager::self()->codeCompletionSettings().macros;
if (!addMacros) {
m_filters |= NoMacros;
}
}
// check 'isValidPosition' after parsing the new content
......@@ -740,8 +746,9 @@ QList<CompletionTreeItemPointer> ClangCodeCompletionContext::completionItems(boo
return {};
}
addOverwritableItems();
addImplementationHelperItems();
addOverwritableItems();
eventuallyAddGroup(i18n("Special"), 700, specialItems);
eventuallyAddGroup(i18n("Macros"), 900, macros);
eventuallyAddGroup(i18n("Builtin"), 800, builtin);
......
......@@ -32,6 +32,7 @@ LINK_PRIVATE
kdevclangcodegen
kdevclangcodecompletion
kdevclangutil
settingsmanager
LINK_PUBLIC
KDev::Language
KDev::Project
......
......@@ -124,16 +124,7 @@ ParseSessionData::ParseSessionData(const QVector<UnsavedFile>& unsavedFiles, Cla
auto languageStandard = environment.languageStandard().toLocal8Bit();
QVector<const char*> args = argsForSession(tuUrl.str(), options, languageStandard);
if (!options.testFlag(DisableSpellChecking)) {
// TODO: Check whether this slows down parsing noticably
// also see http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20100705/032025.html
args << "-fspell-checking"; // note: disabled by default in CIndex
}
if (!options.testFlag(DisableDocumentationWarnings)) {
// TODO: Check whether this slows down parsing noticably
// according to llvm.org/devmtg/2012-11/Gribenko_CommentParsing.pdf this is about 5% with lots (> 10000) of documentation comments
args << "-Wdocumentation";
}
const auto& includes = environment.includes();
const auto& pchInclude = environment.pchInclude();
// uses QByteArray as smart-pointer for const char* ownership
......
......@@ -50,8 +50,6 @@ public:
enum Option {
NoOption, ///< No special options
DisableSpellChecking, ///< Disable -fspell-checking
DisableDocumentationWarnings, ///< Disable -Wdocumentation
SkipFunctionBodies, ///< Pass CXTranslationUnit_SkipFunctionBodies (likely unwanted)
PrecompiledHeader ///< Pass CXTranslationUnit_PrecompiledPreamble and others to cache precompiled headers
};
......
......@@ -26,6 +26,7 @@
#include "../util/clangdebug.h"
#include "../util/clangutils.h"
#include "../util/clangtypes.h"
#include "../clangsettings/clangsettingsmanager.h"
#include <interfaces/icore.h>
#include <interfaces/iprojectcontroller.h>
......@@ -430,10 +431,12 @@ ClangFixits fixUnknownDeclaration( const QualifiedIdentifier& identifier, const
{
ClangFixits fixits;
for( const auto& fixit : forwardDeclarations(identifier, file) ) {
fixits << fixit;
if (fixits.size() == maxSuggestions) {
return fixits;
if (ClangSettingsManager::self()->assistantsSettings().forwardDeclare) {
for (const auto& fixit : forwardDeclarations(identifier, file)) {
fixits << fixit;
if (fixits.size() == maxSuggestions) {
return fixits;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment