Ejemplo n.º 1
0
        public void TestResolveIncludeBestStrategy()
        {
            string implementationFile = Path.Combine(TestData.RootDirectory, @"PackageA1\FileA.cpp");
            string headerFile         = "FileA.h";

            List <string> includePaths = new List <string>
            {
                Path.Combine(TestData.RootDirectory, "PackageA1"),
                Path.Combine(TestData.RootDirectory, "PackageA2"),
                Path.Combine(TestData.RootDirectory, "PackageA3")
            };
            IIncludeResolveStrategy  includeResolveStrategy = new BestMatchIncludeFileResolveStrategy(includePaths);
            IList <IncludeCandidate> candidates             = includeResolveStrategy.GetCandidates(headerFile);
            IList <string>           includes = includeResolveStrategy.Resolve(implementationFile, headerFile, candidates);

            Assert.AreEqual(1, includes.Count);
            Assert.AreEqual(Path.GetFullPath(Path.Combine(TestData.RootDirectory, @"PackageA1\FileA.h")), includes[0]);
        }
Ejemplo n.º 2
0
        private IIncludeResolveStrategy GetIncludeResolveStrategy()
        {
            IIncludeResolveStrategy includeResolveStrategy;

            switch (_analyzerSettings.ResolveMethod)
            {
            case ResolveMethod.AddBestMatch:
                includeResolveStrategy = new BestMatchIncludeFileResolveStrategy(_sourceDirectory.IncludeDirectories);
                break;

            case ResolveMethod.AddAll:
                includeResolveStrategy = new AllIncludeFileResolveStrategy(_sourceDirectory.IncludeDirectories);
                break;

            case ResolveMethod.Ignore:
                includeResolveStrategy = new IgnoreIncludeFileResolveStrategy(_sourceDirectory.IncludeDirectories);
                break;

            default:
                includeResolveStrategy = new IgnoreIncludeFileResolveStrategy(_sourceDirectory.IncludeDirectories);
                break;
            }
            return(includeResolveStrategy);
        }