(session: Session, params: GetTcbParams)
| 10 | import {filePathToUri, lspPositionToTsPosition, tsTextSpanToLspRange} from '../utils'; |
| 11 | |
| 12 | export function onGetTcb(session: Session, params: GetTcbParams): GetTcbResponse | null { |
| 13 | const lsInfo = session.getLSAndScriptInfo(params.textDocument); |
| 14 | if (lsInfo === null) { |
| 15 | return null; |
| 16 | } |
| 17 | const {languageService, scriptInfo} = lsInfo; |
| 18 | const offset = lspPositionToTsPosition(scriptInfo, params.position); |
| 19 | const response = languageService.getTcb(scriptInfo.fileName, offset); |
| 20 | if (response === undefined) { |
| 21 | return null; |
| 22 | } |
| 23 | const {fileName: tcfName} = response; |
| 24 | const tcfScriptInfo = session.projectService.getScriptInfo(tcfName); |
| 25 | if (!tcfScriptInfo) { |
| 26 | return null; |
| 27 | } |
| 28 | return { |
| 29 | uri: filePathToUri(tcfName), |
| 30 | content: response.content, |
| 31 | selections: response.selections.map((span) => tsTextSpanToLspRange(tcfScriptInfo, span)), |
| 32 | }; |
| 33 | } |
no test coverage detected