Переглянути джерело

Fully support namespace, interface, and import types.

tags/v1.0^2
Ben Kurtovic 10 роки тому
джерело
коміт
62efe9f59d
2 змінених файлів з 23 додано та 4 видалено
  1. +17
    -1
      bitshift/query/__init__.py
  2. +6
    -3
      bitshift/query/nodes.py

+ 17
- 1
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:


+ 6
- 3
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):
"""


Завантаження…
Відмінити
Зберегти