Browse Source

Recognised XML file extensions now read from XmlEditor.addin file.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5077 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 17 years ago
parent
commit
3befe85746
  1. 34
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlDisplayBinding.cs
  2. 3
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlLanguageBinding.cs
  3. 2
      src/AddIns/DisplayBindings/XmlEditor/Project/XmlEditor.addin
  4. 53
      src/AddIns/DisplayBindings/XmlEditor/Test/Editor/XmlEditorFileExtensionsTestFixture.cs
  5. 2
      src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj

34
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlDisplayBinding.cs

@ -58,25 +58,31 @@ namespace ICSharpCode.XmlEditor @@ -58,25 +58,31 @@ namespace ICSharpCode.XmlEditor
}
/// <summary>
/// Gets the known xml file extensions.
/// Returns the extensions defined in the @extensions property of the first codon in the tree node.
/// </summary>
public static string[] GetXmlFileExtensions()
public static string[] GetXmlFileExtensions(AddInTreeNode node)
{
foreach (ParserDescriptor parser in AddInTree.BuildItems<ParserDescriptor>("/Workspace/Parser", null, false)) {
if (parser.Language == "XmlFoldingParser") {
return parser.Supportedextensions;
if (node != null) {
foreach (Codon codon in node.Codons) {
if (codon.Id == "Xml") {
List<string> extensions = new List<string>();
foreach (string ext in codon.Properties["extensions"].Split(';')) {
extensions.Add(ext.Trim());
}
return extensions.ToArray();
}
}
}
return new string[0];
}
// // Did not find the XmlFoldingParser so default to those files defined by the
// // HighlightingManager.
// TODO : not supported in AvalonEdit
// IHighlightingStrategy strategy = HighlightingManager.Manager.FindHighlighter("XML");
// if (strategy != null) {
// return strategy.Extensions;
// }
return new string[] { ".xml", ".addin" };
/// <summary>
/// Gets the known xml file extensions.
/// </summary>
public static string[] GetXmlFileExtensions()
{
AddInTreeNode node = AddInTree.GetTreeNode("/AddIns/DefaultTextEditor/CodeCompletion", false);
return GetXmlFileExtensions(node);
}
public IViewContent[] CreateSecondaryViewContent(IViewContent viewContent)

3
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlLanguageBinding.cs

@ -11,9 +11,6 @@ using ICSharpCode.SharpDevelop.Editor; @@ -11,9 +11,6 @@ using ICSharpCode.SharpDevelop.Editor;
namespace ICSharpCode.XmlEditor
{
/// <summary>
/// Description of XmlLanguageBinding.
/// </summary>
public class XmlLanguageBinding : DefaultLanguageBinding
{
public override IFormattingStrategy FormattingStrategy {

2
src/AddIns/DisplayBindings/XmlEditor/Project/XmlEditor.addin

@ -29,7 +29,7 @@ @@ -29,7 +29,7 @@
<Path name = "/SharpDevelop/Workbench/LanguageBindings">
<LanguageBinding
id="XML"
id = "Xml"
class = "ICSharpCode.XmlEditor.XmlLanguageBinding"
extensions = ".xml;.xsl;.xslt;.xsd;.manifest;.config;.addin;.xshd;.wxs;.wxi;.wxl;.proj;.csproj;.vbproj;.ilproj;.build;.xfrm;.targets;.xpt;.xft;.map;.wsdl;.disco" />
</Path>

53
src/AddIns/DisplayBindings/XmlEditor/Test/Editor/XmlEditorFileExtensionsTestFixture.cs

@ -0,0 +1,53 @@ @@ -0,0 +1,53 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision: 4723 $</version>
// </file>
using System;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
namespace XmlEditor.Tests.Editor
{
[TestFixture]
public class XmlEditorFileExtensionsTestFixture
{
AddInTreeNode addinTreeNode;
[SetUp]
public void SetUp()
{
string addinXml = "<AddIn name = 'Xml Editor'\r\n" +
"author = ''\r\n" +
"copyright = 'prj:///doc/copyright.txt'\r\n" +
"description = ''\r\n" +
"addInManagerHidden = 'preinstalled'>\r\n" +
"</AddIn>";
using (StringReader reader = new StringReader(addinXml)) {
AddIn addin = AddIn.Load(reader);
addinTreeNode = new AddInTreeNode();
addinTreeNode.Codons.Add(new Codon(addin, "CodeCompletionC#", new Properties(), new ICondition[0]));
Properties properties = new Properties();
properties.Set<string>("extensions", " .xml; .xsd ");
properties.Set<string>("id", "Xml");
addinTreeNode.Codons.Add(new Codon(addin, "CodeCompletionXml", properties, new ICondition[0]));
}
}
[Test]
public void ExpectedFileExtensions()
{
string[] expectedExtension = new string[] { ".xml", ".xsd" };
Assert.AreEqual(expectedExtension, XmlDisplayBinding.GetXmlFileExtensions(addinTreeNode));
}
}
}

2
src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj

@ -75,6 +75,7 @@ @@ -75,6 +75,7 @@
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Completion\FirstCompletionListItemSelectedTestFixture.cs" />
<Compile Include="Completion\ProcessKeyTests.cs" />
<Compile Include="Editor\XmlEditorFileExtensionsTestFixture.cs" />
<Compile Include="Parser\XamlMixedNamespaceTestFixture.cs" />
<Compile Include="Paths\QualifiedNameToStringTests.cs" />
<Compile Include="Schema\SingleElementSchemaTestFixture.cs" />
@ -205,6 +206,7 @@ @@ -205,6 +206,7 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Completion" />
<Folder Include="Editor" />
<Folder Include="Schema\" />
<Folder Include="Parser\" />
<Folder Include="Paths\" />

Loading…
Cancel
Save