# Path: ma/checkers/checker.py
# class Checker(object):
#     """ Abstract class Checker """
#     __metaclass__ = abc.ABCMeta
# 
#     def check_node(self, node):
#         """ Check node from AST and return if it is a migration issue """
#         return False
# 
#     def check_include(self, include_name):
#         """ Check include from AST and return if it is a migration issue """
#         return False
# 
#     def check_file(self, file_name):
#         """ Check issues into file and return a list of lists, containing the
#         problem name and line number """
#         return []
# 
#     def get_solution(self, problem):
#         """ Get solution for the problem using the node from AST or the raw
#         node from file """
#         return ""
# 
#     @abc.abstractmethod
#     def get_pattern_hint(self):
#         """Return the pattern that should be used to get the
#         problematics files"""
#         raise NotImplementedError('users must define __get_pattern_hint__ to\
#         use this base class')
# 
#     @abc.abstractmethod
#     def get_problem_msg(self):
#         """Return the problem message of the checker"""
#         raise NotImplementedError('users must define __get_problem_msg__ to \
#         use this base class')
# 
#     @abc.abstractmethod
#     def get_problem_type(self):
#         """Return the problem type of the checker"""
#         raise NotImplementedError('users must define __get_problem_type__ to \
#         use this base class')
# 
# Path: ma/core.py
# X86_PATTERNS = ["amd64", "AMD64", "[xX]86", "[xX]86_64", "[iI]386", "[iI]486",
#                 "[iI]686"]
# PPC_PATTERNS = ["PPC", "ppc", "power[pP][cC]", "POWER[pP][cC]"]
# def get_supported_checkers():
# def get_supported_extensions():
# def execute(command):
# def execute_stdout(command):
# def cmdexists(command):
# def get_timestamp():
# def get_files(location, hint=''):
# def get_file_content(file_name, offset, length):
# def get_raw_node(node):
# def get_includes(file_path):
# def get_ifdefs(file_path):
# def get_ifdef_regex(arch, separator):


import re
import os
from clang.cindex import CursorKind
from clang.cindex import TypeKind
from ma.checkers.checker import Checker
from ma import core
        info = ""
        if kind == CursorKind.BINARY_OPERATOR or type_kind == TypeKind.TYPEDEF:
            node = self._get_var_declaration(node, node)
            location = node.location
            line = location.line
            file_name = os.path.basename(str(location.file))
            info = "    (file: {0} | line: {1})".format(file_name, line)

        raw_node = core.get_raw_node(node)
        char_regex = "\\bchar\\b"
        solution = ""
        if (re.search(char_regex, raw_node) and
                not re.search("typedef.*(struct|union)", raw_node)):
            solution = re.sub(char_regex, "signed char", raw_node)
            solution += info
        else:
            solution = self.default_solution
        return solution

    def _get_var_declaration(self, node, definition):
        """ Get where a variable is defined and return the corresponding
        node """
        aux_node = None
        if node.type.kind == TypeKind.TYPEDEF:
            aux_node = node.type.get_declaration()
        elif node.kind == CursorKind.DECL_REF_EXPR:
            aux_node = node.get_definition()

        if aux_node:
            node = aux_node

# Path: ma/checkers/checker.py
# class Checker(object):
#     """ Abstract class Checker """
#     __metaclass__ = abc.ABCMeta
# 
#     def check_node(self, node):
#         """ Check node from AST and return if it is a migration issue """
#         return False
# 
#     def check_include(self, include_name):
#         """ Check include from AST and return if it is a migration issue """
#         return False
# 
#     def check_file(self, file_name):
#         """ Check issues into file and return a list of lists, containing the
#         problem name and line number """
#         return []
# 
#     def get_solution(self, problem):
#         """ Get solution for the problem using the node from AST or the raw
#         node from file """
#         return ""
# 
#     @abc.abstractmethod
#     def get_pattern_hint(self):
#         """Return the pattern that should be used to get the
#         problematics files"""
#         raise NotImplementedError('users must define __get_pattern_hint__ to\
#         use this base class')
# 
#     @abc.abstractmethod
#     def get_problem_msg(self):
#         """Return the problem message of the checker"""
#         raise NotImplementedError('users must define __get_problem_msg__ to \
#         use this base class')
# 
#     @abc.abstractmethod
#     def get_problem_type(self):
#         """Return the problem type of the checker"""
#         raise NotImplementedError('users must define __get_problem_type__ to \
#         use this base class')
# 
# Path: ma/core.py
# X86_PATTERNS = ["amd64", "AMD64", "[xX]86", "[xX]86_64", "[iI]386", "[iI]486",
#                 "[iI]686"]
# PPC_PATTERNS = ["PPC", "ppc", "power[pP][cC]", "POWER[pP][cC]"]
# def get_supported_checkers():
# def get_supported_extensions():
# def execute(command):
# def execute_stdout(command):
# def cmdexists(command):
# def get_timestamp():
# def get_files(location, hint=''):
# def get_file_content(file_name, offset, length):
# def get_raw_node(node):
# def get_includes(file_path):
# def get_ifdefs(file_path):
# def get_ifdef_regex(arch, separator):


# Path: ma/checkers/char_checker.py
import re
import os
from clang.cindex import CursorKind
from clang.cindex import TypeKind
from ma.checkers.checker import Checker
from ma import core

        info = ""
        if kind == CursorKind.BINARY_OPERATOR or type_kind == TypeKind.TYPEDEF:
            node = self._get_var_declaration(node, node)
            location = node.location
            line = location.line
            file_name = os.path.basename(str(location.file))
            info = "    (file: {0} | line: {1})".format(file_name, line)

        raw_node = core.get_raw_node(node)
        char_regex = "\\bchar\\b"
        solution = ""
        if (re.search(char_regex, raw_node) and
                not re.search("typedef.*(struct|union)", raw_node)):
            solution = re.sub(char_regex, "signed char", raw_node)
            solution += info
        else:
            solution = self.default_solution
        return solution

    def _get_var_declaration(self, node, definition):
        """ Get where a variable is defined and return the corresponding
        node """
        aux_node = None
        if node.type.kind == TypeKind.TYPEDEF:
            aux_node = node.type.get_declaration()
        elif node.kind == CursorKind.DECL_REF_EXPR:
            aux_node = node.get_definition()

        if aux_node:
            node = aux_node

            definition = node