public bool ProcessProjectItem <TResult>(IPsiSourceFile sourceFile, IFindResultConsumer <TResult> consumer) { if (!myDeferredCacheController.CompletedOnce.Value) { return(false); } foreach (var element in myElements) { if (element is IMethod || element is IProperty) { var usages = myAssetMethodsElementContainer.GetAssetUsagesFor(sourceFile, element); foreach (var assetMethodData in usages) { var hierarchyElement = myAssetDocumentHierarchyElementContainer.GetHierarchyElement(assetMethodData.Location, false); if (hierarchyElement != null) { consumer.Accept(new UnityMethodsFindResult(sourceFile, element, assetMethodData, hierarchyElement)); } } } if (element is ITypeElement typeElement) { var usages = myAssetUsagesElementContainer.GetAssetUsagesFor(sourceFile, typeElement); foreach (var assetUsage in usages) { var hierarchyElement = myAssetDocumentHierarchyElementContainer.GetHierarchyElement(assetUsage.Location, false); if (hierarchyElement == null) { continue; } consumer.Accept(new UnityScriptsFindResults(sourceFile, element, assetUsage, hierarchyElement)); } } if (element is IField field) { var usages = myAssetInspectorValuesContainer.GetAssetUsagesFor(sourceFile, field); foreach (var assetUsage in usages) { var hierarchyElement = myAssetDocumentHierarchyElementContainer.GetHierarchyElement(assetUsage.Location, false); if (hierarchyElement == null) { continue; } consumer.Accept(new UnityInspectorFindResults(sourceFile, element, assetUsage, hierarchyElement)); } } } return(false); }
public bool ProcessProjectItem <TResult>(IPsiSourceFile sourceFile, IFindResultConsumer <TResult> consumer) { if (!myDeferredCacheController.CompletedOnce.Value) { return(false); } foreach (var element in myElements) { if (element is IMethod || element is IProperty) { var usages = myUnityEventsElementContainer.GetAssetUsagesFor(sourceFile, element); foreach (var findResult in usages) { consumer.Accept(findResult); } } if (element is ITypeElement typeElement) { var usages = myAssetScriptUsagesElementContainer.GetAssetUsagesFor(sourceFile, typeElement); foreach (var assetUsage in usages) { consumer.Accept(new UnityScriptsFindResults(sourceFile, element, assetUsage, assetUsage.Location)); } } if (element is IField field) { if (UnityApi.IsDescendantOfUnityEvent(field.Type.GetTypeElement())) { 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); } } } } return(false); }
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); }