Skip to content

Commit 1c97bf7

Browse files
committed
Remove currently deprecated functionality
Mostly in the node extension. The method for marking something as deprecated is currently unused but seems fine leave as is.
1 parent 93542e6 commit 1c97bf7

6 files changed

Lines changed: 6 additions & 601 deletions

File tree

lib/prism/node_ext.rb

Lines changed: 0 additions & 259 deletions
Original file line numberDiff line numberDiff line change
@@ -176,20 +176,6 @@ class RationalNode < Node
176176
def value
177177
Rational(numerator, denominator)
178178
end
179-
180-
# Returns the value of the node as an IntegerNode or a FloatNode. This
181-
# method is deprecated in favor of #value or #numerator/#denominator.
182-
#--
183-
#: () -> (IntegerNode | FloatNode)
184-
def numeric
185-
deprecated("value", "numerator", "denominator")
186-
187-
if denominator == 1
188-
IntegerNode.new(source, -1, location.chop, flags, numerator)
189-
else
190-
FloatNode.new(source, -1, location.chop, 0, numerator.to_f / denominator)
191-
end
192-
end
193179
end
194180

195181
class ConstantReadNode < Node
@@ -271,21 +257,6 @@ def full_name_parts
271257
def full_name
272258
full_name_parts.join("::")
273259
end
274-
275-
# Previously, we had a child node on this class that contained either a
276-
# constant read or a missing node. To not cause a breaking change, we
277-
# continue to supply that API.
278-
#--
279-
#: () -> (ConstantReadNode | MissingNode)
280-
def child
281-
deprecated("name", "name_loc")
282-
283-
if (name = self.name)
284-
ConstantReadNode.new(source, -1, name_loc, 0, name)
285-
else
286-
MissingNode.new(source, -1, location, 0)
287-
end
288-
end
289260
end
290261

291262
class ConstantPathTargetNode < Node
@@ -318,21 +289,6 @@ def full_name_parts
318289
def full_name
319290
full_name_parts.join("::")
320291
end
321-
322-
# Previously, we had a child node on this class that contained either a
323-
# constant read or a missing node. To not cause a breaking change, we
324-
# continue to supply that API.
325-
#--
326-
#: () -> (ConstantReadNode | MissingNode)
327-
def child
328-
deprecated("name", "name_loc")
329-
330-
if (name = self.name)
331-
ConstantReadNode.new(source, -1, name_loc, 0, name)
332-
else
333-
MissingNode.new(source, -1, location, 0)
334-
end
335-
end
336292
end
337293

338294
class ConstantTargetNode < Node
@@ -432,219 +388,4 @@ def full_message_loc
432388
attribute_write? ? message_loc&.adjoin("=") : message_loc
433389
end
434390
end
435-
436-
class CallOperatorWriteNode < Node
437-
# Returns the binary operator used to modify the receiver. This method is
438-
# deprecated in favor of #binary_operator.
439-
#--
440-
#: () -> Symbol
441-
def operator
442-
deprecated("binary_operator")
443-
binary_operator
444-
end
445-
446-
# Returns the location of the binary operator used to modify the receiver.
447-
# This method is deprecated in favor of #binary_operator_loc.
448-
#--
449-
#: () -> Location
450-
def operator_loc
451-
deprecated("binary_operator_loc")
452-
binary_operator_loc
453-
end
454-
end
455-
456-
class ClassVariableOperatorWriteNode < Node
457-
# Returns the binary operator used to modify the receiver. This method is
458-
# deprecated in favor of #binary_operator.
459-
#--
460-
#: () -> Symbol
461-
def operator
462-
deprecated("binary_operator")
463-
binary_operator
464-
end
465-
466-
# Returns the location of the binary operator used to modify the receiver.
467-
# This method is deprecated in favor of #binary_operator_loc.
468-
#--
469-
#: () -> Location
470-
def operator_loc
471-
deprecated("binary_operator_loc")
472-
binary_operator_loc
473-
end
474-
end
475-
476-
class ConstantOperatorWriteNode < Node
477-
# Returns the binary operator used to modify the receiver. This method is
478-
# deprecated in favor of #binary_operator.
479-
#--
480-
#: () -> Symbol
481-
def operator
482-
deprecated("binary_operator")
483-
binary_operator
484-
end
485-
486-
# Returns the location of the binary operator used to modify the receiver.
487-
# This method is deprecated in favor of #binary_operator_loc.
488-
#--
489-
#: () -> Location
490-
def operator_loc
491-
deprecated("binary_operator_loc")
492-
binary_operator_loc
493-
end
494-
end
495-
496-
class ConstantPathOperatorWriteNode < Node
497-
# Returns the binary operator used to modify the receiver. This method is
498-
# deprecated in favor of #binary_operator.
499-
#--
500-
#: () -> Symbol
501-
def operator
502-
deprecated("binary_operator")
503-
binary_operator
504-
end
505-
506-
# Returns the location of the binary operator used to modify the receiver.
507-
# This method is deprecated in favor of #binary_operator_loc.
508-
#--
509-
#: () -> Location
510-
def operator_loc
511-
deprecated("binary_operator_loc")
512-
binary_operator_loc
513-
end
514-
end
515-
516-
class GlobalVariableOperatorWriteNode < Node
517-
# Returns the binary operator used to modify the receiver. This method is
518-
# deprecated in favor of #binary_operator.
519-
#--
520-
#: () -> Symbol
521-
def operator
522-
deprecated("binary_operator")
523-
binary_operator
524-
end
525-
526-
# Returns the location of the binary operator used to modify the receiver.
527-
# This method is deprecated in favor of #binary_operator_loc.
528-
#--
529-
#: () -> Location
530-
def operator_loc
531-
deprecated("binary_operator_loc")
532-
binary_operator_loc
533-
end
534-
end
535-
536-
class IndexOperatorWriteNode < Node
537-
# Returns the binary operator used to modify the receiver. This method is
538-
# deprecated in favor of #binary_operator.
539-
#--
540-
#: () -> Symbol
541-
def operator
542-
deprecated("binary_operator")
543-
binary_operator
544-
end
545-
546-
# Returns the location of the binary operator used to modify the receiver.
547-
# This method is deprecated in favor of #binary_operator_loc.
548-
#--
549-
#: () -> Location
550-
def operator_loc
551-
deprecated("binary_operator_loc")
552-
binary_operator_loc
553-
end
554-
end
555-
556-
class InstanceVariableOperatorWriteNode < Node
557-
# Returns the binary operator used to modify the receiver. This method is
558-
# deprecated in favor of #binary_operator.
559-
#--
560-
#: () -> Symbol
561-
def operator
562-
deprecated("binary_operator")
563-
binary_operator
564-
end
565-
566-
# Returns the location of the binary operator used to modify the receiver.
567-
# This method is deprecated in favor of #binary_operator_loc.
568-
#--
569-
#: () -> Location
570-
def operator_loc
571-
deprecated("binary_operator_loc")
572-
binary_operator_loc
573-
end
574-
end
575-
576-
class LocalVariableOperatorWriteNode < Node
577-
# Returns the binary operator used to modify the receiver. This method is
578-
# deprecated in favor of #binary_operator.
579-
#--
580-
#: () -> Symbol
581-
def operator
582-
deprecated("binary_operator")
583-
binary_operator
584-
end
585-
586-
# Returns the location of the binary operator used to modify the receiver.
587-
# This method is deprecated in favor of #binary_operator_loc.
588-
#--
589-
#: () -> Location
590-
def operator_loc
591-
deprecated("binary_operator_loc")
592-
binary_operator_loc
593-
end
594-
end
595-
596-
class CaseMatchNode < Node
597-
# Returns the else clause of the case match node. This method is deprecated
598-
# in favor of #else_clause.
599-
#--
600-
#: () -> ElseNode?
601-
def consequent
602-
deprecated("else_clause")
603-
else_clause
604-
end
605-
end
606-
607-
class CaseNode < Node
608-
# Returns the else clause of the case node. This method is deprecated in
609-
# favor of #else_clause.
610-
#--
611-
#: () -> ElseNode?
612-
def consequent
613-
deprecated("else_clause")
614-
else_clause
615-
end
616-
end
617-
618-
class IfNode < Node
619-
# Returns the subsequent if/elsif/else clause of the if node. This method is
620-
# deprecated in favor of #subsequent.
621-
#--
622-
#: () -> (IfNode | ElseNode)?
623-
def consequent
624-
deprecated("subsequent")
625-
subsequent
626-
end
627-
end
628-
629-
class RescueNode < Node
630-
# Returns the subsequent rescue clause of the rescue node. This method is
631-
# deprecated in favor of #subsequent.
632-
#--
633-
#: () -> RescueNode?
634-
def consequent
635-
deprecated("subsequent")
636-
subsequent
637-
end
638-
end
639-
640-
class UnlessNode < Node
641-
# Returns the else clause of the unless node. This method is deprecated in
642-
# favor of #else_clause.
643-
#--
644-
#: () -> ElseNode?
645-
def consequent
646-
deprecated("else_clause")
647-
else_clause
648-
end
649-
end
650391
end

lib/prism/translation/parser.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ def initialize(message, level, reason, location)
7373
#
7474
def initialize(builder = Prism::Translation::Parser::Builder.new, parser: Prism)
7575
if !builder.is_a?(Prism::Translation::Parser::Builder)
76-
warn(<<~MSG, uplevel: 1, category: :deprecated)
77-
[deprecation]: The builder passed to `Prism::Translation::Parser.new` is not a \
78-
`Prism::Translation::Parser::Builder` subclass. This will raise in the next major version.
76+
raise TypeError, <<~MSG
77+
Expected a `Prism::Translation::Parser::Builder` as the first positional argument, \
78+
got `#{builder.class}`
7979
MSG
8080
end
8181
@parser = parser

lib/prism/translation/parser/compiler.rb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,17 +1178,7 @@ def visit_it_local_variable_read_node(node)
11781178
# -> { it }
11791179
# ^^^^^^^^^
11801180
def visit_it_parameters_node(node)
1181-
# FIXME: The builder _should_ always be a subclass of the prism builder.
1182-
# Currently RuboCop passes in its own builder that always inherits from the
1183-
# parser builder (which is lacking the `itarg` method). Once rubocop-ast
1184-
# opts in to use the custom prism builder a warning can be emitted when
1185-
# it is not the expected class, and eventually raise.
1186-
# https://github.com/rubocop/rubocop-ast/pull/354
1187-
if builder.is_a?(Translation::Parser::Builder)
1188-
builder.itarg
1189-
else
1190-
builder.args(nil, [], nil, false)
1191-
end
1181+
builder.itarg
11921182
end
11931183

11941184
# foo(bar: baz)

0 commit comments

Comments
 (0)