CodeFragmentFactory (@Nullable PsiElement context, @Nullable FileType fileType) { DefaultCodeFragmentFactory defaultFactory = DefaultCodeFragmentFactory.getInstance(); if (fileType == null) { if (context == null) { return defaultFactory; } else { PsiFile file = context.getContainingFile(); fileType = file != null ? file.getFileType() : null; } } for (CodeFragmentFactory factory : CodeFragmentFactory.EXTENSION_POINT_NAME.getExtensionList()) { if (factory != defaultFactory && (fileType == null || factory.getFileType().equals(fileType)) && factory.isContextAccepted(context)) { return factory; } } return defaultFactory; }