Create an index containing all compilation units of Java files from
the source tree under the given root folder.

@param rootFolder
421562
public void indexSourceTree(final Folder rootFolder) {

		logger.info("Starting indexing of source tree " + rootFolder.getPath());

		final SecurityContext securityContext = rootFolder.getSecurityContext();
		app = StructrApp.getInstance(securityContext);

		structrTypeSolver.parseRoot(rootFolder);

		final CombinedTypeSolver typeSolver = new CombinedTypeSolver();
		typeSolver.add(new ReflectionTypeSolver());
		typeSolver.add(structrTypeSolver);

		facade = JavaParserFacade.get(typeSolver);

		logger.info("Done with indexing of source tree " + rootFolder.getPath());
	}
592416
public static final Index indexAllClasses(final List<File> classFiles) {
        final Indexer indexer = new Indexer();
        indexAllClasses(indexer, classFiles);
        return indexer.complete();
    }
880449
public void addJarsToIndex(final String folderPath) {

		logger.info("Starting adding jar files in " + folderPath);

		final CombinedTypeSolver typeSolver = new CombinedTypeSolver();
		typeSolver.add(new ReflectionTypeSolver());

		final AtomicLong count = new AtomicLong(0);

		try {
			Files.newDirectoryStream(Paths.get(folderPath), path -> path.toString().endsWith(".jar")).forEach((file) -> {
				try {
					typeSolver.add(new JarTypeSolver(new FileInputStream(file.toFile())));
					count.addAndGet(1L);

				} catch (IOException ex) {}
			}
148286
private static Collection<? extends URL> doFindPathMatchingJarResources(final URL rootDirResource, final String subPattern) {

        final Set<URL> result = new LinkedHashSet<URL>();

        JarFile jarFile = null;
        String jarFileUrl;
        String rootEntryPath = null;
        URLConnection con;
        boolean newJarFile = false;

        try {
            con = rootDirResource.openConnection();

            if (con instanceof JarURLConnection) {
                final JarURLConnection jarCon = (JarURLConnection) con;

                jarCon.setUseCaches(false);
                jarFile = jarCon.getJarFile();
                jarFileUrl = jarCon.getJarFileURL().toExternalForm();
                final JarEntry jarEntry = jarCon.getJarEntry();

                rootEntryPath = jarEntry != null ? jarEntry.getName() : "";
            } else {
                // No JarURLConnection -> need to resort to URL file parsing.
                // We'll assume URLs of the format "jar:path!/entry", with the
                // protocol
                // being arbitrary as long as following the entry format.
                // We'll also handle paths with and without leading "file:"
                // prefix.
                final String urlFile = rootDirResource.getFile();
                final int separatorIndex = urlFile.indexOf(JAR_URL_SEPARATOR);

                if (separatorIndex != -1) {
                    jarFileUrl = urlFile.substring(0, separatorIndex);
                    rootEntryPath = urlFile.substring(separatorIndex + JAR_URL_SEPARATOR.length());
                    jarFile = getJarFile(jarFileUrl);
                } else {
                    jarFile = new JarFile(urlFile);
                    jarFileUrl = urlFile;
                    rootEntryPath = "";
                }
                newJarFile = true;

            }

        } catch (final IOException e) {
            LOGGER.log(Level.ERROR, "reslove jar File error", e);
            return result;
        }
        try {
            if (!"".equals(rootEntryPath) && !rootEntryPath.endsWith("/")) {
                // Root entry path must end with slash to allow for proper
                // matching.
                // The Sun JRE does not return a slash here, but BEA JRockit
                // does.
                rootEntryPath = rootEntryPath + "/";
            }
            for (final Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements(); ) {
                final JarEntry entry = (JarEntry) entries.nextElement();
                final String entryPath = entry.getName();

                String relativePath = null;

                if (entryPath.startsWith(rootEntryPath)) {
                    relativePath = entryPath.substring(rootEntryPath.length());

                    if (AntPathMatcher.match(subPattern, relativePath)) {
                        if (relativePath.startsWith("/")) {
                            relativePath = relativePath.substring(1);
                        }
                        result.add(new URL(rootDirResource, relativePath));
                    }
                }
            }
            return result;
        } catch (final IOException e) {
            LOGGER.log(Level.ERROR, "parse the JarFile error", e);
        } finally {
            // Close jar file, but only if freshly obtained -
            // not from JarURLConnection, which might cache the file reference.
            if (newJarFile) {
                try {
                    jarFile.close();
                } catch (final IOException e) {
                    LOGGER.log(Level.WARN, " occur error when closing jarFile", e);
                }
            }
        }
        return result;
    }
770689
@GwtIncompatible("Unnecessary")
  private List<SourceFile> createSourceInputs(
      List<JsModuleSpec> jsModuleSpecs,
      List<FlagEntry<JsSourceType>> files,
      List<JsonFileSpec> jsonFiles,
      List<String> moduleRoots)
      throws IOException {
    if (isInTestMode()) {
      return inputsSupplierForTesting != null ? inputsSupplierForTesting.get()
          : null;
    }
    if (files.isEmpty() && jsonFiles == null) {
      // Request to read from stdin.
      files = ImmutableList.of(new FlagEntry<JsSourceType>(JsSourceType.JS, "-"));
    }

    for (JSError error : deduplicateIjsFiles(files, moduleRoots, !jsModuleSpecs.isEmpty())) {
      compiler.report(error);
    }

    try {
      if (jsonFiles != null) {
        return createInputs(files, jsonFiles, jsModuleSpecs);
      } else {
        return createInputs(files, true, jsModuleSpecs);
      }
    } catch (FlagUsageException e) {
      throw new FlagUsageException("Bad --js flag. " + e.getMessage());
    }
  }
639660
private void listDirectory(File directory,
                               RelativeDirectory subdirectory,
                               Set<JavaFileObject.Kind> fileKinds,
                               boolean recurse,
                               ListBuffer<JavaFileObject> resultList) {
        File d = subdirectory.getFile(directory);
        if (!caseMapCheck(d, subdirectory))
            return;

        File[] files = d.listFiles();
        if (files == null)
            return;

        if (sortFiles != null)
            Arrays.sort(files, sortFiles);

        for (File f: files) {
            String fname = f.getName();
            if (f.isDirectory()) {
                if (recurse && SourceVersion.isIdentifier(fname)) {
                    listDirectory(directory,
                                  new RelativeDirectory(subdirectory, fname),
                                  fileKinds,
                                  recurse,
                                  resultList);
                }
            } else {
                if (isValidFile(fname, fileKinds)) {
                    JavaFileObject fe =
                        new RegularFileObject(this, fname, new File(d, fname));
                    resultList.append(fe);
                }
            }
        }
    }
134742
public CmsResource ensureModelFolder(CmsResource rootResource) throws CmsException {

        String modelFolderPath = CmsStringUtil.joinPaths(m_adeConfig.getBasePath(), ".content/.templates");

        try {
            CmsResource result = m_cms.readFolder(modelFolderPath);
            return result;
        } catch (CmsVfsResourceNotFoundException e) {
            CmsProperty searchExclude = new CmsProperty(CmsPropertyDefinition.PROPERTY_SEARCH_EXCLUDE, "all", null);
            CmsResource result = m_cms.createResource(
                modelFolderPath,
                getType(CmsResourceTypeFolder.getStaticTypeName()),
                null,
                Arrays.asList(searchExclude));
            tryUnlock(result);
            return result;
        }

    }
659305
static void addToRootFileCache(File sourceFile, JarFile jarFile) {
		Map<File, JarFile> cache = rootFileCache.get();
		if (cache == null) {
			cache = new ConcurrentHashMap<>();
			rootFileCache = new SoftReference<>(cache);
		}
		cache.put(sourceFile, jarFile);
	}
773898
public static HttpFileService forClassPath(ClassLoader classLoader, String rootDir) {
        return HttpFileServiceBuilder.forClassPath(classLoader, rootDir).build();
    }
1057854
public void copyResources(String outputFolder) {

        logger.entering(new Object[] { outputFolder });

        copyResource(outputFolder, "RuntimeReporterResources.properties");
        copyResource(outputFolder, "Resources.properties");

        logger.exiting();
    }
716265
private static void createSimpleProject( File targetDirectory, CreationBean creationBean )
	throws IOException {

		// Create the directory structure
		String[] directoriesToCreate = creationBean.isReusableRecipe() ? RR_DIRECTORIES : ALL_DIRECTORIES;
		for( String s : directoriesToCreate ) {
			File dir = new File( targetDirectory, s );
			Utils.createDirectory( dir );
		}

		// Create the descriptor
		InputStream in = ProjectUtils.class.getResourceAsStream( "/application-skeleton.props" );
		ByteArrayOutputStream out = new ByteArrayOutputStream();
		Utils.copyStreamSafely( in, out );
		String tpl = out.toString( "UTF-8" )
				.replace( TPL_NAME, creationBean.getProjectName())
				.replace( TPL_VERSION, creationBean.getProjectVersion())
				.replace( TPL_DESCRIPTION, creationBean.getProjectDescription());

		// Create the rest of the project
		completeProjectCreation( targetDirectory, tpl, creationBean );
	}
284666
private static Collection<? extends URL> doFindPathMatchingFileResources(final URL rootDirResource, final String subPattern) {

        File rootFile = null;
        final Set<URL> rets = new LinkedHashSet<URL>();

        try {
            rootFile = new File(rootDirResource.toURI());
        } catch (final URISyntaxException e) {
            LOGGER.log(Level.ERROR, "cat not resolve the rootFile", e);
            throw new RuntimeException("cat not resolve the rootFile", e);
        }
        String fullPattern = StringUtils.replace(rootFile.getAbsolutePath(), File.separator, "/");

        if (!subPattern.startsWith("/")) {
            fullPattern += "/";
        }
        final String filePattern = fullPattern + StringUtils.replace(subPattern, File.separator, "/");

        @SuppressWarnings("unchecked") final Collection<File> files = FileUtils.listFiles(rootFile, new IOFileFilter() {
            @Override
            public boolean accept(final File dir, final String name) {
                return true;
            }

            @Override
            public boolean accept(final File file) {

                if (file.isDirectory()) {
                    return false;
                }
                if (AntPathMatcher.match(filePattern, StringUtils.replace(file.getAbsolutePath(), File.separator, "/"))) {
                    return true;
                }
                return false;
            }
        }, TrueFileFilter.INSTANCE);

        try {
            for (File file : files) {
                rets.add(file.toURI().toURL());
            }
        } catch (final Exception e) {
            LOGGER.log(Level.ERROR, "convert file to URL error", e);
            throw new RuntimeException("convert file to URL error", e);
        }

        return rets;
    }
151867
public List<JCCompilationUnit> enterTrees(List<JCCompilationUnit> roots) {
        //enter symbols for all files
        if (!taskListener.isEmpty()) {
            for (JCCompilationUnit unit: roots) {
                TaskEvent e = new TaskEvent(TaskEvent.Kind.ENTER, unit);
                taskListener.started(e);
            }
        }

        enter.main(roots);

        if (!taskListener.isEmpty()) {
            for (JCCompilationUnit unit: roots) {
                TaskEvent e = new TaskEvent(TaskEvent.Kind.ENTER, unit);
                taskListener.finished(e);
            }
        }

        // If generating source, or if tracking public apis,
        // then remember the classes declared in
        // the original compilation units listed on the command line.
        if (needRootClasses || sourceOutput || stubOutput) {
            ListBuffer<JCClassDecl> cdefs = new ListBuffer<>();
            for (JCCompilationUnit unit : roots) {
                for (List<JCTree> defs = unit.defs;
                     defs.nonEmpty();
                     defs = defs.tail) {
                    if (defs.head instanceof JCClassDecl)
                        cdefs.append((JCClassDecl)defs.head);
                }
            }
            rootClasses = cdefs.toList();
        }

        // Ensure the input files have been recorded. Although this is normally
        // done by readSource, it may not have been done if the trees were read
        // in a prior round of annotation processing, and the trees have been
        // cleaned and are being reused.
        for (JCCompilationUnit unit : roots) {
            inputFiles.add(unit.sourcefile);
        }

        return roots;
    }
1324246
private void addSubDirectory(Path root, Path filePath) throws IOException {
        String listener = getListenerRootPath(root);

        List<String> listeners = mSubDirectories.get(listener);

        if (listeners != null) {
            if (mSubDirectories.get(listener).contains(filePath.toAbsolutePath())) {
                return;
            } else {
                mSubDirectories.get(listener).add(filePath.toString());
            }

            try {
                watchDir(filePath.toFile());
            } catch (IOException e) {
                throw new IOException("Could not watch the subdirectories.", e);
            }
        }
    }
1281275
private void loadRootFolder() {
        new Thread() {
            @Override
            public void run() {
                try {
                    //Api to fetch root folder
                    final BoxIteratorItems folderItems = mFolderApi.getItemsRequest(BoxConstants.ROOT_FOLDER_ID).send();
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            mAdapter.clear();
                            for (BoxItem boxItem: folderItems) {
                                mAdapter.add(boxItem);
                            }
                        }
                    });
                } catch (BoxException e) {
                    e.printStackTrace();
                }

            }
        }.start();
    }
1361595
@Override
    public ComponentBuilder addDirectory(String target) throws IOException
    {
        checkTarget(target);
        FileBuilder fb = new FileBuilder(target);
        fileBuilders.add(fb);
        return fb;
    }
474208
@Nonnull
  public PreprocessorContext setSources(@Nonnull @MustNotContainNull final List<String> folderPaths) {
    this.sources.clear();
    this.sources.addAll(assertDoesntContainNull(folderPaths).stream().map(x -> new SourceFolder(this.baseDir, x)).collect(Collectors.toList()));
    return this;
  }