Object (@NotNull String dataId, @NotNull Editor e, @NotNull Caret caret) { if (e.isDisposed() || !(e instanceof EditorEx)) { return null; } VirtualFile file = e.getVirtualFile(); if (file == null || !file.isValid()) return null; Project project = e.getProject(); if (PSI_FILE.is(dataId)) { return getPsiFile(e, file); } if (InjectedDataKeys.EDITOR.is(dataId)) { if (project != null && PsiDocumentManager.getInstance(project).isCommitted(e.getDocument()) && InjectedLanguageManager.getInstance(project).mightHaveInjectedFragmentAtOffset(e.getDocument(), caret.getOffset())) { //noinspection deprecation return InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(e, caret, getPsiFile(e, file)); } return null; } if (InjectedDataKeys.CARET.is(dataId)) { return querySlowInjectedCaret(e, caret); } if (InjectedDataKeys.VIRTUAL_FILE.is(dataId)) { PsiFile psiFile = querySlowInjectedPsiFile(e, caret); if (psiFile == null) return null; return psiFile.getVirtualFile(); } if (InjectedDataKeys.PSI_FILE.is(dataId)) { Editor editor = querySlowInjectedEditor(e, caret); if (editor == null || project == null) return null; return PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); } if (InjectedDataKeys.PSI_ELEMENT.is(dataId)) { EditorWindow editor = querySlowInjectedEditor(e, caret); if (editor == null) return null; InjectedCaret injectedCaret = getInjectedCaret(editor, caret); return injectedCaret == null ? null : getPsiElementIn(editor, injectedCaret, file); } if (PSI_ELEMENT.is(dataId)) { return getPsiElementIn(e, caret, file); } if (InjectedDataKeys.LANGUAGE.is(dataId)) { PsiFile psiFile = querySlowInjectedPsiFile(e, caret); if (psiFile == null) return null; InjectedCaret injectedCaret = querySlowInjectedCaret(e, caret); return injectedCaret == null ? null : getLanguageAtCurrentPositionInEditor(injectedCaret, psiFile); } if (MODULE.is(dataId)) { return project == null ? null : ModuleUtilCore.findModuleForFile(file, project); } if (LANGUAGE.is(dataId)) { PsiFile psiFile = getPsiFile(e, file); if (psiFile == null) return null; return getLanguageAtCurrentPositionInEditor(caret, psiFile); } if (CONTEXT_LANGUAGES.is(dataId)) { LinkedHashSet<Language> set = new LinkedHashSet<>(4); Language injectedLanguage = (Language)getSlowData(InjectedDataKeys.LANGUAGE.getName(), e, caret); addIfNotNull(set, injectedLanguage); Language language = (Language)getSlowData(LANGUAGE.getName(), e, caret); addIfNotNull(set, language); PsiFile psiFile = (PsiFile)getSlowData(PSI_FILE.getName(), e, caret); if (psiFile != null) { addIfNotNull(set, psiFile.getViewProvider().getBaseLanguage()); } return set.toArray(Language.EMPTY_ARRAY); } return null; }