Class Variables - no attrAutoCompleteAfter patch

Andrew Lowe <[email protected]> Sun, 11 Feb 2007 18:25:26 +1100
Newsgroups gmane.comp.kde.devel.quanta
Message-ID <[email protected]>
Andras,
Please find attached to svn diff to fix the first of the problems that I 
am looking at:
 Removing the "completionDTD->attrAutoCompleteAfter" which for php is: 
"(" from the autocompletion entry for class variables.

You have to update the description.rc to make variables a member of the 
class group - exactly as you sent in a previous email, then this code 
seems to work, and I do not believe it breaks anything?

Here is what I have done:
in sagroupparser.cpp SAGroupParser::parseForScriptGroup
    I check if s (the tag text) contains a "(" and if it does, I set the 
qTag->type to "function", otherwise I set it to "variable".
in document.cpp Document::getTagCompletions
    I add a QMap named type,
    I check if the completionDTD->family is Script, (if not ignore - it 
is XML) then if our tag->type is "variable" insert into the type QMap 
"variable", if it is function, insert "script" (so it works in 
Document::slotFilterCompletion.) I also add to the comments QMap the 
type ("variable" or "function") to show the user the type when they are 
using the autocomplete drop-down.
    Finally, I set the completion.type to be the type for that tag.
    I also made a TODO comment to sort the completions by type.

I hope everything is right - and I have not used any QTag or 
CompletionEntry variables I should not have - if so let me know.  Also 
let me know if anything is not right :-)

-- 
Andrew Lowe
    System Administrator & Programmer
        Information Technology
            Manildra Group

Email:   [email protected]
Phone:   02 4423 8270
Mobile:  04 1323 8270
Fax:     02 4421 7760

_______________________________________________
quanta-devel mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/quanta-devel
noautocompletafter-for-class-variables.patch (text/plain, 2.8 KB)
Index: parsers/sagroupparser.cpp
===================================================================
--- parsers/sagroupparser.cpp	(revision 631116)
+++ parsers/sagroupparser.cpp	(working copy)
@@ -216,6 +216,15 @@
               }
             }
           }
+          /* Author Andrew Lowe - [email protected]
+           * Test for variable or function Type by checking for an opening bracket "(" used by functions
+           * store the type in the QTag type variable.
+           */
+          if (s.find('(') == -1)
+            qTag->type="variable";
+          else
+            qTag->type="function";
+
           m_write->userTagList.insert(s.lower(), qTag);
         }
 
Index: src/document.cpp
===================================================================
--- src/document.cpp	(revision 631116)
+++ src/document.cpp	(working copy)
@@ -1285,6 +1285,10 @@
   completion.userdata = word + "|";
   QStringList tagNameList;
   QMap<QString, QString> comments;
+  /* Andrew Lowe - [email protected]
+   * A QMap to hold the completion type (function/string/class/etc)
+   */
+  QMap<QString, QString> type;
   QString tagName;
   QDictIterator<QTag> it(*(completionDTD->tagsList));
   int i = 0;
@@ -1318,6 +1322,24 @@
       tagName = tag->name() + QString("%1").arg(i, 10);
       tagNameList += tagName;
       comments.insert(tagName, tag->comment);
+      /* Author - Andrew Lowe - [email protected]
+       * If the completion family is script, then we want to update the tag type
+       * it appears we use "script" for adding the completionDTD->attrAutoCompleteAfter when we run the slotFilterCompletion
+       * so we will continue to use that for functions (they need the attribute added), but variables get a new type - and we do not
+       * have to auto-complete them
+       */
+      if(completionDTD->family==Script)
+      {
+        if(tag->type=="variable")
+          type.insert(tagName, tag->type);
+        else if(tag->type=="function")
+            type.insert(tagName, "script");
+      }
+      /*
+       * While we are at it - we might add the type to the comment variable, so it displays on the screen, giving the user some feedback
+       */
+      comments.insert(tagName, tag->type);
+
       i++;
     }
   }
@@ -1331,10 +1353,17 @@
       completion.text = tagNameList[i];
     completion.text = completion.text.left(completion.text.length() - 10).stripWhiteSpace();
     completion.comment = comments[tagNameList[i]];
+    /* Author Andrew Lowe - [email protected]
+     * Here we actually append the completion type
+     */
+    completion.type = type[tagNameList[i]];
     completions->append( completion );
   }
 
 //  completionInProgress = true;
+  /* Author - Andrew Lowe - [email protected]
+   * TODO: Sort completions here (variables first, then functions)
+   */
   return completions;
 }