Browse Source

Update to AvalonEdit 5.0.1 from the standalone AvalonEdit repository.

pull/507/head
Daniel Grunwald 11 years ago
parent
commit
fdb87492f5
  1. 16
      SharpDevelop.Tests.sln
  2. 8
      SharpDevelop.sln
  3. 5
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs
  4. 1
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/GoToEntityAction.cs
  5. 1
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/QuickClassBrowser.cs
  6. 7
      src/Libraries/AvalonEdit/.gitignore
  7. 118
      src/Libraries/AvalonEdit/Documentation/ICSharpCode.AvalonEdit.shfbproj
  8. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Document/ChangeTrackingTest.cs
  9. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Document/TextAnchorTest.cs
  10. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Document/TextSegmentTreeTest.cs
  11. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Document/TextUtilitiesTests.cs
  12. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Editing/ChangeDocumentTests.cs
  13. 3
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Highlighting/HighlightedLineMergeTests.cs
  14. 52
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/ICSharpCode.AvalonEdit.Tests.csproj
  15. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/MultipleUIThreads.cs
  16. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Properties/AssemblyInfo.cs
  17. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Search/FindTests.cs
  18. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Utils/CaretNavigationTests.cs
  19. 8
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionList.cs
  20. 4
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/ICompletionData.cs
  21. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/DocumentChangeEventArgs.cs
  22. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/DocumentLine.cs
  23. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/DocumentTextWriter.cs
  24. 343
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/IDocument.cs
  25. 142
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/ITextAnchor.cs
  26. 357
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/ITextSource.cs
  27. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/LineManager.cs
  28. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/NewLineFinder.cs
  29. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/OffsetChangeMap.cs
  30. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/RopeTextSource.cs
  31. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/SimpleSegment.cs
  32. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextAnchor.cs
  33. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextAnchorTree.cs
  34. 5
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs
  35. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocumentWeakEventManager.cs
  36. 271
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextLocation.cs
  37. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextSegment.cs
  38. 4
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextSegmentCollection.cs
  39. 136
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextSourceVersionProvider.cs
  40. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextUtilities.cs
  41. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Caret.cs
  42. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs
  43. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/EmptySelection.cs
  44. 4
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/IReadOnlySectionProvider.cs
  45. 7
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/NoReadOnlySections.cs
  46. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/RectangleSelection.cs
  47. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Selection.cs
  48. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/SelectionColorizer.cs
  49. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/SelectionMouseHandler.cs
  50. 4
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/SelectionSegment.cs
  51. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/SimpleSelection.cs
  52. 3
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/TextArea.cs
  53. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/TextSegmentReadOnlySectionProvider.cs
  54. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingSection.cs
  55. 4
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/NewFolding.cs
  56. 8
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/DocumentHighlighter.cs
  57. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightedInlineBuilder.cs
  58. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightedLine.cs
  59. 4
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightedSection.cs
  60. 3
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColor.cs
  61. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColorizer.cs
  62. 6
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingEngine.cs
  63. 3
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingManager.cs
  64. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HtmlClipboard.cs
  65. 8
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HtmlOptions.cs
  66. 19
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HtmlRichTextWriter.cs
  67. 4
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/IHighlighter.cs
  68. 8
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/RichTextModel.cs
  69. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/RichTextModelWriter.cs
  70. 108
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj
  71. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Indentation/DefaultIndentationStrategy.cs
  72. 12
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Properties/AssemblyInfo.cs
  73. 3
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/BackgroundGeometryBuilder.cs
  74. 3
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs
  75. 28
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/DropDownButton.cs
  76. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/ISearchStrategy.cs
  77. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/RegexSearchStrategy.cs
  78. 33
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/SearchCommands.cs
  79. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/IActiveElement.cs
  80. 6
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/InsertionContext.cs
  81. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/Snippet.cs
  82. 3
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/SnippetCaretElement.cs
  83. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/SnippetReplaceableTextElement.cs
  84. 10
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditor.cs
  85. 12
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditorOptions.cs
  86. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextViewPosition.cs
  87. 101
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/CallbackOnDispose.cs
  88. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/Deque.cs
  89. 11
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/DocumentPrinter.cs
  90. 123
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/IFreezable.cs
  91. 132
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/ImmutableStack.cs
  92. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/Rope.cs
  93. 0
      src/Main/Base/Project/Editor/CodeCompletion/Images/Class.png
  94. 4
      src/Main/Base/Project/Editor/CodeCompletion/Images/CompletionImage.cs
  95. 0
      src/Main/Base/Project/Editor/CodeCompletion/Images/Constructor.png
  96. 0
      src/Main/Base/Project/Editor/CodeCompletion/Images/Delegate.png
  97. 0
      src/Main/Base/Project/Editor/CodeCompletion/Images/Enum.png
  98. 0
      src/Main/Base/Project/Editor/CodeCompletion/Images/EnumValue.png
  99. 0
      src/Main/Base/Project/Editor/CodeCompletion/Images/Event.png
  100. 0
      src/Main/Base/Project/Editor/CodeCompletion/Images/ExtensionMethod.png
  101. Some files were not shown because too many files have changed in this diff Show More

16
SharpDevelop.Tests.sln

@ -290,10 +290,10 @@ Global
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|Any CPU.Build.0 = net_4_0_Debug|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|Any CPU.Build.0 = net_4_0_Debug|Any CPU
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Release|Any CPU.Build.0 = net_4_0_Release|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Release|Any CPU.Build.0 = net_4_0_Release|Any CPU
{6222A3A1-83CE-47A3-A4E4-A018F82D44D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6222A3A1-83CE-47A3-A4E4-A018F82D44D8}.Debug|Any CPU.ActiveCfg = Debug|WithNRefactory
{6222A3A1-83CE-47A3-A4E4-A018F82D44D8}.Debug|Any CPU.Build.0 = Debug|Any CPU {6222A3A1-83CE-47A3-A4E4-A018F82D44D8}.Debug|Any CPU.Build.0 = Debug|WithNRefactory
{6222A3A1-83CE-47A3-A4E4-A018F82D44D8}.Release|Any CPU.ActiveCfg = Release|Any CPU {6222A3A1-83CE-47A3-A4E4-A018F82D44D8}.Release|Any CPU.ActiveCfg = Release|WithNRefactory
{6222A3A1-83CE-47A3-A4E4-A018F82D44D8}.Release|Any CPU.Build.0 = Release|Any CPU {6222A3A1-83CE-47A3-A4E4-A018F82D44D8}.Release|Any CPU.Build.0 = Release|WithNRefactory
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Debug|Any CPU.ActiveCfg = net_4_5_Debug|Any CPU {3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Debug|Any CPU.ActiveCfg = net_4_5_Debug|Any CPU
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Debug|Any CPU.Build.0 = net_4_5_Debug|Any CPU {3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Debug|Any CPU.Build.0 = net_4_5_Debug|Any CPU
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Release|Any CPU.ActiveCfg = net_4_5_Release|Any CPU {3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Release|Any CPU.ActiveCfg = net_4_5_Release|Any CPU
@ -322,10 +322,10 @@ Global
{2FF700C2-A38A-48BD-A637-8CAFD4FE6237}.Debug|Any CPU.Build.0 = Debug|Any CPU {2FF700C2-A38A-48BD-A637-8CAFD4FE6237}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2FF700C2-A38A-48BD-A637-8CAFD4FE6237}.Release|Any CPU.ActiveCfg = Release|Any CPU {2FF700C2-A38A-48BD-A637-8CAFD4FE6237}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2FF700C2-A38A-48BD-A637-8CAFD4FE6237}.Release|Any CPU.Build.0 = Release|Any CPU {2FF700C2-A38A-48BD-A637-8CAFD4FE6237}.Release|Any CPU.Build.0 = Release|Any CPU
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.ActiveCfg = Debug|WithNRefactory
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.Build.0 = Debug|Any CPU {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.Build.0 = Debug|WithNRefactory
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Release|Any CPU.ActiveCfg = Release|Any CPU {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Release|Any CPU.ActiveCfg = Release|WithNRefactory
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Release|Any CPU.Build.0 = Release|Any CPU {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Release|Any CPU.Build.0 = Release|WithNRefactory
{4139CCF6-FB49-4A9D-B2CF-331E9EA3198D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4139CCF6-FB49-4A9D-B2CF-331E9EA3198D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4139CCF6-FB49-4A9D-B2CF-331E9EA3198D}.Debug|Any CPU.Build.0 = Debug|Any CPU {4139CCF6-FB49-4A9D-B2CF-331E9EA3198D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4139CCF6-FB49-4A9D-B2CF-331E9EA3198D}.Release|Any CPU.ActiveCfg = Release|Any CPU {4139CCF6-FB49-4A9D-B2CF-331E9EA3198D}.Release|Any CPU.ActiveCfg = Release|Any CPU

8
SharpDevelop.sln

@ -263,10 +263,10 @@ Global
{2FF700C2-A38A-48BD-A637-8CAFD4FE6237}.Debug|Any CPU.Build.0 = Debug|Any CPU {2FF700C2-A38A-48BD-A637-8CAFD4FE6237}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2FF700C2-A38A-48BD-A637-8CAFD4FE6237}.Release|Any CPU.ActiveCfg = Release|Any CPU {2FF700C2-A38A-48BD-A637-8CAFD4FE6237}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2FF700C2-A38A-48BD-A637-8CAFD4FE6237}.Release|Any CPU.Build.0 = Release|Any CPU {2FF700C2-A38A-48BD-A637-8CAFD4FE6237}.Release|Any CPU.Build.0 = Release|Any CPU
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.ActiveCfg = Debug|WithNRefactory
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.Build.0 = Debug|Any CPU {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.Build.0 = Debug|WithNRefactory
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Release|Any CPU.ActiveCfg = Release|Any CPU {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Release|Any CPU.ActiveCfg = Release|WithNRefactory
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Release|Any CPU.Build.0 = Release|Any CPU {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Release|Any CPU.Build.0 = Release|WithNRefactory
{4139CCF6-FB49-4A9D-B2CF-331E9EA3198D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4139CCF6-FB49-4A9D-B2CF-331E9EA3198D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4139CCF6-FB49-4A9D-B2CF-331E9EA3198D}.Debug|Any CPU.Build.0 = Debug|Any CPU {4139CCF6-FB49-4A9D-B2CF-331E9EA3198D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4139CCF6-FB49-4A9D-B2CF-331E9EA3198D}.Release|Any CPU.ActiveCfg = Release|Any CPU {4139CCF6-FB49-4A9D-B2CF-331E9EA3198D}.Release|Any CPU.ActiveCfg = Release|Any CPU

5
src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs

@ -94,7 +94,10 @@ namespace CSharpBinding.FormattingStrategy
convertTabsToSpaces = effectiveConvertTabsToSpaces.Value; convertTabsToSpaces = effectiveConvertTabsToSpaces.Value;
} }
return ICSharpCode.AvalonEdit.TextEditorOptions.GetIndentationString(1, indentationSize, convertTabsToSpaces); if (convertTabsToSpaces)
return new string(' ', indentationSize);
else
return "\t";
} }
/* NR indent engine (temporarily?) disabled as per #447 /* NR indent engine (temporarily?) disabled as per #447

1
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/GoToEntityAction.cs

@ -23,6 +23,7 @@ using System.Threading.Tasks;
using ICSharpCode.AvalonEdit.CodeCompletion; using ICSharpCode.AvalonEdit.CodeCompletion;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using ICSharpCode.SharpDevelop.Editor.ContextActions; using ICSharpCode.SharpDevelop.Editor.ContextActions;
using ICSharpCode.SharpDevelop.Refactoring; using ICSharpCode.SharpDevelop.Refactoring;

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

@ -26,6 +26,7 @@ using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem.Implementation; using ICSharpCode.NRefactory.TypeSystem.Implementation;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using ICSharpCode.SharpDevelop.Parser; using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;

7
src/Libraries/AvalonEdit/.gitignore vendored

@ -0,0 +1,7 @@
# ignore all obj and bin folders (even in subdirectories)
obj/
bin/
/Documentation/Help
/packages/AvalonEdit
/packages/AvalonEdit.Sample
/packages/NUnit.2.6.3

118
src/Libraries/AvalonEdit/Documentation/ICSharpCode.AvalonEdit.shfbproj

@ -39,20 +39,20 @@
<ComponentConfigurations> <ComponentConfigurations>
<ComponentConfig id="Code Block Component" enabled="True"> <ComponentConfig id="Code Block Component" enabled="True">
<component id="Code Block Component" type="SandcastleBuilder.Components.CodeBlockComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll"> <component id="Code Block Component" type="SandcastleBuilder.Components.CodeBlockComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll">
<!-- Base path for relative filenames in source attributes (optional) --> <!-- Base path for relative filenames in source attributes (optional) -->
<basePath value="{@HtmlEncProjectFolder}" /> <basePath value="{@HtmlEncProjectFolder}" />
<!-- Base output paths for the files (required). These should match the parent folder of the output path <!-- Base output paths for the files (required). These should match the parent folder of the output path
of the HTML files (see each of the SaveComponent instances in the configuration files). --> of the HTML files (see each of the SaveComponent instances in the configuration files). -->
<outputPaths> <outputPaths>
{@HelpFormatOutputPaths} {@HelpFormatOutputPaths}
</outputPaths> </outputPaths>
<!-- Allow missing source files (Optional). If omitted, it will generate errors if referenced source files <!-- Allow missing source files (Optional). If omitted, it will generate errors if referenced source files
are missing. --> are missing. -->
<allowMissingSource value="false" /> <allowMissingSource value="false" />
<!-- Remove region markers from imported code blocks. If omitted, region markers in imported code blocks <!-- Remove region markers from imported code blocks. If omitted, region markers in imported code blocks
are left alone. --> are left alone. -->
<removeRegionMarkers value="false" /> <removeRegionMarkers value="false" />
<!-- Code colorizer options (required). <!-- Code colorizer options (required).
Attributes: Attributes:
Language syntax configuration file (required) Language syntax configuration file (required)
XSLT stylesheet file (required) XSLT stylesheet file (required)
@ -65,58 +65,68 @@
Keep XML comment "see" tags within the code (optional) Keep XML comment "see" tags within the code (optional)
Tab size override (optional, 0 = Use syntax file setting) Tab size override (optional, 0 = Use syntax file setting)
Use language name as default title (optional) --> Use language name as default title (optional) -->
<colorizer syntaxFile="{@SHFBFolder}Colorizer\highlight.xml" styleFile="{@SHFBFolder}Colorizer\highlight.xsl" stylesheet="{@SHFBFolder}Colorizer\highlight.css" scriptFile="{@SHFBFolder}Colorizer\highlight.js" disabled="{@DisableCodeBlockComponent}" language="cs" numberLines="false" outlining="false" keepSeeTags="false" tabSize="0" defaultTitle="true" /> <colorizer syntaxFile="{@SHFBFolder}Colorizer\highlight.xml" styleFile="{@SHFBFolder}Colorizer\highlight.xsl" stylesheet="{@SHFBFolder}Colorizer\highlight.css" scriptFile="{@SHFBFolder}Colorizer\highlight.js" disabled="{@DisableCodeBlockComponent}" language="cs" numberLines="false" outlining="false" keepSeeTags="false" tabSize="0" defaultTitle="true" />
</component> </component>
</ComponentConfig> </ComponentConfig>
<ComponentConfig id="IntelliSense Component" enabled="True"><component id="IntelliSense Component" type="SandcastleBuilder.Components.IntelliSenseComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll"> <ComponentConfig id="IntelliSense Component" enabled="True">
<!-- Output options (optional) <component id="IntelliSense Component" type="SandcastleBuilder.Components.IntelliSenseComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll">
<!-- Output options (optional)
Attributes: Attributes:
Include Namespaces (false by default) Include Namespaces (false by default)
Namespaces filename ("Namespaces" if not specified or empty) Namespaces filename ("Namespaces" if not specified or empty)
Directory (current folder if not specified or empty) --> Directory (current folder if not specified or empty) -->
<output includeNamespaces="false" namespacesFile="Namespaces" folder="{@OutputFolder}" /> <output includeNamespaces="false" namespacesFile="Namespaces" folder="{@OutputFolder}" />
</component></ComponentConfig> </component>
<ComponentConfig id="Cached Framework Comments Index Data" enabled="True"><component id="Cached Framework Comments Index Data" type="SandcastleBuilder.Components.CachedCopyFromIndexComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll"> </ComponentConfig>
<index name="comments" value="/doc/members/member" key="@name" cache="100"> <ComponentConfig id="Cached Framework Comments Index Data" enabled="True">
<component id="Cached Framework Comments Index Data" type="SandcastleBuilder.Components.CachedCopyFromIndexComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll">
<index name="comments" value="/doc/members/member" key="@name" cache="100">
{@CachedFrameworkCommentList} {@CachedFrameworkCommentList}
{@CommentFileList} {@CommentFileList}
</index> </index>
<copy name="comments" source="*" target="/document/comments" /> <copy name="comments" source="*" target="/document/comments" />
</component></ComponentConfig> </component>
<ComponentConfig id="Cached Reflection Index Data" enabled="True"><component id="Cached Reflection Index Data" type="SandcastleBuilder.Components.CachedCopyFromIndexComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll"> </ComponentConfig>
<index name="reflection" value="/reflection/apis/api" key="@id" cache="10"> <ComponentConfig id="Cached Reflection Index Data" enabled="True">
<cache base="{@SandcastlePath}Data\Reflection" recurse="true" files="*.xml" cacheFile="{@LocalDataFolder}Cache\Reflection.cache" /> <component id="Cached Reflection Index Data" type="SandcastleBuilder.Components.CachedCopyFromIndexComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll">
<data files="reflection.xml" /> <index name="reflection" value="/reflection/apis/api" key="@id" cache="10">
</index> <cache base="{@SandcastlePath}Data\Reflection" recurse="true" files="*.xml" cacheFile="{@LocalDataFolder}Cache\Reflection.cache" />
<copy name="reflection" source="*" target="/document/reference" /> <data files="reflection.xml" />
</component></ComponentConfig> </index>
<ComponentConfig id="API Token Resolution" enabled="True"><component id="API Token Resolution" type="Microsoft.Ddue.Tools.SharedContentComponent" assembly="{@SandcastlePath}ProductionTools\BuildComponents.dll"> <copy name="reflection" source="*" target="/document/reference" />
</component>
</ComponentConfig>
<ComponentConfig id="API Token Resolution" enabled="True">
<component id="API Token Resolution" type="Microsoft.Ddue.Tools.SharedContentComponent" assembly="{@SandcastlePath}ProductionTools\BuildComponents.dll">
{@TokenFiles} {@TokenFiles}
<replace elements="/*//token" item="string(.)" /> <replace elements="/*//token" item="string(.)" /></component>
</component></ComponentConfig> </ComponentConfig>
<ComponentConfig id="Cached MSDN URL References" enabled="True"><component id="Cached MSDN URL References" type="SandcastleBuilder.Components.CachedResolveReferenceLinksComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll" locale="{@Locale}" linkTarget="{@SdkLinkTarget}"> <ComponentConfig id="Cached MSDN URL References" enabled="True">
<helpOutput format="HtmlHelp1"> <component id="Cached MSDN URL References" type="SandcastleBuilder.Components.CachedResolveReferenceLinksComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll" locale="{@Locale}" linkTarget="{@SdkLinkTarget}">
<cache filename="{@LocalDataFolder}Cache\MsdnUrl.cache" /> <helpOutput format="HtmlHelp1">
<targets base="{@SandcastlePath}Data\Reflection" recurse="true" files="*.xml" type="{@HtmlSdkLinkType}" /> <cache filename="{@LocalDataFolder}Cache\MsdnUrl.cache" />
<targets files="reflection.xml" type="Local" /> <targets base="{@SandcastlePath}Data\Reflection" recurse="true" files="*.xml" type="{@HtmlSdkLinkType}" />
</helpOutput> <targets files="reflection.xml" type="Local" />
<helpOutput format="MSHelp2"> </helpOutput>
<cache filename="{@LocalDataFolder}Cache\MsdnUrl.cache" /> <helpOutput format="MSHelp2">
<targets base="{@SandcastlePath}Data\Reflection" recurse="true" files="*.xml" type="{@MSHelp2SdkLinkType}" /> <cache filename="{@LocalDataFolder}Cache\MsdnUrl.cache" />
<targets files="reflection.xml" type="Index" /> <targets base="{@SandcastlePath}Data\Reflection" recurse="true" files="*.xml" type="{@MSHelp2SdkLinkType}" />
</helpOutput> <targets files="reflection.xml" type="Index" />
<helpOutput format="MSHelpViewer"> </helpOutput>
<cache filename="{@LocalDataFolder}Cache\MsdnUrl.cache" /> <helpOutput format="MSHelpViewer">
<targets base="{@SandcastlePath}Data\Reflection" recurse="true" files="*.xml" type="{@MSHelpViewerSdkLinkType}" /> <cache filename="{@LocalDataFolder}Cache\MsdnUrl.cache" />
<targets files="reflection.xml" type="Id" /> <targets base="{@SandcastlePath}Data\Reflection" recurse="true" files="*.xml" type="{@MSHelpViewerSdkLinkType}" />
</helpOutput> <targets files="reflection.xml" type="Id" />
<helpOutput format="Website"> </helpOutput>
<cache filename="{@LocalDataFolder}Cache\MsdnUrl.cache" /> <helpOutput format="Website">
<targets base="{@SandcastlePath}Data\Reflection" recurse="true" files="*.xml" type="{@WebsiteSdkLinkType}" /> <cache filename="{@LocalDataFolder}Cache\MsdnUrl.cache" />
<targets files="reflection.xml" type="Local" /> <targets base="{@SandcastlePath}Data\Reflection" recurse="true" files="*.xml" type="{@WebsiteSdkLinkType}" />
</helpOutput> <targets files="reflection.xml" type="Local" />
</component></ComponentConfig></ComponentConfigurations> </helpOutput>
</component>
</ComponentConfig>
</ComponentConfigurations>
<DocumentationSources> <DocumentationSources>
<DocumentationSource sourceFile="..\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj" /> <DocumentationSource sourceFile="..\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj" />
</DocumentationSources> </DocumentationSources>
@ -146,6 +156,12 @@ Additionally, the class HighlightingColorizer provides integration of the highli
<NamingMethod>Guid</NamingMethod> <NamingMethod>Guid</NamingMethod>
<Language>en-US</Language> <Language>en-US</Language>
<ContentPlacement>AboveNamespaces</ContentPlacement> <ContentPlacement>AboveNamespaces</ContentPlacement>
<BuildAssemblerVerbosity>OnlyWarningsAndErrors</BuildAssemblerVerbosity>
<HelpFileFormat>HtmlHelp1, Website</HelpFileFormat>
<IndentHtml>False</IndentHtml>
<KeepLogFile>True</KeepLogFile>
<DisableCodeBlockComponent>False</DisableCodeBlockComponent>
<CppCommentsFixup>False</CppCommentsFixup>
</PropertyGroup> </PropertyGroup>
<!-- There are no properties for these two groups but they need to appear in <!-- There are no properties for these two groups but they need to appear in
order for Visual Studio to perform the build. --> order for Visual Studio to perform the build. -->

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Document/ChangeTrackingTest.cs

@ -18,7 +18,9 @@
using System; using System;
using System.Linq; using System.Linq;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
using NUnit.Framework; using NUnit.Framework;
namespace ICSharpCode.AvalonEdit.Document namespace ICSharpCode.AvalonEdit.Document

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Document/TextAnchorTest.cs

@ -18,7 +18,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
using NUnit.Framework; using NUnit.Framework;
namespace ICSharpCode.AvalonEdit.Document namespace ICSharpCode.AvalonEdit.Document

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Document/TextSegmentTreeTest.cs

@ -18,7 +18,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
using NUnit.Framework; using NUnit.Framework;
namespace ICSharpCode.AvalonEdit.Document namespace ICSharpCode.AvalonEdit.Document

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Document/TextUtilitiesTests.cs

@ -17,7 +17,9 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
using NUnit.Framework; using NUnit.Framework;
namespace ICSharpCode.AvalonEdit.Document namespace ICSharpCode.AvalonEdit.Document

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Editing/ChangeDocumentTests.cs

@ -19,7 +19,9 @@
using System; using System;
using System.Text; using System.Text;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
#if NREFACTORY
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
#endif
using NUnit.Framework; using NUnit.Framework;
namespace ICSharpCode.AvalonEdit.Editing namespace ICSharpCode.AvalonEdit.Editing

3
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Highlighting/HighlightedLineMergeTests.cs

@ -19,6 +19,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
using NUnit.Framework; using NUnit.Framework;
@ -27,7 +28,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting
[TestFixture] [TestFixture]
public class HighlightedLineMergeTests public class HighlightedLineMergeTests
{ {
IDocument document = new ReadOnlyDocument(new string(' ', 20)); IDocument document = new TextDocument(new string(' ', 20));
[Test] [Test]
public void SimpleMerge1() public void SimpleMerge1()

52
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/ICSharpCode.AvalonEdit.Tests.csproj

@ -3,13 +3,12 @@
<PropertyGroup> <PropertyGroup>
<ProjectGuid>{6222A3A1-83CE-47A3-A4E4-A018F82D44D8}</ProjectGuid> <ProjectGuid>{6222A3A1-83CE-47A3-A4E4-A018F82D44D8}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">Net40</Platform>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.AvalonEdit</RootNamespace> <RootNamespace>ICSharpCode.AvalonEdit</RootNamespace>
<AssemblyName>ICSharpCode.AvalonEdit.Tests</AssemblyName> <AssemblyName>ICSharpCode.AvalonEdit.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion Condition=" '$(Configuration)' == '' ">v4.0</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<SourceAnalysisOverrideSettingsFile>"C:\Program Files\SharpDevelop\3.0\bin\..\AddIns\AddIns\Misc\SourceAnalysis\Settings.SourceAnalysis"</SourceAnalysisOverrideSettingsFile>
<SignAssembly>True</SignAssembly> <SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>..\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.snk</AssemblyOriginatorKeyFile>
<DelaySign>False</DelaySign> <DelaySign>False</DelaySign>
@ -18,44 +17,54 @@
<NoStdLib>False</NoStdLib> <NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors> <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<OutputPath>..\..\..\..\bin\UnitTests\</OutputPath> <OutputPath>bin\$(Configuration)\</OutputPath>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent> <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<TargetFrameworkProfile> <TargetFrameworkProfile>
</TargetFrameworkProfile> </TargetFrameworkProfile>
<NoWin32Manifest>False</NoWin32Manifest> <NoWin32Manifest>False</NoWin32Manifest>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath> <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'Net35' ">
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'Net40' ">
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<DefineConstants>DOTNET4</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'WithNRefactory' ">
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<DefineConstants>NREFACTORY</DefineConstants>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType> <DebugType>Full</DebugType>
<Optimize>False</Optimize> <Optimize>False</Optimize>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath> <BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
<DefineDebug />
<DefineTrace />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>false</DebugSymbols> <DebugSymbols>false</DebugSymbols>
<DebugType>None</DebugType> <DebugType>None</DebugType>
<Optimize>True</Optimize> <Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants> <BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
</PropertyGroup> <DefineTrace />
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
<Prefer32Bit>False</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup> <ItemGroup>
<Reference Include="ICSharpCode.SharpZipLib"> <ProjectReference Include="..\..\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj" Condition="$(DefineConstants.Contains('NREFACTORY'))">
<HintPath>..\..\..\AddIns\Misc\AddInManager\RequiredLibraries\ICSharpCode.SharpZipLib.dll</HintPath> <Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
</Reference> <Name>ICSharpCode.NRefactory</Name>
</ProjectReference>
<Reference Include="nunit.framework"> <Reference Include="nunit.framework">
<HintPath>..\..\..\Tools\NUnit\nunit.framework.dll</HintPath> <HintPath>..\..\..\Tools\NUnit\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference> </Reference>
<Reference Include="PresentationCore"> <Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework> <RequiredTargetFramework>3.0</RequiredTargetFramework>
@ -103,10 +112,6 @@
<Compile Include="WeakReferenceTests.cs" /> <Compile Include="WeakReferenceTests.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
<Name>ICSharpCode.NRefactory</Name>
</ProjectReference>
<ProjectReference Include="..\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj"> <ProjectReference Include="..\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj">
<Project>{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}</Project> <Project>{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}</Project>
<Name>ICSharpCode.AvalonEdit</Name> <Name>ICSharpCode.AvalonEdit</Name>
@ -115,4 +120,7 @@
<ItemGroup> <ItemGroup>
<Folder Include="Search" /> <Folder Include="Search" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
</Project> </Project>

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/MultipleUIThreads.cs

@ -34,6 +34,7 @@ namespace ICSharpCode.AvalonEdit
try { try {
var window = new Window(); var window = new Window();
window.Content = new TextEditor(); window.Content = new TextEditor();
window.ShowActivated = false;
window.Show(); window.Show();
} catch (Exception ex) { } catch (Exception ex) {
error = ex; error = ex;

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Properties/AssemblyInfo.cs

@ -51,3 +51,5 @@ using NUnit.Framework;
// Run unit tests on STA thread. // Run unit tests on STA thread.
[assembly: RequiresSTA] [assembly: RequiresSTA]
namespace ICSharpCode.NRefactory.Editor {}

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Search/FindTests.cs

@ -19,7 +19,9 @@
using System; using System;
using System.Linq; using System.Linq;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
using NUnit.Framework; using NUnit.Framework;
namespace ICSharpCode.AvalonEdit.Search namespace ICSharpCode.AvalonEdit.Search

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Utils/CaretNavigationTests.cs

@ -19,7 +19,9 @@
using System; using System;
using System.Windows.Documents; using System.Windows.Documents;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
using NUnit.Framework; using NUnit.Framework;
namespace ICSharpCode.AvalonEdit.Utils namespace ICSharpCode.AvalonEdit.Utils

8
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionList.cs

@ -380,11 +380,15 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion
static bool CamelCaseMatch(string text, string query) static bool CamelCaseMatch(string text, string query)
{ {
// We take the first letter of the text regardless of whether or not it's upper case so we match
// against camelCase text as well as PascalCase text ("cct" matches "camelCaseText")
var theFirstLetterOfEachWord = text.Take(1).Concat(text.Skip(1).Where(char.IsUpper));
int i = 0; int i = 0;
foreach (char upper in text.Where(c => char.IsUpper(c))) { foreach (var letter in theFirstLetterOfEachWord) {
if (i > query.Length - 1) if (i > query.Length - 1)
return true; // return true here for CamelCase partial match ("CQ" matches "CodeQualityAnalysis") return true; // return true here for CamelCase partial match ("CQ" matches "CodeQualityAnalysis")
if (char.ToUpper(query[i], CultureInfo.InvariantCulture) != upper) if (char.ToUpperInvariant(query[i]) != char.ToUpperInvariant(letter))
return false; return false;
i++; i++;
} }

4
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/ICompletionData.cs

@ -19,7 +19,11 @@
using System; using System;
using System.Windows.Media; using System.Windows.Media;
using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.AvalonEdit.Editing;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#else
using ICSharpCode.AvalonEdit.Document;
#endif
namespace ICSharpCode.AvalonEdit.CodeCompletion namespace ICSharpCode.AvalonEdit.CodeCompletion
{ {

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/DocumentChangeEventArgs.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
namespace ICSharpCode.AvalonEdit.Document namespace ICSharpCode.AvalonEdit.Document

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/DocumentLine.cs

@ -19,7 +19,9 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
namespace ICSharpCode.AvalonEdit.Document namespace ICSharpCode.AvalonEdit.Document
{ {

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/DocumentTextWriter.cs

@ -19,7 +19,9 @@
using System; using System;
using System.IO; using System.IO;
using System.Text; using System.Text;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
namespace ICSharpCode.AvalonEdit.Document namespace ICSharpCode.AvalonEdit.Document
{ {

343
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/IDocument.cs

@ -0,0 +1,343 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
namespace ICSharpCode.AvalonEdit.Document
{
#if !NREFACTORY
/// <summary>
/// A document representing a source code file for refactoring.
/// Line and column counting starts at 1.
/// Offset counting starts at 0.
/// </summary>
public interface IDocument : ITextSource, IServiceProvider
{
#if NREFACTORY
/// <summary>
/// Creates an immutable snapshot of this document.
/// </summary>
IDocument CreateDocumentSnapshot();
#endif
/// <summary>
/// Gets/Sets the text of the whole document..
/// </summary>
new string Text { get; set; } // hides ITextSource.Text to add the setter
/// <summary>
/// This event is called directly before a change is applied to the document.
/// </summary>
/// <remarks>
/// It is invalid to modify the document within this event handler.
/// Aborting the change (by throwing an exception) is likely to cause corruption of data structures
/// that listen to the Changing and Changed events.
/// </remarks>
event EventHandler<TextChangeEventArgs> TextChanging;
/// <summary>
/// This event is called directly after a change is applied to the document.
/// </summary>
/// <remarks>
/// It is invalid to modify the document within this event handler.
/// Aborting the event handler (by throwing an exception) is likely to cause corruption of data structures
/// that listen to the Changing and Changed events.
/// </remarks>
event EventHandler<TextChangeEventArgs> TextChanged;
/// <summary>
/// This event is called after a group of changes is completed.
/// </summary>
/// <seealso cref="EndUndoableAction"/>
event EventHandler ChangeCompleted;
/// <summary>
/// Gets the number of lines in the document.
/// </summary>
int LineCount { get; }
/// <summary>
/// Gets the document line with the specified number.
/// </summary>
/// <param name="lineNumber">The number of the line to retrieve. The first line has number 1.</param>
IDocumentLine GetLineByNumber(int lineNumber);
/// <summary>
/// Gets the document line that contains the specified offset.
/// </summary>
IDocumentLine GetLineByOffset(int offset);
/// <summary>
/// Gets the offset from a text location.
/// </summary>
/// <seealso cref="GetLocation"/>
int GetOffset(int line, int column);
/// <summary>
/// Gets the offset from a text location.
/// </summary>
/// <seealso cref="GetLocation"/>
int GetOffset(TextLocation location);
/// <summary>
/// Gets the location from an offset.
/// </summary>
/// <seealso cref="GetOffset(TextLocation)"/>
TextLocation GetLocation(int offset);
/// <summary>
/// Inserts text.
/// </summary>
/// <param name="offset">The offset at which the text is inserted.</param>
/// <param name="text">The new text.</param>
/// <remarks>
/// Anchors positioned exactly at the insertion offset will move according to their movement type.
/// For AnchorMovementType.Default, they will move behind the inserted text.
/// The caret will also move behind the inserted text.
/// </remarks>
void Insert(int offset, string text);
/// <summary>
/// Inserts text.
/// </summary>
/// <param name="offset">The offset at which the text is inserted.</param>
/// <param name="text">The new text.</param>
/// <remarks>
/// Anchors positioned exactly at the insertion offset will move according to their movement type.
/// For AnchorMovementType.Default, they will move behind the inserted text.
/// The caret will also move behind the inserted text.
/// </remarks>
void Insert(int offset, ITextSource text);
/// <summary>
/// Inserts text.
/// </summary>
/// <param name="offset">The offset at which the text is inserted.</param>
/// <param name="text">The new text.</param>
/// <param name="defaultAnchorMovementType">
/// Anchors positioned exactly at the insertion offset will move according to the anchor's movement type.
/// For AnchorMovementType.Default, they will move according to the movement type specified by this parameter.
/// The caret will also move according to the <paramref name="defaultAnchorMovementType"/> parameter.
/// </param>
void Insert(int offset, string text, AnchorMovementType defaultAnchorMovementType);
/// <summary>
/// Inserts text.
/// </summary>
/// <param name="offset">The offset at which the text is inserted.</param>
/// <param name="text">The new text.</param>
/// <param name="defaultAnchorMovementType">
/// Anchors positioned exactly at the insertion offset will move according to the anchor's movement type.
/// For AnchorMovementType.Default, they will move according to the movement type specified by this parameter.
/// The caret will also move according to the <paramref name="defaultAnchorMovementType"/> parameter.
/// </param>
void Insert(int offset, ITextSource text, AnchorMovementType defaultAnchorMovementType);
/// <summary>
/// Removes text.
/// </summary>
/// <param name="offset">Starting offset of the text to be removed.</param>
/// <param name="length">Length of the text to be removed.</param>
void Remove(int offset, int length);
/// <summary>
/// Replaces text.
/// </summary>
/// <param name="offset">The starting offset of the text to be replaced.</param>
/// <param name="length">The length of the text to be replaced.</param>
/// <param name="newText">The new text.</param>
void Replace(int offset, int length, string newText);
/// <summary>
/// Replaces text.
/// </summary>
/// <param name="offset">The starting offset of the text to be replaced.</param>
/// <param name="length">The length of the text to be replaced.</param>
/// <param name="newText">The new text.</param>
void Replace(int offset, int length, ITextSource newText);
/// <summary>
/// Make the document combine the following actions into a single
/// action for undo purposes.
/// </summary>
void StartUndoableAction();
/// <summary>
/// Ends the undoable action started with <see cref="StartUndoableAction"/>.
/// </summary>
void EndUndoableAction();
/// <summary>
/// Creates an undo group. Dispose the returned value to close the undo group.
/// </summary>
/// <returns>An object that closes the undo group when Dispose() is called.</returns>
IDisposable OpenUndoGroup();
/// <summary>
/// Creates a new <see cref="ITextAnchor"/> at the specified offset.
/// </summary>
/// <inheritdoc cref="ITextAnchor" select="remarks|example"/>
ITextAnchor CreateAnchor(int offset);
/// <summary>
/// Gets the name of the file the document is stored in.
/// Could also be a non-existent dummy file name or null if no name has been set.
/// </summary>
string FileName { get; }
/// <summary>
/// Fired when the file name of the document changes.
/// </summary>
event EventHandler FileNameChanged;
}
/// <summary>
/// A line inside a <see cref="IDocument"/>.
/// </summary>
public interface IDocumentLine : ISegment
{
/// <summary>
/// Gets the length of this line, including the line delimiter.
/// </summary>
int TotalLength { get; }
/// <summary>
/// Gets the length of the line terminator.
/// Returns 1 or 2; or 0 at the end of the document.
/// </summary>
int DelimiterLength { get; }
/// <summary>
/// Gets the number of this line.
/// The first line has the number 1.
/// </summary>
int LineNumber { get; }
/// <summary>
/// Gets the previous line. Returns null if this is the first line in the document.
/// </summary>
IDocumentLine PreviousLine { get; }
/// <summary>
/// Gets the next line. Returns null if this is the last line in the document.
/// </summary>
IDocumentLine NextLine { get; }
/// <summary>
/// Gets whether the line was deleted.
/// </summary>
bool IsDeleted { get; }
}
/// <summary>
/// Describes a change of the document text.
/// This class is thread-safe.
/// </summary>
[Serializable]
public class TextChangeEventArgs : EventArgs
{
readonly int offset;
readonly ITextSource removedText;
readonly ITextSource insertedText;
/// <summary>
/// The offset at which the change occurs.
/// </summary>
public int Offset {
get { return offset; }
}
/// <summary>
/// The text that was removed.
/// </summary>
public ITextSource RemovedText {
get { return removedText; }
}
/// <summary>
/// The number of characters removed.
/// </summary>
public int RemovalLength {
get { return removedText.TextLength; }
}
/// <summary>
/// The text that was inserted.
/// </summary>
public ITextSource InsertedText {
get { return insertedText; }
}
/// <summary>
/// The number of characters inserted.
/// </summary>
public int InsertionLength {
get { return insertedText.TextLength; }
}
/// <summary>
/// Creates a new TextChangeEventArgs object.
/// </summary>
public TextChangeEventArgs(int offset, string removedText, string insertedText)
{
if (offset < 0)
throw new ArgumentOutOfRangeException("offset", offset, "offset must not be negative");
this.offset = offset;
this.removedText = removedText != null ? new StringTextSource(removedText) : StringTextSource.Empty;
this.insertedText = insertedText != null ? new StringTextSource(insertedText) : StringTextSource.Empty;
}
/// <summary>
/// Creates a new TextChangeEventArgs object.
/// </summary>
public TextChangeEventArgs(int offset, ITextSource removedText, ITextSource insertedText)
{
if (offset < 0)
throw new ArgumentOutOfRangeException("offset", offset, "offset must not be negative");
this.offset = offset;
this.removedText = removedText ?? StringTextSource.Empty;
this.insertedText = insertedText ?? StringTextSource.Empty;
}
/// <summary>
/// Gets the new offset where the specified offset moves after this document change.
/// </summary>
public virtual int GetNewOffset(int offset, AnchorMovementType movementType = AnchorMovementType.Default)
{
if (offset >= this.Offset && offset <= this.Offset + this.RemovalLength) {
if (movementType == AnchorMovementType.BeforeInsertion)
return this.Offset;
else
return this.Offset + this.InsertionLength;
} else if (offset > this.Offset) {
return offset + this.InsertionLength - this.RemovalLength;
} else {
return offset;
}
}
/// <summary>
/// Creates TextChangeEventArgs for the reverse change.
/// </summary>
public virtual TextChangeEventArgs Invert()
{
return new TextChangeEventArgs(offset, insertedText, removedText);
}
}
#endif
}

142
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/ITextAnchor.cs

@ -0,0 +1,142 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using ICSharpCode.NRefactory;
namespace ICSharpCode.AvalonEdit.Document
{
#if !NREFACTORY
/// <summary>
/// The TextAnchor class references an offset (a position between two characters).
/// It automatically updates the offset when text is inserted/removed in front of the anchor.
/// </summary>
/// <remarks>
/// <para>Use the <see cref="ITextAnchor.Offset"/> property to get the offset from a text anchor.
/// Use the <see cref="IDocument.CreateAnchor"/> method to create an anchor from an offset.
/// </para>
/// <para>
/// The document will automatically update all text anchors; and because it uses weak references to do so,
/// the garbage collector can simply collect the anchor object when you don't need it anymore.
/// </para>
/// <para>Moreover, the document is able to efficiently update a large number of anchors without having to look
/// at each anchor object individually. Updating the offsets of all anchors usually only takes time logarithmic
/// to the number of anchors. Retrieving the <see cref="ITextAnchor.Offset"/> property also runs in O(lg N).</para>
/// </remarks>
/// <example>
/// Usage:
/// <code>TextAnchor anchor = document.CreateAnchor(offset);
/// ChangeMyDocument();
/// int newOffset = anchor.Offset;
/// </code>
/// </example>
public interface ITextAnchor
{
/// <summary>
/// Gets the text location of this anchor.
/// </summary>
/// <exception cref="InvalidOperationException">Thrown when trying to get the Offset from a deleted anchor.</exception>
TextLocation Location { get; }
/// <summary>
/// Gets the offset of the text anchor.
/// </summary>
/// <exception cref="InvalidOperationException">Thrown when trying to get the Offset from a deleted anchor.</exception>
int Offset { get; }
/// <summary>
/// Controls how the anchor moves.
/// </summary>
/// <remarks>Anchor movement is ambiguous if text is inserted exactly at the anchor's location.
/// Does the anchor stay before the inserted text, or does it move after it?
/// The property <see cref="MovementType"/> will be used to determine which of these two options the anchor will choose.
/// The default value is <see cref="AnchorMovementType.Default"/>.</remarks>
AnchorMovementType MovementType { get; set; }
/// <summary>
/// <para>
/// Specifies whether the anchor survives deletion of the text containing it.
/// </para><para>
/// <c>false</c>: The anchor is deleted when the a selection that includes the anchor is deleted.
/// <c>true</c>: The anchor is not deleted.
/// </para>
/// </summary>
/// <remarks><inheritdoc cref="IsDeleted" /></remarks>
bool SurviveDeletion { get; set; }
/// <summary>
/// Gets whether the anchor was deleted.
/// </summary>
/// <remarks>
/// <para>When a piece of text containing an anchor is removed, then that anchor will be deleted.
/// First, the <see cref="IsDeleted"/> property is set to true on all deleted anchors,
/// then the <see cref="Deleted"/> events are raised.
/// You cannot retrieve the offset from an anchor that has been deleted.</para>
/// <para>This deletion behavior might be useful when using anchors for building a bookmark feature,
/// but in other cases you want to still be able to use the anchor. For those cases, set <c><see cref="SurviveDeletion"/> = true</c>.</para>
/// </remarks>
bool IsDeleted { get; }
/// <summary>
/// Occurs after the anchor was deleted.
/// </summary>
/// <remarks>
/// <inheritdoc cref="IsDeleted" />
/// <para>Due to the 'weak reference' nature of text anchors, you will receive
/// the Deleted event only while your code holds a reference to the TextAnchor object.
/// </para>
/// </remarks>
event EventHandler Deleted;
/// <summary>
/// Gets the line number of the anchor.
/// </summary>
/// <exception cref="InvalidOperationException">Thrown when trying to get the Offset from a deleted anchor.</exception>
int Line { get; }
/// <summary>
/// Gets the column number of this anchor.
/// </summary>
/// <exception cref="InvalidOperationException">Thrown when trying to get the Offset from a deleted anchor.</exception>
int Column { get; }
}
/// <summary>
/// Defines how a text anchor moves.
/// </summary>
public enum AnchorMovementType
{
/// <summary>
/// When text is inserted at the anchor position, the type of the insertion
/// determines where the caret moves to. For normal insertions, the anchor will move
/// after the inserted text.
/// </summary>
Default,
/// <summary>
/// Behaves like a start marker - when text is inserted at the anchor position, the anchor will stay
/// before the inserted text.
/// </summary>
BeforeInsertion,
/// <summary>
/// Behave like an end marker - when text is insered at the anchor position, the anchor will move
/// after the inserted text.
/// </summary>
AfterInsertion
}
#endif
}

357
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/ITextSource.cs

@ -0,0 +1,357 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
using System;
using System.IO;
namespace ICSharpCode.AvalonEdit.Document
{
#if !NREFACTORY
/// <summary>
/// A read-only view on a (potentially mutable) text source.
/// The IDocument interface derives from this interface.
/// </summary>
public interface ITextSource
{
/// <summary>
/// Gets a version identifier for this text source.
/// Returns null for unversioned text sources.
/// </summary>
ITextSourceVersion Version { get; }
/// <summary>
/// Creates an immutable snapshot of this text source.
/// Unlike all other methods in this interface, this method is thread-safe.
/// </summary>
ITextSource CreateSnapshot();
/// <summary>
/// Creates an immutable snapshot of a part of this text source.
/// Unlike all other methods in this interface, this method is thread-safe.
/// </summary>
ITextSource CreateSnapshot(int offset, int length);
/// <summary>
/// Creates a new TextReader to read from this text source.
/// </summary>
TextReader CreateReader();
/// <summary>
/// Creates a new TextReader to read from this text source.
/// </summary>
TextReader CreateReader(int offset, int length);
/// <summary>
/// Gets the total text length.
/// </summary>
/// <returns>The length of the text, in characters.</returns>
/// <remarks>This is the same as Text.Length, but is more efficient because
/// it doesn't require creating a String object.</remarks>
int TextLength { get; }
/// <summary>
/// Gets the whole text as string.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods")]
string Text { get; }
/// <summary>
/// Gets a character at the specified position in the document.
/// </summary>
/// <paramref name="offset">The index of the character to get.</paramref>
/// <exception cref="ArgumentOutOfRangeException">Offset is outside the valid range (0 to TextLength-1).</exception>
/// <returns>The character at the specified position.</returns>
/// <remarks>This is the same as Text[offset], but is more efficient because
/// it doesn't require creating a String object.</remarks>
char GetCharAt(int offset);
/// <summary>
/// Retrieves the text for a portion of the document.
/// </summary>
/// <exception cref="ArgumentOutOfRangeException">offset or length is outside the valid range.</exception>
/// <remarks>This is the same as Text.Substring, but is more efficient because
/// it doesn't require creating a String object for the whole document.</remarks>
string GetText(int offset, int length);
/// <summary>
/// Retrieves the text for a portion of the document.
/// </summary>
/// <exception cref="ArgumentOutOfRangeException">offset or length is outside the valid range.</exception>
string GetText(ISegment segment);
/// <summary>
/// Writes the text from this document into the TextWriter.
/// </summary>
void WriteTextTo(TextWriter writer);
/// <summary>
/// Writes the text from this document into the TextWriter.
/// </summary>
void WriteTextTo(TextWriter writer, int offset, int length);
/// <summary>
/// Gets the index of the first occurrence of the character in the specified array.
/// </summary>
/// <param name="c">Character to search for</param>
/// <param name="startIndex">Start index of the area to search.</param>
/// <param name="count">Length of the area to search.</param>
/// <returns>The first index where the character was found; or -1 if no occurrence was found.</returns>
int IndexOf(char c, int startIndex, int count);
/// <summary>
/// Gets the index of the first occurrence of any character in the specified array.
/// </summary>
/// <param name="anyOf">Characters to search for</param>
/// <param name="startIndex">Start index of the area to search.</param>
/// <param name="count">Length of the area to search.</param>
/// <returns>The first index where any character was found; or -1 if no occurrence was found.</returns>
int IndexOfAny(char[] anyOf, int startIndex, int count);
/// <summary>
/// Gets the index of the first occurrence of the specified search text in this text source.
/// </summary>
/// <param name="searchText">The search text</param>
/// <param name="startIndex">Start index of the area to search.</param>
/// <param name="count">Length of the area to search.</param>
/// <param name="comparisonType">String comparison to use.</param>
/// <returns>The first index where the search term was found; or -1 if no occurrence was found.</returns>
int IndexOf(string searchText, int startIndex, int count, StringComparison comparisonType);
/// <summary>
/// Gets the index of the last occurrence of the specified character in this text source.
/// </summary>
/// <param name="c">The search character</param>
/// <param name="startIndex">Start index of the area to search.</param>
/// <param name="count">Length of the area to search.</param>
/// <returns>The last index where the search term was found; or -1 if no occurrence was found.</returns>
/// <remarks>The search proceeds backwards from (startIndex+count) to startIndex.
/// This is different than the meaning of the parameters on string.LastIndexOf!</remarks>
int LastIndexOf(char c, int startIndex, int count);
/// <summary>
/// Gets the index of the last occurrence of the specified search text in this text source.
/// </summary>
/// <param name="searchText">The search text</param>
/// <param name="startIndex">Start index of the area to search.</param>
/// <param name="count">Length of the area to search.</param>
/// <param name="comparisonType">String comparison to use.</param>
/// <returns>The last index where the search term was found; or -1 if no occurrence was found.</returns>
/// <remarks>The search proceeds backwards from (startIndex+count) to startIndex.
/// This is different than the meaning of the parameters on string.LastIndexOf!</remarks>
int LastIndexOf(string searchText, int startIndex, int count, StringComparison comparisonType);
/* What about:
void Insert (int offset, string value);
void Remove (int offset, int count);
void Remove (ISegment segment);
void Replace (int offset, int count, string value);
Or more search operations:
IEnumerable<int> SearchForward (string pattern, int startIndex);
IEnumerable<int> SearchForwardIgnoreCase (string pattern, int startIndex);
IEnumerable<int> SearchBackward (string pattern, int startIndex);
IEnumerable<int> SearchBackwardIgnoreCase (string pattern, int startIndex);
*/
}
/// <summary>
/// Represents a version identifier for a text source.
/// </summary>
/// <remarks>
/// Verions can be used to efficiently detect whether a document has changed and needs reparsing;
/// or even to implement incremental parsers.
/// It is a separate class from ITextSource to allow the GC to collect the text source while
/// the version checkpoint is still in use.
/// </remarks>
public interface ITextSourceVersion
{
/// <summary>
/// Gets whether this checkpoint belongs to the same document as the other checkpoint.
/// </summary>
/// <remarks>
/// Returns false when given <c>null</c>.
/// </remarks>
bool BelongsToSameDocumentAs(ITextSourceVersion other);
/// <summary>
/// Compares the age of this checkpoint to the other checkpoint.
/// </summary>
/// <remarks>This method is thread-safe.</remarks>
/// <exception cref="ArgumentException">Raised if 'other' belongs to a different document than this version.</exception>
/// <returns>-1 if this version is older than <paramref name="other"/>.
/// 0 if <c>this</c> version instance represents the same version as <paramref name="other"/>.
/// 1 if this version is newer than <paramref name="other"/>.</returns>
int CompareAge(ITextSourceVersion other);
/// <summary>
/// Gets the changes from this checkpoint to the other checkpoint.
/// If 'other' is older than this checkpoint, reverse changes are calculated.
/// </summary>
/// <remarks>This method is thread-safe.</remarks>
/// <exception cref="ArgumentException">Raised if 'other' belongs to a different document than this checkpoint.</exception>
IEnumerable<TextChangeEventArgs> GetChangesTo(ITextSourceVersion other);
/// <summary>
/// Calculates where the offset has moved in the other buffer version.
/// </summary>
/// <exception cref="ArgumentException">Raised if 'other' belongs to a different document than this checkpoint.</exception>
int MoveOffsetTo(ITextSourceVersion other, int oldOffset, AnchorMovementType movement = AnchorMovementType.Default);
}
/// <summary>
/// Implements the ITextSource interface using a string.
/// </summary>
[Serializable]
public class StringTextSource : ITextSource
{
/// <summary>
/// Gets a text source containing the empty string.
/// </summary>
public static readonly StringTextSource Empty = new StringTextSource(string.Empty);
readonly string text;
readonly ITextSourceVersion version;
/// <summary>
/// Creates a new StringTextSource with the given text.
/// </summary>
public StringTextSource(string text)
{
if (text == null)
throw new ArgumentNullException("text");
this.text = text;
}
/// <summary>
/// Creates a new StringTextSource with the given text.
/// </summary>
public StringTextSource(string text, ITextSourceVersion version)
{
if (text == null)
throw new ArgumentNullException("text");
this.text = text;
this.version = version;
}
/// <inheritdoc/>
public ITextSourceVersion Version {
get { return version; }
}
/// <inheritdoc/>
public int TextLength {
get { return text.Length; }
}
/// <inheritdoc/>
public string Text {
get { return text; }
}
/// <inheritdoc/>
public ITextSource CreateSnapshot()
{
return this; // StringTextSource is immutable
}
/// <inheritdoc/>
public ITextSource CreateSnapshot(int offset, int length)
{
return new StringTextSource(text.Substring(offset, length));
}
/// <inheritdoc/>
public TextReader CreateReader()
{
return new StringReader(text);
}
/// <inheritdoc/>
public TextReader CreateReader(int offset, int length)
{
return new StringReader(text.Substring(offset, length));
}
/// <inheritdoc/>
public void WriteTextTo(TextWriter writer)
{
writer.Write(text);
}
/// <inheritdoc/>
public void WriteTextTo(TextWriter writer, int offset, int length)
{
writer.Write(text.Substring(offset, length));
}
/// <inheritdoc/>
public char GetCharAt(int offset)
{
return text[offset];
}
/// <inheritdoc/>
public string GetText(int offset, int length)
{
return text.Substring(offset, length);
}
/// <inheritdoc/>
public string GetText(ISegment segment)
{
if (segment == null)
throw new ArgumentNullException("segment");
return text.Substring(segment.Offset, segment.Length);
}
/// <inheritdoc/>
public int IndexOf(char c, int startIndex, int count)
{
return text.IndexOf(c, startIndex, count);
}
/// <inheritdoc/>
public int IndexOfAny(char[] anyOf, int startIndex, int count)
{
return text.IndexOfAny(anyOf, startIndex, count);
}
/// <inheritdoc/>
public int IndexOf(string searchText, int startIndex, int count, StringComparison comparisonType)
{
return text.IndexOf(searchText, startIndex, count, comparisonType);
}
/// <inheritdoc/>
public int LastIndexOf(char c, int startIndex, int count)
{
return text.LastIndexOf(c, startIndex + count - 1, count);
}
/// <inheritdoc/>
public int LastIndexOf(string searchText, int startIndex, int count, StringComparison comparisonType)
{
return text.LastIndexOf(searchText, startIndex + count - 1, count, comparisonType);
}
}
#endif
}

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/LineManager.cs

@ -16,7 +16,6 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using ICSharpCode.AvalonEdit.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/NewLineFinder.cs

@ -18,7 +18,9 @@
using System; using System;
using System.Text; using System.Text;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
namespace ICSharpCode.AvalonEdit.Document namespace ICSharpCode.AvalonEdit.Document
{ {

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/OffsetChangeMap.cs

@ -21,7 +21,9 @@ using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
namespace ICSharpCode.AvalonEdit.Document namespace ICSharpCode.AvalonEdit.Document
{ {

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/RopeTextSource.cs

@ -19,7 +19,9 @@
using System; using System;
using System.IO; using System.IO;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
namespace ICSharpCode.AvalonEdit.Document namespace ICSharpCode.AvalonEdit.Document
{ {

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/SimpleSegment.cs

@ -20,7 +20,9 @@ using System;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
namespace ICSharpCode.AvalonEdit.Document namespace ICSharpCode.AvalonEdit.Document
{ {

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextAnchor.cs

@ -20,6 +20,7 @@ using System;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
using ICSharpCode.AvalonEdit.Document;
namespace ICSharpCode.AvalonEdit.Document namespace ICSharpCode.AvalonEdit.Document
{ {

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextAnchorTree.cs

@ -21,7 +21,9 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Text; using System.Text;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
namespace ICSharpCode.AvalonEdit.Document namespace ICSharpCode.AvalonEdit.Document
{ {

5
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs

@ -27,7 +27,6 @@ using System.Threading;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
using ICSharpCode.NRefactory.Utils;
namespace ICSharpCode.AvalonEdit.Document namespace ICSharpCode.AvalonEdit.Document
{ {
@ -133,8 +132,10 @@ namespace ICSharpCode.AvalonEdit.Document
if (textSource == null) if (textSource == null)
throw new ArgumentNullException("textSource"); throw new ArgumentNullException("textSource");
#if NREFACTORY
if (textSource is ReadOnlyDocument) if (textSource is ReadOnlyDocument)
textSource = textSource.CreateSnapshot(); // retrieve underlying text source, which might be a RopeTextSource textSource = textSource.CreateSnapshot(); // retrieve underlying text source, which might be a RopeTextSource
#endif
RopeTextSource rts = textSource as RopeTextSource; RopeTextSource rts = textSource as RopeTextSource;
if (rts != null) if (rts != null)
@ -362,11 +363,13 @@ namespace ICSharpCode.AvalonEdit.Document
} }
} }
#if NREFACTORY
/// <inheritdoc/> /// <inheritdoc/>
public IDocument CreateDocumentSnapshot() public IDocument CreateDocumentSnapshot()
{ {
return new ReadOnlyDocument(this, fileName); return new ReadOnlyDocument(this, fileName);
} }
#endif
/// <inheritdoc/> /// <inheritdoc/>
public ITextSourceVersion Version { public ITextSourceVersion Version {

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocumentWeakEventManager.cs

@ -17,7 +17,9 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
namespace ICSharpCode.AvalonEdit.Document namespace ICSharpCode.AvalonEdit.Document

271
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextLocation.cs

@ -0,0 +1,271 @@
// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.ComponentModel;
using System.Globalization;
namespace ICSharpCode.AvalonEdit.Document
{
#if !NREFACTORY
/// <summary>
/// A line/column position.
/// Text editor lines/columns are counted started from one.
/// </summary>
/// <remarks>
/// The document provides the methods <see cref="IDocument.GetLocation"/> and
/// <see cref="IDocument.GetOffset(TextLocation)"/> to convert between offsets and TextLocations.
/// </remarks>
[Serializable]
[TypeConverter(typeof(TextLocationConverter))]
public struct TextLocation : IComparable<TextLocation>, IEquatable<TextLocation>
{
/// <summary>
/// Represents no text location (0, 0).
/// </summary>
public static readonly TextLocation Empty = new TextLocation(0, 0);
/// <summary>
/// Creates a TextLocation instance.
/// </summary>
public TextLocation(int line, int column)
{
this.line = line;
this.column = column;
}
readonly int column, line;
/// <summary>
/// Gets the line number.
/// </summary>
public int Line {
get { return line; }
}
/// <summary>
/// Gets the column number.
/// </summary>
public int Column {
get { return column; }
}
/// <summary>
/// Gets whether the TextLocation instance is empty.
/// </summary>
public bool IsEmpty {
get {
return column <= 0 && line <= 0;
}
}
/// <summary>
/// Gets a string representation for debugging purposes.
/// </summary>
public override string ToString()
{
return string.Format(CultureInfo.InvariantCulture, "(Line {1}, Col {0})", this.column, this.line);
}
/// <summary>
/// Gets a hash code.
/// </summary>
public override int GetHashCode()
{
return unchecked (191 * column.GetHashCode() ^ line.GetHashCode());
}
/// <summary>
/// Equality test.
/// </summary>
public override bool Equals(object obj)
{
if (!(obj is TextLocation)) return false;
return (TextLocation)obj == this;
}
/// <summary>
/// Equality test.
/// </summary>
public bool Equals(TextLocation other)
{
return this == other;
}
/// <summary>
/// Equality test.
/// </summary>
public static bool operator ==(TextLocation left, TextLocation right)
{
return left.column == right.column && left.line == right.line;
}
/// <summary>
/// Inequality test.
/// </summary>
public static bool operator !=(TextLocation left, TextLocation right)
{
return left.column != right.column || left.line != right.line;
}
/// <summary>
/// Compares two text locations.
/// </summary>
public static bool operator <(TextLocation left, TextLocation right)
{
if (left.line < right.line)
return true;
else if (left.line == right.line)
return left.column < right.column;
else
return false;
}
/// <summary>
/// Compares two text locations.
/// </summary>
public static bool operator >(TextLocation left, TextLocation right)
{
if (left.line > right.line)
return true;
else if (left.line == right.line)
return left.column > right.column;
else
return false;
}
/// <summary>
/// Compares two text locations.
/// </summary>
public static bool operator <=(TextLocation left, TextLocation right)
{
return !(left > right);
}
/// <summary>
/// Compares two text locations.
/// </summary>
public static bool operator >=(TextLocation left, TextLocation right)
{
return !(left < right);
}
/// <summary>
/// Compares two text locations.
/// </summary>
public int CompareTo(TextLocation other)
{
if (this == other)
return 0;
if (this < other)
return -1;
else
return 1;
}
}
/// <summary>
/// Converts strings of the form '0+[;,]0+' to a <see cref="TextLocation"/>.
/// </summary>
public class TextLocationConverter : TypeConverter
{
/// <inheritdoc/>
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
}
/// <inheritdoc/>
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
return destinationType == typeof(TextLocation) || base.CanConvertTo(context, destinationType);
}
/// <inheritdoc/>
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
if (value is string) {
string[] parts = ((string)value).Split(';', ',');
if (parts.Length == 2) {
return new TextLocation(int.Parse(parts[0], culture), int.Parse(parts[1], culture));
}
}
return base.ConvertFrom(context, culture, value);
}
/// <inheritdoc/>
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (value is TextLocation && destinationType == typeof(string)) {
var loc = (TextLocation)value;
return loc.Line.ToString(culture) + ";" + loc.Column.ToString(culture);
}
return base.ConvertTo(context, culture, value, destinationType);
}
}
/// <summary>
/// An (Offset,Length)-pair.
/// </summary>
public interface ISegment
{
/// <summary>
/// Gets the start offset of the segment.
/// </summary>
int Offset { get; }
/// <summary>
/// Gets the length of the segment.
/// </summary>
/// <remarks>For line segments (IDocumentLine), the length does not include the line delimeter.</remarks>
int Length { get; }
/// <summary>
/// Gets the end offset of the segment.
/// </summary>
/// <remarks>EndOffset = Offset + Length;</remarks>
int EndOffset { get; }
}
/// <summary>
/// Extension methods for <see cref="ISegment"/>.
/// </summary>
public static class ISegmentExtensions
{
/// <summary>
/// Gets whether <paramref name="segment"/> fully contains the specified segment.
/// </summary>
/// <remarks>
/// Use <c>segment.Contains(offset, 0)</c> to detect whether a segment (end inclusive) contains offset;
/// use <c>segment.Contains(offset, 1)</c> to detect whether a segment (end exclusive) contains offset.
/// </remarks>
public static bool Contains (this ISegment segment, int offset, int length)
{
return segment.Offset <= offset && offset + length <= segment.EndOffset;
}
/// <summary>
/// Gets whether <paramref name="thisSegment"/> fully contains the specified segment.
/// </summary>
public static bool Contains (this ISegment thisSegment, ISegment segment)
{
return segment != null && thisSegment.Offset <= segment.Offset && segment.EndOffset <= thisSegment.EndOffset;
}
}
#endif
}

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextSegment.cs

@ -18,7 +18,9 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
namespace ICSharpCode.AvalonEdit.Document namespace ICSharpCode.AvalonEdit.Document
{ {

4
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextSegmentCollection.cs

@ -24,7 +24,9 @@ using System.Linq;
using System.Text; using System.Text;
using System.Windows; using System.Windows;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
namespace ICSharpCode.AvalonEdit.Document namespace ICSharpCode.AvalonEdit.Document
{ {
@ -47,7 +49,7 @@ namespace ICSharpCode.AvalonEdit.Document
/// </summary> /// </summary>
/// <remarks><inheritdoc cref="TextSegment"/></remarks> /// <remarks><inheritdoc cref="TextSegment"/></remarks>
/// <see cref="TextSegment"/> /// <see cref="TextSegment"/>
public sealed class TextSegmentCollection<T> : ICollection<T>, IReadOnlyCollection<T>, ISegmentTree, IWeakEventListener where T : TextSegment public sealed class TextSegmentCollection<T> : ICollection<T>, ISegmentTree, IWeakEventListener where T : TextSegment
{ {
// Implementation: this is basically a mixture of an augmented interval tree // Implementation: this is basically a mixture of an augmented interval tree
// and the TextAnchorTree. // and the TextAnchorTree.

136
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextSourceVersionProvider.cs

@ -0,0 +1,136 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using ICSharpCode.AvalonEdit.Utils;
namespace ICSharpCode.AvalonEdit.Document
{
#if !NREFACTORY
/// <summary>
/// Provides ITextSourceVersion instances.
/// </summary>
public class TextSourceVersionProvider
{
Version currentVersion;
/// <summary>
/// Creates a new TextSourceVersionProvider instance.
/// </summary>
public TextSourceVersionProvider()
{
this.currentVersion = new Version(this);
}
/// <summary>
/// Gets the current version.
/// </summary>
public ITextSourceVersion CurrentVersion {
get { return currentVersion; }
}
/// <summary>
/// Replaces the current version with a new version.
/// </summary>
/// <param name="change">Change from current version to new version</param>
public void AppendChange(TextChangeEventArgs change)
{
if (change == null)
throw new ArgumentNullException("change");
currentVersion.change = change;
currentVersion.next = new Version(currentVersion);
currentVersion = currentVersion.next;
}
[DebuggerDisplay("Version #{id}")]
sealed class Version : ITextSourceVersion
{
// Reference back to the provider.
// Used to determine if two checkpoints belong to the same document.
readonly TextSourceVersionProvider provider;
// ID used for CompareAge()
readonly int id;
// the change from this version to the next version
internal TextChangeEventArgs change;
internal Version next;
internal Version(TextSourceVersionProvider provider)
{
this.provider = provider;
}
internal Version(Version prev)
{
this.provider = prev.provider;
this.id = unchecked( prev.id + 1 );
}
public bool BelongsToSameDocumentAs(ITextSourceVersion other)
{
Version o = other as Version;
return o != null && provider == o.provider;
}
public int CompareAge(ITextSourceVersion other)
{
if (other == null)
throw new ArgumentNullException("other");
Version o = other as Version;
if (o == null || provider != o.provider)
throw new ArgumentException("Versions do not belong to the same document.");
// We will allow overflows, but assume that the maximum distance between checkpoints is 2^31-1.
// This is guaranteed on x86 because so many checkpoints don't fit into memory.
return Math.Sign(unchecked( this.id - o.id ));
}
public IEnumerable<TextChangeEventArgs> GetChangesTo(ITextSourceVersion other)
{
int result = CompareAge(other);
Version o = (Version)other;
if (result < 0)
return GetForwardChanges(o);
else if (result > 0)
return o.GetForwardChanges(this).Reverse().Select(change => change.Invert());
else
return Empty<TextChangeEventArgs>.Array;
}
IEnumerable<TextChangeEventArgs> GetForwardChanges(Version other)
{
// Return changes from this(inclusive) to other(exclusive).
for (Version node = this; node != other; node = node.next) {
yield return node.change;
}
}
public int MoveOffsetTo(ITextSourceVersion other, int oldOffset, AnchorMovementType movement)
{
int offset = oldOffset;
foreach (var e in GetChangesTo(other)) {
offset = e.GetNewOffset(offset, movement);
}
return offset;
}
}
}
#endif
}

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextUtilities.cs

@ -19,7 +19,9 @@
using System; using System;
using System.Globalization; using System.Globalization;
using System.Windows.Documents; using System.Windows.Documents;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
namespace ICSharpCode.AvalonEdit.Document namespace ICSharpCode.AvalonEdit.Document
{ {

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Caret.cs

@ -27,8 +27,10 @@ using System.Windows.Threading;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Rendering; using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
#if NREFACTORY
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
namespace ICSharpCode.AvalonEdit.Editing namespace ICSharpCode.AvalonEdit.Editing
{ {

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs

@ -29,7 +29,9 @@ using System.Windows.Input;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Highlighting; using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
namespace ICSharpCode.AvalonEdit.Editing namespace ICSharpCode.AvalonEdit.Editing
{ {

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/EmptySelection.cs

@ -22,8 +22,10 @@ using System.Runtime.CompilerServices;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
#if NREFACTORY
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
namespace ICSharpCode.AvalonEdit.Editing namespace ICSharpCode.AvalonEdit.Editing
{ {

4
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/IReadOnlySectionProvider.cs

@ -18,7 +18,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#else
using ICSharpCode.AvalonEdit.Document;
#endif
namespace ICSharpCode.AvalonEdit.Editing namespace ICSharpCode.AvalonEdit.Editing
{ {

7
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/NoReadOnlySections.cs

@ -19,8 +19,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
using ICSharpCode.AvalonEdit.Utils;
namespace ICSharpCode.AvalonEdit.Editing namespace ICSharpCode.AvalonEdit.Editing
{ {
@ -48,9 +49,9 @@ namespace ICSharpCode.AvalonEdit.Editing
/// <summary> /// <summary>
/// <see cref="IReadOnlySectionProvider"/> that completely disables editing. /// <see cref="IReadOnlySectionProvider"/> that completely disables editing.
/// </summary> /// </summary>
sealed class ReadOnlyDocument : IReadOnlySectionProvider sealed class ReadOnlySectionDocument : IReadOnlySectionProvider
{ {
public static readonly ReadOnlyDocument Instance = new ReadOnlyDocument(); public static readonly ReadOnlySectionDocument Instance = new ReadOnlySectionDocument();
public bool CanInsert(int offset) public bool CanInsert(int offset)
{ {

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/RectangleSelection.cs

@ -28,8 +28,10 @@ using System.Windows.Media.TextFormatting;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Rendering; using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
#if NREFACTORY
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
namespace ICSharpCode.AvalonEdit.Editing namespace ICSharpCode.AvalonEdit.Editing
{ {

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Selection.cs

@ -24,7 +24,9 @@ using System.Windows;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Highlighting; using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
namespace ICSharpCode.AvalonEdit.Editing namespace ICSharpCode.AvalonEdit.Editing
{ {

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/SelectionColorizer.cs

@ -18,7 +18,9 @@
using System; using System;
using ICSharpCode.AvalonEdit.Rendering; using ICSharpCode.AvalonEdit.Rendering;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
namespace ICSharpCode.AvalonEdit.Editing namespace ICSharpCode.AvalonEdit.Editing
{ {

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/SelectionMouseHandler.cs

@ -29,7 +29,9 @@ using System.Windows.Threading;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Rendering; using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
namespace ICSharpCode.AvalonEdit.Editing namespace ICSharpCode.AvalonEdit.Editing
{ {

4
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/SelectionSegment.cs

@ -17,7 +17,11 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#else
using ICSharpCode.AvalonEdit.Document;
#endif
namespace ICSharpCode.AvalonEdit.Editing namespace ICSharpCode.AvalonEdit.Editing
{ {

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/SimpleSelection.cs

@ -20,7 +20,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
namespace ICSharpCode.AvalonEdit.Editing namespace ICSharpCode.AvalonEdit.Editing
{ {

3
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/TextArea.cs

@ -35,7 +35,6 @@ using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
using ICSharpCode.NRefactory.Utils;
namespace ICSharpCode.AvalonEdit.Editing namespace ICSharpCode.AvalonEdit.Editing
{ {
@ -1023,9 +1022,11 @@ namespace ICSharpCode.AvalonEdit.Editing
this.MouseEnter += delegate { ShowMouseCursor(); }; this.MouseEnter += delegate { ShowMouseCursor(); };
this.MouseLeave += delegate { ShowMouseCursor(); }; this.MouseLeave += delegate { ShowMouseCursor(); };
this.PreviewMouseMove += delegate { ShowMouseCursor(); }; this.PreviewMouseMove += delegate { ShowMouseCursor(); };
#if DOTNET4
this.TouchEnter += delegate { ShowMouseCursor(); }; this.TouchEnter += delegate { ShowMouseCursor(); };
this.TouchLeave += delegate { ShowMouseCursor(); }; this.TouchLeave += delegate { ShowMouseCursor(); };
this.PreviewTouchMove += delegate { ShowMouseCursor(); }; this.PreviewTouchMove += delegate { ShowMouseCursor(); };
#endif
} }
void ShowMouseCursor() void ShowMouseCursor()

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/TextSegmentReadOnlySectionProvider.cs

@ -19,7 +19,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
namespace ICSharpCode.AvalonEdit.Editing namespace ICSharpCode.AvalonEdit.Editing
{ {

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingSection.cs

@ -19,7 +19,9 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Text; using System.Text;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#endif
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Rendering; using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;

4
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/NewFolding.cs

@ -17,7 +17,11 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#else
using ICSharpCode.AvalonEdit.Document;
#endif
namespace ICSharpCode.AvalonEdit.Folding namespace ICSharpCode.AvalonEdit.Folding
{ {

8
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/DocumentHighlighter.cs

@ -20,12 +20,10 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using ICSharpCode.NRefactory.Editor;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.NRefactory.Editor; using SpanStack = ICSharpCode.AvalonEdit.Utils.ImmutableStack<ICSharpCode.AvalonEdit.Highlighting.HighlightingSpan>;
using ICSharpCode.NRefactory.Utils;
using SpanStack = ICSharpCode.NRefactory.Utils.ImmutableStack<ICSharpCode.AvalonEdit.Highlighting.HighlightingSpan>;
namespace ICSharpCode.AvalonEdit.Highlighting namespace ICSharpCode.AvalonEdit.Highlighting
{ {
@ -74,6 +72,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting
InvalidateHighlighting(); InvalidateHighlighting();
} }
#if NREFACTORY
/// <summary> /// <summary>
/// Creates a new DocumentHighlighter instance. /// Creates a new DocumentHighlighter instance.
/// </summary> /// </summary>
@ -88,6 +87,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting
this.engine = new HighlightingEngine(definition.MainRuleSet); this.engine = new HighlightingEngine(definition.MainRuleSet);
InvalidateHighlighting(); InvalidateHighlighting();
} }
#endif
/// <summary> /// <summary>
/// Disposes the document highlighter. /// Disposes the document highlighter.

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightedInlineBuilder.cs

@ -24,7 +24,7 @@ using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Media; using System.Windows.Media;
using ICSharpCode.NRefactory.TypeSystem.Implementation; using ICSharpCode.AvalonEdit.Utils;
namespace ICSharpCode.AvalonEdit.Highlighting namespace ICSharpCode.AvalonEdit.Highlighting
{ {

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightedLine.cs

@ -18,7 +18,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;

4
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightedSection.cs

@ -17,7 +17,11 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#else
using ICSharpCode.AvalonEdit.Document;
#endif
namespace ICSharpCode.AvalonEdit.Highlighting namespace ICSharpCode.AvalonEdit.Highlighting
{ {

3
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColor.cs

@ -23,8 +23,7 @@ using System.Security.Permissions;
using System.Text; using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Media; using System.Windows.Media;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.NRefactory.TypeSystem.Implementation;
namespace ICSharpCode.AvalonEdit.Highlighting namespace ICSharpCode.AvalonEdit.Highlighting
{ {

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColorizer.cs

@ -289,7 +289,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting
// If the highlighting state change applies to the lines below, too, the construction of each line // If the highlighting state change applies to the lines below, too, the construction of each line
// will invalidate the next line, and the construction pass will regenerate all lines. // will invalidate the next line, and the construction pass will regenerate all lines.
Debug.WriteLine("OnHighlightStateChanged forces redraw of lines {0} to {1}", fromLineNumber, toLineNumber); Debug.WriteLine(string.Format("OnHighlightStateChanged forces redraw of lines {0} to {1}", fromLineNumber, toLineNumber));
// If the VisualLine construction is in progress, we have to avoid sending redraw commands for // If the VisualLine construction is in progress, we have to avoid sending redraw commands for
// anything above the line currently being constructed. // anything above the line currently being constructed.

6
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingEngine.cs

@ -21,9 +21,13 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#else
using ICSharpCode.AvalonEdit.Document;
#endif
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
using SpanStack = ICSharpCode.NRefactory.Utils.ImmutableStack<ICSharpCode.AvalonEdit.Highlighting.HighlightingSpan>; using SpanStack = ICSharpCode.AvalonEdit.Utils.ImmutableStack<ICSharpCode.AvalonEdit.Highlighting.HighlightingSpan>;
namespace ICSharpCode.AvalonEdit.Highlighting namespace ICSharpCode.AvalonEdit.Highlighting
{ {

3
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingManager.cs

@ -22,8 +22,7 @@ using System.Collections.ObjectModel;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Xml; using System.Xml;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.NRefactory.Utils;
namespace ICSharpCode.AvalonEdit.Highlighting namespace ICSharpCode.AvalonEdit.Highlighting
{ {

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HtmlClipboard.cs

@ -19,7 +19,6 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.IO;
using System.Text; using System.Text;
using System.Windows; using System.Windows;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;

8
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HtmlOptions.cs

@ -18,7 +18,11 @@
using System; using System;
using System.IO; using System.IO;
#if DOTNET4
using System.Net; using System.Net;
#else
using System.Web;
#endif
namespace ICSharpCode.AvalonEdit.Highlighting namespace ICSharpCode.AvalonEdit.Highlighting
{ {
@ -60,7 +64,11 @@ namespace ICSharpCode.AvalonEdit.Highlighting
if (color == null) if (color == null)
throw new ArgumentNullException("color"); throw new ArgumentNullException("color");
writer.Write(" style=\""); writer.Write(" style=\"");
#if DOTNET4
WebUtility.HtmlEncode(color.ToCss(), writer); WebUtility.HtmlEncode(color.ToCss(), writer);
#else
HttpUtility.HtmlEncode(color.ToCss(), writer);
#endif
writer.Write('"'); writer.Write('"');
} }

19
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HtmlRichTextWriter.cs

@ -19,7 +19,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
#if DOTNET4
using System.Net; using System.Net;
#else
using System.Web;
#endif
using System.Text; using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Media; using System.Windows.Media;
@ -132,7 +136,11 @@ namespace ICSharpCode.AvalonEdit.Highlighting
needIndentation = true; needIndentation = true;
break; break;
default: default:
#if DOTNET4
WebUtility.HtmlEncode(c.ToString(), htmlWriter); WebUtility.HtmlEncode(c.ToString(), htmlWriter);
#else
HttpUtility.HtmlEncode(c.ToString(), htmlWriter);
#endif
break; break;
} }
// If we just handled a space by setting hasSpace = true, // If we just handled a space by setting hasSpace = true,
@ -173,7 +181,11 @@ namespace ICSharpCode.AvalonEdit.Highlighting
if (value.Length == 0) if (value.Length == 0)
return; return;
WriteIndentationAndSpace(); WriteIndentationAndSpace();
#if DOTNET4
WebUtility.HtmlEncode(value, htmlWriter); WebUtility.HtmlEncode(value, htmlWriter);
#else
HttpUtility.HtmlEncode(value, htmlWriter);
#endif
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -244,7 +256,12 @@ namespace ICSharpCode.AvalonEdit.Highlighting
public override void BeginHyperlinkSpan(Uri uri) public override void BeginHyperlinkSpan(Uri uri)
{ {
WriteIndentationAndSpace(); WriteIndentationAndSpace();
htmlWriter.Write("<a href=\"" + WebUtility.HtmlEncode(uri.ToString()) + "\">"); #if DOTNET4
string link = WebUtility.HtmlEncode(uri.ToString());
#else
string link = HttpUtility.HtmlEncode(uri.ToString());
#endif
htmlWriter.Write("<a href=\"" + link + "\">");
endTagStack.Push("</a>"); endTagStack.Push("</a>");
} }
} }

4
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/IHighlighter.cs

@ -18,7 +18,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
#if NREFACTORY
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
#else
using ICSharpCode.AvalonEdit.Document;
#endif
namespace ICSharpCode.AvalonEdit.Highlighting namespace ICSharpCode.AvalonEdit.Highlighting
{ {

8
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/RichTextModel.cs

@ -17,24 +17,20 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Media;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.NRefactory.TypeSystem.Implementation;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.NRefactory.Editor;
namespace ICSharpCode.AvalonEdit.Highlighting namespace ICSharpCode.AvalonEdit.Highlighting
{ {
/// <summary> /// <summary>
/// Stores rich-text formatting. /// Stores rich-text formatting.
/// </summary> /// </summary>
public sealed class RichTextModel : AbstractFreezable public sealed class RichTextModel
{ {
List<int> stateChangeOffsets = new List<int>(); List<int> stateChangeOffsets = new List<int>();
List<HighlightingColor> stateChanges = new List<HighlightingColor>(); List<HighlightingColor> stateChanges = new List<HighlightingColor>();

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/RichTextModelWriter.cs

@ -18,8 +18,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Windows; using System.Windows;
using System.Windows.Media; using System.Windows.Media;
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;

108
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj

@ -3,52 +3,72 @@
<PropertyGroup> <PropertyGroup>
<ProjectGuid>{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}</ProjectGuid> <ProjectGuid>{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">Net40</Platform>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.AvalonEdit</RootNamespace> <RootNamespace>ICSharpCode.AvalonEdit</RootNamespace>
<AssemblyName>ICSharpCode.AvalonEdit</AssemblyName> <AssemblyName>ICSharpCode.AvalonEdit</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<SourceAnalysisOverrideSettingsFile>"C:\Program Files\SharpDevelop\3.0\bin\..\AddIns\AddIns\Misc\SourceAnalysis\Settings.SourceAnalysis"</SourceAnalysisOverrideSettingsFile>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib> <NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<SignAssembly>True</SignAssembly> <SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>ICSharpCode.AvalonEdit.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>ICSharpCode.AvalonEdit.snk</AssemblyOriginatorKeyFile>
<DelaySign>False</DelaySign> <DelaySign>False</DelaySign>
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode> <AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
<RunCodeAnalysis>False</RunCodeAnalysis> <RunCodeAnalysis>False</RunCodeAnalysis>
<CodeAnalysisRules>-Microsoft.Design#CA1020;-Microsoft.Design#CA1033;-Microsoft.Performance#CA1805;-Microsoft.Performance#CA1810</CodeAnalysisRules> <CodeAnalysisRules>-Microsoft.Design#CA1020;-Microsoft.Design#CA1033;-Microsoft.Performance#CA1805;-Microsoft.Performance#CA1810</CodeAnalysisRules>
<OutputPath>..\..\..\..\bin\</OutputPath>
<DocumentationFile>..\..\..\..\bin\ICSharpCode.AvalonEdit.xml</DocumentationFile>
<NoWarn>1607</NoWarn> <NoWarn>1607</NoWarn>
<TargetFrameworkProfile> <TargetFrameworkProfile>
</TargetFrameworkProfile> </TargetFrameworkProfile>
<NoWin32Manifest>False</NoWin32Manifest>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'Net35' ">
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'Net40' ">
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<DefineConstants>DOTNET4</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'WithNRefactory' ">
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<DefineConstants>DOTNET4;NREFACTORY</DefineConstants>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
<DocumentationFile>bin\Debug\ICSharpCode.AvalonEdit.xml</DocumentationFile>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<Optimize>False</Optimize> <Optimize>False</Optimize>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE;DOTNET4</DefineConstants> <BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
<DebugType>Full</DebugType>
<DefineDebug/>
<DefineTrace/>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<DocumentationFile>bin\Release\ICSharpCode.AvalonEdit.xml</DocumentationFile>
<DebugSymbols>false</DebugSymbols> <DebugSymbols>false</DebugSymbols>
<DebugType>PdbOnly</DebugType>
<Optimize>True</Optimize> <Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE;DOTNET4</DefineConstants> <DebugType>Full</DebugType>
</PropertyGroup> <DefineTrace/>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup> </PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj" Condition="$(DefineConstants.Contains('NREFACTORY'))">
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
<Name>ICSharpCode.NRefactory</Name>
</ProjectReference>
<Reference Include="Microsoft.CSharp">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="PresentationCore"> <Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework> <RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference> </Reference>
@ -67,6 +87,7 @@
<Reference Include="System.Printing"> <Reference Include="System.Printing">
<RequiredTargetFramework>3.0</RequiredTargetFramework> <RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="System.Web" Condition="!$(DefineConstants.Contains('DOTNET4'))" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml"> <Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework> <RequiredTargetFramework>4.0</RequiredTargetFramework>
@ -86,9 +107,6 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="..\..\..\Main\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="AvalonEditCommands.cs" /> <Compile Include="AvalonEditCommands.cs" />
<Compile Include="CodeCompletion\CompletionListBox.cs" /> <Compile Include="CodeCompletion\CompletionListBox.cs" />
<Compile Include="CodeCompletion\CompletionWindowBase.cs" /> <Compile Include="CodeCompletion\CompletionWindowBase.cs" />
@ -97,7 +115,6 @@
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="CodeCompletion\ICompletionData.cs" /> <Compile Include="CodeCompletion\ICompletionData.cs" />
<Compile Include="CodeCompletion\Images\CompletionImage.cs" />
<Compile Include="CodeCompletion\InsightWindow.cs" /> <Compile Include="CodeCompletion\InsightWindow.cs" />
<Compile Include="CodeCompletion\IOverloadProvider.cs" /> <Compile Include="CodeCompletion\IOverloadProvider.cs" />
<Compile Include="CodeCompletion\OverloadInsightWindow.cs" /> <Compile Include="CodeCompletion\OverloadInsightWindow.cs" />
@ -106,7 +123,10 @@
<DependentUpon>UndoStack.cs</DependentUpon> <DependentUpon>UndoStack.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Document\DocumentTextWriter.cs" /> <Compile Include="Document\DocumentTextWriter.cs" />
<Compile Include="Document\IDocument.cs" />
<Compile Include="Document\ILineTracker.cs" /> <Compile Include="Document\ILineTracker.cs" />
<Compile Include="Document\ITextAnchor.cs" />
<Compile Include="Document\ITextSource.cs" />
<Compile Include="Document\SimpleSegment.cs" /> <Compile Include="Document\SimpleSegment.cs" />
<Compile Include="Document\RopeTextSource.cs" /> <Compile Include="Document\RopeTextSource.cs" />
<Compile Include="Document\IUndoableOperation.cs"> <Compile Include="Document\IUndoableOperation.cs">
@ -120,6 +140,7 @@
<Compile Include="Document\TextDocumentWeakEventManager.cs"> <Compile Include="Document\TextDocumentWeakEventManager.cs">
<DependentUpon>TextDocument.cs</DependentUpon> <DependentUpon>TextDocument.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Document\TextLocation.cs" />
<Compile Include="Document\TextSegmentCollection.cs" /> <Compile Include="Document\TextSegmentCollection.cs" />
<Compile Include="Document\TextAnchor.cs" /> <Compile Include="Document\TextAnchor.cs" />
<Compile Include="Document\TextAnchorNode.cs"> <Compile Include="Document\TextAnchorNode.cs">
@ -129,6 +150,7 @@
<DependentUpon>TextAnchor.cs</DependentUpon> <DependentUpon>TextAnchor.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Document\TextSegment.cs" /> <Compile Include="Document\TextSegment.cs" />
<Compile Include="Document\TextSourceVersionProvider.cs" />
<Compile Include="Document\TextUtilities.cs" /> <Compile Include="Document\TextUtilities.cs" />
<Compile Include="Document\UndoOperationGroup.cs"> <Compile Include="Document\UndoOperationGroup.cs">
<DependentUpon>UndoStack.cs</DependentUpon> <DependentUpon>UndoStack.cs</DependentUpon>
@ -355,6 +377,7 @@
</Compile> </Compile>
<Compile Include="TextViewPosition.cs" /> <Compile Include="TextViewPosition.cs" />
<Compile Include="Utils\Boxes.cs" /> <Compile Include="Utils\Boxes.cs" />
<Compile Include="Utils\CallbackOnDispose.cs" />
<Compile Include="Utils\CharRope.cs" /> <Compile Include="Utils\CharRope.cs" />
<Compile Include="Utils\CompressingTreeList.cs" /> <Compile Include="Utils\CompressingTreeList.cs" />
<Compile Include="Utils\Constants.cs" /> <Compile Include="Utils\Constants.cs" />
@ -364,6 +387,8 @@
<Compile Include="Utils\Empty.cs" /> <Compile Include="Utils\Empty.cs" />
<Compile Include="Utils\ExtensionMethods.cs" /> <Compile Include="Utils\ExtensionMethods.cs" />
<Compile Include="Utils\FileReader.cs" /> <Compile Include="Utils\FileReader.cs" />
<Compile Include="Utils\IFreezable.cs" />
<Compile Include="Utils\ImmutableStack.cs" />
<Compile Include="Utils\NullSafeCollection.cs" /> <Compile Include="Utils\NullSafeCollection.cs" />
<Compile Include="Utils\ObserveAddRemoveCollection.cs" /> <Compile Include="Utils\ObserveAddRemoveCollection.cs" />
<Compile Include="Utils\PlainRichTextWriter.cs" /> <Compile Include="Utils\PlainRichTextWriter.cs" />
@ -412,51 +437,10 @@
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Highlighting\Resources\CSS-Mode.xshd" /> <EmbeddedResource Include="Highlighting\Resources\CSS-Mode.xshd" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Main\Core\Project\ICSharpCode.Core.csproj">
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project>
<Name>ICSharpCode.Core</Name>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
<Name>ICSharpCode.NRefactory</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup> <ItemGroup>
<Resource Include="Search\next.png" /> <Resource Include="Search\next.png" />
<Resource Include="Search\prev.png" /> <Resource Include="Search\prev.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="CodeCompletion\Images" />
</ItemGroup>
<ItemGroup>
<Resource Include="CodeCompletion\Images\Class.png" />
<Resource Include="CodeCompletion\Images\Constructor.png" />
<Resource Include="CodeCompletion\Images\Delegate.png" />
<Resource Include="CodeCompletion\Images\Enum.png" />
<Resource Include="CodeCompletion\Images\EnumValue.png" />
<Resource Include="CodeCompletion\Images\Event.png" />
<Resource Include="CodeCompletion\Images\ExtensionMethod.png" />
<Resource Include="CodeCompletion\Images\Field.png" />
<Resource Include="CodeCompletion\Images\FieldReadOnly.png" />
<Resource Include="CodeCompletion\Images\Indexer.png" />
<Resource Include="CodeCompletion\Images\Interface.png" />
<Resource Include="CodeCompletion\Images\Literal.png" />
<Resource Include="CodeCompletion\Images\Method.png" />
<Resource Include="CodeCompletion\Images\NameSpace.png" />
<Resource Include="CodeCompletion\Images\Operator.png" />
<Resource Include="CodeCompletion\Images\OverlayInternal.png" />
<Resource Include="CodeCompletion\Images\OverlayPrivate.png" />
<Resource Include="CodeCompletion\Images\OverlayProtected.png" />
<Resource Include="CodeCompletion\Images\OverlayProtectedInternal.png" />
<Resource Include="CodeCompletion\Images\OverlayStatic.png" />
<Resource Include="CodeCompletion\Images\PInvokeMethod.png" />
<Resource Include="CodeCompletion\Images\Property.png" />
<Resource Include="CodeCompletion\Images\StaticClass.png" />
<Resource Include="CodeCompletion\Images\Struct.png" />
<Resource Include="CodeCompletion\Images\VirtualMethod.png" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Highlighting\Resources\PowerShell.xshd" /> <EmbeddedResource Include="Highlighting\Resources\PowerShell.xshd" />
</ItemGroup> </ItemGroup>

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Indentation/DefaultIndentationStrategy.cs

@ -17,8 +17,8 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
using ICSharpCode.AvalonEdit.Document;
namespace ICSharpCode.AvalonEdit.Indentation namespace ICSharpCode.AvalonEdit.Indentation
{ {

12
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Properties/AssemblyInfo.cs

@ -50,6 +50,13 @@ using System.Windows.Markup;
// app, or any theme specific resource dictionaries) // app, or any theme specific resource dictionaries)
)] )]
[assembly: System.Runtime.InteropServices.ComVisible(false)]
[assembly: AssemblyCompany("ic#code")]
[assembly: AssemblyProduct("SharpDevelop")]
[assembly: AssemblyCopyright("2000-2014 AlphaSierraPapa for the SharpDevelop Team")]
[assembly: AssemblyVersion("5.0.1")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: XmlnsPrefix("http://icsharpcode.net/sharpdevelop/avalonedit", "avalonedit")] [assembly: XmlnsPrefix("http://icsharpcode.net/sharpdevelop/avalonedit", "avalonedit")]
[assembly: XmlnsDefinition("http://icsharpcode.net/sharpdevelop/avalonedit", "ICSharpCode.AvalonEdit")] [assembly: XmlnsDefinition("http://icsharpcode.net/sharpdevelop/avalonedit", "ICSharpCode.AvalonEdit")]
@ -57,3 +64,8 @@ using System.Windows.Markup;
[assembly: XmlnsDefinition("http://icsharpcode.net/sharpdevelop/avalonedit", "ICSharpCode.AvalonEdit.Rendering")] [assembly: XmlnsDefinition("http://icsharpcode.net/sharpdevelop/avalonedit", "ICSharpCode.AvalonEdit.Rendering")]
[assembly: XmlnsDefinition("http://icsharpcode.net/sharpdevelop/avalonedit", "ICSharpCode.AvalonEdit.Highlighting")] [assembly: XmlnsDefinition("http://icsharpcode.net/sharpdevelop/avalonedit", "ICSharpCode.AvalonEdit.Highlighting")]
[assembly: XmlnsDefinition("http://icsharpcode.net/sharpdevelop/avalonedit", "ICSharpCode.AvalonEdit.Search")] [assembly: XmlnsDefinition("http://icsharpcode.net/sharpdevelop/avalonedit", "ICSharpCode.AvalonEdit.Search")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2243:AttributeStringLiteralsShouldParseCorrectly",
Justification = "AssemblyInformationalVersion does not need to be a parsable version")]
namespace ICSharpCode.NRefactory.Editor {}

3
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/BackgroundGeometryBuilder.cs

@ -23,9 +23,10 @@ using System.Windows;
using System.Windows.Controls.Primitives; using System.Windows.Controls.Primitives;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.TextFormatting; using System.Windows.Media.TextFormatting;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.NRefactory.Editor;
namespace ICSharpCode.AvalonEdit.Rendering namespace ICSharpCode.AvalonEdit.Rendering
{ {

3
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs

@ -31,10 +31,9 @@ using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.TextFormatting; using System.Windows.Media.TextFormatting;
using System.Windows.Threading; using System.Windows.Threading;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.NRefactory.Editor;
namespace ICSharpCode.AvalonEdit.Rendering namespace ICSharpCode.AvalonEdit.Rendering
{ {

28
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/DropDownButton.cs

@ -18,26 +18,33 @@
using System; using System;
using System.Windows; using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives; using System.Windows.Controls.Primitives;
using System.Windows.Input;
namespace ICSharpCode.AvalonEdit.Search namespace ICSharpCode.AvalonEdit.Search
{ {
/// <summary> /// <summary>
/// A button that opens a drop-down menu when clicked. /// A button that opens a drop-down menu when clicked.
/// </summary> /// </summary>
class DropDownButton : ButtonBase public class DropDownButton : ButtonBase
{ {
/// <summary>
/// Identifies the <see cref="DropDownContentProperty" /> dependency property.
/// </summary>
public static readonly DependencyProperty DropDownContentProperty public static readonly DependencyProperty DropDownContentProperty
= DependencyProperty.Register("DropDownContent", typeof(Popup), = DependencyProperty.Register("DropDownContent", typeof(Popup),
typeof(DropDownButton), new FrameworkPropertyMetadata(null)); typeof(DropDownButton), new FrameworkPropertyMetadata(null));
/// <summary>
/// The key that identifies the <see cref="IsDropDownContentOpenProperty" /> dependency property.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
protected static readonly DependencyPropertyKey IsDropDownContentOpenPropertyKey protected static readonly DependencyPropertyKey IsDropDownContentOpenPropertyKey
= DependencyProperty.RegisterReadOnly("IsDropDownContentOpen", typeof(bool), = DependencyProperty.RegisterReadOnly("IsDropDownContentOpen", typeof(bool),
typeof(DropDownButton), new FrameworkPropertyMetadata(false)); typeof(DropDownButton), new FrameworkPropertyMetadata(false));
/// <summary>
/// Identifies the <see cref="IsDropDownContentOpenProperty" /> dependency property.
/// </summary>
public static readonly DependencyProperty IsDropDownContentOpenProperty = IsDropDownContentOpenPropertyKey.DependencyProperty; public static readonly DependencyProperty IsDropDownContentOpenProperty = IsDropDownContentOpenPropertyKey.DependencyProperty;
static DropDownButton() static DropDownButton()
@ -45,16 +52,23 @@ namespace ICSharpCode.AvalonEdit.Search
DefaultStyleKeyProperty.OverrideMetadata(typeof(DropDownButton), new FrameworkPropertyMetadata(typeof(DropDownButton))); DefaultStyleKeyProperty.OverrideMetadata(typeof(DropDownButton), new FrameworkPropertyMetadata(typeof(DropDownButton)));
} }
/// <summary>
/// Gets/Sets the popup that is used as drop-down content.
/// </summary>
public Popup DropDownContent { public Popup DropDownContent {
get { return (Popup)GetValue(DropDownContentProperty); } get { return (Popup)GetValue(DropDownContentProperty); }
set { SetValue(DropDownContentProperty, value); } set { SetValue(DropDownContentProperty, value); }
} }
/// <summary>
/// Gets whether the drop-down is opened.
/// </summary>
public bool IsDropDownContentOpen { public bool IsDropDownContentOpen {
get { return (bool)GetValue(IsDropDownContentOpenProperty); } get { return (bool)GetValue(IsDropDownContentOpenProperty); }
protected set { SetValue(IsDropDownContentOpenPropertyKey, value); } protected set { SetValue(IsDropDownContentOpenPropertyKey, value); }
} }
/// <inheritdoc/>
protected override void OnClick() protected override void OnClick()
{ {
if (DropDownContent != null && !IsDropDownContentOpen) { if (DropDownContent != null && !IsDropDownContentOpen) {

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/ISearchStrategy.cs

@ -19,8 +19,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
using ICSharpCode.AvalonEdit.Document;
namespace ICSharpCode.AvalonEdit.Search namespace ICSharpCode.AvalonEdit.Search
{ {

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/RegexSearchStrategy.cs

@ -22,7 +22,6 @@ using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Documents; using System.Windows.Documents;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;

33
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/SearchCommands.cs

@ -86,9 +86,9 @@ namespace ICSharpCode.AvalonEdit.Search
void RegisterCommands(ICollection<CommandBinding> commandBindings) void RegisterCommands(ICollection<CommandBinding> commandBindings)
{ {
commandBindings.Add(new CommandBinding(ApplicationCommands.Find, ExecuteFind)); commandBindings.Add(new CommandBinding(ApplicationCommands.Find, ExecuteFind));
commandBindings.Add(new CommandBinding(SearchCommands.FindNext, ExecuteFindNext)); commandBindings.Add(new CommandBinding(SearchCommands.FindNext, ExecuteFindNext, CanExecuteWithOpenSearchPanel));
commandBindings.Add(new CommandBinding(SearchCommands.FindPrevious, ExecuteFindPrevious)); commandBindings.Add(new CommandBinding(SearchCommands.FindPrevious, ExecuteFindPrevious, CanExecuteWithOpenSearchPanel));
commandBindings.Add(new CommandBinding(SearchCommands.CloseSearchPanel, ExecuteCloseSearchPanel)); commandBindings.Add(new CommandBinding(SearchCommands.CloseSearchPanel, ExecuteCloseSearchPanel, CanExecuteWithOpenSearchPanel));
} }
SearchPanel panel; SearchPanel panel;
@ -101,19 +101,40 @@ namespace ICSharpCode.AvalonEdit.Search
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Input, (Action)delegate { panel.Reactivate(); }); Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Input, (Action)delegate { panel.Reactivate(); });
} }
void CanExecuteWithOpenSearchPanel(object sender, CanExecuteRoutedEventArgs e)
{
if (panel.IsClosed) {
e.CanExecute = false;
// Continue routing so that the key gesture can be consumed by another component.
e.ContinueRouting = true;
} else {
e.CanExecute = true;
e.Handled = true;
}
}
void ExecuteFindNext(object sender, ExecutedRoutedEventArgs e) void ExecuteFindNext(object sender, ExecutedRoutedEventArgs e)
{ {
panel.FindNext(); if (!panel.IsClosed) {
panel.FindNext();
e.Handled = true;
}
} }
void ExecuteFindPrevious(object sender, ExecutedRoutedEventArgs e) void ExecuteFindPrevious(object sender, ExecutedRoutedEventArgs e)
{ {
panel.FindPrevious(); if (!panel.IsClosed) {
panel.FindPrevious();
e.Handled = true;
}
} }
void ExecuteCloseSearchPanel(object sender, ExecutedRoutedEventArgs e) void ExecuteCloseSearchPanel(object sender, ExecutedRoutedEventArgs e)
{ {
panel.Close(); if (!panel.IsClosed) {
panel.Close();
e.Handled = true;
}
} }
/// <summary> /// <summary>

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/IActiveElement.cs

@ -18,6 +18,7 @@
using System; using System;
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
using ICSharpCode.AvalonEdit.Document;
namespace ICSharpCode.AvalonEdit.Snippets namespace ICSharpCode.AvalonEdit.Snippets
{ {

6
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/InsertionContext.cs

@ -19,9 +19,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows; using System.Windows;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.NRefactory.Editor;
namespace ICSharpCode.AvalonEdit.Snippets namespace ICSharpCode.AvalonEdit.Snippets
{ {
@ -70,7 +70,7 @@ namespace ICSharpCode.AvalonEdit.Snippets
/// <summary> /// <summary>
/// Gets the text document. /// Gets the text document.
/// </summary> /// </summary>
public TextDocument Document { get; private set; } public ICSharpCode.AvalonEdit.Document.TextDocument Document { get; private set; }
/// <summary> /// <summary>
/// Gets the text that was selected before the insertion of the snippet. /// Gets the text that was selected before the insertion of the snippet.
@ -98,7 +98,7 @@ namespace ICSharpCode.AvalonEdit.Snippets
public int InsertionPosition { get; set; } public int InsertionPosition { get; set; }
readonly int startPosition; readonly int startPosition;
AnchorSegment wholeSnippetAnchor; ICSharpCode.AvalonEdit.Document.AnchorSegment wholeSnippetAnchor;
bool deactivateIfSnippetEmpty; bool deactivateIfSnippetEmpty;
/// <summary> /// <summary>

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/Snippet.cs

@ -17,9 +17,9 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.NRefactory.Editor;
namespace ICSharpCode.AvalonEdit.Snippets namespace ICSharpCode.AvalonEdit.Snippets
{ {

3
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/SnippetCaretElement.cs

@ -18,9 +18,8 @@
using System; using System;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using System.Windows.Input;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Editor;
using ICSharpCode.AvalonEdit.Document;
namespace ICSharpCode.AvalonEdit.Snippets namespace ICSharpCode.AvalonEdit.Snippets
{ {

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/SnippetReplaceableTextElement.cs

@ -21,9 +21,9 @@ using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Media; using System.Windows.Media;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Rendering; using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.NRefactory.Editor;
namespace ICSharpCode.AvalonEdit.Snippets namespace ICSharpCode.AvalonEdit.Snippets
{ {

10
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditor.cs

@ -408,7 +408,7 @@ namespace ICSharpCode.AvalonEdit
TextEditor editor = d as TextEditor; TextEditor editor = d as TextEditor;
if (editor != null) { if (editor != null) {
if ((bool)e.NewValue) if ((bool)e.NewValue)
editor.TextArea.ReadOnlySectionProvider = ReadOnlyDocument.Instance; editor.TextArea.ReadOnlySectionProvider = ReadOnlySectionDocument.Instance;
else else
editor.TextArea.ReadOnlySectionProvider = NoReadOnlySections.Instance; editor.TextArea.ReadOnlySectionProvider = NoReadOnlySections.Instance;
@ -905,7 +905,7 @@ namespace ICSharpCode.AvalonEdit
if (start < 0 || start > documentLength) if (start < 0 || start > documentLength)
throw new ArgumentOutOfRangeException("start", start, "Value must be between 0 and " + documentLength); throw new ArgumentOutOfRangeException("start", start, "Value must be between 0 and " + documentLength);
if (length < 0 || start + length > documentLength) if (length < 0 || start + length > documentLength)
throw new ArgumentOutOfRangeException("length", length, "Value must be between 0 and " + (documentLength - length)); throw new ArgumentOutOfRangeException("length", length, "Value must be between 0 and " + (documentLength - start));
textArea.Selection = SimpleSelection.Create(textArea, start, start + length); textArea.Selection = SimpleSelection.Create(textArea, start, start + length);
textArea.Caret.Offset = start + length; textArea.Caret.Offset = start + length;
} }
@ -944,9 +944,9 @@ namespace ICSharpCode.AvalonEdit
{ {
using (StreamReader reader = FileReader.OpenStream(stream, this.Encoding ?? Encoding.UTF8)) { using (StreamReader reader = FileReader.OpenStream(stream, this.Encoding ?? Encoding.UTF8)) {
this.Text = reader.ReadToEnd(); this.Text = reader.ReadToEnd();
this.Encoding = reader.CurrentEncoding; // assign encoding after ReadToEnd() so that the StreamReader can autodetect the encoding SetCurrentValue(EncodingProperty, reader.CurrentEncoding); // assign encoding after ReadToEnd() so that the StreamReader can autodetect the encoding
} }
this.IsModified = false; SetCurrentValue(IsModifiedProperty, Boxes.False);
} }
/// <summary> /// <summary>
@ -997,7 +997,7 @@ namespace ICSharpCode.AvalonEdit
document.WriteTextTo(writer); document.WriteTextTo(writer);
writer.Flush(); writer.Flush();
// do not close the stream // do not close the stream
this.IsModified = false; SetCurrentValue(IsModifiedProperty, Boxes.False);
} }
/// <summary> /// <summary>

12
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditorOptions.cs

@ -264,19 +264,11 @@ namespace ICSharpCode.AvalonEdit
/// Gets text required to indent from the specified <paramref name="column"/> to the next indentation level. /// Gets text required to indent from the specified <paramref name="column"/> to the next indentation level.
/// </summary> /// </summary>
public virtual string GetIndentationString(int column) public virtual string GetIndentationString(int column)
{
return GetIndentationString(column, IndentationSize, ConvertTabsToSpaces);
}
/// <summary>
/// Gets text required to indent from the specified <paramref name="column"/> to the next indentation level,
/// considering given <paramref name="indentationSize"/> and <paramref name="convertTabsToSpaces"/> settings.
/// </summary>
public static string GetIndentationString(int column, int indentationSize, bool convertTabsToSpaces)
{ {
if (column < 1) if (column < 1)
throw new ArgumentOutOfRangeException("column", column, "Value must be at least 1."); throw new ArgumentOutOfRangeException("column", column, "Value must be at least 1.");
if (convertTabsToSpaces) { int indentationSize = this.IndentationSize;
if (ConvertTabsToSpaces) {
return new string(' ', indentationSize - ((column - 1) % indentationSize)); return new string(' ', indentationSize - ((column - 1) % indentationSize));
} else { } else {
return "\t"; return "\t";

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextViewPosition.cs

@ -19,6 +19,7 @@
using System; using System;
using System.Globalization; using System.Globalization;
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
using ICSharpCode.AvalonEdit.Document;
namespace ICSharpCode.AvalonEdit namespace ICSharpCode.AvalonEdit
{ {

101
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/CallbackOnDispose.cs

@ -0,0 +1,101 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Threading;
namespace ICSharpCode.AvalonEdit.Utils
{
/// <summary>
/// Invokes an action when it is disposed.
/// </summary>
/// <remarks>
/// This class ensures the callback is invoked at most once,
/// even when Dispose is called on multiple threads.
/// </remarks>
sealed class CallbackOnDispose : IDisposable
{
Action action;
public CallbackOnDispose(Action action)
{
if (action == null)
throw new ArgumentNullException("action");
this.action = action;
}
public void Dispose()
{
Action a = Interlocked.Exchange(ref action, null);
if (a != null) {
a();
}
}
}
/// <summary>
/// This class is used to prevent stack overflows by representing a 'busy' flag
/// that prevents reentrance when another call is running.
/// However, using a simple 'bool busy' is not thread-safe, so we use a
/// thread-static BusyManager.
/// </summary>
static class BusyManager
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible",
Justification = "Should always be used with 'var'")]
public struct BusyLock : IDisposable
{
public static readonly BusyLock Failed = new BusyLock(null);
readonly List<object> objectList;
internal BusyLock(List<object> objectList)
{
this.objectList = objectList;
}
public bool Success {
get { return objectList != null; }
}
public void Dispose()
{
if (objectList != null) {
objectList.RemoveAt(objectList.Count - 1);
}
}
}
[ThreadStatic] static List<object> _activeObjects;
public static BusyLock Enter(object obj)
{
List<object> activeObjects = _activeObjects;
if (activeObjects == null)
activeObjects = _activeObjects = new List<object>();
for (int i = 0; i < activeObjects.Count; i++) {
if (activeObjects[i] == obj)
return BusyLock.Failed;
}
activeObjects.Add(obj);
return new BusyLock(activeObjects);
}
}
}

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/Deque.cs

@ -27,7 +27,7 @@ namespace ICSharpCode.AvalonEdit.Utils
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
[Serializable] [Serializable]
public sealed class Deque<T> : ICollection<T>, IReadOnlyCollection<T> public sealed class Deque<T> : ICollection<T>
{ {
T[] arr = Empty<T>.Array; T[] arr = Empty<T>.Array;
int size, head, tail; int size, head, tail;

11
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/DocumentPrinter.cs

@ -18,17 +18,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.IO.Packaging;
using System.Printing;
using System.Windows; using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Xps;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Highlighting; using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.NRefactory.Editor;
namespace ICSharpCode.AvalonEdit.Utils namespace ICSharpCode.AvalonEdit.Utils
{ {
@ -37,6 +32,7 @@ namespace ICSharpCode.AvalonEdit.Utils
/// </summary> /// </summary>
public static class DocumentPrinter public static class DocumentPrinter
{ {
#if NREFACTORY
/// <summary> /// <summary>
/// Converts a readonly TextDocument to a Block and applies the provided highlighting definition. /// Converts a readonly TextDocument to a Block and applies the provided highlighting definition.
/// </summary> /// </summary>
@ -49,6 +45,7 @@ namespace ICSharpCode.AvalonEdit.Utils
highlighter = null; highlighter = null;
return ConvertTextDocumentToBlock(document, highlighter); return ConvertTextDocumentToBlock(document, highlighter);
} }
#endif
/// <summary> /// <summary>
/// Converts an IDocument to a Block and applies the provided highlighter. /// Converts an IDocument to a Block and applies the provided highlighter.
@ -73,6 +70,7 @@ namespace ICSharpCode.AvalonEdit.Utils
return p; return p;
} }
#if NREFACTORY
/// <summary> /// <summary>
/// Converts a readonly TextDocument to a RichText and applies the provided highlighting definition. /// Converts a readonly TextDocument to a RichText and applies the provided highlighting definition.
/// </summary> /// </summary>
@ -85,6 +83,7 @@ namespace ICSharpCode.AvalonEdit.Utils
highlighter = null; highlighter = null;
return ConvertTextDocumentToRichText(document, highlighter); return ConvertTextDocumentToRichText(document, highlighter);
} }
#endif
/// <summary> /// <summary>
/// Converts an IDocument to a RichText and applies the provided highlighter. /// Converts an IDocument to a RichText and applies the provided highlighter.

123
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/IFreezable.cs

@ -0,0 +1,123 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
namespace ICSharpCode.AvalonEdit.Utils
{
interface IFreezable
{
/// <summary>
/// Gets if this instance is frozen. Frozen instances are immutable and thus thread-safe.
/// </summary>
bool IsFrozen { get; }
/// <summary>
/// Freezes this instance.
/// </summary>
void Freeze();
}
static class FreezableHelper
{
public static void ThrowIfFrozen(IFreezable freezable)
{
if (freezable.IsFrozen)
throw new InvalidOperationException("Cannot mutate frozen " + freezable.GetType().Name);
}
public static IList<T> FreezeListAndElements<T>(IList<T> list)
{
if (list != null) {
foreach (T item in list)
Freeze(item);
}
return FreezeList(list);
}
public static IList<T> FreezeList<T>(IList<T> list)
{
if (list == null || list.Count == 0)
return Empty<T>.Array;
if (list.IsReadOnly) {
// If the list is already read-only, return it directly.
// This is important, otherwise we might undo the effects of interning.
return list;
} else {
return new ReadOnlyCollection<T>(list.ToArray());
}
}
public static void Freeze(object item)
{
IFreezable f = item as IFreezable;
if (f != null)
f.Freeze();
}
public static T FreezeAndReturn<T>(T item) where T : IFreezable
{
item.Freeze();
return item;
}
/// <summary>
/// If the item is not frozen, this method creates and returns a frozen clone.
/// If the item is already frozen, it is returned without creating a clone.
/// </summary>
public static T GetFrozenClone<T>(T item) where T : IFreezable, ICloneable
{
if (!item.IsFrozen) {
item = (T)item.Clone();
item.Freeze();
}
return item;
}
}
[Serializable]
abstract class AbstractFreezable : IFreezable
{
bool isFrozen;
/// <summary>
/// Gets if this instance is frozen. Frozen instances are immutable and thus thread-safe.
/// </summary>
public bool IsFrozen {
get { return isFrozen; }
}
/// <summary>
/// Freezes this instance.
/// </summary>
public void Freeze()
{
if (!isFrozen) {
FreezeInternal();
isFrozen = true;
}
}
protected virtual void FreezeInternal()
{
}
}
}

132
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/ImmutableStack.cs

@ -0,0 +1,132 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
namespace ICSharpCode.AvalonEdit.Utils
{
/// <summary>
/// An immutable stack.
///
/// Using 'foreach' on the stack will return the items from top to bottom (in the order they would be popped).
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
[Serializable]
public sealed class ImmutableStack<T> : IEnumerable<T>
{
/// <summary>
/// Gets the empty stack instance.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "ImmutableStack is immutable")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes")]
public static readonly ImmutableStack<T> Empty = new ImmutableStack<T>();
readonly T value;
readonly ImmutableStack<T> next;
private ImmutableStack()
{
}
private ImmutableStack(T value, ImmutableStack<T> next)
{
this.value = value;
this.next = next;
}
/// <summary>
/// Pushes an item on the stack. This does not modify the stack itself, but returns a new
/// one with the value pushed.
/// </summary>
public ImmutableStack<T> Push(T item)
{
return new ImmutableStack<T>(item, this);
}
/// <summary>
/// Gets the item on the top of the stack.
/// </summary>
/// <exception cref="InvalidOperationException">The stack is empty.</exception>
public T Peek()
{
if (IsEmpty)
throw new InvalidOperationException("Operation not valid on empty stack.");
return value;
}
/// <summary>
/// Gets the item on the top of the stack.
/// Returns <c>default(T)</c> if the stack is empty.
/// </summary>
public T PeekOrDefault()
{
return value;
}
/// <summary>
/// Gets the stack with the top item removed.
/// </summary>
/// <exception cref="InvalidOperationException">The stack is empty.</exception>
public ImmutableStack<T> Pop()
{
if (IsEmpty)
throw new InvalidOperationException("Operation not valid on empty stack.");
return next;
}
/// <summary>
/// Gets if this stack is empty.
/// </summary>
public bool IsEmpty {
get { return next == null; }
}
/// <summary>
/// Gets an enumerator that iterates through the stack top-to-bottom.
/// </summary>
public IEnumerator<T> GetEnumerator()
{
ImmutableStack<T> t = this;
while (!t.IsEmpty) {
yield return t.value;
t = t.next;
}
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
/// <inheritdoc/>
public override string ToString()
{
StringBuilder b = new StringBuilder("[Stack");
foreach (T val in this) {
b.Append(' ');
b.Append(val);
}
b.Append(']');
return b.ToString();
}
}
}

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/Rope.cs

@ -23,7 +23,6 @@ using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using System.Text; using System.Text;
using ICSharpCode.NRefactory.Utils;
namespace ICSharpCode.AvalonEdit.Utils namespace ICSharpCode.AvalonEdit.Utils
{ {

0
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/Images/Class.png → src/Main/Base/Project/Editor/CodeCompletion/Images/Class.png

Before

Width:  |  Height:  |  Size: 470 B

After

Width:  |  Height:  |  Size: 470 B

4
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/Images/CompletionImage.cs → src/Main/Base/Project/Editor/CodeCompletion/Images/CompletionImage.cs

@ -25,7 +25,7 @@ using System.Windows.Media.Imaging;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem.Implementation; using ICSharpCode.NRefactory.TypeSystem.Implementation;
namespace ICSharpCode.AvalonEdit.CodeCompletion namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion
{ {
/// <summary> /// <summary>
/// Provides icons for code-completion. /// Provides icons for code-completion.
@ -44,7 +44,7 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion
static BitmapImage LoadBitmap(string name) static BitmapImage LoadBitmap(string name)
{ {
BitmapImage image = new BitmapImage(new Uri("pack://application:,,,/ICSharpCode.AvalonEdit;component/CodeCompletion/Images/" + name + ".png")); BitmapImage image = new BitmapImage(new Uri("pack://application:,,,/ICSharpCode.SharpDevelop;component/Editor/CodeCompletion/Images/" + name + ".png"));
image.Freeze(); image.Freeze();
return image; return image;
} }

0
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/Images/Constructor.png → src/Main/Base/Project/Editor/CodeCompletion/Images/Constructor.png

Before

Width:  |  Height:  |  Size: 468 B

After

Width:  |  Height:  |  Size: 468 B

0
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/Images/Delegate.png → src/Main/Base/Project/Editor/CodeCompletion/Images/Delegate.png

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

0
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/Images/Enum.png → src/Main/Base/Project/Editor/CodeCompletion/Images/Enum.png

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

0
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/Images/EnumValue.png → src/Main/Base/Project/Editor/CodeCompletion/Images/EnumValue.png

Before

Width:  |  Height:  |  Size: 631 B

After

Width:  |  Height:  |  Size: 631 B

0
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/Images/Event.png → src/Main/Base/Project/Editor/CodeCompletion/Images/Event.png

Before

Width:  |  Height:  |  Size: 494 B

After

Width:  |  Height:  |  Size: 494 B

0
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/Images/ExtensionMethod.png → src/Main/Base/Project/Editor/CodeCompletion/Images/ExtensionMethod.png

Before

Width:  |  Height:  |  Size: 567 B

After

Width:  |  Height:  |  Size: 567 B

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save