Bug 122385

Summary: Impossible to disable error checking
Product: [Applications] kdevelop Reporter: Yevgen Muntyan <ymuntyan>
Component: Problem reporterAssignee: kdevelop-bugs-null
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 3.3.1   
Target Milestone: ---   
Platform: FreeBSD Ports   
OS: FreeBSD   
Latest Commit: Version Fixed In:

Description Yevgen Muntyan 2006-02-20 23:53:13 UTC
Version:           3.3.1 (using KDE KDE 3.5.1)
Installed from:    FreeBSD Ports
OS:                FreeBSD

It's impossible to turn off error checking, and it's really annoying in some cases. 
Example: glib has macros like DEFINE_SOME_STUFF(arguments) which expand to stuff like

static void some_func ()
{
   ...
}

so one can't put semicolon after such a macro, and kdevelop thinks it's a syntax error since the macro looks like function call.
Comment 1 Jens Dagerbo 2006-12-29 21:17:32 UTC
SVN commit 617644 by dagerbo:

This patch finally makes the c++ problem reporter optional! 
Also, added "whatsthis" descriptions to the 'C++ Parsing' settings.

BUG: 122385

 M  +47 -2     configproblemreporter.ui  
 M  +5 -0      configproblemreporter.ui.h  
 M  +87 -11    cppsupportpart.cpp  
 M  +8 -1      cppsupportpart.h  
 M  +0 -21     problemreporter.cpp  
 M  +0 -2      problemreporter.h  


--- branches/kdevelop/3.4/languages/cpp/configproblemreporter.ui #617643:617644
@@ -1,4 +1,4 @@
-<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
 <class>ConfigureProblemReporter</class>
 <widget class="QWidget">
     <property name="name">
@@ -12,12 +12,43 @@
             <height>492</height>
         </rect>
     </property>
+    <property name="caption">
+        <string>ConfigureProblemReporter</string>
+    </property>
     <vbox>
         <property name="name">
             <cstring>unnamed</cstring>
         </property>
         <widget class="QGroupBox">
             <property name="name">
+                <cstring>groupBox3_2</cstring>
+            </property>
+            <property name="title">
+                <string>Problem Reporter</string>
+            </property>
+            <property name="whatsThis" stdset="0">
+                <string>If enabled, the C++ parser will report any syntax errors it detects. 
+They will be displayed in the 'Problems' output view and as markers in the editor.</string>
+            </property>
+            <hbox>
+                <property name="name">
+                    <cstring>unnamed</cstring>
+                </property>
+                <widget class="QCheckBox">
+                    <property name="name">
+                        <cstring>problemReporterCheckbox</cstring>
+                    </property>
+                    <property name="text">
+                        <string>&amp;Use Problem Reporter</string>
+                    </property>
+                    <property name="accel">
+                        <string>Alt+U</string>
+                    </property>
+                </widget>
+            </hbox>
+        </widget>
+        <widget class="QGroupBox">
+            <property name="name">
                 <cstring>groupBox1</cstring>
             </property>
             <property name="frameShadow">
@@ -26,6 +57,11 @@
             <property name="title">
                 <string>Parsing</string>
             </property>
+            <property name="whatsThis" stdset="0">
+                <string>If enabled, the C++ parser will run on the active file after the stated timeout, after there has been any changes to the text.
+
+If disabled, the parser will typically only run when the file is saved.</string>
+            </property>
             <vbox>
                 <property name="name">
                     <cstring>unnamed</cstring>
@@ -43,8 +79,11 @@
                                 <cstring>bgParserCheckbox</cstring>
                             </property>
                             <property name="text">
-                                <string>&amp;Enable background parsing</string>
+                                <string>Enable &amp;background parsing</string>
                             </property>
+                            <property name="accel">
+                                <string>Alt+B</string>
+                            </property>
                         </widget>
                         <widget class="QLabel">
                             <property name="name">
@@ -71,6 +110,9 @@
                     <property name="name">
                         <cstring>delaySlider</cstring>
                     </property>
+                    <property name="minValue">
+                        <number>250</number>
+                    </property>
                     <property name="maxValue">
                         <number>2000</number>
                     </property>
@@ -99,6 +141,9 @@
             <property name="title">
                 <string>Special &amp;Headers</string>
             </property>
+            <property name="whatsThis" stdset="0">
+                <string>Often a macro that the C++ parser must understand in order to correctly parse a piece of code is defined somewhere in some far off header file that the parser doesn't look at. This textbox can be used to define those macros locally so that the C++ parser to understand them.</string>
+            </property>
             <vbox>
                 <property name="name">
                     <cstring>unnamed</cstring>
--- branches/kdevelop/3.4/languages/cpp/configproblemreporter.ui.h #617643:617644
@@ -23,6 +23,7 @@
 	m_part = 0;
 	KConfig* config = kapp->config();
 	config->setGroup( "General Options" );
+	problemReporterCheckbox->setChecked( config->readBoolEntry( "EnableProblemReporter", true ) );
 	bgParserCheckbox->setChecked( config->readBoolEntry( "EnableCppBgParser", true ) );
 	delaySlider->setEnabled( bgParserCheckbox->isChecked() );
 	delaySlider->setValue( config->readNumEntry( "CppBgParserDelay", 500 ) );
@@ -55,11 +56,15 @@
 {
 	KConfig * config = kapp->config();
 	config->setGroup( "General Options" );
+	config->writeEntry( "EnableProblemReporter", problemReporterCheckbox->isChecked() );
 	config->writeEntry( "EnableCppBgParser", bgParserCheckbox->isChecked() );
 	if ( bgParserCheckbox->isChecked() )
 		config->writeEntry( "CppBgParserDelay", delaySlider->value() );
 	config->sync();
 
+	m_part->updateBackgroundParserConfig();
+	
+	
 	if ( m_part && specialHeader->isModified() )
 	{
 		QString conf_file_name = m_part->specialHeaderName( true );
--- branches/kdevelop/3.4/languages/cpp/cppsupportpart.cpp #617643:617644
@@ -51,6 +51,7 @@
 // designer integration
 #include "qtdesignercppintegration.h"
 #include "cppimplementationwidget.h"
+#include "configproblemreporter.h"
 
 #include <qeventloop.h>
 #include <qheader.h>
@@ -168,8 +169,33 @@
 	}
 };
 
+// ProblemReporter doesn't really depend on background parsing, so it's a bit of a mixup to 
+// handle them together, but it's the same config widget so...
+class BackgroundParserConfig
+{
+	bool m_useProblemReporter;
+	bool m_useBackgroundParser;
+	int m_backgroundParseDelay;
+public:
+	void readConfig()
+	{
+		KConfig* config = kapp->config();
+		config->setGroup( "General Options" );
+		m_useProblemReporter = config->readBoolEntry( "EnableProblemReporter", true );
+		m_useBackgroundParser = config->readBoolEntry( "EnableCppBgParser", true );
+		m_backgroundParseDelay = config->readNumEntry( "BgParserDelay", 500 );
+	}
+	
+	bool useProblemReporter() { return m_useProblemReporter; }
+	bool useBackgroundParser() { return m_useBackgroundParser; }
+	int backgroudParseDelay() { return m_backgroundParseDelay; }
+};
+
 CppSupportPart::CppSupportPart( QObject *parent, const char *name, const QStringList &args )
-: KDevLanguageSupport( CppSupportFactory::info(), parent, name ? name : "KDevCppSupport" ), m_backgroundParser(0), m_activeDocument( 0 ), m_activeView( 0 ), m_activeSelection( 0 ), m_activeEditor( 0 ), m_activeViewCursor( 0 ), m_projectClosed( true ), m_projectClosing( false ), m_valid( false ), _jd(0), m_isTyping( false ), m_hadErrors( false )
+: KDevLanguageSupport( CppSupportFactory::info(), parent, name ? name : "KDevCppSupport" ), m_backgroundParser(0), 
+	m_activeDocument( 0 ), m_activeView( 0 ), m_activeSelection( 0 ), m_activeEditor( 0 ), m_activeViewCursor( 0 ), 
+	m_projectClosed( true ), m_projectClosing( false ), m_valid( false ), m_isTyping( false ), m_hadErrors( false ), 
+	_jd(0)
 {
 	setInstance( CppSupportFactory::instance() );
 
@@ -182,6 +208,9 @@
 	m_qtBuildConfig = new QtBuildConfig( this, projectDom() );
     m_qtBuildConfig->store();
 
+	m_backgroundParserConfig = new BackgroundParserConfig;
+	m_backgroundParserConfig->readConfig();
+	
 	m_driver = new CppDriver( this );
 	m_problemReporter = 0;
 
@@ -308,14 +337,17 @@
 		codeRepository() ->unregisterCatalog( catalog );
 	}
 
-	mainWindow( ) ->removeView( m_problemReporter );
 
+	delete m_backgroundParserConfig;
+	m_backgroundParserConfig = 0;
+	
 	delete m_pCompletion;
+	m_pCompletion = 0;
+	
+/*	mainWindow()->removeView( m_problemReporter );
 	delete m_problemReporter;
-
-	m_pCompletion = 0;
 	m_problemReporter = 0;
-
+*/
 	delete _jd;
 	_jd = 0;
 
@@ -390,6 +422,12 @@
 	                                 BarIcon( info() ->icon(), KIcon::SizeMedium ) );
 	ClassGeneratorConfig *w = new ClassGeneratorConfig( vbox, "classgenerator config widget" );
 	connect( dlg, SIGNAL( okClicked() ), w, SLOT( storeConfig() ) );
+	
+	vbox = dlg->addVBoxPage(i18n("C++ Parsing"), i18n("C++ Parsing"),
+	                               BarIcon( "source_cpp", KIcon::SizeMedium) );
+	ConfigureProblemReporter* ww = new ConfigureProblemReporter( vbox );
+	ww->setPart( this );
+	connect(dlg, SIGNAL(okClicked()), ww, SLOT(accept()));	
 }
 
 void CppSupportPart::activePartChanged( KParts::Part *part )
@@ -486,10 +524,7 @@
 
 	setupCatalog();
 
-	m_problemReporter = new ProblemReporter( this, 0, "problemReporterWidget" );
-	m_problemReporter->setIcon( SmallIcon( "info" ) );
-	m_problemReporter->setCaption( i18n( "Problem Reporter" ) );
-	mainWindow( ) ->embedOutputView( m_problemReporter, i18n( "Problems" ), i18n( "Problem reporter" ) );
+	embedProblemReporter();
 
 	connect( core(), SIGNAL( configWidget( KDialogBase* ) ),
 	         m_problemReporter, SLOT( configWidget( KDialogBase* ) ) );
@@ -515,7 +550,25 @@
 	QTimer::singleShot( 500, this, SLOT( initialParse( ) ) );
 }
 
+void CppSupportPart::embedProblemReporter( bool force )
+{
+	if ( force || m_backgroundParserConfig->useProblemReporter() )
+	{
+		m_problemReporter = new ProblemReporter( this, 0, "problemReporterWidget" );
+		m_problemReporter->setIcon( SmallIcon( "info" ) );
+		m_problemReporter->setCaption( i18n( "Problem Reporter" ) );
+		mainWindow( ) ->embedOutputView( m_problemReporter, i18n( "Problems" ), i18n( "Problem reporter" ) );
+	}
+}
 
+void CppSupportPart::removeProblemReporter()
+{
+	mainWindow()->removeView( m_problemReporter );
+	delete m_problemReporter;
+	m_problemReporter = 0;
+}
+
+
 void CppSupportPart::projectClosed( )
 {
 	kdDebug( 9007 ) << "projectClosed( )" << endl;
@@ -546,6 +599,8 @@
 	delete _jd;
 	_jd = 0;
 
+	removeProblemReporter();
+	
 	delete m_pCompletion;
 	m_parseEmitWaiting.clear();
 	m_fileParsedEmitWaiting.clear();
@@ -2733,18 +2788,39 @@
 {
 	setTyping( true );	///@todo check if this is really needed
 	
-	///@todo use user setting (see problemreporter)
-	m_textChangedTimer->start( 250, true );
+	if ( m_backgroundParserConfig->useBackgroundParser() )
+	{
+		m_textChangedTimer->start( m_backgroundParserConfig->backgroudParseDelay(), true );
+	}
 }
 
 void CppSupportPart::slotParseCurrentFile()
 {
+// 	if( isValid() && !isQueued( m_activeFileName ) ) 
 	if( !isQueued( m_activeFileName ) ) 
 	{
 		parseFileAndDependencies( m_activeFileName, true, true );
 	}
 }
 
+void CppSupportPart::updateBackgroundParserConfig()
+{
+	BackgroundParserConfig config;
+	config.readConfig();
+	
+	if ( m_backgroundParserConfig->useProblemReporter() && !config.useProblemReporter() )
+	{
+		removeProblemReporter();
+	}
+	else if ( !m_backgroundParserConfig->useProblemReporter() && config.useProblemReporter() )
+	{
+		embedProblemReporter( true );
+	}
+	
+	*m_backgroundParserConfig = config;
+}
+
 #include "cppsupportpart.moc"
 //kate: indent-mode csands; tab-width 4; space-indent off;
 
+
--- branches/kdevelop/3.4/languages/cpp/cppsupportpart.h #617643:617644
@@ -49,6 +49,7 @@
 class KListView;
 class Driver;
 class KPopupMenu;
+class BackgroundParserConfig;
 
 
 namespace KParts
@@ -79,7 +80,8 @@
 
 	QString specialHeaderName( bool local = false ) const;
 	void updateParserConfiguration();
-
+	void updateBackgroundParserConfig();
+	
 	// @fixme - isValid is used to avoid using the problem reporter
 	// when a project is first parsed. This because the problem reporter
 	// is currently a great slowdown for large projects (see bug #73671)
@@ -226,6 +228,9 @@
 	void slotTextChanged();
 	void slotCursorMoved();
 	void slotParseCurrentFile();
+	void embedProblemReporter( bool force = false );
+	void removeProblemReporter();
+	
 
 	void slotNeedTextHint( int, int, QString& );
 
@@ -496,6 +501,8 @@
 	void parseEmit( ParseEmitWaiting::Processed files );
 private:
 	
+	BackgroundParserConfig * m_backgroundParserConfig;
+	
 	static QStringList m_sourceMimeTypes;
 	static QStringList m_headerMimeTypes;
 
--- branches/kdevelop/3.4/languages/cpp/problemreporter.cpp #617643:617644
@@ -150,8 +150,6 @@
 	connect( part->partController(), SIGNAL(partAdded(KParts::Part*)),
 	         this, SLOT(slotPartAdded(KParts::Part*)) );
 
-	configure();
-
 	// any editors that were open when we loaded the project needs to have their markType07 icon set too..
 	QPtrListIterator<KParts::Part> it( *m_cppSupport->partController()->parts() );
 	while( it.current() )
@@ -372,25 +370,6 @@
 	initCurrentList();
 }
 
-void ProblemReporter::configure()
-{
-	kdDebug(9007) << "ProblemReporter::configure()" << endl;
-	KConfig* config = kapp->config();
-	config->setGroup( "General Options" );
-	m_active = config->readBoolEntry( "EnableCppBgParser", TRUE );
-	m_delay = config->readNumEntry( "BgParserDelay", 250 );
-}
-
-void ProblemReporter::configWidget( KDialogBase* dlg )
-{
-	QVBox *vbox = dlg->addVBoxPage(i18n("C++ Parsing"), i18n("C++ Parsing"),
-	                               BarIcon( "source_cpp", KIcon::SizeMedium) );
-	ConfigureProblemReporter* w = new ConfigureProblemReporter( vbox );
-	w->setPart( m_cppSupport );
-	connect(dlg, SIGNAL(okClicked()), w, SLOT(accept()));
-	connect(dlg, SIGNAL(okClicked()), this, SLOT(configure()));
-}
-
 void ProblemReporter::slotPartAdded( KParts::Part* part )
 {
 	KTextEditor::MarkInterfaceExtension* iface = dynamic_cast<KTextEditor::MarkInterfaceExtension*>( part );
--- branches/kdevelop/3.4/languages/cpp/problemreporter.h #617643:617644
@@ -106,8 +106,6 @@
 	bool hasErrors(const QString& file);
 
 public slots:
-	void configure();
-	void configWidget( KDialogBase* );
 
 private slots:
 	void slotPartAdded( KParts::Part* );