unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* etags and php classes
@ 2014-04-02  6:40 Luca Ferrari
  2014-04-02 16:03 ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Luca Ferrari @ 2014-04-02  6:40 UTC (permalink / raw)
  To: help-gnu-emacs

I've a project made of several php files, some procedural and some OOP.
I ran etags on the whole set of files, and while functions are mapped
well, classes and their members are not at all.
I've tried also to add the --member option to etags, but nothing changed:

etags -l php --members `find . -name '*.php'`

Am I missing something?

Thanks,
Luca



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: etags and php classes
  2014-04-02  6:40 etags and php classes Luca Ferrari
@ 2014-04-02 16:03 ` Eli Zaretskii
  2014-04-03  6:27   ` Luca Ferrari
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2014-04-02 16:03 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Wed, 2 Apr 2014 08:40:26 +0200
> From: Luca Ferrari <fluca1978@infinito.it>
> 
> I've a project made of several php files, some procedural and some OOP.
> I ran etags on the whole set of files, and while functions are mapped
> well, classes and their members are not at all.
> I've tried also to add the --member option to etags, but nothing changed:
> 
> etags -l php --members `find . -name '*.php'`
> 
> Am I missing something?

Perhaps post here a sample file with classes that are not tagged.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: etags and php classes
  2014-04-02 16:03 ` Eli Zaretskii
@ 2014-04-03  6:27   ` Luca Ferrari
  2014-04-03  9:47     ` Chris Van Dusen
  0 siblings, 1 reply; 7+ messages in thread
From: Luca Ferrari @ 2014-04-03  6:27 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

On Wed, Apr 2, 2014 at 6:03 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> Perhaps post here a sample file with classes that are not tagged.

Consider the following simple file (class):

<?php

class Foo{
    public function doSomething(){
        echo "Something";
    }

    public function doSomethingElse(){
        echo "Else";
    }
}


?>

then, if I rebuild the tags file with
etags --members `find . -name '*.php'`

and then list the tags for Foo I got (M-x list-tags Foo.php):

Tags in file `/sviluppo/php/edilweb/edilweb/classes/Foo.php':

class Foo{


If I search for one of the functions (M-.) I got:

No tags containing doSomethingElse


Any idea?
Thanks,
Luca



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: etags and php classes
  2014-04-03  6:27   ` Luca Ferrari
@ 2014-04-03  9:47     ` Chris Van Dusen
  2014-04-03 15:22       ` Luca Ferrari
  0 siblings, 1 reply; 7+ messages in thread
From: Chris Van Dusen @ 2014-04-03  9:47 UTC (permalink / raw)
  To: Luca Ferrari; +Cc: help-gnu-emacs

On Apr 3, 2014, at 1:27 AM, Luca Ferrari <fluca1978@infinito.it> wrote:

> 
> Consider the following simple file (class):
> 
> <?php
> 
> class Foo{
>    public function doSomething(){
>        echo "Something";
>    }
> 
>    public function doSomethingElse(){
>        echo "Else";
>    }
> }
> 
> 
> ?>
> 
> then, if I rebuild the tags file with
> etags --members `find . -name '*.php'`
> 
> and then list the tags for Foo I got (M-x list-tags Foo.php):
> 
> Tags in file `/sviluppo/php/edilweb/edilweb/classes/Foo.php':
> 
> class Foo{
> 
> 
> If I search for one of the functions (M-.) I got:
> 
> No tags containing doSomethingElse
> 

Looking at the output of stags —help, I see that it lists support
for PHP only up to php4.

PHP4 doesn't support visibility operators (public, private, 
protected), so if you remove those, and rerun stags,
M-x list-tags will display the functions.

hth,
Chris.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: etags and php classes
  2014-04-03  9:47     ` Chris Van Dusen
@ 2014-04-03 15:22       ` Luca Ferrari
  2014-04-03 18:00         ` cavd
  0 siblings, 1 reply; 7+ messages in thread
From: Luca Ferrari @ 2014-04-03 15:22 UTC (permalink / raw)
  To: Chris Van Dusen; +Cc: help-gnu-emacs

On Thu, Apr 3, 2014 at 11:47 AM, Chris Van Dusen <cavandusen@gmail.com> wrote:
> PHP4 doesn't support visibility operators (public, private,
> protected), so if you remove those, and rerun stags,
> M-x list-tags will display the functions.

Arghhhhh! That's correct (of course), but removing all the visibility
from my classes to gain in tagging does not sound like a good idea.
Sgrunt!

Luca



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: etags and php classes
  2014-04-03 15:22       ` Luca Ferrari
@ 2014-04-03 18:00         ` cavd
  2014-04-03 23:45           ` Leo Liu
  0 siblings, 1 reply; 7+ messages in thread
From: cavd @ 2014-04-03 18:00 UTC (permalink / raw)
  To: Luca Ferrari; +Cc: help-gnu-emacs

On Apr 3, 2014, at 10:22, Luca Ferrari <fluca1978@infinito.it> wrote:

> On Thu, Apr 3, 2014 at 11:47 AM, Chris Van Dusen <cavandusen@gmail.com> wrote:
>> PHP4 doesn't support visibility operators (public, private,
>> protected), so if you remove those, and rerun stags,
>> M-x list-tags will display the functions.
> 
> Arghhhhh! That's correct (of course), but removing all the visibility
> from my classes to gain in tagging does not sound like a good idea.
> Sgrunt!
> 
> Luca

You might try GNU Global; it's pretty nice. 

Chris. 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: etags and php classes
  2014-04-03 18:00         ` cavd
@ 2014-04-03 23:45           ` Leo Liu
  0 siblings, 0 replies; 7+ messages in thread
From: Leo Liu @ 2014-04-03 23:45 UTC (permalink / raw)
  To: cavd; +Cc: help-gnu-emacs, Luca Ferrari

[-- Attachment #1: Type: text/plain, Size: 423 bytes --]

On 2014-04-04 02:00 +0800, cavd wrote:
> You might try GNU Global; it's pretty nice. 
>
> Chris. 

I use global CVS + php.diff (attached) + ggtags.el. The patch should
make Global usable for php5.

If you install Global with the right plugin it can support many
languages reasonably nicely with the ability to find both definitions
and references. See
https://github.com/leoliu/ggtags#install-global-and-plugins

HTH,
Leo


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: php.diff --]
[-- Type: text/x-patch, Size: 4305 bytes --]

From cde42478e8e8666974a8ed261084c6fa2f96b563 Mon Sep 17 00:00:00 2001
From: Leo Liu <sdl.web@gmail.com>
Date: Wed, 5 Mar 2014 14:41:14 +0800
Subject: [PATCH 1/2] Update reserved words for PHP

---
 libparser/php_res.in | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/libparser/php_res.in b/libparser/php_res.in
index 5f8bd754..84053ca3 100644
--- a/libparser/php_res.in
+++ b/libparser/php_res.in
@@ -13,17 +13,29 @@
 ;
 ; PHP reserved word list.
 ;
-__FILE__		word
+; http://us2.php.net/manual/en/language.constants.predefined.php
 __LINE__		word
+__FILE__		word
+__DIR__                 word
 __FUNCTION__		word
 __CLASS__		word
+__TRAIT__               word
+__METHOD__              word
+__NAMESPACE__           word
+;
+; http://us2.php.net/manual/en/reserved.keywords.php
+__halt_compiler,__HALT_COMPILER,__Halt_Compiler         word
+abstract,ABSTRACT,Abstract                              word
 and,AND,And						word
 array,ARRAY,Array					word
 as,AS,As						word
 break,BREAK,Break					word
+callable,CALLABLE,Callable                              word
 case,CASE,Case						word
+catch,CATCH,Catch                                       word
 cfunction,CFUNCTION,Cfunction,CFunction			word
 class,CLASS,Class					word
+clone,CLONE,Clone                                       word
 const,CONST,Const					word
 continue,CONTINUE,Continue				word
 declare,DECLARE,Declare					word
@@ -44,24 +56,36 @@ endwhile,ENDWHILE,Endwhile,EndWhile			word
 endswitch,ENDSWITCH,Endswitch,EndSwitch			word
 eval,EVAL,Eval						word
 exit,EXIT,Exit						word
+extends,EXTENDS,Extends				        word
 failure,FAILURE,Failure					word
 false,FALSE,False					word
+final,FINAL,Final					word
 for,FOR,For						word
 foreach,FOREACH,Foreach,ForEach				word
 function,FUNCTION,Function				word
 global,GLOBAL,Global					word
+goto,GOTO,Goto					        word
 header,HEADER,Header					word
 list,LIST,List						word
 if,IF,If						word
+implements,IMPLEMENTS,Implements			word
 include,INCLUDE,Include					word
 include_once,INCLUDE_ONCE,Include_once,Include_Once	word
+instanceof,INSTANCEOF,Instanceof			word
+insteadof,INSTEADOF,Insteadof				word
+interface,INTERFACE,Interface				word
 is_array,IS_ARRAY,Is_array,Is_Array			word
 is_set,IS_SET,Is_set,Is_Set				word
+isset,ISSET,Isset					word
+namespace,NAMESPACE,Namespace				word
 new,NEW,New						word
 old_function,OLD_FUNCTION,Old_function,Old_Function	word
 or,OR,Or						word
 print,PRINT,Print					word
 printf,PRINTF,Printf					word
+private,PRIVATE,Private					word
+protected,PROTECTED,Protected				word
+public,PUBLIC,Public					word
 return,RETURN,Return					word
 require,REQUIRE,Require					word
 require_once,REQUIRE_ONCE,Require_once,Require_Once	word
@@ -69,7 +93,11 @@ setcookie,SETCOOKIE,Setcookie,SetCookie			word
 success,SUCCESS,Success					word
 static,STATIC,Static					word
 switch,SWITCH,Switch					word
+throw,THROW,Throw					word
+trait,TRAIT,Trait					word
+try,TRY,Try					        word
 true,TRUE,True						word
+use,USE,Use					        word
 var,VAR,Var						word
 while,WHILE,While					word
 unset,UNSET,Unset					word
-- 
1.9.1.352.gd393d14


From a72fafcda8b9fb53baad122903ce7cbf28ebe5a6 Mon Sep 17 00:00:00 2001
From: Leo Liu <sdl.web@gmail.com>
Date: Wed, 5 Mar 2014 17:01:04 +0800
Subject: [PATCH 2/2] update php lexer

---
 libparser/php.l | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/libparser/php.l b/libparser/php.l
index 584112bc..24459042 100644
--- a/libparser/php.l
+++ b/libparser/php.l
@@ -298,6 +298,12 @@ php(const struct parser_param *param)
 			PUT(PARSER_DEF, strbuf_value(string), LEXLINENO);
 			break;
 		case PHP_CLASS:
+		case PHP_INTERFACE:
+			if (LEXLEX(param) != PHP_TOKEN)
+				break;
+			PUT(PARSER_DEF, LEXTEXT, LEXLINENO);
+			break;
+		case PHP_CONST:
 			if (LEXLEX(param) != PHP_TOKEN)
 				break;
 			PUT(PARSER_DEF, LEXTEXT, LEXLINENO);
@@ -309,6 +315,11 @@ php(const struct parser_param *param)
 				break;
 			PUT(PARSER_DEF, LEXTEXT, LEXLINENO);
 			break;
+		case PHP_TRAIT:
+			if (LEXLEX(param) != PHP_TOKEN)
+				break;
+			PUT(PARSER_DEF, LEXTEXT, LEXLINENO);
+			break;
 		case PHP_VARIABLE:
 			if (php_reserved_variable(LEXTEXT, LEXLENG)) {
 				PUT(PARSER_REF_SYM, LEXTEXT, LEXLINENO);
-- 
1.9.1.352.gd393d14


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-04-03 23:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-02  6:40 etags and php classes Luca Ferrari
2014-04-02 16:03 ` Eli Zaretskii
2014-04-03  6:27   ` Luca Ferrari
2014-04-03  9:47     ` Chris Van Dusen
2014-04-03 15:22       ` Luca Ferrari
2014-04-03 18:00         ` cavd
2014-04-03 23:45           ` Leo Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).