@@ -28,7 +28,7 @@ public class DartSyntax {
28
28
*/
29
29
@ Nullable
30
30
public static DartCallExpression findEnclosingFunctionCall (@ NotNull PsiElement elt , @ NotNull String functionName ) {
31
- return findEnclosingFunctionCall (elt , functionName , new Equator <String , String >() {
31
+ return findEnclosingFunctionCall (elt , functionName , new Equator <>() {
32
32
@ Override
33
33
boolean equate (@ NotNull String first , @ NotNull String second ) {
34
34
return Objects .equals (first , second );
@@ -43,7 +43,7 @@ boolean equate(@NotNull String first, @NotNull String second) {
43
43
*/
44
44
@ Nullable
45
45
public static DartCallExpression findEnclosingFunctionCall (@ NotNull PsiElement elt , @ NotNull Pattern functionRegex ) {
46
- return findEnclosingFunctionCall (elt , functionRegex , new Equator <Pattern , String >() {
46
+ return findEnclosingFunctionCall (elt , functionRegex , new Equator <>() {
47
47
@ Override
48
48
boolean equate (@ NotNull Pattern first , @ NotNull String second ) {
49
49
return first .matcher (second ).matches ();
@@ -54,8 +54,7 @@ boolean equate(@NotNull Pattern first, @NotNull String second) {
54
54
private static <T > DartCallExpression findEnclosingFunctionCall (
55
55
@ NotNull PsiElement elt , @ NotNull T functionDescriptor , @ NotNull Equator <T , String > equator ) {
56
56
while (elt != null ) {
57
- if (elt instanceof DartCallExpression ) {
58
- final DartCallExpression call = (DartCallExpression )elt ;
57
+ if (elt instanceof DartCallExpression call ) {
59
58
final String name = getCalledFunctionName (call );
60
59
if (name != null && equator .equate (functionDescriptor , name )) {
61
60
return call ;
@@ -72,8 +71,7 @@ private static <T> DartCallExpression findEnclosingFunctionCall(
72
71
@ Nullable
73
72
public static DartCallExpression findClosestEnclosingFunctionCall (@ Nullable PsiElement element ) {
74
73
while (element != null ) {
75
- if (element instanceof DartCallExpression ) {
76
- final DartCallExpression call = (DartCallExpression )element ;
74
+ if (element instanceof DartCallExpression call ) {
77
75
final String name = getCalledFunctionName (call );
78
76
if (name != null ) {
79
77
return call ;
@@ -181,8 +179,7 @@ public static String unquote(@NotNull DartStringLiteralExpression lit) {
181
179
if (lit .getFirstChild () == null ) return null ;
182
180
final PsiElement second = lit .getFirstChild ().getNextSibling ();
183
181
if (second .getNextSibling () != lit .getLastChild ()) return null ; // not three items
184
- if (!(second instanceof LeafPsiElement )) return null ;
185
- final LeafPsiElement leaf = (LeafPsiElement )second ;
182
+ if (!(second instanceof LeafPsiElement leaf )) return null ;
186
183
187
184
if (leaf .getElementType () != DartTokenTypes .REGULAR_STRING_PART ) return null ;
188
185
return leaf .getText ();
0 commit comments