Example #1
0
        private EnvDTE.CodeElement GetAttributeArgumentForCodeModelEvent(CodeModelEvent codeModelEvent, EnvDTE.CodeElements parentAttributeArguments, object parentElement)
        {
            if (parentAttributeArguments == null)
            {
                return(null);
            }

            SyntaxNode attributeNode;
            int        ordinal;

            CodeModelService.GetAttributeArgumentParentAndIndex(codeModelEvent.Node, out attributeNode, out ordinal);

            if (codeModelEvent.Type == CodeModelEventType.Remove)
            {
                var parentCodeElement = ComAggregate.TryGetManagedObject <CodeAttribute>(parentElement);
                if (parentCodeElement != null)
                {
                    return((EnvDTE.CodeElement)CodeAttributeArgument.Create(this.State, parentCodeElement, ordinal));
                }
            }
            else
            {
                return(parentAttributeArguments.Item(ordinal + 1)); // Needs to be 1-based to call back into code model
            }

            return(null);
        }