static void Main(string[] args) { var app = new CommandLineApplication { Name = "", Description = "" }; app.HelpOption("-?|-h|--help"); app.VersionOption("-v|--version", () => $"Version {Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion}"); new VetCommandController(app).Apply(); app.OnExecute(async() => { #if DEBUG const string path = @"https://www.1800petmeds.com/vetdirectory"; const string exportPath = @"C:\\Temp"; var analyzeModel = new DirectoryModel(path, exportPath, verbose: true); var analyzeService = AnalyzerService.CreateAnalyzer(analyzeModel.Path); await analyzeService.AnalyzeAsync(analyzeModel); #endif return(0); }); try { app.Execute(args); } catch (CommandParsingException ex) { Console.WriteLine(ex.Message); } }
public ListResponeMessage <AnalyzerInfo> GetAnalyzerByDate([FromQuery] AnalyzerSeachCriteria _criteria) { ListResponeMessage <AnalyzerInfo> ret = new ListResponeMessage <AnalyzerInfo>(); try { List <AnalyzerInfo> item = AnalyzerService.GetInstance().GetAnalyzerByDate(_criteria); if (item == null) { ret.isSuccess = false; ret.err.msgCode = "001"; ret.err.msgString = "no Analyzer found"; return(ret); } ret.data = item; ret.isSuccess = true; } catch (Exception ex) { ret.isSuccess = false; ret.err.msgCode = "Internal Error !!!"; ret.err.msgString = ex.ToString(); } return(ret); }
public ListResponeMessage <AnalyzerInfo> GetListWithCondition( string analyzerCode, string departmentID, string customerID, DateTime fromDate, DateTime toDate, int pageSize = 10, int pageIndex = 0) { ListResponeMessage <AnalyzerInfo> ret = new ListResponeMessage <AnalyzerInfo>(); try { AnalyzerSeachCriteria _criteria = new AnalyzerSeachCriteria(); _criteria.AnalyzerCode = analyzerCode; _criteria.DepartmentID = departmentID; _criteria.CustomerID = customerID; _criteria.FromDate = fromDate; _criteria.ToDate = toDate; _criteria.pageSize = pageSize; _criteria.pageIndex = pageIndex; ret.data = AnalyzerService.GetInstance().getAllAnalyzer(pageSize, pageIndex, _criteria); ret.totalRecords = AnalyzerService.GetInstance().getTotalRecords(_criteria); ret.isSuccess = true; } catch (Exception ex) { ret.isSuccess = false; ret.err.msgCode = "005"; ret.err.msgString = ex.ToString(); } return(ret); }
private bool IsCandidateForFullSolutionAnalysis(DiagnosticAnalyzer analyzer, Project project) { // PERF: Don't query descriptors for compiler analyzer, always execute it. if (DiagnosticAnalyzerInfoCache.IsCompilerDiagnosticAnalyzer(project.Language, analyzer)) { return(true); } if (analyzer.IsBuiltInAnalyzer()) { // always return true for builtin analyzer. we can't use // descriptor check since many builtin analyzer always return // hidden descriptor regardless what descriptor it actually // return on runtime. they do this so that they can control // severity through option page rather than rule set editor. // this is special behavior only ide analyzer can do. we hope // once we support editorconfig fully, third party can use this // ability as well and we can remove this kind special treatment on builtin // analyzer. return(true); } // For most of analyzers, the number of diagnostic descriptors is small, so this should be cheap. var descriptors = AnalyzerService.GetDiagnosticDescriptors(analyzer); return(descriptors.Any(d => d.GetEffectiveSeverity(project.CompilationOptions !) != ReportDiagnostic.Hidden)); }
public List <ResultData> Search(SingleFieldSearchViewModel sfsViewModel) { var results = new List <ResultData>(); string fieldName = sfsViewModel.FieldName.Trim(); string fieldValue = sfsViewModel.FieldValue.Trim(); QueryType queryType = (QueryType)Enum.Parse(typeof(QueryType), sfsViewModel.QueryType); IndexerType type = AnalyzerService.GetIndexerType(sfsViewModel.Language); try { Query query = QueryBuilder.BuildQuery(type, queryType, fieldName, fieldValue); InformationRetriever informationRetriever = new InformationRetriever(type, RAW_DIR_PATH, INDEX_DIR_PATH); var queriedHighlights = new List <string>() { fieldName }; results = informationRetriever.RetrieveEBooks(type, query, queriedHighlights, Sort.INDEXORDER); if (results.Count != 0) { MapLanguageAndCategory(results); } } catch (Exception e) { throw e; } return(results); }
public void RemoveDocument(DocumentId documentId) { using (Logger.LogBlock(FunctionId.Diagnostics_RemoveDocument, GetRemoveLogMessage, documentId, CancellationToken.None)) { var stateSets = _stateManager.GetStateSets(documentId.ProjectId); // let other components knows about this event ClearCompilationsWithAnalyzersCache(); var changed = _stateManager.OnDocumentRemoved(stateSets, documentId); // if there was no diagnostic reported for this document, nothing to clean up if (!changed) { // this is Perf to reduce raising events unnecessarily. return; } // remove all diagnostics for the document AnalyzerService.RaiseBulkDiagnosticsUpdated(raiseEvents => { foreach (var stateSet in stateSets) { RaiseDiagnosticsRemoved(documentId, solution: null, stateSet, AnalysisKind.Syntax, raiseEvents); RaiseDiagnosticsRemoved(documentId, solution: null, stateSet, AnalysisKind.Semantic, raiseEvents); RaiseDiagnosticsRemoved(documentId, solution: null, stateSet, AnalysisKind.NonLocal, raiseEvents); } }); } }
public Task RemoveProjectAsync(ProjectId projectId, CancellationToken cancellation) { using (Logger.LogBlock(FunctionId.Diagnostics_RemoveProject, GetRemoveLogMessage, projectId, CancellationToken.None)) { var stateSets = _stateManager.GetStateSets(projectId); // let other components knows about this event ClearCompilationsWithAnalyzersCache(); var changed = _stateManager.OnProjectRemoved(stateSets, projectId); // if there was no diagnostic reported for this project, nothing to clean up // this is Perf to reduce raising events unnecessarily. if (changed) { // remove all diagnostics for the project AnalyzerService.RaiseBulkDiagnosticsUpdated(raiseEvents => { foreach (var stateSet in stateSets) { // clear all project diagnostics RaiseDiagnosticsRemoved(projectId, solution: null, stateSet, raiseEvents); } }); } } return(Task.CompletedTask); }
private bool IndexEBook(BookViewModel bookViewModel, string path) { bool success; Document document = null; string language = LanguageService.Get(bookViewModel.LanguageId).Name; IndexerType type = AnalyzerService.GetIndexerType(language); BookDomainModelBuilder builder = BuilderResolverService.Get <BookDomainModelBuilder, BookViewModel>(bookViewModel); Constructor.ConstructDomainModelData(builder); BookData book = builder.GetDataModel(); try { document = DocumentHandler.GetDocument(book, path); if (book.Id != 0) { EBookIndexer.DeleteById(book.Id.ToString(), type); } EBookIndexer.Add(document, type); success = true; } catch (Exception e) { success = false; } return(success); }
public SingleResponeMessage <AnalyzerInfo> Get(int id) { SingleResponeMessage <AnalyzerInfo> ret = new SingleResponeMessage <AnalyzerInfo>(); try { AnalyzerInfo item = AnalyzerService.GetInstance().getAnalyzer(id); if (item == null) { ret.isSuccess = false; ret.err.msgCode = "001"; ret.err.msgString = "no Analyzer found"; return(ret); } ret.item = item; ret.isSuccess = true; } catch (Exception ex) { ret.isSuccess = false; ret.err.msgCode = "Internal Error !!!"; ret.err.msgString = ex.ToString(); } return(ret); }
private void RaiseProjectDiagnosticsIfNeeded( Project project, IEnumerable <StateSet> stateSets, ImmutableDictionary <DiagnosticAnalyzer, DiagnosticAnalysisResult> oldResult, ImmutableDictionary <DiagnosticAnalyzer, DiagnosticAnalysisResult> newResult) { if (oldResult.Count == 0 && newResult.Count == 0) { // there is nothing to update return; } AnalyzerService.RaiseBulkDiagnosticsUpdated(async raiseEvents => { foreach (var stateSet in stateSets) { var analyzer = stateSet.Analyzer; var oldAnalysisResult = GetResultOrEmpty(oldResult, analyzer, project.Id, VersionStamp.Default); var newAnalysisResult = GetResultOrEmpty(newResult, analyzer, project.Id, VersionStamp.Default); // Perf - 4 different cases. // upper 3 cases can be removed and it will still work. but this is hot path so if we can bail out // without any allocations, that's better. if (oldAnalysisResult.IsEmpty && newAnalysisResult.IsEmpty) { // nothing to do continue; } if (!oldAnalysisResult.IsEmpty && newAnalysisResult.IsEmpty) { RoslynDebug.Assert(oldAnalysisResult.DocumentIds != null); // remove old diagnostics RaiseProjectDiagnosticsRemoved(stateSet, oldAnalysisResult.ProjectId, oldAnalysisResult.DocumentIds, handleActiveFile: false, raiseEvents); continue; } if (oldAnalysisResult.IsEmpty && !newAnalysisResult.IsEmpty) { // add new diagnostics await RaiseProjectDiagnosticsCreatedAsync(project, stateSet, oldAnalysisResult, newAnalysisResult, raiseEvents, CancellationToken.None).ConfigureAwait(false); continue; } // both old and new has items in them. update existing items RoslynDebug.Assert(oldAnalysisResult.DocumentIds != null); RoslynDebug.Assert(newAnalysisResult.DocumentIds != null); // first remove ones no longer needed. var documentsToRemove = oldAnalysisResult.DocumentIds.Except(newAnalysisResult.DocumentIds); RaiseProjectDiagnosticsRemoved(stateSet, oldAnalysisResult.ProjectId, documentsToRemove, handleActiveFile: false, raiseEvents); // next update or create new ones await RaiseProjectDiagnosticsCreatedAsync(project, stateSet, oldAnalysisResult, newAnalysisResult, raiseEvents, CancellationToken.None).ConfigureAwait(false); } }); }
private Task <IEnumerable <Diagnostic> > ComputeProjectDiagnosticAnalyzerDiagnosticsAsync( Project project, ProjectDiagnosticAnalyzer analyzer, Compilation?compilation, CancellationToken cancellationToken) { return(AnalyzerService.ComputeProjectDiagnosticAnalyzerDiagnosticsAsync(project, analyzer, compilation, DiagnosticLogAggregator, cancellationToken)); }
public SingleResponeMessage <AnalyzerInfo> GetByCode(string code) { SingleResponeMessage <AnalyzerInfo> ret = new SingleResponeMessage <AnalyzerInfo>(); ret.isSuccess = true; ret.item = AnalyzerService.GetInstance().GetAnalyzerByCode(code); return(ret); }
private Task <IEnumerable <Diagnostic> > ComputeDocumentDiagnosticAnalyzerDiagnosticsAsync( Document document, DocumentDiagnosticAnalyzer analyzer, AnalysisKind kind, Compilation?compilation, CancellationToken cancellationToken) { return(AnalyzerService.ComputeDocumentDiagnosticAnalyzerDiagnosticsAsync(document, analyzer, kind, compilation, DiagnosticLogAggregator, cancellationToken)); }
public List <ResultData> Search(MultiFieldSearchViewModel mfsViewModel) { var results = new List <ResultData>(); var requiredHighlights = new List <string>(); var booleanQuery = new BooleanQuery(); IndexerType type = AnalyzerService.GetIndexerType(mfsViewModel.Language); InformationRetriever informationRetriever = new InformationRetriever(type, RAW_DIR_PATH, INDEX_DIR_PATH); QueryType queryType = (QueryType)Enum.Parse(typeof(QueryType), mfsViewModel.QueryType); QueryOperator queryOperator = (QueryOperator)Enum.Parse(typeof(QueryOperator), mfsViewModel.QueryOperator); Occur occur = queryOperator.Equals(QueryOperator.AND) ? Occur.MUST : Occur.SHOULD; try { if (!string.IsNullOrEmpty(mfsViewModel.Title)) { requiredHighlights.Add("Title"); booleanQuery.Add(QueryBuilder.BuildQuery(type, queryType, "Title", mfsViewModel.Title.Trim()), occur); } if (!string.IsNullOrEmpty(mfsViewModel.Author)) { requiredHighlights.Add("Author"); booleanQuery.Add(QueryBuilder.BuildQuery(type, queryType, "Author", mfsViewModel.Author.Trim()), occur); } if (!string.IsNullOrEmpty(mfsViewModel.Keywords)) { requiredHighlights.Add("Keyword"); List <Query> queries = BuildQueriesForKeywords(type, queryType, occur, mfsViewModel.Keywords); queries.ForEach(x => booleanQuery.Add(x, occur)); } if (!string.IsNullOrEmpty(mfsViewModel.Content)) { requiredHighlights.Add("Content"); booleanQuery.Add(QueryBuilder.BuildQuery(type, queryType, "Content", mfsViewModel.Content.Trim()), occur); } if (!string.IsNullOrEmpty(mfsViewModel.Language)) { requiredHighlights.Add("Language"); booleanQuery.Add(QueryBuilder.BuildQuery(type, queryType, "Language", mfsViewModel.Language.Trim()), occur); } results = informationRetriever.RetrieveEBooks(type, booleanQuery, requiredHighlights, Sort.INDEXORDER); } catch (Exception e) { results = null; } return(results); }
public async Task SynchronizeWithBuildAsync(ImmutableDictionary <ProjectId, ImmutableArray <DiagnosticData> > buildDiagnostics, bool onBuildCompleted) { var options = Workspace.Options; using (Logger.LogBlock(FunctionId.DiagnosticIncrementalAnalyzer_SynchronizeWithBuildAsync, LogSynchronizeWithBuild, options, buildDiagnostics, CancellationToken.None)) { DebugVerifyDiagnosticLocations(buildDiagnostics); if (!PreferBuildErrors(options)) { // Prefer live errors over build errors return; } var solution = Workspace.CurrentSolution; foreach (var(projectId, diagnostics) in buildDiagnostics) { var project = solution.GetProject(projectId); if (project == null) { continue; } // REVIEW: do build diagnostics include suppressed diagnostics? var stateSets = _stateManager.CreateBuildOnlyProjectStateSet(project); // We load data since we don't know right version. var oldAnalysisData = await ProjectAnalysisData.CreateAsync(PersistentStorageService, project, stateSets, avoidLoadingData : false, CancellationToken.None).ConfigureAwait(false); var newResult = CreateAnalysisResults(project, stateSets, oldAnalysisData, diagnostics); foreach (var stateSet in stateSets) { var state = stateSet.GetOrCreateProjectState(project.Id); var result = GetResultOrEmpty(newResult, stateSet.Analyzer, project.Id, VersionStamp.Default); await state.SaveAsync(PersistentStorageService, project, result).ConfigureAwait(false); } // REVIEW: this won't handle active files. might need to tweak it later. RaiseProjectDiagnosticsIfNeeded(project, stateSets, oldAnalysisData.Result, newResult); } // Refresh diagnostics for open files after solution build completes. if (onBuildCompleted && PreferLiveErrorsOnOpenedFiles(options)) { // Enqueue re-analysis of active document. if (_documentTrackingService?.GetActiveDocument(solution) is { } activeDocument) { AnalyzerService.Reanalyze(Workspace, documentIds: ImmutableArray.Create(activeDocument.Id), highPriority: true); } // Enqueue re-analysis of open documents. AnalyzerService.Reanalyze(Workspace, documentIds: Workspace.GetOpenDocumentIds(), highPriority: true); } } }
public void Setup() { IDataService data = new DataService(); IAnalyserService analyzer = new AnalyzerService(data); _analyseService = analyzer; _dataService = data; _matches = new List <string> { "match_one" }; }
public MainWindowViewModel() { Paths = new ObservableCollection <string>(); Files = new ObservableCollection <FileInfo>(); CleanCommand = new ActionCommand(o => RunClean(), o => CanRefresh); RefreshCommand = new ActionCommand(async o => await RunRefresh(), o => CanRefresh); analyzerService = new AnalyzerService(); cleanerService = new CleanerService(); //TODO run on a background thread, add spinner etc Init(); }
private void RaiseDiagnosticsRemovedForDocument(DocumentId documentId, IEnumerable <StateSet> stateSets) { // remove all diagnostics for the document AnalyzerService.RaiseBulkDiagnosticsUpdated(raiseEvents => { foreach (var stateSet in stateSets) { // clear all doucment diagnostics RaiseDiagnosticsRemoved(documentId, solution: null, stateSet, AnalysisKind.Syntax, raiseEvents); RaiseDiagnosticsRemoved(documentId, solution: null, stateSet, AnalysisKind.Semantic, raiseEvents); RaiseDiagnosticsRemoved(documentId, solution: null, stateSet, AnalysisKind.NonLocal, raiseEvents); } }); }
public List <ResultData> RetrieveEBooks(IndexerType indexerType, Query query, List <string> fieldNames, Sort sort) { var results = new List <ResultData>(); List <Document> documents = documentRetriever.RetrieveDocuments(query, true, sort); Analyzer analyzer = AnalyzerService.GetAnalyzer(indexerType); foreach (Document document in documents) { ResultData resultData = GenerateResultData(document); resultData.Highlights = GenerateHighlights(analyzer, query, document, fieldNames); results.Add(resultData); } return(results); }
private async Task AnalyzeProjectAsync(Project project, bool forceAnalyzerRun, CancellationToken cancellationToken) { try { var stateSets = GetStateSetsForFullSolutionAnalysis(_stateManager.GetOrUpdateStateSets(project), project).ToList(); var options = project.Solution.Options; // PERF: get analyzers that are not suppressed and marked as open file only // this is perf optimization. we cache these result since we know the result. (no diagnostics) // REVIEW: IsAnalyzerSuppressed call seems can be quite expensive in certain condition. is there any other way to do this? var activeAnalyzers = stateSets .Select(s => s.Analyzer) .Where(a => !AnalyzerService.IsAnalyzerSuppressed(a, project) && !a.IsOpenFileOnly(options)); // get driver only with active analyzers. var compilationWithAnalyzers = await CreateCompilationWithAnalyzersAsync(project, activeAnalyzers, includeSuppressedDiagnostics : true, cancellationToken).ConfigureAwait(false); var result = await GetProjectAnalysisDataAsync(compilationWithAnalyzers, project, stateSets, forceAnalyzerRun, cancellationToken).ConfigureAwait(false); if (result.OldResult == null) { RaiseProjectDiagnosticsIfNeeded(project, stateSets, result.Result); return; } // we might not have compilationWithAnalyzers even if project supports compilation if we are called with no analyzers. var compilation = compilationWithAnalyzers?.Compilation ?? (project.SupportsCompilation ? await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false) : null); // no cancellation after this point. // any analyzer that doesn't have result will be treated as returned empty set // which means we will remove those from error list foreach (var stateSet in stateSets) { var state = stateSet.GetOrCreateProjectState(project.Id); await state.SaveAsync(PersistentStorageService, project, result.GetResult(stateSet.Analyzer)).ConfigureAwait(false); stateSet.ComputeCompilationEndAnalyzer(project, compilation); } RaiseProjectDiagnosticsIfNeeded(project, stateSets, result.OldResult, result.Result); } catch (Exception e) when(FatalError.ReportUnlessCanceled(e)) { throw ExceptionUtilities.Unreachable; } }
public async Task SynchronizeWithBuildAsync(Workspace workspace, ImmutableDictionary <ProjectId, ImmutableArray <DiagnosticData> > buildDiagnostics) { using (Logger.LogBlock(FunctionId.DiagnosticIncrementalAnalyzer_SynchronizeWithBuildAsync, (w, m) => LogSynchronizeWithBuild(w, m), workspace, buildDiagnostics, CancellationToken.None)) { DebugVerifyDiagnosticLocations(buildDiagnostics); if (!PreferBuildErrors(workspace)) { // prefer live errors over build errors return; } var solution = workspace.CurrentSolution; foreach (var(projectId, diagnostics) in buildDiagnostics) { var project = solution.GetProject(projectId); if (project == null) { continue; } // REVIEW: do build diagnostics include suppressed diagnostics? var stateSets = _stateManager.CreateBuildOnlyProjectStateSet(project); // we load data since we don't know right version. var oldAnalysisData = await ProjectAnalysisData.CreateAsync(project, stateSets, avoidLoadingData : false, CancellationToken.None).ConfigureAwait(false); var newResult = CreateAnalysisResults(project, stateSets, oldAnalysisData, diagnostics); foreach (var stateSet in stateSets) { var state = stateSet.GetOrCreateProjectState(project.Id); var result = GetResultOrEmpty(newResult, stateSet.Analyzer, project.Id, VersionStamp.Default); await state.SaveAsync(project, result).ConfigureAwait(false); } // REVIEW: this won't handle active files. might need to tweak it later. RaiseProjectDiagnosticsIfNeeded(project, stateSets, oldAnalysisData.Result, newResult); } // if we have updated errors, refresh open files if (buildDiagnostics.Count > 0 && PreferLiveErrorsOnOpenedFiles(workspace)) { // enqueue re-analysis of open documents. AnalyzerService.Reanalyze(workspace, documentIds: workspace.GetOpenDocumentIds(), highPriority: true); } } }
public ActionMessage DeleteAll(string AnalyzerIDs) { ActionMessage ret = new ActionMessage(); try { ret = AnalyzerService.GetInstance().DeleteMuti(AnalyzerIDs); } catch (Exception ex) { ret.isSuccess = false; ret.err.msgCode = "Internal Error !!!"; ret.err.msgString = ex.ToString(); } return(ret); }
public async Task <ActionMessage> Put(int id, [FromBody] AnalyzerInfo _Analyzer) { ActionMessage ret = new ActionMessage(); try { ret = await AnalyzerService.GetInstance().editAnalyzer(id, _Analyzer, GetUserId()); } catch (Exception ex) { ret.isSuccess = false; ret.err.msgCode = "Internal Error !!!"; ret.err.msgString = ex.ToString(); } return(ret); }
public ActionMessage Post([FromBody] AnalyzerInfo _Analyzer) { ActionMessage ret = new ActionMessage(); try { ret = AnalyzerService.GetInstance().createAnalyzer(_Analyzer, GetUserId()); } catch (Exception ex) { ret.isSuccess = false; ret.err.msgCode = "Internal Error !!!"; ret.err.msgString = ex.ToString(); } return(ret); }
public ListResponeMessage <string> getListAnalyzerCode(string AnalyzerCode = "") { ListResponeMessage <string> ret = new ListResponeMessage <string>(); try { ret.isSuccess = true; ret.data = AnalyzerService.GetInstance().getListAnalyzerCode(AnalyzerCode); } catch (Exception ex) { ret.isSuccess = false; ret.err.msgCode = "Internal Error !!!"; ret.err.msgString = ex.ToString(); } return(ret); }
private bool DeleteEBookIndex(BookData book, string path, string language) { bool success = false; Document document; IndexerType type = AnalyzerService.GetIndexerType(language); try { document = DocumentHandler.GetDocument(book, path); EBookIndexer.DeleteByDocument(document, type); success = true; } catch (Exception e) { success = false; } return(success); }
private async Task <DocumentAnalysisData> GetDocumentAnalysisDataAsync( CompilationWithAnalyzers?compilation, Document document, StateSet stateSet, AnalysisKind kind, CancellationToken cancellationToken) { // get log title and functionId GetLogFunctionIdAndTitle(kind, out var functionId, out var title); using (Logger.LogBlock(functionId, GetDocumentLogMessage, title, document, stateSet.Analyzer, cancellationToken)) { try { var version = await GetDiagnosticVersionAsync(document.Project, cancellationToken).ConfigureAwait(false); var state = stateSet.GetOrCreateActiveFileState(document.Id); var existingData = state.GetAnalysisData(kind); if (existingData.Version == version) { return(existingData); } // perf optimization. check whether analyzer is suppressed and avoid getting diagnostics if suppressed. // REVIEW: IsAnalyzerSuppressed call seems can be quite expensive in certain condition. is there any other way to do this? if (AnalyzerService.IsAnalyzerSuppressed(stateSet.Analyzer, document.Project)) { return(new DocumentAnalysisData(version, existingData.Items, ImmutableArray <DiagnosticData> .Empty)); } var nullFilterSpan = (TextSpan?)null; var diagnostics = await ComputeDiagnosticsAsync(compilation, document, stateSet.Analyzer, kind, nullFilterSpan, cancellationToken).ConfigureAwait(false); // this is no-op in product. only run in test environment Logger.Log(functionId, (t, d, a, ds) => $"{GetDocumentLogMessage(t, d, a)}, {string.Join(Environment.NewLine, ds)}", title, document, stateSet.Analyzer, diagnostics); // we only care about local diagnostics return(new DocumentAnalysisData(version, existingData.Items, diagnostics.ToImmutableArrayOrEmpty())); } catch (Exception e) when(FatalError.ReportUnlessCanceled(e)) { throw ExceptionUtilities.Unreachable; } } }
public static Query BuildQuery(IndexerType indexerType, QueryType queryType, string fieldName, string fieldValue) { Query query = null; Analyzer analyzer = AnalyzerService.GetAnalyzer(indexerType); QueryParser queryParser = new QueryParser(VERSION, fieldName, analyzer); fieldName = fieldName.Trim(); fieldValue = fieldValue.Trim(); if (queryType.Equals(QueryType.STANDARD)) { try { query = queryParser.Parse(fieldValue); } catch (Exception e) { throw e; } } else if (queryType.Equals(QueryType.FUZZY)) { Term term = new Term(fieldName, fieldValue); query = new FuzzyQuery(term); } else if (queryType.Equals(QueryType.PHRASE)) { StringTokenizer tokenizedFieldValue = new StringTokenizer(fieldValue); query = new PhraseQuery(); while (tokenizedFieldValue.HasMoreTokens()) { Term term = new Term(fieldName, tokenizedFieldValue.NextToken()); ((PhraseQuery)query).Add(term); } } return(query); }
public void Shutdown() { var stateSets = _stateManager.GetAllStateSets(); AnalyzerService.RaiseBulkDiagnosticsUpdated(raiseEvents => { var handleActiveFile = true; var documentSet = PooledHashSet <DocumentId> .GetInstance(); foreach (var stateSet in stateSets) { var projectIds = stateSet.GetProjectsWithDiagnostics(); foreach (var projectId in projectIds) { stateSet.CollectDocumentsWithDiagnostics(projectId, documentSet); RaiseProjectDiagnosticsRemoved(stateSet, projectId, documentSet, handleActiveFile, raiseEvents); documentSet.Clear(); } } documentSet.Free(); }); }
private void ClearAllDiagnostics(ImmutableArray <StateSet> stateSets, ProjectId projectId) { AnalyzerService.RaiseBulkDiagnosticsUpdated(raiseEvents => { var documentSet = PooledHashSet <DocumentId> .GetInstance(); foreach (var stateSet in stateSets) { Debug.Assert(documentSet.Count == 0); stateSet.CollectDocumentsWithDiagnostics(projectId, documentSet); // PERF: don't fire events for ones that we dont have any diagnostics on if (documentSet.Count > 0) { RaiseProjectDiagnosticsRemoved(stateSet, projectId, documentSet, handleActiveFile: true, raiseEvents); documentSet.Clear(); } } documentSet.Free(); }); }