return lodash.flatten(queryResults.map((queryResult) => { const lineReference = createLineReferenceFromSourceMap( lodash.get(queryResult, refractSymbol.sourceMapPath, []), document, documentLines ); let results = {}; const description = lodash.get(queryResult, refractSymbol.descriptionPath, ''); const lodashChain = lodash .chain(refractSymbol.childs) .map((child) => { return extractSymbols(queryResult, document, documentLines, child, description); }) .flatten() if (!lodash.isEmpty(lineReference)) { results = SymbolInformation.create( description, refractSymbol.symbol, Range.create(lineReference.startRow, lineReference.startIndex, lineReference.endRow, lineReference.endIndex), null, containerName); return lodashChain.concat(results).value(); } return lodashChain.value(); }));
return lodash.transform(queryResults, (result, queryResult) => { /* WARNING: This might be your reaction when you'll look into this code: 😱 Thing is there is no really source map here and I do not want to solve this thing in this release. The long term idea would be to wait till the underlying parser will be updated to generate sourcemaps on generated content as well and everybody will be happy; till that moment, please bear with me. */ let sourceMap; ['meta.title.attributes.sourceMap', 'attributes.href.attributes.sourceMap', (qs) => query(qs, [{ query: { attributes: { method: {} } }, symbolKind: 0 }]), ].some((path: string | Function): boolean => { if (typeof (path) === 'function') { sourceMap = lodash.get((path as Function)(queryResult)[0], 'attributes.method.attributes.sourceMap'); return true; } else { if (lodash.has(queryResult, path)) { sourceMap = lodash.get(queryResult, path); return true; } } }); const lineReference = createLineReferenceFromSourceMap( sourceMap, document, documentLines, ); let description = ''; ['meta.title.content', 'attributes.href.content', (qs) => query(qs, [{ query: { attributes: { method: {} } }, symbolKind: 0 }]), ].some((path: string | Function): boolean => { if (typeof (path) === 'function') { description = decodeURI(lodash.get((path as Function)(queryResult)[0], 'attributes.method.content')); return true; } else { if (lodash.has(queryResult, path)) { description = decodeURI(lodash.get(queryResult, path)); return true; } } }); if (!lodash.isEmpty(lineReference)) { result.push(SymbolInformation.create( description, queryResult.symbolKind, Range.create( lineReference.startRow, lineReference.startIndex, lineReference.endRow, lineReference.endIndex, ), null, queryResult.container)); } });
let res = externals.map(external => { return SymbolInformation.create(external.name, util.formEmptyKind(), util.formEmptyRange(), util.formExternalUri(external)); });
result = navigateToItems.map(item => { let start = ts.getLineAndCharacterOfPosition(service.services.getProgram().getSourceFile(item.fileName), item.textSpan.start); let end = ts.getLineAndCharacterOfPosition(service.services.getProgram().getSourceFile(item.fileName), item.textSpan.start + item.textSpan.length); return SymbolInformation.create(item.name, util.convertStringtoSymbolKind(item.kind), Range.create(start.line, start.character, end.line, end.character), 'file:///' + item.fileName, item.containerName); });
result = topDecls.map(decl => { return SymbolInformation.create(decl.name, decl.kind, decl.location.range, 'file:///' + decl.location.file, util.formExternalUri(decl)); });
result = exported.map(ent => { return SymbolInformation.create(ent.name, ent.kind, ent.location.range, 'file:///' + ent.location.file, util.formExternalUri(ent)); });