MCPcopy Create free account
hub / github.com/compiler-explorer/compiler-explorer / glGetMainContents

Function glGetMainContents

lib/utils.ts:429–451  ·  view source on GitHub ↗
(content: ItemConfigType[] = [])

Source from the content-addressed store, hash-verified

427 * @returns {glContents}
428 */
429export function glGetMainContents(content: ItemConfigType[] = []): glContents {
430 const contents: glContents = {editors: [], compilers: []};
431 _.each(content, element => {
432 if (element.type === 'component') {
433 const component = element as ComponentConfig;
434 if (component.componentName === 'codeEditor') {
435 contents.editors.push({
436 source: component.componentState.source,
437 language: component.componentState.lang as LanguageKey,
438 });
439 } else if (component.componentName === 'compiler') {
440 contents.compilers.push({
441 compiler: component.componentState.compiler,
442 });
443 }
444 } else {
445 const subComponents = glGetMainContents(element.content);
446 contents.editors = contents.editors.concat(subComponents.editors);
447 contents.compilers = contents.compilers.concat(subComponents.compilers);
448 }
449 });
450 return contents;
451}
452
453export function squashHorizontalWhitespace(line: string, atStart = true): string {
454 if (line.trim().length === 0) {

Callers

nothing calls this directly

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected