Permalink
Browse files

Match built-in classes more intelligently

  • Loading branch information...
1 parent b4190a6 commit 9f67c11a0e9b200f5b516e55b1ffccc37577de89 @joshvarner joshvarner committed with Josh Varner Dec 6, 2010
Showing with 212 additions and 89 deletions.
  1. +14 −2 Support/generate/generate.rb
  2. +198 −87 Syntaxes/PHP.plist
@@ -56,14 +56,23 @@ def process_list(list)
end
end
-def pattern_for(name, list, constructors = false)
+def pattern_for(name, list)
return unless list = process_list(list)
{
'name' => name,
'match' => "(?i)\\b#{ list }\\b"
}
end
+def pattern_for_classes(name, list)
+ return unless list = process_list(list)
+ {
+ 'name' => name,
+ 'match' => "(?i)(\\\\)?\\b#{ list }\\b",
+ 'captures' => { '1' => {'name' => 'punctuation.separator.inheritance.php'} }
+ }
+end
+
GrammarPath = File.dirname(__FILE__) + '/../../Syntaxes/PHP.plist'
grammar = OSX::PropertyList.load(File.read(GrammarPath))
@@ -74,9 +83,12 @@ def pattern_for(name, list, constructors = false)
patterns << pattern_for('support.function.' + section + '.php', funcs)
end
patterns << pattern_for('support.function.alias.php', %w{is_int is_integer})
-patterns << pattern_for('support.class.builtin.php', classes, true)
+
+class_patterns = [pattern_for_classes('support.class.builtin.php', classes)]
grammar['repository']['support'] = { 'patterns' => patterns }
+grammar['repository']['class-builtin'] = { 'patterns' => class_patterns }
+
File.open(GrammarPath, 'w') do |file|
file << grammar.to_plist
end
Oops, something went wrong.

0 comments on commit 9f67c11

Please sign in to comment.