Code-Completion with $ in variable names

Niko Sams niko.sams at gmail.com
Fri Oct 31 16:46:28 UTC 2008


Hi,

As all variables in Php start with a $ I'm facing some problems for
code completion.
I'm not sure where to solve them.

- I don't store as identifier for the variable the $
- In CompletionItem::data I add the $ for DisplayRole

In KateCompletionWidget::determineRange() the range is reported without $, so
I tweaked that regular expression to include $ there:

--- completion/katecompletionwidget.cpp (Revision 872602)
+++ completion/katecompletionwidget.cpp (Arbeitskopie)
@@ -798,8 +798,8 @@

   QString text = view()->document()->line(end.line());

-  static QRegExp findWordStart( "\\b([_\\w]+)$" );
+  static QRegExp findWordStart( "^[^\\w\\$]*(\\$?\\w+)" );
  static QRegExp findWordEnd( "^(\\w*)\\b" );

   KTextEditor::Cursor start = end;

(I also removed the _ as it is included in \w)
Is this change Ok?

Next problem (with this patch applied) is when executing the - the $ is
missing.


So what are the best solutions for my problems?


Niko




More information about the KDevelop-devel mailing list