import * as vscode from 'vscode' ; import { ExtensionComponent } from '../extensionComponent' ; import { DependenciesTreeNode } from '../treeDataProviders/dependenciesTree/dependenciesTreeNode' ; import { TreesManager } from '../treeDataProviders/treesManager' ; import { PypiUtils } from '../utils/pypiUtils' ; import { AbstractCodeActionProvider } from './abstractCodeActionProvider' ; export class PypiCodeActionProvider extends AbstractCodeActionProvider implements ExtensionComponent { constructor ( diagnosticCollection , treesManager ) { super ( PypiUtils . DOCUMENT_SELECTOR , diagnosticCollection , treesManager ) ; } @override  protected getDependenciesTree ( ) { return this . _treesManager . dependenciesTreeDataProvider . getDependenciesTreeNode ( PypiUtils . PKG_TYPE ) ; } @override  public updateDiagnostics ( document ) { if ( ! vscode . languages . match ( this . _documentSelector , document ) ) { return ; } let diagnostics = [ ] ; let pyPiDependenciesTree = this . getDependenciesTree ( ) ; if ( ! pyPiDependenciesTree ) { return ; } let requirementsContent = document . getText ( ) . toLowerCase ( ) ; pyPiDependenciesTree . children . forEach ( child => { let dependencyPos = PypiUtils . getDependencyPos ( document , requirementsContent , child ) ; if ( dependencyPos . length > 0 ) { this . addDiagnostic ( diagnostics , child , dependencyPos ) ; return ; } for ( let grandChild of child . children ) { dependencyPos = PypiUtils . getDependencyPos ( document , requirementsContent , grandChild ) ; if ( dependencyPos . length > 0 ) { this . addDiagnostic ( diagnostics , grandChild , dependencyPos ) ; } } } ) ; this . _diagnosticCollection . set ( document . uri , diagnostics ) ; } }