From b5f9f09c4085310c40651a1b196a7d31bd90ea58 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sun, 7 Mar 2010 17:36:16 +0000 Subject: [PATCH] Highlighting editor: allow editing colors of highlighting definitions defined in AddIns. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5582 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- AddIns/ICSharpCode.SharpDevelop.addin | 1 - .../FSharpBinding/FSharpBinding.addin | 2 +- .../FSharpBinding/Resources/FS-Mode.xshd | 2 +- .../ILAsmBinding/Project/ILAsmBinding.addin | 2 +- .../Project/Resources/ILAsm-Mode.xshd | 1085 ++++++++--------- .../PythonBinding/Project/PythonBinding.addin | 2 +- .../Test/AddInFileTestFixture.cs | 1 - ...onvertToPythonProjectCommandTestFixture.cs | 1 - .../ProjectHasStartupObjectTestFixture.cs | 1 - .../Test/PythonSyntaxModeTestFixture.cs | 8 +- .../PythonBinding/Test/Utils/AddInHelper.cs | 1 - .../RubyBinding/Project/RubyBinding.addin | 2 +- .../AvalonEdit.AddIn/AvalonEdit.AddIn.addin | 4 +- .../AvalonEdit.AddIn/AvalonEdit.AddIn.csproj | 1 + .../Src/AvalonEditDisplayBinding.cs | 26 +- .../AvalonEdit.AddIn/Src/CodeEditorView.cs | 2 + .../Src/Options/HighlightingOptions.xaml.cs | 35 +- .../AvalonEdit.AddIn/Src/SyntaxModeDoozer.cs | 116 ++ .../Project/ICSharpCode.SharpDevelop.csproj | 2 - .../Codons/AddInTreeSyntaxModeProvider.cs | 49 - .../Src/TextEditor/Codons/SyntaxModeDoozer.cs | 112 -- ...ightingToHighlightingManagerTestFixture.cs | 3 +- 22 files changed, 689 insertions(+), 769 deletions(-) create mode 100644 src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SyntaxModeDoozer.cs delete mode 100644 src/Main/Base/Project/Src/TextEditor/Codons/AddInTreeSyntaxModeProvider.cs delete mode 100644 src/Main/Base/Project/Src/TextEditor/Codons/SyntaxModeDoozer.cs diff --git a/AddIns/ICSharpCode.SharpDevelop.addin b/AddIns/ICSharpCode.SharpDevelop.addin index 2e6432f658..5d40feb3e7 100644 --- a/AddIns/ICSharpCode.SharpDevelop.addin +++ b/AddIns/ICSharpCode.SharpDevelop.addin @@ -41,7 +41,6 @@ - diff --git a/src/AddIns/BackendBindings/FSharpBinding/FSharpBinding.addin b/src/AddIns/BackendBindings/FSharpBinding/FSharpBinding.addin index d305fa0cd9..358644ec2c 100644 --- a/src/AddIns/BackendBindings/FSharpBinding/FSharpBinding.addin +++ b/src/AddIns/BackendBindings/FSharpBinding/FSharpBinding.addin @@ -21,7 +21,7 @@ class = "FSharpBindings.FSharpAmbience"/> - + - + diff --git a/src/AddIns/BackendBindings/ILAsmBinding/Project/ILAsmBinding.addin b/src/AddIns/BackendBindings/ILAsmBinding/Project/ILAsmBinding.addin index 7d5b4b0d4a..a66cb8856e 100644 --- a/src/AddIns/BackendBindings/ILAsmBinding/Project/ILAsmBinding.addin +++ b/src/AddIns/BackendBindings/ILAsmBinding/Project/ILAsmBinding.addin @@ -37,7 +37,7 @@ - + - - - + + + + + + + + + + - - - - - - - - - &<>~!@%^*()-+=|\#/{}[]:;"' , ? + + + nop + break + ldarg.0 + ldarg.1 + ldarg.2 + ldarg.3 + ldloc.0 + ldloc.1 + ldloc.2 + ldloc.3 + stloc.0 + stloc.1 + stloc.2 + stloc.3 + ldarg.s + ldarga.s + starg.s + ldloc.s + ldloca.s + stloc.s + ldnull + ldc.i4.m1 + ldc.i4.0 + ldc.i4.1 + ldc.i4.2 + ldc.i4.3 + ldc.i4.4 + ldc.i4.5 + ldc.i4.6 + ldc.i4.7 + ldc.i4.8 + ldc.i4.s + ldc.i4 + ldc.i8 + ldc.r4 + ldc.r8 + dup + pop + jmp + call + calli + ret + br.s + brfalse.s + brtrue.s + beq.s + bge.s + bgt.s + ble.s + blt.s + bne.un.s + bge.un.s + bgt.un.s + ble.un.s + blt.un.s + br + brfalse + brtrue + beq + bge + bgt + ble + blt + bne.un + bge.un + bgt.un + ble.un + blt.un + switch + ldind.i1 + ldind.u1 + ldind.i2 + ldind.u2 + ldind.i4 + ldind.u4 + ldind.i8 + ldind.i + ldind.r4 + ldind.r8 + ldind.ref + stind.ref + stind.i1 + stind.i2 + stind.i4 + stind.i8 + stind.r4 + stind.r8 + add + sub + mul + div + div.un + rem + rem.un + and + or + xor + shl + shr + shr.un + neg + not + conv.i1 + conv.i2 + conv.i4 + conv.i8 + conv.r4 + conv.r8 + conv.u4 + conv.u8 + callvirt + cpobj + ldobj + ldstr + newobj + castclass + isinst + conv.r.un + unbox + throw + ldfld + ldflda + stfld + ldsfld + ldsflda + stsfld + stobj + conv.ovf.i1.un + conv.ovf.i2.un + conv.ovf.i4.un + conv.ovf.i8.un + conv.ovf.u1.un + conv.ovf.u2.un + conv.ovf.u4.un + conv.ovf.u8.un + conv.ovf.i.un + conv.ovf.u.un + box + newarr + ldlen + ldelema + ldelem.i1 + ldelem.u1 + ldelem.i2 + ldelem.u2 + ldelem.i4 + ldelem.u4 + ldelem.i8 + ldelem.i + ldelem.r4 + ldelem.r8 + ldelem.ref + stelem.i + stelem.i1 + stelem.i2 + stelem.i4 + stelem.i8 + stelem.r4 + stelem.r8 + stelem.ref + conv.ovf.i1 + conv.ovf.u1 + conv.ovf.i2 + conv.ovf.u2 + conv.ovf.i4 + conv.ovf.u4 + conv.ovf.i8 + conv.ovf.u8 + refanyval + ckfinite + mkrefany + ldtoken + conv.u2 + conv.u1 + conv.i + conv.ovf.i + conv.ovf.u + add.ovf + add.ovf.un + mul.ovf + mul.ovf.un + sub.ovf + sub.ovf.un + endfinally + leave + leave.s + stind.i + conv.u + prefix7 + prefix6 + prefix5 + prefix4 + prefix3 + prefix2 + prefix1 + prefixref + arglist + ceq + cgt + cgt.un + clt + clt.un + ldftn + ldvirtftn + ldarg + ldarga + starg + ldloc + ldloca + stloc + localloc + endfilter + unaligned. + volatile. + tail. + initobj + cpblk + initblk + rethrow + sizeof + refanytype + illegal + endmac + brnull + brnull.s + brzero + brzero.s + brinst + brinst.s + ldind.u8 + ldelem.u8 + ldc.i4.M1 + endfault + + + void + bool + char + wchar + int + int8 + int16 + int32 + int64 + float + float32 + float64 + refany + typedref + object + string + native + unsigned + value + valuetype + class + const + vararg + default + stdcall + thiscall + fastcall + unmanaged + not_in_gc_heap + beforefieldinit + instance + filter + catch + static + public + private + synchronized + interface + extends + implements + handler + finally + fault + to + abstract + auto + sequential + explicit + wrapper + ansi + unicode + autochar + import + enum + virtual + notremotable + special + il + cil + optil + managed + preservesig + runtime + method + field + bytearray + final + sealed + specialname + family + assembly + famandassem + famorassem + privatescope + nested + hidebysig + newslot + rtspecialname + pinvokeimpl + unmanagedexp + reqsecobj + .ctor + .cctor + initonly + literal + notserialized + forwardref + internalcall + noinlining + nomangle + lasterr + winapi + cdecl + stdcall + thiscall + fastcall + as + pinned + modreq + modopt + serializable + at + tls + true + false + + + .class + .namespace + .method + .field + .emitbyte + .try + .maxstack + .locals + .entrypoint + .zeroinit + .pdirect + .data + .event + .addon + .removeon + .fire + .other + protected + .property + .set + .get + default + .import + .permission + .permissionset + .line + .language + #line + + + request + demand + assert + deny + permitonly + linkcheck + inheritcheck + reqmin + reqopt + reqrefuse + prejitgrant + prejitdeny + noncasdemand + noncaslinkdemand + noncasinheritance + + + + .custom + + init + + .size + .pack + + .file + nometadata + .hash + .assembly + implicitcom + noappdomain + noprocess + nomachine + .publickey + .publickeytoken + algorithm + .ver + .locale + extern + .export + .manifestres + .mresource + .localized - - // - - - - " - " - + + .module + marshal + custom + sysstring + fixed + variant + currency + syschar + decimal + date + bstr + tbstr + lpstr + lpwstr + lptstr + objectref + iunknown + idispatch + struct + safearray + byvalstr + lpvoid + any + array + lpstruct - ( - - - - - - - - - - - - - - - - - - - - - - - - - - + + .vtfixup + fromunmanaged + callmostderived + .vtentry - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + in + out + opt + lcid + retval + .param + + + .override + with + + + null + error + hresult + carray + userdefined + record + filetime + blob + stream + storage + streamed_object + stored_object + blob_object + cf + clsid + vector + + + nullref - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <>~!@%^*()-+=|\#/{}[]:;"' , .? - - - - - - - - - - - + + .subsystem + .corflags + alignment + .imagebase + + + // + + + " + " + + [\d\w_]+(?=(\s*\()) + \b0[xX][0-9a-fA-F]+|\b(\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)? + + + + + TODO + FIXME + + + HACK + UNDONE + + + \ No newline at end of file diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.addin b/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.addin index f510d6cf1b..7559322692 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.addin +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.addin @@ -16,7 +16,7 @@ - + - + - + + + diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj index 3a6b3c11de..243b62876b 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj @@ -135,6 +135,7 @@ + diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditDisplayBinding.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditDisplayBinding.cs index 822a989ebf..5c54543f33 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditDisplayBinding.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditDisplayBinding.cs @@ -6,7 +6,7 @@ // using System; -using System.Collections.Generic; +using ICSharpCode.AvalonEdit.Highlighting; using ICSharpCode.Core; using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Gui; @@ -15,8 +15,18 @@ namespace ICSharpCode.AvalonEdit.AddIn { public class AvalonEditDisplayBinding : IDisplayBinding { - const string path = "/SharpDevelop/ViewContent/DefaultTextEditor/SyntaxModes"; - bool builtAddInHighlighting; + static bool addInHighlightingDefinitionsRegistered; + + internal static void RegisterAddInHighlightingDefinitions() + { + WorkbenchSingleton.AssertMainThread(); + if (!addInHighlightingDefinitionsRegistered) { + foreach (AddInTreeSyntaxMode syntaxMode in AddInTree.BuildItems(SyntaxModeDoozer.Path, null, false)) { + syntaxMode.Register(HighlightingManager.Instance); + } + addInHighlightingDefinitionsRegistered = true; + } + } public bool CanCreateContentForFile(string fileName) { @@ -25,16 +35,8 @@ namespace ICSharpCode.AvalonEdit.AddIn public IViewContent CreateContentForFile(OpenedFile file) { - BuildAddInHighlighting(); + RegisterAddInHighlightingDefinitions(); return new AvalonEditViewContent(file); } - - void BuildAddInHighlighting() - { - if (!builtAddInHighlighting) { - builtAddInHighlighting = true; - AddInTree.BuildItems(path, this, false); - } - } } } diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs index fef06b2005..c77ae97970 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs @@ -45,6 +45,8 @@ namespace ICSharpCode.AvalonEdit.AddIn public CodeEditorView() { + AvalonEditDisplayBinding.RegisterAddInHighlightingDefinitions(); + this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Help, OnHelpExecuted)); this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Print, OnPrint)); this.CommandBindings.Add(new CommandBinding(ApplicationCommands.PrintPreview, OnPrintPreview)); diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs index ce94bed520..8ead4acc2b 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs @@ -26,6 +26,9 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options { public HighlightingOptions() { + // ensure all definitions from AddIns are registered so that they are available for the example view + AvalonEditDisplayBinding.RegisterAddInHighlightingDefinitions(); + InitializeComponent(); textEditor.Document.UndoStack.SizeLimit = 0; textEditor.Options = CodeEditorOptions.Instance; @@ -50,16 +53,18 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options base.LoadOptions(); if (allSyntaxDefinitions == null) { allSyntaxDefinitions = ( - from name in typeof(HighlightingManager).Assembly.GetManifestResourceNames() + from name in typeof(HighlightingManager).Assembly.GetManifestResourceNames().AsParallel() where name.StartsWith(typeof(HighlightingManager).Namespace + ".Resources.", StringComparison.OrdinalIgnoreCase) && name.EndsWith(".xshd", StringComparison.OrdinalIgnoreCase) && !name.EndsWith("XmlDoc.xshd", StringComparison.OrdinalIgnoreCase) - let def = LoadBuiltinXshd(name) - where def.Elements.OfType().Any(c => c.ExampleText != null) - orderby def.Name - select def - ).ToList(); - // TODO: also find syntax definitions defined in addins + select LoadBuiltinXshd(name) + ).Concat( + ICSharpCode.Core.AddInTree.BuildItems(SyntaxModeDoozer.Path, null, false).AsParallel() + .Select(m => m.LoadXshd()) + ) + .Where(def => def.Elements.OfType().Any(c => c.ExampleText != null)) + .OrderBy(def => def.Name) + .ToList(); } customizationList = CustomizedHighlightingColor.LoadColors(); @@ -77,12 +82,16 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options XshdSyntaxDefinition xshd = (XshdSyntaxDefinition)languageComboBox.SelectedItem; if (xshd != null) { IHighlightingDefinition def = HighlightingManager.Instance.GetDefinition(xshd.Name); - foreach (XshdColor namedColor in xshd.Elements.OfType()) { - if (namedColor.ExampleText != null) { - IHighlightingItem item = new NamedColorHighlightingItem(def, namedColor); - item = new CustomizedHighlightingItem(customizationList, item, xshd.Name); - listBox.Items.Add(item); - item.PropertyChanged += item_PropertyChanged; + if (def == null) { + throw new InvalidOperationException("Expected that all XSHDs are registered in default highlighting manager; but highlighting definition was not found"); + } else { + foreach (XshdColor namedColor in xshd.Elements.OfType()) { + if (namedColor.ExampleText != null) { + IHighlightingItem item = new NamedColorHighlightingItem(def, namedColor); + item = new CustomizedHighlightingItem(customizationList, item, xshd.Name); + listBox.Items.Add(item); + item.PropertyChanged += item_PropertyChanged; + } } } if (listBox.Items.Count > 0) diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SyntaxModeDoozer.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SyntaxModeDoozer.cs new file mode 100644 index 0000000000..704fcb22e1 --- /dev/null +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SyntaxModeDoozer.cs @@ -0,0 +1,116 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Xml; + +using ICSharpCode.AvalonEdit.Highlighting; +using ICSharpCode.AvalonEdit.Highlighting.Xshd; +using ICSharpCode.Core; + +namespace ICSharpCode.AvalonEdit.AddIn +{ + public class AddInTreeSyntaxMode + { + ICSharpCode.Core.AddIn addin; + string resourceName; + + public string Name { get; private set; } + public string[] Extensions { get; private set; } + + public AddInTreeSyntaxMode(ICSharpCode.Core.AddIn addin, string resourceName, string name, string[] extensions) + { + if (addin == null) + throw new ArgumentNullException("addin"); + if (resourceName == null) + throw new ArgumentNullException("resourceName"); + if (name == null) + throw new ArgumentNullException("name"); + if (extensions == null) + throw new ArgumentNullException("extensions"); + + this.addin = addin; + this.resourceName = resourceName; + this.Name = name; + this.Extensions = extensions; + } + + public XmlReader CreateXmlReader() + { + Stream stream = addin.GetManifestResourceStream(resourceName); + if (stream != null) { + return new XmlTextReader(stream); + } else { + throw new InvalidOperationException("Could not find resource '" + resourceName + "' in any of the AddIn runtime assemblies."); + } + } + + public XshdSyntaxDefinition LoadXshd() + { + using (XmlReader reader = CreateXmlReader()) { + XshdSyntaxDefinition xshd = HighlightingLoader.LoadXshd(reader); + if (xshd.Name != this.Name) + throw new InvalidOperationException("Loaded XSHD has name '" + xshd.Name + "', but expected was '" + this.Name + "'."); + if (!Enumerable.SequenceEqual(xshd.Extensions, this.Extensions)) + throw new InvalidOperationException("Loaded XSHD has extensions '" + string.Join(";", xshd.Extensions) + "', but expected was '" + string.Join(";", this.Extensions) + "'."); + return xshd; + } + } + + public void Register(HighlightingManager manager) + { + manager.RegisterHighlighting( + this.Name, this.Extensions, delegate { + return HighlightingLoader.Load(LoadXshd(), manager); + }); + } + } + + /// + /// Creates AddInTreeSyntaxMode objects that wrap a .xshd syntax mode stored as resource in the + /// addin assembly. + /// + /// + /// Name of the language for which the syntax mode is used. + /// + /// + /// Semicolon-separated list of file extensions for which the syntax mode is used. + /// + /// + /// Fully qualified name of the resource file. + /// + /// Only in /SharpDevelop/ViewContent/AvalonEdit/SyntaxModes + /// + /// An AddInTreeSyntaxMode object that loads the resource from the addin assembly when + /// its CreateTextReader method is called. + /// + public class SyntaxModeDoozer : IDoozer + { + public const string Path = "/SharpDevelop/ViewContent/AvalonEdit/SyntaxModes"; + + /// + /// Gets if the doozer handles codon conditions on its own. + /// If this property return false, the item is excluded when the condition is not met. + /// + public bool HandleConditions { + get { return false; } + } + + public object BuildItem(object caller, Codon codon, ArrayList subItems) + { + string highlightingName = codon.Properties["name"]; + string[] extensions = codon.Properties["extensions"].Split(';'); + string resource = codon.Properties["resource"]; + + return new AddInTreeSyntaxMode(codon.AddIn, resource, highlightingName, extensions); + } + } +} diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj index fc2ef12445..2188002491 100644 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj @@ -573,8 +573,6 @@ - - diff --git a/src/Main/Base/Project/Src/TextEditor/Codons/AddInTreeSyntaxModeProvider.cs b/src/Main/Base/Project/Src/TextEditor/Codons/AddInTreeSyntaxModeProvider.cs deleted file mode 100644 index 615f9e236d..0000000000 --- a/src/Main/Base/Project/Src/TextEditor/Codons/AddInTreeSyntaxModeProvider.cs +++ /dev/null @@ -1,49 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Xml; - -using ICSharpCode.Core; -using ICSharpCode.TextEditor.Document; - -namespace ICSharpCode.SharpDevelop.DefaultEditor.Codons -{ - /// - /// Description of AddInTreeSyntaxModeProvider. - /// - public class AddInTreeSyntaxModeProvider : ISyntaxModeFileProvider - { - const string syntaxModePath = "/SharpDevelop/ViewContent/DefaultTextEditor/SyntaxModes"; - - List syntaxModes; - - public ICollection SyntaxModes { - get { - return syntaxModes; - } - } - - public AddInTreeSyntaxModeProvider() - { - syntaxModes = AddInTree.BuildItems(syntaxModePath, this, false); - } - - public XmlTextReader GetSyntaxModeFile(SyntaxMode syntaxMode) - { - Debug.Assert(syntaxMode is AddInTreeSyntaxMode); - return ((AddInTreeSyntaxMode)syntaxMode).CreateTextReader(); - } - - public void UpdateSyntaxModeList() - { - // addintree doesn't change during runtime - } - } -} diff --git a/src/Main/Base/Project/Src/TextEditor/Codons/SyntaxModeDoozer.cs b/src/Main/Base/Project/Src/TextEditor/Codons/SyntaxModeDoozer.cs deleted file mode 100644 index 5407c9d7ea..0000000000 --- a/src/Main/Base/Project/Src/TextEditor/Codons/SyntaxModeDoozer.cs +++ /dev/null @@ -1,112 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Collections; -using System.IO; -using System.Reflection; -using System.Xml; - -using ICSharpCode.Core; -using ICSharpCode.SharpDevelop.Editor; -using ICSharpCode.TextEditor.Document; -using AvalonEdit = ICSharpCode.AvalonEdit; -using ICSharpCode.AvalonEdit.Highlighting; - -namespace ICSharpCode.SharpDevelop.DefaultEditor.Codons -{ - public class AddInTreeSyntaxMode : SyntaxMode - { - Runtime[] runtimes; - - public AddInTreeSyntaxMode(Runtime[] runtimes, string fileName, string name, string[] extensions) : base(fileName, name, extensions) - { - this.runtimes = runtimes; - } - - public XmlTextReader CreateTextReader() - { - foreach (Runtime runtime in runtimes) { - Assembly assembly = runtime.LoadedAssembly; - if (assembly != null) { - Stream stream = assembly.GetManifestResourceStream(FileName); - if (stream != null) { - return new XmlTextReader(stream); - } - } - } - return null; - } - } - - /// - /// Creates AddInTreeSyntaxMode objects that wrap a .xshd syntax mode stored as resource in the - /// addin assembly. - /// - /// - /// Name of the language for which the syntax mode is used. - /// - /// - /// Semicolon-separated list of file extensions for which the syntax mode is used. - /// - /// - /// Fully qualified name of the resource file. - /// - /// Only in /SharpDevelop/ViewContent/DefaultTextEditor/SyntaxModes - /// - /// An AddInTreeSyntaxMode object that loads the resource from the addin assembly when - /// its CreateTextReader method is called. - /// - public class SyntaxModeDoozer : IDoozer - { - AvalonEdit.Highlighting.HighlightingManager highlightingManager; - - public SyntaxModeDoozer(AvalonEdit.Highlighting.HighlightingManager highlightingManager) - { - this.highlightingManager = highlightingManager; - } - - public SyntaxModeDoozer() - : this(AvalonEdit.Highlighting.HighlightingManager.Instance) - { - } - - /// - /// Gets if the doozer handles codon conditions on its own. - /// If this property return false, the item is excluded when the condition is not met. - /// - public bool HandleConditions { - get { return false; } - } - - public object BuildItem(object caller, Codon codon, ArrayList subItems) - { - string highlightingName = codon.Properties["name"]; - string[] extensions = codon.Properties["extensions"].Split(';'); - string resource = codon.Properties["resource"]; - - Runtime[] assemblies = new Runtime[codon.AddIn.Runtimes.Count]; - int i = 0; - foreach (Runtime library in codon.AddIn.Runtimes) { - assemblies[i++] = library; - } - - highlightingManager.RegisterHighlighting(highlightingName, extensions, LoadHighlighting(assemblies, resource)); - - return new AddInTreeSyntaxMode(assemblies, resource, highlightingName, extensions); - } - - Func LoadHighlighting(Runtime[] runtimes, string resourceName) - { - Func func = delegate { - AddInHighlightingResource highlightingResource = new AddInHighlightingResource(runtimes); - return highlightingResource.LoadHighlighting(resourceName, highlightingManager); - }; - return func; - } - } -} diff --git a/src/Main/Base/Test/Highlighting/SyntaxDoozerAddsHighlightingToHighlightingManagerTestFixture.cs b/src/Main/Base/Test/Highlighting/SyntaxDoozerAddsHighlightingToHighlightingManagerTestFixture.cs index f665962974..03f92cdf81 100644 --- a/src/Main/Base/Test/Highlighting/SyntaxDoozerAddsHighlightingToHighlightingManagerTestFixture.cs +++ b/src/Main/Base/Test/Highlighting/SyntaxDoozerAddsHighlightingToHighlightingManagerTestFixture.cs @@ -13,12 +13,12 @@ using System.Text; using ICSharpCode.AvalonEdit.Highlighting; using ICSharpCode.Core; using ICSharpCode.Core.Tests.Utils; -using ICSharpCode.SharpDevelop.DefaultEditor.Codons; using ICSharpCode.SharpDevelop.Tests.Utils; using NUnit.Framework; namespace ICSharpCode.SharpDevelop.Tests.Highlighting { + /* TODO: create Tests-project for AvalonEdit.AddIn and move this test there [TestFixture] public class SyntaxDoozerAddsHighlightingToHighlightingManagerTestFixture { @@ -117,4 +117,5 @@ namespace ICSharpCode.SharpDevelop.Tests.Highlighting Assert.AreEqual("XML", highlightingDefinition.Name); } } + */ }