license import * as monacoEditor from "monaco-editor" ; import Commands from "./Commands" ; /**
 * Provides codelens shortcuts for lilypond.
 */ export default class CodelensProvider implements monacoEditor . languages . CodeLensProvider { commands : Commands ; constructor ( commands ) { this . commands = commands ; } provideCodeLenses = ( model , _token ) : monacoEditor . languages . ICodeLensSymbol [ ] => { const lines = model . getLinesContent ( ) ; type sym = monacoEditor . languages . ICodeLensSymbol ; return lines . reduce ( ( memos , line , i ) : sym [ ] => { let memo = memos ; if ( line . indexOf ( "\\clef" ) !== - 1 ) { memo = [ ... memo , { command : { arguments : [ i ] , id : this . commands . setClef , title : "Tool: Change Clef" , } , range : { endColumn : 1 , endLineNumber : i + 2 , startColumn : 1 , startLineNumber : i + 1 , } , } , ] ; } if ( line . indexOf ( "\\key" ) !== - 1 ) { memo = [ ... memo , { command : { arguments : [ i ] , id : this . commands . setKey , title : "Tool: Change Key Signature" , } , range : { endColumn : 1 , endLineNumber : i + 2 , startColumn : 1 , startLineNumber : i + 1 , } , } , ] ; } if ( line . indexOf ( "\\time" ) !== - 1 ) { memo = [ ... memo , { command : { arguments : [ i ] , id : this . commands . setTime , title : "Tool: Change Time Signature" , } , range : { endColumn : 1 , endLineNumber : i + 2 , startColumn : 1 , startLineNumber : i + 1 , } , } , ] ; } if ( line . indexOf ( "\\relative" ) !== - 1 ) { memo = [ ... memo , { command : { arguments : [ i ] , id : this . commands . insertNotes , title : "Tool: Insert Notes" , } , range : { endColumn : 1 , endLineNumber : i + 2 , startColumn : 1 , startLineNumber : i + 1 , } , } , ] ; } return memo ; } , [ ] ) ; } ; resolveCodeLens = ( _model , codeLens , _token ) : monacoEditor . languages . ICodeLensSymbol => { return codeLens ; } ; }