public UnityAnimationEventOccurence([NotNull] IPsiSourceFile sourceFile, [NotNull] IDeclaredElementPointer <IDeclaredElement> declaredElement, [NotNull] AnimationUsage usage) : base(sourceFile, declaredElement, usage.Location, false) { Usage = usage; }
protected UnityAssetOccurrence(IPsiSourceFile sourceFile, IDeclaredElementPointer <IDeclaredElement> declaredElement, IHierarchyElement attachedElement) { SourceFile = sourceFile; AttachedElementLocation = attachedElement.Location; PresentationOptions = OccurrencePresentationOptions.DefaultOptions; DeclaredElementPointer = declaredElement; }
public UnityEventTargetAtomicRename(ISolution solution, IDeclaredElement declaredElement, string newName) { mySolution = solution; myPointer = declaredElement.CreateElementPointer(); OldName = declaredElement.ShortName; NewName = newName; }
public override bool Navigate(ISolution solution, IDeclaredElementPointer <IDeclaredElement> pointer, LocalReference location) { if (!solution.GetComponent <BackendUnityHost>().IsConnectionEstablished()) { var textControl = solution.GetComponent <TextControlManager>().LastFocusedTextControl.Value; if (textControl == null) { return(true); } var tooltipManager = solution.GetComponent <ITooltipManager>(); tooltipManager.Show("Start the Unity Editor to view results", new PopupWindowContextSource(lifetime => textControl.PopupWindowContextFactory.CreatePopupWindowContext(lifetime))); return(true); } var findRequestCreator = solution.GetComponent <UnityEditorFindUsageResultCreator>(); var declaredElement = pointer.FindDeclaredElement(); if (declaredElement == null) { return(true); } findRequestCreator.CreateRequestToUnity(declaredElement, location, true); return(false); }
protected UnityAssetOccurrence(IPsiSourceFile sourceFile, IDeclaredElementPointer <IDeclaredElement> declaredElement, LocalReference owningElementLocation, bool isPrefabModification) { SourceFile = sourceFile; OwningElementLocation = owningElementLocation; PresentationOptions = OccurrencePresentationOptions.DefaultOptions; DeclaredElementPointer = declaredElement; IsPrefabModification = isPrefabModification; }
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 override void Rename(IRenameRefactoring executer, IProgressIndicator pi, bool hasConflictsWithDeclarations, IRefactoringDriver driver) { // Rename the "declaration" var declaredElement = myPointer.FindDeclaredElement(); var originalTreeNode = declaredElement?.GetTreeNode(); if (originalTreeNode == null) { return; } var originalRange = originalTreeNode.GetDocumentRange(); var factory = JavaScriptElementFactory.GetInstance(originalTreeNode); var literalExpression = factory.CreateExpression("\"$0\"", NewName); var newExpression = originalTreeNode.ReplaceBy(literalExpression); RemoveFromTextualOccurrences(executer, originalRange); var references = executer.Workflow.GetElementReferences(declaredElement); if (!Enumerable.Any(references)) { return; } pi.Start(references.Count); // Create a new declared element (other implementations don't appear to cache this, either) var element = new AsmDefNameDeclaredElement(declaredElement.GetJsServices(), NewName, declaredElement.SourceFile, newExpression.GetTreeStartOffset().Offset); // Rename/bind the references foreach (var pair in LanguageUtil.SortReferences(references.Where(r => r.IsValid()))) { foreach (var sortedReference in LanguageUtil.GetSortedReferences(pair.Value)) { InterruptableActivityCookie.CheckAndThrow(pi); var referenceRange = sortedReference.GetDocumentRange(); if (sortedReference.IsValid()) { sortedReference.BindTo(element); } RemoveFromTextualOccurrences(executer, referenceRange); pi.Advance(); } } element.GetPsiServices().Caches.Update(); myNewPointer = element.CreateElementPointer(); }
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 override bool Initialize(IDataContext context) { _solution = context.GetData(JetBrains.ProjectModel.DataContext.DataConstants.SOLUTION); _page = new AddDependencyPage( s => _parameterType = s, context.GetData(JetBrains.ProjectModel.DataContext.DataConstants.SOLUTION)); var @class = GetClass(context); _class = @class.CreateElementPointer(); var ctor = @class.Constructors.FirstOrDefault(); if (ctor != null) { _ctor = ctor.CreateElementPointer(); } return(true); }
public UnityAnimatorScriptOccurence([NotNull] IPsiSourceFile sourceFile, [NotNull] IDeclaredElementPointer <IDeclaredElement> declaredElement, [NotNull] IAnimatorScriptUsage usage) : base(sourceFile, declaredElement, usage.Location, false) { Usage = usage; var container = GetSolution() .NotNull("occurrence.GetSolution() != null") .GetComponent <AnimatorScriptUsagesElementContainer>(); Container = container; var element = declaredElement.FindDeclaredElement(); if (element is null) { return; } var location = Usage.Location; container.GetElementsNames(location, element, out _, out var isStateMachine); IconId = isStateMachine ? UnityObjectTypeThemedIcons.UsageAnimatorStateMachine.Id : UnityObjectTypeThemedIcons.UsageAnimatorState.Id; }
public UnityInspectorValuesOccurrence(IPsiSourceFile sourceFile, InspectorVariableUsage inspectorVariableUsage, IDeclaredElementPointer <IDeclaredElement> declaredElement, IHierarchyElement attachedElement) : base(sourceFile, declaredElement, attachedElement) { InspectorVariableUsage = inspectorVariableUsage; }
public UnityScriptsOccurrence(IPsiSourceFile sourceFile, IDeclaredElementPointer <IDeclaredElement> declaredElement, IHierarchyElement attachedElement, string guid) : base(sourceFile, declaredElement, attachedElement) { myGuid = guid; }
public AsmDefNameAtomicRename(AsmDefNameDeclaredElement declaredElement, string newName) { myPointer = declaredElement.CreateElementPointer(); NewName = newName; OldName = declaredElement.ShortName; }
public UnityEventHandlerOccurrence(IPsiSourceFile sourceFile, IDeclaredElementPointer <IDeclaredElement> declaredElement, LocalReference owningElementLocation, AssetMethodUsages methodUsages, bool isPrefabModification) : base(sourceFile, declaredElement, owningElementLocation, isPrefabModification) { MethodUsages = methodUsages; }
public override void Rename(RenameRefactoring executer, IProgressIndicator pi, bool hasConflictsWithDeclarations, IRefactoringDriver driver) { BuildDeclarations(); //Logger.Assert(myDeclarations.Count > 0, "myDeclarations.Count > 0"); IDeclaredElement declaredElement = myOriginalElementPointer.FindDeclaredElement(); if (declaredElement == null) { return; } IPsiServices psiServices = declaredElement.GetPsiServices(); IList<IReference> primaryReferences = executer.Workflow.GetElementReferences(PrimaryDeclaredElement); List<Pair<IDeclaredElement, IList<IReference>>> secondaryElementWithReferences = SecondaryDeclaredElements.Select(x => Pair.Of(x, executer.Workflow.GetElementReferences(x))).ToList(); pi.Start(myDeclarations.Count + primaryReferences.Count); foreach (IDeclaration declaration in myDeclarations) { InterruptableActivityCookie.CheckAndThrow(pi); declaration.SetName(myNewName); pi.Advance(); } psiServices.PsiManager.UpdateCaches(); IDeclaredElement newDeclaredElement = null; if (myDeclarations.Count > 0) { newDeclaredElement = myDeclarations[0].DeclaredElement; } Assertion.Assert(newDeclaredElement != null, "The condition (newDeclaredElement != null) is false."); myNewElementPointer = newDeclaredElement.CreateElementPointer(); Assertion.Assert(newDeclaredElement.IsValid(), "myNewDeclaredElement.IsValid()"); 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 = 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 && !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); } myNewReferences.Insert(0, newReference); rename.AdditionalReferenceProcessing(newDeclaredElement, newReference, 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); } } } }
public UnityInspectorValuesOccurrence(IPsiSourceFile sourceFile, InspectorVariableUsage inspectorVariableUsage, IDeclaredElementPointer <IDeclaredElement> declaredElement, LocalReference owningElementLocation, bool isPrefabModification) : base(sourceFile, declaredElement, owningElementLocation, isPrefabModification) { InspectorVariableUsage = inspectorVariableUsage; }
public override void Rename(IRenameRefactoring executer, IProgressIndicator pi, bool hasConflictsWithDeclarations, IRefactoringDriver driver) { BuildDeclarations(); //Logger.Assert(myDeclarations.Count > 0, "myDeclarations.Count > 0"); IDeclaredElement declaredElement = myOriginalElementPointer.FindDeclaredElement(); if (declaredElement == null) { return; } IPsiServices psiServices = declaredElement.GetPsiServices(); IList <IReference> primaryReferences = executer.Workflow.GetElementReferences(PrimaryDeclaredElement); List <Pair <IDeclaredElement, IList <IReference> > > secondaryElementWithReferences = SecondaryDeclaredElements.Select(x => Pair.Of(x, executer.Workflow.GetElementReferences(x))).ToList(); pi.Start(myDeclarations.Count + primaryReferences.Count); foreach (IDeclaration declaration in myDeclarations) { InterruptableActivityCookie.CheckAndThrow(pi); declaration.SetName(myNewName); pi.Advance(); } psiServices.Caches.Update(); IDeclaredElement newDeclaredElement; if (myDeclarations.Count > 0) { newDeclaredElement = myDeclarations[0].DeclaredElement; } else { if (myElement is RoleDeclaredElement) { newDeclaredElement = myElement; ((RoleDeclaredElement)myElement).ChangeName = true; ((RoleDeclaredElement)myElement).NewName = NewName; ((RoleDeclaredElement)newDeclaredElement).SetName(NewName); } else { newDeclaredElement = null; } } Assertion.Assert(newDeclaredElement != null, "The condition (newDeclaredElement != null) is false."); myNewElementPointer = newDeclaredElement.CreateElementPointer(); Assertion.Assert(newDeclaredElement.IsValid(), "myNewDeclaredElement.IsValid()"); 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 && !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); } myNewReferences.Insert(0, newReference); rename.AdditionalReferenceProcessing(newDeclaredElement, newReference, 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); } } } if (myElement is RoleDeclaredElement) { ((RoleDeclaredElement)myElement).ChangeName = false; ((RoleDeclaredElement)myElement).SetName(NewName); foreach (IReference reference in referencesToRename) { ((PsiRoleReference)reference).SetName(NewName); reference.CurrentResolveResult = null; ((PsiFile)((RoleDeclaredElement)myElement).File).ClearTables(); } } }
public bool Initialize(IDataContext context) { _solution = context.GetData(JetBrains.IDE.DataConstants.SOLUTION); _page = new AddDependencyPage( s => _parameterType = s, context.GetData(JetBrains.IDE.DataConstants.SOLUTION)); var @class = GetClass(context); _class = @class.CreateElementPointer(); var ctor = @class.Constructors.FirstOrDefault(); if (ctor != null) _ctor = ctor.CreateElementPointer(); return true; }
public UnityScriptsOccurrence(IPsiSourceFile sourceFile, IDeclaredElementPointer <IDeclaredElement> declaredElement, LocalReference owningElementLocation, Guid guid) : base(sourceFile, declaredElement, owningElementLocation, false) { myGuid = guid; }
public virtual bool Navigate(ISolution solution, IDeclaredElementPointer <IDeclaredElement> pointer, LocalReference location) { return(true); }
public UnityMethodsOccurrence(IPsiSourceFile sourceFile, IDeclaredElementPointer <IDeclaredElement> declaredElement, IHierarchyElement attachedElement, AssetMethodData methodData) : base(sourceFile, declaredElement, attachedElement) { MethodData = methodData; }
public FormerlySerializedAsAtomicRename(IDeclaredElement declaredElement, string newName) { myPointer = declaredElement.CreateElementPointer(); OldName = declaredElement.ShortName; NewName = newName; }