| @@ -156,10 +156,10 @@ class Database(object): | |||||
| build = lambda id, L, typ: [tuple([id, typ] + list(loc)) for loc in L] | build = lambda id, L, typ: [tuple([id, typ] + list(loc)) for loc in L] | ||||
| type_id = Symbol.TYPES.index(sym_type) | 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)) | cursor.execute(query1, (code_id, type_id, name)) | ||||
| sym_id = cursor.lastrowid | sym_id = cursor.lastrowid | ||||
| params = (build(sym_id, assigns, Symbol.ASSIGN) + | |||||
| params = (build(sym_id, defs, Symbol.DEFINE) + | |||||
| build(sym_id, uses, Symbol.USE)) | build(sym_id, uses, Symbol.USE)) | ||||
| cursor.executemany(query2, params) | cursor.executemany(query2, params) | ||||
| @@ -170,11 +170,11 @@ class _QueryParser(object): | |||||
| def _parse_symbol(self, term, stype=Symbol.ALL): | def _parse_symbol(self, term, stype=Symbol.ALL): | ||||
| """Parse part of a query into a symbol node and return it.""" | """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:") | "decl:", "declare:", "declaration:") | ||||
| uses = ("u:", "use:", "c:", "call:") | 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] | term_part = term.split(":", 1)[1] | ||||
| if not term_part: | if not term_part: | ||||
| raise QueryParseException('Incomplete query term: "%s"' % term) | raise QueryParseException('Incomplete query term: "%s"' % term) | ||||
| @@ -197,7 +197,7 @@ class Symbol(_Node): | |||||
| Searches in symbol_type and symbol_name. | Searches in symbol_type and symbol_name. | ||||
| """ | """ | ||||
| ALL = -1 | ALL = -1 | ||||
| ASSIGN = 0 | |||||
| DEFINE = 0 | |||||
| USE = 1 | USE = 1 | ||||
| FUNCTION = 0 | FUNCTION = 0 | ||||
| @@ -213,7 +213,7 @@ class Symbol(_Node): | |||||
| def __init__(self, context, type_, name): | 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 type_: int (``ALL``, ``FUNCTION``, ``CLASS``, etc.) | ||||
| :type name: :py:class:`._Literal` | :type name: :py:class:`._Literal` | ||||
| """ | """ | ||||
| @@ -222,7 +222,7 @@ class Symbol(_Node): | |||||
| self.name = name | self.name = name | ||||
| def __repr__(self): | 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" | type_ = self.TYPE_REPR[self.type] if self.type >= 0 else "ALL" | ||||
| return "Symbol({0}, {1}, {2})".format(context, type_, self.name) | return "Symbol({0}, {1}, {2})".format(context, type_, self.name) | ||||