Example #1
0
        internal string AddImplementedInterface(
            SyntaxNode node,
            object @base,
            object position = null
            )
        {
            var semanticModel = GetSemanticModel();
            var typeSymbol    = CodeModelService.GetTypeSymbol(@base, semanticModel, node.SpanStart);

            // If a CodeType or CodeTypeRef was specified, we need to verify that a
            // valid base type was specified (i.e. an interface for a struct or class).
            if (
                CodeModelInterop.CanChangedVariantType(@base, VarEnum.VT_UNKNOWN) &&
                !CodeModelService.IsValidInterfaceType(node, typeSymbol)
                )
            {
                throw Exceptions.ThrowEInvalidArg();
            }

            var realPosition = GetRealPosition(position);

            var updatedNode = CodeModelService.AddImplementedInterface(
                node,
                typeSymbol,
                semanticModel,
                realPosition
                );

            if (node != updatedNode)
            {
                UpdateNode(node, updatedNode);
            }

            return(typeSymbol.Name);
        }