<commit_before>package org.drools.eclipse.refactoring;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;

/**
 * To detect the DRL files in the project
 * @author <NAME>
 *
 */
public class DRLProjectDetector {

	private List<IFile> resources;

	public DRLProjectDetector() {
		resources = new ArrayList<IFile>();
	}

	public List<IFile> detect(IProject project) throws CoreException {
		detect(project.members());
		return resources;
	}

	private void detect(IResource[] members) throws CoreException {
		for (int i = 0; i < members.length; i++) {
			if (members[i] instanceof IFolder) {
				IFolder folder = (IFolder)members[i];
				if (!folder.isDerived())
					detect(((IFolder)members[i]).members());
			}
			if (members[i] instanceof IFile) {
				IFile file = (IFile)members[i];
				if (file.getFileExtension().equalsIgnoreCase("drl"))
					if (file.isAccessible() && !file.isReadOnly() && !file.isDerived())
						resources.add(file);
			}<commit_msg>JBRULES-2450: Nullpointer Exception when refacroring in unreleted projectsa  - made sure no NPE can occur in this part of the code anymore<commit_after>package org.drools.eclipse.refactoring;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;

/**
 * To detect the DRL files in the project
 * @author <NAME>ador
 *
 */
public class DRLProjectDetector {

	private List<IFile> resources;

	public DRLProjectDetector() {
		resources = new ArrayList<IFile>();
	}

	public List<IFile> detect(IProject project) throws CoreException {
		detect(project.members());
		return resources;
	}

	private void detect(IResource[] members) throws CoreException {
		if (members == null) {
			return;
		}
		for (int i = 0; i < members.length; i++) {
			if (members[i] instanceof IFolder) {
				IFolder folder = (IFolder) members[i];
				if (!folder.isDerived())
					detect(folder.members());
			} else if (members[i] instanceof IFile) {
				IFile file = (IFile) members[i];
				if (file.getFileExtension() != null && file.getFileExtension().equalsIgnoreCase("drl"))
					if (file.isAccessible() && !file.isReadOnly() && !file.isDerived())
						resources.add(file);
			}
{'fraction_non_alphanumeric': 0.13268101761252446, 'fraction_numerical': 0.0023483365949119373, 'mean_word_length': 4.438297872340425, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4632946', 'n_tokens_mistral': 885, 'n_tokens_neox': 794, 'n_words': 195}