diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Parser/Parser.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Parser/Parser.cs
index bbad1ed6bc..fb83fe1701 100644
--- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Parser/Parser.cs
+++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Parser/Parser.cs
@@ -98,16 +98,21 @@ namespace CSharpBinding.Parser
if (index > -1) {
if (document == null)
document = new ReadOnlyDocument(fileContent);
- int startOffset = document.GetOffset(comment.StartLocation);
int commentSignLength = comment.CommentType == CommentType.Documentation || comment.CommentType == CommentType.MultiLineDocumentation ? 3 : 2;
int commentEndSignLength = comment.CommentType == CommentType.MultiLine || comment.CommentType == CommentType.MultiLineDocumentation ? 2 : 0;
+ int commentStartOffset = document.GetOffset(comment.StartLocation) + commentSignLength;
+ int commentEndOffset = document.GetOffset(comment.EndLocation) - commentEndSignLength;
do {
- int absoluteOffset = startOffset + index + commentSignLength;
+ int absoluteOffset = commentStartOffset + index;
var startLocation = document.GetLocation(absoluteOffset);
- int endOffset = Math.Min(document.GetLineByNumber(startLocation.Line).EndOffset, document.GetOffset(comment.EndLocation) - commentEndSignLength);
+ int endOffset = Math.Min(document.GetLineByNumber(startLocation.Line).EndOffset, commentEndOffset);
string content = document.GetText(absoluteOffset, endOffset - absoluteOffset);
+ if (content.Length < matchLength) {
+ // HACK: workaround parser bug with multi-line documentation comments
+ break;
+ }
tagComments.Add(new TagComment(content.Substring(0, matchLength), new DomRegion(cu.FileName, startLocation.Line, startLocation.Column), content.Substring(matchLength)));
- index = comment.Content.IndexOfAny(TaskListTokens, endOffset - startOffset - commentSignLength, out matchLength);
+ index = comment.Content.IndexOfAny(TaskListTokens, endOffset - commentStartOffset, out matchLength);
} while (index > -1);
}
}
diff --git a/src/Main/Core/Project/Src/Services/StringParser/StringParser.cs b/src/Main/Core/Project/Src/Services/StringParser/StringParser.cs
index 5b746d6542..b7919609d9 100644
--- a/src/Main/Core/Project/Src/Services/StringParser/StringParser.cs
+++ b/src/Main/Core/Project/Src/Services/StringParser/StringParser.cs
@@ -118,23 +118,6 @@ namespace ICSharpCode.Core
return output.ToString();
}
- ///
- /// For new code, please use the overload taking StringTagPair[]!
- ///
- [Obsolete("Please use the overload taking StringTagPair[]!")]
- public static string Parse(string input, string[,] customTags)
- {
- if (customTags == null)
- return Parse(input);
- if (customTags.GetLength(1) != 2)
- throw new ArgumentException("incorrect dimension");
- StringTagPair[] pairs = new StringTagPair[customTags.GetLength(0)];
- for (int i = 0; i < pairs.Length; i++) {
- pairs[i] = new StringTagPair(customTags[i, 0], customTags[i, 1]);
- }
- return Parse(input, pairs);
- }
-
///
/// Evaluates a property using the StringParser. Equivalent to StringParser.Parse("${" + propertyName + "}");
///
diff --git a/src/Main/SharpDevelop/Parser/ParserServiceEntry.cs b/src/Main/SharpDevelop/Parser/ParserServiceEntry.cs
index 8890eeba38..d95d701d09 100644
--- a/src/Main/SharpDevelop/Parser/ParserServiceEntry.cs
+++ b/src/Main/SharpDevelop/Parser/ParserServiceEntry.cs
@@ -195,7 +195,7 @@ namespace ICSharpCode.SharpDevelop.Parser
if (versionComparison > 0 || index < 0) {
// We're going backwards in time, or are requesting a project that is not an owner
// for this entry.
- var parseInfo = parser.Parse(fileName, fileContent, fullParseInformationRequested, parentProject, cancellationToken);
+ var parseInfo = ParseWithExceptionHandling(fileContent, fullParseInformationRequested, parentProject, cancellationToken);
FreezableHelper.Freeze(parseInfo.ParsedFile);
return new ProjectEntry(parentProject, parseInfo.ParsedFile, parseInfo);
} else {
@@ -210,13 +210,7 @@ namespace ICSharpCode.SharpDevelop.Parser
ParseInformationEventArgs[] results = new ParseInformationEventArgs[entries.Count];
for (int i = 0; i < entries.Count; i++) {
- ParseInformation parseInfo;
- try {
- parseInfo = parser.Parse(fileName, fileContent, fullParseInformationRequested, entries[i].Project, cancellationToken);
- } catch (Exception ex) {
- SD.LoggingService.Error("Got " + ex.GetType().Name + " while parsing " + fileName);
- throw;
- }
+ var parseInfo = ParseWithExceptionHandling(fileContent, fullParseInformationRequested, entries[i].Project, cancellationToken);
if (parseInfo == null)
throw new NullReferenceException(parser.GetType().Name + ".Parse() returned null");
if (fullParseInformationRequested && !parseInfo.IsFullParseInformation)
@@ -244,6 +238,20 @@ namespace ICSharpCode.SharpDevelop.Parser
parserService.RegisterForCacheExpiry(this);
return result;
}
+
+ ParseInformation ParseWithExceptionHandling(ITextSource fileContent, bool fullParseInformationRequested, IProject project, CancellationToken cancellationToken)
+ {
+ #if DEBUG
+ if (Debugger.IsAttached)
+ return parser.Parse(fileName, fileContent, fullParseInformationRequested, project, cancellationToken);
+ #endif
+ try {
+ return parser.Parse(fileName, fileContent, fullParseInformationRequested, project, cancellationToken);
+ } catch (Exception ex) {
+ SD.LoggingService.Error("Got " + ex.GetType().Name + " while parsing " + fileName);
+ throw;
+ }
+ }
#endregion
#region ParseAsync