File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -159,7 +159,9 @@ def convert_class_to_legacy(class_def)
159159 end
160160
161161 # @deprecated Legacy regex-based parser. Will be removed in future version.
162+ # Use `use_token_parser: true` or set TRUBY_NEW_PARSER=1 to use the new parser.
162163 def parse_with_legacy_parser
164+ emit_deprecation_warning
163165 functions = [ ]
164166 type_aliases = [ ]
165167 interfaces = [ ]
@@ -776,5 +778,24 @@ def parse_interface(start_index)
776778
777779 [ { name : interface_name , members : members } , i ]
778780 end
781+
782+ # Emit deprecation warning for legacy parser (once per process)
783+ def emit_deprecation_warning
784+ return if self . class . deprecation_warned?
785+
786+ self . class . mark_deprecation_warned
787+ warn "[DEPRECATION] The regex-based parser is deprecated and will be removed in a future version. " \
788+ "Set TRUBY_NEW_PARSER=1 or use `use_token_parser: true` to opt into the new TokenDeclarationParser."
789+ end
790+
791+ class << self
792+ def deprecation_warned?
793+ @deprecation_warned ||= false
794+ end
795+
796+ def mark_deprecation_warned
797+ @deprecation_warned = true
798+ end
799+ end
779800 end
780801end
You can’t perform that action at this time.
0 commit comments