Polyman Documentation - v3.1.0
    Preparing search index...

    Function renamePublicClass

    • 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

      renamePublicClass('public class Main { Main() {} }', 'Main', 'Sol');
      // 'public class Sol { Sol() {} }'