<commit_before># v0.1
import sublime, sublime_plugin, re

class ConvertTestNameCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        # get a list of [test name with separate words, test name with no spaces in between and camel cased] from the current cursor(s) or selection(s)
        extractedTestNames = []

        currentSyntax = self.getSyntax()
        if ((currentSyntax != "PHP") & (currentSyntax != "JavaScript")):
            return

        # iterate over all cursors
        for region in self.view.sel():
            # extract line contents from cursor(s)
            line = self.view.line(region)
            lineContents = self.view.substr(line).strip()

            # keep only alphanum and ",", ".", "(", ")"
            testNameExpanded = re.sub(r'[^a-zA-Z0-9., \(\)]', '', lineContents).strip()

            # if extracted line contents are not empty, add them to stack
            if (testNameExpanded):
                # convert to CamelCase and keep only alphanumeric chars
                testNameContracted = testNameExpanded.title()
                testNameContracted = re.sub(r'[^a-zA-Z0-9]', '', testNameContracted)

                # replace current line
                self.view.replace(edit, line, self.prepareTestContent(testNameExpanded, testNameContracted, currentSyntax))

    def prepareTestContent(self, testNameExpanded, testNameContracted, languageSyntax):
        returnContent = ""

        tab = self.getWhitespaceTab()

        if (languageSyntax == "PHP"):
            returnContent = tab + "/**\n" + tab + "* " + testNameExpanded + "\n" + tab + "*/\n" + tab + "public function test"+testNameContracted+"()\n" + tab + "{\n\n" + tab + "}\n" + tab

        elif (languageSyntax == "JavaScript"):
            # will generate Jasmine blocks
            examineNameTypeParts = testNameExpanded.split(" ")

            if (examineNameTypeParts[0].lower() == "describe"):
                examineNameTypeParts.pop(0) # remove the "describe" prefix
                returnContent = tab + "describe('"+ (" ".join(examineNameTypeParts)) +"', function () {\n\n" + tab + "});\n" + tab
            else:
                returnContent = tab + tab + "it('"+testNameExpanded+"', function () {\n\n" + tab + "" + tab + "});\n" + tab

        return returnContent

    def getWhitespaceTab(self):
        if (self.view.settings().get('translate_tabs_to_spaces')):<commit_msg>Generate blank test method (works with multi-cursor)<commit_after># v0.1
import sublime, sublime_plugin, re

class ConvertTestNameCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        # get a list of [test name with separate words, test name with no spaces in between and camel cased] from the current cursor(s) or selection(s)
        extractedTestNames = []

        currentSyntax = self.getSyntax()
        if ((currentSyntax != "PHP") & (currentSyntax != "JavaScript")):
            return

        cursor = 0
        # iterate over all cursors
        for region in self.view.sel():
            # extract line contents from cursor(s)
            line = self.view.line(region)
            lineContents = self.view.substr(line).strip()

            # keep only alphanum and ",", ".", "(", ")"
            testNameExpanded = re.sub(r'[^a-zA-Z0-9., \(\)]', '', lineContents).strip()

            # if extracted line contents are empty, use "blank"
            if not testNameExpanded:
                testNameExpanded = "blank"
                if cursor > 0:
                    testNameExpanded += str(cursor)
                cursor += 1

            # convert to CamelCase and keep only alphanumeric chars
            testNameContracted = testNameExpanded.title()
            testNameContracted = re.sub(r'[^a-zA-Z0-9]', '', testNameContracted)

            # replace current line
            self.view.replace(edit, line, self.prepareTestContent(testNameExpanded, testNameContracted, currentSyntax))

    def prepareTestContent(self, testNameExpanded, testNameContracted, languageSyntax):
        returnContent = ""

        tab = self.getWhitespaceTab()

        if (languageSyntax == "PHP"):
            returnContent = tab + "/**\n" + tab + "* " + testNameExpanded + "\n" + tab + "*/\n" + tab + "public function test"+testNameContracted+"()\n" + tab + "{\n\n" + tab + "}\n\n" + tab

        elif (languageSyntax == "JavaScript"):
            # will generate Jasmine blocks
            examineNameTypeParts = testNameExpanded.split(" ")

            if (examineNameTypeParts[0].lower() == "describe"):
                examineNameTypeParts.pop(0) # remove the "describe" prefix
                returnContent = tab + "describe('"+ (" ".join(examineNameTypeParts)) +"', function () {\n\n" + tab + "});\n\n" + tab
            else:
                returnContent = tab + tab + "it('"+testNameExpanded+"', function () {\n\n" + tab + "" + tab + "});\n\n" + tab

        return returnContent

    def getWhitespaceTab(self):
        if (self.view.settings().get('translate_tabs_to_spaces')):
{'fraction_non_alphanumeric': 0.13468818489738993, 'fraction_numerical': 0.003785614664275752, 'mean_word_length': 2.3964817320703653, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '310827', 'n_tokens_mistral': 1459, 'n_tokens_neox': 1392, 'n_words': 362}