Renames the public top-level type from to to: its declaration, its
constructors and every other reference in the file. Names inside comments,
string literals, char literals and text blocks are left alone, as are
longer names such as MainHelper and qualified names such as Other.Main.
The code is returned unchanged when from or to is not a valid class
name, when both are equal, or when the file declares no public top-level
type called from.
Parameters
code: string
Java source
from: string
Current public type name
to: string
New public type name
Returns string
The renamed source
Example
renamePublicClass('public class Main { Main() {} }', 'Main', 'Sol'); // 'public class Sol { Sol() {} }'
Renames the public top-level type
fromtoto: its declaration, its constructors and every other reference in the file. Names inside comments, string literals, char literals and text blocks are left alone, as are longer names such asMainHelperand qualified names such asOther.Main.The code is returned unchanged when
fromortois not a valid class name, when both are equal, or when the file declares no public top-level type calledfrom.