1

我需要用符号浏览器做一个编辑器,我说我会玩 ctags。好吧,我阅读了 ctags 格式并尝试使用 Google 并在 SO 上搜索。我发现的只是关于 ctags 和 vim 的问题,而我在 vim 上为零。所以我决定自己一个人玩。所以我拿了一个标签文件,我完全糊涂了!

在这里,我放置了 PHP 文件及其相应的标签,我需要您的帮助,我如何知道该行代表类属性还是方法?另外我怎么知道 PHP 函数/方法的返回值?

除了 vi/vim 连接之外,我还没有找到任何关于在 ctags 中处理 PHP(或任何其他语言)标签的好教程!谢谢

PHP 文件

<?php

$teachers = array("standard one"=>"Celina Stephen", "Standard Two"=>"Emanyor Dickson");

function set_teachers($teacher_array){
    $teachers = $teacher_array;
    return $teacher_array;
}

class School{
    $teachers;
    $students;

    public function __construct(){

    }

    public function get_all(){
        return array($this->teachers,$this->students);
    }
}

class ManySchools extends School{
    public __construct(){
        parent::construct();
    }

    private do_selection($teacher, $student=null){
        return false;
    }

}

标签文件

!_TAG_FILE_FORMAT   2   /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED   1   /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR    Darren Hiebert  /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME  Exuberant Ctags //
!_TAG_PROGRAM_URL   http://ctags.sourceforge.net    /official site/
!_TAG_PROGRAM_VERSION   5.9~svn20110310 //
ManySchools test.php    /^class ManySchools extends School{$/;" c
School  test.php    /^class School{$/;" c
__construct test.php    /^    public function __construct(){$/;"    f
get_all test.php    /^    public function get_all(){$/;"    f
set_teachers    test.php    /^function set_teachers($teacher_array){$/;"    f
teachers    test.php    /^    $teachers = $teacher_array;$/;"   v
teachers    test.php    /^$teachers = array("standard one"=>"Celina Stephen", "Standard Two"=>"Emanyor Dickson");$/;"   v
4

2 回答 2

4

;"每行中的第一项描述kind了标记的,即它是否是类、函数等。在您的示例c中代表类、f函数等。您可以使用 获取完整列表ctags --list-kinds=php

(不幸的是)ctags 没有报告返回类型。

您绝对应该看一下 ctags 手册页,那里对所有内容都进行了很好的解释,例如除了默认报告的信息之外,它还可以报告哪些其他信息。

于 2011-10-28T13:44:42.920 回答
0

好吧,我读了 ctags 格式

Exuberant Ctags文件格式有据可查。

于 2012-03-02T08:06:06.400 回答