
com.undefinedlabs.scope.utils.sourcecode.SourceCodeFrameUtils Maven / Gradle / Ivy
package com.undefinedlabs.scope.utils.sourcecode;
import com.undefinedlabs.scope.utils.StringUtils;
public enum SourceCodeFrameUtils {
INSTANCE;
public String buildLinkPathWithMethodBoundaries(final SourceCodeBoundary boundary) {
if (SourceCodeBoundary.EMPTY.equals(boundary)
|| SourceCode.EMPTY.equals(boundary.getBoundarySourceCode())
|| StringUtils.isEmpty(boundary.getBoundarySourceCode().getSourceFilePath())) {
return null;
}
if (boundary.getBoundaryMethodLine() == -1 && boundary.getBoundarySourceCode().hasConflicts()) {
return null;
}
final StringBuilder sb = new StringBuilder();
sb.append(boundary.getBoundarySourceCode().getSourceFilePath());
sb.append(":");
sb.append(
boundary.getBoundaryMethodLine() != -1
? boundary.getBoundaryMethodLine()
: boundary.getInstructionStartLine());
sb.append(":");
sb.append(boundary.getInstructionEndLine());
return sb.toString();
}
public String buildLinkPathWithMethodLine(final SourceCode sourceCode, final int methodLine) {
if (SourceCode.EMPTY.equals(sourceCode)
|| StringUtils.isEmpty(sourceCode.getSourceFilePath())
|| methodLine == -1) {
return null;
}
return sourceCode.getSourceFilePath() + ":" + methodLine;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy