private void IndentGuideGeneralOptionUpdated(GeneralOptionProvider sender) { // ReSharper disable CompareOfFloatsByEqualityOperator if (sender.IsEnabledIndentGuides == _isEnabled && sender.IndentGuideThickness == _thickness && sender.IndentGuideDashSize == _dashSize && sender.IndentGuideSpaceSize == _spaceSize && sender.IndentGuideOffsetX == _offsetX && sender.IndentGuideOffsetY == _offsetY) { return; } // ReSharper restore CompareOfFloatsByEqualityOperator _isEnabled = sender.IsEnabledIndentGuides; _thickness = sender.IndentGuideThickness; _dashSize = sender.IndentGuideDashSize; _spaceSize = sender.IndentGuideSpaceSize; _offsetX = sender.IndentGuideOffsetX; _offsetY = sender.IndentGuideOffsetY; _currentResult = _documentAnalysis.CurrentResult; if (_isEnabled) { UpdateIndentGuides(); } else { ClearIndentGuides(); } }
internal IAnalysisResult TryGetUserDefinedType(string typeName, int index) { // do a binary search to determine what node we're in IAnalysisResult type = null; _body.SetNamespace(null); // TODO: need to handle multiple results of the same name AstNode containingNode = GetContainingNode(_body, index); if (containingNode != null) { if (containingNode is IFunctionResult) { if ((containingNode as IFunctionResult).Types.TryGetValue(typeName, out type)) { return(type); } } if (_body is IModuleResult) { if ((_body as IModuleResult).Types.TryGetValue(typeName, out type) || (_body as IModuleResult).GlobalTypes.TryGetValue(typeName, out type)) { return(type); } } } // TODO: this could probably be done more efficiently by having each GeneroAst load globals and functions into // dictionaries stored on the IGeneroProject, instead of in each project entry. // However, this does required more upkeep when changes occur. Will look into it... if (_projEntry != null && _projEntry is IGeneroProjectEntry) { IGeneroProjectEntry genProj = _projEntry as IGeneroProjectEntry; if (genProj.ParentProject != null) { foreach (var projEntry in genProj.ParentProject.ProjectEntries.Where(x => x.Value != genProj)) { if (projEntry.Value.Analysis != null && projEntry.Value.Analysis.Body != null) { projEntry.Value.Analysis.Body.SetNamespace(null); IModuleResult modRes = projEntry.Value.Analysis.Body as IModuleResult; if (modRes != null) { // check global types if (modRes.GlobalTypes.TryGetValue(typeName, out type)) { return(type); } } } } } } return(type); }
private void AnalysisUpdated(IAnalysisResult analysisResult, RescanReason reason, CancellationToken cancellationToken) { if (reason == RescanReason.ContentChanged) { ThreadHelper.JoinableTaskFactory.RunAsync(() => UpdateTagSpansAsync(analysisResult.Snapshot, analysisResult.Scopes, cancellationToken)); } }
public static FunctionBlock TryGetFunctionBlock(this IAnalysisResult analysisResult, SnapshotPoint point) { if (point.Snapshot != analysisResult.Snapshot) { return(null); } var block = analysisResult.Scopes.FirstOrDefault(t => t.FInRange(point)); if (block == null) { return(null); } while (true) { var innerBlock = InnerInRange(block.Children, point); if (innerBlock != null) { block = innerBlock; continue; } break; } return((FunctionBlock)block); }
public void ShouldReturnResultOnValidAnalyzeCall() { int min = 100; int max = 50; Mock <IAnalysisResult> analysisResultMock = new Mock <IAnalysisResult>(); Mock <IQuantityAnalysisResultFactory> quantityAnalysisResultFactoryMock = new Mock <IQuantityAnalysisResultFactory>(); quantityAnalysisResultFactoryMock.Setup(m => m.CreateInstance(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <bool>())).Returns(analysisResultMock.Object); Mock <IQuantitySearch> quantitySearchMock = new Mock <IQuantitySearch>(); quantitySearchMock.Setup(m => m.Search(It.IsAny <IDNA>())).Returns(100); List <IQuantitySearch> listOfQuantitySearch = new List <IQuantitySearch>() { quantitySearchMock.Object }; QuantityAnalysis quantityAnalysis = new QuantityAnalysis(min, max, quantityAnalysisResultFactoryMock.Object, listOfQuantitySearch); Mock <IDNA> dnaMock = new Mock <IDNA>(); dnaMock.Setup(m => m.IsValid()).Returns(true); IAnalysisResult analysisResult = quantityAnalysis.Analyze(dnaMock.Object); Assert.AreEqual(analysisResult, analysisResultMock.Object); }
internal static bool TryGetCompareContextDefinedByBaseline(IAnalysisResult analysisResult, out ICompareContext compareContext) { Debug.Assert(analysisResult != null); var project = analysisResult.AnalysisResultRef.Project; IAnalysisResultRef analysisResultUsedInUIRef; if (project.BaselineInUI.TryGetAnalysisResultRefToCompareWith(out analysisResultUsedInUIRef) == TryGetAnalysisResultRefToCompareWithResult.DoCompareWith) { Debug.Assert(analysisResultUsedInUIRef != null); compareContext = LoadCompareContext(analysisResultUsedInUIRef, analysisResult); return(true); } IAnalysisResultRef analysisResultUsedDuringAnalysisRef; if (project.BaselineDuringAnalysis.TryGetAnalysisResultRefToCompareWith(out analysisResultUsedDuringAnalysisRef) == TryGetAnalysisResultRefToCompareWithResult.DoCompareWith) { Debug.Assert(analysisResultUsedDuringAnalysisRef != null); compareContext = LoadCompareContext(analysisResultUsedDuringAnalysisRef, analysisResult); return(true); } compareContext = null; return(false); }
public void AddMeasurement(Measurement measure, IAnalysisResult result) { // we do the reset here, so flush rates can be set just before the first call to AddMeasurement if (_summaryCount == 0) { Reset(); } _summaryCount++; _measure = measure; _result = result; _sumDelay += measure.Delay; if (result.Flow) { _flowCount++; _sumAmplitude += result.Amplitude; _sumLowPassOnHighPass += result.LowPassOnHighPass; } if (result.Outlier) { _outlierCount++; } if (result.Drift) { _driftCount++; } if (result.ExcludeAll) { _excludeCount = _summaryCount; } else if (result.Exclude) { _excludeCount++; } }
private IAnalysisResult GetResolvedType(Genero4glAst ast, out string errMsg) { errMsg = null; IAnalysisResult result = null; // if it's not a base type, look up the type IGeneroProject dummyProj; IProjectEntry dummyProjEntry; bool isDeferred; var res = Genero4glAst.GetValueByIndex(_typeNameString, StartIndex, ast as Genero4glAst, out dummyProj, out dummyProjEntry, out isDeferred, FunctionProviderSearchMode.NoSearch, false, true, false, false); if (res == null) { errMsg = string.Format("Type {0} not found.", _typeNameString); } else { if (res is GeneroPackageClass || res is TypeDefinitionNode) { result = res; } else { errMsg = string.Format("Invalid type {0} found.", _typeNameString); } } return(result); }
internal static void AugmentQuickInfoWorker(IQuickInfoSession session, ITextBuffer subjectBuffer, IVsTextView viewAdapter, ExpressionAnalysis exprAnalysis, System.Collections.Generic.IList <object> quickInfoContent, out ITrackingSpan applicableToSpan) { applicableToSpan = exprAnalysis.Span; if (applicableToSpan == null || String.IsNullOrWhiteSpace(exprAnalysis.Expression)) { return; } bool first = true; var result = new StringBuilder(); int count = 0; IAnalysisResult val = exprAnalysis.Value; if (val != null) { DTE dte = (DTE)VSGeneroPackage.Instance.GetPackageService(typeof(DTE)); if (dte.Debugger.CurrentMode != dbgDebugMode.dbgBreakMode || !val.CanGetValueFromDebugger) { quickInfoContent.Add(val.Documentation); } else { string qiText; if (TryGetQuickInfoFromDebugger(session, applicableToSpan.GetSpan(subjectBuffer.CurrentSnapshot), viewAdapter, out qiText)) { quickInfoContent.Add(qiText); } } } }
private void UpdateFunctionList(IAnalysisResult analysisResult, RescanReason reason, CancellationToken cancellationToken) { if (reason == RescanReason.ContentChanged) { UpdateFunctionList(analysisResult, cancellationToken); } }
private static void HandleProject(string slnAbsolutePath, string outputDirectory, string outputFileName) { var stopwatch = Stopwatch.StartNew(); Logger.Information("**** Analyzing solution {solution} *** ", slnAbsolutePath); Logger.Information("\tBuilding NDepend Project"); var result = NDependProjectHandler.GetOrCreateProjectFromVisualStudioSolution( slnAbsolutePath, outputDirectory, outputFileName); if (result.IsFailure) { Logger.Information(" \t Could not create an NDepend project for the solution. Reason:{error}", result.Error); return; } stopwatch.Stop(); Logger.Information("\tBuilt NDepend Project in {Elapsed:000} ms", stopwatch.ElapsedMilliseconds); stopwatch = Stopwatch.StartNew(); Logger.Information("\tRunning NDepend Analysis"); IAnalysisResult analysisResult = NDependProjectHandler.GetAnalysisResult(result.Value, Logger); stopwatch.Stop(); Logger.Information("\tAnalyzed NDepend Project in {Elapsed:000} ms", stopwatch.ElapsedMilliseconds); var codeBase = analysisResult.CodeBase; Analyzers.Handle(outputDirectory, outputFileName, codeBase, Logger); }
protected LocationInfo ResolveLocationInternal(IGeneroProject project, IProjectEntry projectEntry, object location) { IAnalysisResult result = location as IAnalysisResult; if (result != null) { IProjectEntry projEntry = projectEntry; IAnalysisResult trueRes = result; if (projEntry == null) { if (project is GeneroProject) { trueRes = (project as GeneroProject).GetMemberOfType(result.Name, this, true, true, true, true, out projEntry); } } if (projEntry != null && projEntry is IGeneroProjectEntry) { var ast = (projEntry as IGeneroProjectEntry).Analysis; var locIndex = trueRes.LocationIndex; var loc = ast.IndexToLocation(locIndex); return(new LocationInfo(projEntry, loc.Line, loc.Column, locIndex)); } } return(null); }
public IChartResults LoadChartsData(AnalysisParametersModel parameters, IAnalysisResult analysisResult) { SetAnalysisStrategy(parameters.AnalysisMethod); var data = ImportService.LoadDataByImportId(parameters.ImportIds); var headers = ImportService.LoadImportHeadersById(parameters.MainHeadersId); return(AnalysisStrategy.LoadChartsData(headers, data, analysisResult)); }
internal IAnalysisResult GetMemberOfType(string name, object ast, bool vars, bool types, bool consts, bool funcs, out IProjectEntry definingProjEntry) { string projNamespace = string.Format("{0}", this.Name); string tempStart = string.Format("{0}.", projNamespace); if (name.StartsWith(tempStart, StringComparison.OrdinalIgnoreCase)) { name = name.Substring(tempStart.Length); } definingProjEntry = null; IAnalysisResult res = null; foreach (var projEntry in ProjectEntries) { if (projEntry.Value.Analysis != null && projEntry.Value.Analysis.Body != null) { projEntry.Value.Analysis.Body.SetNamespace(projNamespace); IModuleResult modRes = projEntry.Value.Analysis.Body as IModuleResult; if (modRes != null) { // check global vars, types, and constants if ((vars && modRes.GlobalVariables.TryGetValue(name, out res)) || (types && modRes.GlobalTypes.TryGetValue(name, out res)) || (consts && modRes.GlobalConstants.TryGetValue(name, out res))) { //found = true; definingProjEntry = projEntry.Value; break; } if (((vars && modRes.Variables.TryGetValue(name, out res)) || (types && modRes.Types.TryGetValue(name, out res)) || (consts && modRes.Constants.TryGetValue(name, out res))) && res.IsPublic) { definingProjEntry = projEntry.Value; break; } // check project functions IFunctionResult funcRes = null; if (funcs && modRes.Functions.TryGetValue(name, out funcRes)) { if (funcRes.AccessModifier == AccessModifier.Public) { res = funcRes; //found = true; definingProjEntry = projEntry.Value; break; } } } } } return(res); }
private void AnalysisUpdated(IAnalysisResult analysisResult, RescanReason reason, CancellationToken ct) { _analysisResult = analysisResult; if (reason != RescanReason.ContentChanged) { ClassificationChanged?.Invoke(this, new ClassificationChangedEventArgs(new SnapshotSpan(analysisResult.Snapshot, 0, analysisResult.Snapshot.Length))); } }
private void ApplyChartMergeOperators(IAnalysisResult result, Report report) { var mergedSections = ChartMergeOperators .Select(op => op.Merge(result)) .Where(section => section != null) .ToList(); report.Sections.AddRange(mergedSections); }
public Report Generate(IAnalysisResult result) { var report = new Report("CombinedCharts", "Combined charts: " + result.Stock.Name); ApplyChartMergeOperators(result, report); AddStandaloneCharts(result, report); return(report); }
public Report Generate( IAnalysisResult result ) { var report = new Report( "CombinedCharts", "Combined charts: " + result.Stock.Name ); ApplyChartMergeOperators( result, report ); AddStandaloneCharts( result, report ); return report; }
public IAnalysisResult[] GetResult() { var res = new IAnalysisResult[analyzers.Length]; for(int i = 0; i < analyzers.Length; i++) { res[i] = analyzers[i].Finish(); } return res; }
public ICodeBase LoadLastCodebase() { IAnalysisResultRef lastAnalysisResultRef; bool result = nDependProject.TryGetMostRecentAnalysisResultRef(out lastAnalysisResultRef); IAnalysisResult analisysResult = lastAnalysisResultRef.Load(); ICodeBase codeBase = analisysResult.CodeBase; return(codeBase); }
private void ApplyChartMergeOperators( IAnalysisResult result, Report report ) { var mergedSections = ChartMergeOperators .Select( op => op.Merge( result ) ) .Where( section => section != null ) .ToList(); report.Sections.AddRange( mergedSections ); }
public MemberResult(string name, IAnalysisResult var, GeneroMemberType type, GeneroAst ast) { _documentation = null; _name = _completion = name; _var = () => var; _type = null; _ast = ast; _type = () => type; }
private void AnalysisUpdated(IAnalysisResult analysisResult, RescanReason reason, CancellationToken ct) { if (reason != RescanReason.ContentChanged) { return; } _currentResult = analysisResult; UpdateIndentGuides(); }
public void BindCursorResult(IAnalysisResult cursorResult, IParser parser) { if (!Cursors.ContainsKey(cursorResult.Name)) { Cursors.Add(cursorResult.Name, cursorResult); } else { parser.ReportSyntaxError(cursorResult.LocationIndex, cursorResult.LocationIndex + cursorResult.Name.Length, string.Format("Module cursor {0} defined more than once.", cursorResult.Name), Severity.Error); } }
private void AddStandaloneCharts( IAnalysisResult result, Report report ) { var visitor = new ChartSectionVisitor(); var walker = new ReportWalker( visitor ); walker.Visit( result.Report ); var standaloneCharts = visitor.Sections .Where( section => !HandledByChartMergeOperators( section ) ) .ToList(); report.Sections.AddRange( standaloneCharts ); }
public Report Generate(IAnalysisResult result) { var stock = result.Stock; var report = new Report("ClosedPricesChart", "Closed price chart: " + stock.Name); var chart = new StockPriceChart(stock, Prices.ForStock(stock)); var chartSection = new GenericChartSection("Closed prices", chart); report.Sections.Add(chartSection); return(report); }
public LocationInfo ResolveLocation(IProjectEntry entry, object location) { IAnalysisResult result = location as IAnalysisResult; if (result != null) { var locIndex = result.LocationIndex; var loc = IndexToLocation(locIndex); return(new LocationInfo(entry, loc.Line, loc.Column, locIndex)); } return(null); }
private async void LaunchAnalyzer() { EntropyAnalyzer analyzer = new EntropyAnalyzer(); _results = await analyzer.AnalyzeAsync(Stream); //_results = analyzer.Analyze(Stream); PlotResults(); Stream.Close(); }
public static IAnalysisResult GetAnalysisItemUnderCaret(ITextView textView) { IAnalysisResult result = null; // don't need the various providers, at least right now var analysis = textView.GetExpressionAnalysis(null, null, null); if (analysis != null) { result = analysis.Value; } return(result); }
public Report Generate( IAnalysisResult result ) { var stock = result.Stock; var report = new Report( "ClosedPricesChart", "Closed price chart: " + stock.Name ); var chart = new StockPriceChart( stock, Prices.ForStock( stock ) ); var chartSection = new GenericChartSection( "Closed prices", chart ); report.Sections.Add( chartSection ); return report; }
protected void AddLimitedScopeVariable(IAnalysisResult res, int start, int end) { if (LimitedScopeVariables.ContainsKey(res.Name)) { LimitedScopeVariables[res.Name].Add(new Tuple <IAnalysisResult, IndexSpan>(res, new IndexSpan(start, end - start))); } else { LimitedScopeVariables.Add(res.Name, new List <Tuple <IAnalysisResult, IndexSpan> > { new Tuple <IAnalysisResult, IndexSpan>(res, new IndexSpan(start, end - start)) }); } }
private void AddStandaloneCharts(IAnalysisResult result, Report report) { var visitor = new ChartSectionVisitor(); var walker = new ReportWalker(visitor); walker.Visit(result.Report); var standaloneCharts = visitor.Sections .Where(section => !HandledByChartMergeOperators(section)) .ToList(); report.Sections.AddRange(standaloneCharts); }
public AbstractSection Merge( IAnalysisResult result ) { var visitor = new GenericChartSectionVisitor( Indicators ); var walker = new ReportWalker( visitor ); walker.Visit( result.Report ); if ( !visitor.Sections.Any() ) { return null; } var section = CreateMergedChartsSection( result.Stock, visitor.Sections ); return section; }
public void BindTableResult(IAnalysisResult tableResult, IParser parser) { if (string.IsNullOrWhiteSpace(tableResult.Name)) { parser.ReportSyntaxError(tableResult.LocationIndex, tableResult.LocationIndex + 1, "Database table found with no name.", Severity.Error); } else { if (!Tables.ContainsKey(tableResult.Name)) { Tables.Add(tableResult.Name, tableResult); } } }
public AbstractSection Merge(IAnalysisResult result) { var visitor = new GenericChartSectionVisitor(Indicators); var walker = new ReportWalker(visitor); walker.Visit(result.Report); if (!visitor.Sections.Any()) { return(null); } var section = CreateMergedChartsSection(result.Stock, visitor.Sections); return(section); }
public bool HasChildFunctions(Genero4glAst ast) { if (Children.Count == 1) { var node = Children[Children.Keys[0]]; if (node is ArrayTypeReference) { return(true); } else if (node is RecordDefinitionNode) { return((node as RecordDefinitionNode).HasChildFunctions(ast)); } } else { if (!string.IsNullOrWhiteSpace(_typeNameString)) { if (_typeNameString.Equals("string", StringComparison.OrdinalIgnoreCase)) { return(true); } else { // try to determine if the _typeNameString is a user defined type IAnalysisResult udt = ast.TryGetUserDefinedType(_typeNameString, LocationIndex); if (udt != null) { return(udt.HasChildFunctions(ast)); } // check for package class IGeneroProject dummyProj; IProjectEntry projEntry; bool dummyDef; udt = ast.GetValueByIndex(_typeNameString, LocationIndex, ast._functionProvider, ast._databaseProvider, ast._programFileProvider, false, out dummyDef, out dummyProj, out projEntry); if (udt != null) { return(udt.HasChildFunctions(ast)); } } } } return(false); }
public ComposedResult(IAnalysisResult[] results) { this.results = results; }
private void EvaluateGoodCandidates(IAnalysisResult analysisResult) { var repeatedGoodCandidates = analysisResult.GoodCandidates.Where(g => this.goodCandidates.Any(x => x.Equals(g))); foreach (var repeatedGoodCandidate in repeatedGoodCandidates) { this.numberBuilder.IncludeAlways(repeatedGoodCandidate); this.confirmedGoods.Add(repeatedGoodCandidate); this.badCandidates.Remove(repeatedGoodCandidate.Value); var goodCandidateToRemove = this.goodCandidates.FirstOrDefault(g => g.Equals(repeatedGoodCandidate)); this.goodCandidates.Remove(goodCandidateToRemove); } var possibleGoodCandidates = analysisResult.GoodCandidates.Where(g => !this.confirmedGoods.Any(x => x.Equals(g))); foreach (var possibleGoodCandidate in possibleGoodCandidates) { this.goodCandidates.Add(possibleGoodCandidate); } }
public AnalysisPerformedEventArgs(IAnalysisResult result) { Result = result; }
private void EvaluateBadCandidates(IAnalysisResult analysisResult) { var repeatedBadCandidates = analysisResult.BadCandidates.Where(b => this.badCandidates.Any(x => x == b)); foreach (var repeatedBadCandidate in repeatedBadCandidates) { this.numberBuilder.ExcludeAlways(repeatedBadCandidate); this.confirmedBads.Add(repeatedBadCandidate); this.badCandidates.Remove(repeatedBadCandidate); var goodCandidatesToRemove = this.goodCandidates .Where(g => g.Value == repeatedBadCandidate) .ToList(); foreach(var goodCandidateToRemove in goodCandidatesToRemove) { this.goodCandidates.Remove(goodCandidateToRemove); } } var possibleBadCandidates = analysisResult.BadCandidates.Where(b => !this.confirmedBads.Any(x => x == b)); foreach (var possibleBadCandidate in possibleBadCandidates) { this.badCandidates.Add(possibleBadCandidate); } }