public bool ProcessProjectItem <TResult>(IPsiSourceFile sourceFile, IFindResultConsumer <TResult> consumer) { try { if (!myDeferredCacheController.CompletedOnce.Value) { return(false); } foreach (var element in myElements) { if (element is IMethod || element is IProperty) { var animationEventUsages = myAnimationEventUsagesContainer.GetEventUsagesFor(sourceFile, element); foreach (var usage in animationEventUsages) { var occurence = new UnityAnimationEventFindResults(sourceFile, element, usage, usage.Location); consumer.Accept(occurence); } var usages = myUnityEventsElementContainer.GetAssetUsagesFor(sourceFile, element); foreach (var findResult in usages) { consumer.Accept(findResult); } } if (element is ITypeElement typeElement) { AddScriptUsages(sourceFile, consumer, typeElement, element); } if (element is IField field) { if (field.Type.GetTypeElement().DerivesFromUnityEvent()) { foreach (var findResult in myUnityEventsElementContainer.GetMethodsForUnityEvent(sourceFile, field)) { consumer.Accept(findResult); } } else { var usages = myAssetInspectorValuesContainer.GetAssetUsagesFor(sourceFile, field); foreach (var findResult in usages) { consumer.Accept(findResult); } } } } } catch (OperationCanceledException) { throw; } catch (Exception e) { ourLogger.Error(e, $"An error occurred while searching assets in: {sourceFile.GetPersistentIdForLogging()}"); } return(false); }