Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Spell filter list more compactly, without calling append() all the time.

  • Loading branch information...
commit 32f1d3e825f2e0fe9e716618f3973fe61952f4e2 1 parent 43053da
@erikrose erikrose authored
Showing with 432 additions and 444 deletions.
  1. +432 −444 dxr/query.py
View
876 dxr/query.py
@@ -5,9 +5,6 @@
import time
-# Register filters by adding them to this list.
-filters = []
-
# TODO
# - Special argument files-only to just search for file names
# - If no plugin returns an extents query, don't fetch content
@@ -619,447 +616,438 @@ def sorter():
yield sorter()
-# TriLite Search filter
-filters.append(TriLiteSearchFilter())
-
-# path filter
-filters.append(SimpleFilter(
- param = "path",
- filter_sql = """files.path LIKE ? ESCAPE "\\" """,
- neg_filter_sql = """files.path NOT LIKE ? ESCAPE "\\" """,
- ext_sql = None,
- formatter = lambda arg: ['%' + like_escape(arg) + '%']
-))
-
-# ext filter
-filters.append(SimpleFilter(
- param = "ext",
- filter_sql = """files.path LIKE ? ESCAPE "\\" """,
- neg_filter_sql = """files.path NOT LIKE ? ESCAPE "\\" """,
- ext_sql = None,
- formatter = lambda arg: ['%' + like_escape(arg)]
-))
-
-
-# type filter
-filters.append(UnionFilter([
- ExistsLikeFilter(
- param = "type",
- filter_sql = """SELECT 1 FROM types
- WHERE %s
- AND types.file_id = files.id
- """,
- ext_sql = """SELECT types.extent_start, types.extent_end FROM types
- WHERE types.file_id = ?
- AND %s
- ORDER BY types.extent_start
- """,
- like_name = "types.name",
- qual_name = "types.qualname"
- ),
- ExistsLikeFilter(
- param = "type",
- filter_sql = """SELECT 1 FROM typedefs
- WHERE %s
- AND typedefs.file_id = files.id
- """,
- ext_sql = """SELECT typedefs.extent_start, typedefs.extent_end FROM typedefs
- WHERE typedefs.file_id = ?
- AND %s
- ORDER BY typedefs.extent_start
- """,
- like_name = "typedefs.name",
- qual_name = "typedefs.qualname"
- ),
-]))
-
-
-# type-ref filter
-filters.append(UnionFilter([
- ExistsLikeFilter(
- param = "type-ref",
- filter_sql = """SELECT 1 FROM types, type_refs AS refs
- WHERE %s
- AND types.id = refs.refid AND refs.file_id = files.id
- """,
- ext_sql = """SELECT refs.extent_start, refs.extent_end FROM type_refs AS refs
- WHERE refs.file_id = ?
- AND EXISTS (SELECT 1 FROM types
- WHERE %s
- AND types.id = refs.refid)
- ORDER BY refs.extent_start
- """,
- like_name = "types.name",
- qual_name = "types.qualname"
- ),
- ExistsLikeFilter(
- param = "type-ref",
- filter_sql = """SELECT 1 FROM typedefs, typedef_refs AS refs
- WHERE %s
- AND typedefs.id = refs.refid AND refs.file_id = files.id
- """,
- ext_sql = """SELECT refs.extent_start, refs.extent_end FROM typedef_refs AS refs
- WHERE refs.file_id = ?
- AND EXISTS (SELECT 1 FROM typedefs
- WHERE %s
- AND typedefs.id = refs.refid)
- ORDER BY refs.extent_start
- """,
- like_name = "typedefs.name",
- qual_name = "typedefs.qualname"
- ),
-]))
-
-# function filter
-filters.append(ExistsLikeFilter(
- param = "function",
- filter_sql = """SELECT 1 FROM functions
- WHERE %s
- AND functions.file_id = files.id
- """,
- ext_sql = """SELECT functions.extent_start, functions.extent_end FROM functions
- WHERE functions.file_id = ?
- AND %s
- ORDER BY functions.extent_start
- """,
- like_name = "functions.name",
- qual_name = "functions.qualname"
-))
-
-
-# function-ref filter
-filters.append(ExistsLikeFilter(
- param = "function-ref",
- filter_sql = """SELECT 1 FROM functions, function_refs AS refs
- WHERE %s
- AND functions.id = refs.refid AND refs.file_id = files.id
- """,
- ext_sql = """SELECT refs.extent_start, refs.extent_end FROM function_refs AS refs
- WHERE refs.file_id = ?
- AND EXISTS (SELECT 1 FROM functions
- WHERE %s
- AND functions.id = refs.refid)
- ORDER BY refs.extent_start
- """,
- like_name = "functions.name",
- qual_name = "functions.qualname"
-))
-
-
-# var filter
-filters.append(ExistsLikeFilter(
- param = "var",
- filter_sql = """SELECT 1 FROM variables
- WHERE %s
- AND variables.file_id = files.id
- """,
- ext_sql = """SELECT variables.extent_start, variables.extent_end FROM variables
- WHERE variables.file_id = ?
- AND %s
- ORDER BY variables.extent_start
- """,
- like_name = "variables.name",
- qual_name = "variables.qualname"
-))
-
-
-# var-ref filter
-filters.append(ExistsLikeFilter(
- param = "var-ref",
- filter_sql = """SELECT 1 FROM variables, variable_refs AS refs
- WHERE %s
- AND variables.id = refs.refid AND refs.file_id = files.id
- """,
- ext_sql = """SELECT refs.extent_start, refs.extent_end FROM variable_refs AS refs
- WHERE refs.file_id = ?
- AND EXISTS (SELECT 1 FROM variables
- WHERE %s
- AND variables.id = refs.refid)
- ORDER BY refs.extent_start
- """,
- like_name = "variables.name",
- qual_name = "variables.qualname"
-))
-
-
-# macro filter
-filters.append(ExistsLikeFilter(
- param = "macro",
- filter_sql = """SELECT 1 FROM macros
- WHERE %s
- AND macros.file_id = files.id
- """,
- ext_sql = """SELECT macros.extent_start, macros.extent_end FROM macros
- WHERE macros.file_id = ?
- AND %s
- ORDER BY macros.extent_start
- """,
- like_name = "macros.name",
- qual_name = "macros.name"
-))
-
-
-# macro-ref filter
-filters.append(ExistsLikeFilter(
- param = "macro-ref",
- filter_sql = """SELECT 1 FROM macros, macro_refs AS refs
- WHERE %s
- AND macros.id = refs.refid AND refs.file_id = files.id
- """,
- ext_sql = """SELECT refs.extent_start, refs.extent_end FROM macro_refs AS refs
- WHERE refs.file_id = ?
- AND EXISTS (SELECT 1 FROM macros
- WHERE %s
- AND macros.id = refs.refid)
- ORDER BY refs.extent_start
- """,
- like_name = "macros.name",
- qual_name = "macros.name"
-))
-
-
-filters.append(UnionFilter([
- # callers filter (direct-calls)
- ExistsLikeFilter(
- param = "callers",
- filter_sql = """SELECT 1
- FROM functions as caller, functions as target, callers
- WHERE %s
- AND callers.targetid = target.id
- AND callers.callerid = caller.id
- AND caller.file_id = files.id
- """,
- ext_sql = """SELECT functions.extent_start, functions.extent_end
- FROM functions
- WHERE functions.file_id = ?
- AND EXISTS (SELECT 1 FROM functions as target, callers
- WHERE %s
- AND callers.targetid = target.id
- AND callers.callerid = functions.id
- )
- ORDER BY functions.extent_start
- """,
- like_name = "target.name",
- qual_name = "target.qualname"
- ),
-
- # callers filter (indirect-calls)
- ExistsLikeFilter(
- param = "callers",
- filter_sql = """SELECT 1
- FROM functions as caller, functions as target, callers
- WHERE %s
- AND EXISTS ( SELECT 1 FROM targets
+# Register filters by adding them to this list:
+filters = [
+ TriLiteSearchFilter(),
+
+ # path filter
+ SimpleFilter(
+ param = "path",
+ filter_sql = """files.path LIKE ? ESCAPE "\\" """,
+ neg_filter_sql = """files.path NOT LIKE ? ESCAPE "\\" """,
+ ext_sql = None,
+ formatter = lambda arg: ['%' + like_escape(arg) + '%']
+ ),
+
+ # ext filter
+ SimpleFilter(
+ param = "ext",
+ filter_sql = """files.path LIKE ? ESCAPE "\\" """,
+ neg_filter_sql = """files.path NOT LIKE ? ESCAPE "\\" """,
+ ext_sql = None,
+ formatter = lambda arg: ['%' + like_escape(arg)]
+ ),
+
+
+ # type filter
+ UnionFilter([
+ ExistsLikeFilter(
+ param = "type",
+ filter_sql = """SELECT 1 FROM types
+ WHERE %s
+ AND types.file_id = files.id
+ """,
+ ext_sql = """SELECT types.extent_start, types.extent_end FROM types
+ WHERE types.file_id = ?
+ AND %s
+ ORDER BY types.extent_start
+ """,
+ like_name = "types.name",
+ qual_name = "types.qualname"
+ ),
+ ExistsLikeFilter(
+ param = "type",
+ filter_sql = """SELECT 1 FROM typedefs
+ WHERE %s
+ AND typedefs.file_id = files.id
+ """,
+ ext_sql = """SELECT typedefs.extent_start, typedefs.extent_end FROM typedefs
+ WHERE typedefs.file_id = ?
+ AND %s
+ ORDER BY typedefs.extent_start
+ """,
+ like_name = "typedefs.name",
+ qual_name = "typedefs.qualname"
+ ),
+ ]),
+
+ # type-ref filter
+ UnionFilter([
+ ExistsLikeFilter(
+ param = "type-ref",
+ filter_sql = """SELECT 1 FROM types, type_refs AS refs
+ WHERE %s
+ AND types.id = refs.refid AND refs.file_id = files.id
+ """,
+ ext_sql = """SELECT refs.extent_start, refs.extent_end FROM type_refs AS refs
+ WHERE refs.file_id = ?
+ AND EXISTS (SELECT 1 FROM types
+ WHERE %s
+ AND types.id = refs.refid)
+ ORDER BY refs.extent_start
+ """,
+ like_name = "types.name",
+ qual_name = "types.qualname"
+ ),
+ ExistsLikeFilter(
+ param = "type-ref",
+ filter_sql = """SELECT 1 FROM typedefs, typedef_refs AS refs
+ WHERE %s
+ AND typedefs.id = refs.refid AND refs.file_id = files.id
+ """,
+ ext_sql = """SELECT refs.extent_start, refs.extent_end FROM typedef_refs AS refs
+ WHERE refs.file_id = ?
+ AND EXISTS (SELECT 1 FROM typedefs
+ WHERE %s
+ AND typedefs.id = refs.refid)
+ ORDER BY refs.extent_start
+ """,
+ like_name = "typedefs.name",
+ qual_name = "typedefs.qualname"
+ ),
+ ]),
+
+ # function filter
+ ExistsLikeFilter(
+ param = "function",
+ filter_sql = """SELECT 1 FROM functions
+ WHERE %s
+ AND functions.file_id = files.id
+ """,
+ ext_sql = """SELECT functions.extent_start, functions.extent_end FROM functions
+ WHERE functions.file_id = ?
+ AND %s
+ ORDER BY functions.extent_start
+ """,
+ like_name = "functions.name",
+ qual_name = "functions.qualname"
+ ),
+
+ # function-ref filter
+ ExistsLikeFilter(
+ param = "function-ref",
+ filter_sql = """SELECT 1 FROM functions, function_refs AS refs
+ WHERE %s
+ AND functions.id = refs.refid AND refs.file_id = files.id
+ """,
+ ext_sql = """SELECT refs.extent_start, refs.extent_end FROM function_refs AS refs
+ WHERE refs.file_id = ?
+ AND EXISTS (SELECT 1 FROM functions
+ WHERE %s
+ AND functions.id = refs.refid)
+ ORDER BY refs.extent_start
+ """,
+ like_name = "functions.name",
+ qual_name = "functions.qualname"
+ ),
+
+ # var filter
+ ExistsLikeFilter(
+ param = "var",
+ filter_sql = """SELECT 1 FROM variables
+ WHERE %s
+ AND variables.file_id = files.id
+ """,
+ ext_sql = """SELECT variables.extent_start, variables.extent_end FROM variables
+ WHERE variables.file_id = ?
+ AND %s
+ ORDER BY variables.extent_start
+ """,
+ like_name = "variables.name",
+ qual_name = "variables.qualname"
+ ),
+
+ # var-ref filter
+ ExistsLikeFilter(
+ param = "var-ref",
+ filter_sql = """SELECT 1 FROM variables, variable_refs AS refs
+ WHERE %s
+ AND variables.id = refs.refid AND refs.file_id = files.id
+ """,
+ ext_sql = """SELECT refs.extent_start, refs.extent_end FROM variable_refs AS refs
+ WHERE refs.file_id = ?
+ AND EXISTS (SELECT 1 FROM variables
+ WHERE %s
+ AND variables.id = refs.refid)
+ ORDER BY refs.extent_start
+ """,
+ like_name = "variables.name",
+ qual_name = "variables.qualname"
+ ),
+
+ # macro filter
+ ExistsLikeFilter(
+ param = "macro",
+ filter_sql = """SELECT 1 FROM macros
+ WHERE %s
+ AND macros.file_id = files.id
+ """,
+ ext_sql = """SELECT macros.extent_start, macros.extent_end FROM macros
+ WHERE macros.file_id = ?
+ AND %s
+ ORDER BY macros.extent_start
+ """,
+ like_name = "macros.name",
+ qual_name = "macros.name"
+ ),
+
+ # macro-ref filter
+ ExistsLikeFilter(
+ param = "macro-ref",
+ filter_sql = """SELECT 1 FROM macros, macro_refs AS refs
+ WHERE %s
+ AND macros.id = refs.refid AND refs.file_id = files.id
+ """,
+ ext_sql = """SELECT refs.extent_start, refs.extent_end FROM macro_refs AS refs
+ WHERE refs.file_id = ?
+ AND EXISTS (SELECT 1 FROM macros
+ WHERE %s
+ AND macros.id = refs.refid)
+ ORDER BY refs.extent_start
+ """,
+ like_name = "macros.name",
+ qual_name = "macros.name"
+ ),
+
+ UnionFilter([
+ # callers filter (direct-calls)
+ ExistsLikeFilter(
+ param = "callers",
+ filter_sql = """SELECT 1
+ FROM functions as caller, functions as target, callers
+ WHERE %s
+ AND callers.targetid = target.id
+ AND callers.callerid = caller.id
+ AND caller.file_id = files.id
+ """,
+ ext_sql = """SELECT functions.extent_start, functions.extent_end
+ FROM functions
+ WHERE functions.file_id = ?
+ AND EXISTS (SELECT 1 FROM functions as target, callers
+ WHERE %s
+ AND callers.targetid = target.id
+ AND callers.callerid = functions.id
+ )
+ ORDER BY functions.extent_start
+ """,
+ like_name = "target.name",
+ qual_name = "target.qualname"
+ ),
+
+ # callers filter (indirect-calls)
+ ExistsLikeFilter(
+ param = "callers",
+ filter_sql = """SELECT 1
+ FROM functions as caller, functions as target, callers
+ WHERE %s
+ AND EXISTS ( SELECT 1 FROM targets
+ WHERE targets.funcid = target.id
+ AND targets.targetid = callers.targetid
+ )
+ AND callers.callerid = caller.id
+ AND caller.file_id = files.id
+ """,
+ ext_sql = """SELECT functions.extent_start, functions.extent_end
+ FROM functions
+ WHERE functions.file_id = ?
+ AND EXISTS (SELECT 1 FROM functions as target, callers
+ WHERE %s
+ AND EXISTS (
+ SELECT 1 FROM targets
WHERE targets.funcid = target.id
AND targets.targetid = callers.targetid
- )
- AND callers.callerid = caller.id
- AND caller.file_id = files.id
- """,
- ext_sql = """SELECT functions.extent_start, functions.extent_end
- FROM functions
- WHERE functions.file_id = ?
- AND EXISTS (SELECT 1 FROM functions as target, callers
- WHERE %s
- AND EXISTS (
- SELECT 1 FROM targets
- WHERE targets.funcid = target.id
- AND targets.targetid = callers.targetid
- AND callers.callerid = target.id
- )
- AND callers.callerid = functions.id
- )
- ORDER BY functions.extent_start
- """,
- like_name = "target.name",
- qual_name = "target.qualname"
- ),
-]))
-
-filters.append(UnionFilter([
- # called-by filter (direct calls)
- ExistsLikeFilter(
- param = "called-by",
- filter_sql = """SELECT 1
- FROM functions as target, functions as caller, callers
- WHERE %s
- AND callers.callerid = caller.id
- AND callers.targetid = target.id
- AND target.file_id = files.id
- """,
- ext_sql = """SELECT functions.extent_start, functions.extent_end
- FROM functions
- WHERE functions.file_id = ?
- AND EXISTS (SELECT 1 FROM functions as caller, callers
- WHERE %s
- AND caller.id = callers.callerid
- AND callers.targetid = functions.id
- )
- ORDER BY functions.extent_start
- """,
- like_name = "caller.name",
- qual_name = "caller.qualname"
- ),
-
- # called-by filter (indirect calls)
- ExistsLikeFilter(
- param = "called-by",
- filter_sql = """SELECT 1
- FROM functions as target, functions as caller, callers
- WHERE %s
- AND callers.callerid = caller.id
- AND ( EXISTS (SELECT 1 FROM targets
- WHERE targets.funcid = target.id
- AND targets.targetid = callers.targetid
- )
- )
- AND target.file_id = files.id
- """,
- ext_sql = """SELECT functions.extent_start, functions.extent_end
- FROM functions
- WHERE functions.file_id = ?
- AND EXISTS (SELECT 1 FROM functions as caller, callers
- WHERE %s
- AND caller.id = callers.callerid
- AND EXISTS (
- SELECT 1 FROM targets
- WHERE targets.funcid = functions.id
- AND targets.targetid = callers.targetid
- )
- )
- ORDER BY functions.extent_start
- """,
- like_name = "caller.name",
- qual_name = "caller.qualname"
- ),
-]))
-
-#warning filter
-filters.append(ExistsLikeFilter(
- param = "warning",
- filter_sql = """SELECT 1 FROM warnings
- WHERE %s
- AND warnings.file_id = files.id """,
- ext_sql = """SELECT warnings.extent_start, warnings.extent_end
- FROM warnings
- WHERE warnings.file_id = ?
- AND %s
- """,
- like_name = "warnings.msg",
- qual_name = "warnings.msg"
-))
-
-
-#warning-opt filter
-filters.append(ExistsLikeFilter(
- param = "warning-opt",
- filter_sql = """SELECT 1 FROM warnings
- WHERE %s
- AND warnings.file_id = files.id """,
- ext_sql = """SELECT warnings.extent_start, warnings.extent_end
- FROM warnings
- WHERE warnings.file_id = ?
- AND %s
- """,
- like_name = "warnings.opt",
- qual_name = "warnings.opt"
-))
-
-
-# bases filter
-filters.append(ExistsLikeFilter(
- param = "bases",
- filter_sql = """SELECT 1 FROM types as base, impl, types
- WHERE %s
- AND impl.tbase = base.id
- AND impl.tderived = types.id
- AND base.file_id = files.id""",
- ext_sql = """SELECT base.extent_start, base.extent_end
- FROM types as base
- WHERE base.file_id = ?
- AND EXISTS (SELECT 1 FROM impl, types
- WHERE impl.tbase = base.id
- AND impl.tderived = types.id
- AND %s
+ AND callers.callerid = target.id
+ )
+ AND callers.callerid = functions.id
+ )
+ ORDER BY functions.extent_start
+ """,
+ like_name = "target.name",
+ qual_name = "target.qualname"
+ ),
+ ]),
+
+ UnionFilter([
+ # called-by filter (direct calls)
+ ExistsLikeFilter(
+ param = "called-by",
+ filter_sql = """SELECT 1
+ FROM functions as target, functions as caller, callers
+ WHERE %s
+ AND callers.callerid = caller.id
+ AND callers.targetid = target.id
+ AND target.file_id = files.id
+ """,
+ ext_sql = """SELECT functions.extent_start, functions.extent_end
+ FROM functions
+ WHERE functions.file_id = ?
+ AND EXISTS (SELECT 1 FROM functions as caller, callers
+ WHERE %s
+ AND caller.id = callers.callerid
+ AND callers.targetid = functions.id
+ )
+ ORDER BY functions.extent_start
+ """,
+ like_name = "caller.name",
+ qual_name = "caller.qualname"
+ ),
+
+ # called-by filter (indirect calls)
+ ExistsLikeFilter(
+ param = "called-by",
+ filter_sql = """SELECT 1
+ FROM functions as target, functions as caller, callers
+ WHERE %s
+ AND callers.callerid = caller.id
+ AND ( EXISTS (SELECT 1 FROM targets
+ WHERE targets.funcid = target.id
+ AND targets.targetid = callers.targetid
+ )
)
- """,
- like_name = "types.name",
- qual_name = "types.qualname"
-))
-
-
-# derived filter
-filters.append(ExistsLikeFilter(
- param = "derived",
- filter_sql = """SELECT 1 FROM types as sub, impl, types
- WHERE %s
- AND impl.tbase = types.id
- AND impl.tderived = sub.id
- AND sub.file_id = files.id""",
- ext_sql = """SELECT sub.extent_start, sub.extent_end
- FROM types as sub
- WHERE sub.file_id = ?
- AND EXISTS (SELECT 1 FROM impl, types
- WHERE impl.tbase = types.id
- AND impl.tderived = sub.id
- AND %s
- )
- """,
- like_name = "types.name",
- qual_name = "types.qualname"
-))
-
-
-filters.append(UnionFilter([
- # member filter for functions
- ExistsLikeFilter(
- param = "member",
- filter_sql = """SELECT 1 FROM types as type, functions as mem
- WHERE %s
- AND mem.scopeid = type.id AND mem.file_id = files.id
- """,
- ext_sql = """ SELECT extent_start, extent_end
- FROM functions as mem WHERE mem.file_id = ?
- AND EXISTS ( SELECT 1 FROM types as type
- WHERE %s
- AND type.id = mem.scopeid)
- ORDER BY mem.extent_start
- """,
- like_name = "type.name",
- qual_name = "type.qualname"
- ),
- # member filter for types
- ExistsLikeFilter(
- param = "member",
- filter_sql = """SELECT 1 FROM types as type, types as mem
- WHERE %s
- AND mem.scopeid = type.id AND mem.file_id = files.id
- """,
- ext_sql = """ SELECT extent_start, extent_end
- FROM types as mem WHERE mem.file_id = ?
- AND EXISTS ( SELECT 1 FROM types as type
- WHERE %s
- AND type.id = mem.scopeid)
- ORDER BY mem.extent_start
- """,
- like_name = "type.name",
- qual_name = "type.qualname"
- ),
- # member filter for variables
- ExistsLikeFilter(
- param = "member",
- filter_sql = """SELECT 1 FROM types as type, variables as mem
- WHERE %s
- AND mem.scopeid = type.id AND mem.file_id = files.id
- """,
- ext_sql = """ SELECT extent_start, extent_end
- FROM variables as mem WHERE mem.file_id = ?
- AND EXISTS ( SELECT 1 FROM types as type
- WHERE %s
- AND type.id = mem.scopeid)
- ORDER BY mem.extent_start
- """,
- like_name = "type.name",
- qual_name = "type.qualname"
- ),
-]))
+ AND target.file_id = files.id
+ """,
+ ext_sql = """SELECT functions.extent_start, functions.extent_end
+ FROM functions
+ WHERE functions.file_id = ?
+ AND EXISTS (SELECT 1 FROM functions as caller, callers
+ WHERE %s
+ AND caller.id = callers.callerid
+ AND EXISTS (
+ SELECT 1 FROM targets
+ WHERE targets.funcid = functions.id
+ AND targets.targetid = callers.targetid
+ )
+ )
+ ORDER BY functions.extent_start
+ """,
+ like_name = "caller.name",
+ qual_name = "caller.qualname"
+ ),
+ ]),
+
+ #warning filter
+ ExistsLikeFilter(
+ param = "warning",
+ filter_sql = """SELECT 1 FROM warnings
+ WHERE %s
+ AND warnings.file_id = files.id """,
+ ext_sql = """SELECT warnings.extent_start, warnings.extent_end
+ FROM warnings
+ WHERE warnings.file_id = ?
+ AND %s
+ """,
+ like_name = "warnings.msg",
+ qual_name = "warnings.msg"
+ ),
+
+ #warning-opt filter
+ ExistsLikeFilter(
+ param = "warning-opt",
+ filter_sql = """SELECT 1 FROM warnings
+ WHERE %s
+ AND warnings.file_id = files.id """,
+ ext_sql = """SELECT warnings.extent_start, warnings.extent_end
+ FROM warnings
+ WHERE warnings.file_id = ?
+ AND %s
+ """,
+ like_name = "warnings.opt",
+ qual_name = "warnings.opt"
+ ),
+
+ # bases filter
+ ExistsLikeFilter(
+ param = "bases",
+ filter_sql = """SELECT 1 FROM types as base, impl, types
+ WHERE %s
+ AND impl.tbase = base.id
+ AND impl.tderived = types.id
+ AND base.file_id = files.id""",
+ ext_sql = """SELECT base.extent_start, base.extent_end
+ FROM types as base
+ WHERE base.file_id = ?
+ AND EXISTS (SELECT 1 FROM impl, types
+ WHERE impl.tbase = base.id
+ AND impl.tderived = types.id
+ AND %s
+ )
+ """,
+ like_name = "types.name",
+ qual_name = "types.qualname"
+ ),
+
+ # derived filter
+ ExistsLikeFilter(
+ param = "derived",
+ filter_sql = """SELECT 1 FROM types as sub, impl, types
+ WHERE %s
+ AND impl.tbase = types.id
+ AND impl.tderived = sub.id
+ AND sub.file_id = files.id""",
+ ext_sql = """SELECT sub.extent_start, sub.extent_end
+ FROM types as sub
+ WHERE sub.file_id = ?
+ AND EXISTS (SELECT 1 FROM impl, types
+ WHERE impl.tbase = types.id
+ AND impl.tderived = sub.id
+ AND %s
+ )
+ """,
+ like_name = "types.name",
+ qual_name = "types.qualname"
+ ),
+
+ UnionFilter([
+ # member filter for functions
+ ExistsLikeFilter(
+ param = "member",
+ filter_sql = """SELECT 1 FROM types as type, functions as mem
+ WHERE %s
+ AND mem.scopeid = type.id AND mem.file_id = files.id
+ """,
+ ext_sql = """ SELECT extent_start, extent_end
+ FROM functions as mem WHERE mem.file_id = ?
+ AND EXISTS ( SELECT 1 FROM types as type
+ WHERE %s
+ AND type.id = mem.scopeid)
+ ORDER BY mem.extent_start
+ """,
+ like_name = "type.name",
+ qual_name = "type.qualname"
+ ),
+ # member filter for types
+ ExistsLikeFilter(
+ param = "member",
+ filter_sql = """SELECT 1 FROM types as type, types as mem
+ WHERE %s
+ AND mem.scopeid = type.id AND mem.file_id = files.id
+ """,
+ ext_sql = """ SELECT extent_start, extent_end
+ FROM types as mem WHERE mem.file_id = ?
+ AND EXISTS ( SELECT 1 FROM types as type
+ WHERE %s
+ AND type.id = mem.scopeid)
+ ORDER BY mem.extent_start
+ """,
+ like_name = "type.name",
+ qual_name = "type.qualname"
+ ),
+ # member filter for variables
+ ExistsLikeFilter(
+ param = "member",
+ filter_sql = """SELECT 1 FROM types as type, variables as mem
+ WHERE %s
+ AND mem.scopeid = type.id AND mem.file_id = files.id
+ """,
+ ext_sql = """ SELECT extent_start, extent_end
+ FROM variables as mem WHERE mem.file_id = ?
+ AND EXISTS ( SELECT 1 FROM types as type
+ WHERE %s
+ AND type.id = mem.scopeid)
+ ORDER BY mem.extent_start
+ """,
+ like_name = "type.name",
+ qual_name = "type.qualname"
+ ),
+ ])
+]
Please sign in to comment.
Something went wrong with that request. Please try again.