Sha256: 9067f1473fe2706f01ad6d4693eb72923a67a5dfabb508dc3e3084ed564e76b3
Contents?: true
Size: 1022 Bytes
Versions: 18
Compression:
Stored size: 1022 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
18 entries across 18 versions & 1 rubygems