Parcourir la source

Implement "Find symbol declaration" (currently does not search system headers).

git-svn-id: file:///var/svn/tigccpp/trunk@824 9552661e-59e3-4036-b4f2-dbe53926924f
kevinkofler il y a 18 ans
Parent
commit
bc7905e12a
5 fichiers modifiés avec 44 ajouts et 12 suppressions
  1. 1 0
      ktigcc/completion.h
  2. 1 4
      ktigcc/mainform.ui
  3. 21 2
      ktigcc/mainform.ui.h
  4. 2 5
      ktigcc/srcfilewin.ui
  5. 19 1
      ktigcc/srcfilewin.ui.h

+ 1 - 0
ktigcc/completion.h

@@ -29,6 +29,7 @@
 #include <kate/view.h>
 
 struct CompletionInfo {
+  CompletionInfo() : dirty(false) {}
   bool dirty;
   QStringList includedSystem;
   QStringList included;

+ 1 - 4
ktigcc/mainform.ui

@@ -1107,9 +1107,6 @@
         <property name="statusTip">
             <string>Find symbol declaration</string>
         </property>
-        <property name="visible">
-            <bool>false</bool>
-        </property>
     </action>
     <actiongroup>
         <property name="name">
@@ -1717,6 +1714,7 @@
     <function>fileSave_fromto( const QString &amp; lastProj, const QString &amp; nextProj )</function>
     <function access="private" specifier="non virtual">findReplace_next( bool firstTime )</function>
     <function>findAndOpenFile( const QString &amp; fileName, void * category )</function>
+    <function>openHeader( const QString &amp; fileName, bool systemHeader, unsigned lineno )</function>
     <function access="private" specifier="non virtual" returnType="int">projectAddFiles_oneFile( const QString &amp; fileName )</function>
     <function returnType="QString">writeTempSourceFile( void * srcFile, bool inProject )</function>
     <function access="private" specifier="non virtual">startCompiling()</function>
@@ -1742,7 +1740,6 @@
     <function access="protected">closeEvent( QCloseEvent * e )</function>
     <function access="private" specifier="non virtual" returnType="QString">pathInProject( QListViewItem * item )</function>
     <function returnType="QString">textForHeader( const QString &amp; fileName )</function>
-    <function>openHeader(const QString &amp;fileName, bool systemHeader, unsigned lineno)</function>
 </functions>
 <pixmapinproject/>
 <layoutdefaults spacing="0" margin="0"/>

+ 21 - 2
ktigcc/mainform.ui.h

@@ -953,7 +953,7 @@ void MainForm::init()
   fileNewFolderAction->setEnabled(FALSE);
   te_popup = new QPopupMenu(this);
   te_popup->insertItem("&Open file at cursor",0);
-  //te_popup->insertItem("&Find symbol declaration",1);
+  te_popup->insertItem("&Find symbol declaration",1);
   te_popup->insertSeparator();
   te_popup->insertItem("&Undo",2);
   te_popup->insertItem("&Redo",3);
@@ -3345,7 +3345,26 @@ void MainForm::openHeader(const QString &fileName, bool systemHeader,
 
 void MainForm::findFindSymbolDeclaration()
 {
-
+  if (IS_FILE(currentListItem) && CURRENT_VIEW) {
+    QString fileText=CURRENT_VIEW->getDoc()->text();
+    CATEGORY_OF(category,currentListItem);
+    // "Find symbol declaration" only operates on C files.
+    if (category==cFilesListItem
+        || (category==hFilesListItem && fileText[0]!='|' && fileText[0]!=';')) {
+      QString fileName=pathInProject(currentListItem);
+      QString symbolFile;
+      unsigned symbolLine;
+      bool systemHeader;
+      if (findSymbolInFile(CURRENT_VIEW->currentWord(),fileText,fileName,this,
+                           symbolFile,symbolLine,systemHeader)
+          && !symbolFile.isNull()) {
+        if (symbolFile==fileName)
+          CURRENT_VIEW->setCursorPositionReal(symbolLine,0);
+        else
+          openHeader(symbolFile,systemHeader,symbolLine);
+      }
+    }
+  }
 }
 
 //returns 1 on success

+ 2 - 5
ktigcc/srcfilewin.ui

@@ -467,9 +467,6 @@
         <property name="statusTip">
             <string>Find symbol declaration</string>
         </property>
-        <property name="visible">
-            <bool>false</bool>
-        </property>
     </action>
     <action>
         <property name="name">
@@ -647,8 +644,8 @@
     <slot>findReplace_replace( const QString &amp; text, int replacementIndex, int replacedLength, int matchedLength )</slot>
     <slot>findReplace_stop()</slot>
     <slot>findFunctions()</slot>
-    <slot>findFunctions_functionListBox_highlighted(int index)</slot>
-    <slot>findFunctions_functionListBox_selected(int index)</slot>
+    <slot>findFunctions_functionListBox_highlighted( int index )</slot>
+    <slot>findFunctions_functionListBox_selected( int index )</slot>
     <slot>findFunctions_prototypeButton_clicked()</slot>
     <slot>findFunctions_implementationButton_clicked()</slot>
     <slot>findFunctionsPopup_aboutToShow()</slot>

+ 19 - 1
ktigcc/srcfilewin.ui.h

@@ -1075,7 +1075,25 @@ void SourceFileWindow::findOpenFileAtCursor()
 
 void SourceFileWindow::findFindSymbolDeclaration()
 {
-
+  QString fileText=CURRENT_VIEW->getDoc()->text();
+  // "Find symbol declaration" only operates on C files.
+  if (THIS->isCFile) {
+    QString fileName=THIS->fileName;
+    QString symbolFile;
+    unsigned symbolLine;
+    bool systemHeader;
+    if (findSymbolInFile(CURRENT_VIEW->currentWord(),fileText,fileName,
+                         THIS->mainForm,symbolFile,symbolLine,systemHeader)
+        && !symbolFile.isNull()) {
+      if (symbolFile==fileName)
+        CURRENT_VIEW->setCursorPositionReal(symbolLine,0);
+      else {
+        THIS->mainForm->openHeader(symbolFile,systemHeader,symbolLine);
+        if (!systemHeader)
+          KWin::activateWindow(THIS->mainForm->winId());
+      }
+    }
+  }
 }
 
 void SourceFileWindow::updateSizes()