public UnityEventTargetAtomicRename(ISolution solution, IDeclaredElement declaredElement, string newName) { mySolution = solution; myPointer = declaredElement.CreateElementPointer(); OldName = declaredElement.ShortName; NewName = newName; }
public FormerlySerializedAsAtomicRename(IDeclaredElement declaredElement, string newName, ISettingsStore settingsStore) { myModel = new SerializedFieldRenameModel(settingsStore); myPointer = declaredElement.CreateElementPointer(); OldName = declaredElement.ShortName; NewName = newName; }
public PsiDerivedElementRename(IDeclaredElement declaredElement, [NotNull] string newName, bool doNotShowBindingConflicts) { myOriginalElementPointer = declaredElement.CreateElementPointer(); myNewName = newName; myDoNotShowBindingConflicts = doNotShowBindingConflicts; mySecondaryElements = new List<IDeclaredElementPointer<IDeclaredElement>>(); mySecondaryElements = RenameRefactoringService.Instance.GetRenameService(PsiLanguage.Instance).GetSecondaryElements(declaredElement).Select(x => x.CreateElementPointer()).ToList(); BuildDeclarations(); }
public PsiDerivedElementRename(IDeclaredElement declaredElement, [NotNull] string newName, bool doNotShowBindingConflicts) { myOriginalElementPointer = declaredElement.CreateElementPointer(); myNewName = newName; myDoNotShowBindingConflicts = doNotShowBindingConflicts; mySecondaryElements = new List <IDeclaredElementPointer <IDeclaredElement> >(); mySecondaryElements = RenameRefactoringService.Instance.GetRenameService(PsiLanguage.Instance).GetSecondaryElements(declaredElement).Select(x => x.CreateElementPointer()).ToList(); BuildDeclarations(); }
public FormerlySerializedAsAtomicRename(IDeclaredElement declaredElement, string newName, ISettingsStore settingsStore, KnownTypesCache knownTypesCache, bool isRenameShouldBeSilent) { myKnownTypesCache = knownTypesCache; myIsRenameShouldBeSilent = isRenameShouldBeSilent; myModel = new SerializedFieldRenameModel(settingsStore); myPointer = declaredElement.CreateElementPointer(); OldName = declaredElement.ShortName; NewName = newName; }
public UnityEventSubscriptionOccurrence(IPsiSourceFile sourceFile, IDeclaredElement declaredElement, LocalReference owningElementLocation, bool isPrefabModification) : base(sourceFile, declaredElement.CreateElementPointer(), owningElementLocation, isPrefabModification) { }
public FormerlySerializedAsAtomicRename(IDeclaredElement declaredElement, string newName) { myPointer = declaredElement.CreateElementPointer(); OldName = declaredElement.ShortName; NewName = newName; }
public override void Rename( RenameRefactoring executer, IProgressIndicator pi, bool hasConflictsWithDeclarations, IRefactoringDriver driver) { this.BuildDeclarations(); //Logger.Assert(myDeclarations.Count > 0, "myDeclarations.Count > 0"); IDeclaredElement declaredElement = this.myOriginalElementPointer.FindDeclaredElement(); if (declaredElement == null) { return; } IPsiServices psiServices = declaredElement.GetPsiServices(); IList <IReference> primaryReferences = executer.Workflow.GetElementReferences(this.PrimaryDeclaredElement); List <Pair <IDeclaredElement, IList <IReference> > > secondaryElementWithReferences = this.SecondaryDeclaredElements.Select(x => Pair.Of(x, executer.Workflow.GetElementReferences(x))).ToList(); pi.Start(this.myDeclarations.Count + primaryReferences.Count); foreach (IDeclaration declaration in this.myDeclarations) { InterruptableActivityCookie.CheckAndThrow(pi); declaration.SetName(this.myNewName); pi.Advance(); } psiServices.Caches.Update(); NTriplesCache cache = null; if (this.myDeclarations.Any()) { cache = this.myDeclarations[0].GetSolution().GetComponent <NTriplesCache>(); } foreach (var declaration in this.myDeclarations) { var file = (NTriplesFile)declaration.Root(); file.ClearTables(); //cache.MarkAsDirty(declaration.GetSourceFile()); } /*if (cache != null) * { * cache.SyncUpdate(true); * }*/ IDeclaredElement newDeclaredElement = null; if (this.myDeclarations.Count > 0) { newDeclaredElement = this.myDeclarations[0].DeclaredElement; } Assertion.Assert(newDeclaredElement != null, "The condition (newDeclaredElement != null) is false."); this.myNewElementPointer = newDeclaredElement.CreateElementPointer(); Assertion.Assert(newDeclaredElement.IsValid(), "myNewDeclaredElement.IsValid()"); this.myNewReferences.Clear(); OneToSetMap <PsiLanguageType, IReference> references = LanguageUtil.SortReferences(primaryReferences.Where(x => x.IsValid())); IList <IReference> referencesToRename = new List <IReference>(); foreach (var pair in references) { List <IReference> sortedReferences = pair.Value.ToList(); //LanguageUtil.GetSortedReferences(pair.Value); foreach (IReference reference in sortedReferences) { IReference oldReferenceForConflict = reference; InterruptableActivityCookie.CheckAndThrow(pi); if (reference.IsValid()) // reference may invalidate during additional reference processing { RenameHelperBase rename = executer.Workflow.LanguageSpecific[reference.GetTreeNode().Language]; IReference reference1 = rename.TransformProjectedInitializer(reference); DeclaredElementInstance subst = GetSubst(newDeclaredElement, executer); IReference newReference; if (subst != null) { if (subst.Substitution.Domain.IsEmpty()) { newReference = reference1.BindTo(subst.Element); } else { newReference = reference1.BindTo(subst.Element, subst.Substitution); } } else { newReference = reference1.BindTo(newDeclaredElement); } if (!(newReference is IImplicitReference)) { IDeclaredElement element = newReference.Resolve().DeclaredElement; if (!hasConflictsWithDeclarations && !this.myDoNotShowBindingConflicts && (element == null || !element.Equals(newDeclaredElement)) && !rename.IsAlias(newDeclaredElement)) { driver.AddLateConflict( () => new Conflict( newReference.GetTreeNode().GetSolution(), "Usage {0} can not be updated correctly.", ConflictSeverity.Error, oldReferenceForConflict), "not bound"); } referencesToRename.Add(newReference); } this.myNewReferences.Insert(0, newReference); rename.AdditionalReferenceProcessing(newDeclaredElement, newReference, this.myNewReferences); } pi.Advance(); } } foreach (var pair in secondaryElementWithReferences) { IDeclaredElement element = pair.First; IList <IReference> secondaryReferences = pair.Second; foreach (IReference reference in secondaryReferences) { InterruptableActivityCookie.CheckAndThrow(pi); if (reference.IsValid()) { reference.BindTo(element); } } } }