diff --git a/TODOnewNR.txt b/TODOnewNR.txt index a9e77b4617..919327e636 100644 --- a/TODOnewNR.txt +++ b/TODOnewNR.txt @@ -13,6 +13,7 @@ Commented code, needs to be ported and re-enabled: FindReferencesAndRenameHelper NamespaceRefactoringsService RefactoringMenuBuilder + TaskService.UpdateCommentTags Stuff that was renamed/moved: ICSharpCode.SharpDevelop.Dom -> the type system and resolvers now are part of ICSharpCode.NRefactory diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj index aa1bf8f029..2832286487 100644 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj @@ -312,6 +312,7 @@ + diff --git a/src/Main/Base/Project/Src/Bookmarks/BookmarkBase.cs b/src/Main/Base/Project/Src/Bookmarks/BookmarkBase.cs index 980c7914de..3accd116b2 100644 --- a/src/Main/Base/Project/Src/Bookmarks/BookmarkBase.cs +++ b/src/Main/Base/Project/Src/Bookmarks/BookmarkBase.cs @@ -38,9 +38,9 @@ namespace ICSharpCode.SharpDevelop.Bookmarks void CreateAnchor() { if (document != null) { - int lineNumber = Math.Max(1, Math.Min(location.Line, document.TotalNumberOfLines)); - int lineLength = document.GetLine(lineNumber).Length; - int offset = document.PositionToOffset( + int lineNumber = Math.Max(1, Math.Min(location.Line, document.LineCount)); + int lineLength = document.GetLineByNumber(lineNumber).Length; + int offset = document.GetOffset( lineNumber, Math.Max(1, Math.Min(location.Column, lineLength + 1)) ); @@ -56,7 +56,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks void AnchorDeleted(object sender, EventArgs e) { // the anchor just became invalid, so don't try to use it again - location = Location.Empty; + location = TextLocation.Empty; anchor = null; RemoveMark(); } diff --git a/src/Main/Base/Project/Src/Bookmarks/BookmarkConverter.cs b/src/Main/Base/Project/Src/Bookmarks/BookmarkConverter.cs index 1caf27154d..3f8eed1ed9 100644 --- a/src/Main/Base/Project/Src/Bookmarks/BookmarkConverter.cs +++ b/src/Main/Base/Project/Src/Bookmarks/BookmarkConverter.cs @@ -6,8 +6,8 @@ using System.ComponentModel; using System.Globalization; using System.Text; using System.Windows; - using ICSharpCode.Core; +using ICSharpCode.Editor; using ICSharpCode.NRefactory; namespace ICSharpCode.SharpDevelop.Bookmarks @@ -45,7 +45,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks scriptLanguage = v[6]; script = v[7]; - var bbm = new Debugging.BreakpointBookmark(fileName, new Location(columnNumber, lineNumber), action, scriptLanguage, script); + var bbm = new Debugging.BreakpointBookmark(fileName, new TextLocation(columnNumber, lineNumber), action, scriptLanguage, script); bbm.IsEnabled = bool.Parse(v[4]); bbm.Action = action; bbm.ScriptLanguage = scriptLanguage; @@ -53,7 +53,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks bookmark = bbm; break; case "PinBookmark": - var pin = new PinBookmark(fileName, new Location(columnNumber, lineNumber)); + var pin = new PinBookmark(fileName, new TextLocation(columnNumber, lineNumber)); pin.Comment = v[4]; pin.PinPosition = new Point @@ -71,7 +71,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks bookmark = pin; break; default: - bookmark = new Bookmark(fileName, new Location(columnNumber, lineNumber)); + bookmark = new Bookmark(fileName, new TextLocation(columnNumber, lineNumber)); break; } return bookmark; diff --git a/src/Main/Base/Project/Src/Bookmarks/BookmarkManager.cs b/src/Main/Base/Project/Src/Bookmarks/BookmarkManager.cs index 3aa3317493..ee5d9ef43d 100644 --- a/src/Main/Base/Project/Src/Bookmarks/BookmarkManager.cs +++ b/src/Main/Base/Project/Src/Bookmarks/BookmarkManager.cs @@ -110,16 +110,16 @@ namespace ICSharpCode.SharpDevelop.Bookmarks Predicate canToggle, Func bookmarkFactory) { - foreach (SDBookmark bookmark in GetBookmarks(new FileName(editor.FileName))) { + foreach (SDBookmark bookmark in GetBookmarks(FileName.Create(editor.FileName))) { if (canToggle(bookmark) && bookmark.LineNumber == line) { BookmarkManager.RemoveMark(bookmark); return; } } // no bookmark at that line: create a new bookmark - int lineStartOffset = editor.Document.GetLine(line).Offset; + int lineStartOffset = editor.Document.GetLineByNumber(line).Offset; int column = 1 + DocumentUtilitites.GetWhitespaceAfter(editor.Document, lineStartOffset).Length; - BookmarkManager.AddMark(bookmarkFactory(new Location(column, line))); + BookmarkManager.AddMark(bookmarkFactory(new TextLocation(column, line))); } public static void RemoveAll(Predicate match) diff --git a/src/Main/Base/Project/Src/Commands/DebugCommands.cs b/src/Main/Base/Project/Src/Commands/DebugCommands.cs index 89e348a0d7..e5fe53e748 100644 --- a/src/Main/Base/Project/Src/Commands/DebugCommands.cs +++ b/src/Main/Base/Project/Src/Commands/DebugCommands.cs @@ -5,8 +5,8 @@ using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; - using ICSharpCode.Core; +using ICSharpCode.Editor; using ICSharpCode.SharpDevelop.Bookmarks; using ICSharpCode.SharpDevelop.Bookmarks.Pad.Controls; using ICSharpCode.SharpDevelop.Debugging; diff --git a/src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditTextEditorAdapter.cs b/src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditTextEditorAdapter.cs index fd14717556..4a62669937 100755 --- a/src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditTextEditorAdapter.cs +++ b/src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditTextEditorAdapter.cs @@ -21,7 +21,7 @@ namespace ICSharpCode.SharpDevelop.Editor.AvalonEdit /// /// Wraps AvalonEdit to provide the ITextEditor interface. /// - public class AvalonEditTextEditorAdapter : ITextEditor, IWeakEventListener + public class AvalonEditTextEditorAdapter : ITextEditor { readonly TextEditor textEditor; @@ -34,10 +34,7 @@ namespace ICSharpCode.SharpDevelop.Editor.AvalonEdit if (textEditor == null) throw new ArgumentNullException("textEditor"); this.textEditor = textEditor; - this.Caret = new CaretAdapter(textEditor.TextArea.Caret); this.Options = new OptionsAdapter(textEditor.Options); - TextEditorWeakEventManager.DocumentChanged.AddListener(textEditor, this); - OnDocumentChanged(); } public static TextEditor CreateAvalonEditInstance() @@ -49,28 +46,6 @@ namespace ICSharpCode.SharpDevelop.Editor.AvalonEdit return (TextEditor)editor; } - protected virtual bool ReceiveWeakEvent(Type managerType, object sender, EventArgs e) - { - if (managerType == typeof(TextEditorWeakEventManager.DocumentChanged)) { - OnDocumentChanged(); - return true; - } - return false; - } - - bool IWeakEventListener.ReceiveWeakEvent(Type managerType, object sender, EventArgs e) - { - return ReceiveWeakEvent(managerType, sender, e); - } - - void OnDocumentChanged() - { - if (textEditor.Document != null) - document = new AvalonEditDocumentAdapter(textEditor.Document, this); - else - document = null; - } - public IDocument Document { get { return textEditor.Document; } } diff --git a/src/Main/Base/Project/Src/Editor/AvalonEdit/IndentationStrategyAdapter.cs b/src/Main/Base/Project/Src/Editor/AvalonEdit/IndentationStrategyAdapter.cs index fad1f53602..989bd189d1 100644 --- a/src/Main/Base/Project/Src/Editor/AvalonEdit/IndentationStrategyAdapter.cs +++ b/src/Main/Base/Project/Src/Editor/AvalonEdit/IndentationStrategyAdapter.cs @@ -31,7 +31,7 @@ namespace ICSharpCode.SharpDevelop.Editor.AvalonEdit { if (line == null) throw new ArgumentNullException("line"); - formattingStrategy.IndentLine(editor, editor.Document.GetLine(line.LineNumber)); + formattingStrategy.IndentLine(editor, editor.Document.GetLineByNumber(line.LineNumber)); } public virtual void IndentLines(TextDocument document, int beginLine, int endLine) diff --git a/src/Main/Base/Project/Src/Editor/Commands/IndentSelection.cs b/src/Main/Base/Project/Src/Editor/Commands/IndentSelection.cs index 522dcdae98..47c81fc7f8 100644 --- a/src/Main/Base/Project/Src/Editor/Commands/IndentSelection.cs +++ b/src/Main/Base/Project/Src/Editor/Commands/IndentSelection.cs @@ -26,11 +26,11 @@ namespace ICSharpCode.SharpDevelop.Editor.Commands return; int beginLine = 1; - int endLine = provider.TextEditor.Document.TotalNumberOfLines; + int endLine = provider.TextEditor.Document.LineCount; if (provider.TextEditor.SelectionLength != 0) { - beginLine = provider.TextEditor.Document.GetLineForOffset(provider.TextEditor.SelectionStart).LineNumber; - endLine = provider.TextEditor.Document.GetLineForOffset(provider.TextEditor.SelectionStart + provider.TextEditor.SelectionLength).LineNumber; + beginLine = provider.TextEditor.Document.GetLineByOffset(provider.TextEditor.SelectionStart).LineNumber; + endLine = provider.TextEditor.Document.GetLineByOffset(provider.TextEditor.SelectionStart + provider.TextEditor.SelectionLength).LineNumber; } provider.TextEditor.Language.FormattingStrategy.IndentLines(provider.TextEditor, beginLine, endLine); diff --git a/src/Main/Base/Project/Src/Editor/Commands/PasteAsCommands.cs b/src/Main/Base/Project/Src/Editor/Commands/PasteAsCommands.cs index 5196e12e1b..b7df41ec48 100644 --- a/src/Main/Base/Project/Src/Editor/Commands/PasteAsCommands.cs +++ b/src/Main/Base/Project/Src/Editor/Commands/PasteAsCommands.cs @@ -36,7 +36,7 @@ namespace ICSharpCode.SharpDevelop.Editor.Commands protected string GetIndentation(IDocument document, int line) { - return DocumentUtilitites.GetWhitespaceAfter(document, document.GetLine(line).Offset); + return DocumentUtilitites.GetWhitespaceAfter(document, document.GetLineByNumber(line).Offset); } } @@ -66,7 +66,7 @@ namespace ICSharpCode.SharpDevelop.Editor.Commands } } IDocument document = editor.Document; - int insertionPos = document.GetLine(editor.Caret.Line).Offset + indentation.Length; + int insertionPos = document.GetLineByNumber(editor.Caret.Line).Offset + indentation.Length; document.Insert(insertionPos, insertedText.ToString()); } diff --git a/src/Main/Base/Project/Src/Editor/DocumentUtilitites.cs b/src/Main/Base/Project/Src/Editor/DocumentUtilitites.cs index aa53757fe9..d300d5e2f6 100644 --- a/src/Main/Base/Project/Src/Editor/DocumentUtilitites.cs +++ b/src/Main/Base/Project/Src/Editor/DocumentUtilitites.cs @@ -69,7 +69,7 @@ namespace ICSharpCode.SharpDevelop.Editor if (newLineText == null) throw new ArgumentNullException("newLineText"); string newLineTextTrim = newLineText.Trim(whitespaceChars); - string oldLineText = line.Text; + string oldLineText = document.GetText(line); if (oldLineText == newLineText) return; int pos = oldLineText.IndexOf(newLineTextTrim, StringComparison.Ordinal); @@ -150,7 +150,7 @@ namespace ICSharpCode.SharpDevelop.Editor public static string GetWhitespaceAfter(ITextSource textSource, int offset) { ISegment segment = TextUtilities.GetWhitespaceAfter(textSource, offset); - return textBuffer.GetText(segment.Offset, segment.Length); + return textSource.GetText(segment.Offset, segment.Length); } /// @@ -162,7 +162,7 @@ namespace ICSharpCode.SharpDevelop.Editor public static string GetWhitespaceBefore(ITextSource textSource, int offset) { ISegment segment = TextUtilities.GetWhitespaceBefore(textSource, offset); - return textBuffer.GetText(segment.Offset, segment.Length); + return textSource.GetText(segment.Offset, segment.Length); } /// @@ -170,13 +170,13 @@ namespace ICSharpCode.SharpDevelop.Editor /// public static string GetLineTerminator(IDocument document, int lineNumber) { - IDocumentLine line = document.GetLine(lineNumber); + IDocumentLine line = document.GetLineByNumber(lineNumber); if (line.DelimiterLength == 0) { // at the end of the document, there's no line delimiter, so use the delimiter // from the previous line if (lineNumber == 1) return Environment.NewLine; - line = document.GetLine(lineNumber - 1); + line = document.GetLineByNumber(lineNumber - 1); } return document.GetText(line.Offset + line.Length, line.DelimiterLength); } @@ -195,7 +195,7 @@ namespace ICSharpCode.SharpDevelop.Editor { if (document == null) throw new ArgumentNullException("document"); - IDocumentLine line = document.GetLineForOffset(offset); + IDocumentLine line = document.GetLineByOffset(offset); text = NormalizeNewLines(text, document, line.LineNumber); document.Insert(offset, text); } diff --git a/src/Main/Base/Project/Src/Editor/IFormattingStrategy.cs b/src/Main/Base/Project/Src/Editor/IFormattingStrategy.cs index fda2531bea..bef62b96e1 100644 --- a/src/Main/Base/Project/Src/Editor/IFormattingStrategy.cs +++ b/src/Main/Base/Project/Src/Editor/IFormattingStrategy.cs @@ -47,7 +47,7 @@ namespace ICSharpCode.SharpDevelop.Editor IDocument document = editor.Document; int lineNumber = line.LineNumber; if (lineNumber > 1) { - IDocumentLine previousLine = document.GetLine(lineNumber - 1); + IDocumentLine previousLine = document.GetLineByNumber(lineNumber - 1); string indentation = DocumentUtilitites.GetWhitespaceAfter(document, previousLine.Offset); // copy indentation to line string newIndentation = DocumentUtilitites.GetWhitespaceAfter(document, line.Offset); @@ -59,7 +59,7 @@ namespace ICSharpCode.SharpDevelop.Editor { using (editor.Document.OpenUndoGroup()) { for (int i = begin; i <= end; i++) { - IndentLine(editor, editor.Document.GetLine(i)); + IndentLine(editor, editor.Document.GetLineByNumber(i)); } } } @@ -73,9 +73,10 @@ namespace ICSharpCode.SharpDevelop.Editor /// protected void SurroundSelectionWithSingleLineComment(ITextEditor editor, string comment) { - using (editor.Document.OpenUndoGroup()) { - Location startPosition = editor.Document.OffsetToPosition(editor.SelectionStart); - Location endPosition = editor.Document.OffsetToPosition(editor.SelectionStart + editor.SelectionLength); + IDocument document = editor.Document; + using (document.OpenUndoGroup()) { + TextLocation startPosition = document.GetLocation(editor.SelectionStart); + TextLocation endPosition = document.GetLocation(editor.SelectionStart + editor.SelectionLength); // endLine is one above endPosition if no characters are selected on the last line (e.g. line selection from the margin) int endLine = (endPosition.Column == 1 && endPosition.Line > startPosition.Line) ? endPosition.Line - 1 : endPosition.Line; @@ -84,16 +85,16 @@ namespace ICSharpCode.SharpDevelop.Editor bool removeComment = true; for (int i = startPosition.Line; i <= endLine; i++) { - lines.Add(editor.Document.GetLine(i)); - if (!lines[i - startPosition.Line].Text.Trim().StartsWith(comment, StringComparison.Ordinal)) + lines.Add(editor.Document.GetLineByNumber(i)); + if (!document.GetText(lines[i - startPosition.Line]).Trim().StartsWith(comment, StringComparison.Ordinal)) removeComment = false; } foreach (IDocumentLine line in lines) { if (removeComment) { - editor.Document.Remove(line.Offset + line.Text.IndexOf(comment, StringComparison.Ordinal), comment.Length); + document.Remove(line.Offset + document.GetText(line).IndexOf(comment, StringComparison.Ordinal), comment.Length); } else { - editor.Document.Insert(line.Offset, comment, AnchorMovementType.BeforeInsertion); + document.Insert(line.Offset, comment, AnchorMovementType.BeforeInsertion); } } } @@ -109,7 +110,7 @@ namespace ICSharpCode.SharpDevelop.Editor int endOffset = editor.SelectionStart + editor.SelectionLength; if (editor.SelectionLength == 0) { - IDocumentLine line = editor.Document.GetLineForOffset(editor.SelectionStart); + IDocumentLine line = editor.Document.GetLineByOffset(editor.SelectionStart); startOffset = line.Offset; endOffset = line.Offset + line.Length; } diff --git a/src/Main/Base/Project/Src/Editor/PermanentAnchor.cs b/src/Main/Base/Project/Src/Editor/PermanentAnchor.cs index c9d19c876f..7b76f88504 100644 --- a/src/Main/Base/Project/Src/Editor/PermanentAnchor.cs +++ b/src/Main/Base/Project/Src/Editor/PermanentAnchor.cs @@ -48,9 +48,9 @@ namespace ICSharpCode.SharpDevelop.Editor return; Debug.Assert(currentDocument == null && document != null); this.currentDocument = document; - line = Math.Min(line, document.TotalNumberOfLines); - column = Math.Min(column, document.GetLine(line).Length + 1); - baseAnchor = document.CreateAnchor(document.PositionToOffset(line, column)); + line = Math.Min(line, document.LineCount); + column = Math.Min(column, document.GetLineByNumber(line).Length + 1); + baseAnchor = document.CreateAnchor(document.GetOffset(line, column)); baseAnchor.MovementType = movementType; baseAnchor.SurviveDeletion = surviveDeletion; baseAnchor.Deleted += baseAnchor_Deleted; @@ -62,7 +62,7 @@ namespace ICSharpCode.SharpDevelop.Editor return; Debug.Assert(currentDocument != null); - Location loc = baseAnchor.Location; + TextLocation loc = baseAnchor.Location; line = loc.Line; column = loc.Column; @@ -111,7 +111,7 @@ namespace ICSharpCode.SharpDevelop.Editor if (baseAnchor != null) return baseAnchor.Location; else - return new Location(column, line); + return new TextLocation(column, line); } } diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/ExtractInterfaceDialog.Designer.cs b/src/Main/Base/Project/Src/Gui/Dialogs/ExtractInterfaceDialog.Designer.cs index ccecac0f13..c47a69d7f8 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/ExtractInterfaceDialog.Designer.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/ExtractInterfaceDialog.Designer.cs @@ -3,7 +3,7 @@ namespace ICSharpCode.SharpDevelop.Gui { - partial class ExtractInterfaceDialog + partial class ExtractInterfaceDialog : System.Windows.Forms.Form { /// /// Designer variable used to keep track of non-visual components. diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/GotoDialog.cs b/src/Main/Base/Project/Src/Gui/Dialogs/GotoDialog.cs index 32f2a95fda..da0da5c8ba 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/GotoDialog.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/GotoDialog.cs @@ -233,7 +233,7 @@ namespace ICSharpCode.SharpDevelop.Gui if (int.TryParse(text, out num)) { ITextEditor editor = GetEditor(); if (editor != null) { - num = Math.Min(editor.Document.TotalNumberOfLines, Math.Max(1, num)); + num = Math.Min(editor.Document.LineCount, Math.Max(1, num)); AddItem(StringParser.Parse("${res:Dialog.Goto.GotoLine} ") + num, ClassBrowserIconService.GotoArrow, num, int.MaxValue); } } @@ -361,7 +361,7 @@ namespace ICSharpCode.SharpDevelop.Gui if (tag is int) { ITextEditor editor = GetEditor(); if (editor != null) { - int i = Math.Min(editor.Document.TotalNumberOfLines, Math.Max(1, (int)tag)); + int i = Math.Min(editor.Document.LineCount, Math.Max(1, (int)tag)); editor.JumpTo(i, int.MaxValue); } } else if (tag is IClass) { diff --git a/src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs b/src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs index 6234894a40..8e9f171678 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs @@ -9,9 +9,9 @@ using System.ComponentModel.Design; using System.Drawing; using System.Linq; using System.Windows.Forms; - using ICSharpCode.Core; using ICSharpCode.Core.WinForms; +using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.SharpDevelop.Project; namespace ICSharpCode.SharpDevelop.Gui @@ -412,15 +412,17 @@ namespace ICSharpCode.SharpDevelop.Gui if (gridItem != null) { Type component = gridItem.PropertyDescriptor.ComponentType; if (component != null) { - ICSharpCode.SharpDevelop.Dom.IClass c = ParserService.CurrentProjectContent.GetClass(component.FullName, 0); - if (c != null) { - foreach (ICSharpCode.SharpDevelop.Dom.IProperty p in c.DefaultReturnType.GetProperties()) { - if (gridItem.PropertyDescriptor.Name == p.Name) { - HelpProvider.ShowHelp(p); - return; + using (var ctx = ParserService.CurrentTypeResolveContext.Synchronize()) { + ITypeDefinition c = ctx.GetTypeDefinition(component.Namespace, component.Name, 0, StringComparer.Ordinal); + if (c != null) { + foreach (IProperty p in c.GetProperties(ctx)) { + if (gridItem.PropertyDescriptor.Name == p.Name) { + HelpProvider.ShowHelp(p); + return; + } } + HelpProvider.ShowHelp(c); } - HelpProvider.ShowHelp(c); } } } diff --git a/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskListPad.cs b/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskListPad.cs index fcbf613fd6..09422978ba 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskListPad.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskListPad.cs @@ -97,8 +97,8 @@ namespace ICSharpCode.SharpDevelop.Gui if (provider != null) { // ensure we don't attach multiple times to the same editor - provider.TextEditor.Caret.PositionChanged -= CaretPositionChanged; - provider.TextEditor.Caret.PositionChanged += CaretPositionChanged; + provider.TextEditor.Caret.LocationChanged -= CaretPositionChanged; + provider.TextEditor.Caret.LocationChanged += CaretPositionChanged; } } @@ -106,11 +106,11 @@ namespace ICSharpCode.SharpDevelop.Gui { if (this.selectedScopeIndex > 2) { - IClass current = GetCurrentClass(); + ITypeDefinition current = GetCurrentClass(); if (oldClass == null) oldClass = current; - if ((current != null) && (current.FullyQualifiedName != oldClass.FullyQualifiedName)) + if ((current != null) && (current.ReflectionName != oldClass.ReflectionName)) UpdateItems(); } } @@ -179,8 +179,8 @@ namespace ICSharpCode.SharpDevelop.Gui bool IsInScope(Task item) { - IClass current = GetCurrentClass(); - IClass itemClass = GetCurrentClass(item); + ITypeDefinition current = GetCurrentClass(); + ITypeDefinition itemClass = GetCurrentClass(item); switch (this.selectedScopeIndex) { case 0: @@ -209,11 +209,11 @@ namespace ICSharpCode.SharpDevelop.Gui if (WorkbenchSingleton.Workbench.ActiveViewContent == null) return null; - ParseInformation parseInfo = ParserService.GetParseInformation(WorkbenchSingleton.Workbench.ActiveViewContent.PrimaryFileName); + IParsedFile parseInfo = ParserService.GetParseInformation(WorkbenchSingleton.Workbench.ActiveViewContent.PrimaryFileName); if (parseInfo != null) { IPositionable positionable = WorkbenchSingleton.Workbench.ActiveViewContent as IPositionable; if (positionable != null) { - IClass c = parseInfo.CompilationUnit.GetInnermostClass(positionable.Line, positionable.Column); + ITypeDefinition c = parseInfo.GetTypeDefinition(positionable.Line, positionable.Column); if (c != null) return c; } } @@ -226,9 +226,9 @@ namespace ICSharpCode.SharpDevelop.Gui // Tasks are created by parsing, so the parse information for item.FileName should already be present. // If they aren't, that's because the file might have been deleted/renamed in the meantime. // We use GetExistingParseInformation to avoid trying to parse a file that might have been deleted/renamed. - ParseInformation parseInfo = ParserService.GetExistingParseInformation(item.FileName); + IParsedFile parseInfo = ParserService.GetExistingParseInformation(item.FileName); if (parseInfo != null) { - IClass c = parseInfo.CompilationUnit.GetInnermostClass(item.Line, item.Column); + ITypeDefinition c = parseInfo.GetTypeDefinition(item.Line, item.Column); if (c != null) return c; } diff --git a/src/Main/Base/Project/Src/Project/IProject.cs b/src/Main/Base/Project/Src/Project/IProject.cs index 2d95f9cf21..ab93bcae89 100644 --- a/src/Main/Base/Project/Src/Project/IProject.cs +++ b/src/Main/Base/Project/Src/Project/IProject.cs @@ -218,13 +218,6 @@ namespace ICSharpCode.SharpDevelop.Project /// True, if a debugger should be used for the project. void Start(bool withDebugging); - /// - /// Creates a new project content for this project. - /// This method should only be called by ParserService.LoadSolutionProjectsInternal()! - /// Return null if you don't want to create any project content. - /// - IProjectContent CreateProjectContent(); - /// /// Creates a new ProjectItem for the passed MSBuild item. /// diff --git a/src/Main/Base/Project/Src/Project/MSBuildInternals.cs b/src/Main/Base/Project/Src/Project/MSBuildInternals.cs index 244cf50c6d..d4f6ac9cc6 100644 --- a/src/Main/Base/Project/Src/Project/MSBuildInternals.cs +++ b/src/Main/Base/Project/Src/Project/MSBuildInternals.cs @@ -220,7 +220,7 @@ namespace ICSharpCode.SharpDevelop.Project string originalInclude = item.GetMetadataValue("OriginalItemSpec"); ReferenceProjectItem reference; if (referenceDict.TryGetValue(originalInclude, out reference)) { - reference.AssemblyName = new Dom.DomAssemblyName(item.GetMetadataValue("FusionName")); + reference.AssemblyName = new DomAssemblyName(item.GetMetadataValue("FusionName")); //string fullPath = item.GetEvaluatedMetadata("FullPath"); is incorrect for relative paths string fullPath = FileUtility.GetAbsolutePath(baseProject.Directory, item.GetMetadataValue("Identity")); reference.FileName = fullPath; diff --git a/src/Main/Base/Project/Src/Services/AmbienceService/IAmbience.cs b/src/Main/Base/Project/Src/Services/AmbienceService/IAmbience.cs new file mode 100644 index 0000000000..7854a8567b --- /dev/null +++ b/src/Main/Base/Project/Src/Services/AmbienceService/IAmbience.cs @@ -0,0 +1,12 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; + +namespace ICSharpCode.SharpDevelop +{ + public interface IAmbience + { + + } +} diff --git a/src/Main/Base/Project/Src/Services/ClassBrowserIcons/ClassBrowserIconService.cs b/src/Main/Base/Project/Src/Services/ClassBrowserIcons/ClassBrowserIconService.cs index 53386b8cc1..7d71e10857 100644 --- a/src/Main/Base/Project/Src/Services/ClassBrowserIcons/ClassBrowserIconService.cs +++ b/src/Main/Base/Project/Src/Services/ClassBrowserIcons/ClassBrowserIconService.cs @@ -223,8 +223,8 @@ namespace ICSharpCode.SharpDevelop return GetIcon(entity as IField); else if (entity is IEvent) return GetIcon(entity as IEvent); - else if (entity is IClass) - return GetIcon(entity as IClass); + else if (entity is ITypeDefinition) + return GetIcon(entity as ITypeDefinition); else throw new ArgumentException("unknown entity type"); } @@ -234,35 +234,44 @@ namespace ICSharpCode.SharpDevelop if (method.IsOperator) return Operator; else if (method.IsExtensionMethod) - return entityImages[ExtensionMethodIndex + GetModifierOffset(method.Modifiers)]; + return entityImages[ExtensionMethodIndex + GetModifierOffset(method.Accessibility)]; else - return entityImages[MethodIndex + GetModifierOffset(method.Modifiers)]; + return entityImages[MethodIndex + GetModifierOffset(method.Accessibility)]; } public static ClassBrowserImage GetIcon(IProperty property) { if (property.IsIndexer) - return entityImages[IndexerIndex + GetModifierOffset(property.Modifiers)]; + return entityImages[IndexerIndex + GetModifierOffset(property.Accessibility)]; else - return entityImages[PropertyIndex + GetModifierOffset(property.Modifiers)]; + return entityImages[PropertyIndex + GetModifierOffset(property.Accessibility)]; } public static ClassBrowserImage GetIcon(IField field) { if (field.IsConst) { return Const; - } else if (field.IsParameter) { + } else { + return entityImages[FieldIndex + GetModifierOffset(field.Accessibility)]; + } + } + + public static ClassBrowserImage GetIcon(IVariable v) + { + if (v.IsConst) { + return Const; + } else if (v is IField) { + return GetIcon((IField)v); + } else if (v is IParameter) { return Parameter; - } else if (field.IsLocalVariable) { - return LocalVariable; } else { - return entityImages[FieldIndex + GetModifierOffset(field.Modifiers)]; + return LocalVariable; } } public static ClassBrowserImage GetIcon(IEvent evt) { - return entityImages[EventIndex + GetModifierOffset(evt.Modifiers)]; + return entityImages[EventIndex + GetModifierOffset(evt.Accessibility)]; } public static ClassBrowserImage GetIcon(ITypeDefinition c) @@ -282,97 +291,7 @@ namespace ICSharpCode.SharpDevelop imageIndex = InterfaceIndex; break; } - return entityImages[imageIndex + GetModifierOffset(c.Modifiers)]; - } - - static int GetVisibilityOffset(MethodBase methodinfo) - { - if (methodinfo.IsAssembly) { - return internalModifierOffset; - } - if (methodinfo.IsPrivate) { - return privateModifierOffset; - } - if (!(methodinfo.IsPrivate || methodinfo.IsPublic)) { - return protectedModifierOffset; - } - return 0; - } - - public static ClassBrowserImage GetIcon(MethodBase methodinfo) - { - return entityImages[MethodIndex + GetVisibilityOffset(methodinfo)]; - } - - public static ClassBrowserImage GetIcon(PropertyInfo propertyinfo) - { - if (propertyinfo.CanRead && propertyinfo.GetGetMethod(true) != null) { - return entityImages[PropertyIndex + GetVisibilityOffset(propertyinfo.GetGetMethod(true))]; - } - if (propertyinfo.CanWrite && propertyinfo.GetSetMethod(true) != null) { - return entityImages[PropertyIndex + GetVisibilityOffset(propertyinfo.GetSetMethod(true))]; - } - return entityImages[PropertyIndex]; - } - - public static ClassBrowserImage GetIcon(FieldInfo fieldinfo) - { - if (fieldinfo.IsLiteral) { - return Const; - } - - if (fieldinfo.IsAssembly) { - return entityImages[FieldIndex + internalModifierOffset]; - } - - if (fieldinfo.IsPrivate) { - return entityImages[FieldIndex + privateModifierOffset]; - } - - if (!(fieldinfo.IsPrivate || fieldinfo.IsPublic)) { - return entityImages[FieldIndex + protectedModifierOffset]; - } - - return entityImages[FieldIndex]; - } - - public static ClassBrowserImage GetIcon(EventInfo eventinfo) - { - if (eventinfo.GetAddMethod(true) != null) { - return entityImages[EventIndex + GetVisibilityOffset(eventinfo.GetAddMethod(true))]; - } - return entityImages[EventIndex]; - } - - public static ClassBrowserImage GetIcon(System.Type type) - { - int BASE = ClassIndex; - - if (type.IsValueType) { - BASE = StructIndex; - } - if (type.IsEnum) { - BASE = EnumIndex; - } - if (type.IsInterface) { - BASE = InterfaceIndex; - } - if (type.IsSubclassOf(typeof(System.Delegate))) { - BASE = DelegateIndex; - } - - if (type.IsNestedPrivate) { - return entityImages[BASE + privateModifierOffset]; - } - - if (type.IsNotPublic || type.IsNestedAssembly) { - return entityImages[BASE + internalModifierOffset]; - } - - if (type.IsNestedFamily) { - return entityImages[BASE + protectedModifierOffset]; - } - return entityImages[BASE]; + return entityImages[imageIndex + GetModifierOffset(c.Accessibility)]; } #endregion diff --git a/src/Main/Base/Project/Src/Services/Debugger/BreakpointBookmark.cs b/src/Main/Base/Project/Src/Services/Debugger/BreakpointBookmark.cs index bd9f874060..60b398f2a5 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/BreakpointBookmark.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/BreakpointBookmark.cs @@ -109,7 +109,7 @@ namespace ICSharpCode.SharpDevelop.Debugging protected override ITextMarker CreateMarker(ITextMarkerService markerService) { - IDocumentLine line = this.Document.GetLine(this.LineNumber); + IDocumentLine line = this.Document.GetLineByNumber(this.LineNumber); ITextMarker marker = markerService.Create(line.Offset, line.Length); marker.BackgroundColor = Color.FromRgb(180, 38, 38); marker.ForegroundColor = Colors.White; diff --git a/src/Main/Base/Project/Src/Services/Debugger/CurrentLineBookmark.cs b/src/Main/Base/Project/Src/Services/Debugger/CurrentLineBookmark.cs index dfce2bc4a0..6c5f5e8443 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/CurrentLineBookmark.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/CurrentLineBookmark.cs @@ -39,16 +39,16 @@ namespace ICSharpCode.SharpDevelop.Debugging endLine = makerEndLine; endColumn = makerEndColumn; - if (startLine < 1 || startLine > document.TotalNumberOfLines) + if (startLine < 1 || startLine > document.LineCount) return; - if (endLine < 1 || endLine > document.TotalNumberOfLines) { + if (endLine < 1 || endLine > document.LineCount) { endLine = startLine; endColumn = int.MaxValue; } if (startColumn < 1) startColumn = 1; - IDocumentLine line = document.GetLine(startLine); + IDocumentLine line = document.GetLineByNumber(startLine); if (endColumn < 1 || endColumn > line.Length) endColumn = line.Length; instance = new CurrentLineBookmark(fileName, new Location(startColumn, startLine)); @@ -87,7 +87,7 @@ namespace ICSharpCode.SharpDevelop.Debugging protected override ITextMarker CreateMarker(ITextMarkerService markerService) { - IDocumentLine line = this.Document.GetLine(startLine); + IDocumentLine line = this.Document.GetLineByNumber(startLine); ITextMarker marker = markerService.Create(line.Offset + startColumn - 1, Math.Max(endColumn - startColumn, 1)); marker.BackgroundColor = Colors.Yellow; marker.ForegroundColor = Colors.Blue; diff --git a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs index c45fd44619..08270bb2d6 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs @@ -266,7 +266,7 @@ namespace ICSharpCode.SharpDevelop.Debugging IExpressionFinder expressionFinder = ParserService.GetExpressionFinder(e.Editor.FileName); if (expressionFinder == null) return; - var currentLine = doc.GetLine(logicPos.Y); + var currentLine = doc.GetLineByNumber(logicPos.Y); if (logicPos.X > currentLine.Length) return; /* diff --git a/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs b/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs index f6f9b484fb..4708bfbf5b 100644 --- a/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs +++ b/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs @@ -46,6 +46,17 @@ namespace ICSharpCode.SharpDevelop } } + public static ITypeResolveContext CurrentTypeResolveContext { + get { + throw new NotImplementedException(); + } + } + + public static ITypeResolveContext GetTypeResolveContext(IProject project) + { + throw new NotImplementedException(); + } + public static IProjectContent GetProjectContent(IProject project) { lock (projectContents) { @@ -171,7 +182,7 @@ namespace ICSharpCode.SharpDevelop if (GetParser(fileName) == null) return; - ITextBuffer snapshot; + ITextSource snapshot; IEditable editable = viewContent as IEditable; if (editable != null) snapshot = editable.CreateSnapshot(); @@ -179,8 +190,8 @@ namespace ICSharpCode.SharpDevelop snapshot = GetParseableFileContent(viewContent.PrimaryFileName); lastParseRun = BeginParse(fileName, snapshot).ContinueWith( - delegate(Task backgroundTask) { - ParseInformation parseInfo = backgroundTask.Result; + delegate(Task backgroundTask) { + IParsedFile parseInfo = backgroundTask.Result; RaiseParserUpdateStepFinished(new ParserUpdateStepEventArgs(fileName, snapshot, parseInfo)); }); } @@ -270,7 +281,7 @@ namespace ICSharpCode.SharpDevelop #endregion #region Parse Information Management - static readonly IParsedFile[] emptyCompilationUnitArray = new ICompilationUnit[0]; + static readonly IParsedFile[] emptyCompilationUnitArray = new IParsedFile[0]; sealed class FileEntry { @@ -300,7 +311,7 @@ namespace ICSharpCode.SharpDevelop public IParsedFile GetParseInformation(IProjectContent content) { - ParseInformation p = GetExistingParseInformation(content); + IParsedFile p = GetExistingParseInformation(content); if (p != null) return p; else @@ -317,7 +328,7 @@ namespace ICSharpCode.SharpDevelop return p; lock (this) { if (this.oldUnits != null) { - ICompilationUnit cu = this.oldUnits.FirstOrDefault(c => c.ProjectContent == content); + IParsedFile cu = this.oldUnits.FirstOrDefault(c => c.ProjectContent == content); return cu; } else { return null; @@ -349,7 +360,7 @@ namespace ICSharpCode.SharpDevelop // Detect when a file belongs to multiple projects but the ParserService hasn't realized // that, yet. In this case, do another parse run to detect all parent projects. if (!(parentProjectContent != null && this.oldUnits.Length == 1 && this.oldUnits[0].ProjectContent != parentProjectContent)) { - return this.parseInfo; + return this.mainParseInfo; } } } @@ -368,8 +379,8 @@ namespace ICSharpCode.SharpDevelop // risking deadlocks. // parse once for each project content that contains the file - ICompilationUnit[] newUnits = new ICompilationUnit[projectContents.Count]; - ICompilationUnit resultUnit = null; + IParsedFile[] newUnits = new IParsedFile[projectContents.Count]; + IParsedFile resultUnit = null; for (int i = 0; i < newUnits.Length; i++) { IProjectContent pc = projectContents[i]; try { @@ -387,59 +398,58 @@ namespace ICSharpCode.SharpDevelop // ensure we never go backwards in time (we need to repeat this check after we've reacquired the lock) if (fileContentVersion != null && this.bufferVersion != null && this.bufferVersion.BelongsToSameDocumentAs(fileContentVersion)) { if (this.bufferVersion.CompareAge(fileContentVersion) >= 0) { - if (parentProjectContent != null && parentProjectContent != parseInfo.CompilationUnit.ProjectContent) { - ICompilationUnit oldUnit = oldUnits.FirstOrDefault(o => o.ProjectContent == parentProjectContent); + if (parentProjectContent != null) { + IParsedFile oldUnit = oldUnits.FirstOrDefault(o => o.ProjectContent == parentProjectContent); if (oldUnit != null) - return new ParseInformation(oldUnit); + return oldUnit; } - return this.parseInfo; + return this.mainParseInfo; } } - ParseInformation newParseInfo = new ParseInformation(resultUnit); + IParsedFile newParseInfo = resultUnit; for (int i = 0; i < newUnits.Length; i++) { IProjectContent pc = projectContents[i]; // update the compilation unit - ICompilationUnit oldUnit = oldUnits.FirstOrDefault(o => o.ProjectContent == pc); + IParsedFile oldUnit = oldUnits.FirstOrDefault(o => o.ProjectContent == pc); pc.UpdateCompilationUnit(oldUnit, newUnits[i], fileName); - ParseInformation newUnitParseInfo = (newUnits[i] == resultUnit) ? newParseInfo : new ParseInformation(newUnits[i]); - RaiseParseInformationUpdated(new ParseInformationEventArgs(fileName, pc, oldUnit, newUnitParseInfo, newUnits[i] == resultUnit)); + RaiseParseInformationUpdated(new ParseInformationEventArgs(oldUnit, newUnits[i], newUnits[i] == resultUnit)); } // remove all old units that don't exist anymore - foreach (ICompilationUnit oldUnit in oldUnits) { + foreach (IParsedFile oldUnit in oldUnits) { if (!newUnits.Any(n => n.ProjectContent == oldUnit.ProjectContent)) { oldUnit.ProjectContent.RemoveCompilationUnit(oldUnit); - RaiseParseInformationUpdated(new ParseInformationEventArgs(fileName, oldUnit.ProjectContent, oldUnit, null, false)); + RaiseParseInformationUpdated(new ParseInformationEventArgs(oldUnit, null, false)); } } this.bufferVersion = fileContentVersion; this.oldUnits = newUnits; - this.parseInfo = newParseInfo; + this.mainParseInfo = newParseInfo; return newParseInfo; } } public void Clear() { - ParseInformation parseInfo; - ICompilationUnit[] oldUnits; + IParsedFile parseInfo; + IParsedFile[] oldUnits; lock (this) { // by setting the disposed flag, we'll cause all running ParseFile() calls to return null and not // call into the parser anymore, so we can do the remainder of the clean-up work outside the lock this.disposed = true; - parseInfo = this.parseInfo; + parseInfo = this.mainParseInfo; oldUnits = this.oldUnits; this.oldUnits = null; this.bufferVersion = null; - this.parseInfo = null; + this.mainParseInfo = null; } - foreach (ICompilationUnit oldUnit in oldUnits) { + foreach (IParsedFile oldUnit in oldUnits) { oldUnit.ProjectContent.RemoveCompilationUnit(oldUnit); - bool isPrimary = parseInfo != null && parseInfo.CompilationUnit == oldUnit; - RaiseParseInformationUpdated(new ParseInformationEventArgs(fileName, oldUnit.ProjectContent, oldUnit, null, isPrimary)); + bool isPrimary = parseInfo == oldUnit; + RaiseParseInformationUpdated(new ParseInformationEventArgs(oldUnit, null, isPrimary)); } } diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsPopupBase.cs b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsPopupBase.cs index 27d8b06faa..4c4650b898 100644 --- a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsPopupBase.cs +++ b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsPopupBase.cs @@ -44,7 +44,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring var editorUIService = editor == null ? null : editor.GetService(typeof(IEditorUIService)) as IEditorUIService; if (editorUIService != null) { var document = editor.Document; - int offset = document.PositionToOffset(line, column); + int offset = document.GetOffset(line, column); if (openAtWordStart) { int wordStart = document.FindPrevWordStart(offset); if (wordStart != -1) { diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/ExtractInterfaceOptions.cs b/src/Main/Base/Project/Src/Services/RefactoringService/ExtractInterfaceOptions.cs index bad6d46de4..3d4a460478 100644 --- a/src/Main/Base/Project/Src/Services/RefactoringService/ExtractInterfaceOptions.cs +++ b/src/Main/Base/Project/Src/Services/RefactoringService/ExtractInterfaceOptions.cs @@ -50,7 +50,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring get { return String.Format("{0}{1}", this.NewInterfaceName, - Path.GetExtension(ClassEntity.CompilationUnit.FileName)); + Path.GetExtension(ClassEntity.Region.FileName)); } } } diff --git a/src/Main/Base/Project/Src/Services/Tasks/ErrorPainter.cs b/src/Main/Base/Project/Src/Services/Tasks/ErrorPainter.cs index a38b720c15..3f123ae48d 100644 --- a/src/Main/Base/Project/Src/Services/Tasks/ErrorPainter.cs +++ b/src/Main/Base/Project/Src/Services/Tasks/ErrorPainter.cs @@ -131,9 +131,9 @@ namespace ICSharpCode.SharpDevelop if (!CheckTask(task)) return; - if (task.Line >= 1 && task.Line <= textEditor.Document.TotalNumberOfLines) { + if (task.Line >= 1 && task.Line <= textEditor.Document.LineCount) { LoggingService.Debug(task.ToString()); - int offset = textEditor.Document.PositionToOffset(task.Line, task.Column); + int offset = textEditor.Document.GetOffset(task.Line, task.Column); int endOffset = TextUtilities.GetNextCaretPosition(DocumentUtilitites.GetTextSource(textEditor.Document), offset, System.Windows.Documents.LogicalDirection.Forward, CaretPositioningMode.WordBorderOrSymbol); if (endOffset < 0) endOffset = textEditor.Document.TextLength; int length = endOffset - offset; diff --git a/src/Main/Base/Project/Src/Services/Tasks/TaskService.cs b/src/Main/Base/Project/Src/Services/Tasks/TaskService.cs index 9d596932fb..4598d93e68 100644 --- a/src/Main/Base/Project/Src/Services/Tasks/TaskService.cs +++ b/src/Main/Base/Project/Src/Services/Tasks/TaskService.cs @@ -144,6 +144,7 @@ namespace ICSharpCode.SharpDevelop } } + /* static void UpdateCommentTags(FileName fileName, IList tagComments) { List newTasks = new List(); @@ -188,6 +189,7 @@ namespace ICSharpCode.SharpDevelop } } } +*/ static void OnCleared(EventArgs e) { diff --git a/src/Main/Base/Project/Src/Util/ExtensionMethods.cs b/src/Main/Base/Project/Src/Util/ExtensionMethods.cs index 7d19396e2f..d73b4c558c 100644 --- a/src/Main/Base/Project/Src/Util/ExtensionMethods.cs +++ b/src/Main/Base/Project/Src/Util/ExtensionMethods.cs @@ -567,13 +567,13 @@ namespace ICSharpCode.SharpDevelop #region Dom, AST, Editor, Document public static string GetText(this IDocument document, TextLocation startPos, TextLocation endPos) { - int startOffset = document.PositionToOffset(startPos); - return document.GetText(startOffset, document.PositionToOffset(endPos) - startOffset); + int startOffset = document.GetOffset(startPos); + return document.GetText(startOffset, document.GetOffset(endPos) - startOffset); } public static void ClearSelection(this ITextEditor editor) { - editor.Select(editor.Document.PositionToOffset(editor.Caret.Position), 0); + editor.Select(editor.Document.GetOffset(editor.Caret.Location), 0); } #endregion }