Beispiel #1
0
 public static ImplementInterfaceCodeAction CreateImplementRemainingExplicitlyCodeAction(
     AbstractImplementInterfaceService service,
     Document document,
     State state)
 {
     return(new ImplementInterfaceCodeAction(service, document, state, explicitly: true, abstractly: false, onlyRemaining: true, throughMember: null));
 }
 public static ImplementInterfaceCodeAction CreateImplementExplicitlyCodeAction(
     AbstractImplementInterfaceService service,
     Document document,
     State state)
 {
     return new ImplementInterfaceCodeAction(service, document, state, explicitly: true, abstractly: false, throughMember: null);
 }
Beispiel #3
0
 public static ImplementInterfaceWithDisposePatternCodeAction CreateImplementExplicitlyWithDisposePatternCodeAction(
     AbstractImplementInterfaceService service,
     Document document,
     State state)
 {
     return(new ImplementInterfaceWithDisposePatternCodeAction(service, document, state, explicitly: true, abstractly: false, throughMember: null));
 }
 internal ImplementInterfaceCodeAction(
     AbstractImplementInterfaceService service,
     Document document,
     State state,
     bool explicitly,
     bool abstractly,
     bool onlyRemaining,
     ISymbol throughMember
     )
 {
     Service         = service;
     Document        = document;
     State           = state;
     Abstractly      = abstractly;
     _onlyRemaining  = onlyRemaining;
     Explicitly      = explicitly;
     ThroughMember   = throughMember;
     _equivalenceKey = ComputeEquivalenceKey(
         state,
         explicitly,
         abstractly,
         onlyRemaining,
         throughMember,
         GetType().FullName
         );
 }
Beispiel #5
0
 public static ImplementInterfaceCodeAction CreateImplementThroughMemberCodeAction(
     AbstractImplementInterfaceService service,
     Document document,
     State state,
     ISymbol throughMember)
 {
     return(new ImplementInterfaceCodeAction(service, document, state, explicitly: false, abstractly: false, onlyRemaining: false, throughMember: throughMember));
 }
 public static ImplementInterfaceCodeAction CreateImplementThroughMemberCodeAction(
     AbstractImplementInterfaceService service,
     Document document,
     State state,
     ISymbol throughMember)
 {
     return new ImplementInterfaceCodeAction(service, document, state, explicitly: false, abstractly: false, throughMember: throughMember);
 }
Beispiel #7
0
 internal ImplementInterfaceWithDisposePatternCodeAction(
     AbstractImplementInterfaceService service,
     Document document,
     State state,
     bool explicitly,
     bool abstractly,
     ISymbol throughMember) : base(service, document, state, explicitly, abstractly, throughMember)
 {
 }
 internal ImplementInterfaceWithDisposePatternCodeAction(
     AbstractImplementInterfaceService service,
     Document document,
     State state,
     bool explicitly,
     bool abstractly,
     ISymbol throughMember) : base(service, document, state, explicitly, abstractly, throughMember)
 {
 }
Beispiel #9
0
 internal ImplementInterfaceCodeAction(
     AbstractImplementInterfaceService service,
     Document document,
     State state,
     bool explicitly,
     bool abstractly,
     ISymbol throughMember)
 {
     this.Service       = service;
     this.Document      = document;
     this.State         = state;
     this.Abstractly    = abstractly;
     this.Explicitly    = explicitly;
     this.ThroughMember = throughMember;
     _equivalenceKey    = ComputeEquivalenceKey(state, explicitly, abstractly, throughMember, this.GetType().FullName);
 }
 internal ImplementInterfaceCodeAction(
     AbstractImplementInterfaceService service,
     Document document,
     State state,
     bool explicitly,
     bool abstractly,
     ISymbol throughMember)
 {
     this.Service = service;
     this.Document = document;
     this.State = state;
     this.Abstractly = abstractly;
     this.Explicitly = explicitly;
     this.ThroughMember = throughMember;
     _equivalenceKey = ComputeEquivalenceKey(state, explicitly, abstractly, throughMember, this.GetType().FullName);
 }
Beispiel #11
0
            public static State Generate(
                AbstractImplementInterfaceService service,
                Document document,
                SemanticModel model,
                SyntaxNode interfaceNode,
                CancellationToken cancellationToken)
            {
                SyntaxNode       classOrStructDecl;
                INamedTypeSymbol classOrStructType;
                IEnumerable <INamedTypeSymbol> interfaceTypes;

                if (!service.TryInitializeState(document, model, interfaceNode, cancellationToken,
                                                out classOrStructDecl, out classOrStructType, out interfaceTypes))
                {
                    return(null);
                }

                if (!CodeGenerator.CanAdd(document.Project.Solution, classOrStructType, cancellationToken))
                {
                    return(null);
                }

                var state = new State(interfaceNode, classOrStructDecl, classOrStructType, interfaceTypes, model);

                if (service.CanImplementImplicitly)
                {
                    state.UnimplementedMembers = state.ClassOrStructType.GetAllUnimplementedMembers(
                        interfaceTypes, cancellationToken);

                    state.UnimplementedExplicitMembers = state.ClassOrStructType.GetAllUnimplementedExplicitMembers(
                        interfaceTypes, cancellationToken);

                    var allMembersImplemented           = state.UnimplementedMembers == null || state.UnimplementedMembers.Count == 0;
                    var allMembersImplementedExplicitly = state.UnimplementedExplicitMembers == null || state.UnimplementedExplicitMembers.Count == 0;

                    return(!allMembersImplementedExplicitly && !allMembersImplemented ? state : null);
                }
                else
                {
                    state.UnimplementedMembers = state.ClassOrStructType.GetAllUnimplementedExplicitMembers(
                        interfaceTypes, cancellationToken);

                    var allMembersImplemented = state.UnimplementedMembers == null || state.UnimplementedMembers.Count == 0;
                    return(!allMembersImplemented ? state : null);
                }
            }
            public static State Generate(
                AbstractImplementInterfaceService service,
                Document document,
                SemanticModel model,
                SyntaxNode interfaceNode,
                CancellationToken cancellationToken)
            {
                SyntaxNode classOrStructDecl;
                INamedTypeSymbol classOrStructType;
                IEnumerable<INamedTypeSymbol> interfaceTypes;
                if (!service.TryInitializeState(document, model, interfaceNode, cancellationToken,
                    out classOrStructDecl, out classOrStructType, out interfaceTypes))
                {
                    return null;
                }

                if (!CodeGenerator.CanAdd(document.Project.Solution, classOrStructType, cancellationToken))
                {
                    return null;
                }

                var state = new State(interfaceNode, classOrStructDecl, classOrStructType, interfaceTypes, model);

                if (service.CanImplementImplicitly)
                {
                    state.UnimplementedMembers = state.ClassOrStructType.GetAllUnimplementedMembers(
                        interfaceTypes, cancellationToken);

                    state.UnimplementedExplicitMembers = state.ClassOrStructType.GetAllUnimplementedExplicitMembers(
                        interfaceTypes, cancellationToken);

                    var allMembersImplemented = state.UnimplementedMembers == null || state.UnimplementedMembers.Count == 0;
                    var allMembersImplementedExplicitly = state.UnimplementedExplicitMembers == null || state.UnimplementedExplicitMembers.Count == 0;

                    return !allMembersImplementedExplicitly && !allMembersImplemented ? state : null;
                }
                else
                {
                    state.UnimplementedMembers = state.ClassOrStructType.GetAllUnimplementedExplicitMembers(
                        interfaceTypes, cancellationToken);

                    var allMembersImplemented = state.UnimplementedMembers == null || state.UnimplementedMembers.Count == 0;
                    return !allMembersImplemented ? state : null;
                }
            }