Exemple #1
0
        public void HandleToolTipRequest(ToolTipRequestEventArgs args)
        {
            if (args.InDocument)
            {
                int offset = args.Editor.Document.GetOffset(args.LogicalPosition);

                FoldingManager foldings = args.Editor.GetService(typeof(FoldingManager)) as FoldingManager;
                if (foldings != null)
                {
                    var            foldingsAtOffset = foldings.GetFoldingsAt(offset);
                    FoldingSection collapsedSection = foldingsAtOffset.FirstOrDefault(section => section.IsFolded);

                    if (collapsedSection != null)
                    {
                        args.SetToolTip(GetTooltipTextForCollapsedSection(args, collapsedSection));
                    }
                }

                TextMarkerService textMarkerService = args.Editor.GetService(typeof(ITextMarkerService)) as TextMarkerService;
                if (textMarkerService != null)
                {
                    var         markersAtOffset   = textMarkerService.GetMarkersAtOffset(offset);
                    ITextMarker markerWithToolTip = markersAtOffset.FirstOrDefault(marker => marker.ToolTip != null);

                    if (markerWithToolTip != null)
                    {
                        args.SetToolTip(markerWithToolTip.ToolTip);
                    }
                }
            }
        }
		public void SetUpFixture()
		{
			string ruby = "class Test\r\n" +
							"\tdef initialize\r\n" +
							"\t\tputs 'test'\r\n" +
							"\tend\r\n" +
							"end";
			
			DefaultProjectContent projectContent = new DefaultProjectContent();
			RubyParser parser = new RubyParser();
			compilationUnit = parser.Parse(projectContent, @"C:\test.rb", ruby);			
			if (compilationUnit.Classes.Count > 0) {
				c = compilationUnit.Classes[0];
				if (c.Methods.Count > 0) {
					method = c.Methods[0];
				}
				
				TextArea textArea = new TextArea();
				document = new TextDocument();
				textArea.Document = document;
				textArea.Document.Text = ruby;
				
				// Get folds.
				ParserFoldingStrategy foldingStrategy = new ParserFoldingStrategy(textArea);
				
				ParseInformation parseInfo = new ParseInformation(compilationUnit);
				foldingStrategy.UpdateFoldings(parseInfo);
				List<FoldingSection> folds = new List<FoldingSection>(foldingStrategy.FoldingManager.AllFoldings);
			
				if (folds.Count > 1) {
					classFold = folds[0];
					methodFold = folds[1];
				}
			}
		}
		public void SetUpFixture()
		{
			string python = "class Test:\r\n" +
							"\tdef foo(self):\r\n" +
							"\t\tpass";
			
			DefaultProjectContent projectContent = new DefaultProjectContent();
			PythonParser parser = new PythonParser();
			compilationUnit = parser.Parse(projectContent, @"C:\test.py", python);			
			if (compilationUnit.Classes.Count > 0) {
				c = compilationUnit.Classes[0];
				if (c.Methods.Count > 0) {
					method = c.Methods[0];
				}
				
				TextArea textArea = new TextArea();
				document = new TextDocument();
				textArea.Document = document;
				textArea.Document.Text = python;
				
				ParserFoldingStrategy foldingStrategy = new ParserFoldingStrategy(textArea);
				
				ParseInformation parseInfo = new ParseInformation(compilationUnit);
				foldingStrategy.UpdateFoldings(parseInfo);
				List<FoldingSection> folds = new List<FoldingSection>(foldingStrategy.FoldingManager.AllFoldings);
				
				if (folds.Count > 0) {
					classFold = folds[0];
				}
				if (folds.Count > 1) {
					methodFold = folds[1];
				}
			}
		}
        public TableEditorPage(SelectedContentArgs SelectedContentArgs, string startKeyWord, string endKeyWord, string KeyWordForTableLocationIndication = null)
        {
            InitializeComponent();

            GapBetweenFoldingOffsetAndTableLocaionIndication = 0;
            this.textEditor     = SelectedContentArgs.TextEditor;
            this.foldingSection = SelectedContentArgs.GetFoldingsAtCaretPosition()[0];
            int CaretLocation = SelectedContentArgs.GetCaretPosition();

            FoldingOffset = SelectedContentArgs.GetFoldingOffSet();
            if (KeyWordForTableLocationIndication != null)
            {
                int indexOfKeyWordForIndication = foldingSection.TextContent.IndexOf(KeyWordForTableLocationIndication);
                if (KeyWordForTableLocationIndication != null && indexOfKeyWordForIndication != -1 && CaretLocation - FoldingOffset > indexOfKeyWordForIndication)
                {
                    WorkingSection = foldingSection.TextContent.Substring(indexOfKeyWordForIndication);
                    GapBetweenFoldingOffsetAndTableLocaionIndication = foldingSection.TextContent.Length - WorkingSection.Length;
                }

                else
                {
                    WorkingSection = foldingSection.TextContent;
                }
            }
            else
            {
                WorkingSection = foldingSection.TextContent;
            }

            StartKeyWord = startKeyWord;
            EndKeyWord   = endKeyWord;
            InitTable();
        }
Exemple #5
0
        /// <summary>
        /// Goes through all foldings in the displayed text and folds them
        /// so that users can explore the text in a top down manner.
        /// </summary>
        private void CollapseAllTextfoldings()
        {
            if (this.mFoldingManager == null)
            {
                return;
            }

            if (this.mFoldingManager.AllFoldings == null)
            {
                return;
            }

            foreach (var loFolding in this.mFoldingManager.AllFoldings)
            {
                loFolding.IsFolded = true;
            }

            // Unfold the first fold (if any) to give a useful overview on content
            FoldingSection foldSection = this.mFoldingManager.GetNextFolding(0);

            if (foldSection != null)
            {
                foldSection.IsFolded = false;
            }
        }
		/// <summary>
		/// Creates a folding for the specified text section.
		/// </summary>
		public FoldingSection CreateFolding(int startOffset, int endOffset)
		{
			if (startOffset >= endOffset)
				throw new ArgumentException("startOffset must be less than endOffset");
			FoldingSection fs = new FoldingSection(this, startOffset, endOffset);
			foldings.Add(fs);
			textView.Redraw(fs, DispatcherPriority.Normal);
			return fs;
		}
        public GherkinTableEditorPage(SelectedContentArgs SelectedContentArgs)
        {
            InitializeComponent();

            this.textEditor     = SelectedContentArgs.TextEditor;
            this.foldingSection = SelectedContentArgs.GetFoldingsAtCaretPosition()[0];

            InitTable();
        }
            public bool TryFinishFoldingSection(OracleToken token, out FoldingSection foldingSection)
            {
                foldingSection = _foldingStacks.Values.SelectMany(s => s).FirstOrDefault();
                if (foldingSection == null)
                {
                    return(false);
                }

                foldingSection.FoldingEnd = token.Index + token.Value.Length;
                return(true);
            }
            public void AddFolding(string placeholder, string stackKey, int indexStart)
            {
                var foldingSectionStack = GetFoldingStack(stackKey);

                var section =
                    new FoldingSection
                {
                    FoldingStart = indexStart,
                    IsNested     = foldingSectionStack.Count > 0,
                    Placeholder  = placeholder
                };

                foldingSectionStack.Push(section);

                _sectionScopes.Add(section, new Dictionary <string, int>(_nestedScopes));
            }
        public void SetUpFixture()
        {
            string ruby =
                "def foo\r\n" +
                "end\r\n" +
                "\r\n" +
                "def bar(i)\r\n" +
                "end";

            DefaultProjectContent projectContent = new DefaultProjectContent();
            RubyParser            parser         = new RubyParser();

            compilationUnit = parser.Parse(projectContent, @"C:\test.rb", ruby);

            if (compilationUnit.Classes.Count > 0)
            {
                globalClass = compilationUnit.Classes[0];
                if (globalClass.Methods.Count > 1)
                {
                    fooMethod = globalClass.Methods[0];
                    barMethod = globalClass.Methods[1];
                }
            }

            // Get folds.
            TextArea textArea = new TextArea();

            document               = new TextDocument();
            textArea.Document      = document;
            textArea.Document.Text = ruby;

            ParserFoldingStrategy foldingStrategy = new ParserFoldingStrategy(textArea);

            ParseInformation parseInfo = new ParseInformation(compilationUnit);

            foldingStrategy.UpdateFoldings(parseInfo);
            List <FoldingSection> folds = new List <FoldingSection>(foldingStrategy.FoldingManager.AllFoldings);

            if (folds.Count > 1)
            {
                fooMethodFold = folds[0];
                barMethodFold = folds[1];
            }
        }
        public override void Run()
        {
            ITextEditor    editor         = SD.GetActiveViewContentService <ITextEditor>();
            FoldingManager foldingManager = editor.GetService(typeof(FoldingManager)) as FoldingManager;

            if (foldingManager != null)
            {
                // look for folding on this line:
                FoldingSection folding = foldingManager.GetNextFolding(editor.Document.PositionToOffset(editor.Caret.Line, 1));
                if (folding == null || editor.Document.GetLineForOffset(folding.StartOffset).LineNumber != editor.Caret.Line)
                {
                    // no folding found on current line: find innermost folding containing the caret
                    folding = foldingManager.GetFoldingsContaining(editor.Caret.Offset).LastOrDefault();
                }
                if (folding != null)
                {
                    folding.IsFolded = !folding.IsFolded;
                }
            }
        }
        public override void Run()
        {
            ITextEditorProvider   provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorProvider;
            ITextEditor           editor   = provider.TextEditor;
            ParserFoldingStrategy strategy = editor.GetService(typeof(ParserFoldingStrategy)) as ParserFoldingStrategy;

            if (strategy != null)
            {
                // look for folding on this line:
                FoldingSection folding = strategy.FoldingManager.GetNextFolding(editor.Document.PositionToOffset(editor.Caret.Line, 1));
                if (folding == null || editor.Document.GetLineForOffset(folding.StartOffset).LineNumber != editor.Caret.Line)
                {
                    // no folding found on current line: find innermost folding containing the caret
                    folding = strategy.FoldingManager.GetFoldingsContaining(editor.Caret.Offset).LastOrDefault();
                }
                if (folding != null)
                {
                    folding.IsFolded = !folding.IsFolded;
                }
            }
        }
        public void SetUpFixture()
        {
            string python = "class Test:\r\n" +
                            "\tdef foo(self):\r\n" +
                            "\t\tpass";

            DefaultProjectContent projectContent = new DefaultProjectContent();
            PythonParser          parser         = new PythonParser();

            compilationUnit = parser.Parse(projectContent, @"C:\test.py", python);
            if (compilationUnit.Classes.Count > 0)
            {
                c = compilationUnit.Classes[0];
                if (c.Methods.Count > 0)
                {
                    method = c.Methods[0];
                }

                TextArea textArea = new TextArea();
                document               = new TextDocument();
                textArea.Document      = document;
                textArea.Document.Text = python;

                ParserFoldingStrategy foldingStrategy = new ParserFoldingStrategy(textArea);

                ParseInformation parseInfo = new ParseInformation(compilationUnit);
                foldingStrategy.UpdateFoldings(parseInfo);
                List <FoldingSection> folds = new List <FoldingSection>(foldingStrategy.FoldingManager.AllFoldings);

                if (folds.Count > 0)
                {
                    classFold = folds[0];
                }
                if (folds.Count > 1)
                {
                    methodFold = folds[1];
                }
            }
        }
Exemple #14
0
        public void SetUpFixture()
        {
            string ruby = "class Test\r\n" +
                          "\tdef initialize\r\n" +
                          "\t\tputs 'test'\r\n" +
                          "\tend\r\n" +
                          "end";

            DefaultProjectContent projectContent = new DefaultProjectContent();
            RubyParser            parser         = new RubyParser();

            compilationUnit = parser.Parse(projectContent, @"C:\test.rb", ruby);
            if (compilationUnit.Classes.Count > 0)
            {
                c = compilationUnit.Classes[0];
                if (c.Methods.Count > 0)
                {
                    method = c.Methods[0];
                }

                TextArea textArea = new TextArea();
                document               = new TextDocument();
                textArea.Document      = document;
                textArea.Document.Text = ruby;

                // Get folds.
                ParserFoldingStrategy foldingStrategy = new ParserFoldingStrategy(textArea);

                ParseInformation parseInfo = new ParseInformation(compilationUnit);
                foldingStrategy.UpdateFoldings(parseInfo);
                List <FoldingSection> folds = new List <FoldingSection>(foldingStrategy.FoldingManager.AllFoldings);

                if (folds.Count > 1)
                {
                    classFold  = folds[0];
                    methodFold = folds[1];
                }
            }
        }
		public void SetUpFixture()
		{
			string ruby =
				"def foo\r\n" +
				"end\r\n" +
				"\r\n" +
				"def bar(i)\r\n" +
				"end";
			
			DefaultProjectContent projectContent = new DefaultProjectContent();
			RubyParser parser = new RubyParser();
			compilationUnit = parser.Parse(projectContent, @"C:\test.rb", ruby);			
			
			if (compilationUnit.Classes.Count > 0) {
				globalClass = compilationUnit.Classes[0];
				if (globalClass.Methods.Count > 1) {
					fooMethod = globalClass.Methods[0];
					barMethod = globalClass.Methods[1];
				}
			}
	
			// Get folds.
			TextArea textArea = new TextArea();
			document = new TextDocument();
			textArea.Document = document;
			textArea.Document.Text = ruby;
			
			ParserFoldingStrategy foldingStrategy = new ParserFoldingStrategy(textArea);
			
			ParseInformation parseInfo = new ParseInformation(compilationUnit);
			foldingStrategy.UpdateFoldings(parseInfo);
			List<FoldingSection> folds = new List<FoldingSection>(foldingStrategy.FoldingManager.AllFoldings);
		
			if (folds.Count > 1) {
				fooMethodFold = folds[0];
				barMethodFold = folds[1];
			}
		}
Exemple #16
0
        public void Execute(TextViewContext context)
        {
            var textView = context.TextView;

            if (null == textView)
            {
                return;
            }
            var            editor         = textView.textEditor;
            FoldingManager foldingManager = context.TextView.FoldingManager;

            if (null == foldingManager)
            {
                return;
            }
            // TODO: or use Caret if position is not given?
            var posBox = context.Position;

            if (null == posBox)
            {
                return;
            }
            TextViewPosition pos = posBox.Value;
            // look for folding on this line:
            FoldingSection folding = foldingManager.GetNextFolding(editor.Document.GetOffset(pos.Line, 1));

            if (folding == null || editor.Document.GetLineByOffset(folding.StartOffset).LineNumber != pos.Line)
            {
                // no folding found on current line: find innermost folding containing the mouse position
                folding = foldingManager.GetFoldingsContaining(editor.Document.GetOffset(pos.Line, pos.Column)).LastOrDefault();
            }
            if (folding != null)
            {
                folding.IsFolded = !folding.IsFolded;
            }
        }
Exemple #17
0
 /// <summary>
 /// Removes a folding section from this manager.
 /// </summary>
 public void RemoveFolding(FoldingSection fs)
 {
     if (fs == null)
         throw new ArgumentNullException(nameof(fs));
     fs.IsFolded = false;
     foldings.Remove(fs);
     Redraw(fs);
 }
Exemple #18
0
 /// <summary>
 /// Creates a folding for the specified text section.
 /// </summary>
 public FoldingSection CreateFolding(int startOffset, int endOffset)
 {
     if (startOffset >= endOffset)
         throw new ArgumentException("startOffset must be less than endOffset");
     if (startOffset < 0 || endOffset > document.TextLength)
         throw new ArgumentException("Folding must be within document boundary");
     FoldingSection fs = new FoldingSection(this, startOffset, endOffset);
     foldings.Add(fs);
     Redraw(fs);
     return fs;
 }
Exemple #19
0
 internal void Redraw(FoldingSection fs)
 {
     foreach (TextView textView in textViews)
         textView.Redraw(fs);
 }
 public string FoldTitle(FoldingSection section, TextDocument document)
 {
     throw new NotImplementedException();
 }
            public bool TryFinishFoldingSection(string placeholder, string stackKey, OracleToken token, out FoldingSection foldingSection)
            {
                var foldingSectionStack = GetFoldingStack(stackKey);
                var sectionExists       = !Equals(token, OracleToken.Empty) && IsScopeValid(placeholder, foldingSectionStack);

                if (sectionExists)
                {
                    foldingSection = foldingSectionStack.Pop();
                    _sectionScopes.Remove(foldingSection);
                    foldingSection.FoldingEnd = token.Index + token.Value.Length;
                }
                else
                {
                    foldingSection = null;
                }

                return(sectionExists);
            }
Exemple #22
0
 public FoldInfo(FoldingSection s)
 {
     Start    = s.StartOffset;
     End      = s.EndOffset;
     IsFolded = s.IsFolded;
 }
Exemple #23
0
 public static bool IsDefinition(FoldingSection section)
 {
     return(section.Tag is NewFoldingDefinition);
 }
Exemple #24
0
		string GetTooltipTextForCollapsedSection(FoldingSection foldingSection)
		{
			// This fixes SD-1394:
			// Each line is checked for leading indentation whitespaces. If
			// a line has the same or more indentation than the first line,
			// it is reduced. If a line is less indented than the first line
			// the indentation is removed completely.
			//
			// See the following example:
			// 	line 1
			// 		line 2
			// 			line 3
			//  line 4
			//
			// is reduced to:
			// line 1
			// 	line 2
			// 		line 3
			// line 4
			
			const int maxLineCount = 15;
			
			TextDocument document = this.Document;
			int startOffset = foldingSection.StartOffset;
			int endOffset = foldingSection.EndOffset;
			
			DocumentLine startLine = document.GetLineByOffset(startOffset);
			DocumentLine endLine = document.GetLineByOffset(endOffset);
			StringBuilder builder = new StringBuilder();
			
			DocumentLine current = startLine;
			ISegment startIndent = TextUtilities.GetLeadingWhitespace(document, startLine);
			int lineCount = 0;
			while (current != endLine.NextLine && lineCount < maxLineCount) {
				ISegment currentIndent = TextUtilities.GetLeadingWhitespace(document, current);
				
				if (current == startLine && current == endLine)
					builder.Append(document.GetText(startOffset, endOffset - startOffset));
				else if (current == startLine) {
					if (current.EndOffset - startOffset > 0)
						builder.AppendLine(document.GetText(startOffset, current.EndOffset - startOffset).TrimStart());
				} else if (current == endLine) {
					if (startIndent.Length <= currentIndent.Length)
						builder.Append(document.GetText(current.Offset + startIndent.Length, endOffset - current.Offset - startIndent.Length));
					else
						builder.Append(document.GetText(current.Offset + currentIndent.Length, endOffset - current.Offset - currentIndent.Length));
				} else {
					if (startIndent.Length <= currentIndent.Length)
						builder.AppendLine(document.GetText(current.Offset + startIndent.Length, current.Length - startIndent.Length));
					else
						builder.AppendLine(document.GetText(current.Offset + currentIndent.Length, current.Length - currentIndent.Length));
				}
				
				current = current.NextLine;
				lineCount++;
			}
			if (current != endLine.NextLine)
				builder.Append("...");
			
			return builder.ToString();
		}
Exemple #25
0
		/// <summary>
		/// Creates a folding for the specified text section.
		/// </summary>
		public FoldingSection CreateFolding(int startOffset, int endOffset)
		{
			if (startOffset >= endOffset)
				throw new ArgumentException("startOffset must be less than endOffset");
			FoldingSection fs = new FoldingSection(this, startOffset, endOffset);
			foldings.Add(fs);
			Redraw(fs);
			return fs;
		}
 private bool IsAmlFolding(FoldingSection f)
 {
     return(f.Title.StartsWith("<Item") || f.Title.StartsWith("<Properties ") || f.Title.StartsWith("<Relationships"));
 }
 private bool IsAmlFolding(FoldingSection f)
 {
   return f.Title.StartsWith("<Item") || f.Title.StartsWith("<Properties ") || f.Title.StartsWith("<Relationships");
 }
		/// <summary>
		/// Removes a folding section from this manager.
		/// </summary>
		public void RemoveFolding(FoldingSection fs)
		{
			if (fs == null)
				throw new ArgumentNullException("fs");
			fs.IsFolded = false;
			foldings.Remove(fs);
			textView.Redraw(fs, DispatcherPriority.Normal);
		}
        void TextEditorMouseHover(object sender, MouseEventArgs e)
        {
            Debug.Assert(sender == this);
            ToolTipRequestEventArgs args = new ToolTipRequestEventArgs(this.Adapter);
            var pos = this.TextArea.TextView.GetPositionFloor(e.GetPosition(this.TextArea.TextView) + this.TextArea.TextView.ScrollOffset);

            args.InDocument = pos.HasValue;
            if (pos.HasValue)
            {
                args.LogicalPosition = AvalonEditDocumentAdapter.ToLocation(pos.Value.Location);
            }

            if (args.InDocument)
            {
                int offset = args.Editor.Document.PositionToOffset(args.LogicalPosition.Line, args.LogicalPosition.Column);

                FoldingManager foldings = this.Adapter.GetService(typeof(FoldingManager)) as FoldingManager;
                if (foldings != null)
                {
                    var            foldingsAtOffset = foldings.GetFoldingsAt(offset);
                    FoldingSection collapsedSection = foldingsAtOffset.FirstOrDefault(section => section.IsFolded);

                    if (collapsedSection != null)
                    {
                        args.SetToolTip(GetTooltipTextForCollapsedSection(collapsedSection));
                    }
                }

                TextMarkerService textMarkerService = this.Adapter.GetService(typeof(ITextMarkerService)) as TextMarkerService;
                if (textMarkerService != null)
                {
                    var         markersAtOffset   = textMarkerService.GetMarkersAtOffset(offset);
                    ITextMarker markerWithToolTip = markersAtOffset.FirstOrDefault(marker => marker.ToolTip != null);

                    if (markerWithToolTip != null)
                    {
                        args.SetToolTip(markerWithToolTip.ToolTip);
                    }
                }
            }

            if (!args.Handled)
            {
                // if request wasn't handled by a marker, pass it to the ToolTipRequestService
                ToolTipRequestService.RequestToolTip(args);
            }

            if (args.ContentToShow != null)
            {
                var contentToShowITooltip = args.ContentToShow as ITooltip;

                if (contentToShowITooltip != null && contentToShowITooltip.ShowAsPopup)
                {
                    if (!(args.ContentToShow is UIElement))
                    {
                        throw new NotSupportedException("Content to show in Popup must be UIElement: " + args.ContentToShow);
                    }
                    if (popup == null)
                    {
                        popup = CreatePopup();
                    }
                    // if popup was only first level, hovering somewhere else closes it
                    if (TryCloseExistingPopup(false))
                    {
                        // when popup content decides to close, close the popup
                        contentToShowITooltip.Closed += (closedSender, closedArgs) => { popup.IsOpen = false; };
                        popup.Child = (UIElement)args.ContentToShow;
                        //ICSharpCode.SharpDevelop.Debugging.DebuggerService.CurrentDebugger.IsProcessRunningChanged
                        SetPopupPosition(popup, e);
                        popup.IsOpen = true;
                    }
                    e.Handled = true;
                }
                else
                {
                    if (toolTip == null)
                    {
                        toolTip         = new ToolTip();
                        toolTip.Closed += ToolTipClosed;
                    }
                    toolTip.PlacementTarget = this;                     // required for property inheritance

                    if (args.ContentToShow is string)
                    {
                        toolTip.Content = new TextBlock
                        {
                            Text         = args.ContentToShow as string,
                            TextWrapping = TextWrapping.Wrap
                        };
                    }
                    else
                    {
                        toolTip.Content = args.ContentToShow;
                    }

                    toolTip.IsOpen = true;
                    e.Handled      = true;
                }
            }
            else
            {
                // close popup if mouse hovered over empty area
                if (popup != null)
                {
                    e.Handled = true;
                }
                TryCloseExistingPopup(false);
            }
        }
        string GetTooltipTextForCollapsedSection(FoldingSection foldingSection)
        {
            // This fixes SD-1394:
            // Each line is checked for leading indentation whitespaces. If
            // a line has the same or more indentation than the first line,
            // it is reduced. If a line is less indented than the first line
            // the indentation is removed completely.
            //
            // See the following example:
            //  line 1
            //      line 2
            //          line 3
            //  line 4
            //
            // is reduced to:
            // line 1
            //  line 2
            //      line 3
            // line 4

            const int maxLineCount = 15;

            TextDocument document    = this.Document;
            int          startOffset = foldingSection.StartOffset;
            int          endOffset   = foldingSection.EndOffset;

            DocumentLine  startLine = document.GetLineByOffset(startOffset);
            DocumentLine  endLine   = document.GetLineByOffset(endOffset);
            StringBuilder builder   = new StringBuilder();

            DocumentLine current     = startLine;
            ISegment     startIndent = TextUtilities.GetLeadingWhitespace(document, startLine);
            int          lineCount   = 0;

            while (current != endLine.NextLine && lineCount < maxLineCount)
            {
                ISegment currentIndent = TextUtilities.GetLeadingWhitespace(document, current);

                if (current == startLine && current == endLine)
                {
                    builder.Append(document.GetText(startOffset, endOffset - startOffset));
                }
                else if (current == startLine)
                {
                    if (current.EndOffset - startOffset > 0)
                    {
                        builder.AppendLine(document.GetText(startOffset, current.EndOffset - startOffset).TrimStart());
                    }
                }
                else if (current == endLine)
                {
                    if (startIndent.Length <= currentIndent.Length)
                    {
                        builder.Append(document.GetText(current.Offset + startIndent.Length, endOffset - current.Offset - startIndent.Length));
                    }
                    else
                    {
                        builder.Append(document.GetText(current.Offset + currentIndent.Length, endOffset - current.Offset - currentIndent.Length));
                    }
                }
                else
                {
                    if (startIndent.Length <= currentIndent.Length)
                    {
                        builder.AppendLine(document.GetText(current.Offset + startIndent.Length, current.Length - startIndent.Length));
                    }
                    else
                    {
                        builder.AppendLine(document.GetText(current.Offset + currentIndent.Length, current.Length - currentIndent.Length));
                    }
                }

                current = current.NextLine;
                lineCount++;
            }
            if (current != endLine.NextLine)
            {
                builder.Append("...");
            }

            return(builder.ToString());
        }
Exemple #31
0
 string GetTooltipTextForCollapsedSection(ToolTipRequestEventArgs args, FoldingSection foldingSection)
 {
     return(ToolTipUtils.GetAlignedText(args.Editor.Document, foldingSection.StartOffset, foldingSection.EndOffset));
 }
		public static bool IsDefinition(FoldingSection section)
		{
			return section.Tag is NewFoldingDefinition;
		}