public static void ShowErrorBadge( this IBadgeContainer self, VisualElement parent, SpriteAlignment alignment, string description, Store store, CompilerQuickFix errorQuickFix ) { Assert.IsNotNull(parent); Assert.IsTrue(self is VisualElement); var target = (VisualElement)self; if (self.ErrorBadge?.parent == null) { var message = description; if (errorQuickFix != null) { message += $"\r\nQuick fix: {errorQuickFix.description}"; } self.ErrorBadge = IconBadge.CreateError(message); parent.Add(self.ErrorBadge); self.ErrorBadge.AttachTo(target, alignment); target.EnableInClassList(k_HasErrorBadge, true); if (errorQuickFix != null) { self.ErrorBadge.RegisterCallback <MouseDownEvent>(e => errorQuickFix.quickFix(store)); } return; } self.ErrorBadge.AttachTo(target, alignment); }
public void AddError(INodeModel model, string error, CompilerQuickFix quickFix = null) { m_Errors.Add(new CompilerError { sourceNode = model, sourceNodeGuid = model.Guid, description = error, quickFix = quickFix }); }
public void AddWarning(INodeModel model, string warning, CompilerQuickFix quickFix = null) { m_Errors.Add(new CompilerError { sourceNode = model, sourceNodeGuid = model.Guid, description = warning, quickFix = quickFix, isWarning = true }); }
internal void AttachErrorBadge(VisualElement visualElement, string errorDescription, SpriteAlignment alignment, Store store = null, CompilerQuickFix errorQuickFix = null) { Assert.IsNotNull(visualElement); if (errorQuickFix != null) { Assert.IsNotNull(store); } VisualElement parent = visualElement.parent; while (parent.GetType().IsSubclassOf(typeof(GraphElement)) && parent.parent != null) { parent = parent.parent; } (visualElement as IBadgeContainer)?.ShowErrorBadge(m_IconsParent, alignment, errorDescription, store, errorQuickFix); }