本文整理汇总了Java中com.intellij.openapi.util.io.FileUtilRt.getExtension方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtilRt.getExtension方法的具体用法?Java FileUtilRt.getExtension怎么用?Java FileUtilRt.getExtension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.util.io.FileUtilRt
的用法示例。
在下文中一共展示了FileUtilRt.getExtension方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transformTestFile
import com.intellij.openapi.util.io.FileUtilRt; //导入方法依赖的package包/类
private static void transformTestFile(@NotNull Project project, int toSubtaskIndex, VirtualFile taskDir) {
String subtaskTestFileName = getTestFileName(project, toSubtaskIndex);
if (subtaskTestFileName == null) {
return;
}
String nameWithoutExtension = FileUtil.getNameWithoutExtension(subtaskTestFileName);
String extension = FileUtilRt.getExtension(subtaskTestFileName);
VirtualFile subtaskTestFile = taskDir.findChild(nameWithoutExtension + ".txt");
if (subtaskTestFile != null) {
ApplicationManager.getApplication().runWriteAction(() -> {
try {
subtaskTestFile.rename(project, nameWithoutExtension + "." + extension);
}
catch (IOException e) {
LOG.error(e);
}
});
}
}
示例2: getAllAnswerTaskFiles
import com.intellij.openapi.util.io.FileUtilRt; //导入方法依赖的package包/类
private static List<VirtualFile> getAllAnswerTaskFiles(@NotNull Course course, @NotNull Project project) {
List<VirtualFile> result = new ArrayList<>();
for (Lesson lesson : course.getLessons()) {
for (Task task : lesson.getTaskList()) {
for (Map.Entry<String, TaskFile> entry : task.getTaskFiles().entrySet()) {
String name = entry.getKey();
String answerName = FileUtil.getNameWithoutExtension(name) + CCUtils.ANSWER_EXTENSION_DOTTED + FileUtilRt.getExtension(name);
String taskPath = FileUtil.join(project.getBasePath(), EduNames.LESSON + lesson.getIndex(), EduNames.TASK + task.getIndex());
VirtualFile taskFile = LocalFileSystem.getInstance().findFileByPath(FileUtil.join(taskPath, answerName));
if (taskFile == null) {
taskFile = LocalFileSystem.getInstance().findFileByPath(FileUtil.join(taskPath, EduNames.SRC, answerName));
}
if (taskFile != null) {
result.add(taskFile);
}
}
}
}
return result;
}
示例3: getTestsFile
import com.intellij.openapi.util.io.FileUtilRt; //导入方法依赖的package包/类
@Nullable
@Override
protected VirtualFile getTestsFile() {
String testFileName = EduJavaPluginConfigurator.TEST_JAVA;
if (myTask instanceof TaskWithSubtasks) {
int activeSubtaskIndex = ((TaskWithSubtasks) myTask).getActiveSubtaskIndex();
testFileName = FileUtil.getNameWithoutExtension(testFileName) + EduNames.SUBTASK_MARKER + activeSubtaskIndex + "." + FileUtilRt.getExtension(EduJavaPluginConfigurator.TEST_JAVA);
}
VirtualFile taskDir = myTask.getTaskDir(myProject);
if (taskDir == null) {
return null;
}
VirtualFile srcDir = taskDir.findChild(EduNames.SRC);
if (srcDir != null) {
taskDir = srcDir;
}
VirtualFile virtualFile = taskDir.findChild(testFileName);
if (virtualFile != null) {
return virtualFile;
}
return null;
}
示例4: collectArchives
import com.intellij.openapi.util.io.FileUtilRt; //导入方法依赖的package包/类
private static void collectArchives(File file, boolean recursively, List<String> result) {
final File[] children = file.listFiles();
if (children != null) {
for (File child : children) {
final String extension = FileUtilRt.getExtension(child.getName());
if (child.isDirectory()) {
if (recursively) {
collectArchives(child, recursively, result);
}
}
// todo [nik] get list of extensions mapped to Archive file type from IDE settings
else if (AR_EXTENSIONS.contains(extension)) {
result.add(JpsPathUtil.getLibraryRootUrl(child));
}
}
}
}
示例5: updateOutputPath
import com.intellij.openapi.util.io.FileUtilRt; //导入方法依赖的package包/类
public void updateOutputPath(@NotNull String oldArtifactName, @NotNull final String newArtifactName) {
final String oldDefaultPath = ArtifactUtil.getDefaultArtifactOutputPath(oldArtifactName, myProject);
if (Comparing.equal(oldDefaultPath, getConfiguredOutputPath())) {
setOutputPath(ArtifactUtil.getDefaultArtifactOutputPath(newArtifactName, myProject));
}
final CompositePackagingElement<?> root = getRootElement();
if (root instanceof ArchivePackagingElement) {
String oldFileName = ArtifactUtil.suggestArtifactFileName(oldArtifactName);
final String name = ((ArchivePackagingElement)root).getArchiveFileName();
final String fileName = FileUtil.getNameWithoutExtension(name);
final String extension = FileUtilRt.getExtension(name);
if (fileName.equals(oldFileName) && extension.length() > 0) {
myLayoutTreeComponent.editLayout(new Runnable() {
@Override
public void run() {
((ArchivePackagingElement)getRootElement()).setArchiveFileName(ArtifactUtil.suggestArtifactFileName(newArtifactName) + "." + extension);
}
});
myLayoutTreeComponent.updateRootNode();
}
}
}
示例6: getLanguageByExtension
import com.intellij.openapi.util.io.FileUtilRt; //导入方法依赖的package包/类
@Nullable
@Override
public OCLanguageKind getLanguageByExtension(Project project, String name) {
if (Blaze.isBlazeProject(project)) {
String extension = FileUtilRt.getExtension(name);
if (CFileExtensions.C_FILE_EXTENSIONS.contains(extension)) {
return OCLanguageKind.C;
}
if (CFileExtensions.CXX_FILE_EXTENSIONS.contains(extension)) {
return OCLanguageKind.CPP;
}
if (CFileExtensions.CXX_ONLY_HEADER_EXTENSIONS.contains(extension)) {
return OCLanguageKind.CPP;
}
}
return null;
}
示例7: filenameMatchesPrefixOrType
import com.intellij.openapi.util.io.FileUtilRt; //导入方法依赖的package包/类
private static boolean filenameMatchesPrefixOrType(final String fileName, final String prefix, final FileType[] suitableFileTypes, final int invocationCount) {
final boolean prefixMatched = prefix.length() == 0 || StringUtil.startsWithIgnoreCase(fileName, prefix);
if (prefixMatched && (suitableFileTypes.length == 0 || invocationCount > 2)) return true;
if (prefixMatched) {
final String extension = FileUtilRt.getExtension(fileName);
if (extension.length() == 0) return false;
for (final FileType fileType : suitableFileTypes) {
for (final FileNameMatcher matcher : FileTypeManager.getInstance().getAssociations(fileType)) {
if (FileNameMatcherEx.acceptsCharSequence(matcher, fileName)) return true;
}
}
}
return false;
}
示例8: updateExtensionsCombo
import com.intellij.openapi.util.io.FileUtilRt; //导入方法依赖的package包/类
private void updateExtensionsCombo() {
final Object source = getSource();
if (source instanceof LanguageFileType) {
final List<String> extensions = getAllExtensions((LanguageFileType)source);
if (extensions.size() > 1) {
final ExtensionComparator comp = new ExtensionComparator(extensions.get(0));
Collections.sort(extensions, comp);
final SortedComboBoxModel<String> model = new SortedComboBoxModel<String>(comp);
model.setAll(extensions);
myExtensionComboBox.setModel(model);
myExtensionComboBox.setVisible(true);
myExtensionLabel.setVisible(true);
String fileExt = myCurrentFile != null ? FileUtilRt.getExtension(myCurrentFile.getName()) : "";
if (fileExt.length() > 0 && extensions.contains(fileExt)) {
myExtensionComboBox.setSelectedItem(fileExt);
return;
}
myExtensionComboBox.setSelectedIndex(0);
return;
}
}
myExtensionComboBox.setVisible(false);
myExtensionLabel.setVisible(false);
}
示例9: deduplicate
import com.intellij.openapi.util.io.FileUtilRt; //导入方法依赖的package包/类
@Override
@Nullable
public String deduplicate(@NotNull Parameter parameter, @Nullable String value) {
if (StringUtil.isEmpty(value) || !parameter.constraints.contains(Parameter.Constraint.UNIQUE)) {
return value;
}
String suggested = value;
String extension = FileUtilRt.getExtension(value);
boolean hasExtension = !extension.isEmpty();
int extensionOffset = value.length() - extension.length();
//noinspection ForLoopThatDoesntUseLoopVariable
for (int i = 2; !parameter.uniquenessSatisfied(project, module, provider, packageName, suggested); i++) {
if (hasExtension) {
suggested = value.substring(0, extensionOffset) + i + value.substring(extensionOffset);
}
else {
suggested = value + i;
}
}
return suggested;
}
示例10: getSubtaskTestsFileName
import com.intellij.openapi.util.io.FileUtilRt; //导入方法依赖的package包/类
@NotNull
public static String getSubtaskTestsFileName(int index) {
return index == 0 ? TESTS_PY : FileUtil.getNameWithoutExtension(TESTS_PY) +
EduNames.SUBTASK_MARKER +
index + "." +
FileUtilRt.getExtension(TESTS_PY);
}
示例11: createCheckProcess
import com.intellij.openapi.util.io.FileUtilRt; //导入方法依赖的package包/类
Process createCheckProcess(@NotNull final Project project, @NotNull final String executablePath) throws ExecutionException {
final Sdk sdk = PythonSdkType.findPythonSdk(ModuleManager.getInstance(project).getModules()[0]);
PyEduPluginConfigurator configurator = new PyEduPluginConfigurator();
String testsFileName = configurator.getTestFileName();
if (myTask instanceof TaskWithSubtasks) {
testsFileName = FileUtil.getNameWithoutExtension(testsFileName);
int index = ((TaskWithSubtasks)myTask).getActiveSubtaskIndex();
testsFileName += EduNames.SUBTASK_MARKER + index + "." + FileUtilRt.getExtension(configurator.getTestFileName());
}
final File testRunner = new File(myTaskDir.getPath(), testsFileName);
myCommandLine = new GeneralCommandLine();
myCommandLine.withWorkDirectory(myTaskDir.getPath());
final Map<String, String> env = myCommandLine.getEnvironment();
final VirtualFile courseDir = project.getBaseDir();
if (courseDir != null) {
env.put(PYTHONPATH, courseDir.getPath());
}
if (sdk != null) {
String pythonPath = sdk.getHomePath();
if (pythonPath != null) {
myCommandLine.setExePath(pythonPath);
myCommandLine.addParameter(testRunner.getPath());
myCommandLine.addParameter(FileUtil.toSystemDependentName(executablePath));
return myCommandLine.createProcess();
}
}
return null;
}
示例12: getTestFileName
import com.intellij.openapi.util.io.FileUtilRt; //导入方法依赖的package包/类
@Nullable
private static String getTestFileName(@NotNull Project project, int subtaskIndex) {
Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null) {
return null;
}
EduPluginConfigurator configurator = EduPluginConfigurator.INSTANCE.forLanguage(course.getLanguageById());
if (configurator == null) {
return null;
}
String defaultTestFileName = configurator.getTestFileName();
String nameWithoutExtension = FileUtil.getNameWithoutExtension(defaultTestFileName);
String extension = FileUtilRt.getExtension(defaultTestFileName);
return nameWithoutExtension + EduNames.SUBTASK_MARKER + subtaskIndex + "." + extension;
}
示例13: isTaskDescriptionFile
import com.intellij.openapi.util.io.FileUtilRt; //导入方法依赖的package包/类
private static boolean isTaskDescriptionFile(@NotNull final String fileName) {
if (TASK_HTML.equals(fileName) || TASK_MD.equals(fileName)) {
return true;
}
String extension = FileUtilRt.getExtension(fileName);
if (!extension.equals(FileUtilRt.getExtension(TASK_HTML)) && !extension.equals(FileUtilRt.getExtension(TASK_MD))) {
return false;
}
return fileName.contains(EduNames.TASK) && fileName.contains(EduNames.SUBTASK_MARKER);
}
示例14: replaceWithSubtask
import com.intellij.openapi.util.io.FileUtilRt; //导入方法依赖的package包/类
private static void replaceWithSubtask(JsonObject fileWrapper) {
final String file = fileWrapper.get(NAME).getAsString();
final String extension = FileUtilRt.getExtension(file);
final String name = FileUtil.getNameWithoutExtension(file);
if (!name.contains(EduNames.SUBTASK_MARKER)) {
fileWrapper.remove(NAME);
fileWrapper.add(NAME, new JsonPrimitive(name + "_subtask0." + extension));
}
}
示例15: loadState
import com.intellij.openapi.util.io.FileUtilRt; //导入方法依赖的package包/类
@Override
public void loadState(Element state) {
try {
Element courseElement = getChildWithName(state, COURSE).getChild(COURSE_TITLED);
for (Element lesson : getChildList(courseElement, LESSONS, true)) {
int lessonIndex = getAsInt(lesson, INDEX);
for (Element task : getChildList(lesson, TASK_LIST, true)) {
int taskIndex = getAsInt(task, INDEX);
Map<String, Element> taskFiles = getChildMap(task, TASK_FILES, true);
for (Map.Entry<String, Element> entry : taskFiles.entrySet()) {
Element taskFileElement = entry.getValue();
String name = entry.getKey();
String answerName = FileUtil.getNameWithoutExtension(name) + CCUtils.ANSWER_EXTENSION_DOTTED + FileUtilRt.getExtension(name);
Document document = StudyUtils.getDocument(myProject.getBasePath(), lessonIndex, taskIndex, answerName);
if (document == null) {
document = StudyUtils.getDocument(myProject.getBasePath(), lessonIndex, taskIndex, name);
if (document == null) {
continue;
}
}
for (Element placeholder : getChildList(taskFileElement, ANSWER_PLACEHOLDERS, true)) {
Element lineElement = getChildWithName(placeholder, LINE, true);
int line = lineElement != null ? Integer.valueOf(lineElement.getAttributeValue(VALUE)) : 0;
Element startElement = getChildWithName(placeholder, START, true);
int start = startElement != null ? Integer.valueOf(startElement.getAttributeValue(VALUE)) : 0;
int offset = document.getLineStartOffset(line) + start;
addChildWithName(placeholder, OFFSET, offset);
addChildWithName(placeholder, "useLength", "false");
}
}
}
}
XmlSerializer.deserializeInto(this, state);
} catch (StudyUnrecognizedFormatException e) {
LOG.error(e);
}
}