public void Merge(IPsiSourceFile sourceFile, AssetDocumentHierarchyElement assetDocumentHierarchyElement, IUnityAssetDataElement unityAssetDataElement)
        {
            var element      = (unityAssetDataElement as AssetMethodsDataElement).NotNull("element != null");
            var groupMethods = new OneToListMap <string, AssetMethodData>();

            foreach (var method in element.Methods)
            {
                myShortNameToScriptTarget.Add(method.MethodName, method);
                groupMethods.Add(method.MethodName, method);

                if (method.TargetScriptReference is ExternalReference)
                {
                    myExternalCount.Add(method.MethodName);
                }
                else if (method.TargetScriptReference is LocalReference localReference)
                {
                    if (assetDocumentHierarchyElement.GetHierarchyElement(null, localReference.LocalDocumentAnchor, null) is IScriptComponentHierarchy script)
                    {
                        if (script.IsStripped)
                        {
                            myExternalCount.Add(method.MethodName);
                        }
                        else
                        {
                            myLocalUsages.Add(method.MethodName, new AssetMethodData(LocalReference.Null,
                                                                                     method.MethodName, TextRange.InvalidRange,
                                                                                     method.Mode, method.Type, script.ScriptReference));
                        }
                    }
                }
            }

            myPsiSourceFileToMethods.Add(sourceFile, groupMethods);
        }
        public void RemoveItem_TheSameItemWasAddedTwice_CollectionStillContainsItem()
        {
            CountingSet <object> coll = new CountingSet <object>();

            object item = new object();

            coll.Add(item);
            coll.Add(item);

            coll.Remove(item);

            Assert.IsTrue(coll.Contains(item));
        }
        public void RemoveItemTwice_TheSameItemWasAddedTwice_CollectionDoesntContainItem()
        {
            CountingSet <object> coll = new CountingSet <object>();

            object item = new object();

            coll.Add(item);
            coll.Add(item);

            coll.Remove(item);
            coll.Remove(item);

            Assert.IsFalse(coll.Contains(item));
        }
        public void Merge(IPsiSourceFile currentAssetSourceFile, AssetDocumentHierarchyElement assetDocumentHierarchyElement, IUnityAssetDataElementPointer unityAssetDataElementPointer, IUnityAssetDataElement unityAssetDataElement)
        {
            myPointers[currentAssetSourceFile] = unityAssetDataElementPointer;

            var element = unityAssetDataElement as AssetInspectorValuesDataElement;


            foreach (var variableUsage in element.VariableUsages)
            {
                var scriptReference = variableUsage.ScriptReference;
                var guid            = scriptReference.ExternalAssetGuid;

                myNameToSourceFile.Add(variableUsage.Name, currentAssetSourceFile);

                var mbField = new MonoBehaviourField(guid, variableUsage.Name.GetPlatformIndependentHashCode());
                AddUniqueValue(mbField, variableUsage);
                myChangesInFiles.Add(mbField, currentAssetSourceFile);
                AddChangesPerFile(new MonoBehaviourField(guid, variableUsage.Name.GetPlatformIndependentHashCode(), currentAssetSourceFile), variableUsage);

                myNameHashToGuids.Add(variableUsage.Name.GetPlatformIndependentHashCode(), scriptReference.ExternalAssetGuid);
            }

            foreach (var(reference, _) in element.ImportedInspectorValues.Modifications)
            {
                myNamesInPrefabModifications.Add(reference.Name);
                myNameToSourceFile.Add(reference.Name, currentAssetSourceFile);
            }
        }
        private void RemoveChangesPerFile(MonoBehaviourField monoBehaviourField, InspectorVariableUsage variableUsage)
        {
            var beforeRemoveDifferentValuesCount = myValueCountPerPropertyAndFile.GetOrEmpty(monoBehaviourField).Count;

            myValueCountPerPropertyAndFile.Remove(monoBehaviourField, variableUsage.Value.GetHashCode());
            var afterRemoveDifferentValuesCount = myValueCountPerPropertyAndFile.GetOrEmpty(monoBehaviourField).Count;

            if (beforeRemoveDifferentValuesCount == 2 && afterRemoveDifferentValuesCount == 1)
            {
                var uniqueValue    = myValueCountPerPropertyAndFile.GetOrEmpty(monoBehaviourField).First().Key;
                var fieldWithValue = new MonoBehaviourFieldWithValue(new MonoBehaviourField(monoBehaviourField.ScriptGuid, monoBehaviourField.NameHash), uniqueValue);
                myValuesWhichAreUniqueInWholeFile.Add(fieldWithValue);
            }
            else if (beforeRemoveDifferentValuesCount == 1 && afterRemoveDifferentValuesCount == 0)
            {
                var fieldWithValue = new MonoBehaviourFieldWithValue(new MonoBehaviourField(monoBehaviourField.ScriptGuid, monoBehaviourField.NameHash), variableUsage.Value.GetHashCode());
                myValuesWhichAreUniqueInWholeFile.Remove(fieldWithValue);
            }
        }
Esempio n. 6
0
        public void Merge(IPsiSourceFile currentAssetSourceFile, AssetDocumentHierarchyElement assetDocumentHierarchyElement, IUnityAssetDataElementPointer unityAssetDataElementPointer, IUnityAssetDataElement unityAssetDataElement)
        {
            myPointers[currentAssetSourceFile] = unityAssetDataElementPointer;
            var dataElement = unityAssetDataElement as AssetUsagesDataElement;

            foreach (var assetUsagePointer in dataElement.EnumerateAssetUsages())
            {
                var guid = assetUsagePointer.UsageTarget.ExternalAssetGuid;
                myUsagesCount.Add(guid);
                myUsageToSourceFiles.Add(guid, currentAssetSourceFile);
            }
        }
        public void Add(MonoBehaviourProperty property, MonoBehaviourPropertyValueWithLocation valueWithLocation)
        {
            var value = valueWithLocation.Value.Value;

            if (value != null)
            {
                myUniquePropertyValues.Add(property, new MonoBehaviorPropertyValueBox(valueWithLocation));

                // file changes index
                var query = new MonoBehaviourPropertyWithFile(property, valueWithLocation.File);
                var beforeAddDifferentValuesCount = myValueCountPerPropertyAndFile.GetOrEmpty(query).Count;

                if (beforeAddDifferentValuesCount == 0)
                {
                    myValueCountPerPropertyAndFile.Add(query, value);

                    myValuesWhichAreUniqueInWholeFile.Add(new MonoBehaviourPropertyWithValue(property, value));
                }
                else if (beforeAddDifferentValuesCount == 1)
                {
                    var previousValue = myValueCountPerPropertyAndFile.GetOrEmpty(query).First().Key;
                    myValueCountPerPropertyAndFile.Add(query, value);
                    var afterAddDifferentValuesCount = myValueCountPerPropertyAndFile.GetOrEmpty(query).Count;
                    if (afterAddDifferentValuesCount == 2)
                    {
                        myValuesWhichAreUniqueInWholeFile.Remove(new MonoBehaviourPropertyWithValue(property, previousValue));
                    }
                }
                else
                {
                    myValueCountPerPropertyAndFile.Add(query, value);
                }

                myPropertyFiles.Add(property, valueWithLocation.File);
            }

            myPropertyValues.Add(property, valueWithLocation);
        }
Esempio n. 8
0
        private void AddScenes(ProjectSettingsCacheItem.ProjectSettingsSceneData sceneData)
        {
            foreach (var name in sceneData.SceneNamesFromBuildSettings)
            {
                myLocalCache.Scenes.SceneNamesFromBuildSettings.Add(name);
                myShortNameAtBuildSettings.Add(GetShortNameForSceneName(name));
            }

            foreach (var name in sceneData.DisabledSceneNamesFromBuildSettings)
            {
                myLocalCache.Scenes.DisabledSceneNamesFromBuildSettings.Add(name);
                myDisabledShortNameAtBuildSettings.Add(GetShortNameForSceneName(name));
            }

            foreach (var name in sceneData.SceneNames)
            {
                myLocalCache.Scenes.SceneNames.Add(name);
                myShortNameAll.Add(GetShortNameForSceneName(name));
            }
        }
Esempio n. 9
0
        private void MergePrefabModifications(IPsiSourceFile sourceFile, UnityEventsDataElement element)
        {
            foreach (var(unityEvent, _) in element.ImportedUnityEventData.UnityEventToModifiedIndex)
            {
                myUnityEventsWithModifications.Add(unityEvent.EventName);
                myUnityEventNameToSourceFiles.Add(unityEvent.EventName, sourceFile);
            }

            foreach (var assetMethodNameInModification in element.ImportedUnityEventData.AssetMethodNameInModifications)
            {
                myMethodNameToFilesWithPossibleUsages.Add(assetMethodNameInModification, sourceFile);
            }

            if (element.ImportedUnityEventData.HasEventModificationWithoutMethodName)
            {
                myFilesToCheckForUsages.Add(sourceFile);
            }

            myImportedUnityEventDatas.Add(sourceFile, element.ImportedUnityEventData);
        }
        private static IUnsafeMarshaller <CountingSet <string> > CreateMarshaller()
        {
            return(new UniversalMarshaller <CountingSet <string> >(reader =>
            {
                var count = reader.ReadInt32();
                var set = new CountingSet <string>(count);
                for (int i = 0; i < count; i++)
                {
                    set.Add(reader.ReadString(), reader.ReadInt32());
                }

                return set;
            },
                                                                   (writer, value) =>
            {
                writer.Write(value.Count);
                foreach (var(item, count) in value)
                {
                    writer.Write(item);
                    writer.Write(count);
                }
            }));