org.conqat.engine.commons.findings.location.TextRegionLocationUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of teamscale-commons Show documentation
Show all versions of teamscale-commons Show documentation
Provides common DTOs for Teamscale
package org.conqat.engine.commons.findings.location;
import org.checkerframework.checker.nullness.qual.NonNull;
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 {@link TextRegionLocation} for the given shallow entity. */
public static @NonNull TextRegionLocation createLocationForShallowEntity(String uniformPath,
ShallowEntity shallowEntity) {
return new TextRegionLocation(uniformPath, shallowEntity.getStartOffset(), shallowEntity.getEndOffset(),
shallowEntity.getStartLine(), shallowEntity.getEndLine());
}
/**
* 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