(connection: Connection, documents: TextDocuments<AlphaTexTextDocument>)
| 25 | } from '@coderline/alphatab-language-server/server/utils'; |
| 26 | |
| 27 | export function setupHover(connection: Connection, documents: TextDocuments<AlphaTexTextDocument>) { |
| 28 | connection.onHover(params => { |
| 29 | const document = documents.get(params.textDocument.uri); |
| 30 | if (!document?.ast) { |
| 31 | return null; |
| 32 | } |
| 33 | |
| 34 | const offset = document.offsetAt(params.position); |
| 35 | |
| 36 | // lookup bar at location |
| 37 | const bar = binaryNodeSearch(document.ast.bars, offset); |
| 38 | if (!bar) { |
| 39 | return null; |
| 40 | } |
| 41 | |
| 42 | const metaData = binaryNodeSearch(bar.metaData, offset); |
| 43 | if (metaData) { |
| 44 | return createMetaDataHover(metaData, offset); |
| 45 | } |
| 46 | |
| 47 | const beat = binaryNodeSearch(bar.beats, offset); |
| 48 | if (beat) { |
| 49 | return createBeatHover(beat, offset); |
| 50 | } |
| 51 | |
| 52 | return null; |
| 53 | }); |
| 54 | } |
| 55 | |
| 56 | function createMetaDataHover(metaData: alphaTab.importer.alphaTex.AlphaTexMetaDataNode, offset: number): Hover | null { |
| 57 | const metaDataDocs = allMetadata.get(`\\${metaData.tag.tag.text.toLowerCase()}`); |
no test coverage detected