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

org.conqat.engine.commons.findings.location.TextRegionLocationUtils Maven / Gradle / Ivy

The newest version!
package org.conqat.engine.commons.findings.location;

import org.conqat.engine.resource.text.filter.util.StringOffsetTransformer;
import org.conqat.lib.commons.string.LineOffsetConverter;

import eu.cqse.check.framework.shallowparser.framework.ShallowEntity;

/**
 * Utility for creating a {@link TextRegionLocation} for a {@link ShallowEntity}.
 */
public class TextRegionLocationUtils {

	/**
	 * Creates a new {@link org.conqat.engine.commons.findings.location.TextRegionLocation} for the
	 * given uniform path and offsets.
	 */
	public static TextRegionLocation createTextRegionLocationForFilteredOffsets(String uniformPath, int startOffset,
			int endOffset, StringOffsetTransformer offsetTransformer, LineOffsetConverter rawLineOffsetConverter) {
		int rawStartOffset = offsetTransformer.getUnfilteredOffset(startOffset);
		int rawEndOffset = offsetTransformer.getUnfilteredOffset(endOffset);
		int rawStartLine = rawLineOffsetConverter.getLine(rawStartOffset);
		int rawEndLine = rawLineOffsetConverter.getLine(rawEndOffset);
		return new TextRegionLocation(uniformPath, rawStartOffset, rawEndOffset, rawStartLine, rawEndLine);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy