本文整理汇总了Java中com.intellij.util.PathUtil.makeFileName方法的典型用法代码示例。如果您正苦于以下问题:Java PathUtil.makeFileName方法的具体用法?Java PathUtil.makeFileName怎么用?Java PathUtil.makeFileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.PathUtil
的用法示例。
在下文中一共展示了PathUtil.makeFileName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getContentFile
import com.intellij.util.PathUtil; //导入方法依赖的package包/类
@Nullable
public static VirtualFile getContentFile(@NotNull final ConsoleRootType rootType, @NotNull String id, ScratchFileService.Option option) {
final String pathName = PathUtil.makeFileName(rootType.getContentPathName(id), rootType.getDefaultFileExtension());
try {
return rootType.findFile(null, pathName, option);
}
catch (final IOException e) {
LOG.warn(e);
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
String message = String.format("Unable to open '%s/%s'\nReason: %s", rootType.getId(), pathName, e.getLocalizedMessage());
Messages.showErrorDialog(message, "Unable to Open File");
}
});
return null;
}
}
示例2: runConsole
import com.intellij.util.PathUtil; //导入方法依赖的package包/类
protected void runConsole(@NotNull AnActionEvent e, @NotNull String language) {
Project project = e.getProject();
if (project == null) return;
List<String> extensions = IdeScriptEngineManager.getInstance().getFileExtensions(language);
try {
String pathName = PathUtil.makeFileName(DEFAULT_FILE_NAME, ContainerUtil.getFirstItem(extensions));
VirtualFile virtualFile = IdeConsoleRootType.getInstance().findFile(project, pathName, ScratchFileService.Option.create_if_missing);
if (virtualFile != null) {
FileEditorManager.getInstance(project).openFile(virtualFile, true);
}
}
catch (IOException ex) {
LOG.error(ex);
}
}
示例3: run
import com.intellij.util.PathUtil; //导入方法依赖的package包/类
@Override
public void run() {
logger.info("Preparing to write a total of " + sketchFiles.size() + " to the project package " + packageFqn + ".");
for (PsiFile sketchFile : sketchFiles) {
logger.info("Writing the sketch PSI file '" + sketchFile.getName() + "' to the project package '" + packageFqn + "'.");
String sketchFileExtension = PathUtil.getFileExtension(sketchFile.getName());
if (sketchFileExtension == null || ! sketchFileExtension.equals(JavaFileType.DEFAULT_EXTENSION)) {
String generatedSketchFileName = PathUtil.makeFileName(PathUtil.getFileName(sketchFile.getName()), JavaFileType.DEFAULT_EXTENSION);
sketchFile.setName(generatedSketchFileName);
}
WriteCommandAction.Simple<String> command = new WriteCommandAction.Simple<String>(project, sketchFile) {
@Override
protected void run() throws Throwable {
CodeStyleManager.getInstance(project).reformat(sketchFile, false);
packageFqn.add(sketchFile);
}
};
RunResult<String> result = command.execute();
logger.debug("Result of executing the file write action is: '" + result.getResultObject() + "'.");
}
}
示例4: getHistoryName
import com.intellij.util.PathUtil; //导入方法依赖的package包/类
@NotNull
private static String getHistoryName(@NotNull ConsoleRootType rootType, @NotNull String id) {
return rootType.getConsoleTypeId() + "/" +
PathUtil.makeFileName(rootType.getHistoryPathName(id), rootType.getDefaultFileExtension());
}