예제 #1
0
        internal void AddBase(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. class for class, interface for interface).
            if (
                CodeModelInterop.CanChangedVariantType(@base, VarEnum.VT_UNKNOWN) &&
                !CodeModelService.IsValidBaseType(node, typeSymbol)
                )
            {
                throw Exceptions.ThrowEInvalidArg();
            }

            var realPosition = GetRealPosition(position);

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

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