示例#1
0
            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}'."));
            }
示例#2
0
        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);
        }
示例#3
0
 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;
 }
示例#4
0
        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);
        }
示例#5
0
            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);
                }
            }
示例#6
0
            public List<NodeHandler> GetHandlers(RuleAnalysisScope scope, int kind)
            {
                Contract.Requires(IsSingleCaseEnum(scope));

                return GetHandlerFields(scope)[kind];
            }
示例#7
0
 /// <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;
 }