@@ -59,6 +59,11 @@ class Indexer
5959 */
6060 private $ composerLock ;
6161
62+ /**
63+ * @var \stdClasss
64+ */
65+ private $ composerJson ;
66+
6267 /**
6368 * @param FilesFinder $filesFinder
6469 * @param string $rootPath
@@ -77,7 +82,8 @@ public function __construct(
7782 DependenciesIndex $ dependenciesIndex ,
7883 Index $ sourceIndex ,
7984 PhpDocumentLoader $ documentLoader ,
80- \stdClass $ composerLock = null
85+ \stdClass $ composerLock = null ,
86+ \stdClass $ composerJson = null
8187 ) {
8288 $ this ->filesFinder = $ filesFinder ;
8389 $ this ->rootPath = $ rootPath ;
@@ -87,6 +93,7 @@ public function __construct(
8793 $ this ->sourceIndex = $ sourceIndex ;
8894 $ this ->documentLoader = $ documentLoader ;
8995 $ this ->composerLock = $ composerLock ;
96+ $ this ->composerJson = $ composerJson ;
9097 }
9198
9299 /**
@@ -109,10 +116,11 @@ public function index(): Promise
109116 $ source = [];
110117 /** @var string[][] */
111118 $ deps = [];
119+
112120 foreach ($ uris as $ uri ) {
113- if ($ this ->composerLock !== null && preg_match ('/\/vendor\/([^\/]+\/[^\/]+)\// ' , $ uri , $ matches )) {
121+ $ packageName = getPackageName ($ uri , $ this ->composerJson );
122+ if ($ this ->composerLock !== null && $ packageName ) {
114123 // Dependency file
115- $ packageName = $ matches [1 ];
116124 if (!isset ($ deps [$ packageName ])) {
117125 $ deps [$ packageName ] = [];
118126 }
@@ -174,6 +182,8 @@ public function index(): Promise
174182 if ($ cacheKey !== null ) {
175183 $ this ->client ->window ->logMessage (MessageType::INFO , "Storing $ packageKey in cache " );
176184 $ this ->cache ->set ($ cacheKey , $ index );
185+ } else {
186+ $ this ->client ->window ->logMessage (MessageType::WARNING , "Could not compute cache key for $ packageName " );
177187 }
178188 }
179189 }
@@ -205,7 +215,7 @@ private function indexFiles(array $files): Promise
205215 $ this ->client ->window ->logMessage (MessageType::LOG , "Parsing $ uri " );
206216 try {
207217 $ document = yield $ this ->documentLoader ->load ($ uri );
208- if (!$ document-> isVendored ( )) {
218+ if (!isVendored ( $ document, $ this -> composerJson )) {
209219 $ this ->client ->textDocument ->publishDiagnostics ($ uri , $ document ->getDiagnostics ());
210220 }
211221 } catch (ContentTooLargeException $ e ) {
0 commit comments