Browse Source

A few more adjustments to the new NRefactory

newNRvisualizers
Daniel Grunwald 14 years ago
parent
commit
3c85020743
  1. 1
      TODOnewNR.txt
  2. 1
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  3. 8
      src/Main/Base/Project/Src/Bookmarks/BookmarkBase.cs
  4. 8
      src/Main/Base/Project/Src/Bookmarks/BookmarkConverter.cs
  5. 6
      src/Main/Base/Project/Src/Bookmarks/BookmarkManager.cs
  6. 2
      src/Main/Base/Project/Src/Commands/DebugCommands.cs
  7. 27
      src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditTextEditorAdapter.cs
  8. 2
      src/Main/Base/Project/Src/Editor/AvalonEdit/IndentationStrategyAdapter.cs
  9. 6
      src/Main/Base/Project/Src/Editor/Commands/IndentSelection.cs
  10. 4
      src/Main/Base/Project/Src/Editor/Commands/PasteAsCommands.cs
  11. 12
      src/Main/Base/Project/Src/Editor/DocumentUtilitites.cs
  12. 21
      src/Main/Base/Project/Src/Editor/IFormattingStrategy.cs
  13. 10
      src/Main/Base/Project/Src/Editor/PermanentAnchor.cs
  14. 2
      src/Main/Base/Project/Src/Gui/Dialogs/ExtractInterfaceDialog.Designer.cs
  15. 4
      src/Main/Base/Project/Src/Gui/Dialogs/GotoDialog.cs
  16. 18
      src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs
  17. 20
      src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskListPad.cs
  18. 7
      src/Main/Base/Project/Src/Project/IProject.cs
  19. 2
      src/Main/Base/Project/Src/Project/MSBuildInternals.cs
  20. 12
      src/Main/Base/Project/Src/Services/AmbienceService/IAmbience.cs
  21. 123
      src/Main/Base/Project/Src/Services/ClassBrowserIcons/ClassBrowserIconService.cs
  22. 2
      src/Main/Base/Project/Src/Services/Debugger/BreakpointBookmark.cs
  23. 8
      src/Main/Base/Project/Src/Services/Debugger/CurrentLineBookmark.cs
  24. 2
      src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs
  25. 64
      src/Main/Base/Project/Src/Services/ParserService/ParserService.cs
  26. 2
      src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsPopupBase.cs
  27. 2
      src/Main/Base/Project/Src/Services/RefactoringService/ExtractInterfaceOptions.cs
  28. 4
      src/Main/Base/Project/Src/Services/Tasks/ErrorPainter.cs
  29. 2
      src/Main/Base/Project/Src/Services/Tasks/TaskService.cs
  30. 6
      src/Main/Base/Project/Src/Util/ExtensionMethods.cs

1
TODOnewNR.txt

@ -13,6 +13,7 @@ Commented code, needs to be ported and re-enabled:
FindReferencesAndRenameHelper FindReferencesAndRenameHelper
NamespaceRefactoringsService NamespaceRefactoringsService
RefactoringMenuBuilder RefactoringMenuBuilder
TaskService.UpdateCommentTags
Stuff that was renamed/moved: Stuff that was renamed/moved:
ICSharpCode.SharpDevelop.Dom -> the type system and resolvers now are part of ICSharpCode.NRefactory ICSharpCode.SharpDevelop.Dom -> the type system and resolvers now are part of ICSharpCode.NRefactory

1
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -312,6 +312,7 @@
<Compile Include="Src\Project\ProjectPropertyChangedEventArgs.cs" /> <Compile Include="Src\Project\ProjectPropertyChangedEventArgs.cs" />
<Compile Include="Src\Project\Solution\Project_TypeGuids.cs" /> <Compile Include="Src\Project\Solution\Project_TypeGuids.cs" />
<Compile Include="Src\Project\TargetFramework.cs" /> <Compile Include="Src\Project\TargetFramework.cs" />
<Compile Include="Src\Services\AmbienceService\IAmbience.cs" />
<Compile Include="Src\Services\Debugger\BreakpointBookmark.cs" /> <Compile Include="Src\Services\Debugger\BreakpointBookmark.cs" />
<Compile Include="Src\Services\Debugger\BreakpointBookmarkEventArgs.cs" /> <Compile Include="Src\Services\Debugger\BreakpointBookmarkEventArgs.cs" />
<Compile Include="Src\Services\Debugger\Tooltips\IPinDebuggerControl.cs" /> <Compile Include="Src\Services\Debugger\Tooltips\IPinDebuggerControl.cs" />

8
src/Main/Base/Project/Src/Bookmarks/BookmarkBase.cs

@ -38,9 +38,9 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
void CreateAnchor() void CreateAnchor()
{ {
if (document != null) { if (document != null) {
int lineNumber = Math.Max(1, Math.Min(location.Line, document.TotalNumberOfLines)); int lineNumber = Math.Max(1, Math.Min(location.Line, document.LineCount));
int lineLength = document.GetLine(lineNumber).Length; int lineLength = document.GetLineByNumber(lineNumber).Length;
int offset = document.PositionToOffset( int offset = document.GetOffset(
lineNumber, lineNumber,
Math.Max(1, Math.Min(location.Column, lineLength + 1)) Math.Max(1, Math.Min(location.Column, lineLength + 1))
); );
@ -56,7 +56,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
void AnchorDeleted(object sender, EventArgs e) void AnchorDeleted(object sender, EventArgs e)
{ {
// the anchor just became invalid, so don't try to use it again // the anchor just became invalid, so don't try to use it again
location = Location.Empty; location = TextLocation.Empty;
anchor = null; anchor = null;
RemoveMark(); RemoveMark();
} }

8
src/Main/Base/Project/Src/Bookmarks/BookmarkConverter.cs

@ -6,8 +6,8 @@ using System.ComponentModel;
using System.Globalization; using System.Globalization;
using System.Text; using System.Text;
using System.Windows; using System.Windows;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Editor;
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
namespace ICSharpCode.SharpDevelop.Bookmarks namespace ICSharpCode.SharpDevelop.Bookmarks
@ -45,7 +45,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
scriptLanguage = v[6]; scriptLanguage = v[6];
script = v[7]; 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.IsEnabled = bool.Parse(v[4]);
bbm.Action = action; bbm.Action = action;
bbm.ScriptLanguage = scriptLanguage; bbm.ScriptLanguage = scriptLanguage;
@ -53,7 +53,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
bookmark = bbm; bookmark = bbm;
break; break;
case "PinBookmark": 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.Comment = v[4];
pin.PinPosition = pin.PinPosition =
new Point new Point
@ -71,7 +71,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
bookmark = pin; bookmark = pin;
break; break;
default: default:
bookmark = new Bookmark(fileName, new Location(columnNumber, lineNumber)); bookmark = new Bookmark(fileName, new TextLocation(columnNumber, lineNumber));
break; break;
} }
return bookmark; return bookmark;

6
src/Main/Base/Project/Src/Bookmarks/BookmarkManager.cs

@ -110,16 +110,16 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
Predicate<SDBookmark> canToggle, Predicate<SDBookmark> canToggle,
Func<TextLocation, SDBookmark> bookmarkFactory) Func<TextLocation, SDBookmark> 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) { if (canToggle(bookmark) && bookmark.LineNumber == line) {
BookmarkManager.RemoveMark(bookmark); BookmarkManager.RemoveMark(bookmark);
return; return;
} }
} }
// no bookmark at that line: create a new bookmark // 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; 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<SDBookmark> match) public static void RemoveAll(Predicate<SDBookmark> match)

2
src/Main/Base/Project/Src/Commands/DebugCommands.cs

@ -5,8 +5,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Editor;
using ICSharpCode.SharpDevelop.Bookmarks; using ICSharpCode.SharpDevelop.Bookmarks;
using ICSharpCode.SharpDevelop.Bookmarks.Pad.Controls; using ICSharpCode.SharpDevelop.Bookmarks.Pad.Controls;
using ICSharpCode.SharpDevelop.Debugging; using ICSharpCode.SharpDevelop.Debugging;

27
src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditTextEditorAdapter.cs

@ -21,7 +21,7 @@ namespace ICSharpCode.SharpDevelop.Editor.AvalonEdit
/// <summary> /// <summary>
/// Wraps AvalonEdit to provide the ITextEditor interface. /// Wraps AvalonEdit to provide the ITextEditor interface.
/// </summary> /// </summary>
public class AvalonEditTextEditorAdapter : ITextEditor, IWeakEventListener public class AvalonEditTextEditorAdapter : ITextEditor
{ {
readonly TextEditor textEditor; readonly TextEditor textEditor;
@ -34,10 +34,7 @@ namespace ICSharpCode.SharpDevelop.Editor.AvalonEdit
if (textEditor == null) if (textEditor == null)
throw new ArgumentNullException("textEditor"); throw new ArgumentNullException("textEditor");
this.textEditor = textEditor; this.textEditor = textEditor;
this.Caret = new CaretAdapter(textEditor.TextArea.Caret);
this.Options = new OptionsAdapter(textEditor.Options); this.Options = new OptionsAdapter(textEditor.Options);
TextEditorWeakEventManager.DocumentChanged.AddListener(textEditor, this);
OnDocumentChanged();
} }
public static TextEditor CreateAvalonEditInstance() public static TextEditor CreateAvalonEditInstance()
@ -49,28 +46,6 @@ namespace ICSharpCode.SharpDevelop.Editor.AvalonEdit
return (TextEditor)editor; 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 { public IDocument Document {
get { return textEditor.Document; } get { return textEditor.Document; }
} }

2
src/Main/Base/Project/Src/Editor/AvalonEdit/IndentationStrategyAdapter.cs

@ -31,7 +31,7 @@ namespace ICSharpCode.SharpDevelop.Editor.AvalonEdit
{ {
if (line == null) if (line == null)
throw new ArgumentNullException("line"); 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) public virtual void IndentLines(TextDocument document, int beginLine, int endLine)

6
src/Main/Base/Project/Src/Editor/Commands/IndentSelection.cs

@ -26,11 +26,11 @@ namespace ICSharpCode.SharpDevelop.Editor.Commands
return; return;
int beginLine = 1; int beginLine = 1;
int endLine = provider.TextEditor.Document.TotalNumberOfLines; int endLine = provider.TextEditor.Document.LineCount;
if (provider.TextEditor.SelectionLength != 0) { if (provider.TextEditor.SelectionLength != 0) {
beginLine = provider.TextEditor.Document.GetLineForOffset(provider.TextEditor.SelectionStart).LineNumber; beginLine = provider.TextEditor.Document.GetLineByOffset(provider.TextEditor.SelectionStart).LineNumber;
endLine = provider.TextEditor.Document.GetLineForOffset(provider.TextEditor.SelectionStart + provider.TextEditor.SelectionLength).LineNumber; endLine = provider.TextEditor.Document.GetLineByOffset(provider.TextEditor.SelectionStart + provider.TextEditor.SelectionLength).LineNumber;
} }
provider.TextEditor.Language.FormattingStrategy.IndentLines(provider.TextEditor, beginLine, endLine); provider.TextEditor.Language.FormattingStrategy.IndentLines(provider.TextEditor, beginLine, endLine);

4
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) 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; 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()); document.Insert(insertionPos, insertedText.ToString());
} }

12
src/Main/Base/Project/Src/Editor/DocumentUtilitites.cs

@ -69,7 +69,7 @@ namespace ICSharpCode.SharpDevelop.Editor
if (newLineText == null) if (newLineText == null)
throw new ArgumentNullException("newLineText"); throw new ArgumentNullException("newLineText");
string newLineTextTrim = newLineText.Trim(whitespaceChars); string newLineTextTrim = newLineText.Trim(whitespaceChars);
string oldLineText = line.Text; string oldLineText = document.GetText(line);
if (oldLineText == newLineText) if (oldLineText == newLineText)
return; return;
int pos = oldLineText.IndexOf(newLineTextTrim, StringComparison.Ordinal); int pos = oldLineText.IndexOf(newLineTextTrim, StringComparison.Ordinal);
@ -150,7 +150,7 @@ namespace ICSharpCode.SharpDevelop.Editor
public static string GetWhitespaceAfter(ITextSource textSource, int offset) public static string GetWhitespaceAfter(ITextSource textSource, int offset)
{ {
ISegment segment = TextUtilities.GetWhitespaceAfter(textSource, offset); ISegment segment = TextUtilities.GetWhitespaceAfter(textSource, offset);
return textBuffer.GetText(segment.Offset, segment.Length); return textSource.GetText(segment.Offset, segment.Length);
} }
/// <summary> /// <summary>
@ -162,7 +162,7 @@ namespace ICSharpCode.SharpDevelop.Editor
public static string GetWhitespaceBefore(ITextSource textSource, int offset) public static string GetWhitespaceBefore(ITextSource textSource, int offset)
{ {
ISegment segment = TextUtilities.GetWhitespaceBefore(textSource, offset); ISegment segment = TextUtilities.GetWhitespaceBefore(textSource, offset);
return textBuffer.GetText(segment.Offset, segment.Length); return textSource.GetText(segment.Offset, segment.Length);
} }
/// <summary> /// <summary>
@ -170,13 +170,13 @@ namespace ICSharpCode.SharpDevelop.Editor
/// </summary> /// </summary>
public static string GetLineTerminator(IDocument document, int lineNumber) public static string GetLineTerminator(IDocument document, int lineNumber)
{ {
IDocumentLine line = document.GetLine(lineNumber); IDocumentLine line = document.GetLineByNumber(lineNumber);
if (line.DelimiterLength == 0) { if (line.DelimiterLength == 0) {
// at the end of the document, there's no line delimiter, so use the delimiter // at the end of the document, there's no line delimiter, so use the delimiter
// from the previous line // from the previous line
if (lineNumber == 1) if (lineNumber == 1)
return Environment.NewLine; return Environment.NewLine;
line = document.GetLine(lineNumber - 1); line = document.GetLineByNumber(lineNumber - 1);
} }
return document.GetText(line.Offset + line.Length, line.DelimiterLength); return document.GetText(line.Offset + line.Length, line.DelimiterLength);
} }
@ -195,7 +195,7 @@ namespace ICSharpCode.SharpDevelop.Editor
{ {
if (document == null) if (document == null)
throw new ArgumentNullException("document"); throw new ArgumentNullException("document");
IDocumentLine line = document.GetLineForOffset(offset); IDocumentLine line = document.GetLineByOffset(offset);
text = NormalizeNewLines(text, document, line.LineNumber); text = NormalizeNewLines(text, document, line.LineNumber);
document.Insert(offset, text); document.Insert(offset, text);
} }

21
src/Main/Base/Project/Src/Editor/IFormattingStrategy.cs

@ -47,7 +47,7 @@ namespace ICSharpCode.SharpDevelop.Editor
IDocument document = editor.Document; IDocument document = editor.Document;
int lineNumber = line.LineNumber; int lineNumber = line.LineNumber;
if (lineNumber > 1) { if (lineNumber > 1) {
IDocumentLine previousLine = document.GetLine(lineNumber - 1); IDocumentLine previousLine = document.GetLineByNumber(lineNumber - 1);
string indentation = DocumentUtilitites.GetWhitespaceAfter(document, previousLine.Offset); string indentation = DocumentUtilitites.GetWhitespaceAfter(document, previousLine.Offset);
// copy indentation to line // copy indentation to line
string newIndentation = DocumentUtilitites.GetWhitespaceAfter(document, line.Offset); string newIndentation = DocumentUtilitites.GetWhitespaceAfter(document, line.Offset);
@ -59,7 +59,7 @@ namespace ICSharpCode.SharpDevelop.Editor
{ {
using (editor.Document.OpenUndoGroup()) { using (editor.Document.OpenUndoGroup()) {
for (int i = begin; i <= end; i++) { 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
/// </summary> /// </summary>
protected void SurroundSelectionWithSingleLineComment(ITextEditor editor, string comment) protected void SurroundSelectionWithSingleLineComment(ITextEditor editor, string comment)
{ {
using (editor.Document.OpenUndoGroup()) { IDocument document = editor.Document;
Location startPosition = editor.Document.OffsetToPosition(editor.SelectionStart); using (document.OpenUndoGroup()) {
Location endPosition = editor.Document.OffsetToPosition(editor.SelectionStart + editor.SelectionLength); 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) // 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; 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; bool removeComment = true;
for (int i = startPosition.Line; i <= endLine; i++) { for (int i = startPosition.Line; i <= endLine; i++) {
lines.Add(editor.Document.GetLine(i)); lines.Add(editor.Document.GetLineByNumber(i));
if (!lines[i - startPosition.Line].Text.Trim().StartsWith(comment, StringComparison.Ordinal)) if (!document.GetText(lines[i - startPosition.Line]).Trim().StartsWith(comment, StringComparison.Ordinal))
removeComment = false; removeComment = false;
} }
foreach (IDocumentLine line in lines) { foreach (IDocumentLine line in lines) {
if (removeComment) { 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 { } 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; int endOffset = editor.SelectionStart + editor.SelectionLength;
if (editor.SelectionLength == 0) { if (editor.SelectionLength == 0) {
IDocumentLine line = editor.Document.GetLineForOffset(editor.SelectionStart); IDocumentLine line = editor.Document.GetLineByOffset(editor.SelectionStart);
startOffset = line.Offset; startOffset = line.Offset;
endOffset = line.Offset + line.Length; endOffset = line.Offset + line.Length;
} }

10
src/Main/Base/Project/Src/Editor/PermanentAnchor.cs

@ -48,9 +48,9 @@ namespace ICSharpCode.SharpDevelop.Editor
return; return;
Debug.Assert(currentDocument == null && document != null); Debug.Assert(currentDocument == null && document != null);
this.currentDocument = document; this.currentDocument = document;
line = Math.Min(line, document.TotalNumberOfLines); line = Math.Min(line, document.LineCount);
column = Math.Min(column, document.GetLine(line).Length + 1); column = Math.Min(column, document.GetLineByNumber(line).Length + 1);
baseAnchor = document.CreateAnchor(document.PositionToOffset(line, column)); baseAnchor = document.CreateAnchor(document.GetOffset(line, column));
baseAnchor.MovementType = movementType; baseAnchor.MovementType = movementType;
baseAnchor.SurviveDeletion = surviveDeletion; baseAnchor.SurviveDeletion = surviveDeletion;
baseAnchor.Deleted += baseAnchor_Deleted; baseAnchor.Deleted += baseAnchor_Deleted;
@ -62,7 +62,7 @@ namespace ICSharpCode.SharpDevelop.Editor
return; return;
Debug.Assert(currentDocument != null); Debug.Assert(currentDocument != null);
Location loc = baseAnchor.Location; TextLocation loc = baseAnchor.Location;
line = loc.Line; line = loc.Line;
column = loc.Column; column = loc.Column;
@ -111,7 +111,7 @@ namespace ICSharpCode.SharpDevelop.Editor
if (baseAnchor != null) if (baseAnchor != null)
return baseAnchor.Location; return baseAnchor.Location;
else else
return new Location(column, line); return new TextLocation(column, line);
} }
} }

2
src/Main/Base/Project/Src/Gui/Dialogs/ExtractInterfaceDialog.Designer.cs generated

@ -3,7 +3,7 @@
namespace ICSharpCode.SharpDevelop.Gui namespace ICSharpCode.SharpDevelop.Gui
{ {
partial class ExtractInterfaceDialog partial class ExtractInterfaceDialog : System.Windows.Forms.Form
{ {
/// <summary> /// <summary>
/// Designer variable used to keep track of non-visual components. /// Designer variable used to keep track of non-visual components.

4
src/Main/Base/Project/Src/Gui/Dialogs/GotoDialog.cs

@ -233,7 +233,7 @@ namespace ICSharpCode.SharpDevelop.Gui
if (int.TryParse(text, out num)) { if (int.TryParse(text, out num)) {
ITextEditor editor = GetEditor(); ITextEditor editor = GetEditor();
if (editor != null) { 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); 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) { if (tag is int) {
ITextEditor editor = GetEditor(); ITextEditor editor = GetEditor();
if (editor != null) { 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); editor.JumpTo(i, int.MaxValue);
} }
} else if (tag is IClass) { } else if (tag is IClass) {

18
src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs

@ -9,9 +9,9 @@ using System.ComponentModel.Design;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Core.WinForms; using ICSharpCode.Core.WinForms;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Gui namespace ICSharpCode.SharpDevelop.Gui
@ -412,15 +412,17 @@ namespace ICSharpCode.SharpDevelop.Gui
if (gridItem != null) { if (gridItem != null) {
Type component = gridItem.PropertyDescriptor.ComponentType; Type component = gridItem.PropertyDescriptor.ComponentType;
if (component != null) { if (component != null) {
ICSharpCode.SharpDevelop.Dom.IClass c = ParserService.CurrentProjectContent.GetClass(component.FullName, 0); using (var ctx = ParserService.CurrentTypeResolveContext.Synchronize()) {
if (c != null) { ITypeDefinition c = ctx.GetTypeDefinition(component.Namespace, component.Name, 0, StringComparer.Ordinal);
foreach (ICSharpCode.SharpDevelop.Dom.IProperty p in c.DefaultReturnType.GetProperties()) { if (c != null) {
if (gridItem.PropertyDescriptor.Name == p.Name) { foreach (IProperty p in c.GetProperties(ctx)) {
HelpProvider.ShowHelp(p); if (gridItem.PropertyDescriptor.Name == p.Name) {
return; HelpProvider.ShowHelp(p);
return;
}
} }
HelpProvider.ShowHelp(c);
} }
HelpProvider.ShowHelp(c);
} }
} }
} }

20
src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskListPad.cs

@ -97,8 +97,8 @@ namespace ICSharpCode.SharpDevelop.Gui
if (provider != null) { if (provider != null) {
// ensure we don't attach multiple times to the same editor // ensure we don't attach multiple times to the same editor
provider.TextEditor.Caret.PositionChanged -= CaretPositionChanged; provider.TextEditor.Caret.LocationChanged -= CaretPositionChanged;
provider.TextEditor.Caret.PositionChanged += CaretPositionChanged; provider.TextEditor.Caret.LocationChanged += CaretPositionChanged;
} }
} }
@ -106,11 +106,11 @@ namespace ICSharpCode.SharpDevelop.Gui
{ {
if (this.selectedScopeIndex > 2) if (this.selectedScopeIndex > 2)
{ {
IClass current = GetCurrentClass(); ITypeDefinition current = GetCurrentClass();
if (oldClass == null) oldClass = current; if (oldClass == null) oldClass = current;
if ((current != null) && (current.FullyQualifiedName != oldClass.FullyQualifiedName)) if ((current != null) && (current.ReflectionName != oldClass.ReflectionName))
UpdateItems(); UpdateItems();
} }
} }
@ -179,8 +179,8 @@ namespace ICSharpCode.SharpDevelop.Gui
bool IsInScope(Task item) bool IsInScope(Task item)
{ {
IClass current = GetCurrentClass(); ITypeDefinition current = GetCurrentClass();
IClass itemClass = GetCurrentClass(item); ITypeDefinition itemClass = GetCurrentClass(item);
switch (this.selectedScopeIndex) { switch (this.selectedScopeIndex) {
case 0: case 0:
@ -209,11 +209,11 @@ namespace ICSharpCode.SharpDevelop.Gui
if (WorkbenchSingleton.Workbench.ActiveViewContent == null) if (WorkbenchSingleton.Workbench.ActiveViewContent == null)
return null; return null;
ParseInformation parseInfo = ParserService.GetParseInformation(WorkbenchSingleton.Workbench.ActiveViewContent.PrimaryFileName); IParsedFile parseInfo = ParserService.GetParseInformation(WorkbenchSingleton.Workbench.ActiveViewContent.PrimaryFileName);
if (parseInfo != null) { if (parseInfo != null) {
IPositionable positionable = WorkbenchSingleton.Workbench.ActiveViewContent as IPositionable; IPositionable positionable = WorkbenchSingleton.Workbench.ActiveViewContent as IPositionable;
if (positionable != null) { 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; 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. // 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. // 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. // 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) { 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; if (c != null) return c;
} }

7
src/Main/Base/Project/Src/Project/IProject.cs

@ -218,13 +218,6 @@ namespace ICSharpCode.SharpDevelop.Project
/// <param name="withDebugging">True, if a debugger should be used for the project.</param> /// <param name="withDebugging">True, if a debugger should be used for the project.</param>
void Start(bool withDebugging); void Start(bool withDebugging);
/// <summary>
/// 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.
/// </summary>
IProjectContent CreateProjectContent();
/// <summary> /// <summary>
/// Creates a new ProjectItem for the passed MSBuild item. /// Creates a new ProjectItem for the passed MSBuild item.
/// </summary> /// </summary>

2
src/Main/Base/Project/Src/Project/MSBuildInternals.cs

@ -220,7 +220,7 @@ namespace ICSharpCode.SharpDevelop.Project
string originalInclude = item.GetMetadataValue("OriginalItemSpec"); string originalInclude = item.GetMetadataValue("OriginalItemSpec");
ReferenceProjectItem reference; ReferenceProjectItem reference;
if (referenceDict.TryGetValue(originalInclude, out 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 = item.GetEvaluatedMetadata("FullPath"); is incorrect for relative paths
string fullPath = FileUtility.GetAbsolutePath(baseProject.Directory, item.GetMetadataValue("Identity")); string fullPath = FileUtility.GetAbsolutePath(baseProject.Directory, item.GetMetadataValue("Identity"));
reference.FileName = fullPath; reference.FileName = fullPath;

12
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
{
}
}

123
src/Main/Base/Project/Src/Services/ClassBrowserIcons/ClassBrowserIconService.cs

@ -223,8 +223,8 @@ namespace ICSharpCode.SharpDevelop
return GetIcon(entity as IField); return GetIcon(entity as IField);
else if (entity is IEvent) else if (entity is IEvent)
return GetIcon(entity as IEvent); return GetIcon(entity as IEvent);
else if (entity is IClass) else if (entity is ITypeDefinition)
return GetIcon(entity as IClass); return GetIcon(entity as ITypeDefinition);
else else
throw new ArgumentException("unknown entity type"); throw new ArgumentException("unknown entity type");
} }
@ -234,35 +234,44 @@ namespace ICSharpCode.SharpDevelop
if (method.IsOperator) if (method.IsOperator)
return Operator; return Operator;
else if (method.IsExtensionMethod) else if (method.IsExtensionMethod)
return entityImages[ExtensionMethodIndex + GetModifierOffset(method.Modifiers)]; return entityImages[ExtensionMethodIndex + GetModifierOffset(method.Accessibility)];
else else
return entityImages[MethodIndex + GetModifierOffset(method.Modifiers)]; return entityImages[MethodIndex + GetModifierOffset(method.Accessibility)];
} }
public static ClassBrowserImage GetIcon(IProperty property) public static ClassBrowserImage GetIcon(IProperty property)
{ {
if (property.IsIndexer) if (property.IsIndexer)
return entityImages[IndexerIndex + GetModifierOffset(property.Modifiers)]; return entityImages[IndexerIndex + GetModifierOffset(property.Accessibility)];
else else
return entityImages[PropertyIndex + GetModifierOffset(property.Modifiers)]; return entityImages[PropertyIndex + GetModifierOffset(property.Accessibility)];
} }
public static ClassBrowserImage GetIcon(IField field) public static ClassBrowserImage GetIcon(IField field)
{ {
if (field.IsConst) { if (field.IsConst) {
return Const; 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; return Parameter;
} else if (field.IsLocalVariable) {
return LocalVariable;
} else { } else {
return entityImages[FieldIndex + GetModifierOffset(field.Modifiers)]; return LocalVariable;
} }
} }
public static ClassBrowserImage GetIcon(IEvent evt) public static ClassBrowserImage GetIcon(IEvent evt)
{ {
return entityImages[EventIndex + GetModifierOffset(evt.Modifiers)]; return entityImages[EventIndex + GetModifierOffset(evt.Accessibility)];
} }
public static ClassBrowserImage GetIcon(ITypeDefinition c) public static ClassBrowserImage GetIcon(ITypeDefinition c)
@ -282,97 +291,7 @@ namespace ICSharpCode.SharpDevelop
imageIndex = InterfaceIndex; imageIndex = InterfaceIndex;
break; break;
} }
return entityImages[imageIndex + GetModifierOffset(c.Modifiers)]; return entityImages[imageIndex + GetModifierOffset(c.Accessibility)];
}
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];
} }
#endregion #endregion

2
src/Main/Base/Project/Src/Services/Debugger/BreakpointBookmark.cs

@ -109,7 +109,7 @@ namespace ICSharpCode.SharpDevelop.Debugging
protected override ITextMarker CreateMarker(ITextMarkerService markerService) 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); ITextMarker marker = markerService.Create(line.Offset, line.Length);
marker.BackgroundColor = Color.FromRgb(180, 38, 38); marker.BackgroundColor = Color.FromRgb(180, 38, 38);
marker.ForegroundColor = Colors.White; marker.ForegroundColor = Colors.White;

8
src/Main/Base/Project/Src/Services/Debugger/CurrentLineBookmark.cs

@ -39,16 +39,16 @@ namespace ICSharpCode.SharpDevelop.Debugging
endLine = makerEndLine; endLine = makerEndLine;
endColumn = makerEndColumn; endColumn = makerEndColumn;
if (startLine < 1 || startLine > document.TotalNumberOfLines) if (startLine < 1 || startLine > document.LineCount)
return; return;
if (endLine < 1 || endLine > document.TotalNumberOfLines) { if (endLine < 1 || endLine > document.LineCount) {
endLine = startLine; endLine = startLine;
endColumn = int.MaxValue; endColumn = int.MaxValue;
} }
if (startColumn < 1) if (startColumn < 1)
startColumn = 1; startColumn = 1;
IDocumentLine line = document.GetLine(startLine); IDocumentLine line = document.GetLineByNumber(startLine);
if (endColumn < 1 || endColumn > line.Length) if (endColumn < 1 || endColumn > line.Length)
endColumn = line.Length; endColumn = line.Length;
instance = new CurrentLineBookmark(fileName, new Location(startColumn, startLine)); instance = new CurrentLineBookmark(fileName, new Location(startColumn, startLine));
@ -87,7 +87,7 @@ namespace ICSharpCode.SharpDevelop.Debugging
protected override ITextMarker CreateMarker(ITextMarkerService markerService) 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)); ITextMarker marker = markerService.Create(line.Offset + startColumn - 1, Math.Max(endColumn - startColumn, 1));
marker.BackgroundColor = Colors.Yellow; marker.BackgroundColor = Colors.Yellow;
marker.ForegroundColor = Colors.Blue; marker.ForegroundColor = Colors.Blue;

2
src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs

@ -266,7 +266,7 @@ namespace ICSharpCode.SharpDevelop.Debugging
IExpressionFinder expressionFinder = ParserService.GetExpressionFinder(e.Editor.FileName); IExpressionFinder expressionFinder = ParserService.GetExpressionFinder(e.Editor.FileName);
if (expressionFinder == null) if (expressionFinder == null)
return; return;
var currentLine = doc.GetLine(logicPos.Y); var currentLine = doc.GetLineByNumber(logicPos.Y);
if (logicPos.X > currentLine.Length) if (logicPos.X > currentLine.Length)
return; return;
/* /*

64
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) public static IProjectContent GetProjectContent(IProject project)
{ {
lock (projectContents) { lock (projectContents) {
@ -171,7 +182,7 @@ namespace ICSharpCode.SharpDevelop
if (GetParser(fileName) == null) if (GetParser(fileName) == null)
return; return;
ITextBuffer snapshot; ITextSource snapshot;
IEditable editable = viewContent as IEditable; IEditable editable = viewContent as IEditable;
if (editable != null) if (editable != null)
snapshot = editable.CreateSnapshot(); snapshot = editable.CreateSnapshot();
@ -179,8 +190,8 @@ namespace ICSharpCode.SharpDevelop
snapshot = GetParseableFileContent(viewContent.PrimaryFileName); snapshot = GetParseableFileContent(viewContent.PrimaryFileName);
lastParseRun = BeginParse(fileName, snapshot).ContinueWith( lastParseRun = BeginParse(fileName, snapshot).ContinueWith(
delegate(Task<ParseInformation> backgroundTask) { delegate(Task<IParsedFile> backgroundTask) {
ParseInformation parseInfo = backgroundTask.Result; IParsedFile parseInfo = backgroundTask.Result;
RaiseParserUpdateStepFinished(new ParserUpdateStepEventArgs(fileName, snapshot, parseInfo)); RaiseParserUpdateStepFinished(new ParserUpdateStepEventArgs(fileName, snapshot, parseInfo));
}); });
} }
@ -270,7 +281,7 @@ namespace ICSharpCode.SharpDevelop
#endregion #endregion
#region Parse Information Management #region Parse Information Management
static readonly IParsedFile[] emptyCompilationUnitArray = new ICompilationUnit[0]; static readonly IParsedFile[] emptyCompilationUnitArray = new IParsedFile[0];
sealed class FileEntry sealed class FileEntry
{ {
@ -300,7 +311,7 @@ namespace ICSharpCode.SharpDevelop
public IParsedFile GetParseInformation(IProjectContent content) public IParsedFile GetParseInformation(IProjectContent content)
{ {
ParseInformation p = GetExistingParseInformation(content); IParsedFile p = GetExistingParseInformation(content);
if (p != null) if (p != null)
return p; return p;
else else
@ -317,7 +328,7 @@ namespace ICSharpCode.SharpDevelop
return p; return p;
lock (this) { lock (this) {
if (this.oldUnits != null) { if (this.oldUnits != null) {
ICompilationUnit cu = this.oldUnits.FirstOrDefault(c => c.ProjectContent == content); IParsedFile cu = this.oldUnits.FirstOrDefault(c => c.ProjectContent == content);
return cu; return cu;
} else { } else {
return null; return null;
@ -349,7 +360,7 @@ namespace ICSharpCode.SharpDevelop
// Detect when a file belongs to multiple projects but the ParserService hasn't realized // 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. // 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)) { 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. // risking deadlocks.
// parse once for each project content that contains the file // parse once for each project content that contains the file
ICompilationUnit[] newUnits = new ICompilationUnit[projectContents.Count]; IParsedFile[] newUnits = new IParsedFile[projectContents.Count];
ICompilationUnit resultUnit = null; IParsedFile resultUnit = null;
for (int i = 0; i < newUnits.Length; i++) { for (int i = 0; i < newUnits.Length; i++) {
IProjectContent pc = projectContents[i]; IProjectContent pc = projectContents[i];
try { 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) // 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 (fileContentVersion != null && this.bufferVersion != null && this.bufferVersion.BelongsToSameDocumentAs(fileContentVersion)) {
if (this.bufferVersion.CompareAge(fileContentVersion) >= 0) { if (this.bufferVersion.CompareAge(fileContentVersion) >= 0) {
if (parentProjectContent != null && parentProjectContent != parseInfo.CompilationUnit.ProjectContent) { if (parentProjectContent != null) {
ICompilationUnit oldUnit = oldUnits.FirstOrDefault(o => o.ProjectContent == parentProjectContent); IParsedFile oldUnit = oldUnits.FirstOrDefault(o => o.ProjectContent == parentProjectContent);
if (oldUnit != null) 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++) { for (int i = 0; i < newUnits.Length; i++) {
IProjectContent pc = projectContents[i]; IProjectContent pc = projectContents[i];
// update the compilation unit // 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); pc.UpdateCompilationUnit(oldUnit, newUnits[i], fileName);
ParseInformation newUnitParseInfo = (newUnits[i] == resultUnit) ? newParseInfo : new ParseInformation(newUnits[i]); RaiseParseInformationUpdated(new ParseInformationEventArgs(oldUnit, newUnits[i], newUnits[i] == resultUnit));
RaiseParseInformationUpdated(new ParseInformationEventArgs(fileName, pc, oldUnit, newUnitParseInfo, newUnits[i] == resultUnit));
} }
// remove all old units that don't exist anymore // 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)) { if (!newUnits.Any(n => n.ProjectContent == oldUnit.ProjectContent)) {
oldUnit.ProjectContent.RemoveCompilationUnit(oldUnit); oldUnit.ProjectContent.RemoveCompilationUnit(oldUnit);
RaiseParseInformationUpdated(new ParseInformationEventArgs(fileName, oldUnit.ProjectContent, oldUnit, null, false)); RaiseParseInformationUpdated(new ParseInformationEventArgs(oldUnit, null, false));
} }
} }
this.bufferVersion = fileContentVersion; this.bufferVersion = fileContentVersion;
this.oldUnits = newUnits; this.oldUnits = newUnits;
this.parseInfo = newParseInfo; this.mainParseInfo = newParseInfo;
return newParseInfo; return newParseInfo;
} }
} }
public void Clear() public void Clear()
{ {
ParseInformation parseInfo; IParsedFile parseInfo;
ICompilationUnit[] oldUnits; IParsedFile[] oldUnits;
lock (this) { lock (this) {
// by setting the disposed flag, we'll cause all running ParseFile() calls to return null and not // 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 // call into the parser anymore, so we can do the remainder of the clean-up work outside the lock
this.disposed = true; this.disposed = true;
parseInfo = this.parseInfo; parseInfo = this.mainParseInfo;
oldUnits = this.oldUnits; oldUnits = this.oldUnits;
this.oldUnits = null; this.oldUnits = null;
this.bufferVersion = null; this.bufferVersion = null;
this.parseInfo = null; this.mainParseInfo = null;
} }
foreach (ICompilationUnit oldUnit in oldUnits) { foreach (IParsedFile oldUnit in oldUnits) {
oldUnit.ProjectContent.RemoveCompilationUnit(oldUnit); oldUnit.ProjectContent.RemoveCompilationUnit(oldUnit);
bool isPrimary = parseInfo != null && parseInfo.CompilationUnit == oldUnit; bool isPrimary = parseInfo == oldUnit;
RaiseParseInformationUpdated(new ParseInformationEventArgs(fileName, oldUnit.ProjectContent, oldUnit, null, isPrimary)); RaiseParseInformationUpdated(new ParseInformationEventArgs(oldUnit, null, isPrimary));
} }
} }

2
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; var editorUIService = editor == null ? null : editor.GetService(typeof(IEditorUIService)) as IEditorUIService;
if (editorUIService != null) { if (editorUIService != null) {
var document = editor.Document; var document = editor.Document;
int offset = document.PositionToOffset(line, column); int offset = document.GetOffset(line, column);
if (openAtWordStart) { if (openAtWordStart) {
int wordStart = document.FindPrevWordStart(offset); int wordStart = document.FindPrevWordStart(offset);
if (wordStart != -1) { if (wordStart != -1) {

2
src/Main/Base/Project/Src/Services/RefactoringService/ExtractInterfaceOptions.cs

@ -50,7 +50,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring
get { get {
return String.Format("{0}{1}", return String.Format("{0}{1}",
this.NewInterfaceName, this.NewInterfaceName,
Path.GetExtension(ClassEntity.CompilationUnit.FileName)); Path.GetExtension(ClassEntity.Region.FileName));
} }
} }
} }

4
src/Main/Base/Project/Src/Services/Tasks/ErrorPainter.cs

@ -131,9 +131,9 @@ namespace ICSharpCode.SharpDevelop
if (!CheckTask(task)) if (!CheckTask(task))
return; return;
if (task.Line >= 1 && task.Line <= textEditor.Document.TotalNumberOfLines) { if (task.Line >= 1 && task.Line <= textEditor.Document.LineCount) {
LoggingService.Debug(task.ToString()); 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); int endOffset = TextUtilities.GetNextCaretPosition(DocumentUtilitites.GetTextSource(textEditor.Document), offset, System.Windows.Documents.LogicalDirection.Forward, CaretPositioningMode.WordBorderOrSymbol);
if (endOffset < 0) endOffset = textEditor.Document.TextLength; if (endOffset < 0) endOffset = textEditor.Document.TextLength;
int length = endOffset - offset; int length = endOffset - offset;

2
src/Main/Base/Project/Src/Services/Tasks/TaskService.cs

@ -144,6 +144,7 @@ namespace ICSharpCode.SharpDevelop
} }
} }
/*
static void UpdateCommentTags(FileName fileName, IList<TagComment> tagComments) static void UpdateCommentTags(FileName fileName, IList<TagComment> tagComments)
{ {
List<Task> newTasks = new List<Task>(); List<Task> newTasks = new List<Task>();
@ -188,6 +189,7 @@ namespace ICSharpCode.SharpDevelop
} }
} }
} }
*/
static void OnCleared(EventArgs e) static void OnCleared(EventArgs e)
{ {

6
src/Main/Base/Project/Src/Util/ExtensionMethods.cs

@ -567,13 +567,13 @@ namespace ICSharpCode.SharpDevelop
#region Dom, AST, Editor, Document #region Dom, AST, Editor, Document
public static string GetText(this IDocument document, TextLocation startPos, TextLocation endPos) public static string GetText(this IDocument document, TextLocation startPos, TextLocation endPos)
{ {
int startOffset = document.PositionToOffset(startPos); int startOffset = document.GetOffset(startPos);
return document.GetText(startOffset, document.PositionToOffset(endPos) - startOffset); return document.GetText(startOffset, document.GetOffset(endPos) - startOffset);
} }
public static void ClearSelection(this ITextEditor editor) 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 #endregion
} }

Loading…
Cancel
Save