예제 #1
0
    def check_multiple_keyword_definitions(self, normalized_keyword_name):
        from robotframework_ls.impl import text_utilities

        multi = self._keywords_container.check_multiple_keyword_definitions(
            normalized_keyword_name)
        if multi is not None:
            return multi

        multi = []

        for name, remainder in text_utilities.iter_dotted_names(
                normalized_keyword_name):
            if not name or not remainder:
                continue
            containers = []
            keywords_container = self._resource_name_to_keywords_container.get(
                name)
            if keywords_container:
                containers.append(keywords_container)
            keywords_container = self._library_name_to_keywords_container.get(
                name)
            if keywords_container:
                containers.append(keywords_container)

            for keywords_container in containers:
                m = keywords_container.check_multiple_keyword_definitions(
                    remainder)
                if m is not None:
                    multi.extend(m)

        if len(multi) == 0:
            return None

        return multi
예제 #2
0
    def contains_keyword(self, normalized_keyword_name):
        from robotframework_ls.impl import text_utilities

        if self._keywords_container.contains_keyword(normalized_keyword_name):
            return True

        for name, remainder in text_utilities.iter_dotted_names(
                normalized_keyword_name):
            if not name or not remainder:
                continue
            containers = []
            keywords_container = self._resource_name_to_keywords_container.get(
                name)
            if keywords_container:
                containers.append(keywords_container)
            keywords_container = self._library_name_to_keywords_container.get(
                name)
            if keywords_container:
                containers.append(keywords_container)

            for keywords_container in containers:
                if keywords_container.contains_keyword(remainder):
                    return True

        return False
예제 #3
0
def build_matchers_with_resource_or_library_scope(token_str):
    """
    Given a string such as:
    
    'BuiltIn.Should Contain'
    
    it'll return:
    
    [MatcherWithResourceOrLibraryName('BuiltIn', 'Should Contain')]
    """
    from robotframework_ls.impl.text_utilities import iter_dotted_names

    resource_matchers = []
    for resource_or_library_name, qualifier in iter_dotted_names(token_str):
        resource_matchers.append(
            MatcherWithResourceOrLibraryName(resource_or_library_name,
                                             qualifier))
    return resource_matchers
예제 #4
0
def test_iter_dotted_names():
    from robotframework_ls.impl.text_utilities import iter_dotted_names

    assert list(iter_dotted_names("")) == []
    assert list(iter_dotted_names("a")) == []
    assert list(iter_dotted_names("a.b")) == [("a", "b")]
    assert list(iter_dotted_names(".a.b.")) == [
        ("", "a.b."),
        (".a", "b."),
        (".a.b", ""),
    ]
    assert list(iter_dotted_names("a.b.")) == [("a", "b."), ("a.b", "")]
    assert list(iter_dotted_names("a.b.c")) == [("a", "b.c"), ("a.b", "c")]