public override IEnumerable <InspectionResultBase> GetInspectionResults()
        {
            var usages = UserDeclarations.Where(declaration =>
                                                declaration.DeclarationType == DeclarationType.Variable &&
                                                !UserDeclarations.Any(d => d.DeclarationType == DeclarationType.UserDefinedType &&
                                                                      d.IdentifierName == declaration.AsTypeName) &&
                                                !declaration.IsSelfAssigned &&
                                                !declaration.References.Any(reference => reference.IsAssignment))
                         .SelectMany(declaration => declaration.References)
                         .Where(usage => !usage.IsInspectionDisabled(AnnotationName));

            foreach (var issue in usages)
            {
                yield return(new UnassignedVariableUsageInspectionResult(this, issue.Context, issue.QualifiedModuleName, issue.Declaration));
            }
        }
        public override IEnumerable <InspectionResultBase> GetInspectionResults()
        {
            var declarations = UserDeclarations.Where(declaration =>
                                                      declaration.DeclarationType == DeclarationType.Variable &&
                                                      !UserDeclarations.Any(d => d.DeclarationType == DeclarationType.UserDefinedType &&
                                                                            d.IdentifierName == declaration.AsTypeName) &&
                                                      !declaration.IsSelfAssigned &&
                                                      !declaration.References.Any(reference => reference.IsAssignment && !IsIgnoringInspectionResultFor(reference, AnnotationName)));

            //The parameter scoping was apparently incorrect before - need to filter for the actual function.
            var lenFunction  = BuiltInDeclarations.SingleOrDefault(s => s.DeclarationType == DeclarationType.Function && s.Scope.Equals("VBE7.DLL;VBA.Strings.Len"));
            var lenbFunction = BuiltInDeclarations.SingleOrDefault(s => s.DeclarationType == DeclarationType.Function && s.Scope.Equals("VBE7.DLL;VBA.Strings.Len"));

            return(from issue in declarations
                   where issue.References.Any() &&
                   !DeclarationReferencesContainsReference(lenFunction, issue) &&
                   !DeclarationReferencesContainsReference(lenbFunction, issue)
                   select new UnassignedVariableUsageInspectionResult(this, issue.Context, issue.QualifiedName.QualifiedModuleName, issue));
        }
Beispiel #3
0
        public override IEnumerable <InspectionResultBase> GetInspectionResults()
        {
            var declarations = UserDeclarations.Where(declaration =>
                                                      declaration.DeclarationType == DeclarationType.Variable &&
                                                      !UserDeclarations.Any(d => d.DeclarationType == DeclarationType.UserDefinedType &&
                                                                            d.IdentifierName == declaration.AsTypeName) &&
                                                      !declaration.IsSelfAssigned &&
                                                      !declaration.References.Any(reference => reference.IsAssignment));

            var lenFunction  = BuiltInDeclarations.SingleOrDefault(s => s.Scope == "VBE7.DLL;VBA.Strings.Len");
            var lenbFunction = BuiltInDeclarations.SingleOrDefault(s => s.Scope == "VBE7.DLL;VBA.Strings.LenB");

            foreach (var issue in declarations)
            {
                if (DeclarationReferencesContainsReference(lenFunction, issue) ||
                    DeclarationReferencesContainsReference(lenbFunction, issue))
                {
                    continue;
                }

                yield return(new UnassignedVariableUsageInspectionResult(this, issue.Context, issue.QualifiedName.QualifiedModuleName, issue));
            }
        }