当前位置: 首页>>代码示例>>Java>>正文


Java FileUtil.getNameWithoutExtension方法代码示例

本文整理汇总了Java中com.intellij.openapi.util.io.FileUtil.getNameWithoutExtension方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtil.getNameWithoutExtension方法的具体用法?Java FileUtil.getNameWithoutExtension怎么用?Java FileUtil.getNameWithoutExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.util.io.FileUtil的用法示例。


在下文中一共展示了FileUtil.getNameWithoutExtension方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: transformTestFile

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的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);
        }
      });
    }
  }
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:21,代码来源:StudySubtaskUtils.java

示例2: getSubtaskIndex

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public static int getSubtaskIndex(@NotNull Project project, @NotNull VirtualFile file) {
  String fileName = file.getName();
  String name = FileUtil.getNameWithoutExtension(fileName);
  if (!isTestsFile(project, file)) {
    return -1;
  }
  if (!name.contains(EduNames.SUBTASK_MARKER)) {
    return 0;
  }
  int markerIndex = name.indexOf(EduNames.SUBTASK_MARKER);
  String index = name.substring(markerIndex + EduNames.SUBTASK_MARKER.length());
  if (index.isEmpty()) {
    return -1;
  }
  try {
    return Integer.valueOf(index);
  }
  catch (NumberFormatException e) {
    return -1;
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:22,代码来源:CCUtils.java

示例3: getAllAnswerTaskFiles

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的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;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:21,代码来源:CCProjectComponent.java

示例4: getTestsFile

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的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;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:23,代码来源:EduJavaPyCharmTaskChecker.java

示例5: getNewFileName

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private static String getNewFileName(GroovyFile file) {
  final PsiDirectory dir = file.getContainingDirectory();
  LOG.assertTrue(dir != null);


  final PsiFile[] files = dir.getFiles();
  Set<String> fileNames = new HashSet<String>();
  for (PsiFile psiFile : files) {
    fileNames.add(psiFile.getName());
  }
  String prefix = FileUtil.getNameWithoutExtension(file.getName());
  String fileName = prefix + ".java";
  int index = 1;
  while (fileNames.contains(fileName)) {
    fileName = prefix + index + ".java";
  }
  return fileName;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ConvertToJavaProcessor.java

示例6: getTraceFiles

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Nullable
private static File[] getTraceFiles(Project project) {
  final CoverageSuitesBundle currentSuite = CoverageDataManager.getInstance(project).getCurrentSuitesBundle();
  if (currentSuite == null) return null;
  final List<File> files = new ArrayList<File>();
  for (CoverageSuite coverageSuite : currentSuite.getSuites()) {

    final String filePath = coverageSuite.getCoverageDataFileName();
    final String dirName = FileUtil.getNameWithoutExtension(new File(filePath).getName());

    final File parentDir = new File(filePath).getParentFile();
    final File tracesDir = new File(parentDir, dirName);
    final File[] suiteFiles = tracesDir.listFiles();
    if (suiteFiles != null) {
      Collections.addAll(files, suiteFiles);
    }
  }

  return files.isEmpty() ? null : files.toArray(new File[files.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:ShowCoveringTestsAction.java

示例7: updateOutputPath

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的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();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ArtifactEditorImpl.java

示例8: matchesSource

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Override
public boolean matchesSource(
    Project project,
    TargetInfo target,
    @Nullable PsiFile sourcePsiFile,
    File sourceFile,
    @Nullable TestSize testSize) {
  String filePathWithoutExtension = FileUtil.getNameWithoutExtension(sourceFile.getPath());
  String targetName = target.label.targetName().toString();
  if (!filePathWithoutExtension.endsWith(targetName)) {
    return false;
  }
  int i = filePathWithoutExtension.length() - targetName.length() - 1;
  if (i < 0) {
    // Equal length
    return true;
  }
  return filePathWithoutExtension.charAt(i) == '/';
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:20,代码来源:TargetNameHeuristic.java

示例9: process

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private static List<IdeaPluginDescriptor> process(@Nullable String repositoryUrl, List<IdeaPluginDescriptor> list) {
  for (Iterator<IdeaPluginDescriptor> i = list.iterator(); i.hasNext(); ) {
    PluginNode node = (PluginNode)i.next();

    if (node.getPluginId() == null || repositoryUrl != null && node.getDownloadUrl() == null) {
      LOG.warn("Malformed plugin record (id:" + node.getPluginId() + " repository:" + repositoryUrl + ")");
      i.remove();
      continue;
    }

    if (repositoryUrl != null) {
      node.setRepositoryName(repositoryUrl);
    }

    if (node.getName() == null) {
      String url = node.getDownloadUrl();
      String name = FileUtil.getNameWithoutExtension(url.substring(url.lastIndexOf('/') + 1));
      node.setName(name);
    }
  }

  return list;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:RepositoryHelper.java

示例10: correlateTestToHeader

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Nullable
private static OCFile correlateTestToHeader(OCFile file) {
  // Quickly check foo_test.cc -> foo.h as well. "getAssociatedFileWithSameName" only does
  // foo.cc <-> foo.h. However, if you do goto-related-symbol again, it will go from
  // foo.h -> foo.cc instead of back to foo_test.cc.
  PsiManager psiManager = PsiManager.getInstance(file.getProject());
  String pathWithoutExtension = FileUtil.getNameWithoutExtension(file.getVirtualFile().getPath());
  for (String testSuffix : TEST_SUFFIXES) {
    if (pathWithoutExtension.endsWith(testSuffix)) {
      String possibleHeaderName = StringUtil.trimEnd(pathWithoutExtension, testSuffix) + ".h";
      VirtualFile virtualFile = VfsUtil.findFileByIoFile(new File(possibleHeaderName), false);
      if (virtualFile != null) {
        PsiFile psiFile = psiManager.findFile(virtualFile);
        if (psiFile instanceof OCFile) {
          return (OCFile) psiFile;
        }
      }
    }
  }
  return null;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:22,代码来源:SwitchToHeaderOrSourceSearch.java

示例11: getSubtaskTestsFileName

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的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);
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:8,代码来源:PyEduPluginConfigurator.java

示例12: createCheckProcess

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的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;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:30,代码来源:PyStudyTestRunner.java

示例13: getTestFileName

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的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;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:16,代码来源:StudySubtaskUtils.java

示例14: replaceWithSubtask

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的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));
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:10,代码来源:StudySerializationUtils.java

示例15: loadState

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的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);
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:38,代码来源:CCProjectService.java


注:本文中的com.intellij.openapi.util.io.FileUtil.getNameWithoutExtension方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。