Beispiel #1
0
        public ISet <CSharpType> GetDerivedTypes(CSharpTypeIdentifier typeId)
        {
            ISet <CSharpType> result = new HashSet <CSharpType>();

            foreach (Compilation compilation in AllProjects)
            {
                CSharpType baseType = compilation.ResolveTypeIdentifier(typeId);
                if (baseType == null)
                {
                    continue;
                }

                BaseTypeCollector collector = baseType.IsInterface ? GetBaseInterfaceCollector() : GetBaseClassCollector();
                foreach (CSharpType type in compilation.MainAssembly.Types)
                {
                    // an interface can't be derived from a class
                    if (type.IsInterface && !baseType.IsInterface)
                    {
                        continue;
                    }

                    var baseTypes = collector.GetBaseTypes(type);
                    if (baseTypes.Contains(baseType))
                    {
                        result.Add(type);
                    }
                }
            }

            return(result);
        }
Beispiel #2
0
        public static void NavigateToType(CSharpTypeIdentifier typeIdentifier)
        {
            bool result = false;

            try
            {
                CSharpType currentType = ResolveType(typeIdentifier);
                if (currentType == null)
                {
                    return;
                }

                var sourceLocations = currentType.SourceLocations;
                if (sourceLocations == null || sourceLocations.Count == 0)
                {
                    return;
                }

                var location = sourceLocations[0];
                if (location.FileName == null || !location.Position.IsValid)
                {
                    return;
                }

                CSRPOSDATA position = new CSRPOSDATA()
                {
                    LineIndex   = location.Position.Line,
                    ColumnIndex = location.Position.Character
                };

                ILangService languageService;
                CSharpInheritanceAnalyzer.LangService_GetInstance(out languageService);
                if (languageService == null)
                {
                    return;
                }

                IProject project = null;
                languageService.OpenSourceFile(project, location.FileName.Value, position);
            }
            catch (ApplicationException)
            {
                ////_callHierarchy.LanguageService.DisplayErrorMessage(exception.Message);
                return;
            }
            catch (InvalidOperationException)
            {
                ////this._callHierarchy.LanguageService.DisplayErrorMessage(exception2.Message);
                return;
            }

            if (!result)
            {
                ////NativeMessageId.Create(this._callHierarchy.LanguageService, jrc_StringResource_identifiers.IDS_HIDDEN_DEFINITION, new object[0]).DisplayError(this._callHierarchy.LanguageService);
            }
        }
Beispiel #3
0
        private static CSharpType ResolveType(CSharpTypeIdentifier memberIdentifier)
        {
            IDECompilerHost host = new IDECompilerHost();
            var             currentCompilations = host.Compilers.Select(i => i.GetCompilation()).ToList();
            var             resolved            = ResolveTypeIdentifier(currentCompilations, memberIdentifier);

            if (resolved != null)
            {
                return(resolved.Item1);
            }

            return(null);
        }
        public ISet<CSharpType> GetDerivedTypes(CSharpTypeIdentifier typeId)
        {
            ISet<CSharpType> result = new HashSet<CSharpType>();
            foreach (Compilation compilation in AllProjects)
            {
                CSharpType baseType = compilation.ResolveTypeIdentifier(typeId);
                if (baseType == null)
                    continue;

                BaseTypeCollector collector = baseType.IsInterface ? GetBaseInterfaceCollector() : GetBaseClassCollector();
                foreach (CSharpType type in compilation.MainAssembly.Types)
                {
                    // an interface can't be derived from a class
                    if (type.IsInterface && !baseType.IsInterface)
                        continue;

                    var baseTypes = collector.GetBaseTypes(type);
                    if (baseTypes.Contains(baseType))
                        result.Add(type);
                }
            }

            return result;
        }
Beispiel #5
0
 public static Tuple <CSharpType, Compilation> ResolveTypeIdentifier(IEnumerable <Compilation> projectList, CSharpTypeIdentifier typeId)
 {
     return(Resolve(projectList, project => project.ResolveTypeIdentifier(typeId), typeId.AssemblyIdentifier));
 }
Beispiel #6
0
 public TypeTarget(string displayName, CSharpTypeIdentifier typeIdentifier)
 {
     _displayName    = displayName;
     _typeIdentifier = typeIdentifier;
 }
Beispiel #7
0
 public TypeTarget(string displayName, CSharpTypeIdentifier typeIdentifier)
 {
     _displayName = displayName;
     _typeIdentifier = typeIdentifier;
 }