protected void compileReferences(Project project, FileObject fileObject) { if (project == null) { // we need project for dependencies LOGGER.log(Level.INFO, "Cannot compile 'import' file {0}, no project", fileObject); return; } try { DependenciesGraph dependenciesGraph = CssIndex.get(project).getDependencies(fileObject); for (FileObject referring : dependenciesGraph.getAllReferingFiles()) { if (fileObject.equals(referring)) { // ignore myself continue; } processFile(project, referring, null, null); } } catch (IOException ex) { LOGGER.log(Level.WARNING, null, ex); } }
/** * Gets {@link CPCssIndexModel}s for all referred or related files (transitionally) * * @param allRelatedFiles if true the map will takes into account file relations regardless the direction of the imports. * if false then also referred files are taken into account. * @param file the base file * @param excludeTheBaseFile if true, model for the file passed as argument is not added to the result map. * @return */ public static Map<FileObject, CPCssIndexModel> getIndexModels(FileObject file, DependencyType dependencyType, boolean excludeTheBaseFile) throws IOException { Map<FileObject, CPCssIndexModel> models = new LinkedHashMap<>(); Project project = FileOwnerQuery.getOwner(file); if (project != null) { CssIndex index = CssIndex.get(project); DependenciesGraph dependencies = index.getDependencies(file); Collection<FileObject> referred = dependencies.getFiles(dependencyType); for (FileObject reff : referred) { if (excludeTheBaseFile && reff.equals(file)) { //skip current file (it is included to the referred files list) continue; } CPCssIndexModel cpIndexModel = (CPCssIndexModel) index.getIndexModel(CPCssIndexModel.Factory.class, reff); if (cpIndexModel != null) { models.put(reff, cpIndexModel); } } } return models; }