Exemple #1
0
        private void ProcessBreakpointChange(DocumentLine line, BreakpointOperation ops)
        {
            // please notify ATF team before defining  FullISyntaxEditorControl
            if (line == null || StringUtil.IsNullOrEmptyOrWhitespace(line.Text))
                return;

            // get or create breakpoint layer.
            var layer = Document.SpanIndicatorLayers[SpanIndicatorLayer.BreakpointKey];
            if (layer == null)
            {
                layer = new SpanIndicatorLayer(SpanIndicatorLayer.BreakpointKey, SpanIndicatorLayer.BreakpointDisplayPriority);
                Document.SpanIndicatorLayers.Add(layer);
            }
            
            // find breakpoint indicator for the current line.
            BreakpointIndicator breakpointIndicator = null;
            foreach (SpanIndicator si in line.SpanIndicators)
            {
                breakpointIndicator = si as BreakpointIndicator;
                if (breakpointIndicator != null)
                    break;
            }

            var breakpointExist = breakpointIndicator != null;
            var addbreakpoint = ((ops == BreakpointOperation.Set || ops == BreakpointOperation.Toggle) && !breakpointExist);

            // do nothing 
            if (addbreakpoint == breakpointExist)
                return;
                       
            var e = new BreakpointEventArgs(addbreakpoint, line.Index + 1, line.Text);            
            if (BreakpointChanging != null)
                BreakpointChanging(this, e);

            // cancel the operation
            if (e.Cancel)
                return;

            if (addbreakpoint)
            {
                breakpointIndicator = new BreakpointIndicator();
                layer.Add(breakpointIndicator, line.TextRange);
            }
            else // remove breakpoint
            {
                layer.Remove(breakpointIndicator);                
            }
        }
        private void EditorBreakpointChanging(object sender, BreakpointEventArgs e)
        {
            // Set to cancel unless we meet criteria later
            e.Cancel = true;

            CheckLineNumber(e.LineNumber);

            var sd = GetSledDocumentFromSender(sender);
            if (sd == null)
                return;

            // Don't allow breakpoints in files that don't have a plugin associated with them
            if (sd.LanguagePlugin == null)
                return;

            // By default allow the breakpoint change to continue
            e.Cancel = false;

            // When adding a breakpoint we need to check with the language plugin to see if it
            // supports the addition of a new breakpoint
            if (e.IsSet)
            {
                // Grab all breakpoint plugins
                var plugins =
                    SledServiceInstance.GetAll<ISledBreakpointPlugin>();
                
                foreach (var listable in plugins)
                {
                    // Find plugin that implments the breakpoint plugin
                    if (listable != sd.LanguagePlugin)
                        continue;

                    // Check with plugin to see if breakpoint can be added
                    e.Cancel =
                        !listable.CanAdd(
                            sd,
                            e.LineNumber,
                            e.LineText,
                            GetNumberOfBreakpointsForLanguagePlugin(sd.LanguagePlugin));
                }
            }
        }