remove ErbFile refs

This commit is contained in:
Alex Ford
2021-08-24 17:20:59 +01:00
parent e403fc77d3
commit abc283ee8a
3 changed files with 14 additions and 6 deletions

View File

@@ -68,7 +68,8 @@ class ActionControllerActionMethod extends Method, HTTP::Server::RequestHandler:
* corresponding template file at
* `<source_prefix>/app/views/<subpath>/<method_name>.html.erb`.
*/
ErbFile getDefaultTemplateFile() {
// TODO: result should be `ErbFile`
File getDefaultTemplateFile() {
exists(string templatePath, string sourcePrefix, string subPath, string controllerPath |
controllerPath = this.getLocation().getFile().getAbsolutePath() and
sourcePrefix = controllerPath.regexpCapture("^(.*)/app/controllers/.*$", 1) and
@@ -183,7 +184,8 @@ class ActionControllerHelperMethod extends Method {
* Gets an `ActionControllerControllerClass` associated with the given `ErbFile`
* according to Rails path conventions.
*/
ActionControllerControllerClass getAssociatedControllerClass(ErbFile f) {
// TODO: parameter should be `ErbFile`
ActionControllerControllerClass getAssociatedControllerClass(File f) {
exists(string localPrefix, string sourcePrefix, string controllerPath |
controllerPath = result.getLocation().getFile().getAbsolutePath() and
sourcePrefix = f.getAbsolutePath().regexpCapture("^(.*)/app/views/(?:.*?)/(?:[^/]*)$", 1) and

View File

@@ -11,7 +11,8 @@ predicate inActionViewContext(AstNode n) {
n.getEnclosingModule() instanceof ViewComponentClass
or
// Within a template
n.getLocation().getFile() instanceof ErbFile
// TODO: n.getLocation().getFile() instanceof ErbFile
n.getLocation().getFile().getExtension() = "erb"
}
/**
@@ -35,7 +36,10 @@ private class ActionViewContextCall extends MethodCall {
inActionViewContext(this)
}
predicate isInErbFile() { this.getLocation().getFile() instanceof ErbFile }
predicate isInErbFile() {
// TODO: this.getLocation().getFile() instanceof ErbFile
this.getLocation().getFile().getExtension() = "erb"
}
}
/** A call to the `raw` method to output a value without HTML escaping. */
@@ -94,7 +98,8 @@ abstract class RenderCall extends MethodCall {
/**
* Get the template file to be rendered by this call, if any.
*/
ErbFile getTemplateFile() { result.getAbsolutePath().matches(this.getTemplatePathPatterns()) }
// TODO: parameter should be `ErbFile`
File getTemplateFile() { result.getAbsolutePath().matches(this.getTemplatePathPatterns()) }
/**
* Get the local variables passed as context to the renderer