# Path: androguard/gui/helpers.py
# def classdot2class(path):
#     """ Convert a path such as 'android.support.v4.app.ActivityCompat'
#         into a string 'Landroid/support/v4/app/ActivityCompat'
#         so we can change name of a class by d.CLASS_Landroid_support_v4_app_ActivityCompat.set_name(new_name)
#     """
#     if path[0] == 'L' and path[-1] == ';':
#         log.debug("WARNING: %s already a Lclass; name" % path)
#         return path
# 
#     new_name = 'L' + path.replace('.', '/') + ';'
#     return new_name
# 
# def proto2methodprotofunc(proto):
#     """Convert a prototype such as 'Ljava/lang/String;'
#        into a string 'Ljava_lang_String" so we can append that to the
#        'METHOD_myMethod' if its export python name contains the prototype
#     """
#     return proto.replace(' ', '').replace('(', '').replace('[', '').replace(
#         ')', '').replace('/', '_').replace(';', '')
# 
# Path: androguard/gui/renamewindow.py
# class RenameDialog(QtWidgets.QDialog):
#     """
#         parent: SourceWindow that started the new XrefDialog
#     """
# 
#     def __init__(self, parent=None, win=None, element="", info=()):
#         super().__init__(parent)
# 
#         self.sourceWin = parent
#         self.info = info
#         self.element = element
#         title = "Rename: " + element
#         self.setWindowTitle(title)
# 
#         layout = QtWidgets.QGridLayout()
#         question = QtWidgets.QLabel("Please enter new name:")
#         layout.addWidget(question, 0, 0)
#         self.lineEdit = QtWidgets.QLineEdit()
#         layout.addWidget(self.lineEdit, 0, 1)
#         self.buttonOK = QtWidgets.QPushButton("OK", self)
#         layout.addWidget(self.buttonOK, 1, 1)
#         self.buttonCancel = QtWidgets.QPushButton("Cancel", self)
#         layout.addWidget(self.buttonCancel, 1, 0)
# 
#         self.lineEdit.setText(self.element)
# 
#         self.setLayout(layout)
# 
#         self.buttonCancel.clicked.connect(self.cancelClicked)
#         self.buttonOK.clicked.connect(self.okClicked)
# 
#     def cancelClicked(self):
#         self.close()
# 
#     def okClicked(self):
#         self.sourceWin.renameElement(self.element, self.lineEdit.text(),
#                                      self.info)
#         self.close()


import pyperclip
import logging
from PyQt5 import QtCore, QtGui, QtWidgets
from pygments.formatters.html import HtmlFormatter
from pygments.lexers import JavaLexer
from pygments.style import Style
from pygments.token import Token, Comment, Name, Keyword, Generic, Number, Operator, String
from androguard.gui.helpers import classdot2class, proto2methodprotofunc
from androguard.gui.renamewindow import RenameDialog
from androguard.gui.xrefwindow import XrefDialogMethod, XrefDialogField
            log.debug("Found: package={}, class={}".format(package_, class_))
            type_ = "CLASS"
        elif t[0] == 'NAME_FIELD':
            field_item = t[3]
            type_ = "FIELD"
        else:
            self.mainwin.showStatus(
                "Rename not available. Info found: '%s' but object not supported."
                % t[0])
            return

        # Do the actual renaming
        if type_ == "METHOD":
            if self.method_name_exist(newname):
                self.mainwin.showStatus("Method name already exist")
                return

            method_class_name = self.current_class.get_name()
            method_name = method_
            method_proto = proto_
            current_analysis = self.session.get_analysis(self.current_class)

            method_item = current_analysis.get_method_by_name(
                method_class_name, method_name, method_proto)
            if not method_item:
                self.mainwin.showStatus("Impossible to find the method")
                return

            method_item.set_name(str(newname))  # unicode to ascii
        elif type_ == "CLASS":

# Path: androguard/gui/helpers.py
# def classdot2class(path):
#     """ Convert a path such as 'android.support.v4.app.ActivityCompat'
#         into a string 'Landroid/support/v4/app/ActivityCompat'
#         so we can change name of a class by d.CLASS_Landroid_support_v4_app_ActivityCompat.set_name(new_name)
#     """
#     if path[0] == 'L' and path[-1] == ';':
#         log.debug("WARNING: %s already a Lclass; name" % path)
#         return path
# 
#     new_name = 'L' + path.replace('.', '/') + ';'
#     return new_name
# 
# def proto2methodprotofunc(proto):
#     """Convert a prototype such as 'Ljava/lang/String;'
#        into a string 'Ljava_lang_String" so we can append that to the
#        'METHOD_myMethod' if its export python name contains the prototype
#     """
#     return proto.replace(' ', '').replace('(', '').replace('[', '').replace(
#         ')', '').replace('/', '_').replace(';', '')
# 
# Path: androguard/gui/renamewindow.py
# class RenameDialog(QtWidgets.QDialog):
#     """
#         parent: SourceWindow that started the new XrefDialog
#     """
# 
#     def __init__(self, parent=None, win=None, element="", info=()):
#         super().__init__(parent)
# 
#         self.sourceWin = parent
#         self.info = info
#         self.element = element
#         title = "Rename: " + element
#         self.setWindowTitle(title)
# 
#         layout = QtWidgets.QGridLayout()
#         question = QtWidgets.QLabel("Please enter new name:")
#         layout.addWidget(question, 0, 0)
#         self.lineEdit = QtWidgets.QLineEdit()
#         layout.addWidget(self.lineEdit, 0, 1)
#         self.buttonOK = QtWidgets.QPushButton("OK", self)
#         layout.addWidget(self.buttonOK, 1, 1)
#         self.buttonCancel = QtWidgets.QPushButton("Cancel", self)
#         layout.addWidget(self.buttonCancel, 1, 0)
# 
#         self.lineEdit.setText(self.element)
# 
#         self.setLayout(layout)
# 
#         self.buttonCancel.clicked.connect(self.cancelClicked)
#         self.buttonOK.clicked.connect(self.okClicked)
# 
#     def cancelClicked(self):
#         self.close()
# 
#     def okClicked(self):
#         self.sourceWin.renameElement(self.element, self.lineEdit.text(),
#                                      self.info)
#         self.close()


# Path: androguard/gui/sourcewindow.py
import pyperclip
import logging
from PyQt5 import QtCore, QtGui, QtWidgets
from pygments.formatters.html import HtmlFormatter
from pygments.lexers import JavaLexer
from pygments.style import Style
from pygments.token import Token, Comment, Name, Keyword, Generic, Number, Operator, String
from androguard.gui.helpers import classdot2class, proto2methodprotofunc
from androguard.gui.renamewindow import RenameDialog
from androguard.gui.xrefwindow import XrefDialogMethod, XrefDialogField

            log.debug("Found: package={}, class={}".format(package_, class_))
            type_ = "CLASS"
        elif t[0] == 'NAME_FIELD':
            field_item = t[3]
            type_ = "FIELD"
        else:
            self.mainwin.showStatus(
                "Rename not available. Info found: '%s' but object not supported."
                % t[0])
            return

        # Do the actual renaming
        if type_ == "METHOD":
            if self.method_name_exist(newname):
                self.mainwin.showStatus("Method name already exist")
                return

            method_class_name = self.current_class.get_name()
            method_name = method_
            method_proto = proto_
            current_analysis = self.session.get_analysis(self.current_class)

            method_item = current_analysis.get_method_by_name(
                method_class_name, method_name, method_proto)
            if not method_item:
                self.mainwin.showStatus("Impossible to find the method")
                return

            method_item.set_name(str(newname))  # unicode to ascii
        elif type_ == "CLASS":

            newname_class = classdot2class(package_ + '.' + newname)