Exemplo n.º 1
0
            private string GetText(IMethodDeclaration methodDeclaration, MethodSignature signature)
            {
                var language        = methodDeclaration.Language;
                var declaredElement = methodDeclaration.DeclaredElement;

                Assertion.AssertNotNull(declaredElement, "declaredElement != null");
                var methodName = DeclaredElementPresenter.Format(language, DeclaredElementPresenter.NAME_PRESENTER,
                                                                 declaredElement);

                switch (myMatch)
                {
                case MethodSignatureMatch.IncorrectStaticModifier:
                {
                    var staticTerm = PresentationHelper.GetHelper(language).GetStaticTerm();
                    return(signature.IsStatic == true ? $"Make '{methodName}' {staticTerm}" : $"Remove '{staticTerm}' modifier");
                }

                case MethodSignatureMatch.IncorrectParameters:
                    return($"Change parameters to '({signature.Parameters.GetParameterList()})'");

                case MethodSignatureMatch.IncorrectReturnType:
                    return($"Change return type to '{signature.GetReturnTypeName()}'");

                case MethodSignatureMatch.IncorrectTypeParameters:
                    return("Remove type parameters");

                // NoMatch, and any combination of flags
                default:
                    return($"Change signature to '{signature.FormatSignature(methodName.Text)}'");
                }
            }
Exemplo n.º 2
0
        public IncorrectMethodSignatureQuickFix(InvalidStaticModifierWarning warning)
            : this(warning.MethodDeclaration, warning.ExpectedMethodSignature,
                   MethodSignatureMatch.IncorrectStaticModifier)
        {
            var language   = myMethodDeclaration.Language;
            var staticTerm = PresentationHelper.GetHelper(language).GetStaticTerm();

            if (myExpectedMethodSignature.IsStatic == true)
            {
                var declaredElement = myMethodDeclaration.DeclaredElement;
                Assertion.AssertNotNull(declaredElement, "declaredElement != null");
                var methodName = DeclaredElementPresenter.Format(language, DeclaredElementPresenter.NAME_PRESENTER,
                                                                 declaredElement);
                Text = $"Make '{methodName}' {staticTerm}";
            }
            else
            {
                Text = $"Remove '{staticTerm}' modifier";
            }
        }