<commit_before>package ca.concordia.cssanalyser.preprocessors.constructsinfo;

import java.io.File;

import org.apache.commons.lang.NotImplementedException;

import com.github.sommeri.less4j.core.ast.Import;
import com.github.sommeri.less4j.core.ast.StyleSheet;

import ca.concordia.cssanalyser.parser.ParseException;
import ca.concordia.cssanalyser.parser.less.LessCSSParser;
import ca.concordia.cssanalyser.parser.less.ModifiedLessFileSource;
import ca.concordia.cssanalyser.preprocessors.util.less.ImportInliner;

public class LessImport extends LessConstruct {
	
	private final Import originalImportNode;
	private final String url;
	private final String importedFileAbsolutePath;
	private final int line;
	private final int column;
	
	public LessImport(Import importNode, StyleSheet styleSheet) throws Exception {
		super(styleSheet);
		this.originalImportNode = importNode;
		this.url = ImportInliner.getURLFromImportStatement(originalImportNode);
		this.line = importNode.getSourceLine();
		this.column = importNode.getSourceColumn();
		if (!this.url.startsWith("http")) {
			File importedFile = new File(this.url);
			if (importedFile.isAbsolute()) {
				if (importedFile.exists()) {
					this.importedFileAbsolutePath = this.url;
				} else {
					this.importedFileAbsolutePath = "";
				}
			} else {
				String absolutePath = (new File(styleSheet.getSource().toString())).getParentFile().getAbsolutePath()
						+ File.separator 
						+ this.url;
				importedFile = new File(absolutePath);
				if (importedFile.exists()) {
					this.importedFileAbsolutePath = absolutePath;
				} else {
					if (!this.url.endsWith(".less")) {
						absolutePath += ".less";
						if ((new File(absolutePath)).exists()) {<commit_msg>Avoid directories with the same name as files when trying to import<commit_after>package ca.concordia.cssanalyser.preprocessors.constructsinfo;

import java.io.File;

import org.apache.commons.lang.NotImplementedException;

import com.github.sommeri.less4j.core.ast.Import;
import com.github.sommeri.less4j.core.ast.StyleSheet;

import ca.concordia.cssanalyser.parser.ParseException;
import ca.concordia.cssanalyser.parser.less.LessCSSParser;
import ca.concordia.cssanalyser.parser.less.ModifiedLessFileSource;
import ca.concordia.cssanalyser.preprocessors.util.less.ImportInliner;

public class LessImport extends LessConstruct {
	
	private final Import originalImportNode;
	private final String url;
	private final String importedFileAbsolutePath;
	private final int line;
	private final int column;
	
	public LessImport(Import importNode, StyleSheet styleSheet) throws Exception {
		super(styleSheet);
		this.originalImportNode = importNode;
		this.url = ImportInliner.getURLFromImportStatement(originalImportNode);
		this.line = importNode.getSourceLine();
		this.column = importNode.getSourceColumn();
		if (!this.url.startsWith("http")) {
			File importedFile = new File(this.url);
			if (importedFile.isAbsolute()) {
				if (importedFile.exists()) {
					this.importedFileAbsolutePath = this.url;
				} else {
					this.importedFileAbsolutePath = "";
				}
			} else {
				String absolutePath = (new File(styleSheet.getSource().toString())).getParentFile().getAbsolutePath()
						+ File.separator 
						+ this.url;
				importedFile = new File(absolutePath);
				if (importedFile.exists() && !importedFile.isDirectory()) {
					this.importedFileAbsolutePath = absolutePath;
				} else {
					if (!this.url.endsWith(".less")) {
						absolutePath += ".less";
						if ((new File(absolutePath)).exists()) {
{'fraction_non_alphanumeric': 0.11076575303758124, 'fraction_numerical': 0.0011302627860977678, 'mean_word_length': 4.718901453957997, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1093073', 'n_tokens_mistral': 1203, 'n_tokens_neox': 1061, 'n_words': 202}