@@ -185,10 +185,11 @@ private static void addCompiledContainerService(@NotNull Map<String, ContainerSe
185185
186186 ContainerService containerService = services .computeIfAbsent (
187187 entry .getId (),
188- key -> new ContainerService (entry .getId (), entry .getClassName (), false , ! entry . isPublic ( ))
188+ key -> new ContainerService (entry .getId (), entry .getClassName (), toMetadata ( entry , ContainerServiceMetadata . SourceKind . COMPILED_CONTAINER ))
189189 );
190-
191- containerService .addMetadata (toMetadata (entry , ContainerServiceMetadata .SourceKind .COMPILED_CONTAINER ));
190+ if (!containerService .hasSourceKind (ContainerServiceMetadata .SourceKind .COMPILED_CONTAINER )) {
191+ containerService .addMetadata (toMetadata (entry , ContainerServiceMetadata .SourceKind .COMPILED_CONTAINER ));
192+ }
192193 }
193194
194195 @ Nullable
@@ -372,26 +373,17 @@ public Map<String, ContainerService> getServices() {
372373
373374 if (!exps .isEmpty ()) {
374375 exps .forEach (service -> {
375- ContainerService containerService = new ContainerService (service .getId (), service .getClassName (), true , !service .isPublic ());
376- containerService .addMetadata (toMetadata (service , ContainerServiceMetadata .SourceKind .INDEXED_SERVICE ));
377- services .put (service .getId (), containerService );
376+ services .put (
377+ service .getId (),
378+ new ContainerService (service .getId (), service .getClassName (), toMetadata (service , ContainerServiceMetadata .SourceKind .INDEXED_SERVICE ))
379+ );
378380 });
379381 }
380382
381383 for (Map .Entry <String , List <ServiceSerializable >> entry : FileIndexCaches .getSetDataCache (project , SERVICE_CONTAINER_INDEX , SERVICE_CONTAINER_INDEX_NAMES , ServicesDefinitionStubIndex .KEY , ServiceIndexUtil .getRestrictedFileTypesScope (project )).entrySet ()) {
382-
383- // dont work twice on service;
384- // @TODO: to need to optimize this to decorate as much service data as possible
385384 String serviceName = entry .getKey ();
386385
387- // fake empty service, case which is not allowed by catch it
388- List <ServiceSerializable > servicesValues = entry .getValue ();
389- if (services .isEmpty ()) {
390- services .put (serviceName , new ContainerService (serviceName , null , true ));
391- continue ;
392- }
393-
394- for (ServiceInterface service : servicesValues ) {
386+ for (ServiceInterface service : entry .getValue ()) {
395387 String classValue = service .getClassName ();
396388
397389 // duplicate services
@@ -403,13 +395,11 @@ public Map<String, ContainerService> getServices() {
403395 continue ;
404396 }
405397
406- String classValueResolve = classValue ;
407398 String compiledClassName = containerService .getClassName ();
408399 if (!classValue .equalsIgnoreCase (compiledClassName )) {
409400 String resolvedClassValue = getParameterCollector ().resolve (classValue );
410401 if (resolvedClassValue != null && !StringUtils .isBlank (classValue ) && !resolvedClassValue .equalsIgnoreCase (compiledClassName )) {
411402 containerService .addClassName (resolvedClassValue );
412- classValueResolve = resolvedClassValue ;
413403 }
414404 }
415405
@@ -430,9 +420,10 @@ public Map<String, ContainerService> getServices() {
430420 classValue = getParameterCollector ().resolve (classValue );
431421 }
432422
433- ContainerService indexedService = new ContainerService (service .getId (), classValue , true , !service .isPublic ());
434- indexedService .addMetadata (toMetadata (service , ContainerServiceMetadata .SourceKind .INDEXED_SERVICE ));
435- services .put (serviceName , indexedService );
423+ services .put (
424+ serviceName ,
425+ new ContainerService (service .getId (), classValue , toMetadata (service , ContainerServiceMetadata .SourceKind .INDEXED_SERVICE ))
426+ );
436427 }
437428 }
438429
@@ -493,8 +484,7 @@ private Map<String, ContainerService> collectDecorated(@NotNull Collection<Servi
493484 continue ;
494485 }
495486
496- // @TODO: migrate constructor to ServiceInterface and decorate
497- ContainerService value = new ContainerService (decorationInnerName , origin .getClassName (), origin .isWeak (), true );
487+ ContainerService value = new ContainerService (decorationInnerName , origin .getClassName (), ContainerServiceMetadata .empty (ContainerServiceMetadata .SourceKind .INDEXED_SERVICE ));
498488 origin .getClassNames ().forEach (value ::addClassName );
499489
500490 items .put (decorationInnerName , value );
@@ -585,9 +575,7 @@ public static ServiceCollector create(@NotNull Project project) {
585575
586576 @ NotNull
587577 private static ContainerService toContainerService (@ NotNull ResourceBasedService service ) {
588- ContainerService containerService = new ContainerService (service .id (), service .className (), true );
589- containerService .addMetadata (service .metadata ());
590- return containerService ;
578+ return new ContainerService (service .id (), service .className (), service .metadata ());
591579 }
592580 }
593581
0 commit comments