@@ -207,15 +207,15 @@ module ActionDispatch {
207
207
override Location getLocation ( ) { result = call .getLocation ( ) }
208
208
209
209
override string getPathComponent ( ) {
210
- result = call .getKeywordArgument ( "path" ) .( StringlikeLiteral ) . getValueText ( )
210
+ result = call .getKeywordArgument ( "path" ) .getConstantValue ( ) . getStringOrSymbol ( )
211
211
or
212
212
not exists ( call .getKeywordArgument ( "path" ) ) and
213
- result = call .getArgument ( 0 ) .( StringlikeLiteral ) . getValueText ( )
213
+ result = call .getArgument ( 0 ) .getConstantValue ( ) . getStringOrSymbol ( )
214
214
}
215
215
216
216
override string getControllerComponent ( ) {
217
- result = call .getKeywordArgument ( "controller" ) .getValueText ( ) or
218
- result = call .getKeywordArgument ( "module" ) .getValueText ( )
217
+ result = call .getKeywordArgument ( "controller" ) .getConstantValue ( ) . getStringOrSymbol ( ) or
218
+ result = call .getKeywordArgument ( "module" ) .getConstantValue ( ) . getStringOrSymbol ( )
219
219
}
220
220
}
221
221
@@ -244,7 +244,9 @@ module ActionDispatch {
244
244
MethodCall getDefiningMethodCall ( ) { result = call }
245
245
246
246
override string getPathComponent ( ) {
247
- exists ( string resource | resource = call .getArgument ( 0 ) .getValueText ( ) |
247
+ exists ( string resource |
248
+ resource = call .getArgument ( 0 ) .getConstantValue ( ) .getStringOrSymbol ( )
249
+ |
248
250
result = resource + "/:" + singularize ( resource ) + "_id"
249
251
)
250
252
}
@@ -306,7 +308,9 @@ module ActionDispatch {
306
308
307
309
override string getControllerComponent ( ) { result = this .getNamespace ( ) }
308
310
309
- private string getNamespace ( ) { result = call .getArgument ( 0 ) .getValueText ( ) }
311
+ private string getNamespace ( ) {
312
+ result = call .getArgument ( 0 ) .getConstantValue ( ) .getStringOrSymbol ( )
313
+ }
310
314
311
315
override string toString ( ) { result = call .toString ( ) }
312
316
@@ -504,11 +508,11 @@ module ActionDispatch {
504
508
override RouteBlock getParentBlock ( ) { result = parentBlock }
505
509
506
510
override string getLastPathComponent ( ) {
507
- result = method .getArgument ( 0 ) .( StringlikeLiteral ) . getValueText ( )
511
+ result = method .getArgument ( 0 ) .getConstantValue ( ) . getStringOrSymbol ( )
508
512
}
509
513
510
514
override string getLastControllerComponent ( ) {
511
- result = method .getKeywordArgument ( "controller" ) .getValueText ( )
515
+ result = method .getKeywordArgument ( "controller" ) .getConstantValue ( ) . getStringOrSymbol ( )
512
516
or
513
517
not exists ( method .getKeywordArgument ( "controller" ) ) and
514
518
(
@@ -532,15 +536,15 @@ module ActionDispatch {
532
536
}
533
537
534
538
private string getActionString ( ) {
535
- result = method .getKeywordArgument ( "to" ) .( StringlikeLiteral ) . getValueText ( )
539
+ result = method .getKeywordArgument ( "to" ) .getConstantValue ( ) . getStringOrSymbol ( )
536
540
or
537
541
method .getKeywordArgument ( "to" ) .( MethodCall ) .getMethodName ( ) = "redirect" and
538
542
result = "<redirect>#<redirect>"
539
543
}
540
544
541
545
override string getAction ( ) {
542
546
// get "/photos", action: "index"
543
- result = method .getKeywordArgument ( "action" ) .getValueText ( )
547
+ result = method .getKeywordArgument ( "action" ) .getConstantValue ( ) . getStringOrSymbol ( )
544
548
or
545
549
not exists ( method .getKeywordArgument ( "action" ) ) and
546
550
(
@@ -555,7 +559,7 @@ module ActionDispatch {
555
559
or
556
560
// get :some_action
557
561
not exists ( this .getActionString ( ) ) and
558
- result = method .getArgument ( 0 ) .( StringlikeLiteral ) . getValueText ( )
562
+ result = method .getArgument ( 0 ) .getConstantValue ( ) . getStringOrSymbol ( )
559
563
)
560
564
}
561
565
@@ -602,7 +606,7 @@ module ActionDispatch {
602
606
603
607
ResourcesRoute ( ) {
604
608
this = TResourcesRoute ( parent , method , action ) and
605
- resource = method .getArgument ( 0 ) .( StringlikeLiteral ) . getValueText ( ) and
609
+ resource = method .getArgument ( 0 ) .getConstantValue ( ) . getStringOrSymbol ( ) and
606
610
isDefaultResourceRoute ( resource , httpMethod , pathComponent , action )
607
611
}
608
612
@@ -612,7 +616,9 @@ module ActionDispatch {
612
616
613
617
override string getLastPathComponent ( ) { result = pathComponent }
614
618
615
- override string getLastControllerComponent ( ) { result = method .getArgument ( 0 ) .getValueText ( ) }
619
+ override string getLastControllerComponent ( ) {
620
+ result = method .getArgument ( 0 ) .getConstantValue ( ) .getStringOrSymbol ( )
621
+ }
616
622
617
623
override string getAction ( ) { result = action }
618
624
@@ -637,7 +643,7 @@ module ActionDispatch {
637
643
638
644
SingularResourceRoute ( ) {
639
645
this = TResourceRoute ( parent , method , action ) and
640
- resource = method .getArgument ( 0 ) .( StringlikeLiteral ) . getValueText ( ) and
646
+ resource = method .getArgument ( 0 ) .getConstantValue ( ) . getStringOrSymbol ( ) and
641
647
isDefaultSingularResourceRoute ( resource , httpMethod , pathComponent , action )
642
648
}
643
649
@@ -647,7 +653,9 @@ module ActionDispatch {
647
653
648
654
override string getLastPathComponent ( ) { result = pathComponent }
649
655
650
- override string getLastControllerComponent ( ) { result = method .getArgument ( 0 ) .getValueText ( ) }
656
+ override string getLastControllerComponent ( ) {
657
+ result = method .getArgument ( 0 ) .getConstantValue ( ) .getStringOrSymbol ( )
658
+ }
651
659
652
660
override string getAction ( ) { result = action }
653
661
@@ -676,25 +684,39 @@ module ActionDispatch {
676
684
override RouteBlock getParentBlock ( ) { result = parent }
677
685
678
686
override string getLastPathComponent ( ) {
679
- result = method .getArgument ( 0 ) .( StringlikeLiteral ) . getValueText ( ) or
680
- result = method .getArgument ( 0 ) .( Pair ) .getKey ( ) .getValueText ( )
687
+ result = method .getArgument ( 0 ) .getConstantValue ( ) . getStringOrSymbol ( ) or
688
+ result = method .getArgument ( 0 ) .( Pair ) .getKey ( ) .getConstantValue ( ) . getStringOrSymbol ( )
681
689
}
682
690
683
691
override string getLastControllerComponent ( ) {
684
- result = extractController ( method .getKeywordArgument ( "to" ) .getValueText ( ) ) or
685
- result = method .getKeywordArgument ( "controller" ) .getValueText ( ) or
686
- result = extractController ( method .getArgument ( 0 ) .( Pair ) .getValue ( ) .getValueText ( ) )
692
+ result =
693
+ extractController ( method .getKeywordArgument ( "to" ) .getConstantValue ( ) .getStringOrSymbol ( ) ) or
694
+ result = method .getKeywordArgument ( "controller" ) .getConstantValue ( ) .getStringOrSymbol ( ) or
695
+ result =
696
+ extractController ( method
697
+ .getArgument ( 0 )
698
+ .( Pair )
699
+ .getValue ( )
700
+ .getConstantValue ( )
701
+ .getStringOrSymbol ( ) )
687
702
}
688
703
689
704
override string getHTTPMethod ( ) {
690
- result = method .getKeywordArgument ( "via" ) .( StringlikeLiteral ) .getValueText ( ) or
691
- result = method .getKeywordArgument ( "via" ) .( ArrayLiteral ) .getElement ( _) .getValueText ( )
705
+ result = method .getKeywordArgument ( "via" ) .getConstantValue ( ) .getStringOrSymbol ( ) or
706
+ result =
707
+ method
708
+ .getKeywordArgument ( "via" )
709
+ .( ArrayLiteral )
710
+ .getElement ( _)
711
+ .getConstantValue ( )
712
+ .getStringOrSymbol ( )
692
713
}
693
714
694
715
override string getAction ( ) {
695
- result = extractAction ( method .getKeywordArgument ( "to" ) .getValueText ( ) ) or
696
- result = method .getKeywordArgument ( "action" ) .getValueText ( ) or
697
- result = extractAction ( method .getArgument ( 0 ) .( Pair ) .getValue ( ) .getValueText ( ) )
716
+ result = extractAction ( method .getKeywordArgument ( "to" ) .getConstantValue ( ) .getStringOrSymbol ( ) ) or
717
+ result = method .getKeywordArgument ( "action" ) .getConstantValue ( ) .getStringOrSymbol ( ) or
718
+ result =
719
+ extractAction ( method .getArgument ( 0 ) .( Pair ) .getValue ( ) .getConstantValue ( ) .getStringOrSymbol ( ) )
698
720
}
699
721
}
700
722
@@ -710,15 +732,19 @@ module ActionDispatch {
710
732
not exists ( m .getKeywordArgument ( "only" ) )
711
733
or
712
734
exists ( Expr only | only = m .getKeywordArgument ( "only" ) |
713
- [ only .( ArrayLiteral ) .getElement ( _) , only .( StringlikeLiteral ) ] .getValueText ( ) = action
735
+ [ only .( ArrayLiteral ) .getElement ( _) , only .( StringlikeLiteral ) ]
736
+ .getConstantValue ( )
737
+ .getStringOrSymbol ( ) = action
714
738
)
715
739
) and
716
740
// Respect the `except` keyword argument, which removes actions from the default set.
717
741
(
718
742
not exists ( m .getKeywordArgument ( "except" ) )
719
743
or
720
744
exists ( Expr except | except = m .getKeywordArgument ( "except" ) |
721
- [ except .( ArrayLiteral ) .getElement ( _) , except .( StringlikeLiteral ) ] .getValueText ( ) != action
745
+ [ except .( ArrayLiteral ) .getElement ( _) , except .( StringlikeLiteral ) ]
746
+ .getConstantValue ( )
747
+ .getStringOrSymbol ( ) != action
722
748
)
723
749
)
724
750
}
0 commit comments