MCPcopy Index your code
hub / github.com/parca-dev/parca / parse

Method parse

ui/packages/shared/parser/src/index.ts:195–235  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

193 }
194
195 static parse(input: string): Query {
196 const p = NewParser();
197 p.save();
198 try {
199 p.feed(input);
200 p.save();
201 } catch (error) {
202 // do nothing... this means we've got an incomplete or entirely incorrect query
203 }
204
205 if (p.results?.length > 0) {
206 return Query.fromAst(p.results[0]);
207 }
208
209 // partial parse result, also ok, we'll try our best with it :)
210
211 // Parser.table is not defined in the type definitions, so we need to do this unfortunately.
212 const parserTable = (p as any).table;
213 const column = parserTable.filter((c: any) =>
214 c.states.find(
215 (s: any) =>
216 s.data !== undefined &&
217 s.data != null &&
218 Object.prototype.hasOwnProperty.call(s.data, 'profileName')
219 )
220 )[0];
221 if (column !== undefined) {
222 const data = column.states.find(
223 (s: any) =>
224 s.data !== undefined && Object.prototype.hasOwnProperty.call(s.data, 'profileName')
225 ).data;
226 const rest = column.lexerState !== undefined ? input.slice(column.lexerState.col - 2) : input;
227 return new Query(
228 ProfileType.fromString(data.profileName),
229 [],
230 rest.length > 0 ? rest : input
231 );
232 }
233
234 return new Query(new ProfileType('', '', '', '', '', false), [], '');
235 }
236
237 static tryParse(
238 p: Parser,

Callers 14

internalJsonWriteMethod · 0.80
internalJsonReadMethod · 0.80
index.test.tsFile · 0.80
constructorMethod · 0.80
addLabelMatcherFunction · 0.80
handlePointClickFunction · 0.80
ProfileSelectorFunction · 0.80
enforcedProfileNameQueryFunction · 0.80
ProfileMetricsGraphFunction · 0.80
ProfileExplorerCompareFunction · 0.80
useQueryStateFunction · 0.80

Calls 3

NewParserFunction · 0.85
fromAstMethod · 0.80
fromStringMethod · 0.80

Tested by

no test coverage detected