コード例 #1
0
 def loadMainFunctionComboBox_(self):
     '''
     Load combo box for main function.
     It uses a SourceCodeParser instance to get all the possible global functions.
     '''
     language = self.getSelectedLanguage_()
     self.mainFunctionComboBox.clear()
     mainFile = str(self.mainFileEditBox.toPlainText())
     if self.validateMainFile_(mainFile, warnToUser = False):
         mySourceCodeParser = SourceCodeParser(language, mainFile)
         _, functions = mySourceCodeParser.getAllClassesAndFunctions(mainFile)
         
         for funcName in functions:
             self.mainFunctionComboBox.addItem(funcName)
     
     if self.isEditMode_():
         mainFunctionIndex = self.mainFunctionComboBox.findText(self.projectToEdit_.getMainFunction())
         self.mainFunctionComboBox.setCurrentIndex(mainFunctionIndex)
    def testCppGetAllClassesAndFunctions(self):
        MY_HEADER = "MyFunctions.h"
        myFunctionsFileName = os.path.join(TEST_FILES_FOLDER, MY_HEADER)
        mySourceCodeParser = SourceCodeParser(
            ProgramExecution.Languages.C_PLUS_PLUS, myFunctionsFileName)
        classes, functions = mySourceCodeParser.getAllClassesAndFunctions(
            myFunctionsFileName)

        expectedFunctions = [
            'myPrint', 'add', 'subtract', 'innerFunction', 'outerFunction',
            'noParamsFunction', 'mySubstring', 'processVector', 'processIntMap'
        ]
        expectedClasses = [
            'MyClass', 'ClassWithConstructor', 'ClassWithStaticMethods'
        ]

        self.assertEqual(expectedFunctions, functions)
        self.assertEqual(expectedClasses, classes)
    def testPythonGetAllClassesAndFunctions(self):
        mainFileName = 'mainFileForTests.py'
        myFunctionsFileName = os.path.join(TEST_FILES_FOLDER, "MyFunctions.py")
        mySourceCodeParser = SourceCodeParser(
            ProgramExecution.Languages.PYTHON, mainFileName)
        classes, functions = mySourceCodeParser.getAllClassesAndFunctions(
            myFunctionsFileName, "myFunctions")

        expectedFunctions = [
            'myPrint', 'add', 'subtract', 'innerFunction', 'outerFunction',
            'noParamsFunction', 'mySubstring', 'processList', 'processDict'
        ]
        expectedClasses = [
            'MyClass', 'ClassWithDummyParameters', 'NonAnnotatedClass',
            'ClassWithConstructor', 'ClassWithStaticAndClassMethods'
        ]

        self.assertEqual(expectedFunctions, functions)
        self.assertEqual(expectedClasses, classes)
コード例 #4
0
    def loadMainFunctionComboBox_(self):
        '''
        Load combo box for main function.
        It uses a SourceCodeParser instance to get all the possible global functions.
        '''
        language = self.getSelectedLanguage_()
        self.mainFunctionComboBox.clear()
        mainFile = str(self.mainFileEditBox.toPlainText())
        if self.validateMainFile_(mainFile, warnToUser=False):
            mySourceCodeParser = SourceCodeParser(language, mainFile)
            _, functions = mySourceCodeParser.getAllClassesAndFunctions(
                mainFile)

            for funcName in functions:
                self.mainFunctionComboBox.addItem(funcName)

        if self.isEditMode_():
            mainFunctionIndex = self.mainFunctionComboBox.findText(
                self.projectToEdit_.getMainFunction())
            self.mainFunctionComboBox.setCurrentIndex(mainFunctionIndex)