Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorMike Krüger <mikkrg@microsoft.com>2018-07-05 20:05:17 +0300
committerMike Krüger <mikkrg@microsoft.com>2018-07-05 20:11:59 +0300
commit027d50f4bff601c428dfb6a8c44dbb2719ef7afa (patch)
treeb3b0b7c4f17d4a0a1c5a18b95fef8b7e5e325e00 /main
parentdf7a7034f7012b45edfc694dbe7c89b5578fd07b (diff)
[Ide] Fixed failing unit test.
Diffstat (limited to 'main')
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/SyntaxHighlightingService.cs26
-rw-r--r--main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/SyntaxHighlightingTests.cs13
2 files changed, 26 insertions, 13 deletions
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 0b4484116e..a1989f6bf0 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
@@ -399,18 +399,9 @@ namespace MonoDevelop.Ide.Editor.Highlighting
if (readFileTypes && fileTypesEndRegex.Match (line).Success)
break;
if (readFileTypes) {
- line = line.Trim ();
- if (line.Length > 3 && line[0] == '"' && line[line.Length - 1] == '"') {
- int start = 1;
-
- // the . is optional, some extensions mention it and some don't
- if (line[1] == '.') {
- start = 2;
- }
-
- string fileType = line.Substring (start, line.Length - start - 1);
+ string fileType = ParseFileType (line);
+ if (!string.IsNullOrEmpty(fileType))
fileTypes.Add (fileType);
- }
}
}
if (fileTypes == null)
@@ -426,6 +417,19 @@ namespace MonoDevelop.Ide.Editor.Highlighting
return false;
}
+ internal static string ParseFileType (string line)
+ {
+ var idx1 = line.IndexOf ('"');
+ var idx2 = line.LastIndexOf ('"');
+ if (idx1 < 0 || idx1 + 1 >= idx2)
+ return null;
+ // the . is optional, some extensions mention it and some don't
+ if (line [idx1 + 1] == '.')
+ idx1++;
+ idx1++; // skip "
+ return line.Substring (idx1, idx2 - idx1);
+
+ }
static bool TryScanTextMateSyntax (Stream stream, out List<string> fileTypes, out string name, out string scopeName)
{
fileTypes = null;
diff --git a/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/SyntaxHighlightingTests.cs b/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/SyntaxHighlightingTests.cs
index 62ef8d5c2a..32dbcb1a0c 100644
--- a/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/SyntaxHighlightingTests.cs
+++ b/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/SyntaxHighlightingTests.cs
@@ -120,7 +120,6 @@ namespace Mono.TextEditor.Tests
}
[Test]
- [Ignore("FIXME")] // https://github.com/mono/monodevelop/issues/5322
public void TestCDATASection ()
{
TestOutput ("<![CDATA[ test]]>",
@@ -213,6 +212,16 @@ namespace Mono.TextEditor.Tests
TestOutput ("$\"{foo}\"",
"<span foreground=\"#e5da73\">$\"{</span><span foreground=\"#eeeeec\">foo</span><span foreground=\"#e5da73\">}\"</span>");
}
-
+ [Test]
+ public void ParseFileTypeTest ()
+ {
+ Assert.AreEqual ("xml", SyntaxHighlightingService.ParseFileType ("\"xml\""));
+ Assert.AreEqual ("xml", SyntaxHighlightingService.ParseFileType ("\".xml\""));
+ Assert.AreEqual ("xml", SyntaxHighlightingService.ParseFileType ("\"xml\","));
+ Assert.AreEqual ("xml", SyntaxHighlightingService.ParseFileType ("\".xml\","));
+ Assert.IsTrue (string.IsNullOrEmpty (SyntaxHighlightingService.ParseFileType ("\"\",")));
+ Assert.IsTrue (string.IsNullOrEmpty (SyntaxHighlightingService.ParseFileType ("\".\",")));
+ Assert.IsTrue (string.IsNullOrEmpty (SyntaxHighlightingService.ParseFileType ("}")));
+ }
}
}