protected override void Run(T element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer) { if (!myIsEnabled.Value) { return; } var ownerNamespace = element.GetContainingNamespaceDeclaration(); if (ownerNamespace != null) { var ownerNs = ownerNamespace.DeclaredElement; var declaredElement = Resolve(element); if (declaredElement != null) { var referencedNs = declaredElement.GetContainingNamespace(); var ownerMark = myMarks.GetMark(ownerNs); var referencedMark = myMarks.GetMark(referencedNs); var notSpecifiedClass = myMarks.EnumerateClasses(referencedMark.Substract(ownerMark)).FirstOrDefault(); if (notSpecifiedClass != null) { consumer.AddHighlighting(new IncorrectReferenceError(element, notSpecifiedClass, string.Format("Dependency on {0} is not satisfied in the containing namespace", notSpecifiedClass.ShortName)), element.GetContainingNode <IFile>()); } } } }
protected override void Run(IClassDeclaration classDeclaration, ElementProblemAnalyzerData data, IHighlightingConsumer consumer) { if (!myIsEnabled.Value) { return; } var typeElement = classDeclaration.DeclaredElement; if (typeElement == null || !ZoneConstants.IsZoneClass(typeElement)) { return; } var mark = myMarks.GetMark(typeElement.GetContainingNamespace()); var classes = myMarks.EnumerateClasses(mark).ToList(); // find all base zones var baseZones = new HashSet <IClass>(); foreach (var cls in classes) { foreach (var baseZone in MarksService.EnumerableMarkClasses(cls, true)) { if (!baseZone.Equals(cls)) { baseZones.Add(baseZone); } } } foreach (var typeUsage in classDeclaration.SuperTypeUsageNodes.OfType <IUserDeclaredTypeUsage>()) { IDeclaredType superType = CSharpTypeFactory.CreateDeclaredType(typeUsage); var superTypeElement = superType.GetTypeElement(); if (superTypeElement != null) { if (ZoneConstants.IsIRequire(superTypeElement as IInterface)) { var substitution = superType.GetSubstitution(); foreach (var parameter in substitution.Domain) { var zoneType = substitution[parameter] as IDeclaredType; if (zoneType != null) { var zoneClass = zoneType.GetTypeElement() as IClass; if (zoneClass != null && baseZones.Contains(zoneClass)) { consumer.AddHighlighting(new RedundantDependencySpecificationError(typeUsage), classDeclaration.GetContainingNode <IFile>()); } } } } } } }