Ejemplo n.º 1
0
        private void AddUniqueValue(MonoBehaviourField field, InspectorVariableUsage variableUsage)
        {
            if (!myUniqueValues.TryGetValue(field, out var oneToCompactCountingSet))
            {
                oneToCompactCountingSet = new OneToCompactCountingSet <IAssetValue, InspectorVariableUsage>();
                myUniqueValues[field]   = oneToCompactCountingSet;
            }

            oneToCompactCountingSet.Add(variableUsage.Value, variableUsage);
        }
        public void Merge(IPsiSourceFile sourceFile, AssetDocumentHierarchyElement assetDocumentHierarchyElement, IUnityAssetDataElement unityAssetDataElement)
        {
            var dataElement = unityAssetDataElement as AssetUsagesDataElement;

            foreach (var assetUsage in dataElement.AssetUsages)
            {
                foreach (var dependency in assetUsage.Dependencies)
                {
                    if (dependency is ExternalReference externalReference)
                    {
                        myAssetUsages.Add(externalReference.ExternalAssetGuid, assetUsage);

                        if (!myAssetUsagesPerFile.TryGetValue(sourceFile, out var set))
                        {
                            set = new OneToCompactCountingSet <string, AssetUsage>();
                            myAssetUsagesPerFile[sourceFile] = set;
                        }

                        set.Add(externalReference.ExternalAssetGuid, assetUsage);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public static bool HasPossibleDerivedTypesWithMember(Guid ownerGuid, ITypeElement containingType, IEnumerable <string> memberNames, OneToCompactCountingSet <int, Guid> nameHashToGuids)
        {
            var count = 0;

            foreach (var possibleName in memberNames)
            {
                var values = nameHashToGuids.GetValues(possibleName.GetPlatformIndependentHashCode());
                count += values.Length;
                if (values.Length == 1 && !values[0].Equals(ownerGuid))
                {
                    count++;
                }
            }

            if (count > 1)
            {
                // TODO: drop daemon dependency and inject compoentns in consructor
                var configuration = containingType.GetSolution().GetComponent <SolutionAnalysisConfiguration>();
                if (configuration.Enabled.Value && configuration.CompletedOnceAfterStart.Value &&
                    configuration.Loaded.Value)
                {
                    var service = containingType.GetSolution().GetComponent <SolutionAnalysisService>();
                    var id      = service.GetElementId(containingType);
                    if (id.HasValue && service.UsageChecker is IGlobalUsageChecker checker)
                    {
                        // no inheritors
                        if (checker.GetDerivedTypeElementsCount(id.Value) == 0)
                        {
                            return(false);
                        }
                    }
                }

                return(true);
            }

            return(false);
        }