MCPcopy Index your code
hub / github.com/angular/angular / getBestSnippetForMatch

Method getBestSnippetForMatch

adev/shared-docs/services/search.service.ts:130–148  ·  view source on GitHub ↗
(result: SearchResult)

Source from the content-addressed store, hash-verified

128 }
129
130 private getBestSnippetForMatch(result: SearchResult): string {
131 const hierarchy = result._snippetResult.hierarchy;
132 if (hierarchy === undefined) {
133 return '';
134 }
135
136 // return the most specific subheader match
137 if (matched(hierarchy.lvl4)) {
138 return hierarchy.lvl4!.value;
139 }
140 if (matched(hierarchy.lvl3)) {
141 return hierarchy.lvl3!.value;
142 }
143 if (matched(hierarchy.lvl2)) {
144 return hierarchy.lvl2!.value;
145 }
146 // if no subheader matched the query, fall back to just returning the most specific one
147 return hierarchy.lvl3?.value ?? hierarchy.lvl2?.value ?? '';
148 }
149
150 /**
151 * Returns an HTML string with marked text for the matches

Callers 1

parseResultMethod · 0.95

Calls 1

matchedFunction · 0.85

Tested by

no test coverage detected