|
|
@ -2,11 +2,7 @@ |
|
|
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
|
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
|
|
|
|
|
|
|
|
|
|
using System; |
|
|
|
using System; |
|
|
|
using System.ComponentModel.Design; |
|
|
|
|
|
|
|
using System.Linq; |
|
|
|
|
|
|
|
using System.Windows.Controls.Primitives; |
|
|
|
using System.Windows.Controls.Primitives; |
|
|
|
|
|
|
|
|
|
|
|
using ICSharpCode.AvalonEdit.Document; |
|
|
|
|
|
|
|
using ICSharpCode.Core.Presentation; |
|
|
|
using ICSharpCode.Core.Presentation; |
|
|
|
using ICSharpCode.SharpDevelop.Editor; |
|
|
|
using ICSharpCode.SharpDevelop.Editor; |
|
|
|
using ICSharpCode.SharpDevelop.Gui; |
|
|
|
using ICSharpCode.SharpDevelop.Gui; |
|
|
@ -45,10 +41,14 @@ namespace ICSharpCode.AvalonEdit.AddIn.HiddenDefinition |
|
|
|
{ |
|
|
|
{ |
|
|
|
ClosePopup(); |
|
|
|
ClosePopup(); |
|
|
|
|
|
|
|
|
|
|
|
if (BracketSearchResult == null || BracketSearchResult.OpeningBracket != "{") return; |
|
|
|
if (BracketSearchResult == null) return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// verify if we have a open bracket
|
|
|
|
|
|
|
|
if (this.editor.Document.GetCharAt(BracketSearchResult.OpeningBracketOffset) != '{') |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
var line = GetLineText(BracketSearchResult.OpeningBracketOffset); |
|
|
|
var line = GetLineText(BracketSearchResult.OpeningBracketOffset); |
|
|
|
if(line == null) return; |
|
|
|
if(line == null) return; |
|
|
|
|
|
|
|
|
|
|
|
control.DefinitionText = line; |
|
|
|
control.DefinitionText = line; |
|
|
|
popup.Child = control; |
|
|
|
popup.Child = control; |
|
|
@ -60,19 +60,23 @@ namespace ICSharpCode.AvalonEdit.AddIn.HiddenDefinition |
|
|
|
|
|
|
|
|
|
|
|
private string GetLineText(int offset) |
|
|
|
private string GetLineText(int offset) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// get folding manager
|
|
|
|
// get line
|
|
|
|
var container = this.editor.Adapter.GetService(typeof(IServiceContainer)) as IServiceContainer; |
|
|
|
var line = editor.Document.GetLineByOffset(offset); |
|
|
|
if (container == null) return null; |
|
|
|
string text = editor.Document.Text; |
|
|
|
var folding = container.GetService(typeof(ParserFoldingStrategy)) as ParserFoldingStrategy; |
|
|
|
|
|
|
|
if (folding == null) return null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// get folding
|
|
|
|
while (true) { |
|
|
|
var f = folding.FoldingManager.GetFoldingsContaining(offset).LastOrDefault(); |
|
|
|
if (line == null || line.IsDeleted) return null; |
|
|
|
if (f == null) return null; |
|
|
|
string lineString = text.Substring(line.Offset, line.Length).Trim(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (lineString != "{" && !string.IsNullOrEmpty(lineString) && |
|
|
|
|
|
|
|
!lineString.StartsWith("//") && !lineString.StartsWith("/*") && |
|
|
|
|
|
|
|
!lineString.StartsWith("*") && !lineString.StartsWith("'")) |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
line = line.PreviousLine; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// get line
|
|
|
|
if (!editor.TextArea.TextView.VisualLinesValid) |
|
|
|
var line = editor.Document.GetLineByOffset(f.StartOffset); |
|
|
|
return null; |
|
|
|
if (line == null || line.IsDeleted) return null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// check whether the line is visible
|
|
|
|
// check whether the line is visible
|
|
|
|
int off = line.Offset; |
|
|
|
int off = line.Offset; |
|
|
|