예제 #1
0
        protected override bool TryGetItemByName(string name, out EnvDTE.CodeElement element)
        {
            var node          = LookupNode();
            var parentElement = !IsRootNamespace
                ? (AbstractCodeElement)Parent
                : null;

            // Option statements
            foreach (var child in CodeModelService.GetOptionNodes(node))
            {
                string childName;
                int    ordinal;
                CodeModelService.GetOptionNameAndOrdinal(node, child, out childName, out ordinal);
                if (childName == name)
                {
                    element = CodeOptionsStatement.Create(State, FileCodeModel, childName, ordinal);
                    return(true);
                }
            }

            // Imports/using statements
            foreach (var child in CodeModelService.GetImportNodes(node))
            {
                var childName = CodeModelService.GetImportNamespaceOrType(child);
                if (childName == name)
                {
                    element = CodeImport.Create(State, FileCodeModel, parentElement, childName);
                    return(true);
                }
            }

            // Attributes
            foreach (var child in CodeModelService.GetAttributeNodes(node))
            {
                string childName;
                int    ordinal;
                CodeModelService.GetAttributeNameAndOrdinal(node, child, out childName, out ordinal);
                if (childName == name)
                {
                    element = (EnvDTE.CodeElement)CodeAttribute.Create(State, FileCodeModel, parentElement, childName, ordinal);
                    return(true);
                }
            }

            // Members
            foreach (var child in CodeModelService.GetLogicalSupportedMemberNodes(node))
            {
                var childName = CodeModelService.GetName(child);
                if (childName == name)
                {
                    element = FileCodeModel.CreateCodeElement <EnvDTE.CodeElement>(child);
                    return(true);
                }
            }

            element = null;
            return(false);
        }
예제 #2
0
        private EnvDTE.CodeElement CreateCodeImport(
            SyntaxNode node,
            AbstractCodeElement parentElement
            )
        {
            var name = CodeModelService.GetImportNamespaceOrType(node);

            return(CodeImport.Create(this.State, this.FileCodeModel, parentElement, name));
        }
예제 #3
0
        private EnvDTE.CodeElement CreateCodeImport(SyntaxNode node)
        {
            var name = this.CodeModelService.GetImportNamespaceOrType(node);

            return((EnvDTE.CodeElement)CodeImport.Create(_state, this.FileCodeModel, _parentElement, name));
        }