All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.conqat.engine.sourcecode.coverage.TokenElementLineInfo Maven / Gradle / Ivy

The newest version!
package org.conqat.engine.sourcecode.coverage;

import java.io.Serializable;
import java.util.List;
import java.util.Set;

import org.conqat.lib.commons.collections.CompactLines;
import org.conqat.lib.commons.region.LineBasedRegion;
import org.conqat.lib.commons.string.LineOffsetConverter;
import org.conqat.lib.commons.test.IndexValueClass;

import eu.cqse.check.framework.scanner.ELanguage;

/** Consolidates line information about a TokenElement. */
@IndexValueClass
public final class TokenElementLineInfo implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * Stores the line ranges of all leaf statement shallow entities that span multiple lines.
	 */
	private final List multilineStatementRegions;

	/** Holds a precomputed line offset converter. */
	private final LineOffsetConverter rawLineOffsetConverter;

	/**
	 * All lines that are considered coverable within that token element. These lines refer to the raw
	 * lines before content filtering is applied (i.e. line numbers as they would appear in coverage
	 * reports), but content filtering has been taken into account for calculating the coverable lines
	 * (i.e. filtered lines do not show up as coverable here).
	 */
	private final CompactLines rawCoverableLines;

	/** The language of the token element of which the data was extracted. */
	private final ELanguage language;

	/**
	 * Lines that are explicitly excluded from coverage recording. This is currently used, e.g., for C++
	 * coverage if directives like CTC_SKIP or LCOV excludes are found. These lines are even excluded
	 * when
	 * {@link org.conqat.engine.core.configuration.EFeatureToggle#USE_COVERABLE_LINES_FROM_COVERAGE_REPORTS}
	 * is enabled.
	 */
	private final CompactLines excludedRawLines;

	/** Whether the token element is considered to be test code. */
	private final boolean testCode;

	public TokenElementLineInfo(List multilineStatementRegions,
			LineOffsetConverter rawLineOffsetConverter, Set rawCoverableLines, ELanguage language,
			List excludedRawLines, boolean testCode) {
		this.multilineStatementRegions = multilineStatementRegions;
		this.rawLineOffsetConverter = rawLineOffsetConverter;
		this.rawCoverableLines = new CompactLines(rawCoverableLines);
		this.language = language;
		this.excludedRawLines = new CompactLines(excludedRawLines);
		this.testCode = testCode;
	}

	/** @see #multilineStatementRegions */
	public List getMultilineStatementRegions() {
		return multilineStatementRegions;
	}

	/** Returns the line count of the token element. */
	public int getLineCount() {
		return rawLineOffsetConverter.getLineCount();
	}

	/** @see #rawLineOffsetConverter */
	public LineOffsetConverter getRawLineOffsetConverter() {
		return rawLineOffsetConverter;
	}

	/** @see #rawCoverableLines */
	public CompactLines getRawCoverableLines() {
		return rawCoverableLines;
	}

	/** @see #language */
	public ELanguage getLanguage() {
		return language;
	}

	/** @see #excludedRawLines */
	public CompactLines getExcludedRawLines() {
		return excludedRawLines;
	}

	/** @see #testCode */
	public boolean isTestCode() {
		return testCode;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy