Ok, here's the patch.

      
From c6b573fa7813969a3fd363bbbac2d6536e684090 Mon Sep 17 00:00:00 2001
From: Can Koy <can...@ymail.com>
Date: Fri, 5 Mar 2010 22:14:12 +0200
Subject: [PATCH] Improve PHP parser (call tips)

This patch adds call tips for functions in PHP code.
---
 tagmanager/php.c |   31 ++++++++++++++++++++++++++++---
 1 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/tagmanager/php.c b/tagmanager/php.c
index ac67759..6e2f39c 100644
--- a/tagmanager/php.c
+++ b/tagmanager/php.c
@@ -19,7 +19,7 @@
 #include "general.h"  /* must always come first */
 
 #include <string.h>
-
+#include "main.h"
 #include "parse.h"
 #include "read.h"
 #include "vstring.h"
@@ -67,6 +67,7 @@ static kindOption PhpKinds [] = {
 #define ALPHA "[:alpha:]"
 #define ALNUM "[:alnum:]"
 
+static void function_cb(const char *line, const regexMatch *matches, unsigned int count);
 
 static void installPHPRegex (const langType language)
 {
@@ -78,8 +79,9 @@ static void installPHPRegex (const langType language)
 		"\\1", "m,macro,macros", NULL);
 	addTagRegex(language, "^[ \t]*const[ \t]*([" ALPHA "_][" ALNUM "_]*)[ \t]*[=;]",
 		"\\1", "m,macro,macros", NULL);
-	addTagRegex(language, "^[ \t]*((public|protected|private|static)[ \t]+)*function[ \t]+&?[ \t]*([" ALPHA "_][" ALNUM "_]*)",
-		"\\3", "f,function,functions", NULL);
+	addCallbackRegex(language, 
+	"^[ \t]*function[ \t]+&?[ \t]*([" ALPHA "_][" ALNUM "_]*)[[:space:]]*(\\([^)]*\\))",
+			NULL, function_cb);
 	addTagRegex(language, "^[ \t]*(\\$|::\\$|\\$this->)([" ALPHA "_][" ALNUM "_]*)[ \t]*=",
 		"\\2", "v,variable,variables", NULL);
 	addTagRegex(language, "^[ \t]*((var|public|protected|private|static)[ \t]+)+\\$([" ALPHA "_][" ALNUM "_]*)[ \t]*[=;]",
@@ -94,6 +96,29 @@ static void installPHPRegex (const langType language)
 		"\\3", "j,jsfunction,javascript functions", NULL);
 }
 
+static void function_cb(const char *line, const regexMatch *matches, unsigned int count)
+{
+	char *name, *arglist;
+	static char *kindName = "function";
+	tagEntryInfo e;
+	
+	if (count == 3) {
+		
+		name = xMalloc(matches[1].length + 1, char);
+		strncpy(name, line + matches[1].start, matches[1].length);
+		*(name+matches[1].length) = '\x0';
+		arglist = xMalloc(matches[2].length + 1, char);
+		strncpy(arglist, line + matches[2].start, matches[2].length);
+		*(arglist+matches[2].length) = '\x0';
+		
+		initTagEntry (&e, name);
+		e.kind = 'f';
+		e.kindName = kindName;
+		e.extensionFields.arglist = arglist;
+		makeTagEntry (&e);
+	}
+}
+
 /* Create parser definition structure */
 extern parserDefinition* PhpParser (void)
 {
-- 
1.6.3.3

_______________________________________________
Geany-devel mailing list
Geany-devel@uvena.de
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel

Reply via email to