Exemplo n.º 1
0
        private void AddBuiltInDeclarations(IReadOnlyList <VBProject> projects)
        {
            SyncComReferences(projects);

            var finder = new DeclarationFinder(_state.AllDeclarations, new CommentNode[] {}, new IAnnotation[] {});

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

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

            Debug.Assert(vba != null);

            var errObject = finder.FindClass(vba, "ErrObject", true);

            Debug.Assert(errObject != null);

            var qualifiedName = new QualifiedModuleName(vba.IdentifierName, vba.IdentifierName, errObject.IdentifierName);
            var err           = new Declaration(new QualifiedMemberName(qualifiedName, Tokens.Err), vba, "Global", errObject.IdentifierName, true, false, Accessibility.Global, DeclarationType.Variable);

            _state.AddDeclaration(err);

            var debugClassName = new QualifiedModuleName(vba.IdentifierName, vba.IdentifierName, "DebugClass");
            var debugClass     = new Declaration(new QualifiedMemberName(debugClassName, "DebugClass"), vba, "Global", "DebugClass", false, false, Accessibility.Global, DeclarationType.ClassModule);
            var debugObject    = new Declaration(new QualifiedMemberName(debugClassName, "Debug"), vba, "Global", "DebugClass", true, false, Accessibility.Global, DeclarationType.Variable);
            var debugAssert    = new Declaration(new QualifiedMemberName(debugClassName, "Assert"), debugObject, debugObject.Scope, null, false, false, Accessibility.Global, DeclarationType.Procedure);
            var debugPrint     = new Declaration(new QualifiedMemberName(debugClassName, "Print"), debugObject, debugObject.Scope, null, false, false, Accessibility.Global, DeclarationType.Procedure);

            _state.AddDeclaration(debugClass);
            _state.AddDeclaration(debugObject);
            _state.AddDeclaration(debugAssert);
            _state.AddDeclaration(debugPrint);
        }