22require 'errors' # Generated from revapi
33require_relative 'acceptable_errors' # Our list of removals and unimportant errors
44
5- old_name_search = filter = version = nil
5+ new_name_search = old_name_search = filter = version = nil
66
77opts = OptionParser . new do |o |
88 o . banner = 'Usage: #$0 [options]'
2525 o . on ( '-o' , '--old-name {str}' , 'regexp match against old_name' ) do |arg |
2626 old_name_search = Regexp . new ( arg )
2727 end
28+ o . on ( '-n' , '--new-name {str}' , 'regexp match against new_name' ) do |arg |
29+ new_name_search = Regexp . new ( arg )
30+ end
2831end
2932
3033opts . parse! ( ARGV )
3134
32-
35+ # Generic Rules
3336NOT = -> ( f1 ) { -> ( a ) { !f1 . call ( a ) } }
3437AND = -> ( *fns ) { -> ( a ) { fns . all? { |f | f . call ( a ) } } }
3538OR = -> ( *fns ) { -> ( a ) { fns . any? { |f | f . call ( a ) } } }
36-
3739FALSE = -> ( a ) { false }
3840TRUE = -> ( a ) { true }
3941NOOP = TRUE
42+
43+ # FIXME: to make this a generic tool move specific rules and skip list
44+ # to its own require so this script can be used by other Java projects.
4045INVOKER = -> ( a ) { !!a . old_name . match ( /\$ INVOKER/ ) }
4146POPULATOR = -> ( a ) { !!a . old_name . match ( /\$ POPULATOR/ ) }
4247INTERP_ANNO = -> ( a ) { !!a . desc . match ( /org\. jruby\. ir\. Interp/ ) }
6267 'java.annotation.attributeAdded' => NOOP
6368}
6469
70+ SUBSTITUTIONS = {
71+ 'org.jruby.runtime.builtin.IRubyObject' => 'IRubyObject' ,
72+ 'org.jruby.runtime.ThreadContext' => 'ThreadContext' ,
73+ 'org.jruby.Ruby' => 'Ruby' , # This is doing a lot of heavy lifting
74+ 'org.jruby.RubySymbol' => 'RubySymbol' ,
75+ 'java.lang.String' => 'String' ,
76+ 'org.jruby.runtime.Block' => 'Block' ,
77+ 'org.jruby.parser.StaticScope' => 'StaticScope' ,
78+ }
79+
6580class Action
6681 attr_reader :old_name , :new_name , :type , :desc , :categories
6782
@@ -79,6 +94,13 @@ def breaking?
7994 end
8095 end
8196
97+ def sanitize ( str )
98+ SUBSTITUTIONS . each do |pattern , replace |
99+ str . gsub! ( pattern , replace )
100+ end
101+ str
102+ end
103+
82104 def acceptable_key
83105 if removed?
84106 "#{ old_name } |#{ type } "
@@ -92,14 +114,16 @@ def removed?
92114 end
93115
94116 def added?
95- !!type . match ( /java\. (method|class|field)\. [^.]+ [Aa]dded/ )
117+ !!type . match ( /java\. (method|class|field)\. [^.]* [Aa]dded/ )
96118 end
97119
98120 def to_s
99121 str = "type: #{ type } - #{ desc } \n "
100- str += "\n #{ old_name } " if added?
101- str += " ->\n #{ new_name } " if !removed? && !annotation_change?
102- str += "\n #{ categories_to_s } "
122+ if !added?
123+ str += "\n #{ sanitize ( old_name ) } "
124+ end
125+ str += " #{ !added? ? "->" : " " } \n #{ sanitize ( new_name ) } " if !removed? && !annotation_change?
126+ str += "\n #{ categories_to_s } "
103127 str
104128 end
105129
@@ -118,6 +142,7 @@ def to_s
118142 next if filter && type != filter
119143 action = Action . new ( item [ :old ] , item [ :new ] , type , desc , categories )
120144 next if old_name_search && !action . old_name . match? ( old_name_search )
145+ next if new_name_search && !action . new_name . match? ( new_name_search )
121146 fn = SKIPS [ type ] || FALSE
122147 next if fn . call ( action ) || ACCEPTABLE [ action . acceptable_key ]
123148 unless action . breaking?
0 commit comments