Пример #1
0
        protected override bool TryGetItemByName(string name, out EnvDTE.CodeElement element)
        {
            if (name != null)
            {
                // When searching by name it may or may not be the fully qualified named,
                // but we need the fully qualified name for comparison.
                var node          = LookupNode();
                var semanticModel = FileCodeModel.GetSemanticModel();

                name = CodeModelService.GetFullyQualifiedName(name, node.SpanStart, semanticModel);
            }

            foreach (var child in GetBaseTypes())
            {
                var childName = child.GetEscapedFullName();
                if (childName == name)
                {
                    var projectId = FileCodeModel.GetProjectId();
                    element = CodeModelService.CreateCodeType(this.State, projectId, child);
                    return(true);
                }
            }

            element = null;
            return(false);
        }
Пример #2
0
        protected virtual object GetParent()
        {
            var symbol = LookupSymbol();

            if (symbol.Kind == SymbolKind.Namespace && ((INamespaceSymbol)symbol).IsGlobalNamespace)
            {
                // TODO: We should be returning the RootCodeModel object here.
                throw new NotImplementedException();
            }

            if (symbol.ContainingType != null)
            {
                return(CodeModelService.CreateCodeType(
                           this.State,
                           this.ProjectId,
                           symbol.ContainingType
                           ));
            }
            else if (symbol.ContainingNamespace != null)
            {
                return(CodeModelService.CreateExternalCodeElement(
                           this.State,
                           this.ProjectId,
                           symbol.ContainingNamespace
                           ));
            }

            throw Exceptions.ThrowEFail();
        }
Пример #3
0
        public EnvDTE.CodeType CodeTypeFromFullName(string name)
        {
            var compilation = GetCompilation();
            var typeSymbol  = CodeModelService.GetTypeSymbolFromFullName(name, compilation);

            if (typeSymbol == null ||
                typeSymbol.TypeKind == TypeKind.Error ||
                typeSymbol.TypeKind == TypeKind.Unknown)
            {
                return(null);
            }

            return((EnvDTE.CodeType)CodeModelService.CreateCodeType(this.State, _projectId, typeSymbol));
        }
Пример #4
0
        protected override bool TryGetItemByIndex(int index, out EnvDTE.CodeElement element)
        {
            var baseTypes = GetBaseTypes();
            if (index < baseTypes.Count())
            {
                var child = baseTypes.ElementAt(index);
                var projectId = FileCodeModel.GetProjectId();
                element = CodeModelService.CreateCodeType(this.State, projectId, child);
                return true;
            }

            element = null;
            return false;
        }