diff options
Diffstat (limited to 'main/src/addins/AspNet/Razor/Dom')
9 files changed, 79 insertions, 37 deletions
diff --git a/main/src/addins/AspNet/Razor/Dom/RazorCodeBlock.cs b/main/src/addins/AspNet/Razor/Dom/RazorCodeBlock.cs index c6928acbfd..b8386bec5d 100644 --- a/main/src/addins/AspNet/Razor/Dom/RazorCodeBlock.cs +++ b/main/src/addins/AspNet/Razor/Dom/RazorCodeBlock.cs @@ -25,14 +25,14 @@ // THE SOFTWARE.
using MonoDevelop.Xml.Parser;
-using ICSharpCode.NRefactory;
using MonoDevelop.Xml.Dom;
+using MonoDevelop.Ide.Editor;
namespace MonoDevelop.AspNet.Razor.Dom
{
public class RazorCodeBlock : RazorCodeFragment
{
- public RazorCodeBlock (TextLocation start) : base (start)
+ public RazorCodeBlock (DocumentLocation start) : base (start)
{
}
diff --git a/main/src/addins/AspNet/Razor/Dom/RazorCodeFragment.cs b/main/src/addins/AspNet/Razor/Dom/RazorCodeFragment.cs index 19ff98708b..c4327c1364 100644 --- a/main/src/addins/AspNet/Razor/Dom/RazorCodeFragment.cs +++ b/main/src/addins/AspNet/Razor/Dom/RazorCodeFragment.cs @@ -25,16 +25,16 @@ // THE SOFTWARE.
using System.Linq;
-using ICSharpCode.NRefactory;
-using Mono.TextEditor;
using MonoDevelop.Ide;
using MonoDevelop.Xml.Dom;
+using MonoDevelop.Ide.Editor;
+using MonoDevelop.Ide.Editor.Util;
namespace MonoDevelop.AspNet.Razor.Dom
{
public abstract class RazorCodeFragment : XContainer
{
- protected RazorCodeFragment (TextLocation start) : base (start)
+ protected RazorCodeFragment (DocumentLocation start) : base (start)
{
}
@@ -44,34 +44,32 @@ namespace MonoDevelop.AspNet.Razor.Dom public string Name { get; set; }
- public TextLocation? FirstBracket { get; set; }
+ public DocumentLocation? FirstBracket { get; set; }
- public TextDocument Document {
+ public ITextDocument Document {
get {
- if (IdeApp.Workbench.ActiveDocument != null && IdeApp.Workbench.ActiveDocument.Editor != null)
- return IdeApp.Workbench.ActiveDocument.Editor.Document;
- return null;
+ return RazorWorkbenchService.ActiveDocument;
}
}
- public bool IsEndingBracket (TextLocation bracketLocation)
+ public bool IsEndingBracket (DocumentLocation bracketLocation)
{
// If document isn't entirely loaded
- if (Document == null || Document.Lines.Count () < Region.BeginLine)
+ if (Document == null || Document.LineCount < Region.BeginLine)
return false;
if (!FirstBracket.HasValue && !FindFirstBracket (bracketLocation))
return false;
- int firstBracketOffset = Document.GetOffset (FirstBracket.Value);
- int currentBracketOffset = Document.GetOffset (bracketLocation);
+ int firstBracketOffset = Document.LocationToOffset (FirstBracket.Value);
+ int currentBracketOffset = Document.LocationToOffset (bracketLocation);
- return Document.GetMatchingBracketOffset (firstBracketOffset) == currentBracketOffset;
+ return SimpleBracketMatcher.GetMatchingBracketOffset (Document, firstBracketOffset) == currentBracketOffset;
}
- public bool FindFirstBracket (TextLocation currentLocation)
+ public bool FindFirstBracket (DocumentLocation currentLocation)
{
- if (Document.Lines.Count () < Region.BeginLine)
+ if (Document.LineCount < Region.BeginLine)
return false;
int firstBracketPosition = Document.GetTextBetween (Region.Begin, currentLocation).IndexOf ('{');
diff --git a/main/src/addins/AspNet/Razor/Dom/RazorComment.cs b/main/src/addins/AspNet/Razor/Dom/RazorComment.cs index 1cb572a9d6..a9a11503bb 100644 --- a/main/src/addins/AspNet/Razor/Dom/RazorComment.cs +++ b/main/src/addins/AspNet/Razor/Dom/RazorComment.cs @@ -24,19 +24,18 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using ICSharpCode.NRefactory;
-using ICSharpCode.NRefactory.TypeSystem;
using MonoDevelop.Xml.Dom;
+using MonoDevelop.Ide.Editor;
namespace MonoDevelop.AspNet.Razor.Dom
{
public class RazorComment : XNode
{
- public RazorComment (DomRegion region) : base (region)
+ public RazorComment (DocumentRegion region) : base (region)
{
}
- public RazorComment (TextLocation start) : base (start)
+ public RazorComment (DocumentLocation start) : base (start)
{
}
diff --git a/main/src/addins/AspNet/Razor/Dom/RazorDirective.cs b/main/src/addins/AspNet/Razor/Dom/RazorDirective.cs index 7b1755d9a9..3eaebabb49 100644 --- a/main/src/addins/AspNet/Razor/Dom/RazorDirective.cs +++ b/main/src/addins/AspNet/Razor/Dom/RazorDirective.cs @@ -24,14 +24,14 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using ICSharpCode.NRefactory;
using MonoDevelop.Xml.Dom;
+using MonoDevelop.Ide.Editor;
namespace MonoDevelop.AspNet.Razor.Dom
{
public class RazorDirective : RazorCodeFragment
{
- public RazorDirective (TextLocation start) : base (start)
+ public RazorDirective (DocumentLocation start) : base (start)
{
}
diff --git a/main/src/addins/AspNet/Razor/Dom/RazorExplicitExpression.cs b/main/src/addins/AspNet/Razor/Dom/RazorExplicitExpression.cs index 15cbfc6637..80dcdae361 100644 --- a/main/src/addins/AspNet/Razor/Dom/RazorExplicitExpression.cs +++ b/main/src/addins/AspNet/Razor/Dom/RazorExplicitExpression.cs @@ -24,19 +24,18 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using ICSharpCode.NRefactory;
-using ICSharpCode.NRefactory.TypeSystem;
using MonoDevelop.Xml.Dom;
+using MonoDevelop.Ide.Editor;
namespace MonoDevelop.AspNet.Razor.Dom
{
public class RazorExplicitExpression : RazorExpression
{
- public RazorExplicitExpression (DomRegion region) : base (region)
+ public RazorExplicitExpression (DocumentRegion region) : base (region)
{
}
- public RazorExplicitExpression (TextLocation start) : base (start)
+ public RazorExplicitExpression (DocumentLocation start) : base (start)
{
}
diff --git a/main/src/addins/AspNet/Razor/Dom/RazorExpression.cs b/main/src/addins/AspNet/Razor/Dom/RazorExpression.cs index ef1ef4af95..81119710db 100644 --- a/main/src/addins/AspNet/Razor/Dom/RazorExpression.cs +++ b/main/src/addins/AspNet/Razor/Dom/RazorExpression.cs @@ -24,19 +24,18 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using ICSharpCode.NRefactory.TypeSystem;
-using ICSharpCode.NRefactory;
using MonoDevelop.Xml.Dom;
+using MonoDevelop.Ide.Editor;
namespace MonoDevelop.AspNet.Razor.Dom
{
public abstract class RazorExpression : XNode
{
- protected RazorExpression (DomRegion region) : base (region)
+ protected RazorExpression (DocumentRegion region) : base (region)
{
}
- protected RazorExpression (TextLocation start) : base (start)
+ protected RazorExpression (DocumentLocation start) : base (start)
{
}
diff --git a/main/src/addins/AspNet/Razor/Dom/RazorImplicitExpression.cs b/main/src/addins/AspNet/Razor/Dom/RazorImplicitExpression.cs index f87a500d74..9536a8b592 100644 --- a/main/src/addins/AspNet/Razor/Dom/RazorImplicitExpression.cs +++ b/main/src/addins/AspNet/Razor/Dom/RazorImplicitExpression.cs @@ -24,19 +24,18 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using ICSharpCode.NRefactory;
-using ICSharpCode.NRefactory.TypeSystem;
using MonoDevelop.Xml.Dom;
+using MonoDevelop.Ide.Editor;
namespace MonoDevelop.AspNet.Razor.Dom
{
public class RazorImplicitExpression : RazorExpression
{
- public RazorImplicitExpression (DomRegion region) : base (region)
+ public RazorImplicitExpression (DocumentRegion region) : base (region)
{
}
- public RazorImplicitExpression (TextLocation start) : base (start)
+ public RazorImplicitExpression (DocumentLocation start) : base (start)
{
}
diff --git a/main/src/addins/AspNet/Razor/Dom/RazorStatement.cs b/main/src/addins/AspNet/Razor/Dom/RazorStatement.cs index 7af1bbfccf..83fa1d7444 100644 --- a/main/src/addins/AspNet/Razor/Dom/RazorStatement.cs +++ b/main/src/addins/AspNet/Razor/Dom/RazorStatement.cs @@ -24,15 +24,15 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using ICSharpCode.NRefactory;
using MonoDevelop.Xml.Dom;
+using MonoDevelop.Ide.Editor;
namespace MonoDevelop.AspNet.Razor.Dom
{
public class RazorStatement : RazorCodeFragment
{
- public RazorStatement (TextLocation start) : base (start)
+ public RazorStatement (DocumentLocation start) : base (start)
{
}
diff --git a/main/src/addins/AspNet/Razor/Dom/RazorWorkbenchService.cs b/main/src/addins/AspNet/Razor/Dom/RazorWorkbenchService.cs new file mode 100644 index 0000000000..97280a15fd --- /dev/null +++ b/main/src/addins/AspNet/Razor/Dom/RazorWorkbenchService.cs @@ -0,0 +1,48 @@ +// +// RazorWorkbenchService.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using MonoDevelop.Ide; +using MonoDevelop.Ide.Editor; + +namespace MonoDevelop.AspNet.Razor.Dom +{ + internal static class RazorWorkbenchService + { + public static ITextDocument ActiveDocument { + get { + return GetActiveDocument (); + } + } + + internal static Func<ITextDocument> GetActiveDocument = () => { + if (IdeApp.Workbench.ActiveDocument != null && IdeApp.Workbench.ActiveDocument.Editor != null) + return IdeApp.Workbench.ActiveDocument.Editor; + return null; + }; + } +} + |