Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
using Rubberduck.CodeAnalysis.Settings;
using Rubberduck.Inspections.Abstract;
using Rubberduck.Inspections.Inspections.Extensions;
using Rubberduck.Inspections.Results;
using Rubberduck.Parsing.Inspections.Abstract;
using Rubberduck.Parsing.Symbols;
using Rubberduck.Parsing.VBA;
using Rubberduck.Resources;
using Rubberduck.Settings;
using Rubberduck.SettingsProvider;

namespace Rubberduck.Inspections.Concrete
Expand Down Expand Up @@ -104,9 +104,9 @@ public sealed class HungarianNotationInspection : InspectionBase

#endregion

private readonly IPersistanceService<CodeInspectionSettings> _settings;
private readonly IPersistenceService<CodeInspectionSettings> _settings;

public HungarianNotationInspection(RubberduckParserState state, IPersistanceService<CodeInspectionSettings> settings)
public HungarianNotationInspection(RubberduckParserState state, IPersistenceService<CodeInspectionSettings> settings)
: base(state)
{
_settings = settings;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Rubberduck.CodeAnalysis.Settings;
using Rubberduck.Common;
using Rubberduck.Inspections.Abstract;
using Rubberduck.Inspections.Results;
Expand All @@ -9,17 +10,16 @@
using Rubberduck.Parsing.Symbols;
using Rubberduck.Parsing.VBA;
using Rubberduck.Resources;
using Rubberduck.Settings;
using Rubberduck.SettingsProvider;
using static Rubberduck.Parsing.Grammar.VBAParser;

namespace Rubberduck.Inspections.Concrete
{
public sealed class UseMeaningfulNameInspection : InspectionBase
{
private readonly IPersistanceService<CodeInspectionSettings> _settings;
private readonly IPersistenceService<CodeInspectionSettings> _settings;

public UseMeaningfulNameInspection(RubberduckParserState state, IPersistanceService<CodeInspectionSettings> settings)
public UseMeaningfulNameInspection(RubberduckParserState state, IPersistenceService<CodeInspectionSettings> settings)
: base(state)
{
_settings = settings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
using System.Linq;
using Rubberduck.Parsing.Inspections.Abstract;
using Rubberduck.Settings;
using Rubberduck.CodeAnalysis.Settings;

namespace Rubberduck.CodeAnalysis.Inspections
{
public class InspectionProvider : IInspectionProvider
{
public InspectionProvider(IEnumerable<IInspection> inspections)
{
var defaultSettings = new DefaultSettings<CodeInspectionSettings>().Default;
var defaultSettings = new DefaultSettings<CodeInspectionSettings, Properties.CodeInspectionDefaults>().Default;
var defaultNames = defaultSettings.CodeInspections.Select(x => x.Name);
var defaultInspections = inspections.Where(inspection => defaultNames.Contains(inspection.Name));

Expand Down
21 changes: 10 additions & 11 deletions Rubberduck.CodeAnalysis/Inspections/Inspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
using Rubberduck.Parsing.Inspections.Abstract;
using Rubberduck.Parsing.VBA;
using Rubberduck.Parsing.VBA.Parsing;
using Rubberduck.Settings;
using Rubberduck.UI.Inspections;
using Rubberduck.VBEditor;
using Rubberduck.Resources;
using Rubberduck.SettingsProvider;
using Rubberduck.CodeAnalysis.Settings;

namespace Rubberduck.Inspections
{
Expand All @@ -27,29 +27,28 @@ namespace Rubberduck.Inspections
public class Inspector : IInspector
{
private const int _maxDegreeOfInspectionParallelism = -1;

private readonly IGeneralConfigService _configService;
private readonly IConfigurationService<CodeInspectionSettings> _configService;
private readonly List<IInspection> _inspections;

public Inspector(IGeneralConfigService configService, IInspectionProvider inspectionProvider)
public Inspector(IConfigurationService<CodeInspectionSettings> configService, IInspectionProvider inspectionProvider)
{
_inspections = inspectionProvider.Inspections.ToList();

_configService = configService;
configService.SettingsChanged += ConfigServiceSettingsChanged;
}

private void ConfigServiceSettingsChanged(object sender, EventArgs e)
{
var config = _configService.LoadConfiguration();
var config = _configService.Read();
UpdateInspectionSeverity(config);
}

private void UpdateInspectionSeverity(Configuration config)
private void UpdateInspectionSeverity(CodeInspectionSettings config)
{
foreach (var inspection in _inspections)
{
foreach (var setting in config.UserSettings.CodeInspectionSettings.CodeInspections)
foreach (var setting in config.CodeInspections)
{
if (inspection.Name == setting.Name)
{
Expand All @@ -72,7 +71,7 @@ public async Task<IEnumerable<IInspectionResult>> FindIssuesAsync(RubberduckPars
var allIssues = new ConcurrentBag<IInspectionResult>();
token.ThrowIfCancellationRequested();

var config = _configService.LoadConfiguration();
var config = _configService.Read();
UpdateInspectionSeverity(config);
token.ThrowIfCancellationRequested();

Expand All @@ -93,7 +92,7 @@ public async Task<IEnumerable<IInspectionResult>> FindIssuesAsync(RubberduckPars
{
try
{
WalkTrees(config.UserSettings.CodeInspectionSettings, state, parseTreeInspections.Where(i => i.TargetKindOfCode == parsePass), parsePass);
WalkTrees(config, state, parseTreeInspections.Where(i => i.TargetKindOfCode == parsePass), parsePass);
}
catch (Exception e)
{
Expand Down
157 changes: 157 additions & 0 deletions Rubberduck.CodeAnalysis/Properties/CodeInspectionDefaults.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading