protected override IEnumerable <IInspectionResult> DoGetInspectionResults(QualifiedModuleName module, DeclarationFinder finder) { var userDeclarations = finder.Members(module).ToList(); var identifierReferences = finder.IdentifierReferences(module).ToList(); var annotations = finder.FindAnnotations(module); var unboundAnnotations = UnboundAnnotations(annotations, userDeclarations, identifierReferences) .Where(annotation => !annotation.Annotation.Target.HasFlag(AnnotationTarget.General) || annotation.AnnotatedLine == null); var attributeAnnotationsOnDeclarationsNotAllowingAttributes = AttributeAnnotationsOnDeclarationsNotAllowingAttributes(userDeclarations); var illegalAnnotations = unboundAnnotations .Concat(attributeAnnotationsOnDeclarationsNotAllowingAttributes) .Distinct(); if (module.ComponentType == ComponentType.Document) { var attributeAnnotationsInDocuments = AttributeAnnotationsInDocuments(userDeclarations); illegalAnnotations = illegalAnnotations .Concat(attributeAnnotationsInDocuments) .Distinct(); } return(illegalAnnotations .Select(InspectionResult) .ToList()); }
protected override IEnumerable <IInspectionResult> DoGetInspectionResults(QualifiedModuleName module, DeclarationFinder finder) { var objectionableAnnotations = finder.FindAnnotations(module) .Where(IsResultAnnotation); return(objectionableAnnotations .Select(InspectionResult) .ToList()); }
protected sealed override IEnumerable <IInspectionResult> DoGetInspectionResults(QualifiedModuleName module, DeclarationFinder finder) { var annotations = finder.FindAnnotations(module); var userDeclarations = finder.Members(module).ToList(); var identifierReferences = finder.IdentifierReferences(module).ToList(); var invalidAnnotations = GetInvalidAnnotations(annotations, userDeclarations, identifierReferences); return(invalidAnnotations.Select(InspectionResult).ToList()); }
private static bool IsIgnoringInspectionResultFor(this QualifiedModuleName module, int line, DeclarationFinder declarationFinder, string inspectionName) { var lineScopedAnnotations = declarationFinder.FindAnnotations <IgnoreAnnotation>(module, line); var moduleDeclaration = declarationFinder.Members(module).First(decl => decl.DeclarationType.HasFlag(DeclarationType.Module)); var isLineIgnored = lineScopedAnnotations.Any(annotation => annotation.AnnotationArguments.Contains(inspectionName)); var isModuleIgnored = moduleDeclaration.HasModuleIgnoreFor(inspectionName); return(isLineIgnored || isModuleIgnored); }
public IEnumerable <IAnnotation> FindAnnotations(QualifiedModuleName module, int line) { var annotations = new List <IAnnotation>(); var moduleAnnotations = _declarationFinder.FindAnnotations(module).ToList(); // VBE 1-based indexing for (var i = line - 1; i >= 1; i--) { var annotation = moduleAnnotations.SingleOrDefault(a => a.QualifiedSelection.Selection.StartLine == i); if (annotation == null) { break; } annotations.Add(annotation); } return(annotations); }
public IEnumerable <IAnnotation> FindAnnotations(QualifiedModuleName module, int line) { var annotations = new List <IAnnotation>(); var moduleAnnotations = _declarationFinder.FindAnnotations(module).ToList(); // VBE 1-based indexing for (var currentLine = line - 1; currentLine >= 1; currentLine--) { if (!moduleAnnotations.Any(annotation => annotation.QualifiedSelection.Selection.StartLine <= currentLine && annotation.QualifiedSelection.Selection.EndLine >= currentLine)) { break; } var annotationsStartingOnCurrentLine = moduleAnnotations.Where(a => a.QualifiedSelection.Selection.StartLine == currentLine); annotations.AddRange(annotationsStartingOnCurrentLine); } return(annotations); }
private IEnumerable <IParseTreeAnnotation> FindIdentifierAnnotations(QualifiedModuleName module, int line) { return(_declarationFinder.FindAnnotations(module, line, AnnotationTarget.Identifier)); }
private IEnumerable <IAnnotation> FindIdentifierAnnotations(QualifiedModuleName module, int line) { return(_declarationFinder.FindAnnotations(module, line) .Where(annotation => annotation.AnnotationType.HasFlag(AnnotationType.IdentifierAnnotation))); }