diff --git a/bitshift/database/__init__.py b/bitshift/database/__init__.py index b242680..388508d 100644 --- a/bitshift/database/__init__.py +++ b/bitshift/database/__init__.py @@ -156,10 +156,10 @@ class Database(object): build = lambda id, L, typ: [tuple([id, typ] + list(loc)) for loc in L] type_id = Symbol.TYPES.index(sym_type) - for (name, assigns, uses) in symbols: + for (name, defs, uses) in symbols: cursor.execute(query1, (code_id, type_id, name)) sym_id = cursor.lastrowid - params = (build(sym_id, assigns, Symbol.ASSIGN) + + params = (build(sym_id, defs, Symbol.DEFINE) + build(sym_id, uses, Symbol.USE)) cursor.executemany(query2, params) diff --git a/bitshift/query/__init__.py b/bitshift/query/__init__.py index 4e91c77..02050f1 100644 --- a/bitshift/query/__init__.py +++ b/bitshift/query/__init__.py @@ -170,11 +170,11 @@ class _QueryParser(object): def _parse_symbol(self, term, stype=Symbol.ALL): """Parse part of a query into a symbol node and return it.""" - assigns = ("a:", "assign:", "assignment:", "d:", "def:", "definition:", + defines = ("a:", "assign:", "assignment:", "d:", "def:", "definition:", "decl:", "declare:", "declaration:") uses = ("u:", "use:", "c:", "call:") - if term.startswith(assigns) or term.startswith(uses): - context = Symbol.ASSIGN if term.startswith(assigns) else Symbol.USE + if term.startswith(defines) or term.startswith(uses): + context = Symbol.DEFINE if term.startswith(defines) else Symbol.USE term_part = term.split(":", 1)[1] if not term_part: raise QueryParseException('Incomplete query term: "%s"' % term) diff --git a/bitshift/query/nodes.py b/bitshift/query/nodes.py index 2d46ef0..8aec7f6 100644 --- a/bitshift/query/nodes.py +++ b/bitshift/query/nodes.py @@ -197,7 +197,7 @@ class Symbol(_Node): Searches in symbol_type and symbol_name. """ ALL = -1 - ASSIGN = 0 + DEFINE = 0 USE = 1 FUNCTION = 0 @@ -213,7 +213,7 @@ class Symbol(_Node): def __init__(self, context, type_, name): """ - :type context: int (``ASSIGN`` or ``USE``) + :type context: int (``DEFINE`` or ``USE``) :type type_: int (``ALL``, ``FUNCTION``, ``CLASS``, etc.) :type name: :py:class:`._Literal` """ @@ -222,7 +222,7 @@ class Symbol(_Node): self.name = name def __repr__(self): - context = ["ASSIGN", "USE", "ALL"][self.context] + context = ["DEFINE", "USE", "ALL"][self.context] type_ = self.TYPE_REPR[self.type] if self.type >= 0 else "ALL" return "Symbol({0}, {1}, {2})".format(context, type_, self.name)