示例#1
0
 public VariableNotAssignedInspection(RubberduckParserState state)
     : base(state)
 {
 }
示例#2
0
 protected override IQuickFix QuickFix(RubberduckParserState state)
 {
     return(new ReplaceObsoleteCommentMarkerQuickFix());
 }
示例#3
0
 public SpecifyExplicitPublicModifierQuickFix(RubberduckParserState state)
     : base(typeof(ImplicitPublicMemberInspection))
 {
     _state = state;
 }
 public static IEnumerable <Declaration> GetTestModules(this RubberduckParserState state)
 {
     return(state.AllUserDeclarations.Where(item =>
                                            item.DeclarationType == DeclarationType.ProceduralModule &&
                                            item.Annotations.Any(pta => pta.Annotation is TestModuleAnnotation)));
 }
示例#5
0
 public CodePaneRefactorRenameCommand(IVBE vbe, RubberduckParserState state, IMessageBox messageBox)
     : base(vbe)
 {
     _state      = state;
     _messageBox = messageBox;
 }
 public static IEnumerable <TestMethod> GetAllTests(RubberduckParserState state)
 {
     return(GetTestModuleProcedures(state)
            .Where(item => IsTestMethod(state, item))
            .Select(item => new TestMethod(item)));
 }
 public static bool IsTestMethod(RubberduckParserState state, Declaration item)
 {
     return(!state.AllUserDeclarations.Any(d =>
                                           d.DeclarationType == DeclarationType.Parameter && Equals(d.ParentScopeDeclaration, item)) &&
            item.Annotations.Any(pta => pta.Annotation is TestMethodAnnotation));
 }
 public OptionBaseZeroInspection(RubberduckParserState state)
     : base(state, CodeInspectionSeverity.Hint)
 {
 }
 public ObsoleteTypeHintInspection(RubberduckParserState state)
     : base(state, CodeInspectionSeverity.Suggestion)
 {
 }
 public override bool EvaluateCanExecute(RubberduckParserState state)
 {
     return(state != null && state.Status >= ParserState.ResolvedDeclarations && state.Status < ParserState.Error);
 }
示例#11
0
 protected override IInspection InspectionUnderTest(RubberduckParserState state)
 {
     return(new OnLocalErrorInspection(state));
 }
 public ImplicitVariantReturnTypeInspection(RubberduckParserState state)
     : base(state)
 {
 }
示例#13
0
 public ImplicitActiveSheetReferenceInspection(VBE vbe, RubberduckParserState state)
     : base(state)
 {
     _hostApp = vbe.HostApplication();
 }
示例#14
0
 public static IEnumerable <Declaration> FindTestInitializeMethods(QualifiedModuleName module, RubberduckParserState state)
 {
     return(GetTestModuleProcedures(state)
            .Where(m =>
                   m.QualifiedName.QualifiedModuleName == module &&
                   m.Annotations.Any(a => a.AnnotationType == AnnotationType.TestInitialize)));
 }
示例#15
0
 public SetExplicitVariantReturnTypeQuickFix(RubberduckParserState state)
     : base(typeof(ImplicitVariantReturnTypeInspection))
 {
     _state = state;
 }
 public IllegalAnnotationInspection(RubberduckParserState state)
     : base(state, CodeInspectionSeverity.Error)
 {
     Listener = new IllegalAttributeAnnotationsListener(state);
 }
示例#17
0
 public override bool EvaluateCanExecute(RubberduckParserState state)
 {
     return(state != null && Command.CanExecute(null));
 }
 public IllegalAttributeAnnotationsListener(RubberduckParserState state)
 {
     _state = state;
 }
示例#19
0
        public static IEnumerable <TestMethod> GetTests(IVBE vbe, IVBComponent component, RubberduckParserState state)
        {
            if (component == null || component.IsWrappingNullReference)
            {
                return(Enumerable.Empty <TestMethod>());
            }

            // apparently, sometimes it thinks the components are different but knows the modules are the same
            // if the modules are the same, then the component is the same as far as we are concerned
            return(GetAllTests(state)
                   .Where(test => state.ProjectsProvider.Component(test.Declaration).HasEqualCodeModule(component)));
        }
示例#20
0
 public ProjectExplorerRefactorRenameCommand(IVBE vbe, RubberduckParserState state, IMessageBox msgBox)
     : base(vbe)
 {
     _state  = state;
     _msgBox = msgBox;
 }
示例#21
0
 public static IEnumerable <Declaration> FindTestCleanupMethods(QualifiedModuleName module, RubberduckParserState state)
 {
     return(GetTestModuleProcedures(state)
            .Where(m =>
                   m.QualifiedName.QualifiedModuleName == module &&
                   m.Annotations.Any(pta => pta.Annotation is TestCleanupAnnotation)));
 }
示例#22
0
 public OptionExplicitInspection(RubberduckParserState state)
     : base(state)
 {
     Listener = new MissingOptionExplicitListener();
 }
示例#23
0
 public ParameterCanBeByValInspectionResult(IInspection inspection, RubberduckParserState state, Declaration target, ParserRuleContext context, QualifiedMemberName qualifiedName)
     : base(inspection, qualifiedName.QualifiedModuleName, context, target)
 {
     _state = state;
 }
示例#24
0
 public EncapsulateFieldPresenterFactory(IVBE vbe, RubberduckParserState state, IRefactoringDialog <EncapsulateFieldViewModel> view)
 {
     _vbe   = vbe;
     _view  = view;
     _state = state;
 }
 public EmptyIfBlockInspection(RubberduckParserState state)
     : base(state, CodeInspectionSeverity.DoNotShow)
 {
 }
 public EncapsulatePublicFieldInspection(RubberduckParserState state)
     : base(state, CodeInspectionSeverity.Suggestion)
 {
     _wrapperFactory = new CodePaneWrapperFactory();
 }
 private ToDoExplorerViewModel ArrangeViewModel(RubberduckParserState state, IConfigurationService <Configuration> configService)
 {
     return(new ToDoExplorerViewModel(state, configService, null, GetMockedUiDispatcher(), null));
 }
 public ParameterNotUsedInspection(RubberduckParserState state)
     : base(state)
 {
 }
示例#29
0
        public async Task <IEnumerable <IInspectionResult> > FindIssuesAsync(RubberduckParserState state, CancellationToken token)
        {
            if (state == null || !state.AllUserDeclarations.Any())
            {
                return(new IInspectionResult[] { });
            }
            token.ThrowIfCancellationRequested();

            state.OnStatusMessageUpdate(RubberduckUI.CodeInspections_Inspecting);
            var allIssues = new ConcurrentBag <IInspectionResult>();

            token.ThrowIfCancellationRequested();

            var config = _configService.Read();

            UpdateInspectionSeverity(config);
            token.ThrowIfCancellationRequested();

            var parseTreeInspections = _inspections
                                       .Where(inspection => inspection.Severity != CodeInspectionSeverity.DoNotShow)
                                       .OfType <IParseTreeInspection>()
                                       .ToArray();

            token.ThrowIfCancellationRequested();

            foreach (var listener in parseTreeInspections.Select(inspection => inspection.Listener))
            {
                listener.ClearContexts();
            }

            // Prepare ParseTreeWalker based inspections
            var passes = Enum.GetValues(typeof(CodeKind)).Cast <CodeKind>();

            foreach (var parsePass in passes)
            {
                try
                {
                    WalkTrees(config, state, parseTreeInspections.Where(i => i.TargetKindOfCode == parsePass), parsePass);
                }
                catch (Exception e)
                {
                    LogManager.GetCurrentClassLogger().Warn(e);
                }
            }
            token.ThrowIfCancellationRequested();

            var inspectionsToRun = _inspections.Where(inspection =>
                                                      inspection.Severity != CodeInspectionSeverity.DoNotShow &&
                                                      RequiredLibrariesArePresent(inspection, state) &&
                                                      RequiredHostIsPresent(inspection));

            token.ThrowIfCancellationRequested();

            try
            {
                await Task.Run(() => RunInspectionsInParallel(inspectionsToRun, allIssues, token));
            }
            catch (AggregateException exception)
            {
                if (exception.Flatten().InnerExceptions.All(ex => ex is OperationCanceledException))
                {
                    //This eliminates the stack trace, but for the cancellation, this is irrelevant.
                    throw exception.InnerException ?? exception;
                }

                LogManager.GetCurrentClassLogger().Error(exception);
            }
            catch (OperationCanceledException)
            {
                throw;
            }
            catch (Exception e)
            {
                LogManager.GetCurrentClassLogger().Error(e);
            }

            // should be "Ready"
            state.OnStatusMessageUpdate(RubberduckUI.ResourceManager.GetString("ParserState_" + state.Status, CultureInfo.CurrentUICulture));
            return(allIssues);
        }
示例#30
0
 public UnderscoreInPublicClassModuleMemberInspection(RubberduckParserState state)
     : base(state)
 {
 }