import * as path from 'path' ; import * as vscode from 'vscode' ; import { ExtensionComponent } from '../extensionComponent' ; import { FocusType } from '../focus/abstractFocus' ; import { DependenciesTreeNode } from '../treeDataProviders/dependenciesTree/dependenciesTreeNode' ; import { TreesManager } from '../treeDataProviders/treesManager' ; import { NpmUtils } from '../utils/npmUtils' ; import { AbstractCodeActionProvider } from './abstractCodeActionProvider' ; export class NpmCodeActionProvider extends AbstractCodeActionProvider implements ExtensionComponent { constructor ( diagnosticCollection , treesManager ) { super ( NpmUtils . DOCUMENT_SELECTOR , diagnosticCollection , treesManager ) ; } @override  protected getDependenciesTree ( document ? ) { return this . _treesManager . dependenciesTreeDataProvider . getDependenciesTreeNode ( NpmUtils . PKG_TYPE , document ? path . dirname ( document . uri . fsPath ) : document ) ; } @override  public updateDiagnostics ( document ) { if ( ! vscode . languages . match ( this . _documentSelector , document ) ) { return ; } let diagnostics = [ ] ; let npmDependenciesTree = this . getDependenciesTree ( document ) ; if ( ! npmDependenciesTree ) { return ; } npmDependenciesTree . children . forEach ( child => { let dependencyPos = NpmUtils . getDependencyPos ( document , child , FocusType . Dependency ) ; if ( dependencyPos . length === 0 ) { return ; } this . addDiagnostic ( diagnostics , child , dependencyPos ) ; } ) ; this . _diagnosticCollection . set ( document . uri , diagnostics ) ; } }