예제 #1
0
    def test_populate_includes(self):
        """Testing include population
        """
        # open any existing file
        self.tearDown()
        self.setUpView('test_wrong_triggers.cpp')
        # now test the things
        settings = Settings()
        self.assertTrue(settings.is_valid())
        settings.include_file_folder = True
        settings.include_parent_folder = True
        settings.include_dirs = [
            path.realpath("/$project_name/src"),
            path.realpath("/test/test")
        ]
        initial_dirs = list(settings.include_dirs)
        dirs = settings.populate_include_dirs(self.view)

        current_folder = path.dirname(self.view.file_name())
        parent_folder = path.dirname(current_folder)
        self.assertLess(len(initial_dirs), len(dirs))
        self.assertNotEqual(dirs[0], initial_dirs[0])
        self.assertEqual(dirs[1], initial_dirs[1])
        self.assertEqual(dirs[2], current_folder)
        self.assertEqual(dirs[3], parent_folder)
예제 #2
0
    def test_complete(self):
        """Test autocompletion for user type

        """
        file_name = path.join(path.dirname(__file__), 'test.cpp')
        self.view = sublime.active_window().open_file(file_name)
        while self.view.is_loading():
            time.sleep(0.1)
        # now the file should be ready
        settings = Settings()
        current_folder = path.dirname(self.view.file_name())
        parent_folder = path.dirname(current_folder)
        include_dirs = settings.populate_include_dirs(
            file_current_folder=current_folder,
            file_parent_folder=parent_folder)
        completer = Completer("clang++")
        completer.init(view=self.view,
                       includes=include_dirs,
                       settings=settings)
        self.assertTrue(completer.exists_for_view(self.view.id()))
        self.assertEqual(self.getRow(5), "  a.")
        pos = self.view.text_point(5, 4)
        current_word = self.view.substr(self.view.word(pos))
        self.assertEqual(current_word, ".\n")
        completer.complete(self.view, pos, settings.errors_on_save)
        counter = 0
        while not completer.async_completions_ready:
            time.sleep(0.1)
            counter += 1
            if counter > 20:
                break
        self.assertIsNotNone(completer.completions)
        expected = ['a\tint a', 'a']
        self.assertTrue(expected in completer.completions)
예제 #3
0
    def test_init_completer(self):
        """Test that completer is properly initialized

        """
        settings = Settings()
        current_folder = path.dirname(self.view.file_name())
        parent_folder = path.dirname(current_folder)
        include_dirs = settings.populate_include_dirs(
            file_current_folder=current_folder,
            file_parent_folder=parent_folder)
        completer = Completer("clang++")
        completer.init(view=self.view,
                       includes=include_dirs,
                       settings=settings)
        self.assertTrue(completer.exists_for_view(self.view.id()))
예제 #4
0
 def test_populate_includes(self):
     """Testing include population
     """
     settings = Settings()
     self.assertTrue(settings.is_valid())
     settings.include_file_folder = True
     settings.include_parent_folder = True
     settings.include_dirs = [
         path.realpath("/$project_name/src"),
         path.realpath("/test/test")
     ]
     initial_dirs = list(settings.include_dirs)
     dirs = settings.populate_include_dirs(path.realpath(__file__),
                                           path.abspath(path.curdir))
     self.assertLess(len(initial_dirs), len(dirs))
     self.assertNotEqual(dirs[0], initial_dirs[0])
     self.assertEqual(dirs[1], initial_dirs[1])
     self.assertEqual(dirs[2], path.realpath(__file__))
     self.assertEqual(dirs[3], path.abspath(path.dirname(path.curdir)))
예제 #5
0
    def setUpCompleter(self):
        """
        Utility method to set up a completer for the current view.

        Returns:
            BaseCompleter: completer for the current view.
        """

        settings = Settings()
        current_folder = path.dirname(self.view.file_name())
        parent_folder = path.dirname(current_folder)
        include_dirs = settings.populate_include_dirs(
            file_current_folder=current_folder,
            file_parent_folder=parent_folder)

        clang_binary = settings.clang_binary
        completer = self.Completer(clang_binary)
        completer.init(
            view=self.view,
            includes=include_dirs,
            settings=settings)

        return completer
예제 #6
0
    def setUpCompleter(self):
        """
        Utility method to set up a completer for the current view.

        Returns:
            BaseCompleter: completer for the current view.
        """

        settings = Settings()
        current_folder = path.dirname(self.view.file_name())
        parent_folder = path.dirname(current_folder)
        include_dirs = settings.populate_include_dirs(
            file_current_folder=current_folder,
            file_parent_folder=parent_folder)

        clang_binary = settings.clang_binary
        completer = self.Completer(clang_binary)
        completer.init(
            view=self.view,
            includes=include_dirs,
            settings=settings)

        return completer