use of com.facebook.buck.json.DefaultProjectBuildFileParserFactory in project buck by facebook.
the class Cell method createBuildFileParserFactory.
private ProjectBuildFileParserFactory createBuildFileParserFactory() {
ParserConfig parserConfig = getBuckConfig().getView(ParserConfig.class);
boolean useWatchmanGlob = parserConfig.getGlobHandler() == ParserConfig.GlobHandler.WATCHMAN && watchman.hasWildmatchGlob();
boolean watchmanGlobStatResults = parserConfig.getWatchmanGlobSanityCheck() == ParserConfig.WatchmanGlobSanityCheck.STAT;
boolean watchmanUseGlobGenerator = watchman.getCapabilities().contains(Watchman.Capability.GLOB_GENERATOR);
boolean useMercurialGlob = parserConfig.getGlobHandler() == ParserConfig.GlobHandler.MERCURIAL;
String pythonInterpreter = parserConfig.getPythonInterpreter(new ExecutableFinder());
Optional<String> pythonModuleSearchPath = parserConfig.getPythonModuleSearchPath();
return new DefaultProjectBuildFileParserFactory(ProjectBuildFileParserOptions.builder().setProjectRoot(getFilesystem().getRootPath()).setCellRoots(getCellPathResolver().getCellPaths()).setPythonInterpreter(pythonInterpreter).setPythonModuleSearchPath(pythonModuleSearchPath).setAllowEmptyGlobs(parserConfig.getAllowEmptyGlobs()).setIgnorePaths(filesystem.getIgnorePaths()).setBuildFileName(getBuildFileName()).setAutodepsFilesHaveSignatures(config.getIncludeAutodepsSignature()).setDefaultIncludes(parserConfig.getDefaultIncludes()).setDescriptions(getAllDescriptions()).setUseWatchmanGlob(useWatchmanGlob).setWatchmanGlobStatResults(watchmanGlobStatResults).setWatchmanUseGlobGenerator(watchmanUseGlobGenerator).setWatchman(watchman).setWatchmanQueryTimeoutMs(parserConfig.getWatchmanQueryTimeoutMs()).setUseMercurialGlob(useMercurialGlob).setRawConfig(getBuckConfig().getRawConfigForParser()).setBuildFileImportWhitelist(parserConfig.getBuildFileImportWhitelist()).build());
}
use of com.facebook.buck.json.DefaultProjectBuildFileParserFactory in project buck by facebook.
the class JavaSymbolFinderIntegrationTest method shouldFindTargetDefiningSymbol.
@Test
public void shouldFindTargetDefiningSymbol() throws IOException, InterruptedException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "symbol_finder", temporaryFolder);
workspace.setUp();
ProjectFilesystem projectFilesystem = new ProjectFilesystem(temporaryFolder.getRoot());
ImmutableMap<String, String> environment = ImmutableMap.copyOf(System.getenv());
Config rawConfig = Configs.createDefaultConfig(projectFilesystem.getRootPath());
BuckConfig config = new BuckConfig(rawConfig, projectFilesystem, Architecture.detect(), Platform.detect(), environment, new DefaultCellPathResolver(projectFilesystem.getRootPath(), rawConfig));
ParserConfig parserConfig = config.getView(ParserConfig.class);
PythonBuckConfig pythonBuckConfig = new PythonBuckConfig(config, new ExecutableFinder());
ImmutableSet<Description<?>> allDescriptions = KnownBuildRuleTypesTestUtil.getDefaultKnownBuildRuleTypes(projectFilesystem, environment).getAllDescriptions();
SrcRootsFinder srcRootsFinder = new SrcRootsFinder(projectFilesystem);
ProjectBuildFileParserFactory projectBuildFileParserFactory = new DefaultProjectBuildFileParserFactory(ProjectBuildFileParserOptions.builder().setProjectRoot(projectFilesystem.getRootPath()).setPythonInterpreter(pythonBuckConfig.getPythonInterpreter()).setAllowEmptyGlobs(parserConfig.getAllowEmptyGlobs()).setIgnorePaths(projectFilesystem.getIgnorePaths()).setBuildFileName(parserConfig.getBuildFileName()).setDefaultIncludes(parserConfig.getDefaultIncludes()).setDescriptions(allDescriptions).setBuildFileImportWhitelist(parserConfig.getBuildFileImportWhitelist()).build());
BuckEventBus buckEventBus = BuckEventBusFactory.newInstance();
JavaSymbolFinder finder = new JavaSymbolFinder(projectFilesystem, srcRootsFinder, DEFAULT_JAVAC_OPTIONS, new ConstructorArgMarshaller(new DefaultTypeCoercerFactory(ObjectMappers.newDefaultInstance())), projectBuildFileParserFactory, config, buckEventBus, new TestConsole(), environment);
SetMultimap<String, BuildTarget> foundTargets = finder.findTargetsForSymbols(ImmutableSet.of("com.example.a.A"));
assertEquals("JavaSymbolFinder failed to find the right target.", ImmutableSetMultimap.of("com.example.a.A", BuildTargetFactory.newInstance(projectFilesystem, "//java/com/example/a:a")), foundTargets);
}
use of com.facebook.buck.json.DefaultProjectBuildFileParserFactory in project buck by facebook.
the class ResolverIntegrationTest method createParser.
@BeforeClass
public static void createParser() {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
BuckConfig buckConfig = FakeBuckConfig.builder().build();
ParserConfig parserConfig = buckConfig.getView(ParserConfig.class);
PythonBuckConfig pythonBuckConfig = new PythonBuckConfig(buckConfig, new ExecutableFinder());
ImmutableSet<Description<?>> descriptions = ImmutableSet.of(new RemoteFileDescription(new ExplodingDownloader()), new PrebuiltJarDescription());
DefaultProjectBuildFileParserFactory parserFactory = new DefaultProjectBuildFileParserFactory(ProjectBuildFileParserOptions.builder().setProjectRoot(filesystem.getRootPath()).setPythonInterpreter(pythonBuckConfig.getPythonInterpreter()).setAllowEmptyGlobs(parserConfig.getAllowEmptyGlobs()).setIgnorePaths(filesystem.getIgnorePaths()).setBuildFileName(parserConfig.getBuildFileName()).setDefaultIncludes(parserConfig.getDefaultIncludes()).setDescriptions(descriptions).setBuildFileImportWhitelist(parserConfig.getBuildFileImportWhitelist()).build());
buildFileParser = parserFactory.createParser(new ConstructorArgMarshaller(new DefaultTypeCoercerFactory(ObjectMappers.newDefaultInstance())), new TestConsole(), ImmutableMap.of(), BuckEventBusFactory.newInstance(), /* ignoreBuckAutodepsFiles */
false);
}
use of com.facebook.buck.json.DefaultProjectBuildFileParserFactory in project buck by facebook.
the class MissingSymbolsHandler method create.
public static MissingSymbolsHandler create(ProjectFilesystem projectFilesystem, ImmutableSet<Description<?>> descriptions, BuckConfig config, BuckEventBus buckEventBus, Console console, JavacOptions javacOptions, ImmutableMap<String, String> environment) {
SrcRootsFinder srcRootsFinder = new SrcRootsFinder(projectFilesystem);
ParserConfig parserConfig = config.getView(ParserConfig.class);
PythonBuckConfig pythonBuckConfig = new PythonBuckConfig(config, new ExecutableFinder());
ProjectBuildFileParserFactory projectBuildFileParserFactory = new DefaultProjectBuildFileParserFactory(ProjectBuildFileParserOptions.builder().setProjectRoot(projectFilesystem.getRootPath()).setPythonInterpreter(pythonBuckConfig.getPythonInterpreter()).setAllowEmptyGlobs(parserConfig.getAllowEmptyGlobs()).setIgnorePaths(projectFilesystem.getIgnorePaths()).setBuildFileName(parserConfig.getBuildFileName()).setAutodepsFilesHaveSignatures(config.getIncludeAutodepsSignature()).setDefaultIncludes(parserConfig.getDefaultIncludes()).setDescriptions(descriptions).setBuildFileImportWhitelist(parserConfig.getBuildFileImportWhitelist()).build());
JavaSymbolFinder javaSymbolFinder = new JavaSymbolFinder(projectFilesystem, srcRootsFinder, javacOptions, new ConstructorArgMarshaller(new DefaultTypeCoercerFactory(ObjectMappers.newDefaultInstance())), projectBuildFileParserFactory, config, buckEventBus, console, environment);
return new MissingSymbolsHandler(console, javaSymbolFinder, parserConfig.getBuildFileName());
}
Aggregations