Exemplo n.º 1
0
        public static Guid?GetGuidFor(MetaFileGuidCache metaFileGuidCache, ITypeElement typeElement)
        {
            var sourceFile = typeElement.GetDeclarations().FirstOrDefault()?.GetSourceFile();

            if (sourceFile == null || !sourceFile.IsValid())
            {
                return(null);
            }

            if (typeElement.TypeParameters.Count != 0)
            {
                return(null);
            }

            if (typeElement.GetContainingType() != null)
            {
                return(null);
            }

            if (!typeElement.ShortName.Equals(sourceFile.GetLocation().NameWithoutExtension))
            {
                return(null);
            }

            var guid = metaFileGuidCache.GetAssetGuid(sourceFile);

            return(guid);
        }
Exemplo n.º 2
0
        public static Guid?GetGuidFor(MetaFileGuidCache metaFileGuidCache, ITypeElement typeElement)
        {
            // partial classes
            var declarations = typeElement.GetDeclarations();

            foreach (var declaration in declarations)
            {
                var sourceFile = declaration.GetSourceFile();
                if (sourceFile == null || !sourceFile.IsValid())
                {
                    continue;
                }

                if (!typeElement.ShortName.Equals(sourceFile.GetLocation().NameWithoutExtension))
                {
                    continue;
                }

                if (typeElement.TypeParameters.Count != 0)
                {
                    continue;
                }

                if (typeElement.GetContainingType() != null)
                {
                    continue;
                }

                var guid = metaFileGuidCache.GetAssetGuid(sourceFile);
                return(guid);
            }

            return(null);
        }
Exemplo n.º 3
0
        private static ITypeDeclaration GetTargetTypeDeclaration([NotNull] ITypeElement baseClass)
        {
            if (!baseClass.IsValid())
            {
                return(null);
            }

            return(baseClass
                   .GetDeclarations()
                   .OfType <ITypeDeclaration>()
                   .FirstOrDefault(decl => LanguageManager.Instance.TryGetService <IntentionLanguageSpecific>(decl.Language) != null));
        }
        public static ITypeElement GetAssociatedModule([NotNull] this ITypeElement typeElement)
        {
            foreach (var declaration in typeElement.GetDeclarations())
            {
                if (!(declaration is IFSharpTypeOldDeclaration typeDeclaration))
                {
                    continue;
                }

                var moduleDeclaration = typeDeclaration.GetAssociatedModuleDeclaration();
                if (moduleDeclaration != null)
                {
                    return(((ITypeDeclaration)moduleDeclaration).DeclaredElement);
                }
            }

            return(null);
        }
        private static ITypeDeclaration GetTargetTypeDeclaration([NotNull] IDeclaredTypeUsage declaredTypeUsage)
        {
            if (!declaredTypeUsage.IsValid())
            {
                return(null);
            }

            ITypeElement typeElement = CSharpTypeFactory.CreateDeclaredType(declaredTypeUsage).GetTypeElement();

            if (typeElement == null)
            {
                return(null);
            }

            return(typeElement.GetDeclarations()
                   .OfType <ITypeDeclaration>()
                   .FirstOrDefault(decl => LanguageManager.Instance.TryGetService <IntentionLanguageSpecific>(decl.Language) != null));
        }