public void AddAnchorIndentationOperation(AnchorIndentationOperation operation) { // don't add stuff if it is empty if (operation.TextSpan.IsEmpty || _anchorMap.Contains(operation.TextSpan) || _anchorBaseTokenMap.ContainsKey(operation.AnchorToken)) { return; } // If the indentation changes on a line which other code is anchored to, adjust those other lines to reflect // the same change in indentation. Note that we anchor to the first token on a line to account for common // cases like the following code, where the `{` token is anchored to the `(` token of `()`: // // ↓ this space can be removed, which moves `(` one character to the left // var x = Method( () => // { // ↑ this `{` anchors to `var` instead of `(`, which prevents it from moving when `(` is moved // }); // // The calculation of true anchor token (which is always the first token on a line) is delayed to account // for cases where the original anchor token is moved to a new line during a formatting operation. var anchorToken = _tokenStream.FirstTokenOfBaseTokenLine(operation.AnchorToken); var originalSpace = _tokenStream.GetOriginalColumn(anchorToken); var data = new AnchorData(operation, anchorToken, originalSpace); _anchorTree.AddIntervalInPlace(data); _anchorBaseTokenMap.Add(operation.AnchorToken, data); _anchorMap.Add(operation.TextSpan); }
public void Dictionary_Generic_ContainsValue_DefaultValuePresent(int count) { SegmentedDictionary <TKey, TValue> dictionary = (SegmentedDictionary <TKey, TValue>)GenericIDictionaryFactory(count); int seed = 4315; TKey notPresent = CreateTKey(seed++); while (dictionary.ContainsKey(notPresent)) { notPresent = CreateTKey(seed++); } dictionary.Add(notPresent, default(TValue)); Assert.True(dictionary.ContainsValue(default(TValue))); }
public void AddAnchorIndentationOperation(AnchorIndentationOperation operation) { // don't add stuff if it is empty if (operation.TextSpan.IsEmpty || _anchorMap.Contains(operation.TextSpan) || _anchorBaseTokenMap.ContainsKey(operation.AnchorToken)) { return; } var originalSpace = _tokenStream.GetOriginalColumn(operation.StartToken); var data = new AnchorData(operation, originalSpace); _anchorTree.AddIntervalInPlace(data); _anchorBaseTokenMap.Add(operation.AnchorToken, data); _anchorMap.Add(operation.TextSpan); }
public void Dictionary_Generic_RemoveKey_DefaultKeyNotContainedInDictionary(int count) { SegmentedDictionary <TKey, TValue> dictionary = (SegmentedDictionary <TKey, TValue>)GenericIDictionaryFactory(count); TValue outValue; if (DefaultValueAllowed) { TKey missingKey = default(TKey); while (dictionary.ContainsKey(missingKey)) { dictionary.Remove(missingKey); } Assert.False(dictionary.Remove(missingKey, out outValue)); Assert.Equal(default(TValue), outValue); } else { TValue initValue = CreateTValue(count); outValue = initValue; Assert.Throws <ArgumentNullException>(() => dictionary.Remove(default(TKey), out outValue)); Assert.Equal(initValue, outValue); } }