Sha256: 5391ebce005215f15f133a44f14ab33f0c85431e873804d7ceeff518683f76c1
Contents?: true
Size: 1021 Bytes
Versions: 11
Compression:
Stored size: 1021 Bytes
Contents
# typed: strict # frozen_string_literal: true module RBI module Rewriters class Deannotate < Visitor extend T::Sig sig { params(annotation: String).void } def initialize(annotation) super() @annotation = annotation end sig { override.params(node: T.nilable(Node)).void } def visit(node) case node when Scope, Const, Attr, Method, TStructField, TypeMember deannotate_node(node) end visit_all(node.nodes) if node.is_a?(Tree) end private sig { params(node: NodeWithComments).void } def deannotate_node(node) return unless node.annotations.one?(@annotation) node.comments.reject! do |comment| comment.text == "@#{@annotation}" end end end end class Tree extend T::Sig sig { params(annotation: String).void } def deannotate!(annotation) visitor = Rewriters::Deannotate.new(annotation) visitor.visit(self) end end end
Version data entries
11 entries across 11 versions & 2 rubygems