Example #1
0
        protected IReadOnlyList <Declaration> IsMissingDeclarations(DeclarationFinder finder)
        {
            var vbaProjects = finder.Projects
                              .Where(project => project.IdentifierName == "VBA" && !project.IsUserDefined)
                              .ToList();

            if (!vbaProjects.Any())
            {
                return(new List <Declaration>());
            }

            var informationModules = vbaProjects
                                     .Select(project => finder.FindStdModule("Information", project, true))
                                     .OfType <ModuleDeclaration>()
                                     .ToList();

            if (!informationModules.Any())
            {
                return(new List <Declaration>());
            }

            var isMissing = informationModules
                            .SelectMany(module => module.Members)
                            .Where(decl => IsMissingQualifiedNames.Contains(decl.QualifiedName.ToString()))
                            .OfType <ModuleBodyElementDeclaration>();

            return(isMissing
                   .SelectMany(declaration => declaration.Parameters)
                   .ToList());
        }
        private IEnumerable <ModuleBodyElementDeclaration> DeclarationsWithExcludedArgumentUsage(DeclarationFinder finder)
        {
            var vbaProjects = finder.Projects
                              .Where(project => project.IdentifierName == "VBA" && !project.IsUserDefined)
                              .ToList();

            if (!vbaProjects.Any())
            {
                return(new List <ModuleBodyElementDeclaration>());
            }

            var stringModules = vbaProjects
                                .Select(project => finder.FindStdModule("Strings", project, true))
                                .OfType <ModuleDeclaration>()
                                .ToList();

            if (!stringModules.Any())
            {
                return(new List <ModuleBodyElementDeclaration>());
            }

            return(stringModules
                   .SelectMany(module => module.Members)
                   .Where(decl => IgnoredFunctions.Contains(decl.QualifiedName.ToString()))
                   .OfType <ModuleBodyElementDeclaration>());
        }
        private void AddBuiltInDeclarations(IReadOnlyList <VBProject> projects)
        {
            var finder = new DeclarationFinder(_state.AllDeclarations, new CommentNode[] { }, new IAnnotation[] { });

            foreach (var item in finder.MatchName(Tokens.Err))
            {
                if (item.IsBuiltIn && item.DeclarationType == DeclarationType.Variable &&
                    item.Accessibility == Accessibility.Global)
                {
                    return;
                }
            }

            var vba = finder.FindProject("VBA");

            if (vba == null)
            {
                // if VBA project is null, we haven't loaded any COM references;
                // we're in a unit test and mock project didn't setup any references.
                return;
            }
            var informationModule = finder.FindStdModule("Information", vba, true);

            Debug.Assert(informationModule != null, "We expect the information module to exist in the VBA project.");
            var customDeclarations = CustomDeclarations.Load(vba, informationModule);

            lock (_state)
            {
                foreach (var customDeclaration in customDeclarations)
                {
                    _state.AddDeclaration(customDeclaration);
                }
            }
        }
        private void UpdateAliasFunctionModulesFromReferencedProjects(DeclarationFinder finder)
        {
            var vba = finder.FindProject("VBA");

            if (vba == null)
            {
                // If the VBA project is null, we haven't loaded any COM references;
                // we're in a unit test and the mock project didn't setup any references.
                return;
            }

            _conversionModule  = finder.FindStdModule("Conversion", vba, true);
            _fileSystemModule  = finder.FindStdModule("FileSystem", vba, true);
            _interactionModule = finder.FindStdModule("Interaction", vba, true);
            _stringsModule     = finder.FindStdModule("Strings", vba, true);
            _dateTimeModule    = finder.FindStdModule("DateTime", vba, true);
            _hiddenModule      = finder.FindStdModule("_HiddenModule", vba, true);
        }