MCPcopy Create free account
hub / github.com/sourcebot-dev/sourcebot / traverseQueryIR

Function traverseQueryIR

packages/web/src/features/search/ir.ts:75–160  ·  view source on GitHub ↗
(
    query: QueryIR,
    visitor: QueryVisitor
)

Source from the content-addressed store, hash-verified

73 * @returns false if traversal was stopped early, true otherwise
74 */
75export function traverseQueryIR(
76 query: QueryIR,
77 visitor: QueryVisitor
78): boolean {
79 let shouldContinue: boolean | void = true;
80
81 if (isRawConfigQuery(query)) {
82 shouldContinue = visitor.onRawConfig?.(query);
83
84 } else if (isRegexpQuery(query)) {
85 shouldContinue = visitor.onRegexp?.(query);
86
87 } else if (isSymbolQuery(query)) {
88 shouldContinue = visitor.onSymbol?.(query);
89 if (shouldContinue !== false && query.symbol.expr) {
90 shouldContinue = traverseQueryIR(query.symbol.expr, visitor);
91 }
92
93 } else if (isLanguageQuery(query)) {
94 shouldContinue = visitor.onLanguage?.(query);
95
96 } else if (isConstQuery(query)) {
97 shouldContinue = visitor.onConst?.(query);
98
99 } else if (isRepoQuery(query)) {
100 shouldContinue = visitor.onRepo?.(query);
101
102 } else if (isRepoRegexpQuery(query)) {
103 shouldContinue = visitor.onRepoRegexp?.(query);
104
105 } else if (isBranchesReposQuery(query)) {
106 shouldContinue = visitor.onBranchesRepos?.(query);
107
108 } else if (isRepoIdsQuery(query)) {
109 shouldContinue = visitor.onRepoIds?.(query);
110
111 } else if (isRepoSetQuery(query)) {
112 shouldContinue = visitor.onRepoSet?.(query);
113
114 } else if (isFileNameSetQuery(query)) {
115 shouldContinue = visitor.onFileNameSet?.(query);
116
117 } else if (isTypeQuery(query)) {
118 shouldContinue = visitor.onType?.(query);
119
120 } else if (isSubstringQuery(query)) {
121 shouldContinue = visitor.onSubstring?.(query);
122
123 } else if (isAndQuery(query)) {
124 shouldContinue = visitor.onAnd?.(query);
125 if (shouldContinue !== false && query.and.children) {
126 for (const child of query.and.children) {
127 if (!traverseQueryIR(child, visitor)) {
128 return false;
129 }
130 }
131 }
132

Callers 1

findInQueryIRFunction · 0.85

Calls 15

isRawConfigQueryFunction · 0.85
isRegexpQueryFunction · 0.85
isSymbolQueryFunction · 0.85
isLanguageQueryFunction · 0.85
isConstQueryFunction · 0.85
isRepoQueryFunction · 0.85
isRepoRegexpQueryFunction · 0.85
isBranchesReposQueryFunction · 0.85
isRepoIdsQueryFunction · 0.85
isRepoSetQueryFunction · 0.85
isFileNameSetQueryFunction · 0.85
isTypeQueryFunction · 0.85

Tested by

no test coverage detected