[SVN] PHP Namespace Support

Andrew Hanna andrew at sevenlight.com
Thu Oct 2 18:20:21 UTC 2008


I have modified the Interface and Class declarations in the PHP  
language definition to add support for namespaces for PHP 5.3.0.  This  
highlights each individual namespace "segment" as a class name.  It  
works on implements/extends as well.

Here's a screenshot of what it looks like in action:



And here's the code:

		{	name = 'meta.interface.php';
			begin = '^\s*(interface)\s+([a-zA-Z0-9_]+)\s*';
			end = '$';
			beginCaptures = {
				1 = { name = 'storage.type.interface.php'; };
				2 = { name = 'entity.name.interface.declaration.php'; };
			};
			patterns = (
				{	name = 'meta.interface.extends.php';
				    begin = '(extends)\s*';
				    end = '$';
				    beginCaptures = {
				        1 = { name = 'storage.modifier.extends.php'; };
				    };
				    patterns = (
				        {   name = 'entity.name.interface.extends.php';
				            match = '[a-zA-Z0-9_]+';
				        },
				    );
				},
			);
		},
		{	name = 'meta.class.php';
			begin = '^\s*(abstract)?\s*(class)\s+([a-zA-Z0-9_]+)\s*';
			end = '$';
			beginCaptures = {
				1 = { name = 'storage.modifier.abstract.php'; };
				2 = { name = 'storage.type.class.php'; };
				3 = { name = 'entity.name.class.declaration.php'; };
			};
			patterns = (
				{	name = 'meta.class.php';
				    begin = '(extends)\s+';
				    end = '\s+';
					beginCaptures = {
						1 = { name = 'storage.modifier.extends.php'; };
					};
					patterns = (
					    {   name = 'entity.name.class.inherited.php';
					        match = '[a-zA-Z0-9_]+';
					    },
					);
				},
				{	begin = '(implements)\s+';
					end = '(?=\s*extends\s*)|$';
					beginCaptures = {
						1 = { name = 'storage.modifier.implements.php'; };
						2 = { name = 'entity.name.class.implements.php'; };
					};
					patterns = (
						{	begin = '';
						    end = ',|\s+';
						    patterns = (
						        {   name = 'entity.name.class.implements.php';
						            match = '([a-zA-Z0-9_]+)';
						        },
						    );
						},
					);
				},
			);
		},
		{	name = 'meta.namespace.php';
			begin = '^\s*(namespace)\s+([a-zA-Z0-9_]+)\s*';
			end = ';|$';
			beginCaptures = {
				1 = { name = 'storage.type.namespace.php'; };
				2 = { name = 'entity.name.namespace.declaration.php'; };
			};
			patterns = (
				{	name = 'entity.name.namespace.declaration.php';
					match = '[a-zA-Z0-9_]+';
				},
			);
		},

Hope it can be integrated into future releases.

-Andrew
– –

Andrew Hanna
Sevenlight Inc.
http://www.sevenlight.com/
ph 403.770.9544


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate-dev/attachments/20081002/d40a9998/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Picture 2.png
Type: image/png
Size: 28661 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate-dev/attachments/20081002/d40a9998/attachment.png>


More information about the textmate-dev mailing list