private void AnnotateType(Declaration declaration) { if (declaration.DeclarationType == DeclarationType.ClassModule || declaration.DeclarationType == DeclarationType.UserDefinedType || declaration.DeclarationType == DeclarationType.ComAlias) { declaration.AsTypeDeclaration = declaration; return; } string typeExpression; if (declaration.AsTypeContext != null && declaration.AsTypeContext.type().complexType() != null) { var typeContext = declaration.AsTypeContext; typeExpression = typeContext.type().complexType().GetText(); } else if (!string.IsNullOrWhiteSpace(declaration.AsTypeNameWithoutArrayDesignator) && !SymbolList.BaseTypes.Contains(declaration.AsTypeNameWithoutArrayDesignator.ToUpperInvariant())) { typeExpression = declaration.AsTypeNameWithoutArrayDesignator; } else { return; } var module = Declaration.GetModuleParent(declaration); if (module == null) { Logger.Warn("Type annotation failed for {0} because module parent is missing.", typeExpression); return; } var expressionContext = _expressionParser.Parse(typeExpression.Trim()); var boundExpression = _bindingService.ResolveType(module, declaration.ParentDeclaration, expressionContext); if (boundExpression.Classification != ExpressionClassification.ResolutionFailed) { declaration.AsTypeDeclaration = boundExpression.ReferencedDeclaration; } else { const string IGNORE_THIS = "DISPATCH"; if (typeExpression != IGNORE_THIS) { Logger.Warn("Failed to resolve type {0}", typeExpression); } } }
private void AddImplementedInterface(Declaration potentialClassModule) { if (!potentialClassModule.DeclarationType.HasFlag(DeclarationType.ClassModule)) { return; } var classModule = (ClassModuleDeclaration)potentialClassModule; foreach (var implementedInterfaceName in classModule.SupertypeNames) { var expressionContext = _expressionParser.Parse(implementedInterfaceName); var implementedInterface = _bindingService.ResolveType(potentialClassModule, potentialClassModule, expressionContext); if (implementedInterface.Classification != ExpressionClassification.ResolutionFailed) { classModule.AddSupertype(implementedInterface.ReferencedDeclaration); } else { Logger.Warn("Failed to resolve interface {0}.", implementedInterfaceName); } } }