Skip to content

Commit

Permalink
[Declarations] Add API extension point for defining grammar declarations
Browse files Browse the repository at this point in the history
 - A plugin can define the declarations for a given grammar using 
"self.declaration_definitions"
 - Existing definitions will be moved to specific language plugins
  • Loading branch information
kattrali committed Sep 27, 2011
1 parent c5ca052 commit 3cc8441
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions plugins/declarations/lib/declarations/parser.rb
Expand Up @@ -142,6 +142,17 @@ class Parser
/\.feature$/ => YAML.load(CUKE_YAML)
}

def self.definitions
@definitions = nil
@definitions ||= begin
definitions = DEFINITIONS.clone
Redcar.plugin_manager.objects_implementing(:declaration_definitions).each do
definitions.merge(object.declaration_definitions)
end
definitions
end
end

attr_reader :tags

def initialize
Expand All @@ -155,7 +166,7 @@ def parse(files)
end

def decls_for_file(path)
DEFINITIONS.each do |fn_re, decls|
Parser.definitions.each do |fn_re, decls|
if path =~ fn_re
return decls
end
Expand Down Expand Up @@ -208,7 +219,6 @@ def process_file(path, &block)
def file(path)
::File.read(path)
end

end
end
end
Expand Down

0 comments on commit 3cc8441

Please sign in to comment.