Skip to content

Commit 0af900c

Browse files
committed
add "noinspection unchecked" for all twig pattern
1 parent 0e110a9 commit 0af900c

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

src/fr/adrienbrault/idea/symfony2plugin/TwigHelper.java

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,25 @@
22

33
import com.intellij.codeInsight.lookup.LookupElement;
44
import com.intellij.openapi.project.Project;
5+
import com.intellij.openapi.roots.FileIndexUtil;
56
import com.intellij.openapi.vfs.VfsUtil;
67
import com.intellij.openapi.vfs.VirtualFile;
78
import com.intellij.openapi.vfs.VirtualFileVisitor;
89
import com.intellij.patterns.ElementPattern;
910
import com.intellij.patterns.PlatformPatterns;
1011
import com.intellij.patterns.PsiElementPattern;
1112
import com.intellij.psi.*;
13+
import com.intellij.psi.impl.include.FileIncludeIndex;
14+
import com.intellij.psi.search.FileTypeIndex;
1215
import com.intellij.psi.search.GlobalSearchScope;
16+
import com.intellij.psi.search.GlobalSearchScopesCore;
1317
import com.intellij.psi.search.PsiElementProcessor;
1418
import com.intellij.psi.util.PsiTreeUtil;
1519
import com.intellij.util.Processor;
20+
import com.intellij.util.indexing.FileBasedIndex;
1621
import com.intellij.util.indexing.FileBasedIndexImpl;
1722
import com.jetbrains.php.PhpIndex;
23+
import com.jetbrains.php.lang.PhpFileType;
1824
import com.jetbrains.twig.TwigFile;
1925
import com.jetbrains.twig.TwigFileType;
2026
import com.jetbrains.twig.TwigLanguage;
@@ -260,6 +266,7 @@ public static String getTwigMethodString(@Nullable PsiElement transPsiElement) {
260266
* @param functionName twig function name
261267
*/
262268
public static ElementPattern<PsiElement> getPrintBlockFunctionPattern(String... functionName) {
269+
//noinspection unchecked
263270
return PlatformPatterns
264271
.psiElement(TwigTokenTypes.STRING_TEXT)
265272
.withParent(
@@ -286,6 +293,7 @@ public static ElementPattern<PsiElement> getPrintBlockFunctionPattern() {
286293
* NOT: {{ foo.bar }}, {{ 'foo.bar' }}
287294
*/
288295
public static ElementPattern<PsiElement> getCompletablePattern() {
296+
//noinspection unchecked
289297
return PlatformPatterns.psiElement()
290298
.andNot(
291299
PlatformPatterns.or(
@@ -306,6 +314,7 @@ public static ElementPattern<PsiElement> getCompletablePattern() {
306314
}
307315

308316
public static ElementPattern<PsiElement> getBlockTagPattern() {
317+
//noinspection unchecked
309318
return PlatformPatterns
310319
.psiElement(TwigTokenTypes.IDENTIFIER)
311320
.withParent(
@@ -325,7 +334,7 @@ public static ElementPattern<PsiElement> getBlockTagPattern() {
325334
}
326335

327336
public static ElementPattern<PsiElement> getTransDefaultDomain() {
328-
337+
//noinspection unchecked
329338
return PlatformPatterns.or(
330339
PlatformPatterns
331340
.psiElement(TwigTokenTypes.IDENTIFIER)
@@ -363,6 +372,7 @@ public static ElementPattern<PsiElement> getTransDefaultDomain() {
363372
* match 'dddd') on ending
364373
*/
365374
public static ElementPattern<PsiElement> getTransDomainPattern() {
375+
//noinspection unchecked
366376
return PlatformPatterns
367377
.psiElement(TwigTokenTypes.STRING_TEXT)
368378
.beforeLeafSkipping(
@@ -380,6 +390,7 @@ public static ElementPattern<PsiElement> getTransDomainPattern() {
380390
}
381391

382392
public static ElementPattern<PsiElement> getPathAfterLeafPattern() {
393+
//noinspection unchecked
383394
return PlatformPatterns
384395
.psiElement(TwigTokenTypes.STRING_TEXT)
385396
.afterLeafSkipping(
@@ -437,6 +448,7 @@ public static PsiElementPattern.Capture<PsiElement> getFormThemeFileTag() {
437448
}
438449

439450
public static ElementPattern<PsiElement> getRoutePattern() {
451+
//noinspection unchecked
440452
return PlatformPatterns
441453
.psiElement(TwigTokenTypes.IDENTIFIER).withText("path")
442454
.beforeLeafSkipping(
@@ -449,6 +461,7 @@ public static ElementPattern<PsiElement> getRoutePattern() {
449461
}
450462

451463
public static ElementPattern<PsiElement> getAutocompletableRoutePattern() {
464+
//noinspection unchecked
452465
return PlatformPatterns
453466
.psiElement(TwigTokenTypes.STRING_TEXT)
454467
.afterLeafSkipping(
@@ -468,6 +481,7 @@ public static ElementPattern<PsiElement> getAutocompletableRoutePattern() {
468481
}
469482

470483
public static ElementPattern<PsiElement> getAutocompletableAssetPattern() {
484+
//noinspection unchecked
471485
return PlatformPatterns
472486
.psiElement(TwigTokenTypes.STRING_TEXT)
473487
.afterLeafSkipping(
@@ -484,6 +498,7 @@ public static ElementPattern<PsiElement> getAutocompletableAssetPattern() {
484498
}
485499

486500
public static ElementPattern<PsiElement> getTranslationPattern(String... type) {
501+
//noinspection unchecked
487502
return
488503
PlatformPatterns
489504
.psiElement(TwigTokenTypes.STRING_TEXT)
@@ -518,13 +533,13 @@ public static ElementPattern<PsiElement> getAutocompletableFilterPattern() {
518533
}
519534

520535
public static ElementPattern<PsiElement> getAutocompletableAssetTag(String tagName) {
521-
522536
// @TODO: withChild is not working so we are filtering on text
523537

524538
// pattern to match '..foo.css' but not match eg ='...'
525539
//
526540
// {% stylesheets filter='cssrewrite'
527541
// 'assets/css/foo.css'
542+
//noinspection unchecked
528543
return PlatformPatterns
529544
.psiElement(TwigTokenTypes.STRING_TEXT)
530545
.afterLeafSkipping(
@@ -546,6 +561,8 @@ public static ElementPattern<PsiElement> getTemplateFileReferenceTagPattern() {
546561
public static ElementPattern<PsiElement> getTemplateFileReferenceTagPattern(String... tagNames) {
547562

548563
// {% include '<xxx>' with {'foo' : bar, 'bar' : 'foo'} %}
564+
565+
//noinspection unchecked
549566
return PlatformPatterns
550567
.psiElement(TwigTokenTypes.STRING_TEXT)
551568
.afterLeafSkipping(
@@ -562,9 +579,12 @@ public static ElementPattern<PsiElement> getTemplateFileReferenceTagPattern(Stri
562579
}
563580

564581
public static ElementPattern<PsiElement> getTemplateImportFileReferenceTagPattern() {
582+
565583
// first: {% from '<xxx>' import foo, <|> %}
566584
// second: {% from '<xxx>' import <|> %}
567585
// and not: {% from '<xxx>' import foo as <|> %}
586+
587+
//noinspection unchecked
568588
return PlatformPatterns
569589
.psiElement(TwigTokenTypes.IDENTIFIER)
570590
.withParent(PlatformPatterns.psiElement(TwigElementTypes.IMPORT_TAG))
@@ -592,6 +612,8 @@ public static ElementPattern<PsiElement> getTemplateImportFileReferenceTagPatter
592612

593613
public static ElementPattern<PsiElement> getForTagVariablePattern() {
594614
// {% for "user" %}
615+
616+
//noinspection unchecked
595617
return PlatformPatterns
596618
.psiElement(TwigTokenTypes.IDENTIFIER)
597619
.beforeLeafSkipping(
@@ -609,6 +631,8 @@ public static ElementPattern<PsiElement> getForTagInVariablePattern() {
609631
// {% for key, user in "users" %}
610632
// {% for user in "users" %}
611633
// {% for user in "users"|slice(0, 10) %}
634+
635+
//noinspection unchecked
612636
return PlatformPatterns
613637
.psiElement(TwigTokenTypes.IDENTIFIER)
614638
.afterLeafSkipping(
@@ -624,6 +648,8 @@ public static ElementPattern<PsiElement> getForTagInVariablePattern() {
624648
public static ElementPattern<PsiElement> getIfVariablePattern() {
625649

626650
// {% if "var" %}
651+
652+
//noinspection unchecked
627653
return PlatformPatterns
628654
.psiElement(TwigTokenTypes.IDENTIFIER)
629655
.afterLeafSkipping(
@@ -646,6 +672,8 @@ public static ElementPattern<PsiElement> getIfConditionVariablePattern() {
646672
// {% if var < "var1" %}
647673
// {% if var == "var1" %}
648674
// and so on
675+
676+
//noinspection unchecked
649677
return PlatformPatterns
650678
.psiElement(TwigTokenTypes.IDENTIFIER)
651679
.afterLeafSkipping(
@@ -671,6 +699,8 @@ public static ElementPattern<PsiElement> getIfConditionVariablePattern() {
671699
public static ElementPattern<PsiElement> getTwigMacroNamePattern() {
672700

673701
// {% macro <foo>(user) %}
702+
703+
//noinspection unchecked
674704
return PlatformPatterns
675705
.psiElement(TwigTokenTypes.IDENTIFIER)
676706
.withParent(PlatformPatterns.psiElement(
@@ -689,6 +719,8 @@ public static ElementPattern<PsiElement> getTwigMacroNamePattern() {
689719
public static ElementPattern<PsiElement> getTwigMacroNameKnownPattern(String macroName) {
690720

691721
// {% macro <foo>(user) %}
722+
723+
//noinspection unchecked
692724
return PlatformPatterns
693725
.psiElement(TwigTokenTypes.IDENTIFIER).withText(macroName)
694726
.withParent(PlatformPatterns.psiElement(
@@ -707,6 +739,8 @@ public static ElementPattern<PsiElement> getTwigMacroNameKnownPattern(String mac
707739
public static ElementPattern<PsiElement> getSetVariablePattern() {
708740

709741
// {% set count1 = "var" %}
742+
743+
//noinspection unchecked
710744
return PlatformPatterns
711745
.psiElement(TwigTokenTypes.IDENTIFIER)
712746
.afterLeafSkipping(
@@ -728,6 +762,8 @@ public static ElementPattern<PsiElement> getSetVariablePattern() {
728762
public static ElementPattern<PsiElement> getIncludeOnlyPattern() {
729763

730764
// {% set count1 = "var" %}
765+
766+
//noinspection unchecked
731767
return PlatformPatterns
732768
.psiElement(TwigTokenTypes.IDENTIFIER).withText("only")
733769
.beforeLeafSkipping(
@@ -741,6 +777,7 @@ public static ElementPattern<PsiElement> getIncludeOnlyPattern() {
741777
}
742778

743779
public static ElementPattern<PsiElement> getVariableTypePattern() {
780+
//noinspection unchecked
744781
return PlatformPatterns.or(
745782
TwigHelper.getForTagInVariablePattern(),
746783
TwigHelper.getIfVariablePattern(),

0 commit comments

Comments
 (0)