private List<NodeHandler>[] GetHandlerFields(RuleAnalysisScope scope) { Contract.Requires(IsSingleCaseEnum(scope)); if ((scope & RuleAnalysisScope.SpecFile) != RuleAnalysisScope.None) { return m_specHandlers; } if ((scope & RuleAnalysisScope.RootConfig) != RuleAnalysisScope.None) { return m_configHandlers; } if ((scope & RuleAnalysisScope.PackageConfig) != RuleAnalysisScope.None) { return m_packageConfigHandlers; } if ((scope & RuleAnalysisScope.BuildListFile) != RuleAnalysisScope.None) { return m_buildListHandlers; } throw Contract.AssertFailure( I($"Unknown RuleAnalysisScope '{scope}'.")); }
public List<NodeHandler> GetHandlers(RuleAnalysisScope scope, TypeScript.Net.Types.SyntaxKind syntaxKind) { Contract.Requires(IsSingleCaseEnum(scope), "Scope should have just once bit enabled!"); Contract.Requires((int)syntaxKind >= 0 && (int)syntaxKind <= (int)TypeScript.Net.Types.SyntaxKind.Count); return m_handlersesRepository.GetHandlers(scope, (int)syntaxKind); }
public DiagnosticContext(ISourceFile sourceFile, RuleAnalysisScope analysisScope, Logger logger, LoggingContext loggingContext, PathTable pathTable, Workspace workspace) { Workspace = workspace; PathTable = pathTable; SemanticModel = workspace?.GetSemanticModel(); SourceFile = sourceFile; AnalysisScope = analysisScope; LoggingContext = loggingContext; Logger = logger; }
private bool AnalyzeSourceFile(ISourceFile file, RuleAnalysisScope analysisScope, Logger logger, LoggingContext loggingContext, PathTable pathTable, Workspace workspace = null) { var context = new DiagnosticContext(file, analysisScope, logger, loggingContext, pathTable, workspace); // If the file is a public facade one, we don't need to run any linter rule on it since its original version has been already validated if (file.IsPublicFacade) { return(true); } VisitFile(file, context); return(logger.HasErrors); }
public void RegisterHandler(RuleAnalysisScope analysisScope, int kind, NodeHandler handler) { if ((analysisScope & RuleAnalysisScope.SpecFile) != RuleAnalysisScope.None) { m_specHandlers[kind].Add(handler); } if ((analysisScope & RuleAnalysisScope.RootConfig) != RuleAnalysisScope.None) { m_configHandlers[kind].Add(handler); } if ((analysisScope & RuleAnalysisScope.PackageConfig) != RuleAnalysisScope.None) { m_packageConfigHandlers[kind].Add(handler); } if ((analysisScope & RuleAnalysisScope.BuildListFile) != RuleAnalysisScope.None) { m_buildListHandlers[kind].Add(handler); } }
public List<NodeHandler> GetHandlers(RuleAnalysisScope scope, int kind) { Contract.Requires(IsSingleCaseEnum(scope)); return GetHandlerFields(scope)[kind]; }
/// <summary> /// Returns true if a given <paramref name="scope"/> has just one bit enabled. /// </summary> /// <remarks> /// In some cases this analysis is critical because it simplifies a lot an implementation logic and lead to more efficient implementation. /// This method is public only due to Code Contracts requirements. /// </remarks> public static bool IsSingleCaseEnum(RuleAnalysisScope scope) { return NumberOfSetBits((int)scope) == 1; }