public void Drop(IPsiSourceFile sourceFile, AssetDocumentHierarchyElement assetDocumentHierarchyElement, IUnityAssetDataElement unityAssetDataElement)
        {
            var element = unityAssetDataElement as AssetMethodsDataElement;

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

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

            myPsiSourceFileToMethods.Remove(sourceFile);
        }
예제 #2
0
        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 Drop(IPsiSourceFile currentAssetSourceFile, AssetDocumentHierarchyElement assetDocumentHierarchyElement, IUnityAssetDataElement unityAssetDataElement)
        {
            var element = unityAssetDataElement as AssetInspectorValuesDataElement;
            var usages  = element.VariableUsages;

            // inverted order is matter for Remove/AddUniqueValue
            for (int i = usages.Count - 1; i >= 0; i--)
            {
                var variableUsage   = usages[i];
                var scriptReference = variableUsage.ScriptReference;
                var guid            = scriptReference.ExternalAssetGuid;

                myNameToSourceFile.Remove(variableUsage.Name, currentAssetSourceFile);
                var mbField = new MonoBehaviourField(guid, variableUsage.Name.GetPlatformIndependentHashCode());

                RemoveUniqueValue(mbField, variableUsage);
                myChangesInFiles.Remove(mbField, currentAssetSourceFile);
                RemoveChangesPerFile(new MonoBehaviourField(guid, variableUsage.Name.GetPlatformIndependentHashCode(), currentAssetSourceFile), variableUsage);

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

            foreach (var(reference, _) in element.ImportedInspectorValues.Modifications)
            {
                myNamesInPrefabModifications.Remove(reference.Name);
            }

            myPointers.Remove(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);
            }
        }
예제 #5
0
        public void Drop(IPsiSourceFile currentAssetSourceFile, AssetDocumentHierarchyElement assetDocumentHierarchyElement, IUnityAssetDataElement unityAssetDataElement)
        {
            var dataElement = unityAssetDataElement as AssetUsagesDataElement;

            foreach (var assetUsagePointer in dataElement.EnumerateAssetUsages())
            {
                var guid = assetUsagePointer.UsageTarget.ExternalAssetGuid;
                myUsagesCount.Remove(guid);
                myUsageToSourceFiles.Remove(guid, currentAssetSourceFile);
            }

            myPointers.Remove(currentAssetSourceFile);
        }
예제 #6
0
        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 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);
        }
예제 #8
0
        private void RemoveScenes(ProjectSettingsCacheItem.ProjectSettingsSceneData sceneData)
        {
            foreach (var name in sceneData.SceneNamesFromBuildSettings)
            {
                myLocalCache.Scenes.SceneNamesFromBuildSettings.Remove(name);
                myShortNameAtBuildSettings.Remove(GetShortNameForSceneName(name));
            }

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

            foreach (var name in sceneData.SceneNames)
            {
                myLocalCache.Scenes.SceneNames.Remove(name);
                myShortNameAll.Remove(GetShortNameForSceneName(name));
            }
        }
예제 #9
0
        private void DropPrefabModifications(IPsiSourceFile sourceFile, UnityEventsDataElement element)
        {
            foreach (var(unityEvent, _) in element.ImportedUnityEventData.UnityEventToModifiedIndex)
            {
                myUnityEventsWithModifications.Remove(unityEvent.EventName);
                myUnityEventNameToSourceFiles.Remove(unityEvent.EventName, sourceFile);
            }

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

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

            myImportedUnityEventDatas.Remove(sourceFile);
        }