I need to make an editor with Symbol Browser and I said I would toy with ctags. Well I read ctags format and Tried to Google and search here at SO. All I found were questions about ctags and vim and I'm zero at vim . So I decided I will play around by myself. So I took a tag file and I was totally confused!
Here I have put the PHP File and its corresponding tag and I need your help on how do I know if the line represents class attribute or method? Also how can I know return value of PHP function/method?
I have not found any good tutorial on dealing with PHP (or any other language) tags in ctags other than vi/vim connected! Thanks
PHP File
<?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;
}
}
tags file
!_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 /[email protected]/
!_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
The first item after the ;"
in each line describes the kind
of the tag, that is whether it is a class, function etc. In your example c
stands for class, f
for function and so on. You can get the complete list with ctags --list-kinds=php
.
Return types are (unfortunately) not reported by ctags.
You should definitely have a look at the ctags manpage, everything is explained quite well there, for example what other information it can report in addition to the information it reports by default.