diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2016-12-06 17:56:24 +0300 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2016-12-06 17:56:24 +0300 |
commit | ca594ded382b69f1aa258a48eccdf72ee7f16694 (patch) | |
tree | c11bc282ef59741cf438691f0ce44c6a4814c9a7 /main | |
parent | 714ed187786bc94939cd776cb067c10ad9a9b405 (diff) |
Fixed 'Bug 48990 - [TextMate] No extension point for addins to provide
syntax highlighting'
Added new extension point '/MonoDevelop/SourceEditor2/Bundles' - it's
now possible to throw all stuff of textmate/sublime3 extensions in
there. The old one was just for syntax modes.
Diffstat (limited to 'main')
7 files changed, 18 insertions, 78 deletions
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj index b204175828..6cd40325b5 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj @@ -190,7 +190,6 @@ <Compile Include="MonoDevelop.SourceEditor\StyledSourceEditorOptions.cs" /> <Compile Include="MonoDevelop.SourceEditor.Wrappers\SemanticHighlightingSyntaxMode.cs" /> <Compile Include="MonoDevelop.SourceEditor\TextMarker\ErrorMarker.cs" /> - <Compile Include="MonoDevelop.SourceEditor\SyntaxModeLoader.cs" /> <Compile Include="MonoDevelop.SourceEditor\SearchInSelectionMarker.cs" /> <Compile Include="MonoDevelop.SourceEditor\DefaultAutoInsertBracketHandler.cs" /> <Compile Include="Mono.TextEditor\Gui\ActionMargin.cs" /> diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs index d523f7111c..7d02104cf8 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs @@ -2138,7 +2138,6 @@ namespace MonoDevelop.SourceEditor if (ClipbardRingUpdated != null) ClipbardRingUpdated (null, EventArgs.Empty); }; - SyntaxModeLoader.Init (); } public void UpdateClipboardRing (object sender, EventArgs e) diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SyntaxModeLoader.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SyntaxModeLoader.cs deleted file mode 100644 index fc3fe9300b..0000000000 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SyntaxModeLoader.cs +++ /dev/null @@ -1,69 +0,0 @@ -// -// SyntaxModeLoader.cs -// -// Author: -// Mike Krüger <mkrueger@xamarin.com> -// -// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com) -// -// 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.IO; -using Mono.Addins; -using MonoDevelop.Ide.Editor.Highlighting; - -namespace MonoDevelop.SourceEditor -{ - static class SyntaxModeLoader - { - static bool initialized = false; - - public static void Init () - { - if (initialized) - return; - initialized = true; - AddinManager.AddExtensionNodeHandler ("/MonoDevelop/SourceEditor2/SyntaxModes", OnSyntaxModeExtensionChanged); - } - // TODO: EditorTheme - static void OnSyntaxModeExtensionChanged (object s, ExtensionNodeEventArgs args) - { - TemplateCodon codon = (TemplateCodon)args.ExtensionNode; -/* if (args.Change == ExtensionChange.Add) { - Mono.TextEditor.Highlighting.SyntaxModeService.AddSyntaxMode (new StreamProviderWrapper(codon)); - }*/ - } - - /* - class StreamProviderWrapper : IStreamProvider - { - readonly TemplateCodon codon; - - public StreamProviderWrapper (TemplateCodon codon) - { - this.codon = codon; - } - - Stream Mono.TextEditor.Highlighting.IStreamProvider.Open () - { - return codon.Open (); - } - }*/ - } -}
\ No newline at end of file diff --git a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.addin.xml b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.addin.xml index a86b1cce6f..689b801026 100644 --- a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.addin.xml +++ b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.addin.xml @@ -4,10 +4,6 @@ <Import assembly="Mono.TextTemplating.dll" /> </Runtime> - <Extension path = "/MonoDevelop/SourceEditor2/SyntaxModes"> - <Templates resource="T4SyntaxMode.xml" /> - </Extension> - <Extension path = "/MonoDevelop/Core/MimeTypes"> <MimeType id="application/t4-template" _description="Text template" icon="md-template" isText="true"> <File pattern="*.tt" /> diff --git a/main/src/core/MonoDevelop.Ide/ExtensionModel/MonoDevelop.Ide.addin.xml b/main/src/core/MonoDevelop.Ide/ExtensionModel/MonoDevelop.Ide.addin.xml index 6518990e63..3cd4132164 100644 --- a/main/src/core/MonoDevelop.Ide/ExtensionModel/MonoDevelop.Ide.addin.xml +++ b/main/src/core/MonoDevelop.Ide/ExtensionModel/MonoDevelop.Ide.addin.xml @@ -177,8 +177,8 @@ <ExtensionNode name="Generator" type="MonoDevelop.Ide.Extensions.MimeTypeExtensionNode"/> </ExtensionPoint> - <ExtensionPoint path = "/MonoDevelop/SourceEditor2/SyntaxModes" name = "Text editor syntax modes"> - <Description>Syntax modes</Description> + <ExtensionPoint path = "/MonoDevelop/SourceEditor2/Bundles" name = "Text editor extension files"> + <Description>Text editor language bundles</Description> <ExtensionNode name="Templates" type="MonoDevelop.Ide.Editor.Highlighting.TemplateCodon"/> </ExtensionPoint> diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/SyntaxHighlightingService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/SyntaxHighlightingService.cs index 06b20df490..8e156701bd 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/SyntaxHighlightingService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/SyntaxHighlightingService.cs @@ -452,8 +452,23 @@ namespace MonoDevelop.Ide.Editor.Highlighting } } PrepareMatches (); + AddinManager.AddExtensionNodeHandler ("/MonoDevelop/SourceEditor2/Bundles", OnSyntaxModeExtensionChanged); } + static void OnSyntaxModeExtensionChanged (object s, ExtensionNodeEventArgs args) + { + var codon = (TemplateCodon)args.ExtensionNode; + + if (args.Change == ExtensionChange.Add) { + try { + LoadFile (builtInBundle, codon.Name, () => codon.Open (), () => codon); + } catch (Exception e) { + LoggingService.LogError ("Error while loading custom editor extension file.", e); + } + } + } + + public static HslColor GetColor (EditorTheme style, string key) { HslColor result; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/TemplateCodon.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/TemplateCodon.cs index 02c077a7f1..dd84cd6565 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/TemplateCodon.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/TemplateCodon.cs @@ -40,7 +40,7 @@ namespace MonoDevelop.Ide.Editor.Highlighting [NodeAttribute("file", "Name of the file where the template is stored.")] string file; - public string Name { get { return file; } } + public string Name { get { return file ?? resource; } } public TemplateCodon () { |