Browse Source

WIP

newNRvisualizers
Daniel Grunwald 14 years ago
parent
commit
a2add0b62e
  1. 17
      TODOnewNR.txt
  2. 10
      src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj
  3. 10
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj
  4. 1
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditEditorUIService.cs
  5. 9
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs
  6. 18
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CaretReferencesRenderer.cs
  7. 2
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ChangeMarkerMargin.cs
  8. 36
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs
  9. 52
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs
  10. 3
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeManipulation.cs
  11. 4
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Commands/FoldingCommands.cs
  12. 9
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Commands/SortSelectionCommand.cs
  13. 2
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActionsRenderer.cs
  14. 47
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/DefaultChangeWatcher.cs
  15. 2
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ExpressionHighlightRenderer.cs
  16. 10
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/IconBarManager.cs
  17. 1
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/InlineUIElementGenerator.cs
  18. 60
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/LineChangeInfo.cs
  19. 1
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/MyersDiff/DocumentSequence.cs
  20. 2
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/NewLineConsistencyCheck.cs
  21. 16
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ParserFoldingStrategy.cs
  22. 38
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/QuickClassBrowser.cs
  23. 1
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopCompletionWindow.cs
  24. 1
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopTextEditor.cs
  25. 12
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Snippets/CodeSnippet.cs
  26. 14
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/TextMarkerService.cs
  27. 2
      src/AddIns/Misc/SearchAndReplace/Project/Engine/DocumentIterator/DirectoryDocumentIterator.cs
  28. 2
      src/AddIns/Misc/SearchAndReplace/Project/Engine/DocumentIterator/WholeProjectDocumentIterator.cs
  29. 2
      src/AddIns/Misc/SearchAndReplace/Project/Engine/DocumentIterator/WholeSolutionDocumentIterator.cs
  30. 2
      src/AddIns/VersionControl/GitAddIn/Src/OverlayIconManager.cs
  31. 2
      src/AddIns/VersionControl/SubversionAddIn/Src/Gui/ProjectBrowserVisitor/OverlayIconManager.cs
  32. 5
      src/AddIns/VersionControl/SubversionAddIn/SubversionAddIn.csproj
  33. 4
      src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/ParsedFile.cs
  34. 2
      src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs
  35. 2
      src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/IParsedFile.cs
  36. 13
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  37. 2
      src/Main/Base/Project/Src/Commands/AutostartCommands.cs
  38. 3
      src/Main/Base/Project/Src/Gui/Dialogs/GotoDialog.cs
  39. 1
      src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs
  40. 2
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/TaskListOptions.cs
  41. 1
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ApplicationSettings.cs
  42. 1
      src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/GacReferencePanel.cs
  43. 2
      src/Main/Base/Project/Src/Gui/Dialogs/WordCountDialog.cs
  44. 2
      src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/ReferenceFolderNodeCommands.cs
  45. 1
      src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs
  46. 3
      src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskListPad.cs
  47. 1
      src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs
  48. 1
      src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs
  49. 2
      src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs
  50. 3
      src/Main/Base/Project/Src/Project/CustomTool.cs
  51. 2
      src/Main/Base/Project/Src/Project/Items/ReferenceProjectItem.cs
  52. 2
      src/Main/Base/Project/Src/Project/MSBuildInternals.cs
  53. 2
      src/Main/Base/Project/Src/Services/File/FileService.cs
  54. 3
      src/Main/Base/Project/Src/Services/File/OpenedFile.cs
  55. 1
      src/Main/Base/Project/Src/Services/NavigationService/NavigationService.cs
  56. 2
      src/Main/Base/Project/Src/Services/ParserService/AssemblyParserService.cs
  57. 2
      src/Main/Base/Project/Src/Services/ParserService/CodeCompletionOptions.cs
  58. 2
      src/Main/Base/Project/Src/Services/ParserService/DomAssemblyName.cs
  59. 2
      src/Main/Base/Project/Src/Services/ParserService/Doozer/ParserDescriptor.cs
  60. 2
      src/Main/Base/Project/Src/Services/ParserService/Doozer/ParserDoozer.cs
  61. 2
      src/Main/Base/Project/Src/Services/ParserService/Fusion.cs
  62. 3
      src/Main/Base/Project/Src/Services/ParserService/GacInterop.cs
  63. 21
      src/Main/Base/Project/Src/Services/ParserService/IParser.cs
  64. 2
      src/Main/Base/Project/Src/Services/ParserService/LoadSolutionProjects.cs
  65. 34
      src/Main/Base/Project/Src/Services/ParserService/ParseInformation.cs
  66. 2
      src/Main/Base/Project/Src/Services/ParserService/ParseInformationEventArgs.cs
  67. 2
      src/Main/Base/Project/Src/Services/ParserService/ParseProjectContent.cs
  68. 256
      src/Main/Base/Project/Src/Services/ParserService/ParserService.cs
  69. 1
      src/Main/Base/Project/Src/Services/ProjectService/ParseableFileContentFinder.cs
  70. 2
      src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs
  71. 4
      src/Main/Base/Project/Src/Services/Tasks/TaskService.cs
  72. 37
      src/Main/Base/Project/Src/Util/ExtensionMethods.cs
  73. 10
      src/Main/ICSharpCode.SharpDevelop.Sda/ICSharpCode.SharpDevelop.Sda.csproj
  74. 5
      src/Main/ICSharpCode.SharpDevelop.Sda/Src/CallHelper.cs
  75. 3
      src/Main/ICSharpCode.SharpDevelop.Sda/Src/Document.cs
  76. 4
      src/Main/StartUp/Project/StartUp.csproj

17
TODOnewNR.txt

@ -14,14 +14,29 @@ Commented code, needs to be ported and re-enabled:
NamespaceRefactoringsService NamespaceRefactoringsService
RefactoringMenuBuilder RefactoringMenuBuilder
TaskService.UpdateCommentTags TaskService.UpdateCommentTags
CodeManipulation.cs (btw, I think this doesn't belong into AvalonEdit.AddIn - more a job for a language binding)
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
IDocument, ITextEditor -> moved to ICSharpCode.Editor assembly IDocument, ITextEditor -> moved to ICSharpCode.Editor assembly
IClass -> ITypeDefinition IClass -> ITypeDefinition
ParseInformation -> IParsedFile
ICompilationUnit -> IParsedFile ICompilationUnit -> IParsedFile
ITextBuffer -> ITextSource (in ICSharpCode.Editor assembly) ITextBuffer -> ITextSource (in ICSharpCode.Editor assembly)
IReturnType -> ITypeReference (unresolved) or IType (resolved) IReturnType -> ITypeReference (unresolved) or IType (resolved)
Location -> TextLocation or AstLocation. Use AstLocation only when directly working with the AST, and TextLocation otherwise. Location -> TextLocation or AstLocation. Use AstLocation only when directly working with the AST, and TextLocation otherwise.
TextLocation -> moved to ICSharpCode.Editor assembly TextLocation -> moved to ICSharpCode.Editor assembly
Functionality changes:
The result of a parser run (ParseInformation) now may contain a fully parsed AST.
The ParserService may cache such full ASTs, but may also drop them from memory at any time.
This is implemented by keeping the last N accessed files in the cache.
Every parse information also contains an IParsedFile instance with the type system information.
The IParsedFile is stored permanently (both in ParserService and in the IProjectContents).
Context Actions vs. Member Context Menu:
Members context menu should include refactoring options that can be applied from the outside,
for example in the classes pad when the code file isn't open.
Refactorings that don't make sense without opening the file shouldn't be in the member menu.
The context actions menu should show all refactorings (even those that are also in the members context menu).

10
src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj

@ -88,6 +88,16 @@
<Name>ICSharpCode.AvalonEdit</Name> <Name>ICSharpCode.AvalonEdit</Name>
<Private>False</Private> <Private>False</Private>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\ICSharpCode.Editor\ICSharpCode.Editor.csproj">
<Project>{F054A788-B591-4561-A8BA-AE745BBEB817}</Project>
<Name>ICSharpCode.Editor</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
<Name>ICSharpCode.NRefactory</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> <ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> <Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name> <Name>ICSharpCode.SharpDevelop</Name>

10
src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj

@ -197,6 +197,16 @@
<Name>Mono.Cecil</Name> <Name>Mono.Cecil</Name>
<Private>False</Private> <Private>False</Private>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\..\Libraries\NRefactory\ICSharpCode.Editor\ICSharpCode.Editor.csproj">
<Project>{F054A788-B591-4561-A8BA-AE745BBEB817}</Project>
<Name>ICSharpCode.Editor</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\Libraries\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
<Name>ICSharpCode.NRefactory</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> <ProjectReference Include="..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> <Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name> <Name>ICSharpCode.SharpDevelop</Name>

1
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditEditorUIService.cs

@ -5,6 +5,7 @@ using System;
using System.Windows; using System.Windows;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Rendering; using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.Editor;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;

9
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs

@ -11,11 +11,12 @@ using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Highlighting; using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Editor;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Bookmarks; using ICSharpCode.SharpDevelop.Bookmarks;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.AvalonEdit.AddIn namespace ICSharpCode.AvalonEdit.AddIn
@ -175,7 +176,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
codeEditor.FileName = newFileName; codeEditor.FileName = newFileName;
ParserService.BeginParse(file.FileName, codeEditor.DocumentAdapter); ParserService.ParseAsync(file.FileName, codeEditor.Document);
} }
} }
@ -277,9 +278,9 @@ namespace ICSharpCode.AvalonEdit.AddIn
} }
#region IEditable #region IEditable
public ITextBuffer CreateSnapshot() public ITextSource CreateSnapshot()
{ {
return codeEditor.DocumentAdapter.CreateSnapshot(); return codeEditor.Document.CreateSnapshot();
} }
/// <summary> /// <summary>

18
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CaretReferencesRenderer.cs

@ -9,14 +9,13 @@ using System.Windows.Threading;
using ICSharpCode.AvalonEdit.AddIn.Options; using ICSharpCode.AvalonEdit.AddIn.Options;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Refactoring; using ICSharpCode.SharpDevelop.Refactoring;
namespace ICSharpCode.AvalonEdit.AddIn namespace ICSharpCode.AvalonEdit.AddIn
{ {
/// <summary> /* /// <summary>
/// In the code editor, highlights all references to the expression under the caret (for better code readability). /// In the code editor, highlights all references to the expression under the caret (for better code readability).
/// </summary> /// </summary>
public class CaretReferencesRenderer public class CaretReferencesRenderer
@ -142,7 +141,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
delegate { delegate {
LoggingService.Debug("Aborting FindReferencesInCurrentFile due to timeout"); LoggingService.Debug("Aborting FindReferencesInCurrentFile due to timeout");
cancellationTokenSource.Cancel(); cancellationTokenSource.Cancel();
}, null, findReferencesTimeoutMs, Timeout.Infinite)) }, null, findReferencesTimeoutMs, Timeout.Infinite))
{ {
var progressMonitor = new DummyProgressMonitor(); var progressMonitor = new DummyProgressMonitor();
progressMonitor.CancellationToken = cancellationTokenSource.Token; progressMonitor.CancellationToken = cancellationTokenSource.Token;
@ -159,12 +158,12 @@ namespace ICSharpCode.AvalonEdit.AddIn
/// </summary> /// </summary>
bool SameResolveResult(ResolveResult resolveResult, ResolveResult resolveResult2) bool SameResolveResult(ResolveResult resolveResult, ResolveResult resolveResult2)
{ {
/*if (resolveResult == null && resolveResult2 == null) //if (resolveResult == null && resolveResult2 == null)
return true; // return true;
if (resolveResult == null && resolveResult2 != null) //if (resolveResult == null && resolveResult2 != null)
return false; // return false;
if (resolveResult != null && resolveResult2 == null) //if (resolveResult != null && resolveResult2 == null)
return false;*/ // return false;
// TODO determine if 2 ResolveResults refer to the same symbol // TODO determine if 2 ResolveResults refer to the same symbol
return false; return false;
} }
@ -178,4 +177,5 @@ namespace ICSharpCode.AvalonEdit.AddIn
timer.Start(); timer.Start();
} }
} }
*/
} }

2
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ChangeMarkerMargin.cs

@ -198,7 +198,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
if (added) if (added)
delimiter = l.DelimiterLength; delimiter = l.DelimiterLength;
if (length == 0) if (length == 0)
oldText += DocumentUtilitites.GetLineTerminator(new AvalonEditDocumentAdapter(Document, null), l.LineNumber); oldText += DocumentUtilitites.GetLineTerminator(this.Document, l.LineNumber);
Document.Replace(offset, length + delimiter, oldText); Document.Replace(offset, length + delimiter, oldText);
tooltip.IsOpen = false; tooltip.IsOpen = false;
} }

36
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs

@ -13,7 +13,6 @@ using System.Windows.Controls;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Threading; using System.Windows.Threading;
using ICSharpCode.AvalonEdit.AddIn.Options; using ICSharpCode.AvalonEdit.AddIn.Options;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.AvalonEdit.Editing;
@ -22,24 +21,16 @@ using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Core.Presentation; using ICSharpCode.Core.Presentation;
using ICSharpCode.Editor;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Bookmarks; using ICSharpCode.SharpDevelop.Bookmarks;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using ICSharpCode.SharpDevelop.Parser;
namespace ICSharpCode.AvalonEdit.AddIn namespace ICSharpCode.AvalonEdit.AddIn
{ {
public interface ICodeEditor
{
TextDocument Document { get; }
void Redraw(ISegment segment, DispatcherPriority priority);
event EventHandler DocumentChanged;
}
/// <summary> /// <summary>
/// Integrates AvalonEdit with SharpDevelop. /// Integrates AvalonEdit with SharpDevelop.
/// Also provides support for Split-View (showing two AvalonEdit instances using the same TextDocument) /// Also provides support for Split-View (showing two AvalonEdit instances using the same TextDocument)
@ -93,8 +84,9 @@ namespace ICSharpCode.AvalonEdit.AddIn
public event EventHandler DocumentChanged; public event EventHandler DocumentChanged;
[Obsolete("Use CodeEditor.Document instead; TextDocument now directly implements IDocument")]
public IDocument DocumentAdapter { public IDocument DocumentAdapter {
get { return primaryTextEditorAdapter.Document; } get { return this.Document; }
} }
public ITextEditor PrimaryTextEditorAdapter { public ITextEditor PrimaryTextEditorAdapter {
@ -126,7 +118,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
} else { } else {
this.errorPainter.UpdateErrors(); this.errorPainter.UpdateErrors();
} }
changeWatcher.Initialize(this.DocumentAdapter); changeWatcher.Initialize(this.Document, fileName);
FetchParseInformation(); FetchParseInformation();
} }
@ -375,7 +367,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
void HandleCaretPositionChange() void HandleCaretPositionChange()
{ {
if (quickClassBrowser != null) { if (quickClassBrowser != null) {
quickClassBrowser.SelectItemAtCaretPosition(this.ActiveTextEditorAdapter.Caret.Position); quickClassBrowser.SelectItemAtCaretPosition(this.ActiveTextEditor.TextArea.Caret.Location);
} }
CaretPositionChanged.RaiseEvent(this, EventArgs.Empty); CaretPositionChanged.RaiseEvent(this, EventArgs.Empty);
@ -470,7 +462,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
// Immediately parse on enter. // Immediately parse on enter.
// This ensures we have up-to-date CC info about the method boundary when a user // This ensures we have up-to-date CC info about the method boundary when a user
// types near the end of a method. // types near the end of a method.
ParserService.BeginParse(this.FileName, this.DocumentAdapter.CreateSnapshot()); ParserService.ParseAsync(this.FileName, this.DocumentAdapter.CreateSnapshot());
} }
} }
} }
@ -526,10 +518,10 @@ namespace ICSharpCode.AvalonEdit.AddIn
void FetchParseInformation() void FetchParseInformation()
{ {
ParseInformation parseInfo = ParserService.GetExistingParseInformation(this.FileName); ParseInformation parseInfo = ParserService.GetExistingParsedFile(this.FileName);
if (parseInfo == null) { if (parseInfo == null) {
// if parse info is not yet available, start parsing on background // if parse info is not yet available, start parsing on background
ParserService.BeginParse(this.FileName, primaryTextEditorAdapter.Document); ParserService.ParseAsync(this.FileName, primaryTextEditorAdapter.Document);
// we'll receive the result using the ParseInformationUpdated event // we'll receive the result using the ParseInformationUpdated event
} }
ParseInformationUpdated(parseInfo); ParseInformationUpdated(parseInfo);
@ -544,7 +536,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
this.VerifyAccess(); this.VerifyAccess();
// When parse information is updated quickly in succession, only do a single update // When parse information is updated quickly in succession, only do a single update
// to the latest version. // to the latest version.
updateParseInfoTo = e.NewParsedFile; updateParseInfoTo = e.NewParseInformation;
this.Dispatcher.BeginInvoke( this.Dispatcher.BeginInvoke(
DispatcherPriority.Background, DispatcherPriority.Background,
new Action( new Action(
@ -561,15 +553,15 @@ namespace ICSharpCode.AvalonEdit.AddIn
if (parseInfo != null && CodeEditorOptions.Instance.EnableQuickClassBrowser) { if (parseInfo != null && CodeEditorOptions.Instance.EnableQuickClassBrowser) {
// don't create quickClassBrowser for files that don't have any classes // don't create quickClassBrowser for files that don't have any classes
// (but do keep the quickClassBrowser when the last class is removed from a file) // (but do keep the quickClassBrowser when the last class is removed from a file)
if (quickClassBrowser != null || parseInfo.CompilationUnit.Classes.Count > 0) { if (quickClassBrowser != null || parseInfo.ParsedFile.TopLevelTypeDefinitions.Count > 0) {
if (quickClassBrowser == null) { if (quickClassBrowser == null) {
quickClassBrowser = new QuickClassBrowser(); quickClassBrowser = new QuickClassBrowser();
quickClassBrowser.JumpAction = (line, col) => ActiveTextEditor.JumpTo(line, col); quickClassBrowser.JumpAction = (line, col) => ActiveTextEditor.JumpTo(line, col);
SetRow(quickClassBrowser, 0); SetRow(quickClassBrowser, 0);
this.Children.Add(quickClassBrowser); this.Children.Add(quickClassBrowser);
} }
quickClassBrowser.Update(parseInfo.CompilationUnit); quickClassBrowser.Update(parseInfo.ParsedFile);
quickClassBrowser.SelectItemAtCaretPosition(this.ActiveTextEditorAdapter.Caret.Position); quickClassBrowser.SelectItemAtCaretPosition(this.ActiveTextEditor.TextArea.Caret.Location);
} }
} else { } else {
if (quickClassBrowser != null) { if (quickClassBrowser != null) {
@ -577,7 +569,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
quickClassBrowser = null; quickClassBrowser = null;
} }
} }
iconBarManager.UpdateClassMemberBookmarks(parseInfo); iconBarManager.UpdateClassMemberBookmarks(parseInfo.ParsedFile);
primaryTextEditor.UpdateParseInformationForFolding(parseInfo); primaryTextEditor.UpdateParseInformationForFolding(parseInfo);
if (secondaryTextEditor != null) if (secondaryTextEditor != null)
secondaryTextEditor.UpdateParseInformationForFolding(parseInfo); secondaryTextEditor.UpdateParseInformationForFolding(parseInfo);

52
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs

@ -14,21 +14,18 @@ using System.Windows.Controls.Primitives;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Threading; using System.Windows.Threading;
using ICSharpCode.AvalonEdit.AddIn.Options; using ICSharpCode.AvalonEdit.AddIn.Options;
using ICSharpCode.AvalonEdit.AddIn.Snippets; using ICSharpCode.AvalonEdit.AddIn.Snippets;
using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Highlighting; using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.AvalonEdit.Rendering; using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.NRefactory;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using ICSharpCode.SharpDevelop.Editor.Commands; using ICSharpCode.SharpDevelop.Editor.Commands;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Refactoring; using ICSharpCode.SharpDevelop.Refactoring;
using Ast = ICSharpCode.NRefactory.Ast;
namespace ICSharpCode.AvalonEdit.AddIn namespace ICSharpCode.AvalonEdit.AddIn
{ {
@ -42,8 +39,8 @@ namespace ICSharpCode.AvalonEdit.AddIn
public ITextEditor Adapter { get; set; } public ITextEditor Adapter { get; set; }
BracketHighlightRenderer bracketRenderer; BracketHighlightRenderer bracketRenderer;
CaretReferencesRenderer caretReferencesRenderer; //CaretReferencesRenderer caretReferencesRenderer;
ContextActionsRenderer contextActionsRenderer; //ContextActionsRenderer contextActionsRenderer;
HiddenDefinition.HiddenDefinitionRenderer hiddenDefinitionRenderer; HiddenDefinition.HiddenDefinitionRenderer hiddenDefinitionRenderer;
public CodeEditorView() public CodeEditorView()
@ -51,8 +48,8 @@ namespace ICSharpCode.AvalonEdit.AddIn
this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Help, OnHelpExecuted)); this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Help, OnHelpExecuted));
this.bracketRenderer = new BracketHighlightRenderer(this.TextArea.TextView); this.bracketRenderer = new BracketHighlightRenderer(this.TextArea.TextView);
this.caretReferencesRenderer = new CaretReferencesRenderer(this); //this.caretReferencesRenderer = new CaretReferencesRenderer(this);
this.contextActionsRenderer = new ContextActionsRenderer(this); //this.contextActionsRenderer = new ContextActionsRenderer(this);
this.hiddenDefinitionRenderer = new HiddenDefinition.HiddenDefinitionRenderer(this); this.hiddenDefinitionRenderer = new HiddenDefinition.HiddenDefinitionRenderer(this);
UpdateCustomizedHighlighting(); UpdateCustomizedHighlighting();
@ -76,7 +73,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
public virtual void Dispose() public virtual void Dispose()
{ {
contextActionsRenderer.Dispose(); //contextActionsRenderer.Dispose();
hiddenDefinitionRenderer.Dispose(); hiddenDefinitionRenderer.Dispose();
} }
@ -92,8 +89,8 @@ namespace ICSharpCode.AvalonEdit.AddIn
else if (e.PropertyName == "EnableFolding") else if (e.PropertyName == "EnableFolding")
UpdateParseInformationForFolding(); UpdateParseInformationForFolding();
else if (e.PropertyName == "HighlightSymbol") { else if (e.PropertyName == "HighlightSymbol") {
if (this.caretReferencesRenderer != null) //if (this.caretReferencesRenderer != null)
this.caretReferencesRenderer.ClearHighlight(); // this.caretReferencesRenderer.ClearHighlight();
} }
} }
@ -204,6 +201,8 @@ namespace ICSharpCode.AvalonEdit.AddIn
public void ShowHelp() public void ShowHelp()
{ {
// Resolve expression at cursor and show help // Resolve expression at cursor and show help
#warning Reimplement ShowHelp()
/*
TextArea textArea = this.TextArea; TextArea textArea = this.TextArea;
IExpressionFinder expressionFinder = ParserService.GetExpressionFinder(this.Adapter.FileName); IExpressionFinder expressionFinder = ParserService.GetExpressionFinder(this.Adapter.FileName);
if (expressionFinder == null) if (expressionFinder == null)
@ -221,7 +220,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
if (mrr != null) { if (mrr != null) {
HelpProvider.ShowHelp(mrr.ResolvedMember); HelpProvider.ShowHelp(mrr.ResolvedMember);
} }
} }*/
} }
#endregion #endregion
@ -236,12 +235,12 @@ namespace ICSharpCode.AvalonEdit.AddIn
var pos = GetPositionFromPoint(e.GetPosition(this)); var pos = GetPositionFromPoint(e.GetPosition(this));
args.InDocument = pos.HasValue; args.InDocument = pos.HasValue;
if (pos.HasValue) { if (pos.HasValue) {
args.LogicalPosition = AvalonEditDocumentAdapter.ToLocation(pos.Value); args.LogicalPosition = pos.Value;
} }
TextMarkerService textMarkerService = this.Adapter.GetService(typeof(ITextMarkerService)) as TextMarkerService; TextMarkerService textMarkerService = this.Adapter.GetService(typeof(ITextMarkerService)) as TextMarkerService;
if (args.InDocument && textMarkerService != null) { if (args.InDocument && textMarkerService != null) {
var markersAtOffset = textMarkerService.GetMarkersAtOffset(args.Editor.Document.PositionToOffset(args.LogicalPosition.Line, args.LogicalPosition.Column)); var markersAtOffset = textMarkerService.GetMarkersAtOffset(args.Editor.Document.GetOffset(args.LogicalPosition));
ITextMarker markerWithToolTip = markersAtOffset.FirstOrDefault(marker => marker.ToolTip != null); ITextMarker markerWithToolTip = markersAtOffset.FirstOrDefault(marker => marker.ToolTip != null);
@ -386,16 +385,6 @@ namespace ICSharpCode.AvalonEdit.AddIn
#endregion #endregion
#region Ctrl+Click Go To Definition #region Ctrl+Click Go To Definition
GoToDefinition goToDefinitionCommand;
protected GoToDefinition GotoDefinitionCommand {
get
{
if (goToDefinitionCommand == null)
goToDefinitionCommand = new GoToDefinition();
return goToDefinitionCommand;
}
}
void TextViewMouseDown(object sender, MouseButtonEventArgs e) void TextViewMouseDown(object sender, MouseButtonEventArgs e)
{ {
// close existing debugger popup immediately on text editor mouse down // close existing debugger popup immediately on text editor mouse down
@ -406,8 +395,10 @@ namespace ICSharpCode.AvalonEdit.AddIn
var position = GetPositionFromPoint(e.GetPosition(this)); var position = GetPositionFromPoint(e.GetPosition(this));
if (position == null) if (position == null)
return; return;
Core.AnalyticsMonitorService.TrackFeature(typeof(GoToDefinition).FullName, "Ctrl+Click"); throw new NotImplementedException();
this.GotoDefinitionCommand.Run(this.Adapter, this.Document.GetOffset(position.Value)); //Core.AnalyticsMonitorService.TrackFeature(typeof(GoToDefinition).FullName, "Ctrl+Click");
//var goToDefinitionCommand = new GoToDefinition();
//goToDefinitionCommand.Run(this.Adapter, this.Document.GetOffset(position.Value));
e.Handled = true; e.Handled = true;
} }
} }
@ -418,6 +409,9 @@ namespace ICSharpCode.AvalonEdit.AddIn
{ {
base.OnKeyUp(e); base.OnKeyUp(e);
if (e.Handled) return; if (e.Handled) return;
#warning Reimplement CodeManipulation
// TODO put these in some menu so that they are discoverable
/*
if (e.Key == Key.W && Keyboard.Modifiers.HasFlag(ModifierKeys.Control)) { if (e.Key == Key.W && Keyboard.Modifiers.HasFlag(ModifierKeys.Control)) {
CodeManipulation.ExtendSelection(this.Adapter); CodeManipulation.ExtendSelection(this.Adapter);
} }
@ -428,7 +422,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
if (e.SystemKey == Key.Down && Keyboard.Modifiers.HasFlag(ModifierKeys.Alt)) { if (e.SystemKey == Key.Down && Keyboard.Modifiers.HasFlag(ModifierKeys.Alt)) {
// Left Alt + Down (probably will have different shortcut) // Left Alt + Down (probably will have different shortcut)
CodeManipulation.MoveStatementDown(this.Adapter); CodeManipulation.MoveStatementDown(this.Adapter);
} }*/
} }
#endregion #endregion
@ -456,13 +450,13 @@ namespace ICSharpCode.AvalonEdit.AddIn
CaretHighlightAdorner adorner = new CaretHighlightAdorner(textArea); CaretHighlightAdorner adorner = new CaretHighlightAdorner(textArea);
layer.Add(adorner); layer.Add(adorner);
WorkbenchSingleton.CallLater(TimeSpan.FromSeconds(1), (Action)(() => layer.Remove(adorner))); WorkbenchSingleton.CallLater(TimeSpan.FromSeconds(1), () => layer.Remove(adorner));
} }
#region UpdateParseInformation - Folding #region UpdateParseInformation - Folding
void UpdateParseInformationForFolding() void UpdateParseInformationForFolding()
{ {
UpdateParseInformationForFolding(ParserService.GetExistingParseInformation(this.Adapter.FileName)); UpdateParseInformationForFolding(ParserService.GetExistingParsedFile(this.Adapter.FileName));
} }
bool disableParseInformationFolding; bool disableParseInformationFolding;

3
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeManipulation.cs

@ -4,7 +4,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
/*
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Ast; using ICSharpCode.NRefactory.Ast;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
@ -288,3 +288,4 @@ namespace ICSharpCode.AvalonEdit.AddIn
} }
} }
} }
*/

4
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Commands/FoldingCommands.cs

@ -20,8 +20,8 @@ namespace ICSharpCode.AvalonEdit.AddIn.Commands
if (strategy != null) { if (strategy != null) {
// look for folding on this line: // look for folding on this line:
FoldingSection folding = strategy.FoldingManager.GetNextFolding(editor.Document.PositionToOffset(editor.Caret.Line, 1)); FoldingSection folding = strategy.FoldingManager.GetNextFolding(editor.Document.GetOffset(editor.Caret.Line, 1));
if (folding == null || editor.Document.GetLineForOffset(folding.StartOffset).LineNumber != editor.Caret.Line) { if (folding == null || editor.Document.GetLineByOffset(folding.StartOffset).LineNumber != editor.Caret.Line) {
// no folding found on current line: find innermost folding containing the caret // no folding found on current line: find innermost folding containing the caret
folding = strategy.FoldingManager.GetFoldingsContaining(editor.Caret.Offset).LastOrDefault(); folding = strategy.FoldingManager.GetFoldingsContaining(editor.Caret.Offset).LastOrDefault();
} }

9
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Commands/SortSelectionCommand.cs

@ -4,6 +4,7 @@
using System; using System;
using System.Linq; using System.Linq;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Editor;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using System.Collections.Generic; using System.Collections.Generic;
@ -27,11 +28,11 @@ namespace ICSharpCode.AvalonEdit.AddIn.Commands
if (provider != null) { if (provider != null) {
ITextEditor editor = provider.TextEditor; ITextEditor editor = provider.TextEditor;
if (editor.SelectionLength > 0) { if (editor.SelectionLength > 0) {
int start = editor.Document.GetLineForOffset(editor.SelectionStart).LineNumber; int start = editor.Document.GetLineByOffset(editor.SelectionStart).LineNumber;
int end = editor.Document.GetLineForOffset(editor.SelectionStart + editor.SelectionLength).LineNumber; int end = editor.Document.GetLineByOffset(editor.SelectionStart + editor.SelectionLength).LineNumber;
SortLines(editor.Document, start, end, comparer, SortOptions.RemoveDuplicates); SortLines(editor.Document, start, end, comparer, SortOptions.RemoveDuplicates);
} else { } else {
SortLines(editor.Document, 1, editor.Document.TotalNumberOfLines, comparer, SortOptions.RemoveDuplicates); SortLines(editor.Document, 1, editor.Document.LineCount, comparer, SortOptions.RemoveDuplicates);
} }
} }
} }
@ -41,7 +42,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Commands
{ {
List<string> lines = new List<string>(); List<string> lines = new List<string>();
for (int i = startLine; i <= endLine; ++i) { for (int i = startLine; i <= endLine; ++i) {
IDocumentLine line = document.GetLine(i); IDocumentLine line = document.GetLineByNumber(i);
lines.Add(document.GetText(line.Offset, line.Length)); lines.Add(document.GetText(line.Offset, line.Length));
} }

2
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActionsRenderer.cs

@ -15,6 +15,7 @@ using ICSharpCode.SharpDevelop.Refactoring;
namespace ICSharpCode.AvalonEdit.AddIn namespace ICSharpCode.AvalonEdit.AddIn
{ {
/*
/// <summary> /// <summary>
/// Renders Popup with context actions on the left side of the current line in the editor. /// Renders Popup with context actions on the left side of the current line in the editor.
/// </summary> /// </summary>
@ -154,4 +155,5 @@ namespace ICSharpCode.AvalonEdit.AddIn
ClosePopup(); ClosePopup();
} }
} }
*/
} }

47
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/DefaultChangeWatcher.cs

@ -11,6 +11,8 @@ using System.Text;
using ICSharpCode.AvalonEdit.AddIn.MyersDiff; using ICSharpCode.AvalonEdit.AddIn.MyersDiff;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Core;
using ICSharpCode.Editor;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
@ -20,9 +22,8 @@ namespace ICSharpCode.AvalonEdit.AddIn
public class DefaultChangeWatcher : IChangeWatcher, ILineTracker public class DefaultChangeWatcher : IChangeWatcher, ILineTracker
{ {
CompressingTreeList<LineChangeInfo> changeList; CompressingTreeList<LineChangeInfo> changeList;
IDocument document; TextDocument document;
TextDocument textDocument; ReadOnlyDocument baseDocument;
IDocument baseDocument;
public event EventHandler ChangeOccurred; public event EventHandler ChangeOccurred;
@ -38,33 +39,31 @@ namespace ICSharpCode.AvalonEdit.AddIn
return changeList[lineNumber]; return changeList[lineNumber];
} }
public void Initialize(IDocument document) public void Initialize(TextDocument document, FileName fileName)
{ {
if (changeList != null && changeList.Any()) if (changeList != null && changeList.Any())
return; return;
this.document = document; this.document = document;
this.textDocument = (TextDocument)document.GetService(typeof(TextDocument));
this.changeList = new CompressingTreeList<LineChangeInfo>((x, y) => x.Equals(y)); this.changeList = new CompressingTreeList<LineChangeInfo>((x, y) => x.Equals(y));
Stream baseFileStream = GetBaseVersion(); Stream baseFileStream = GetBaseVersion(fileName);
// TODO : update baseDocument on VCS actions // TODO : update baseDocument on VCS actions
if (baseFileStream != null) { if (baseFileStream != null) {
// ReadAll() is taking care of closing the stream // ReadAll() is taking care of closing the stream
baseDocument = DocumentUtilitites.LoadReadOnlyDocumentFromBuffer(new StringTextBuffer(ReadAll(baseFileStream))); baseDocument = new ReadOnlyDocument(ReadAll(baseFileStream));
} else { } else {
if (baseDocument == null) { if (baseDocument == null) {
// if the file is not under subversion, the document is the opened document // if the file is not under subversion, the document is the opened document
var doc = new TextDocument(textDocument.Text); baseDocument = new ReadOnlyDocument(document);
baseDocument = new AvalonEditDocumentAdapter(doc, null);
} }
} }
SetupInitialFileState(false); SetupInitialFileState(false);
this.textDocument.LineTrackers.Add(this); this.document.LineTrackers.Add(this);
this.textDocument.UndoStack.PropertyChanged += UndoStackPropertyChanged; this.document.UndoStack.PropertyChanged += UndoStackPropertyChanged;
} }
LineChangeInfo TransformLineChangeInfo(LineChangeInfo info) LineChangeInfo TransformLineChangeInfo(LineChangeInfo info)
@ -81,7 +80,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
if (update) if (update)
changeList.Transform(TransformLineChangeInfo); changeList.Transform(TransformLineChangeInfo);
else else
changeList.InsertRange(0, document.TotalNumberOfLines + 1, LineChangeInfo.Empty); changeList.InsertRange(0, document.LineCount + 1, LineChangeInfo.Empty);
} else { } else {
changeList.Clear(); changeList.Clear();
@ -110,7 +109,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
lastEndLine = endLine; lastEndLine = endLine;
} }
changeList.InsertRange(changeList.Count, textDocument.LineCount - lastEndLine, LineChangeInfo.Empty); changeList.InsertRange(changeList.Count, document.LineCount - lastEndLine, LineChangeInfo.Empty);
} }
OnChangeOccurred(EventArgs.Empty); OnChangeOccurred(EventArgs.Empty);
@ -123,10 +122,8 @@ namespace ICSharpCode.AvalonEdit.AddIn
} }
} }
Stream GetBaseVersion() Stream GetBaseVersion(FileName fileName)
{ {
string fileName = ((ITextEditor)document.GetService(typeof(ITextEditor))).FileName;
foreach (IDocumentVersionProvider provider in VersioningServices.Instance.DocumentVersionProviders) { foreach (IDocumentVersionProvider provider in VersioningServices.Instance.DocumentVersionProviders) {
var result = provider.OpenBaseVersion(fileName); var result = provider.OpenBaseVersion(fileName);
if (result != null) if (result != null)
@ -136,9 +133,9 @@ namespace ICSharpCode.AvalonEdit.AddIn
return null; return null;
} }
void UndoStackPropertyChanged(object sender, PropertyChangedEventArgs e) void UndoStackPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{ {
if (e.PropertyName == "IsOriginalFile" && textDocument.UndoStack.IsOriginalFile) if (e.PropertyName == "IsOriginalFile" && document.UndoStack.IsOriginalFile)
SetupInitialFileState(true); SetupInitialFileState(true);
} }
@ -167,7 +164,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
void ILineTracker.RebuildDocument() void ILineTracker.RebuildDocument()
{ {
changeList.Clear(); changeList.Clear();
changeList.InsertRange(0, document.TotalNumberOfLines + 1, new LineChangeInfo(ChangeType.Unsaved, 1, 1, baseDocument.TotalNumberOfLines, document.TotalNumberOfLines)); changeList.InsertRange(0, document.LineCount + 1, new LineChangeInfo(ChangeType.Unsaved, 1, 1, baseDocument.LineCount, document.LineCount));
} }
bool disposed = false; bool disposed = false;
@ -175,8 +172,8 @@ namespace ICSharpCode.AvalonEdit.AddIn
public void Dispose() public void Dispose()
{ {
if (!disposed) { if (!disposed) {
this.textDocument.LineTrackers.Remove(this); this.document.LineTrackers.Remove(this);
this.textDocument.UndoStack.PropertyChanged -= UndoStackPropertyChanged; this.document.UndoStack.PropertyChanged -= UndoStackPropertyChanged;
disposed = true; disposed = true;
} }
} }
@ -193,8 +190,8 @@ namespace ICSharpCode.AvalonEdit.AddIn
if (info.Change == ChangeType.Added) if (info.Change == ChangeType.Added)
return ""; return "";
var startDocumentLine = baseDocument.GetLine(info.OldStartLineNumber + 1); var startDocumentLine = baseDocument.GetLineByNumber(info.OldStartLineNumber + 1);
var endLine = baseDocument.GetLine(info.OldEndLineNumber); var endLine = baseDocument.GetLineByNumber(info.OldEndLineNumber);
return baseDocument.GetText(startDocumentLine.Offset, endLine.EndOffset - startDocumentLine.Offset); return baseDocument.GetText(startDocumentLine.Offset, endLine.EndOffset - startDocumentLine.Offset);
} }
@ -208,8 +205,8 @@ namespace ICSharpCode.AvalonEdit.AddIn
LineChangeInfo info = changeList[lineNumber]; LineChangeInfo info = changeList[lineNumber];
if (info.Change != ChangeType.None && info.Change != ChangeType.Unsaved) { if (info.Change != ChangeType.None && info.Change != ChangeType.Unsaved) {
var startLine = document.GetLine(info.NewStartLineNumber + 1); var startLine = document.GetLineByNumber(info.NewStartLineNumber + 1);
var endLine = document.GetLine(info.NewEndLineNumber); var endLine = document.GetLineByNumber(info.NewEndLineNumber);
offset = startLine.Offset; offset = startLine.Offset;
length = endLine.EndOffset - startLine.Offset; length = endLine.EndOffset - startLine.Offset;

2
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ExpressionHighlightRenderer.cs

@ -13,6 +13,7 @@ using ICSharpCode.SharpDevelop.Refactoring;
namespace ICSharpCode.AvalonEdit.AddIn namespace ICSharpCode.AvalonEdit.AddIn
{ {
/*
/// <summary> /// <summary>
/// Highlights expressions (references to expression under current caret). /// Highlights expressions (references to expression under current caret).
/// </summary> /// </summary>
@ -77,4 +78,5 @@ namespace ICSharpCode.AvalonEdit.AddIn
} }
} }
} }
*/
} }

10
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/IconBarManager.cs

@ -1,11 +1,11 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // 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) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.SharpDevelop.Dom;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Collections.Specialized; using System.Collections.Specialized;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Bookmarks; using ICSharpCode.SharpDevelop.Bookmarks;
namespace ICSharpCode.AvalonEdit.AddIn namespace ICSharpCode.AvalonEdit.AddIn
@ -40,7 +40,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
public event EventHandler RedrawRequested; public event EventHandler RedrawRequested;
public void UpdateClassMemberBookmarks(ParseInformation parseInfo) public void UpdateClassMemberBookmarks(IParsedFile parseInfo)
{ {
for (int i = bookmarks.Count - 1; i >= 0; i--) { for (int i = bookmarks.Count - 1; i >= 0; i--) {
if (IsClassMemberBookmark(bookmarks[i])) if (IsClassMemberBookmark(bookmarks[i]))
@ -48,18 +48,18 @@ namespace ICSharpCode.AvalonEdit.AddIn
} }
if (parseInfo == null) if (parseInfo == null)
return; return;
foreach (IClass c in parseInfo.CompilationUnit.Classes) { foreach (ITypeDefinition c in parseInfo.TopLevelTypeDefinitions) {
AddClassMemberBookmarks(c); AddClassMemberBookmarks(c);
} }
} }
void AddClassMemberBookmarks(IClass c) void AddClassMemberBookmarks(ITypeDefinition c)
{ {
if (c.IsSynthetic) return; if (c.IsSynthetic) return;
if (!c.Region.IsEmpty) { if (!c.Region.IsEmpty) {
bookmarks.Add(new ClassBookmark(c)); bookmarks.Add(new ClassBookmark(c));
} }
foreach (IClass innerClass in c.InnerClasses) { foreach (ITypeDefinition innerClass in c.NestedTypes) {
AddClassMemberBookmarks(innerClass); AddClassMemberBookmarks(innerClass);
} }
foreach (IMethod m in c.Methods) { foreach (IMethod m in c.Methods) {

1
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/InlineUIElementGenerator.cs

@ -5,6 +5,7 @@ using System;
using System.Windows; using System.Windows;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Rendering; using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.Editor;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
namespace ICSharpCode.AvalonEdit.AddIn namespace ICSharpCode.AvalonEdit.AddIn

60
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/LineChangeInfo.cs

@ -3,6 +3,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.Core;
using ICSharpCode.Editor;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
namespace ICSharpCode.AvalonEdit.AddIn namespace ICSharpCode.AvalonEdit.AddIn
@ -16,7 +19,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
/// Pass 0 to get the changes before the first line. /// Pass 0 to get the changes before the first line.
/// </summary> /// </summary>
LineChangeInfo GetChange(int lineNumber); LineChangeInfo GetChange(int lineNumber);
void Initialize(IDocument document); void Initialize(TextDocument document, FileName fileName);
string GetOldVersionFromLine(int lineNumber, out int newStartLine, out bool added); string GetOldVersionFromLine(int lineNumber, out int newStartLine, out bool added);
bool GetNewVersionFromLine(int lineNumber, out int offset, out int length); bool GetNewVersionFromLine(int lineNumber, out int offset, out int length);
IDocument CurrentDocument { get; } IDocument CurrentDocument { get; }
@ -43,41 +46,18 @@ namespace ICSharpCode.AvalonEdit.AddIn
set { change = value; } set { change = value; }
} }
int oldStartLineNumber; public readonly int OldStartLineNumber;
public readonly int NewStartLineNumber;
public int OldStartLineNumber { public readonly int OldEndLineNumber;
get { return oldStartLineNumber; } public readonly int NewEndLineNumber;
set { oldStartLineNumber = value; }
}
int newStartLineNumber;
public int NewStartLineNumber {
get { return newStartLineNumber; }
set { newStartLineNumber = value; }
}
int oldEndLineNumber;
public int OldEndLineNumber {
get { return oldEndLineNumber; }
set { oldEndLineNumber = value; }
}
int newEndLineNumber;
public int NewEndLineNumber {
get { return newEndLineNumber; }
set { newEndLineNumber = value; }
}
public LineChangeInfo(ChangeType change, int oldStartLineNumber, int newStartLineNumber, int oldEndLineNumber, int newEndLineNumber) public LineChangeInfo(ChangeType change, int oldStartLineNumber, int newStartLineNumber, int oldEndLineNumber, int newEndLineNumber)
{ {
this.change = change; this.change = change;
this.oldStartLineNumber = oldStartLineNumber; this.OldStartLineNumber = oldStartLineNumber;
this.newStartLineNumber = newStartLineNumber; this.NewStartLineNumber = newStartLineNumber;
this.oldEndLineNumber = oldEndLineNumber; this.OldEndLineNumber = oldEndLineNumber;
this.newEndLineNumber = newEndLineNumber; this.NewEndLineNumber = newEndLineNumber;
} }
#region Equals and GetHashCode implementation #region Equals and GetHashCode implementation
@ -89,10 +69,10 @@ namespace ICSharpCode.AvalonEdit.AddIn
public bool Equals(LineChangeInfo other) public bool Equals(LineChangeInfo other)
{ {
return this.change == other.change && return this.change == other.change &&
this.oldEndLineNumber == other.oldEndLineNumber && this.OldEndLineNumber == other.OldEndLineNumber &&
this.newStartLineNumber == other.newStartLineNumber && this.NewStartLineNumber == other.NewStartLineNumber &&
this.oldStartLineNumber == other.oldStartLineNumber && this.OldStartLineNumber == other.OldStartLineNumber &&
this.newEndLineNumber == other.newEndLineNumber; this.NewEndLineNumber == other.NewEndLineNumber;
} }
public override int GetHashCode() public override int GetHashCode()
@ -100,10 +80,10 @@ namespace ICSharpCode.AvalonEdit.AddIn
int hashCode = 0; int hashCode = 0;
unchecked { unchecked {
hashCode += 1000000007 * change.GetHashCode(); hashCode += 1000000007 * change.GetHashCode();
hashCode += 1000000009 * oldStartLineNumber.GetHashCode(); hashCode += 1000000009 * OldStartLineNumber.GetHashCode();
hashCode += 1000000021 * newStartLineNumber.GetHashCode(); hashCode += 1000000021 * NewStartLineNumber.GetHashCode();
hashCode += 1000000033 * oldEndLineNumber.GetHashCode(); hashCode += 1000000033 * OldEndLineNumber.GetHashCode();
hashCode += 1000000087 * newEndLineNumber.GetHashCode(); hashCode += 1000000087 * NewEndLineNumber.GetHashCode();
} }
return hashCode; return hashCode;
} }

1
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/MyersDiff/DocumentSequence.cs

@ -3,6 +3,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using ICSharpCode.Editor;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
namespace ICSharpCode.AvalonEdit.AddIn.MyersDiff namespace ICSharpCode.AvalonEdit.AddIn.MyersDiff

2
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/NewLineConsistencyCheck.cs

@ -5,9 +5,9 @@ using System;
using System.Threading; using System.Threading;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.AddIn namespace ICSharpCode.AvalonEdit.AddIn
{ {

16
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ParserFoldingStrategy.cs

@ -5,10 +5,10 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Folding; using ICSharpCode.AvalonEdit.Folding;
using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Parser;
namespace ICSharpCode.AvalonEdit.AddIn namespace ICSharpCode.AvalonEdit.AddIn
{ {
@ -52,10 +52,10 @@ namespace ICSharpCode.AvalonEdit.AddIn
{ {
List<NewFolding> newFoldMarkers = new List<NewFolding>(); List<NewFolding> newFoldMarkers = new List<NewFolding>();
if (parseInfo != null) { if (parseInfo != null) {
foreach (IClass c in parseInfo.CompilationUnit.Classes) { foreach (ITypeDefinition c in parseInfo.ParsedFile.TopLevelTypeDefinitions) {
AddClassMembers(c, newFoldMarkers); AddClassMembers(c, newFoldMarkers);
} }
foreach (FoldingRegion foldingRegion in parseInfo.CompilationUnit.FoldingRegions) { foreach (FoldingRegion foldingRegion in parseInfo.FoldingRegions) {
NewFolding f = new NewFoldingDefinition(GetOffset(foldingRegion.Region.BeginLine, foldingRegion.Region.BeginColumn), NewFolding f = new NewFoldingDefinition(GetOffset(foldingRegion.Region.BeginLine, foldingRegion.Region.BeginColumn),
GetOffset(foldingRegion.Region.EndLine, foldingRegion.Region.EndColumn)); GetOffset(foldingRegion.Region.EndLine, foldingRegion.Region.EndColumn));
f.DefaultClosed = isFirstUpdate; f.DefaultClosed = isFirstUpdate;
@ -76,9 +76,9 @@ namespace ICSharpCode.AvalonEdit.AddIn
public NewFoldingDefinition(int start, int end) : base(start, end) {} public NewFoldingDefinition(int start, int end) : base(start, end) {}
} }
void AddClassMembers(IClass c, List<NewFolding> newFoldMarkers) void AddClassMembers(ITypeDefinition c, List<NewFolding> newFoldMarkers)
{ {
if (c.ClassType == ClassType.Delegate) { if (c.Kind == TypeKind.Delegate) {
return; return;
} }
DomRegion cRegion = c.BodyRegion; DomRegion cRegion = c.BodyRegion;
@ -88,11 +88,11 @@ namespace ICSharpCode.AvalonEdit.AddIn
newFoldMarkers.Add(new NewFolding(GetOffset(cRegion.BeginLine, cRegion.BeginColumn), newFoldMarkers.Add(new NewFolding(GetOffset(cRegion.BeginLine, cRegion.BeginColumn),
GetOffset(cRegion.EndLine, cRegion.EndColumn))); GetOffset(cRegion.EndLine, cRegion.EndColumn)));
} }
foreach (IClass innerClass in c.InnerClasses) { foreach (ITypeDefinition innerClass in c.NestedTypes) {
AddClassMembers(innerClass, newFoldMarkers); AddClassMembers(innerClass, newFoldMarkers);
} }
foreach (IMember m in c.AllMembers) { foreach (IMember m in c.Members) {
if (m.Region.EndLine < m.BodyRegion.EndLine) { if (m.Region.EndLine < m.BodyRegion.EndLine) {
newFoldMarkers.Add(new NewFoldingDefinition(GetOffset(m.Region.EndLine, m.Region.EndColumn), newFoldMarkers.Add(new NewFoldingDefinition(GetOffset(m.Region.EndLine, m.Region.EndColumn),
GetOffset(m.BodyRegion.EndLine, m.BodyRegion.EndColumn))); GetOffset(m.BodyRegion.EndLine, m.BodyRegion.EndColumn)));

38
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/QuickClassBrowser.cs

@ -6,9 +6,11 @@ using System.Collections.Generic;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Editor;
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Parser;
namespace ICSharpCode.AvalonEdit.AddIn namespace ICSharpCode.AvalonEdit.AddIn
{ {
@ -44,8 +46,8 @@ namespace ICSharpCode.AvalonEdit.AddIn
this.IsInSamePart = true; this.IsInSamePart = true;
this.entity = entity; this.entity = entity;
this.typeCode = typeCode; this.typeCode = typeCode;
IAmbience ambience = entity.ProjectContent.Language.GetAmbience(); IAmbience ambience = entity.ProjectContent.GetAmbience();
if (entity is IClass) if (entity is ITypeDefinition)
ambience.ConversionFlags = ConversionFlags.ShowTypeParameterList | ConversionFlags.UseFullyQualifiedMemberNames; ambience.ConversionFlags = ConversionFlags.ShowTypeParameterList | ConversionFlags.UseFullyQualifiedMemberNames;
else else
ambience.ConversionFlags = ConversionFlags.ShowTypeParameterList | ConversionFlags.ShowParameterList | ConversionFlags.ShowParameterNames; ambience.ConversionFlags = ConversionFlags.ShowTypeParameterList | ConversionFlags.ShowParameterList | ConversionFlags.ShowParameterNames;
@ -116,7 +118,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
/// This causes the classes combo box to lose its current selection, /// This causes the classes combo box to lose its current selection,
/// so the members combo box will be cleared. /// so the members combo box will be cleared.
/// </summary> /// </summary>
public void Update(ICompilationUnit compilationUnit) public void Update(IParsedFile compilationUnit)
{ {
runUpdateWhenDropDownClosed = true; runUpdateWhenDropDownClosed = true;
runUpdateWhenDropDownClosedCU = compilationUnit; runUpdateWhenDropDownClosedCU = compilationUnit;
@ -129,11 +131,11 @@ namespace ICSharpCode.AvalonEdit.AddIn
List<EntityItem> classItems = new List<EntityItem>(); List<EntityItem> classItems = new List<EntityItem>();
List<EntityItem> memberItems = new List<EntityItem>(); List<EntityItem> memberItems = new List<EntityItem>();
void DoUpdate(ICompilationUnit compilationUnit) void DoUpdate(IParsedFile compilationUnit)
{ {
classItems = new List<EntityItem>(); classItems = new List<EntityItem>();
if (compilationUnit != null) { if (compilationUnit != null) {
AddClasses(compilationUnit.Classes); AddClasses(compilationUnit.TopLevelTypeDefinitions);
} }
classItems.Sort(); classItems.Sort();
classComboBox.ItemsSource = classItems; classComboBox.ItemsSource = classItems;
@ -145,9 +147,9 @@ namespace ICSharpCode.AvalonEdit.AddIn
// Delayed execution - avoid changing combo boxes while the user is browsing the dropdown list. // Delayed execution - avoid changing combo boxes while the user is browsing the dropdown list.
bool runUpdateWhenDropDownClosed; bool runUpdateWhenDropDownClosed;
ICompilationUnit runUpdateWhenDropDownClosedCU; IParsedFile runUpdateWhenDropDownClosedCU;
bool runSelectItemWhenDropDownClosed; bool runSelectItemWhenDropDownClosed;
Location runSelectItemWhenDropDownClosedLocation; TextLocation runSelectItemWhenDropDownClosedLocation;
void ComboBox_DropDownClosed(object sender, EventArgs e) void ComboBox_DropDownClosed(object sender, EventArgs e)
{ {
@ -162,18 +164,18 @@ namespace ICSharpCode.AvalonEdit.AddIn
} }
} }
void AddClasses(IEnumerable<IClass> classes) void AddClasses(IEnumerable<ITypeDefinition> classes)
{ {
foreach (IClass c in classes) { foreach (ITypeDefinition c in classes) {
classItems.Add(new EntityItem(c, TYPE_CLASS)); classItems.Add(new EntityItem(c, TYPE_CLASS));
AddClasses(c.InnerClasses); AddClasses(c.NestedTypes);
} }
} }
/// <summary> /// <summary>
/// Selects the class and member closest to the specified location. /// Selects the class and member closest to the specified location.
/// </summary> /// </summary>
public void SelectItemAtCaretPosition(Location location) public void SelectItemAtCaretPosition(TextLocation location)
{ {
runSelectItemWhenDropDownClosed = true; runSelectItemWhenDropDownClosed = true;
runSelectItemWhenDropDownClosedLocation = location; runSelectItemWhenDropDownClosedLocation = location;
@ -181,14 +183,14 @@ namespace ICSharpCode.AvalonEdit.AddIn
ComboBox_DropDownClosed(null, null); ComboBox_DropDownClosed(null, null);
} }
void DoSelectItem(Location location) void DoSelectItem(TextLocation location)
{ {
EntityItem matchInside = null; EntityItem matchInside = null;
EntityItem nearestMatch = null; EntityItem nearestMatch = null;
int nearestMatchDistance = int.MaxValue; int nearestMatchDistance = int.MaxValue;
foreach (EntityItem item in classItems) { foreach (EntityItem item in classItems) {
if (item.IsInSamePart) { if (item.IsInSamePart) {
IClass c = (IClass)item.Entity; ITypeDefinition c = (ITypeDefinition)item.Entity;
if (c.Region.IsInside(location.Line, location.Column)) { if (c.Region.IsInside(location.Line, location.Column)) {
matchInside = item; matchInside = item;
// when there are multiple matches inside (nested classes), use the last one // when there are multiple matches inside (nested classes), use the last one
@ -236,10 +238,10 @@ namespace ICSharpCode.AvalonEdit.AddIn
// The selected class was changed. // The selected class was changed.
// Update the list of member items to be the list of members of the current class. // Update the list of member items to be the list of members of the current class.
EntityItem item = classComboBox.SelectedItem as EntityItem; EntityItem item = classComboBox.SelectedItem as EntityItem;
IClass selectedClass = item != null ? item.Entity as IClass : null; ITypeDefinition selectedClass = item != null ? item.Entity as ITypeDefinition : null;
memberItems = new List<EntityItem>(); memberItems = new List<EntityItem>();
if (selectedClass != null) { if (selectedClass != null) {
IClass compoundClass = selectedClass.GetCompoundClass(); ITypeDefinition compoundClass = selectedClass.GetDefinition();
foreach (var m in compoundClass.Methods) { foreach (var m in compoundClass.Methods) {
AddMember(selectedClass, m, m.IsConstructor ? TYPE_CONSTRUCTOR : TYPE_METHOD); AddMember(selectedClass, m, m.IsConstructor ? TYPE_CONSTRUCTOR : TYPE_METHOD);
} }
@ -261,7 +263,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
membersComboBox.ItemsSource = memberItems; membersComboBox.ItemsSource = memberItems;
} }
void AddMember(IClass selectedClass, IMember member, int typeCode) void AddMember(ITypeDefinition selectedClass, IMember member, int typeCode)
{ {
bool isInSamePart = (member.DeclaringType == selectedClass); bool isInSamePart = (member.DeclaringType == selectedClass);
memberItems.Add(new EntityItem(member, typeCode) { IsInSamePart = isInSamePart }); memberItems.Add(new EntityItem(member, typeCode) { IsInSamePart = isInSamePart });
@ -287,7 +289,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
if (item.IsInSamePart && jumpAction != null) { if (item.IsInSamePart && jumpAction != null) {
jumpAction(region.BeginLine, region.BeginColumn); jumpAction(region.BeginLine, region.BeginColumn);
} else { } else {
FileService.JumpToFilePosition(item.Entity.CompilationUnit.FileName, region.BeginLine, region.BeginColumn); FileService.JumpToFilePosition(region.FileName, region.BeginLine, region.BeginColumn);
} }
} }

1
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopCompletionWindow.cs

@ -12,6 +12,7 @@ using ICSharpCode.AvalonEdit.CodeCompletion;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Editor;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; using ICSharpCode.SharpDevelop.Editor.CodeCompletion;

1
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopTextEditor.cs

@ -24,7 +24,6 @@ using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.AvalonEdit.Rendering; using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.Core.Presentation; using ICSharpCode.Core.Presentation;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using ICSharpCode.SharpDevelop.Editor.Commands; using ICSharpCode.SharpDevelop.Editor.Commands;

12
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Snippets/CodeSnippet.cs

@ -6,13 +6,13 @@ using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using ICSharpCode.AvalonEdit.Snippets; using ICSharpCode.AvalonEdit.Snippets;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using ICSharpCode.SharpDevelop.Parser;
namespace ICSharpCode.AvalonEdit.AddIn.Snippets namespace ICSharpCode.AvalonEdit.AddIn.Snippets
{ {
@ -185,18 +185,18 @@ namespace ICSharpCode.AvalonEdit.AddIn.Snippets
static string GetValue(ITextEditor editor, string propertyName) static string GetValue(ITextEditor editor, string propertyName)
{ {
if ("ClassName".Equals(propertyName, StringComparison.OrdinalIgnoreCase)) { if ("ClassName".Equals(propertyName, StringComparison.OrdinalIgnoreCase)) {
IClass c = GetCurrentClass(editor); ITypeDefinition c = GetCurrentClass(editor);
if (c != null) if (c != null)
return c.Name; return c.Name;
} }
return Core.StringParser.GetValue(propertyName); return Core.StringParser.GetValue(propertyName);
} }
static IClass GetCurrentClass(ITextEditor editor) static ITypeDefinition GetCurrentClass(ITextEditor editor)
{ {
var parseInfo = ParserService.GetExistingParseInformation(editor.FileName); var parseInfo = ParserService.GetExistingParsedFile(editor.FileName);
if (parseInfo != null) { if (parseInfo != null) {
return parseInfo.CompilationUnit.GetInnermostClass(editor.Caret.Line, editor.Caret.Column); return parseInfo.GetInnermostClass(editor.Caret.Line, editor.Caret.Column);
} }
return null; return null;
} }

14
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/TextMarkerService.cs

@ -7,14 +7,26 @@ using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Threading; using System.Windows.Threading;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Rendering; using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.Editor;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
namespace ICSharpCode.AvalonEdit.AddIn namespace ICSharpCode.AvalonEdit.AddIn
{ {
/// <summary>
/// Interface the text marker service uses to access the code editor.
/// </summary>
public interface ICodeEditor
{
TextDocument Document { get; }
void Redraw(ISegment segment, DispatcherPriority priority);
event EventHandler DocumentChanged;
}
/// <summary> /// <summary>
/// Handles the text markers for a code editor. /// Handles the text markers for a code editor.
/// </summary> /// </summary>

2
src/AddIns/Misc/SearchAndReplace/Project/Engine/DocumentIterator/DirectoryDocumentIterator.cs

@ -4,13 +4,13 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Editor; using ICSharpCode.Editor;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.Search; using ICSharpCode.SharpDevelop.Editor.Search;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Parser;
namespace SearchAndReplace namespace SearchAndReplace
{ {

2
src/AddIns/Misc/SearchAndReplace/Project/Engine/DocumentIterator/WholeProjectDocumentIterator.cs

@ -4,13 +4,13 @@
using System; using System;
using System.Collections; using System.Collections;
using System.IO; using System.IO;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Editor; using ICSharpCode.Editor;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.Search; using ICSharpCode.SharpDevelop.Editor.Search;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
namespace SearchAndReplace namespace SearchAndReplace

2
src/AddIns/Misc/SearchAndReplace/Project/Engine/DocumentIterator/WholeSolutionDocumentIterator.cs

@ -4,13 +4,13 @@
using System; using System;
using System.Collections; using System.Collections;
using System.IO; using System.IO;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Editor; using ICSharpCode.Editor;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.Search; using ICSharpCode.SharpDevelop.Editor.Search;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
namespace SearchAndReplace namespace SearchAndReplace

2
src/AddIns/VersionControl/GitAddIn/Src/OverlayIconManager.cs

@ -83,7 +83,7 @@ namespace ICSharpCode.GitAddIn
// sleep a tiny bit to give main thread time to add more jobs to the queue // sleep a tiny bit to give main thread time to add more jobs to the queue
Thread.Sleep(100); Thread.Sleep(100);
while (true) { while (true) {
if (ICSharpCode.SharpDevelop.ParserService.LoadSolutionProjectsThreadRunning) { if (ICSharpCode.SharpDevelop.Parser.ParserService.LoadSolutionProjectsThreadRunning) {
// Run OverlayIconManager much more slowly while solution is being loaded. // Run OverlayIconManager much more slowly while solution is being loaded.
// This prevents the disk from seeking too much // This prevents the disk from seeking too much
Thread.Sleep(100); Thread.Sleep(100);

2
src/AddIns/VersionControl/SubversionAddIn/Src/Gui/ProjectBrowserVisitor/OverlayIconManager.cs

@ -139,7 +139,7 @@ namespace ICSharpCode.Svn
// sleep a tiny bit to give main thread time to add more jobs to the queue // sleep a tiny bit to give main thread time to add more jobs to the queue
Thread.Sleep(2); Thread.Sleep(2);
while (true) { while (true) {
if (ICSharpCode.SharpDevelop.ParserService.LoadSolutionProjectsThreadRunning) { if (ICSharpCode.SharpDevelop.Parser.ParserService.LoadSolutionProjectsThreadRunning) {
// Run OverlayIconManager much more slowly while solution is being loaded. // Run OverlayIconManager much more slowly while solution is being loaded.
// This prevents the disk from seeking too much // This prevents the disk from seeking too much
Thread.Sleep(100); Thread.Sleep(100);

5
src/AddIns/VersionControl/SubversionAddIn/SubversionAddIn.csproj

@ -107,11 +107,6 @@
<Name>ICSharpCode.Core.WinForms</Name> <Name>ICSharpCode.Core.WinForms</Name>
<Private>False</Private> <Private>False</Private>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj">
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project>
<Name>ICSharpCode.SharpDevelop.Dom</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
</Project> </Project>

4
src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/ParsedFile.cs

@ -111,7 +111,7 @@ namespace ICSharpCode.NRefactory.CSharp
return FindEntity(topLevelTypeDefinitions, location); return FindEntity(topLevelTypeDefinitions, location);
} }
public ITypeDefinition GetTypeDefinition(AstLocation location) public ITypeDefinition GetInnerMostTypeDefinition(AstLocation location)
{ {
ITypeDefinition parent = null; ITypeDefinition parent = null;
ITypeDefinition type = GetTopLevelTypeDefinition(location); ITypeDefinition type = GetTopLevelTypeDefinition(location);
@ -124,7 +124,7 @@ namespace ICSharpCode.NRefactory.CSharp
public IMember GetMember(AstLocation location) public IMember GetMember(AstLocation location)
{ {
ITypeDefinition type = GetTypeDefinition(location); ITypeDefinition type = GetInnerMostTypeDefinition(location);
if (type == null) if (type == null)
return null; return null;
return FindEntity(type.Methods, location) return FindEntity(type.Methods, location)

2
src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs

@ -255,7 +255,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary> /// </summary>
public static ITypeDefinition GetTypeDefinition (this IParsedFile file, int line, int column) public static ITypeDefinition GetTypeDefinition (this IParsedFile file, int line, int column)
{ {
return file.GetTypeDefinition (new AstLocation (line, column)); return file.GetInnerMostTypeDefinition (new AstLocation (line, column));
} }
/// <summary> /// <summary>

2
src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/IParsedFile.cs

@ -67,7 +67,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// Gets the type (potentially a nested type) defined at the specified location. /// Gets the type (potentially a nested type) defined at the specified location.
/// Returns null if no type is defined at that location. /// Returns null if no type is defined at that location.
/// </summary> /// </summary>
ITypeDefinition GetTypeDefinition(AstLocation location); ITypeDefinition GetInnerMostTypeDefinition(AstLocation location);
/// <summary> /// <summary>
/// Gets the member defined at the specified location. /// Gets the member defined at the specified location.

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

@ -203,16 +203,9 @@
</Compile> </Compile>
<Compile Include="Src\Gui\Dialogs\ExtractInterfaceDialog.cs" /> <Compile Include="Src\Gui\Dialogs\ExtractInterfaceDialog.cs" />
<None Include="ICSharpCode.SharpDevelop.addin" /> <None Include="ICSharpCode.SharpDevelop.addin" />
<None Include="Src\Gui\Dialogs\ExtractInterfaceDialog.cs">
<Link>Src\Services\RefactoringService\ExtractInterfaceDialog.cs</Link>
</None>
<Compile Include="Src\Gui\Dialogs\ExtractInterfaceDialog.Designer.cs"> <Compile Include="Src\Gui\Dialogs\ExtractInterfaceDialog.Designer.cs">
<DependentUpon>ExtractInterfaceDialog.cs</DependentUpon> <DependentUpon>ExtractInterfaceDialog.cs</DependentUpon>
</Compile> </Compile>
<None Include="Src\Gui\Dialogs\ExtractInterfaceDialog.Designer.cs">
<Link>Src\Services\RefactoringService\ExtractInterfaceDialog.Designer.cs</Link>
<DependentUpon>ExtractInterfaceDialog.cs</DependentUpon>
</None>
<Compile Include="Src\Gui\Dialogs\GotoDialog.cs"> <Compile Include="Src\Gui\Dialogs\GotoDialog.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
@ -337,6 +330,7 @@
<Compile Include="Src\Services\ParserService\DomAssemblyName.cs" /> <Compile Include="Src\Services\ParserService\DomAssemblyName.cs" />
<Compile Include="Src\Services\ParserService\Fusion.cs" /> <Compile Include="Src\Services\ParserService\Fusion.cs" />
<Compile Include="Src\Services\ParserService\GacInterop.cs" /> <Compile Include="Src\Services\ParserService\GacInterop.cs" />
<Compile Include="Src\Services\ParserService\IParser.cs" />
<Compile Include="Src\Services\ParserService\ParseInformation.cs" /> <Compile Include="Src\Services\ParserService\ParseInformation.cs" />
<Compile Include="Src\Services\ParserService\LoadSolutionProjects.cs" /> <Compile Include="Src\Services\ParserService\LoadSolutionProjects.cs" />
<Compile Include="Src\Services\ParserService\ParserService.cs" /> <Compile Include="Src\Services\ParserService\ParserService.cs" />
@ -762,7 +756,6 @@
<Compile Include="Src\Project\MSBuildItemDefinitionGroup.cs" /> <Compile Include="Src\Project\MSBuildItemDefinitionGroup.cs" />
<Compile Include="Src\Project\AbstractProject.cs" /> <Compile Include="Src\Project\AbstractProject.cs" />
<Compile Include="Src\Project\BuildOptions.cs" /> <Compile Include="Src\Project\BuildOptions.cs" />
<Compile Include="Src\Project\IParser.cs" />
<Compile Include="Src\Project\CompilableProject.cs" /> <Compile Include="Src\Project\CompilableProject.cs" />
<Compile Include="Src\Project\MSBuildInternals.cs" /> <Compile Include="Src\Project\MSBuildInternals.cs" />
<Compile Include="Src\Util\ScrollUtils.cs" /> <Compile Include="Src\Util\ScrollUtils.cs" />
@ -782,10 +775,6 @@
<EmbeddedResource Include="Src\Gui\Dialogs\ExtractInterfaceDialog.resx"> <EmbeddedResource Include="Src\Gui\Dialogs\ExtractInterfaceDialog.resx">
<DependentUpon>ExtractInterfaceDialog.cs</DependentUpon> <DependentUpon>ExtractInterfaceDialog.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<None Include="Src\Gui\Dialogs\ExtractInterfaceDialog.resx">
<Link>Src\Services\RefactoringService\ExtractInterfaceDialog.resx</Link>
<DependentUpon>ExtractInterfaceDialog.cs</DependentUpon>
</None>
<EmbeddedResource Include="Src\Gui\Dialogs\NewProjectDialog.resx"> <EmbeddedResource Include="Src\Gui\Dialogs\NewProjectDialog.resx">
<DependentUpon>NewProjectDialog.cs</DependentUpon> <DependentUpon>NewProjectDialog.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>

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

@ -80,7 +80,7 @@ namespace ICSharpCode.SharpDevelop.Commands
NavigationService.ResumeLogging(); NavigationService.ResumeLogging();
ParserService.StartParserThread(); Parser.ParserService.StartParserThread();
// finally run the workbench window ... // finally run the workbench window ...
app.Run(WorkbenchSingleton.MainWindow); app.Run(WorkbenchSingleton.MainWindow);

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

@ -18,6 +18,7 @@ using ICSharpCode.Editor;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Gui namespace ICSharpCode.SharpDevelop.Gui
@ -166,7 +167,7 @@ namespace ICSharpCode.SharpDevelop.Gui
{ {
ITextEditor editor = GetEditor(); ITextEditor editor = GetEditor();
if (editor != null) { if (editor != null) {
IParsedFile parseInfo = ParserService.GetExistingParseInformation(editor.FileName); IParsedFile parseInfo = ParserService.GetExistingParsedFile(editor.FileName);
if (parseInfo != null) { if (parseInfo != null) {
foreach (ITypeDefinition c in parseInfo.TopLevelTypeDefinitions) { foreach (ITypeDefinition c in parseInfo.TopLevelTypeDefinitions) {
AddAllMembersMatchingText(c, text); AddAllMembersMatchingText(c, text);

1
src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs

@ -15,6 +15,7 @@ using ICSharpCode.Editor;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui.XmlForms; using ICSharpCode.SharpDevelop.Gui.XmlForms;
using ICSharpCode.SharpDevelop.Internal.Templates; using ICSharpCode.SharpDevelop.Internal.Templates;
using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Gui namespace ICSharpCode.SharpDevelop.Gui

2
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/TaskListOptions.cs

@ -4,8 +4,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Parser;
namespace ICSharpCode.SharpDevelop.Gui.OptionPanels namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
{ {

1
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ApplicationSettings.cs

@ -9,6 +9,7 @@ using System.Windows.Forms;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Gui.OptionPanels namespace ICSharpCode.SharpDevelop.Gui.OptionPanels

1
src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/GacReferencePanel.cs

@ -8,6 +8,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
using ICSharpCode.SharpDevelop.Parser;
using Mono.Cecil; using Mono.Cecil;
using ICSharpCode.Build.Tasks; using ICSharpCode.Build.Tasks;
using ICSharpCode.Core; using ICSharpCode.Core;

2
src/Main/Base/Project/Src/Gui/Dialogs/WordCountDialog.cs

@ -6,9 +6,9 @@ using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui.XmlForms; using ICSharpCode.SharpDevelop.Gui.XmlForms;
using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Gui namespace ICSharpCode.SharpDevelop.Gui

2
src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/ReferenceFolderNodeCommands.cs

@ -5,9 +5,9 @@ using System;
using System.Net; using System.Net;
using System.Web.Services.Discovery; using System.Web.Services.Discovery;
using System.Windows.Forms; using System.Windows.Forms;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Parser;
namespace ICSharpCode.SharpDevelop.Project.Commands namespace ICSharpCode.SharpDevelop.Project.Commands
{ {

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

@ -12,6 +12,7 @@ using System.Windows.Forms;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Core.WinForms; using ICSharpCode.Core.WinForms;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Gui namespace ICSharpCode.SharpDevelop.Gui

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

@ -8,6 +8,7 @@ using ICSharpCode.Core;
using ICSharpCode.Core.WinForms; using ICSharpCode.Core.WinForms;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Gui namespace ICSharpCode.SharpDevelop.Gui
@ -226,7 +227,7 @@ 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.
IParsedFile parseInfo = ParserService.GetExistingParseInformation(item.FileName); IParsedFile parseInfo = ParserService.GetExistingParsedFile(item.FileName);
if (parseInfo != null) { if (parseInfo != null) {
ITypeDefinition c = parseInfo.GetTypeDefinition(item.Line, item.Column); ITypeDefinition c = parseInfo.GetTypeDefinition(item.Line, item.Column);
if (c != null) return c; if (c != null) return c;

1
src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs

@ -18,6 +18,7 @@ using System.Windows.Media;
using System.Windows.Navigation; using System.Windows.Navigation;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Core.Presentation; using ICSharpCode.Core.Presentation;
using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Gui namespace ICSharpCode.SharpDevelop.Gui

1
src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs

@ -8,6 +8,7 @@ using System.Windows;
using System.Windows.Forms; using System.Windows.Forms;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Core.WinForms; using ICSharpCode.Core.WinForms;
using ICSharpCode.SharpDevelop.Parser;
namespace ICSharpCode.SharpDevelop.Gui namespace ICSharpCode.SharpDevelop.Gui
{ {

2
src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs

@ -7,10 +7,10 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Xml; using System.Xml;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
using Microsoft.Build.Exceptions; using Microsoft.Build.Exceptions;
using Import = System.Collections.Generic.KeyValuePair<string, string>; using Import = System.Collections.Generic.KeyValuePair<string, string>;

3
src/Main/Base/Project/Src/Project/CustomTool.cs

@ -13,6 +13,7 @@ using System.Text.RegularExpressions;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Editor; using ICSharpCode.Editor;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Parser;
namespace ICSharpCode.SharpDevelop.Project namespace ICSharpCode.SharpDevelop.Project
{ {
@ -200,7 +201,7 @@ namespace ICSharpCode.SharpDevelop.Project
}, },
outputFileName, FileErrorPolicy.Inform); outputFileName, FileErrorPolicy.Inform);
EnsureOutputFileIsInProject(baseItem, outputFileName); EnsureOutputFileIsInProject(baseItem, outputFileName);
ParserService.BeginParse(outputFileName, new StringTextSource(codeOutput)); ParserService.ParseAsync(outputFileName, new StringTextSource(codeOutput));
} }
public void GenerateCodeDomAsync(FileProjectItem baseItem, string outputFileName, Func<CodeCompileUnit> func) public void GenerateCodeDomAsync(FileProjectItem baseItem, string outputFileName, Func<CodeCompileUnit> func)

2
src/Main/Base/Project/Src/Project/Items/ReferenceProjectItem.cs

@ -6,9 +6,9 @@ using System.ComponentModel;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Parser;
namespace ICSharpCode.SharpDevelop.Project namespace ICSharpCode.SharpDevelop.Project
{ {

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

@ -5,8 +5,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Parser;
using Microsoft.Build.Construction; using Microsoft.Build.Construction;
using Microsoft.Build.Execution; using Microsoft.Build.Execution;
using Microsoft.Build.Framework; using Microsoft.Build.Framework;

2
src/Main/Base/Project/Src/Services/File/FileService.cs

@ -9,9 +9,9 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop namespace ICSharpCode.SharpDevelop

3
src/Main/Base/Project/Src/Services/File/OpenedFile.cs

@ -7,6 +7,7 @@ using System.Diagnostics;
using System.IO; using System.IO;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Parser;
namespace ICSharpCode.SharpDevelop namespace ICSharpCode.SharpDevelop
{ {
@ -455,7 +456,7 @@ namespace ICSharpCode.SharpDevelop
// We discarded some information when closing the file, // We discarded some information when closing the file,
// so we need to re-parse it. // so we need to re-parse it.
if (File.Exists(this.FileName)) if (File.Exists(this.FileName))
ParserService.BeginParse(this.FileName); ParserService.ParseAsync(this.FileName);
else else
ParserService.ClearParseInformation(this.FileName); ParserService.ClearParseInformation(this.FileName);
} }

1
src/Main/Base/Project/Src/Services/NavigationService/NavigationService.cs

@ -6,6 +6,7 @@ using System.Collections.Generic;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
using Mono.Cecil; using Mono.Cecil;

2
src/Main/Base/Project/Src/Services/ParserService/AssemblyParserService.cs

@ -15,7 +15,7 @@ using ICSharpCode.SharpDevelop.Project;
using Microsoft.Build.Tasks; using Microsoft.Build.Tasks;
using Mono.Cecil; using Mono.Cecil;
namespace ICSharpCode.SharpDevelop namespace ICSharpCode.SharpDevelop.Parser
{ {
/// <summary> /// <summary>
/// Portions of parser service that deal with loading external assemblies for code completion. /// Portions of parser service that deal with loading external assemblies for code completion.

2
src/Main/Base/Project/Src/Services/ParserService/CodeCompletionOptions.cs

@ -6,6 +6,8 @@ using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop namespace ICSharpCode.SharpDevelop
{ {
// TODO: what is this class doing in the ParserService ??
/// <summary> /// <summary>
/// Class containing static properties for the code completion options. /// Class containing static properties for the code completion options.
/// </summary> /// </summary>

2
src/Main/Base/Project/Src/Services/ParserService/DomAssemblyName.cs

@ -3,7 +3,7 @@
using System; using System;
namespace ICSharpCode.SharpDevelop namespace ICSharpCode.SharpDevelop.Parser
{ {
/// <summary> /// <summary>
/// Similar to System.Reflection.AssemblyName, but does not raise an exception /// Similar to System.Reflection.AssemblyName, but does not raise an exception

2
src/Main/Base/Project/Src/Services/ParserService/Doozer/ParserDescriptor.cs

@ -6,7 +6,7 @@ using System.IO;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop namespace ICSharpCode.SharpDevelop.Parser
{ {
public sealed class ParserDescriptor public sealed class ParserDescriptor
{ {

2
src/Main/Base/Project/Src/Services/ParserService/Doozer/ParserDoozer.cs

@ -5,7 +5,7 @@ using System;
using System.Collections; using System.Collections;
using ICSharpCode.Core; using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop namespace ICSharpCode.SharpDevelop.Parser
{ {
/// <summary> /// <summary>
/// Creates ParserDescriptor objects for the parsing service. /// Creates ParserDescriptor objects for the parsing service.

2
src/Main/Base/Project/Src/Services/ParserService/Fusion.cs

@ -8,7 +8,7 @@ using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes; using System.Runtime.InteropServices.ComTypes;
using System.Text; using System.Text;
namespace ICSharpCode.SharpDevelop namespace ICSharpCode.SharpDevelop.Parser
{ {
// .NET Fusion COM interfaces // .NET Fusion COM interfaces
[ComImport(), Guid("E707DCDE-D1CD-11D2-BAB9-00C04F8ECEAE"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [ComImport(), Guid("E707DCDE-D1CD-11D2-BAB9-00C04F8ECEAE"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]

3
src/Main/Base/Project/Src/Services/ParserService/GacInterop.cs

@ -7,10 +7,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;
using Mono.Cecil; using Mono.Cecil;
namespace ICSharpCode.SharpDevelop namespace ICSharpCode.SharpDevelop.Parser
{ {
/// <summary> /// <summary>
/// Interop with the .NET GAC. /// Interop with the .NET GAC.

21
src/Main/Base/Project/Src/Project/IParser.cs → src/Main/Base/Project/Src/Services/ParserService/IParser.cs

@ -5,15 +5,19 @@ using ICSharpCode.Editor;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using System; using System;
using ICSharpCode.SharpDevelop.Parser;
namespace ICSharpCode.SharpDevelop.Project namespace ICSharpCode.SharpDevelop.Project
{ {
/// <summary> /// <summary>
/// Represents a language parser that produces ICompilationUnit instances /// Represents a language parser that produces ParseInformation
/// for code files. /// and IParsedFile instances for code files.
/// </summary> /// </summary>
public interface IParser public interface IParser
{ {
/// <summary>
/// Gets/Sets the tags used to identify tasks.
/// </summary>
string[] LexerTags { string[] LexerTags {
get; get;
set; set;
@ -26,24 +30,23 @@ namespace ICSharpCode.SharpDevelop.Project
/// </summary> /// </summary>
bool CanParse(string fileName); bool CanParse(string fileName);
/// <summary>
/// Gets if the parser can parse the specified project.
/// Only when no parser for a project is found, the assembly is loaded.
/// </summary>
bool CanParse(IProject project);
/// <summary> /// <summary>
/// Parses a file. /// Parses a file.
/// </summary> /// </summary>
/// <param name="projectContent">The parent project of the file.</param> /// <param name="projectContent">The parent project of the file.</param>
/// <param name="fileName">The name of the file being parsed.</param> /// <param name="fileName">The name of the file being parsed.</param>
/// <param name="fileContent">The content of the file.</param> /// <param name="fileContent">The content of the file.</param>
/// <param name="fullParseInformationRequested">
/// Specifies whether full parse information were requested for this file.
/// If this parameter is false, only the ParsedFile and TagComments on the parse information need to be set.
/// </param>
/// <returns>The parse information representing the parse results.</returns> /// <returns>The parse information representing the parse results.</returns>
/// <remarks> /// <remarks>
/// SharpDevelop may call IParser.Parse in parallel. This will be done on the same IParser instance /// SharpDevelop may call IParser.Parse in parallel. This will be done on the same IParser instance
/// if there are two parallel parse requests for the same file. Parser implementations must be thread-safe. /// if there are two parallel parse requests for the same file. Parser implementations must be thread-safe.
/// </remarks> /// </remarks>
ParseInformation Parse(IProjectContent projectContent, string fileName, ITextSource fileContent); ParseInformation Parse(IProjectContent projectContent, string fileName, ITextSource fileContent,
bool fullParseInformationRequested);
//IResolver CreateResolver(); //IResolver CreateResolver();
} }

2
src/Main/Base/Project/Src/Services/ParserService/LoadSolutionProjects.cs

@ -11,7 +11,7 @@ using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop namespace ICSharpCode.SharpDevelop.Parser
{ {
/// <summary> /// <summary>
/// The background task that initializes the projects in the solution. /// The background task that initializes the projects in the solution.

34
src/Main/Base/Project/Src/Services/ParserService/ParseInformation.cs

@ -7,7 +7,7 @@ using ICSharpCode.Core;
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
namespace ICSharpCode.SharpDevelop namespace ICSharpCode.SharpDevelop.Parser
{ {
/// <summary> /// <summary>
/// Represents the result of a parser operation. /// Represents the result of a parser operation.
@ -15,16 +15,40 @@ namespace ICSharpCode.SharpDevelop
/// The extra information is only provided to listeners of the ParseInformationUpdated event. /// The extra information is only provided to listeners of the ParseInformationUpdated event.
/// Those listeners may then decide to store the extra information (e.g. the TaskService stores TagComments). /// Those listeners may then decide to store the extra information (e.g. the TaskService stores TagComments).
/// </summary> /// </summary>
public class ParseInformation : AbstractAnnotatable public class ParseInformation : AbstractAnnotatable, IFreezable
{ {
readonly IParsedFile parsedFile; readonly IParsedFile parsedFile;
readonly List<TagComment> tagComments = new List<TagComment>(); IList<TagComment> tagComments = new List<TagComment>();
readonly bool isFullParseInformation;
bool isFrozen;
public ParseInformation(IParsedFile parsedFile) public ParseInformation(IParsedFile parsedFile, bool isFullParseInformation)
{ {
if (parsedFile == null) if (parsedFile == null)
throw new ArgumentNullException("parsedFile"); throw new ArgumentNullException("parsedFile");
this.parsedFile = parsedFile; this.parsedFile = parsedFile;
this.isFullParseInformation = isFullParseInformation;
}
public bool IsFrozen {
get { return isFrozen; }
}
public void Freeze()
{
if (!isFrozen) {
isFrozen = true;
}
}
/// <summary>
/// Gets whether this parse information contains 'extra' data.
/// True = extra data is provided (e.g. folding information).
/// False = Only ParsedFile and TagComments are provided.
/// </summary>
public bool IsFullParseInformation {
get { return isFullParseInformation; }
} }
public IParsedFile ParsedFile { public IParsedFile ParsedFile {
@ -39,7 +63,7 @@ namespace ICSharpCode.SharpDevelop
get { return parsedFile.ProjectContent; } get { return parsedFile.ProjectContent; }
} }
public IEnumerable<TagComment> TagComments { public IList<TagComment> TagComments {
get { return tagComments; } get { return tagComments; }
} }
} }

2
src/Main/Base/Project/Src/Services/ParserService/ParseInformationEventArgs.cs

@ -7,7 +7,7 @@ using ICSharpCode.Core;
using ICSharpCode.Editor; using ICSharpCode.Editor;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
namespace ICSharpCode.SharpDevelop namespace ICSharpCode.SharpDevelop.Parser
{ {
public class ParseInformationEventArgs : EventArgs public class ParseInformationEventArgs : EventArgs
{ {

2
src/Main/Base/Project/Src/Services/ParserService/ParseProjectContent.cs

@ -12,7 +12,7 @@ using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
/* /*
namespace ICSharpCode.SharpDevelop namespace ICSharpCode.SharpDevelop.Parser
{ {
public sealed class ParseProjectContent : DefaultProjectContent public sealed class ParseProjectContent : DefaultProjectContent
{ {

256
src/Main/Base/Project/Src/Services/ParserService/ParserService.cs

@ -18,7 +18,7 @@ using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop namespace ICSharpCode.SharpDevelop.Parser
{ {
/// <summary> /// <summary>
/// Stores the compilation units for files. /// Stores the compilation units for files.
@ -259,7 +259,7 @@ namespace ICSharpCode.SharpDevelop
else else
snapshot = GetParseableFileContent(viewContent.PrimaryFileName); snapshot = GetParseableFileContent(viewContent.PrimaryFileName);
lastParseRun = BeginParse(fileName, snapshot).ContinueWith( lastParseRun = ParseAsync(fileName, snapshot).ContinueWith(
delegate(Task<IParsedFile> backgroundTask) { delegate(Task<IParsedFile> backgroundTask) {
IParsedFile parseInfo = backgroundTask.Result; IParsedFile parseInfo = backgroundTask.Result;
RaiseParserUpdateStepFinished(new ParserUpdateStepEventArgs(fileName, snapshot, parseInfo)); RaiseParserUpdateStepFinished(new ParserUpdateStepEventArgs(fileName, snapshot, parseInfo));
@ -532,6 +532,7 @@ namespace ICSharpCode.SharpDevelop
public Task<IParsedFile> BeginParse(ITextSource fileContent) public Task<IParsedFile> BeginParse(ITextSource fileContent)
{ {
// TODO: don't use background task if fileContent was specified and up-to-date parse info is available
return System.Threading.Tasks.Task.Factory.StartNew( return System.Threading.Tasks.Task.Factory.StartNew(
delegate { delegate {
try { try {
@ -545,40 +546,38 @@ namespace ICSharpCode.SharpDevelop
} }
} }
static FileEntry GetFileEntry(string fileName, bool createOnDemand) static FileEntry GetFileEntry(FileName fileName, bool createOnDemand)
{ {
if (fileName == null) if (fileName == null)
throw new ArgumentNullException("fileName"); throw new ArgumentNullException("fileName");
FileName f = new FileName(fileName);
FileEntry entry; FileEntry entry;
lock (syncLock) { lock (syncLock) {
if (!fileEntryDict.TryGetValue(f, out entry)) { if (!fileEntryDict.TryGetValue(fileName, out entry)) {
if (!createOnDemand) if (!createOnDemand)
return null; return null;
entry = new FileEntry(f); entry = new FileEntry(fileName);
fileEntryDict.Add(f, entry); fileEntryDict.Add(fileName, entry);
} }
} }
return entry; return entry;
} }
/// <summary> /// <summary>
/// Removes all parse information stored for the specified file. /// Removes all parse information (both IParsedFile and ParseInformation) for the specified file.
/// This method is thread-safe. /// This method is thread-safe.
/// </summary> /// </summary>
public static void ClearParseInformation(string fileName) public static void ClearParseInformation(FileName fileName)
{ {
if (fileName == null) if (fileName == null)
throw new ArgumentNullException("fileName"); throw new ArgumentNullException("fileName");
FileName f = new FileName(fileName); LoggingService.Info("ClearParseInformation: " + fileName);
LoggingService.Info("ClearParseInformation: " + f);
FileEntry entry; FileEntry entry;
lock (syncLock) { lock (syncLock) {
if (fileEntryDict.TryGetValue(f, out entry)) { if (fileEntryDict.TryGetValue(fileName, out entry)) {
fileEntryDict.Remove(f); fileEntryDict.Remove(fileName);
} }
} }
if (entry != null) if (entry != null)
@ -586,141 +585,166 @@ namespace ICSharpCode.SharpDevelop
} }
/// <summary> /// <summary>
/// Gets parse information for the specified file. /// This is the old method returning potentially-stale parse information.
/// Blocks if the file wasn't parsed yet, but may return an old parsed version. /// Use Parse()/ParseFile() instead if you need fresh parse info; otherwise use GetExistingParsedFile().
/// This method is thread-safe. This method involves waiting for the main thread, so using it while
/// holding a lock can lead to deadlocks. You might want to use <see cref="GetExistingParseInformation"/> instead.
/// </summary> /// </summary>
/// <returns>Returns the ParseInformation for the specified file, or null if the file cannot be parsed. [Obsolete("Use Parse()/ParseFile() instead if you need fresh parse info; otherwise use GetExistingParsedFile().")]
/// The returned ParseInformation might be stale (re-parse is not forced).</returns> public static ParseInformation GetParseInformation(string fileName)
public static IParsedFile GetParseInformation(string fileName)
{ {
if (string.IsNullOrEmpty(fileName)) if (string.IsNullOrEmpty(fileName))
return null; return null;
return GetFileEntry(fileName, true).GetParseInformation(null); return ParseFile(FileName.Create(fileName));
} }
/// <summary> /// <summary>
/// Gets parse information for the specified file. /// Gets full parse information for the specified file, if it is available.
/// This method is thread-safe.
/// </summary> /// </summary>
/// <returns>Returns the ParseInformation for the specified file, or null if the file has not been parsed already.</returns> /// <returns>
public static IParsedFile GetExistingParseInformation(string fileName) /// Returns the ParseInformation for the specified file,
/// or null if it is not in the parse information cache.
///
/// If only the IParsedFile is available (non-full parse information), this method
/// returns null.
/// </returns>
/// <remarks>
/// This method is thread-safe.
///
/// The ParserService may drop elements from the cache at any moment,
/// only IParsedFile will be stored for a longer time.
/// </remarks>
public static ParseInformation GetCachedParseInformation(FileName fileName)
{ {
if (string.IsNullOrEmpty(fileName)) if (string.IsNullOrEmpty(fileName))
return null; return null;
FileEntry entry = GetFileEntry(fileName, false); FileEntry entry = GetFileEntry(fileName, false);
if (entry != null) if (entry != null)
return entry.GetExistingParseInformation(null); return entry.GetCachedParseInformation(null);
else else
return null; return null;
} }
/// <summary> /// <summary>
/// Gets parse information for the specified file in the context of the /// Gets parse information for the specified file.
/// specified project content.
/// This method is thread-safe.
/// </summary> /// </summary>
/// <returns>Returns the ParseInformation for the specified file, or null if the file has not been parsed for that project content.</returns> /// <returns>
public static IParsedFile GetExistingParseInformation(IProjectContent content, string fileName) /// Returns the IParsedFile for the specified file,
/// or null if the file has not been parsed yet.
/// </returns>
/// <remarks>This method is thread-safe.</remarks>
public static IParsedFile GetExistingParsedFile(FileName fileName)
{ {
if (string.IsNullOrEmpty(fileName)) if (string.IsNullOrEmpty(fileName))
return null; return null;
FileEntry entry = GetFileEntry(fileName, false); FileEntry entry = GetFileEntry(fileName, false);
if (entry != null) if (entry != null)
return entry.GetExistingParseInformation(content); return entry.GetExistingParsedFile(null);
else else
return null; return null;
} }
/// <summary> /// <summary>
/// Gets parse information for the specified file. /// Gets parse information for the specified file in the context of the
/// Blocks until a recent copy of the parse information is available. /// specified project content.
/// This method is thread-safe. This method involves waiting for the main thread, so using it while
/// holding a lock can lead to deadlocks. You might want to use the overload taking ITextBuffer instead.
/// </summary> /// </summary>
/// <returns>Returns the ParseInformation for the specified file, or null if the file cannot be parsed. /// <param name="parentProjectContent">
/// The returned ParseInformation will not be stale (re-parse is forced if required).</returns> /// Project content to use as a parent project for the parse run.
public static IParsedFile ParseFile(string fileName) /// Specifying the project content explicitly can be useful when a file is used in multiple projects.
/// </param>
/// <param name="fileName">Name of the file.</param>
/// <returns>
/// Returns the IParsedFile for the specified file,
/// or null if the file has not been parsed for that project content.
/// </returns>
/// <remarks>This method is thread-safe.</remarks>
public static IParsedFile GetExistingParsedFile(IProjectContent parentProjectContent, FileName fileName)
{ {
return GetFileEntry(fileName, true).ParseFile(null, null); if (string.IsNullOrEmpty(fileName))
return null;
FileEntry entry = GetFileEntry(fileName, false);
if (entry != null)
return entry.GetExistingParsedFile(parentProjectContent);
else
return null;
} }
/// <summary> /// <summary>
/// Gets parse information for the specified file. /// Parses the specified file.
/// The fileContent is taken as a hint - if a newer version than it is already available, that will be used instead. /// Produces full parse information.
/// This method is thread-safe.
/// </summary> /// </summary>
/// <returns>Returns the ParseInformation for the specified file, or null if the file cannot be parsed. /// <param name="fileName">Name of the file to parse</param>
/// The returned ParseInformation will not be stale (re-parse is forced if required).</returns> /// <param name="fileContent">Optional: Content of the file to parse.
public static IParsedFile ParseFile(string fileName, ITextSource fileContent)
{
if (fileContent == null)
throw new ArgumentNullException("fileContent");
return GetFileEntry(fileName, true).ParseFile(null, fileContent);
}
/// <summary>
/// Gets parse information for the specified file.
/// The fileContent is taken as a hint - if a newer version than it is already available, that will be used instead. /// The fileContent is taken as a hint - if a newer version than it is already available, that will be used instead.
/// This method is thread-safe. /// </param>
/// </summary> /// <returns>
/// <returns>Returns the ParseInformation for the specified file, or null if the file cannot be parsed. /// Returns the ParseInformation for the specified file, or null if the file cannot be parsed.
/// The returned ParseInformation will not be stale (re-parse is forced if required).</returns> /// For files currently open in an editor, this method does not necessary reparse, but may return
public static IParsedFile ParseFile(IProjectContent parentProjectContent, string fileName, ITextSource fileContent) /// an existing cached parse information (but only if it's still up-to-date).
/// </returns>
/// <remarks>
/// This method is thread-safe. This parser being used may involve locking or waiting for the main thread,
/// so using this method while holding a lock can lead to deadlocks.
/// </remarks>
public static ParseInformation Parse(FileName fileName, ITextSource fileContent = null)
{ {
if (fileContent == null) return GetFileEntry(fileName, true).Parse(null, fileContent);
throw new ArgumentNullException("fileContent");
return GetFileEntry(fileName, true).ParseFile(parentProjectContent, fileContent);
} }
/// <summary> /// <summary>
/// Begins an asynchronous reparse. /// Asynchronous version of <see cref="Parse(FileName, ITextSource)"/>.
/// This method is thread-safe. The returned task might wait for the main thread to be ready, beware of deadlocks.
/// You might want to use the overload taking ITextBuffer instead.
/// </summary> /// </summary>
/// <param name="fileName">Name of the file to parse</param>
/// <param name="fileContent">Optional: Content of the file to parse.
/// The fileContent is taken as a hint - if a newer version than it is already available, that will be used instead.
/// </param>
/// <returns> /// <returns>
/// Returns a task that will make the parse result available. /// Returns the ParseInformation for the specified file, or null if the file cannot be parsed.
/// For files currently open in an editor, this method does not necessary reparse, but may return
/// an existing cached parse information (but only if it's still up-to-date).
/// </returns> /// </returns>
/// <remarks> /// <remarks>
/// EnqueueForParsing has been renamed to BeginParse and now provides a future (Task&lt;ParseInformation&gt;) /// This method is thread-safe. This parser being used may involve locking or waiting for the main thread,
/// to allow waiting for the result. However, to avoid deadlocks, this should not be done by any /// so using this method while holding a lock can lead to deadlocks.
/// thread the parser might be waiting for (especially the main thread).
///
/// Unlike BeginParse().Wait(), ParseFile() is safe to call from the main thread.
/// </remarks> /// </remarks>
public static Task<IParsedFile> BeginParse(string fileName) public static Task<ParseInformation> ParseAsync(FileName fileName, ITextSource fileContent = null)
{ {
return GetFileEntry(fileName, true).BeginParse(null); if (fileContent == null)
throw new ArgumentNullException("fileContent");
// create snapshot (in case someone passes a mutable document to BeginParse)
return GetFileEntry(fileName, true).BeginParse(fileContent.CreateSnapshot());
} }
/// <summary> /// <summary>
/// Begins an asynchronous reparse. /// Parses the specified file.
/// This method is thread-safe. /// This method does not request full parse information
/// </summary> /// </summary>
/// <param name="parentProjectContent">
/// Project content to use as a parent project for the parse run.
/// Specifying the project content explicitly can be useful when a file is used in multiple projects.
/// </param>
/// <param name="fileName">Name of the file to parse</param>
/// <param name="fileContent">Optional: Content of the file to parse.
/// The fileContent is taken as a hint - if a newer version than it is already available, that will be used instead.
/// </param>
/// <returns> /// <returns>
/// Returns a task that will make the parse result available. /// Returns the ParseInformation for the specified file, or null if the file cannot be parsed.
/// For files currently open in an editor, this method does not necessary reparse, but may return
/// an existing cached parse information (but only if it's still up-to-date).
/// </returns> /// </returns>
/// <remarks> /// <remarks>
/// EnqueueForParsing has been renamed to BeginParse and now provides a future (Task&lt;ParseInformation&gt;) /// This method is thread-safe. This parser being used may involve locking or waiting for the main thread,
/// to allow waiting for the result. However, to avoid deadlocks, this should not be done by any /// so using this method while holding a lock can lead to deadlocks.
/// thread the parser might be waiting for (especially the main thread).
///
/// Unlike BeginParse().Wait(), ParseFile() is safe to call from the main thread.
/// </remarks> /// </remarks>
public static Task<IParsedFile> BeginParse(string fileName, ITextSource fileContent) public static IParsedFile ParseFile(IProjectContent parentProjectContent, FileName fileName, ITextSource fileContent = null)
{ {
if (fileContent == null) return GetFileEntry(fileName, true).Parse(parentProjectContent, fileContent);
throw new ArgumentNullException("fileContent");
// create snapshot (in case someone passes a mutable document to BeginParse)
return GetFileEntry(fileName, true).BeginParse(fileContent.CreateSnapshot());
} }
/// <summary> /// <summary>
/// Parses the current view content. /// Parses the current view content.
/// This method can only be called from the main thread. /// This method can only be called from the main thread.
/// </summary> /// </summary>
public static IParsedFile ParseCurrentViewContent() public static ParseInformation ParseCurrentViewContent()
{ {
WorkbenchSingleton.AssertMainThread(); WorkbenchSingleton.AssertMainThread();
IViewContent viewContent = WorkbenchSingleton.Workbench.ActiveViewContent; IViewContent viewContent = WorkbenchSingleton.Workbench.ActiveViewContent;
@ -734,7 +758,7 @@ namespace ICSharpCode.SharpDevelop
/// Parses the specified view content. /// Parses the specified view content.
/// This method can only be called from the main thread. /// This method can only be called from the main thread.
/// </summary> /// </summary>
public static IParsedFile ParseViewContent(IViewContent viewContent) public static ParseInformation ParseViewContent(IViewContent viewContent)
{ {
if (viewContent == null) if (viewContent == null)
throw new ArgumentNullException("viewContent"); throw new ArgumentNullException("viewContent");
@ -748,59 +772,6 @@ namespace ICSharpCode.SharpDevelop
return ParseFile(viewContent.PrimaryFileName); return ParseFile(viewContent.PrimaryFileName);
} }
/// <summary>
/// Parses the current view content.
/// This method can only be called from the main thread.
/// </summary>
/// <remarks>
/// EnqueueForParsing has been renamed to BeginParse and now provides a future (Task&lt;ParseInformation&gt;)
/// to allow waiting for the result. However, to avoid deadlocks, this should not be done by any
/// thread the parser might be waiting for (especially the main thread).
///
/// Unlike BeginParse().Wait(), ParseFile() is safe to call from the main thread.
/// </remarks>
public static Task<IParsedFile> BeginParseCurrentViewContent()
{
WorkbenchSingleton.AssertMainThread();
IViewContent viewContent = WorkbenchSingleton.Workbench.ActiveViewContent;
if (viewContent != null)
return BeginParseViewContent(viewContent);
else
return NullTask();
}
/// <summary>
/// Begins parsing the specified view content.
/// This method can only be called from the main thread.
/// </summary>
/// <remarks>
/// EnqueueForParsing has been renamed to BeginParse and now provides a future (Task&lt;ParseInformation&gt;)
/// to allow waiting for the result. However, to avoid deadlocks, this should not be done by any
/// thread the parser might be waiting for (especially the main thread).
///
/// Unlike BeginParse().Wait(), ParseFile() is safe to call from the main thread.
/// </remarks>
public static Task<IParsedFile> BeginParseViewContent(IViewContent viewContent)
{
if (viewContent == null)
throw new ArgumentNullException("viewContent");
WorkbenchSingleton.AssertMainThread();
if (string.IsNullOrEmpty(viewContent.PrimaryFileName))
return NullTask();
IEditable editable = viewContent as IEditable;
if (editable != null)
return BeginParse(viewContent.PrimaryFileName, editable.CreateSnapshot());
else
return BeginParse(viewContent.PrimaryFileName);
}
static Task<IParsedFile> NullTask()
{
var tcs = new TaskCompletionSource<IParsedFile>();
tcs.SetResult(null);
return tcs.Task;
}
/// <summary> /// <summary>
/// Gets the parser instance that is responsible for the specified file. /// Gets the parser instance that is responsible for the specified file.
/// Will create a new IParser instance on demand. /// Will create a new IParser instance on demand.
@ -815,11 +786,10 @@ namespace ICSharpCode.SharpDevelop
/// Registers a compilation unit in the parser service. /// Registers a compilation unit in the parser service.
/// Does not fire the OnParseInformationUpdated event, please use this for unit tests only! /// Does not fire the OnParseInformationUpdated event, please use this for unit tests only!
/// </summary> /// </summary>
public static IParsedFile RegisterParseInformation(string fileName, IParsedFile cu) public static void RegisterParseInformation(string fileName, IParsedFile cu)
{ {
FileEntry entry = GetFileEntry(fileName, true); FileEntry entry = GetFileEntry(fileName, true);
entry.RegisterParseInformation(cu); entry.RegisterParseInformation(cu);
return cu;
} }
/// <summary> /// <summary>

1
src/Main/Base/Project/Src/Services/ProjectService/ParseableFileContentFinder.cs

@ -7,6 +7,7 @@ using System.Linq;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Editor; using ICSharpCode.Editor;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Parser;
namespace ICSharpCode.SharpDevelop.Project namespace ICSharpCode.SharpDevelop.Project
{ {

2
src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs

@ -8,9 +8,9 @@ using System.Linq;
using System.Text; using System.Text;
using System.Windows.Input; using System.Windows.Input;
using System.Xml; using System.Xml;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Parser;
namespace ICSharpCode.SharpDevelop.Project namespace ICSharpCode.SharpDevelop.Project
{ {

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

@ -4,9 +4,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop namespace ICSharpCode.SharpDevelop
@ -85,7 +85,7 @@ namespace ICSharpCode.SharpDevelop
static void ParserService_ParseInformationUpdated(object sender, ParseInformationEventArgs e) static void ParserService_ParseInformationUpdated(object sender, ParseInformationEventArgs e)
{ {
if (e.NewParsedFile == ParserService.GetExistingParseInformation(e.FileName)) { if (e.NewParsedFile == ParserService.GetExistingParsedFile(e.FileName)) {
// Call UpdateCommentTags only for the main parse information (if a file is in multiple projects), // Call UpdateCommentTags only for the main parse information (if a file is in multiple projects),
// and only if the results haven't already been replaced with a more recent ParseInformation. // and only if the results haven't already been replaced with a more recent ParseInformation.
if (e.NewParseInformation != null) { if (e.NewParseInformation != null) {

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

@ -14,11 +14,13 @@ using System.Windows.Forms;
using System.Windows.Media; using System.Windows.Media;
using System.Xml; using System.Xml;
using System.Xml.Linq; using System.Xml.Linq;
using ICSharpCode.Core.Presentation; using ICSharpCode.Core.Presentation;
using ICSharpCode.Editor; using ICSharpCode.Editor;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Project;
using WinForms = System.Windows.Forms; using WinForms = System.Windows.Forms;
namespace ICSharpCode.SharpDevelop namespace ICSharpCode.SharpDevelop
@ -110,25 +112,7 @@ namespace ICSharpCode.SharpDevelop
/// <returns>Iterator that enumerates the tree structure in preorder.</returns> /// <returns>Iterator that enumerates the tree structure in preorder.</returns>
public static IEnumerable<T> Flatten<T>(this IEnumerable<T> input, Func<T, IEnumerable<T>> recursion) public static IEnumerable<T> Flatten<T>(this IEnumerable<T> input, Func<T, IEnumerable<T>> recursion)
{ {
Stack<IEnumerator<T>> stack = new Stack<IEnumerator<T>>(); return ICSharpCode.NRefactory.Utils.TreeTraversal.PreOrder(input, recursion);
try {
stack.Push(input.GetEnumerator());
while (stack.Count > 0) {
while (stack.Peek().MoveNext()) {
T element = stack.Peek().Current;
yield return element;
IEnumerable<T> children = recursion(element);
if (children != null) {
stack.Push(children.GetEnumerator());
}
}
stack.Pop().Dispose();
}
} finally {
while (stack.Count > 0) {
stack.Pop().Dispose();
}
}
} }
/// <summary> /// <summary>
@ -566,6 +550,19 @@ namespace ICSharpCode.SharpDevelop
{ {
editor.Select(editor.Document.GetOffset(editor.Caret.Location), 0); editor.Select(editor.Document.GetOffset(editor.Caret.Location), 0);
} }
/// <summary>
/// Gets the ambience for the specified project content.
/// Never returns null.
/// </summary>
public static IAmbience GetAmbience(this IProjectContent pc)
{
IProject p = ParserService.GetProject(pc);
if (p != null)
return p.GetAmbience();
else
return AmbienceService.GetCurrentAmbience();
}
#endregion #endregion
} }
} }

10
src/Main/ICSharpCode.SharpDevelop.Sda/ICSharpCode.SharpDevelop.Sda.csproj

@ -88,6 +88,11 @@
<Compile Include="Src\RunWorkbenchException.cs" /> <Compile Include="Src\RunWorkbenchException.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\Libraries\NRefactory\ICSharpCode.Editor\ICSharpCode.Editor.csproj">
<Project>{F054A788-B591-4561-A8BA-AE745BBEB817}</Project>
<Name>ICSharpCode.Editor</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\Base\Project\ICSharpCode.SharpDevelop.csproj"> <ProjectReference Include="..\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> <Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name> <Name>ICSharpCode.SharpDevelop</Name>
@ -113,11 +118,6 @@
<Name>ICSharpCode.Core.WinForms</Name> <Name>ICSharpCode.Core.WinForms</Name>
<Private>False</Private> <Private>False</Private>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj">
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project>
<Name>ICSharpCode.SharpDevelop.Dom</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project> </Project>

5
src/Main/ICSharpCode.SharpDevelop.Sda/Src/CallHelper.cs

@ -49,7 +49,8 @@ namespace ICSharpCode.SharpDevelop.Sda
if (properties.PropertiesName != null) { if (properties.PropertiesName != null) {
startup.PropertiesName = properties.PropertiesName; startup.PropertiesName = properties.PropertiesName;
} }
AssemblyParserService.DomPersistencePath = properties.DomPersistencePath; #warning reimplement DOM persistence, or remove the setting
//AssemblyParserService.DomPersistencePath = properties.DomPersistencePath;
if (properties.ApplicationRootPath != null) { if (properties.ApplicationRootPath != null) {
FileUtility.ApplicationRootPath = properties.ApplicationRootPath; FileUtility.ApplicationRootPath = properties.ApplicationRootPath;
@ -92,7 +93,7 @@ namespace ICSharpCode.SharpDevelop.Sda
Project.ProjectService.SolutionConfigurationChanged += delegate { this.callback.SolutionConfigurationChanged(); }; Project.ProjectService.SolutionConfigurationChanged += delegate { this.callback.SolutionConfigurationChanged(); };
FileUtility.FileLoaded += delegate(object sender, FileNameEventArgs e) { this.callback.FileLoaded(e.FileName); }; FileUtility.FileLoaded += delegate(object sender, FileNameEventArgs e) { this.callback.FileLoaded(e.FileName); };
FileUtility.FileSaved += delegate(object sender, FileNameEventArgs e) { this.callback.FileSaved(e.FileName); }; FileUtility.FileSaved += delegate(object sender, FileNameEventArgs e) { this.callback.FileSaved(e.FileName); };
LoggingService.Info("InitSharpDevelop finished"); LoggingService.Info("InitSharpDevelop finished");
} }

3
src/Main/ICSharpCode.SharpDevelop.Sda/Src/Document.cs

@ -1,8 +1,9 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // 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) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.SharpDevelop.Editor;
using System; using System;
using ICSharpCode.Editor;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.SharpDevelop.Sda namespace ICSharpCode.SharpDevelop.Sda

4
src/Main/StartUp/Project/StartUp.csproj

@ -100,10 +100,6 @@
<Project>{80318B5F-A25D-45AB-8A95-EF31D2370A4C}</Project> <Project>{80318B5F-A25D-45AB-8A95-EF31D2370A4C}</Project>
<Name>ICSharpCode.SharpDevelop.Sda</Name> <Name>ICSharpCode.SharpDevelop.Sda</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj">
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project>
<Name>ICSharpCode.SharpDevelop.Dom</Name>
</ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project> </Project>
Loading…
Cancel
Save