4
"""Implements a container for parsed snippets."""
6
# TODO(sirver): This class should not keep track of extends.
7
class SnippetDictionary(object):
8
"""See module docstring."""
14
def add_snippet(self, snippet):
15
"""Add 'snippet' to this dictionary."""
16
self._snippets.append(snippet)
18
def get_matching_snippets(self, trigger, potentially):
19
"""Returns all snippets matching the given trigger. If 'potentially' is
20
true, returns all that could_match()."""
21
all_snippets = self._snippets
23
return [s for s in all_snippets if s.matches(trigger)]
25
return [s for s in all_snippets if s.could_match(trigger)]
27
def clear_snippets(self, triggers):
28
"""Remove all snippets that match each trigger in 'triggers'. When
29
'triggers' is None, empties this dictionary completely."""
33
for trigger in triggers:
34
for snippet in self.get_matching_snippets(trigger, False):
35
if snippet in self._snippets:
36
self._snippets.remove(snippet)
40
"""The list of filetypes this filetype extends."""