Module: CodeModels::Html::AngularJs
- Defined in:
- lib/codemodels/html/angular_embedding_rules.rb
Class Method Summary collapse
- .attribute_value_pos(code, n) ⇒ Object
- .instances_of_escaped_text(code, content, bi) ⇒ Object
- .parser_considering_angular_embedded_code ⇒ Object
Class Method Details
.attribute_value_pos(code, n) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/codemodels/html/angular_embedding_rules.rb', line 13 def self.attribute_value_pos(code,n) bi = n.java_method(:getValueSegment).call.begin ei = n.java_method(:getValueSegment).call.end-1 #puts "ATTVALUE<<#{code[bi...ei]}>> #{SourcePosition.from_code_indexes(code,bi,ei)} @@@#{code}@@@" SourcePosition.from_code_indexes(code,bi,ei) end |
.instances_of_escaped_text(code, content, bi) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/codemodels/html/angular_embedding_rules.rb', line 61 def self.instances_of_escaped_text(code,content,bi) # puts "content '#{content}'" # puts "content from code '#{code[bi,content.length]}'" matchdata_open = content.match('{{') return [] unless matchdata_open p_start = matchdata_open.begin(0) # puts "after open '#{content[p_start..-1]}'" matchdata_end = content[p_start..-1].match('}}') return [] unless matchdata_end p_end = matchdata_end.begin(0) if (p_end+3)==content.length remaining_content = '' else remaining_content = content[(p_end+2)..-1] end # puts "remaining_content: '#{remaining_content}'" start_in_content = p_start+2 end_in_content = p_start+p_end-1 # puts "BLOCK IN CONTENT '#{content[start_in_content..end_in_content]}'" block = SourcePosition.from_code_indexes(code,bi+start_in_content,bi+end_in_content) # puts "BLOCK IN CODE '#{code[(bi+start_in_content)..(bi+end_in_content)]}'" [block].concat(instances_of_escaped_text(code,remaining_content,bi+end_in_content+3)) end |
.parser_considering_angular_embedded_code ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/codemodels/html/angular_embedding_rules.rb', line 20 def self. js_parser = CodeModels::Js::DefaultParser js_expression_parser = CodeModels::Js::ExpressionParser p = Parser.new ng_attribute_base_names = 'app','repeat','show','class','model','click','include' ng_attribute_names = [] ng_attribute_base_names.each do |n| ng_attribute_names<<"ng:#{n}" ng_attribute_names<<"ng-#{n}" end p.(Java::NetHtmlparserJericho::Attribute,js_expression_parser) do |n,code| ng_attribute_names.include?(n.name) ? attribute_value_pos(code,n) : nil end p.(Java::NetHtmlparserJericho::Element,js_expression_parser) do |n,code| res = [] if n.name!='script' n.text_blocks(code).each do |tb| tb_start = tb.source.position.begin_point.to_absolute_index(code) res.concat(instances_of_escaped_text(code,tb.value,tb_start)) end end res end p.(Java::NetHtmlparserJericho::Attribute,js_expression_parser) do |n,code| content = n.value if n.getValueSegment bi = n.getValueSegment.begin instances_of_escaped_text(code,content,bi) else [] end end p end |