Merge pull request #257 from github/hvitved/cfg/erb

CFG: Allow `erb` top-level scopes
This commit is contained in:
Tom Hvitved
2021-08-17 11:21:44 +02:00
committed by GitHub
4 changed files with 202 additions and 5 deletions

View File

@@ -262,7 +262,7 @@ private module Cached {
} or
TTokenMethodName(MethodName::Token g) { MethodName::range(g) } or
TTokenSuperCall(Ruby::Super g) { vcall(g) } or
TToplevel(Ruby::Program g) { g.getLocation().getFile().getExtension() != "erb" } or
TToplevel(Ruby::Program g) or
TTrueLiteral(Ruby::True g) or
TTuplePatternParameter(Ruby::DestructuredParameter g) or
TUnaryMinusExpr(Ruby::Unary g) { g instanceof @ruby_unary_minus } or

View File

@@ -1477,10 +1477,11 @@ control/loops.rb:
# 66| getAnOperand/getGreaterOperand/getRightOperand: [LocalVariableAccess] y
# 66| getBody: [StmtSequence] do ...
misc/misc.erb:
# 2| [MethodCall] call to require_asset
# 2| getReceiver: [Self] self
# 2| getArgument: [StringLiteral] "main_include_admin.js"
# 2| getComponent: [StringTextComponent] main_include_admin.js
# 2| [Toplevel] misc.erb
# 2| getStmt: [MethodCall] call to require_asset
# 2| getReceiver: [Self] self
# 2| getArgument: [StringLiteral] "main_include_admin.js"
# 2| getComponent: [StringTextComponent] main_include_admin.js
misc/misc.rb:
# 1| [Toplevel] misc.rb
# 1| getStmt: [AssignExpr] ... = ...

View File

@@ -465,6 +465,168 @@ case.rb:
# 4| "2"
#-----| -> call to puts
cfg.html.erb:
# 5| enter cfg.html.erb
#-----| -> @title
# 5| @title
#-----| -> self
# 5| exit cfg.html.erb
# 5| exit cfg.html.erb (normal)
#-----| -> exit cfg.html.erb
# 6| call to stylesheet_link_tag
#-----| -> self
# 6| self
#-----| -> "application"
# 6| "application"
#-----| -> :media
# 6| Pair
#-----| -> call to stylesheet_link_tag
# 6| :media
#-----| -> "all"
# 6| "all"
#-----| -> Pair
# 12| call to link_to
#-----| -> self
# 12| self
#-----| -> "A"
# 12| "A"
#-----| -> self
# 12| call to a
#-----| -> :id
# 12| self
#-----| -> call to a
# 12| :id
#-----| -> "a"
# 12| Pair
#-----| -> call to link_to
# 12| "a"
#-----| -> Pair
# 15| call to link_to
#-----| -> self
# 15| self
#-----| -> "B"
# 15| "B"
#-----| -> self
# 15| call to a
#-----| -> call to link_to
# 15| self
#-----| -> call to a
# 16| call to link_to
#-----| -> self
# 16| self
#-----| -> "C"
# 16| "C"
#-----| -> self
# 16| call to b
#-----| -> call to link_to
# 16| self
#-----| -> call to b
# 18| if ...
#-----| -> self
# 18| call to admin?
#-----| true -> self
#-----| false -> self
# 18| self
#-----| -> call to admin?
# 18| then ...
#-----| -> if ...
# 19| call to link_to
#-----| -> then ...
# 19| self
#-----| -> "D"
# 19| "D"
#-----| -> self
# 19| call to d
#-----| -> call to link_to
# 19| self
#-----| -> call to d
# 20| else ...
#-----| -> if ...
# 21| call to link_to
#-----| -> else ...
# 21| self
#-----| -> "E"
# 21| "E"
#-----| -> self
# 21| call to e
#-----| -> call to link_to
# 21| self
#-----| -> call to e
# 29| call to each
#-----| -> exit cfg.html.erb (normal)
# 29| call to collection
#-----| -> do ... end
# 29| self
#-----| -> call to collection
# 29| enter do ... end
#-----| -> key
# 29| do ... end
#-----| -> call to each
# 29| exit do ... end
# 29| exit do ... end (normal)
#-----| -> exit do ... end
# 29| key
#-----| -> value
# 29| value
#-----| -> key
# 30| key
#-----| -> value
# 30| value
#-----| -> exit do ... end (normal)
cfg.rb:
# 1| enter cfg.rb
#-----| -> self

View File

@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title><%= @title %></title>
<%= stylesheet_link_tag "application", :media => "all" %>
</head>
<body>
<header>
<div class="c">
<%= link_to "A", a, id: "a" %>
<nav>
<ul>
<li><%= link_to "B", a %></li>
<li><%= link_to "C", b %></li>
<% if admin? %>
<li><%= link_to "D", d %></li>
<% else %>
<li><%= link_to "E", e %></li>
<% end %>
</ul>
</nav>
</div>
</header>
<div>
<% collection.each do |key, value| %>
<div class="<%= key %>"><%= value %> </div>
<% end %>
</div>
</body>
</html>