Menu

#192 Ignore patterns in comments (php)

closed-fixed
None
5
2014-09-30
2007-09-16
No

E.g. in php files, the following file will create a "class tag":
<?php
/**
* ... class name ...
*/
?>

Obviously, this is a comment and therefor should get ignored.

Maybe it would make sense to have some properties per mode which indicate line and block comments and if defined, would make ctags ignore those, e.g. for the patterns added by addTagRegex.

Discussion

  • John Lindal

    John Lindal - 2007-09-17
    • assigned_to: nobody --> jafl
    • status: open --> open-accepted
     
  • Mark A. Jaroski

    Mark A. Jaroski - 2007-12-17

    Logged In: YES
    user_id=1620546
    Originator: NO

    For myself I've fixed this by changing ctags to use explicit visibility markers (public, private, protected). Here's the patch:

    --- php.old.c 2007-12-17 12:08:39.000000000 +0100
    +++ php.new.c 2007-12-17 12:08:30.000000000 +0100
    @@ -64,16 +64,18 @@

    static void installPHPRegex (const langType language)
    {
    - addTagRegex(language, "(^|[ \t])class[ \t]+([" ALPHA "_][" ALNUM "_]*)",
    - "\\2", "c,class,classes", NULL);
    - addTagRegex(language, "(^|[ \t])interface[ \t]+([" ALPHA "_][" ALNUM "_]*)",
    - "\\2", "i,interface,interfaces", NULL);
    - addTagRegex(language, "(^|[ \t])define[ \t]*\\([ \t]*['\"]?([" ALPHA "_][" ALNUM "_]*)",
    - "\\2", "d,define,constant definitions", NULL);
    - addTagRegex(language, "(^|[ \t])function[ \t]+&?[ \t]*([" ALPHA "_][" ALNUM "_]*)",
    - "\\2", "f,function,functions", NULL);
    - addTagRegex(language, "(^|[ \t])\\$([" ALPHA "_][" ALNUM "_]*)[ \t]*=",
    - "\\2", "v,variable,variables", NULL);
    + addTagRegex(language, "(^[ \t]*)((public|private|protected)[ \t]*)?class[ \t]+([" ALPHA "_][" ALNUM "_]*)",
    + "\\4", "c,class,classes", NULL);
    + addTagRegex(language, "(^[ \t]*)((public|private|protected)[ \t]*)?interface[ \t]+([" ALPHA "_][" ALNUM "_]*)",
    + "\\4", "i,interface,interfaces", NULL);
    + addTagRegex(language, "(^[ \t]*)((public|private|protected)[ \t]*)?const[ \t]*\\([ \t]*['\"]?([" ALPHA "_][" ALNUM "_]*)",
    + "\\4", "d,define,constant definitions", NULL);
    + addTagRegex(language, "(^[ \t]*)((public|private|protected)[ \t]*)?define[ \t]*\\([ \t]*['\"]?([" ALPHA "_][" ALNUM "_]*)",
    + "\\4", "d,define,constant definitions", NULL);
    + addTagRegex(language, "(^[ \t]*)((public|private|protected)[ \t]*)?function[ \t]+&?[ \t]*([" ALPHA "_][" ALNUM "_]*)",
    + "\\4", "f,function,functions", NULL);
    + addTagRegex(language, "(^[ \t]*)((public|private|protected)[ \t]*)?\\$([" ALPHA "_][" ALNUM "_]*)[ \t]*=",
    + "\\4", "v,variable,variables", NULL);

    /* function regex is covered by PHP regex */
    addTagRegex (language, "(^|[ \t])([A-Za-z0-9_]+)[ \t]*[=:][ \t]*function[ \t]*\\(",

     
  • Elliott Hughes

    Elliott Hughes - 2008-02-16

    Logged In: YES
    user_id=1127237
    Originator: NO

    see also duplicate 1894455.

     
  • John Lindal

    John Lindal - 2009-07-10

    public|protected|private only applies to functions and variables. abstract is the only modifier for classes. I will check in an update.

     
  • John Lindal

    John Lindal - 2009-07-10
    • status: open-accepted --> open-fixed
     
  • John Lindal

    John Lindal - 2009-12-03

    The fix is checked into trunk. It will be in the next release (after 5.8.0)

     
  • John Lindal

    John Lindal - 2009-12-03
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB