示例#1
0
        public IOccurrence Connect(IOccurrence occToBeConnected)
        {
            var occ = occToBeConnected as OccInduced;

            if (occ == null)
            {
                throw new InvalidOperationException("Not an induced occurrence.");
            }

            if (TreeId != occ.TreeId)
            {
                throw new InvalidOperationException("The two occurrences are not from the same tree.");
            }
            if (RightMostIndex != occ.RootIndex)
            {
                throw new InvalidOperationException("The two occurrences cannot be connected.");
            }

            var preList = new List <int> {
                RootIndex
            };

            preList.AddRange(occToBeConnected.PreorderCode);

            return(Create(TreeId, Depth, preList));
        }
        public RdUsageGroupTextAndIcon?GetUsageGroup(IOccurrence occurrence, ProjectItemKind kind, bool takeParent)
        {
            if (occurrence is UnityAssetOccurrence unityAssetOccurrence)
            {
                switch (kind)
                {
                case ProjectItemKind.PHYSICAL_FILE:
                    var filePath = GetPresentablePath(unityAssetOccurrence.SourceFile.GetLocation());
                    if (filePath != null)
                    {
                        return(new RdUsageGroupTextAndIcon(filePath, myIconHost.Transform(GetIcon(unityAssetOccurrence.SourceFile))));
                    }
                    break;

                case ProjectItemKind.PHYSICAL_DIRECTORY:
                    var directoryPath = GetPresentablePath(unityAssetOccurrence.SourceFile.GetLocation().Directory);
                    if (directoryPath != null)
                    {
                        return(new RdUsageGroupTextAndIcon(directoryPath, myIconHost.Transform(myProjectModelIcons.DirectoryIcon)));
                    }
                    break;
                }
            }

            return(null);
        }
示例#3
0
        public override RdUsageGroup CreateModel(IOccurrence occurrence, IOccurrenceBrowserDescriptor descriptor)
        {
            using (CompilationContextCookie.GetExplicitUniversalContextIfNotSet())
            {
                if (occurrence is ReferenceOccurrence referenceOccurrence &&
                    referenceOccurrence.PrimaryReference is IUnityYamlReference reference)
                {
                    var document   = reference.ComponentDocument;
                    var sourceFile = document.GetSourceFile();
                    if (sourceFile == null || !sourceFile.IsValid())
                    {
                        return(EmptyModel());
                    }

                    var anchor = UnitySceneDataUtil.GetAnchorFromBuffer(document.GetTextAsBuffer());
                    if (anchor == null)
                    {
                        return(EmptyModel());
                    }

                    return(CreateModel(UnityObjectPsiUtil.GetGameObjectPathFromComponent(myUnitySceneDataLocalCache, sourceFile, anchor)));
                }
            }

            return(EmptyModel());
        }
        public bool Present(
            IMenuItemDescriptor descriptor,
            IOccurrence occurrence,
            OccurrencePresentationOptions occurrencePresentationOptions)
        {
            var generatorOccurrence = (GeneratorOccurrence)occurrence;
            var generator           = (IFileGenerator)generatorOccurrence.Generator;

            descriptor.Text  = generator.Name;
            descriptor.Style = MenuItemStyle.Enabled;
            descriptor.Icon  = UnitTestingThemedIcons.NewSession.Id;

            string assemblyName = generator.GetType().Assembly.GetName().Name;

            descriptor.ShortcutText = new RichText(assemblyName, TextStyle.FromForeColor(SystemColors.GrayText));

            descriptor.Tooltip = new RichText();
            if (!string.IsNullOrWhiteSpace(generator.Description))
            {
                descriptor.Tooltip.Append(generator.Description);
                descriptor.Tooltip.Append(Environment.NewLine);
            }

            descriptor.Tooltip.Append(new RichText("Output: ", new TextStyle(FontStyle.Bold)));
            descriptor.Tooltip.Append(new RichText(generator.GetFileName(), TextStyle.Default));

            return(true);
        }
示例#5
0
        public bool Contains(IOccurrence occ)
        {
            if (occ == null)
            {
                return(false);
            }
            if (occ.TreeId != TreeId || occ.RootIndex != RootIndex)
            {
                return(false);
            }
            if (PreorderCode.Count < occ.PreorderCode.Count)
            {
                return(false);
            }
            if (RightMostIndex < occ.RightMostIndex)
            {
                return(false);
            }

            for (var i = 1; i < occ.PreorderCode.Count; i++)
            {
                if (!PreorderCode.Contains(occ.PreorderCode[i]))
                {
                    return(false);
                }
            }

            return(true);
        }
示例#6
0
        public override RdUsageGroup CreateModel(IOccurrence occurrence, IOccurrenceBrowserDescriptor descriptor)
        {
            using (CompilationContextCookie.GetExplicitUniversalContextIfNotSet())
            {
                if (occurrence is UnityAssetOccurrence assetOccurrence && !assetOccurrence.SourceFile.GetLocation().IsAsset())
                {
                    using (ReadLockCookie.Create())
                    {
                        var solution  = occurrence.GetSolution();
                        var processor = solution.GetComponent <AssetHierarchyProcessor>();
                        var consumer  = new UnityScenePathGameObjectConsumer();
                        processor.ProcessSceneHierarchyFromComponentToRoot(assetOccurrence.OwningElementLocation, consumer, true, true);
                        string name = "...";
                        if (consumer.NameParts.Count > 0)
                        {
                            name = string.Join("\\", consumer.NameParts);
                        }

                        return(CreateModel(name));
                    }
                }
            }

            return(EmptyModel());
        }
示例#7
0
        public IOccurrence Combine(IOccurrence occToBeCombined)
        {
            var occ = occToBeCombined as OccInduced;

            if (occ == null)
            {
                throw new InvalidOperationException("Not an induced occurrence.");
            }

            if (TreeId != occ.TreeId)
            {
                throw new InvalidOperationException("The two occurrences are not from the same tree.");
            }
            if (RootIndex != occ.RootIndex)
            {
                throw new InvalidOperationException("Cannot combine, the two occurrences do not share the same root.");
            }
            if (RightMostIndex >= occ.SecondIndex)
            {
                throw new InvalidOperationException("Illegal combination.");
            }

            var preList = new List <int>(PreorderCode);

            for (var i = 1; i < occToBeCombined.PreorderCode.Count; i++)
            {
                preList.Add(occToBeCombined.PreorderCode[i]);
            }

            return(Create(TreeId, Depth, preList));
        }
        internal bool ContainsOccurrence(IOccurrence iocc)
        {
            if (RightMostSet == null || RightMostSet.Count <= 0)
            {
                return(false);
            }

            return(RightMostSet.Any(t => t.RightMostIndex == iocc.RightMostIndex));
        }
示例#9
0
        internal bool ContainsOccurrence(IOccurrence occ)
        {
            if (occ == null)
            {
                throw new ArgumentNullException("occ");
            }

            return(TreeSet.ContainsKey(occ.TreeId) && TreeSet[occ.TreeId].ContainsOccurrence(occ));
        }
示例#10
0
 protected override void DisplayMainText(IMenuItemDescriptor descriptor, IOccurrence occurrence, OccurrencePresentationOptions options,
                                         IDeclaredElement declaredElement)
 {
     base.DisplayMainText(descriptor, occurrence, options, declaredElement);
     if (occurrence is LinkedTypesOccurrence linkedTypeOccurrence && linkedTypeOccurrence.HasNameDerived)
     {
         descriptor.Text.SetStyle(FontStyle.Bold);
     }
 }
示例#11
0
        internal int AddOccurrence(IOccurrence occ)
        {
            if (!RootSet.ContainsKey(occ.RootIndex))
            {
                RootSet.Add(occ.RootIndex, new RootOcc(TreeId, occ.Depth, occ.RootIndex));
            }

            return(RootSet[occ.RootIndex].AddOccurrence(occ));
        }
 public override RdUsageGroup CreateModel(IOccurrence occurrence, IOccurrenceBrowserDescriptor descriptor)
 {
     if (occurrence is ReferenceOccurrence referenceOccurrence &&
         referenceOccurrence.PrimaryReference is IUnityYamlReference reference)
     {
         return(CreateModel(UnityObjectPsiUtil.GetGameObjectPathFromComponent(mySceneProcessor, reference.ComponentDocument)));
     }
     return(EmptyModel());
 }
        public override RdUsageGroup CreateModel(IOccurrence occurrence, IOccurrenceBrowserDescriptor descriptor)
        {
            if (!(occurrence is UnityAnimationEventOccurence animationEventOccurence))
            {
                return(EmptyModel());
            }
            var text = animationEventOccurence.GetDisplayText()?.Text;

            return(text != null?CreateModel(text) : EmptyModel());
        }
		private Project CreateProjectForOccurence(IOccurrence arg)
		{
			var app = arg as IAppointment;
			if (app != null)
			{
				return new Project { Name = app.Subject, Start = app.Start, End = app.End };
			}

			return null;
		}
		private IDateRange CreateGanttTaskForOccurence(IOccurrence arg)
		{
			var app = arg as IAppointment;
			if (app != null)
			{
				return new GanttTask { Title = app.Subject, Start = app.Start, End = app.End };
			}

			return null;
		}
        private void ShowTree(string treeId, IOccurrence occ, PatternTree pt)
        {
            var tree = GetTree(treeId);

            if (tree == null)
            {
                return;
            }

            treeVisualizer.SetTree(tree);
            treeVisualizer.SetHighLightOccurrence(occ, pt);
        }
 private CustomAppointment GetCustomAppointmentFromOccurence(IOccurrence occurrence)
 {
     if (occurrence is CustomAppointment)
     {
         return(occurrence as CustomAppointment);
     }
     else
     {
         var occ = (occurrence as Occurrence).Appointment as CustomAppointment;
         return(occ);
     }
 }
示例#18
0
        private Appointment GetAppointment(IOccurrence occurance)
        {
            var appointment = occurance as CustomAppointment;

            if (appointment == null)
            {
                var currentOccurance = occurance as Occurrence;
                appointment = currentOccurance.Appointment as CustomAppointment;
            }

            return(appointment);
        }
        public override bool CanEditAppointment(IReadOnlySettings readOnlySettings, IOccurrence occurrence)
        {
            var customAppointment = GetCustomAppointmentFromOccurence(occurrence);

            if (customAppointment != null)
            {
                return(customAppointment.IsEditable);
            }
            else
            {
                return(base.CanEditAppointment(readOnlySettings, occurrence));
            }
        }
        // If the subject of an appointment is empty, it cannot be saved
        public override bool CanSaveAppointment(IReadOnlySettings readOnlySettings, IOccurrence occurrence)
        {
            var customAppointment = GetCustomAppointmentFromOccurence(occurrence);

            if (customAppointment != null)
            {
                return(customAppointment.Subject != string.Empty);
            }
            else
            {
                return(base.CanSaveAppointment(readOnlySettings, occurrence));
            }
        }
示例#21
0
        public override RdUsageGroup CreateModel(IOccurrence occurrence, IOccurrenceBrowserDescriptor descriptor)
        {
            using (CompilationContextCookie.GetExplicitUniversalContextIfNotSet())
            {
                if (occurrence is ReferenceOccurrence referenceOccurrence &&
                    referenceOccurrence.PrimaryReference is IUnityYamlReference reference)
                {
                    return(CreateModel(UnityObjectPsiUtil.GetComponentName(reference.ComponentDocument)));
                }
            }

            return(EmptyModel());
        }
        public bool Present(IMenuItemDescriptor descriptor, IOccurrence occurrence,
                            OccurrencePresentationOptions occurrencePresentationOptions)
        {
            var unityOccurrence = (occurrence as UnityAssetOccurrence).NotNull("occurrence as UnityAssetOccurrence != null");

            var displayText = GetDisplayText(unityOccurrence) + OccurrencePresentationUtil.TextContainerDelimiter;

            descriptor.Text = displayText;
            OccurrencePresentationUtil.AppendRelatedFile(descriptor, unityOccurrence.SourceFile.DisplayName.Replace('\\', '/'));

            descriptor.Icon = UnityFileTypeThemedIcons.FileUnity.Id;
            return(true);
        }
        private Project CreateProjectForOccurence(IOccurrence arg)
        {
            var app = arg as IAppointment;

            if (app != null)
            {
                return(new Project {
                    Name = app.Subject, Start = app.Start, End = app.End
                });
            }

            return(null);
        }
示例#24
0
        private IDateRange CreateGanttTaskForOccurence(IOccurrence arg)
        {
            var app = arg as IAppointment;

            if (app != null)
            {
                return(new GanttTask {
                    Title = app.Subject, Start = app.Start, End = app.End
                });
            }

            return(null);
        }
        public void SetHighLightOccurrence(IOccurrence occ, PatternTree pt)
        {
            lblOccNumber.Text = string.Empty;
            occurrences.Clear();
            txtPatternTree.Text = string.Empty;

            if (occ == null)
            {
                return;
            }

            occurrences.Add(occ);

            txtPatternTree.Text = pt == null ? string.Empty : pt.ToString();
        }
        internal int AddOccurrence(IOccurrence occ)
        {
            if (occ.TreeId != TreeId || occ.RootIndex != RootIndex)
            {
                throw new InvalidOperationException();
            }

            if (RightMostSet == null)
            {
                RightMostSet = new List <IOccurrence>();
            }

            RightMostSet.Add(occ);

            return(RightMostSet.Count == 1 ? 1 : 0);
        }
示例#27
0
        public ICollection <OccurrenceKind> GetOccurrenceKinds(IOccurrence occurrence)
        {
            var referenceOccurrence = occurrence as ReferenceOccurrence;
            var reference           = referenceOccurrence?.PrimaryReference;

            if (reference is UnityEventTargetReference)
            {
                return new[] { UnityYamlSpecificOccurrenceKinds.EventHandler }
            }
            ;
            if (reference is MonoScriptReference)
            {
                return new[] { UnityYamlSpecificOccurrenceKinds.ComponentUsage }
            }
            ;
            return(EmptyList <OccurrenceKind> .Instance);
        }
示例#28
0
        public override RdUsageGroup CreateModel(IOccurrence occurrence, IOccurrenceBrowserDescriptor descriptor)
        {
            using (CompilationContextCookie.GetExplicitUniversalContextIfNotSet())
            {
                if (occurrence is UnityAssetOccurrence assetOccurrence)
                {
                    var hierarchyContainer = assetOccurrence.GetSolution()?.GetComponent <AssetDocumentHierarchyElementContainer>();
                    var element            = hierarchyContainer?.GetHierarchyElement(assetOccurrence.OwningElementLocation, true);
                    if (element is IComponentHierarchy componentHierarchyElement)
                    {
                        return(CreateModel(AssetUtils.GetComponentName(myMetaFileGuidCache, componentHierarchyElement)));
                    }
                }
            }

            return(EmptyModel());
        }
        public ICollection <OccurrenceKind> GetOccurrenceKinds(IOccurrence occurrence)
        {
            if (occurrence is AsmDefNameOccurrence)
            {
                return new[] { AssemblyDefinitionReference }
            }
            ;

            if (occurrence is JavaScriptReferenceOccurrence jsOccurrence &&
                jsOccurrence.SourceFile.IsAsmDef() &&
                jsOccurrence.PrimaryReference is AsmDefNameReference)
            {
                return(new[] { AssemblyDefinitionReference });
            }

            return(null);
        }
        public bool Present(
            IMenuItemDescriptor descriptor,
            IOccurrence occurrence,
            OccurrencePresentationOptions occurrencePresentationOptions)
        {
            var generatorOccurrence = (GeneratorOccurrence)occurrence;
            var generator           = (IInPlaceGenerator)generatorOccurrence.Generator;

            descriptor.Text    = generator.Name;
            descriptor.Style   = MenuItemStyle.Enabled;
            descriptor.Icon    = OptionsThemedIcons.ImportLayer.Id;
            descriptor.Tooltip = generator.Description;

            string assemblyName = generator.GetType().Assembly.GetName().Name;

            descriptor.ShortcutText = new RichText(assemblyName, TextStyle.FromForeColor(SystemColors.GrayText));

            return(true);
        }
        public ICollection <OccurrenceKind> GetOccurrenceKinds(IOccurrence occurrence)
        {
            if (occurrence is IAsmDefNameOccurence)
            {
                return new[] { AssemblyDefinitionReference }
            }
            ;

            var referenceOccurrence = occurrence as ReferenceOccurrence;
            var reference           = referenceOccurrence?.PrimaryReference;

            if (reference is TReference)
            {
                return new[] { AssemblyDefinitionReference }
            }
            ;

            return(null);
        }
示例#32
0
 public ICollection <OccurrenceKind> GetOccurrenceKinds(IOccurrence occurrence)
 {
     if (occurrence is UnityMethodsOccurrence)
     {
         return new[] { UnityAssetSpecificOccurrenceKinds.EventHandler }
     }
     ;
     if (occurrence is UnityScriptsOccurrence)
     {
         return new[] { UnityAssetSpecificOccurrenceKinds.ComponentUsage }
     }
     ;
     if (occurrence is UnityInspectorValuesOccurrence)
     {
         return new[] { UnityAssetSpecificOccurrenceKinds.InspectorUsage }
     }
     ;
     return(EmptyList <OccurrenceKind> .Instance);
 }
 protected override IEnumerable<IOccurrence> GetSelectedAppointments(AppointmentSelectionState state, IOccurrence target)
 {
     return new List<IOccurrence> { target };
 }
 protected override IEnumerable<IOccurrence> GetSelectedAppointments(AppointmentSelectionState state, IOccurrence target)
 {
     yield return target;
 }