public PerformanceAnalysisDisableByCommentQuickFix(UnityPerformanceInvocationWarning performanceHighlighting) { var range = performanceHighlighting.CalculateRange(); var document = range.Document; var solution = document.TryGetSolution(); if (solution == null) { return; } var psiSourceFile = document.GetPsiSourceFile(solution); var file = psiSourceFile?.GetTheOnlyPsiFile(CSharpLanguage.Instance); if (file == null) { return; } var node = file.FindNodeAt(range); myMethodDeclaration = node?.GetContainingNode <IMethodDeclaration>(); if (myMethodDeclaration != null) { myBulbAction = new PerformanceAnalysisDisableByCommentBulbAction(myMethodDeclaration); } }
public IEnumerable <IntentionAction> CreateBulbItems() { var identifier = myDataProvider.GetSelectedElement <ITreeNode>() as ICSharpIdentifier; var methodDeclaration = MethodDeclarationNavigator.GetByNameIdentifier(identifier); if (methodDeclaration == null) { return(EmptyList <IntentionAction> .Instance); } if (!UnityCallGraphUtil.IsSweaCompleted(mySwa)) { return(EmptyList <IntentionAction> .Instance); } var bulbAction = new PerformanceAnalysisDisableByCommentBulbAction(methodDeclaration); var processKind = UnityCallGraphUtil.GetProcessKindForGraph(mySwa); var isExpensiveContext = myExpensiveContextProvider.HasContext(methodDeclaration, processKind); var isPerformanceContext = myPerformanceContextProvider.HasContext(methodDeclaration, processKind); if (isExpensiveContext || isPerformanceContext) { return(bulbAction.ToContextActionIntentions()); } return(EmptyList <IntentionAction> .Instance); }