Esempio n. 1
0
        /// <summary>
        /// This method is redefined in order to get rid of the IsKindAllowed() check at the end.
        /// </summary>
        public override bool IsAvailable(IDataContext dataContext)
        {
            var solution = dataContext.GetData(ProjectModel.DataContext.DataConstants.SOLUTION);

            if (solution == null)
            {
                return(false);
            }

            var generatorManager = GeneratorManager.GetInstance(solution);

            if (generatorManager == null)
            {
                return(false);
            }

            var languageType = generatorManager.GetPsiLanguageFromContext(dataContext);

            if (languageType == null)
            {
                return(false);
            }

            var generatorContextFactory = LanguageManager.Instance.TryGetService <IGeneratorContextFactory>(languageType);

            return(generatorContextFactory != null);
        }