Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ba45a7c

Browse files
committed
Added null check in YamlHelper.{isRoutingFile,isConfigFile,isServicesFile}
1 parent 61906bb commit ba45a7c

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

‎src/main/java/fr/adrienbrault/idea/symfony2plugin/config/yaml/YamlLanguageInjector.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public void getLanguagesToInject(@NotNull MultiHostRegistrar registrar, @NotNull
3131
}
3232

3333
var file = context.getContainingFile();
34+
if (file == null) {
35+
return;
36+
}
37+
3438
var element = (YAMLQuotedText) context;
3539
var value = element.getTextValue();
3640

‎src/main/java/fr/adrienbrault/idea/symfony2plugin/util/yaml/YamlHelper.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,15 +519,28 @@ public static void processKeysAfterRoot(@NotNull PsiFile psiFile, @NotNull Proce
519519
}
520520

521521
public static boolean isRoutingFile(PsiFile psiFile) {
522-
return psiFile.getName().contains("routing") || psiFile.getVirtualFile().getPath().contains("/routing");
522+
return fileNameOrPathContains(psiFile, "routing");
523523
}
524524

525525
public static boolean isConfigFile(@NotNull PsiFile psiFile) {
526-
return psiFile.getName().contains("config") || psiFile.getVirtualFile().getPath().contains("/config");
526+
return fileNameOrPathContains(psiFile, "config");
527527
}
528528

529529
public static boolean isServicesFile(@NotNull PsiFile psiFile) {
530-
return psiFile.getName().contains("services") || psiFile.getVirtualFile().getPath().contains("/services");
530+
return fileNameOrPathContains(psiFile, "services");
531+
}
532+
533+
private static boolean fileNameOrPathContains(@NotNull PsiFile psiFile, @NotNull String text) {
534+
if (psiFile.getName().contains(text)) {
535+
return true;
536+
}
537+
538+
var virtualFile = psiFile.getVirtualFile();
539+
if (virtualFile != null) {
540+
return virtualFile.getPath().contains("/" + text);
541+
}
542+
543+
return false;
531544
}
532545

533546
public static boolean isInsideServiceDefinition(@NotNull PsiElement psiElement) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /