Esempio n. 1
0
 public ImageByName()
 {
     Map = docs => from i in docs
           select new
     {
         Id   = i.Id,
         Name = new[] { i.Name },
     };
     Index(r => r.Name, FieldIndexing.Search);
     Analyzers.Add(n => n.Name, typeof(NGramAnalyzer).AssemblyQualifiedName);
 }
Esempio n. 2
0
            public MyIndex(string analyzerName)
            {
                Map = customers => from customer in customers
                      select new
                {
                    Name = customer.Name
                };

                Indexes.Add(x => x.Name, FieldIndexing.Search);
                Analyzers.Add(x => x.Name, analyzerName);
            }
Esempio n. 3
0
        public void Generate()
        {
            WriteAllText(
                @"Analyzers\README.md",
                MarkdownGenerator.CreateAnalyzersReadMe(Analyzers.Where(f => !f.IsObsolete), Comparer));

            WriteAllText(
                @"Analyzers\AnalyzersByCategory.md",
                MarkdownGenerator.CreateAnalyzersByCategoryMarkDown(Analyzers.Where(f => !f.IsObsolete), Comparer));

            foreach (AnalyzerDescriptor analyzer in Analyzers)
            {
                WriteAllText(
                    $@"..\docs\analyzers\{analyzer.Id}.md",
                    MarkdownGenerator.CreateAnalyzerMarkDown(analyzer),
                    fileMustExists: false);
            }

            WriteAllText(
                @"..\docs\refactorings\Refactorings.md",
                MarkdownGenerator.CreateRefactoringsMarkDown(Refactorings, Comparer));

            WriteAllText(
                @"Refactorings\README.md",
                MarkdownGenerator.CreateRefactoringsReadMe(Refactorings.Where(f => !f.IsObsolete), Comparer));

            foreach (RefactoringDescriptor refactoring in Refactorings)
            {
                WriteAllText(
                    $@"..\docs\refactorings\{refactoring.Id}.md",
                    MarkdownGenerator.CreateRefactoringMarkDown(refactoring),
                    fileMustExists: false);
            }

            WriteAllText(
                @"CodeFixes\README.md",
                MarkdownGenerator.CreateCodeFixesReadMe(CodeFixes, CompilerDiagnostics, Comparer));

            WriteAllText(
                @"CodeFixes\CodeFixesByDiagnosticId.md",
                MarkdownGenerator.CreateCodeFixesByDiagnosticId(CodeFixes, CompilerDiagnostics));

            WriteAllText(
                "DefaultConfigFile.xml",
                XmlGenerator.CreateDefaultConfigFile(Refactorings, CodeFixes));

            WriteAllText(
                @"VisualStudio\description.txt",
                File.ReadAllText(@"..\text\RoslynatorDescription.txt", Encoding.UTF8));

            WriteAllText(
                @"VisualStudio.Refactorings\description.txt",
                File.ReadAllText(@"..\text\RoslynatorRefactoringsDescription.txt", Encoding.UTF8));
        }
Esempio n. 4
0
        public Index_With_NGram_Analyzer()
        {
            Map = companies => from c in companies
                  select new
            {
                Name = c.Name
            };

            Index(r => r.Name, FieldIndexing.Search);
            Analyzers.Add(n => n.Name, nameof(NGramAnalyzer));
        }
Esempio n. 5
0
            public void FillDictData(string[] namesArr, FieldStorage[] storesArr, string[] analArr, SuggestionOptions[] sugArr)
            {
                for (int i = 0; i < namesArr.Length; i++)
                {
                    Fields.Add(namesArr[i]);

                    Stores.Add(namesArr[i], storesArr[i]);
                    Analyzers.Add(namesArr[i], analArr[i]);
                    Suggestions.Add(namesArr[i], sugArr[i]);
                }
            }
                // TODO: delete this once prototyping is done
                public void ChangeDiagnosticsEngine(bool useV2Engine)
                {
                    var diagnosticAnalyzer = Analyzers.FirstOrDefault(a => a is BaseDiagnosticIncrementalAnalyzer) as DiagnosticAnalyzerService.IncrementalAnalyzerDelegatee;

                    if (diagnosticAnalyzer == null)
                    {
                        return;
                    }

                    diagnosticAnalyzer.TurnOff(useV2Engine);
                }
Esempio n. 7
0
        public void Generate()
        {
            WriteAllText(
                @"Analyzers\README.md",
                MarkdownGenerator.CreateAnalyzersReadMe(Analyzers.Where(f => !f.IsObsolete), Comparer));

            WriteAllText(
                @"Analyzers\AnalyzersByCategory.md",
                MarkdownGenerator.CreateAnalyzersByCategoryMarkdown(Analyzers.Where(f => !f.IsObsolete), Comparer));

            foreach (AnalyzerDescriptor analyzer in Analyzers)
            {
                WriteAllText(
                    $@"..\docs\analyzers\{analyzer.Id}.md",
                    MarkdownGenerator.CreateAnalyzerMarkdown(analyzer),
                    fileMustExists: false);
            }

            WriteAllText(
                @"..\docs\refactorings\Refactorings.md",
                MarkdownGenerator.CreateRefactoringsMarkdown(Refactorings, Comparer));

            WriteAllText(
                @"Refactorings\README.md",
                MarkdownGenerator.CreateRefactoringsReadMe(Refactorings.Where(f => !f.IsObsolete), Comparer));

            foreach (RefactoringDescriptor refactoring in Refactorings)
            {
                WriteAllText(
                    $@"..\docs\refactorings\{refactoring.Id}.md",
                    MarkdownGenerator.CreateRefactoringMarkdown(refactoring),
                    fileMustExists: false);
            }

            WriteAllText(
                @"CodeFixes\README.md",
                MarkdownGenerator.CreateCodeFixesReadMe(CompilerDiagnostics, Comparer));

            foreach (CompilerDiagnosticDescriptor diagnostic in CompilerDiagnostics)
            {
                WriteAllText(
                    $@"..\docs\cs\{diagnostic.Id}.md",
                    MarkdownGenerator.CreateCompilerDiagnosticMarkdown(diagnostic, CodeFixes, Comparer),
                    fileMustExists: false);
            }

            WriteAllText(
                "DefaultConfigFile.xml",
                XmlGenerator.CreateDefaultConfigFile(Refactorings, CodeFixes));

            WriteAllText(
                "DefaultRuleSet.ruleset",
                XmlGenerator.CreateDefaultRuleSet(Analyzers));
        }
Esempio n. 8
0
            public MyDocIndex()
            {
                Map = docs => docs.Select(
                    lm => new MyDocResult()
                {
                    Message  = lm.Message,
                    IsChange = (lm.Type & LogTypeEnum.Changes) == LogTypeEnum.Changes
                });

                Analyzers.Add(lm => lm.Message, "Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net");
            }
        public override void Initialize(AnalysisContext context)
        {
            base.Initialize(context);

            var supportedKinds = Analyzers.Select(p => ((ISyntaxNodeAnalyzer)p).Kind).Distinct();

            foreach (var syntaxKind in supportedKinds)
            {
                context.RegisterSyntaxNodeAction(p => { AnalyzeNode(p, syntaxKind); }
                                                 , syntaxKind);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Gets all the diagnostics reported by the given <paramref name="analyzer"/>.
        /// </summary>
        public ImmutableArray <Diagnostic> GetAllDiagnostics(DiagnosticAnalyzer analyzer)
        {
            if (!Analyzers.Contains(analyzer))
            {
                throw new ArgumentException(
                          CodeAnalysisResources.UnsupportedAnalyzerInstance,
                          nameof(analyzer)
                          );
            }

            return(GetDiagnostics(SpecializedCollections.SingletonEnumerable(analyzer)));
        }
Esempio n. 11
0
        public Users_ByName()
        {
            Map = users => from u in users select new { Name = u.Name, LastName = u.LastName.Boost(10) };

            Indexes.Add(x => x.Name, FieldIndexing.Analyzed);

            IndexSuggestions.Add(x => x.Name, new SuggestionOptions());

            Analyzers.Add(x => x.Name, typeof(SimpleAnalyzer).FullName);

            Stores.Add(x => x.Name, FieldStorage.Yes);
        }
Esempio n. 12
0
        private void CreateSuggestAnalyzer()
        {
            string json = Serialization.Serialize(Analyzers.GetSuggestAnalyzer(Language.GetLanguageAnalyzer(_language)));

            byte[] data = Encoding.UTF8.GetBytes(json);
            var    uri  = _indexing.GetUri(_name, "_settings");

            Logger.Information("Adding Suggest analyzer");
            Logger.Information(JToken.Parse(json).ToString(Formatting.Indented));

            HttpClientHelper.Put(uri, data);
        }
Esempio n. 13
0
        public Users_ByName()
        {
            Map = users => from u in users select new { Name = u.Name, LastName = u.LastName.Boost(10) };

            Indexes.Add(x => x.Name, FieldIndexing.Search);

            IndexSuggestions.Add(x => x.Name);

            Analyzers.Add(x => x.Name, typeof(Lucene.Net.Analysis.SimpleAnalyzer).FullName);

            Stores.Add(x => x.Name, FieldStorage.Yes);
        }
Esempio n. 14
0
        public DeCollationIndex()
        {
            Map = contacts =>
                  from contact in contacts
                  select new
            {
                contact.FirstName,
            };

            Analyzers.Add(x => x.FirstName, typeof(DeCollationAnalyzer).AssemblyQualifiedName);
            Sort(x => x.FirstName, SortOptions.String);
        }
Esempio n. 15
0
        public Posts_ByPostCategory()
        {
            Map = docs => from doc in docs
                  select new
            {
                doc.Body,
                doc.Category
            };

            Stores.Add(x => x.Body, FieldStorage.Yes);
            Analyzers.Add(x => x.Body, typeof(StandardAnalyzer).FullName);
        }
Esempio n. 16
0
        private void WriteAnalyzersExtensionDescription(XmlWriter xw)
        {
            xw.WriteElementString("h3", "List of Analyzers");

            xw.WriteStartElement("ul");
            foreach (AnalyzerInfo analyzer in Analyzers
                     .OrderBy(f => f.Id, StringComparer.InvariantCulture))
            {
                xw.WriteElementString("li", $"{analyzer.Id} - {analyzer.Title}");
            }

            xw.WriteEndElement();
        }
Esempio n. 17
0
            public ZC_CountryCityStateCodeACIndex()
            {
                Map = sEnum => sEnum
                      .Select(t => new { t.CountryCode, CityOrder = t.City, t.City, t.StateCode });

                Reduce = results => results
                         .GroupBy(r => new { r.City, r.CountryCode, r.StateCode })
                         .Select(g => new { g.Key.City, CityOrder = g.Key.City, g.Key.CountryCode, g.Key.StateCode });

                //Bug Collation - following resolves in empty results
                //Without it, {ä ö ü} are analyzed wrongly and are placed at the end of the alphabet
                Analyzers.Add(x => x.CityOrder, typeof(DeCollationAnalyzer).AssemblyQualifiedName);
            }
Esempio n. 18
0
            public Students_WithFriends()
            {
                Map = students => from student in students
                      let friends = LoadDocument <Student>(student.Friends)
                                    select new Mapping
                {
                    EmailDomain = student.Email.Split('@', StringSplitOptions.None).Last(),
                    Friends     = friends.Select(a => a.Email)
                };

                Analyzers.Add(x => x.Friends, "Lucene.Net.Analysis.SimpleAnalyzer, Lucene.Net");
                Indexes.Add(x => x.Friends, FieldIndexing.Search);
            }
Esempio n. 19
0
            public Audio_Index()
            {
                // audio properties
                Map = audios => from audio in audios
                      select new
                {
                    Id      = audio.Id,
                    AudioId = audio.Id,
                    Name    = audio.Name
                };

                Analyzers.Add(x => x.Name, "SimpleAnalyzer");
            }
        public UserIndex()
        {
            Map = users => from user in users
                  select new
            {
                user.Name,
                user.Total,
                user.Role
            };

            Indexes.Add(x => x.Name, FieldIndexing.Analyzed);
            Analyzers.Add(x => x.Name, typeof(TurkishAnalyzer.TurkishAnalyzer).AssemblyQualifiedName);
        }
Esempio n. 21
0
        public Companies_SortByName()
        {
            Map = companies => from company in companies
                  select new { company.Name };

            Sort(c => c.Name, SortOptions.String);

#if !DNXCORE50
            Analyzers.Add(c => c.Name, typeof(Raven.Database.Indexing.Collation.Cultures.PlCollationAnalyzer).ToString());
#else
            Analyzers.Add(c => c.Name, "Raven.Database.Indexing.Collation.Cultures.PlCollationAnalyzer");
#endif
        }
    public ProductIndex()
    {
        Map = products => from product in products
              from category in product.Categories
              select new
        {
            product.Name,
            CategoryName         = category.Name,
            CategoryNameAnalyzed = category.Name,
        };

        Stores.Add(x => x.CategoryName, FieldStorage.Yes);
        Analyzers.Add(x => x.CategoryNameAnalyzed, "SimpleAnalyzer");
    }
        public EmployeesByFirstNameIndex()
        {
            Map = docs => docs.Select(x => new
            {
                FirstName     = x.FirstName,
                LastName      = x.LastName,
                EmployeeGroup = x.EmployeeGroup,
                Title         = x.Title,
                Query         = new object[] { x.Title.Replace("-", " ").Replace("(", " ").Replace(")", " "), x.Title, x.FirstName, x.LastName }
            });

            Index(x => x.Query, FieldIndexing.Analyzed);
            Analyzers.Add(x => x.Query, "Raven.Database.Indexing.LowerCaseWhitespaceAnalyzer");
        }
Esempio n. 24
0
        public Product_ByNameAndTagAndDescription()
        {
            Map = products => from product in products
                  select new
            {
                product.Name,
                product.Tags,
                product.Description
            };

            Analyzers.Add(x => x.Tags, typeof(SimpleAnalyzer).FullName);
            Analyzers.Add(x => x.Name, typeof(SimpleAnalyzer).FullName);
            Analyzers.Add(x => x.Description, typeof(StandardAnalyzer).FullName);
        }
Esempio n. 25
0
        private void CreateAnalyzerSettings()
        {
            var config      = ElasticSearchSection.GetConfiguration();
            var indexConfig = config.IndicesParsed.FirstOrDefault(i => i.Name == _nameWithoutLanguage);

            string json = Serialization.Serialize(Analyzers.GetAnalyzerSettings(_language, indexConfig?.SynonymsFile));
            var    data = Encoding.UTF8.GetBytes(json);
            var    uri  = _indexing.GetUri(_name, "_settings");

            Logger.Information($"Creating analyzer settings. Language: {_name}");
            Logger.Information(JToken.Parse(json).ToString(Formatting.Indented));

            _httpClientHelper.Put(uri, data);
        }
Esempio n. 26
0
        public Posts_ByTitleAndContent()
        {
            Map = posts => from post in posts
                  select new
            {
                post.Title,
                post.Desc
            };

            Stores.Add(x => x.Title, FieldStorage.Yes);
            Stores.Add(x => x.Desc, FieldStorage.Yes);

            Analyzers.Add(x => x.Title, typeof(Lucene.Net.Analysis.SimpleAnalyzer).FullName);
            Analyzers.Add(x => x.Desc, typeof(Lucene.Net.Analysis.SimpleAnalyzer).FullName);
        }
        private void AnalyzeNode(SyntaxNodeAnalysisContext context, SyntaxKind kind)
        {
            var analyzersForKind = Analyzers.Where(p => ((ISyntaxNodeAnalyzer)p).Kind == kind);

            foreach (ISyntaxNodeAnalyzer syntaxNodeAnalyzer in analyzersForKind)
            {
                var diagnosticInfo = syntaxNodeAnalyzer.GetDiagnosticInfo(context);
                foreach (var info in diagnosticInfo)
                {
                    var supportedDiagnostic = GetSupportedDiagnosticAttribute(syntaxNodeAnalyzer);
                    var diagnostic          = DiagnosticFactory.Create(supportedDiagnostic.GetDescriptor(), info);

                    context.ReportDiagnostic(diagnostic);
                }
            }
        }
Esempio n. 28
0
        /// <summary>
        /// Function to retrieve a list of available lingustic analyzers
        /// The list is displayed in the UI
        /// </summary>
        private async void GetAnalyzers()
        {
            var queryString = HttpUtility.ParseQueryString("analyzers");

            Analyzer[] response = await _webRequest.MakeRequest <object, Analyzer[]>(HttpMethod.Get, queryString.ToString());

            if (response == null || response.Length == 0)
            {
                return;
            }

            foreach (Analyzer analyzer in response)
            {
                Analyzers.Add(analyzer);
            }
        }
Esempio n. 29
0
        public Users_ByName()
        {
            Map = users => from u in users select new { Name = u.Name, LastName = u.LastName.Boost(10) };

            Indexes.Add(x => x.Name, FieldIndexing.Analyzed);

            IndexSuggestions.Add(x => x.Name, new SuggestionOptions());

#if !DNXCORE50
            Analyzers.Add(x => x.Name, typeof(SimpleAnalyzer).FullName);
#else
            Analyzers.Add(x => x.Name, "Lucene.Net.Analysis.SimpleAnalyzer");
#endif

            Stores.Add(x => x.Name, FieldStorage.Yes);
        }
Esempio n. 30
0
        public static void DigraphMethods()
        {
            var grammar = GallierCalc.GetGrammar();

            var analyzer = Analyzers.CreateErasableSymbolsAnalyzer(grammar);

            (var initfirstSets, IGraph graphFirst) = DigraphAlgorithm.GetFirstGraph(grammar, analyzer);

            SaveFile("FirstGraph.dot", DigraphDotLanguagePrinter.PrintGraph("INITFIRST", initfirstSets, graphFirst, v => grammar.Nonterminals[v].Name));

            var firstSymbolsAnalyzer = Analyzers.CreateFirstSymbolsAnalyzer(grammar);

            (var initFollowSets, IGraph graphFollow) = DigraphAlgorithm.GetFollowGraph(grammar, firstSymbolsAnalyzer);

            SaveFile("FollowGraph.dot", DigraphDotLanguagePrinter.PrintGraph("INITFOLLOW", initFollowSets, graphFollow, v => grammar.Nonterminals[v].Name));
        }