import * as vscode from "vscode" ; import { ElementNode , getCurrentNode , XmlTagName } from "../utils/lexerUtils" ; class CodeActionProvider implements vscode . CodeActionProvider { public provideCodeActions ( document , range , _context , _token ) { const documentText = document . getText ( ) ; const cursorOffset = document . offsetAt ( range . start ) ; const currentNode = getCurrentNode ( documentText , cursorOffset ) ; if ( currentNode === undefined || currentNode . contentStart === undefined || currentNode . contentEnd === undefined ) { return undefined ; } if ( currentNode . tag === XmlTagName . Dependencies ) { const addDependencyCommand = { command : "maven.project.addDependency" , title : "Add a dependency from Maven Central Repository..." , arguments : [ { pomPath : document . uri . fsPath } ] } ; return [ addDependencyCommand ] ; } return undefined ; } } export const codeActionProvider = new CodeActionProvider ( ) ;