Browse Source

Fully support namespace, interface, and import types.

tags/v1.0^2
Ben Kurtovic 10 years ago
parent
commit
62efe9f59d
2 changed files with 23 additions and 4 deletions
  1. +17
    -1
      bitshift/query/__init__.py
  2. +6
    -3
      bitshift/query/nodes.py

+ 17
- 1
bitshift/query/__init__.py View File

@@ -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:


+ 6
- 3
bitshift/query/nodes.py View File

@@ -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):
"""


Loading…
Cancel
Save