LanguageFileType (@NotNull SearchContext searchContext) { final PsiFile file = searchContext.getFile(); PsiElement context = null; final Editor editor = searchContext.getEditor(); if (editor != null && file != null) { final int offset = editor.getCaretModel().getOffset(); context = InjectedLanguageManager.getInstance(searchContext.getProject()).findInjectedElementAt(file, offset); if (context == null) { context = file.findElementAt(offset); } if (context != null) { context = context.getParent(); } if (context == null) { context = file; } } if (context != null) { final Language language = context.getLanguage(); final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByLanguage(language); if (profile != null) { LanguageFileType fileType = profile.detectFileType(context); if (fileType == null) { fileType = language.getAssociatedFileType(); } if (fileType != null) return fileType; } } return StructuralSearchUtil.getDefaultFileType(); }