private void ResolveInternal(CancellationToken token)
{
var components = _state.Projects
.Where(project => project.Protection == vbext_ProjectProtection.vbext_pp_none)
.SelectMany(p => p.VBComponents.Cast<VBComponent>()).ToList();
if (!_state.HasAllParseTrees(components))
{
return;
}
foreach (var kvp in _state.ParseTrees)
{
var qualifiedName = kvp.Key;
if (true /*_state.IsModified(qualifiedName)*/)
{
Debug.WriteLine("Module '{0}' {1}", qualifiedName.ComponentName, _state.IsModified(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);
}
else
{
Debug.WriteLine(string.Format("Module '{0}' was not modified since last parse. Clearing identifier references...", kvp.Key.ComponentName));
// clear identifier references for non-modified modules
var declarations = _state.AllUserDeclarations.Where(item => item.QualifiedName.QualifiedModuleName.Equals(qualifiedName));
foreach (var declaration in declarations)
{
declaration.ClearReferences();
}
}
}
// walk all parse trees (modified or not) for identifier references
var finder = new DeclarationFinder(_state.AllDeclarations, _state.AllComments, _state.AllAnnotations);
foreach (var kvp in _state.ParseTrees)
{
if (token.IsCancellationRequested) return;
ResolveReferences(finder, kvp.Key.Component, kvp.Value);
}
}