Exemplo n.º 1
0
        private void ResolveInternal(CancellationToken token)
        {
            var components = new List <VBComponent>();

            foreach (var project in _state.Projects)
            {
                if (project.Protection == vbext_ProjectProtection.vbext_pp_locked)
                {
                    continue;
                }

                foreach (VBComponent component in project.VBComponents)
                {
                    components.Add(component);
                }
            }

            if (!_state.HasAllParseTrees(components))
            {
                return;
            }
            _projectDeclarations.Clear();
            _state.ClearBuiltInReferences();
            foreach (var kvp in _state.ParseTrees)
            {
                var qualifiedName = kvp.Key;
                Logger.Debug("Module '{0}' {1}", qualifiedName.ComponentName, _state.IsNewOrModified(qualifiedName) ? "was modified" : "was NOT modified");
                // modified module; walk parse tree and re-acquire all declarations
                if (token.IsCancellationRequested)
                {
                    return;
                }
                ResolveDeclarations(qualifiedName.Component, kvp.Value);
            }

            _state.SetStatusAndFireStateChanged(ParserState.ResolvedDeclarations);

            // walk all parse trees (modified or not) for identifier references
            var finder = new DeclarationFinder(_state.AllDeclarations, _state.AllComments, _state.AllAnnotations);
            var passes = new List <ICompilationPass>
            {
                // This pass has to come first because the type binding resolution depends on it.
                new ProjectReferencePass(finder),
                new TypeHierarchyPass(finder, new VBAExpressionParser()),
                new TypeAnnotationPass(finder, new VBAExpressionParser())
            };

            passes.ForEach(p => p.Execute());
            foreach (var kvp in _state.ParseTrees)
            {
                if (token.IsCancellationRequested)
                {
                    return;
                }
                ResolveReferences(finder, kvp.Key.Component, kvp.Value);
            }
        }
 public void SetStatusAndFireStateChanged(object requestor, ParserState status, CancellationToken token)
 {
     _state.SetStatusAndFireStateChanged(requestor, status, token);
 }