use of ratpack.groovy.script.internal.ScriptPath in project ratpack by ratpack.
the class ClosureUtil method getSourceInfo.
public static SourceInfo getSourceInfo(Closure<?> closure) {
Class<?> closureClass = closure.getClass();
LineNumber lineNumber = closureClass.getAnnotation(LineNumber.class);
if (lineNumber == null) {
return null;
}
Class<?> rootClass = getRootClass(closure);
ScriptPath scriptPath = rootClass.getAnnotation(ScriptPath.class);
if (scriptPath == null) {
return null;
}
return new SourceInfo(scriptPath.value(), lineNumber.value());
}
use of ratpack.groovy.script.internal.ScriptPath in project ratpack by ratpack.
the class ClosureUtil method findScriptByAnnotation.
private static Path findScriptByAnnotation(Closure<?> closure) {
Class<?> rootClass = getRootClass(closure);
ScriptPath annotation = rootClass.getAnnotation(ScriptPath.class);
if (annotation == null) {
return null;
} else {
String scriptPath = annotation.value();
URI uri;
try {
uri = new URI(scriptPath);
} catch (URISyntaxException e) {
return null;
}
return Paths.get(uri);
}
}
Aggregations