From cbd0f63e0381786859eb9ee126277d0438f74b85 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Tue, 9 Mar 2010 20:22:33 +0000 Subject: [PATCH] Python syntax highlighter now highlights docstrings using triple single quotes. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@5593 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Resources/Python.xshd | 15 +++-- .../Test/PythonSyntaxModeTestFixture.cs | 62 +++++++++++++++++++ 2 files changed, 72 insertions(+), 5 deletions(-) diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Resources/Python.xshd b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Resources/Python.xshd index cbcdd8faad..c7dc7234d8 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Resources/Python.xshd +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Resources/Python.xshd @@ -11,16 +11,16 @@ ()[]{}@,:.`=;+-*/% &|^>< - - ' - ' - - """ """ + + ''' + ''' + + # @@ -30,6 +30,11 @@ " + + ' + ' + + ( diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonSyntaxModeTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonSyntaxModeTestFixture.cs index 6f30b7d31b..14ea9244f3 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonSyntaxModeTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonSyntaxModeTestFixture.cs @@ -34,6 +34,7 @@ namespace PythonBinding.Tests Span stringSpan; Span charSpan; Span docCommentSpan; + Span singleQuoteDocCommentSpan; const string SyntaxModePath = "/SharpDevelop/ViewContent/DefaultTextEditor/SyntaxModes"; XmlElement importsKeyWordsElement; XmlElement iterationStatementsKeyWordsElement; @@ -139,6 +140,8 @@ namespace PythonBinding.Tests charSpan = s; } else if (s.Name == "DocComment") { docCommentSpan = s; + } else if (s.Name == "SingleQuoteDocComment") { + singleQuoteDocCommentSpan = s; } } } @@ -246,6 +249,65 @@ namespace PythonBinding.Tests Assert.AreEqual(expectedColor.ToString(), docCommentSpan.Color.ToString()); } + [Test] + public void DocCommentSpanOccursBeforeStringSpan() + { + Assert.IsTrue(SpanOccursBefore("DocComment", "String")); + } + + bool SpanOccursBefore(string before, string after) + { + int beforeIndex = -1; + int afterIndex = -1; + + for (int i = 0; i < defaultRuleSet.Spans.Count; ++i) { + Span span = (Span)defaultRuleSet.Spans[i]; + if (span.Name == before) { + beforeIndex = i; + } else if (span.Name == after) { + afterIndex = i; + } + } + + Assert.AreNotEqual(-1, beforeIndex); + Assert.AreNotEqual(-1, afterIndex); + + return beforeIndex < afterIndex; + } + + [Test] + public void SingleQuoteDocCommentStopAtEndOfLine() + { + Assert.IsFalse(singleQuoteDocCommentSpan.StopEOL); + } + + [Test] + public void SingleQuoteDocCommentBegin() + { + char[] begin = new char[] {'\'', '\'', '\''}; + Assert.AreEqual(begin, singleQuoteDocCommentSpan.Begin); + } + + [Test] + public void SingleQuoteDocCommentEnd() + { + char[] begin = new char[] {'\'', '\'', '\''}; + Assert.AreEqual(begin, singleQuoteDocCommentSpan.End); + } + + [Test] + public void SingleQuoteDocCommentSpanColor() + { + HighlightColor expectedColor = new HighlightColor(Color.Green, false, false); + Assert.AreEqual(expectedColor.ToString(), singleQuoteDocCommentSpan.Color.ToString()); + } + + [Test] + public void SingleQuoteDocCommentSpanOccursBeforeCharSpan() + { + Assert.IsTrue(SpanOccursBefore("DocComment", "Char")); + } + [Test] public void ImportsKeyWordsExist() {