Browse Source

Use DEFINE instead of ASSIGN. Be consistent.

tags/v1.0^2
Ben Kurtovic 10 years ago
parent
commit
65d2529a33
3 changed files with 8 additions and 8 deletions
  1. +2
    -2
      bitshift/database/__init__.py
  2. +3
    -3
      bitshift/query/__init__.py
  3. +3
    -3
      bitshift/query/nodes.py

+ 2
- 2
bitshift/database/__init__.py View File

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



+ 3
- 3
bitshift/query/__init__.py View File

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


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

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



Loading…
Cancel
Save