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); }
private EnvDTE.CodeElement CreateCodeOptionsStatement(SyntaxNode node, SyntaxNode parentNode) { string name; int ordinal; CodeModelService.GetOptionNameAndOrdinal(parentNode, node, out name, out ordinal); return(CodeOptionsStatement.Create(this.State, this.FileCodeModel, name, ordinal)); }