private bool GetBreakApartAvailability(HtmlElement element, bool keepFirstOnBaseLine, TextView view)
        {
            if (((element == null) || !element.HasAttributes) || (element.Attributes.Count == 1))
            {
                return false;
            }

            if (_breakApartPreview == null)
            {
                _breakApartPreview = new PreviewRanges();
            }

            if (_breakApartPreview.PreviewShown)
            {
                return true;
            }

            _breakApartPreview.Clear(view);
            int startLine = element.StartLine;
            int num2 = 0;
            bool flag = false;

            if (keepFirstOnBaseLine)
            {
                if (startLine != element.Attributes[0].StartLine)
                {
                    _breakApartPreview.Add(element.Attributes[0].Range, true);
                    flag = true;
                }
                num2 = 1;
            }

            for (int i = num2; i < element.Attributes.Count; i++)
            {
                HtmlAttribute attribute = element.Attributes[i];
                if (attribute.StartLine == startLine)
                {
                    _breakApartPreview.Add(attribute.Range, false);
                    flag = true;
                }
            }

            return flag;
        }
        private void Apply(string displayName, HtmlElement original, HtmlElement newElement, string tabsBefore)
        {
            if ((!string.IsNullOrEmpty(displayName) && (original != null)) && (newElement != null))
            {
                int num = original.NameRange.End.Offset - original.StartOffset;
                SourceRange insertionRange = GetInsertionRange(original);
                string s = CodeRush.Language.GenerateElement(newElement);
                s = CodeRush.StrUtil.RemoveLastLineTerminator(s);
                if (Options.PutCloseTagOnOwnLine)
                {
                    var terminator = @"/>";
                    if(!s.EndsWith(terminator))
                    {
                        terminator = @">";
                    }

                    s = s.Substring(0, s.Length - terminator.Length);
                    s += string.Format("\r\n{0}{1}", tabsBefore, terminator);
                }
                insertionRange.BindToCode(CodeRush.Documents.Active as TextDocument);
                ICompoundAction action = CodeRush.TextBuffers.NewMultiFileCompoundAction(displayName, true);
                IMultiLidContainerGroup group = CodeRush.LinkedIdentifiers.OpenMultiLidContainerGroup();
                try
                {
                    FileChangeCollection changes = new FileChangeCollection();
                    changes.Add(new FileChange(original.FileNode.Name, insertionRange, s));
                    CodeRush.File.ApplyChanges(changes, false, true);
                    CodeRush.Caret.MoveTo(insertionRange.Start.Line, (int)(insertionRange.Start.Offset + num));
                }
                catch (Exception exception)
                {
                    LogBase<Log>.SendException(displayName, exception);
                }
                finally
                {
                    if (_breakApartPreview != null)
                    {
                        _breakApartPreview.Clear();
                        _breakApartPreview = null;
                    }

                    group.Close();
                    action.Close();
                    insertionRange.RemoveAllBindings();
                }
            }
        }