private static Dictionary<string, List<DocumentRange>> GetDocumentRangesDictionary(this ITreeNode @this)
{
var fields = new Dictionary<string, List<DocumentRange>>();
// NOTE: The expression 'field' pattern.
const string FieldPattern = "/[*]([^*]+?)[*]/";
var regex = new Regex(FieldPattern, RegexOptions.IgnorePatternWhitespace);
string noteText = @this.GetText();
MatchCollection commentMatchCollection = regex.Matches(noteText);
foreach (Match match in commentMatchCollection)
{
string fieldName = match.Groups[1].Value;
if (!fields.ContainsKey(fieldName))
{
fields.Add(fieldName, new List<DocumentRange>());
}
int startOffSet = @this.GetTreeStartOffset().Offset + match.Index;
int endOffSet = startOffSet + match.Length;
const string TypeOfValueExpressionPattern = "typeof[(]\\s" + FieldPattern + "[)]";
if (Regex.IsMatch(noteText, TypeOfValueExpressionPattern))
{
// PATCH: When "typeof(/*Value*/)" is introduced the editor overreact and convert it to "typeof( /*Value*/)", note the awkward space, so...
startOffSet--;
}
fields[fieldName].Add(@this.GetDocumentRange().SetStartTo(startOffSet).SetEndTo(endOffSet));
}
return fields;
}
public static Dictionary<string, List<DocumentRange>> GetFields(this ITreeNode @this)