diff --git a/bitshift/query/__init__.py b/bitshift/query/__init__.py index 73d6f65..84ba844 100644 --- a/bitshift/query/__init__.py +++ b/bitshift/query/__init__.py @@ -33,7 +33,11 @@ class _QueryParser(object): self._parse_symbol: ["s", "sym", "symb", "symbol"], self._parse_function: ["f", "fn", "fun", "func", "function"], self._parse_class: ["cl", "class", "clss"], - self._parse_variable: ["v", "var", "variable"] + self._parse_variable: ["v", "var", "variable"], + self._parse_namespace: ["n", "ns", "namespace", "module"], + self._parse_interface: ["in", "inter", "interface", "implements"], + self._parse_import: ["im", "imp", "import", "include", "require", + "imports", "requires"] } def _scan_query(self, query, markers): @@ -187,6 +191,18 @@ class _QueryParser(object): """Parse part of a query into a variable node and return it.""" return self._parse_symbol(term, Symbol.VARIABLE) + def _parse_namespace(self, term): + """Parse part of a query into a namespace node and return it.""" + return self._parse_symbol(term, Symbol.NAMESPACE) + + def _parse_interface(self, term): + """Parse part of a query into a interface node and return it.""" + return self._parse_symbol(term, Symbol.INTERFACE) + + def _parse_import(self, term): + """Parse part of a query into a import node and return it.""" + return self._parse_symbol(term, Symbol.IMPORT) + def _parse_term(self, term): """Parse a query term into a tree node and return it.""" try: diff --git a/bitshift/query/nodes.py b/bitshift/query/nodes.py index cd21fc8..2ff6d4b 100644 --- a/bitshift/query/nodes.py +++ b/bitshift/query/nodes.py @@ -194,10 +194,13 @@ class Symbol(_Node): FUNCTION = 0 CLASS = 1 VARIABLE = 2 - MODULE = 3 + NAMESPACE = 3 INTERFACE = 4 - TYPES = ["functions", "classes", "vars", "modules", "interfaces"] - TYPE_REPR = ["FUNCTION", "CLASS", "VARIABLE", "MODULE", "INTERFACE"] + IMPORT = 5 + TYPES = ["functions", "classes", "vars", "namespaces", "interfaces", + "imports"] + TYPE_REPR = ["FUNCTION", "CLASS", "VARIABLE", "NAMESPACE", "INTERFACE", + "IMPORT"] def __init__(self, type_, name): """