private string GetVariableNameFeedback() { if (string.IsNullOrEmpty(NewName)) { return(string.Empty); } if (_forbiddenNames.Any(name => name.Equals(NewName, StringComparison.OrdinalIgnoreCase))) { return(string.Format(RubberduckUI.AssignedByValDialog_NewNameAlreadyUsedFormat, NewName)); } if (VariableNameValidator.StartsWithDigit(NewName)) { return(RubberduckUI.AssignedByValDialog_DoesNotStartWithLetter); } if (VariableNameValidator.HasSpecialCharacters(NewName)) { return(RubberduckUI.AssignedByValDialog_InvalidCharacters); } if (VariableNameValidator.IsReservedIdentifier(NewName)) { return(string.Format(RubberduckUI.AssignedByValDialog_ReservedKeywordFormat, NewName)); } if (!VariableNameValidator.IsMeaningfulName(NewName)) { return(string.Format(RubberduckUI.AssignedByValDialog_QuestionableEntryFormat, NewName)); } return(string.Empty); }
protected override IEnumerable <IInspectionResult> DoGetInspectionResults() { var settings = _settings.Load(new CodeInspectionSettings()) ?? new CodeInspectionSettings(); var whitelistedNames = settings.WhitelistedIdentifiers.Select(s => s.Identifier).ToArray(); var handlers = State.DeclarationFinder.FindEventHandlers(); var issues = UserDeclarations .Where(declaration => !string.IsNullOrEmpty(declaration.IdentifierName) && !IgnoreDeclarationTypes.Contains(declaration.DeclarationType) && !(declaration.Context is LineNumberLabelContext) && (declaration.ParentDeclaration == null || !IgnoreDeclarationTypes.Contains(declaration.ParentDeclaration.DeclarationType) && !handlers.Contains(declaration.ParentDeclaration)) && !whitelistedNames.Contains(declaration.IdentifierName) && !VariableNameValidator.IsMeaningfulName(declaration.IdentifierName)); return((from issue in issues let props = issue.DeclarationType.HasFlag(DeclarationType.Module) || issue.DeclarationType.HasFlag(DeclarationType.Project) ? new Dictionary <string, string> { { "DisableFixes", "IgnoreOnceQuickFix" } } : null select new DeclarationInspectionResult(this, string.Format(InspectionsUI.IdentifierNameInspectionResultFormat, RubberduckUI.ResourceManager.GetString("DeclarationType_" + issue.DeclarationType, CultureInfo.CurrentUICulture), issue.IdentifierName), issue, properties: props)) .ToList()); }
private string GetVariableNameFeedback() { if (string.IsNullOrEmpty(NewName)) { return(string.Empty); } if (_isConflictingName(NewName)) { return(string.Format(RubberduckUI.AssignedByValDialog_NewNameAlreadyUsedFormat, NewName)); } if (VariableNameValidator.StartsWithDigit(NewName)) { return(RubberduckUI.AssignedByValDialog_DoesNotStartWithLetter); } if (VariableNameValidator.HasSpecialCharacters(NewName)) { return(RubberduckUI.AssignedByValDialog_InvalidCharacters); } if (VariableNameValidator.IsReservedIdentifier(NewName)) { return(string.Format(RubberduckUI.AssignedByValDialog_ReservedKeywordFormat, NewName)); } if (!VariableNameValidator.IsMeaningfulName(NewName)) { return(string.Format(RubberduckUI.AssignedByValDialog_QuestionableEntryFormat, NewName)); } return(string.Empty); }
protected override IEnumerable <IInspectionResult> DoGetInspectionResults() { var settings = _settings.Load(new CodeInspectionSettings()) ?? new CodeInspectionSettings(); var whitelistedNames = settings.WhitelistedIdentifiers.Select(s => s.Identifier).ToArray(); var handlers = State.DeclarationFinder.FindEventHandlers(); var issues = UserDeclarations .Where(declaration => !string.IsNullOrEmpty(declaration.IdentifierName) && !IgnoreDeclarationTypes.Contains(declaration.DeclarationType) && !(declaration.Context is LineNumberLabelContext) && (declaration.ParentDeclaration == null || !IgnoreDeclarationTypes.Contains(declaration.ParentDeclaration.DeclarationType) && !handlers.Contains(declaration.ParentDeclaration)) && !whitelistedNames.Contains(declaration.IdentifierName) && !VariableNameValidator.IsMeaningfulName(declaration.IdentifierName)); return((from issue in issues select CreateInspectionResult(this, issue)) .ToList()); }