コード例 #1
0
 public DictionaryContainsKeyFix(DictionaryContainsKeyWarning warning)
 {
     _statement        = warning.Statement;
     _matchedElement   = warning.MatchedElement;
     _dictionaryAccess = warning.DictionaryAccess;
     _dictionary       = warning.Dictionary;
     _key = warning.Key;
 }
コード例 #2
0
 public DictionaryContainsKeyFix(DictionaryContainsKeyWarning warning)
 {
     _statement = warning.Statement;
     _matchedElement = warning.MatchedElement;
     _dictionaryAccess = warning.DictionaryAccess;
     _dictionary = warning.Dictionary;
     _key = warning.Key;
 }
        protected override void Run(IIfStatement element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
        {
            foreach (var result in patterns.GetMatchingContainsKey(element.Condition))
            {
                var matchedElement = result.MatchedElement;
                var dictionary     = result.GetMatchedElement("dictionary");
                var key            = result.GetMatchedElement("key");

                var dictionaryAccess = patterns.GetMatchingDictionaryAccess(element, dictionary, key);
                if (dictionaryAccess.Length > 0)
                {
                    var highlighting = new DictionaryContainsKeyWarning(element, dictionaryAccess, matchedElement, key, (IExpression)dictionary);
                    consumer.AddHighlighting(highlighting, matchedElement.GetHighlightingRange());
                    foreach (var treeNode in dictionaryAccess)
                    {
                        consumer.AddHighlighting(highlighting, treeNode.GetHighlightingRange());
                    }
                }
            }
        }