Class: Ast::Crispr::OwnerSelector
- Inherits:
-
Object
- Object
- Ast::Crispr::OwnerSelector
- Defined in:
- lib/ast/crispr.rb
Instance Attribute Summary collapse
-
#anchor ⇒ Object
readonly
Returns the value of attribute anchor.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#locate ⇒ Object
readonly
Returns the value of attribute locate.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#owned_span ⇒ Object
readonly
Returns the value of attribute owned_span.
Instance Method Summary collapse
- #comment_region ⇒ Object
- #include_trailing_gap? ⇒ Boolean
-
#initialize(id:, locate:, owned_span: nil, anchor: nil, limit: nil, metadata: {}, **options) ⇒ OwnerSelector
constructor
A new instance of OwnerSelector.
- #locate_matches(context) ⇒ Object
- #owner_scope ⇒ Object
- #resolve_anchor(context, match = nil) ⇒ Object
- #resolve_owned_match(context, match) ⇒ Object
- #selection_intent ⇒ Object
- #selection_profile(context) ⇒ Object
- #selector_kind ⇒ Object
- #structure_profile(context) ⇒ Object
Constructor Details
#initialize(id:, locate:, owned_span: nil, anchor: nil, limit: nil, metadata: {}, **options) ⇒ OwnerSelector
Returns a new instance of OwnerSelector.
777 778 779 780 781 782 783 784 |
# File 'lib/ast/crispr.rb', line 777 def initialize(id:, locate:, owned_span: nil, anchor: nil, limit: nil, metadata: {}, **) @id = id @locate = locate @owned_span = owned_span @anchor = anchor @limit = Limit.coerce(limit, default: { exactly: 1 }) @metadata = .merge() end |
Instance Attribute Details
#anchor ⇒ Object (readonly)
Returns the value of attribute anchor.
775 776 777 |
# File 'lib/ast/crispr.rb', line 775 def anchor @anchor end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
775 776 777 |
# File 'lib/ast/crispr.rb', line 775 def id @id end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
775 776 777 |
# File 'lib/ast/crispr.rb', line 775 def limit @limit end |
#locate ⇒ Object (readonly)
Returns the value of attribute locate.
775 776 777 |
# File 'lib/ast/crispr.rb', line 775 def locate @locate end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
775 776 777 |
# File 'lib/ast/crispr.rb', line 775 def @metadata end |
#owned_span ⇒ Object (readonly)
Returns the value of attribute owned_span.
775 776 777 |
# File 'lib/ast/crispr.rb', line 775 def owned_span @owned_span end |
Instance Method Details
#comment_region ⇒ Object
817 818 819 |
# File 'lib/ast/crispr.rb', line 817 def comment_region [:comment_region]&.to_sym end |
#include_trailing_gap? ⇒ Boolean
821 822 823 |
# File 'lib/ast/crispr.rb', line 821 def include_trailing_gap? [:include_trailing_gap] ? true : false end |
#locate_matches(context) ⇒ Object
786 787 788 |
# File 'lib/ast/crispr.rb', line 786 def locate_matches(context) Array(invoke(locate, context)).flatten.compact.map { |candidate| coerce_match(candidate) } end |
#owner_scope ⇒ Object
801 802 803 |
# File 'lib/ast/crispr.rb', line 801 def owner_scope .fetch(:owner_scope, :shared_default) end |
#resolve_anchor(context, match = nil) ⇒ Object
795 796 797 798 799 |
# File 'lib/ast/crispr.rb', line 795 def resolve_anchor(context, match = nil) return unless anchor invoke(anchor, context, match) end |
#resolve_owned_match(context, match) ⇒ Object
790 791 792 793 |
# File 'lib/ast/crispr.rb', line 790 def resolve_owned_match(context, match) candidate = owned_span ? invoke(owned_span, context, match) : match coerce_match(candidate).with_target(self) end |
#selection_intent ⇒ Object
813 814 815 |
# File 'lib/ast/crispr.rb', line 813 def selection_intent [:selection_intent]&.to_sym end |
#selection_profile(context) ⇒ Object
825 826 827 828 829 830 831 832 833 834 835 |
# File 'lib/ast/crispr.rb', line 825 def selection_profile(context) SelectionProfile.new( owner_scope: owner_scope, selector_kind: selector_kind, selection_intent: selection_intent, comment_region: comment_region, include_trailing_gap: include_trailing_gap?, structure_profile: structure_profile(context), metadata: ) end |
#selector_kind ⇒ Object
809 810 811 |
# File 'lib/ast/crispr.rb', line 809 def selector_kind [:selector_kind]&.to_sym end |
#structure_profile(context) ⇒ Object
805 806 807 |
# File 'lib/ast/crispr.rb', line 805 def structure_profile(context) context.structure_profile(owner_scope: owner_scope) end |