예제 #1
0
        private static void Main(string[] args)
        {
            var settings = new GeneralSettings()
            {
                SolutionDirectoryPath = @"..\..\..\..\.."
            };

            SnippetDirectory[] snippetDirectories = SnippetDirectory.LoadFromFile(@"..\..\SnippetDirectories.xml").ToArray();

            CharacterSequence[] characterSequences = CharacterSequence.LoadFromFile(@"..\..\CharacterSequences.xml").ToArray();

            LanguageDefinition[] languageDefinitions = LanguageDefinition.LoadFromFile(@"..\..\LanguageDefinitions.xml").ToArray();

            CharacterSequence.SerializeToXml(Path.Combine(settings.ExtensionProjectPath, "CharacterSequences.xml"), characterSequences);

            SnippetGenerator.GenerateSnippets(snippetDirectories, languageDefinitions);
            SnippetGenerator.GenerateHtmlSnippets(snippetDirectories);
            SnippetGenerator.GenerateXamlSnippets(snippetDirectories);
            SnippetGenerator.GenerateXmlSnippets(snippetDirectories);

            SnippetDirectory[] releaseDirectories = snippetDirectories
                                                    .Where(f => f.HasTag(KnownTags.Release) && !f.HasTag(KnownTags.Dev))
                                                    .ToArray();

            MarkdownGenerator.WriteSolutionReadMe(releaseDirectories, settings);

            MarkdownGenerator.WriteProjectReadMe(releaseDirectories, Path.GetFullPath(settings.ProjectPath));

            MarkdownGenerator.WriteDirectoryReadMe(
                snippetDirectories
                .Where(f => f.HasAnyTag(KnownTags.Release, KnownTags.Dev) && !f.HasAnyTag(KnownTags.AutoGenerationSource, KnownTags.AutoGenerationDestination))
                .ToArray(),
                characterSequences,
                settings);

            SnippetPackageGenerator.GenerateVisualStudioPackageFiles(
                releaseDirectories: releaseDirectories,
                characterSequences: characterSequences,
                settings: settings);

            settings.ExtensionProjectName += ".Dev";

            SnippetPackageGenerator.GenerateVisualStudioPackageFiles(
                releaseDirectories: snippetDirectories
                .Where(f => f.HasTags(KnownTags.Release, KnownTags.Dev))
                .ToArray(),
                characterSequences: null,
                settings: settings);

            SnippetChecker.CheckSnippets(snippetDirectories);

            Console.WriteLine("*** END ***");
            Console.ReadKey();
        }
예제 #2
0
        private void ReplacePlaceholders(Snippet snippet)
        {
            snippet.Title = snippet.Title
                            .ReplacePlaceholder(Placeholders.Type, " ", true)
                            .ReplacePlaceholder(Placeholders.OfType, " ", true)
                            .ReplacePlaceholder(Placeholders.GenericType, LanguageDefinition.GetTypeParameterList("T"));

            snippet.Description = snippet.Description
                                  .ReplacePlaceholder(Placeholders.Type, " ", true)
                                  .ReplacePlaceholder(Placeholders.OfType, " ", true)
                                  .ReplacePlaceholder(Placeholders.GenericType, LanguageDefinition.GetTypeParameterList("T"));
        }
예제 #3
0
        public static IEnumerable <LanguageDefinition> ToLanguageDefinitions(this IEnumerable <Record> records)
        {
            foreach (IGrouping <string, Record> grouping in records
                     .Where(f => f.ContainsProperty("Language"))
                     .GroupBy(f => f.GetStringOrDefault(Identifiers.Language)))
            {
                LanguageDefinition language = CreateLanguageDefinition((Language)Enum.Parse(typeof(Language), grouping.Key));

                foreach (ModifierDefinition modifier in grouping.ToModifierDefinitions())
                {
                    language.Modifiers.Add(modifier);
                }

                foreach (TypeDefinition type in grouping
                         .Concat(records.Where(f => !f.ContainsProperty("Language")))
                         .ToTypeDefinitions())
                {
                    language.Types.Add(type);
                }

                yield return(language);
            }
        }
예제 #4
0
        private static void GenerateSnippets2(SnippetDirectory[] snippetDirectories, LanguageDefinition languageDefinition)
        {
            if (snippetDirectories.Length > 0)
            {
                string source = snippetDirectories
                                .Where(f => f.HasTag(KnownTags.AutoGenerationSource))
                                .Select(f => f.Path)
                                .FirstOrDefault();

                if (source != null)
                {
                    string destination = snippetDirectories
                                         .Where(f => f.HasTag(KnownTags.AutoGenerationDestination))
                                         .Select(f => f.Path)
                                         .FirstOrDefault();

                    if (destination != null)
                    {
                        var generator = new SnippetGenerator(languageDefinition);
                        generator.GenerateSnippets(source, destination);
                    }
                }
            }
        }
예제 #5
0
 private static void GenerateSnippets(IEnumerable <SnippetDirectory> snippetDirectories, LanguageDefinition languageDefinition)
 {
     GenerateSnippets2(snippetDirectories.Where(f => !f.HasTag(KnownTags.Dev)).ToArray(), languageDefinition);
     GenerateSnippets2(snippetDirectories.Where(f => f.HasTag(KnownTags.Dev)).ToArray(), languageDefinition);
 }
예제 #6
0
 public SnippetGenerator(LanguageDefinition languageDefinition)
 {
     LanguageDefinition = languageDefinition;
 }
예제 #7
0
        public SnippetGeneratorSettings(LanguageDefinition language)
        {
            Language = language;

            Types = new Collection <TypeDefinition>();
        }
예제 #8
0
 public LanguageExecutionContext(Snippet snippet, LanguageDefinition language)
     : base(snippet)
 {
     Language = language;
 }