public CurrentUsersDataPointV15(CurrentUsersDataPointV15Updater dataPointUpdater, IWorkspaceUpdateManager workspaceUpdateManager, ICodeElementDescriptor codeElementDescriptor) { DataPointUpdater = dataPointUpdater; CodeElementDescriptor = codeElementDescriptor; WorkspaceUpdateManager = workspaceUpdateManager; WorkspaceChangedTask = WorkspaceUpdateManager?.AddWorkspaceChangedAsync(OnWorkspaceChanged); }
public ConflictDataPoint(EditingSession editingSession, ICodeElementDescriptor methodIdentifier) { if (editingSession == null) { throw new ArgumentNullException("editingSession"); } this.MethodIdentifier = methodIdentifier; this.EditingSession = editingSession; EditingSession.ConflictDataChanged += this.OnConflictDataChanged; }
public Task <string> GetTextForDataPoint(ICodeElementDescriptor codeElementDescriptor) { if (CodeElementDescriptorToDataPointString.ContainsKey(codeElementDescriptor)) { return(Task.FromResult(CodeElementDescriptorToDataPointString[codeElementDescriptor])); } else { var result = GetTextForDataPointInternal(codeElementDescriptor); CodeElementDescriptorToDataPointString.Add(codeElementDescriptor, result); return(Task.FromResult(result)); } }
public ICodeLensDataPoint CreateDataPoint(ICodeLensDescriptor descriptor) { if (serviceProvider == null) { return(null); } ICodeElementDescriptor codeElement = descriptor as ICodeElementDescriptor; string filePath = codeElement.FilePath; EditingSession editingSession = EditingSessionFactory.WaitForSession(filePath); return(new ConflictDataPoint(editingSession, codeElement)); }
public Task <string> GetTextForDataPoint(ICodeElementDescriptor codeElementDescriptor) { if (_codeElementDescriptorToDataPointString.ContainsKey(codeElementDescriptor)) { return(Task.FromResult(_codeElementDescriptorToDataPointString[codeElementDescriptor])); } var cmc = new CodeMetricCalculator(); var result = cmc.Calculate(codeElementDescriptor.SyntaxNode); var metricMsg = $"LOC: {result.LineOfCode}, CC: {result.CyclomaticComplexity}, MI: {result.MaintainabilityIndex:###}"; _codeElementDescriptorToDataPointString.Add(codeElementDescriptor, metricMsg); return(Task.FromResult(metricMsg)); }
public Task <string> GetTextForDataPoint(ICodeElementDescriptor codeElementDescriptor) { foreach (var caret in CaretMemberHashCodeToDataPointString.Keys) { var node = codeElementDescriptor.SyntaxNode; // Find the first node that we start the node chain from (any node that is tracked; a class or member declaration etc) var syntaxNodeChain = node.AncestorsAndSelf().ToArray(); var trackedLeafNodes = syntaxNodeChain.Where(n => n.IsUniquelyIdentifiedNode()).Reverse().ToArray(); var foundMatch = false; for (int i = 0; i < trackedLeafNodes.Length; i++) { var matchedLeafNode = trackedLeafNodes[i]; var caretMatchedHashIndex = Array.LastIndexOf(caret, matchedLeafNode.GetValueBasedHashCode()); if (caretMatchedHashIndex == -1) { foundMatch = false; continue; } // Now walk up the tree from the matching one, and up the method hashes ensuring we match all the way up var nodeancestorhashes = matchedLeafNode.AncestorsAndSelf().Select(a => a.GetValueBasedHashCode()); if (nodeancestorhashes.SequenceEqual(caret.Take(caretMatchedHashIndex + 1).Reverse())) { foundMatch = true; } else { foundMatch = false; } } if (foundMatch) { return(Task.FromResult(CaretMemberHashCodeToDataPointString[caret])); } } return(Task.FromResult <string>(null)); }
public CodeHealthDataPoint(ICodeElementDescriptor descriptor) { descriptor.SyntaxNodeContentsChanged += OnMethodBodyChanged; this.descriptor = descriptor; }