public void PickElement(KType key, ElementProcessor process) { int tempIndex = GetKeyHash(key) % ArrayLength; while (KeysArray[tempIndex] != null) { if (KeysArray[tempIndex].Key.Equals(key) && !KeysArray[tempIndex].WasDeleted) { process(KeysArray[tempIndex].Value); } tempIndex = (tempIndex + GetSecondaryKeyHash(key)) % ArrayLength; } }
public override void Init( AsBaseEntity _entity) { base.Init( _entity); m_InitSize = m_Entity.transform.localScale; m_ElementProcessor = new ElementProcessor( m_Entity); m_Entity.SetConditionCheckDelegate( m_ElementProcessor.GetEnableCondition); m_Entity.SetBuffCheckDelegate( m_ElementProcessor.CheckBuffInclusion); m_Entity.SetTargetShopOpening( TargetShopOpening); gameObject.layer = LayerMask.NameToLayer( "Player"); }
protected override void Run(ICSharpFunctionDeclaration element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer) { if (element.Body == null) { return; } var elementProcessor = new ElementProcessor( element, consumer); element.Body.ProcessDescendants(elementProcessor); var store = data.SettingsStore; var baseThreshold = store.GetValue((CognitiveComplexityAnalysisSettings s) => s.CSharpThreshold); var lowThreshold = store.GetValue((CognitiveComplexityAnalysisSettings s) => s.LowComplexityThreshold); var middleThreshold = store.GetValue((CognitiveComplexityAnalysisSettings s) => s.MiddleComplexityThreshold); var highThreshold = store.GetValue((CognitiveComplexityAnalysisSettings s) => s.HighComplexityThreshold); var complexityPercentage = (int)(elementProcessor.ComplexityScore * 100.0 / baseThreshold); string codeLensText; IconId iconId; if (complexityPercentage >= highThreshold) { iconId = ComplexityExtreme.Id; codeLensText = complexityPercentage >= highThreshold * 2 ? $"refactor me? ({complexityPercentage}%)" : $"very complex ({complexityPercentage}%)"; } else if (complexityPercentage >= middleThreshold) { iconId = ComplexityHigh.Id; codeLensText = $"mildly complex ({complexityPercentage}%)"; } else if (complexityPercentage >= lowThreshold) { iconId = ComplexityAverage.Id; codeLensText = $"simple enough ({complexityPercentage}%)"; } else { iconId = ComplexityLow.Id; codeLensText = string.Empty; } if (complexityPercentage > 100) { consumer.AddHighlighting(new CognitiveComplexityHighlighting(element, complexityPercentage)); } #if RIDER var moreText = $"Cognitive complexity value of {elementProcessor.ComplexityScore} " + $"({complexityPercentage}% of threshold {baseThreshold})"; consumer.AddHighlighting( new CodeInsightsHighlighting( element.GetNameDocumentRange(), codeLensText, moreText, moreText, _overallProvider, element.DeclaredElement, _iconHost.Transform(iconId)) ); #endif }
protected override TypeProcessor <T> CloneCore() => (TypeProcessor <T>)Activator.CreateInstance(GetType(), ElementProcessor.Clone(), Context);
protected virtual T ParseCore(List <string> text) { Console.WriteLine($"***** Parsing {string.Join(", ", text.Select(x => $"<{x}>"))}"); return(ConvertToValue(text.Select(value => (TElement)ElementProcessor.Parse(value)))); }
private void AddProcessor(ElementProcessor p) { Processors.Add(new KeyValuePair <string, ElementProcessor>(p.Tagname, p)); }