本文整理汇总了Java中com.intellij.openapi.fileTypes.LanguageFileType.getDefaultExtension方法的典型用法代码示例。如果您正苦于以下问题:Java LanguageFileType.getDefaultExtension方法的具体用法?Java LanguageFileType.getDefaultExtension怎么用?Java LanguageFileType.getDefaultExtension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.fileTypes.LanguageFileType
的用法示例。
在下文中一共展示了LanguageFileType.getDefaultExtension方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTaskFileName
import com.intellij.openapi.fileTypes.LanguageFileType; //导入方法依赖的package包/类
@Nullable
private static String getTaskFileName(@NotNull Language language) {
// This is a hacky way to how we should name task file.
// It's assumed that if test's name is capitalized we need to capitalize task file name too.
String testFileName = EduPluginConfigurator.INSTANCE.forLanguage(language).getTestFileName();
boolean capitalize = !testFileName.isEmpty() && Character.isUpperCase(testFileName.charAt(0));
LanguageFileType type = language.getAssociatedFileType();
if (type == null) {
LOG.warn("Failed to create task file name: associated file type for " + language + " is null");
return null;
}
return (capitalize ? StringUtil.capitalize(TASK_NAME) : TASK_NAME) + "." + type.getDefaultExtension();
}
示例2: createFile
import com.intellij.openapi.fileTypes.LanguageFileType; //导入方法依赖的package包/类
public static PsiFile createFile(Project project, Language language, String text) {
LanguageFileType ftype = language.getAssociatedFileType();
if ( ftype==null ) return null;
String ext = ftype.getDefaultExtension();
String fileName = "___fubar___."+ext; // random name but must have correct extension
PsiFileFactoryImpl factory = (PsiFileFactoryImpl)PsiFileFactory.getInstance(project);
return factory.createFileFromText(fileName, language, text, false, false);
}
示例3: createDummyFile
import com.intellij.openapi.fileTypes.LanguageFileType; //导入方法依赖的package包/类
protected PsiFile createDummyFile(String text, final LanguageFileType fileType) {
String ext = fileType.getDefaultExtension();
@NonNls String fileName = "_Dummy_." + ext;
return PsiFileFactory.getInstance(myManager.getProject()).createFileFromText(fileType, fileName, text, 0, text.length());
}