本文整理汇总了Java中com.intellij.openapi.vfs.VirtualFile.getName方法的典型用法代码示例。如果您正苦于以下问题:Java VirtualFile.getName方法的具体用法?Java VirtualFile.getName怎么用?Java VirtualFile.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.vfs.VirtualFile
的用法示例。
在下文中一共展示了VirtualFile.getName方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIndexer
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@NotNull
@Override
public DataIndexer<String, String, FileContent> getIndexer() {
return virtualFile -> {
final Map<String, String> items = new THashMap<>();
VirtualFile file = virtualFile.getFile();
VirtualFile parentDirectory = file.getParent();
if (parentDirectory != null) {
VirtualFile ancestorDirectory = parentDirectory.getParent();
if (ancestorDirectory != null && ancestorDirectory.isDirectory()) {
String ancestorDirectoryName = ancestorDirectory.getName();
if (ancestorDirectoryName.equals("sysext") || ancestorDirectoryName.equals("ext")) {
String path = file.getPath();
items.put(parentDirectory.getName(), path);
}
// handle the case where the extension name can *not* be inferred from the directory name
}
}
return items;
};
}
示例2: findExtensionKeyFromFile
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Nullable
public static String findExtensionKeyFromFile(@NotNull VirtualFile file) {
VirtualFile extensionRootFolder = FilesystemUtil.findExtensionRootFolder(file);
if (extensionRootFolder == null) {
return null;
}
String extensionKey = null;
VirtualFile composerJsonFile = extensionRootFolder.findChild("composer.json");
if (composerJsonFile != null) {
String extensionKeyFromComposerJson = ComposerUtil.findExtensionKey(composerJsonFile);
if (extensionKeyFromComposerJson == null) {
extensionKey = extensionRootFolder.getName();
} else {
extensionKey = extensionKeyFromComposerJson;
}
} else {
extensionKey = extensionRootFolder.getName();
}
return extensionKey;
}
示例3: processFile
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Override
public boolean processFile(final VirtualFile file) {
final String fileName = file.getName();
final String filePath = file.getPath();
boolean isTarget = false;
if(fileContent.isPython()){
isTarget = !file.isDirectory() && !fileContent.contains(filePath);
}else{
isTarget = !file.isDirectory() && fileContent.contains(filePath);
}
if (isTarget && !this.fileContent.hasFile(fileName)) {
fileContent.get().put(fileName, filePath);
//System.out.println("include: " + fileName);
}
return true;
}
示例4: findMapFiles
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@NotNull
private static Map<String, VirtualFile> findMapFiles(@NotNull VirtualFile baseDir,
@NotNull String filter,
@NotNull String path)
{
Map<String, VirtualFile> files = new HashMap<>();
if (!baseDir.isDirectory() || baseDir.getName().startsWith("."))
{
return files;
}
VirtualFile[] children = baseDir.getChildren();
String currentPath = path.isEmpty() ? baseDir.getName() : path + "/" + baseDir.getName();
for (VirtualFile child : children)
{
if (child.isDirectory())
{
files.putAll(findMapFiles(child, filter, currentPath));
}
else if (filter.equals(child.getName()))
{
files.put(currentPath, child);
}
}
return files;
}
示例5: getTaskDir
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Nullable
public static VirtualFile getTaskDir(@NotNull VirtualFile taskFile) {
VirtualFile parent = taskFile.getParent();
while (parent != null) {
String name = parent.getName();
if (name.contains(EduNames.TASK) && parent.isDirectory()) {
return parent;
}
if (EduNames.SRC.equals(name)) {
return parent.getParent();
}
parent = parent.getParent();
}
return null;
}
示例6: getSubtaskIndex
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的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;
}
}
示例7: ViewLookupElement
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
ViewLookupElement(PsiFile psiFile) {
myFile = psiFile;
VirtualFile file = psiFile.getVirtualFile();
if (file.getNameWithoutExtension().contains(".")) {
myName = file.getName();
myTail = null;
} else {
myName = file.getNameWithoutExtension();
myTail = "." + file.getExtension();
}
}
示例8: getAreaName
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@NotNull
protected String getAreaName() {
VirtualFile containingDirectory = xmlTag.getContainingFile().getVirtualFile().getParent();
String configDirectory = containingDirectory.getName();
if (configDirectory.equals("etc")) {
VirtualFile moduleDirectory = containingDirectory.getParent();
if (moduleDirectory.getName().equals("app")) {
return "primary";
}
return "global";
}
return configDirectory;
}
示例9: isTestFile
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Override
public boolean isTestFile(VirtualFile file) {
String name = file.getName();
if (TESTS_PY.equals(name)) {
return true;
}
return name.contains(FileUtil.getNameWithoutExtension(TESTS_PY)) && name.contains(EduNames.SUBTASK_MARKER);
}
示例10: getTaskFile
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Nullable
public static TaskFile getTaskFile(@NotNull final Project project, @NotNull final VirtualFile file) {
final Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null) {
return null;
}
VirtualFile taskDir = getTaskDir(file);
if (taskDir == null) {
return null;
}
//need this because of multi-module generation
if (EduNames.SRC.equals(taskDir.getName())) {
taskDir = taskDir.getParent();
if (taskDir == null) {
return null;
}
}
final String taskDirName = taskDir.getName();
if (taskDirName.contains(EduNames.TASK)) {
final VirtualFile lessonDir = taskDir.getParent();
if (lessonDir != null) {
int lessonIndex = EduUtils.getIndex(lessonDir.getName(), EduNames.LESSON);
List<Lesson> lessons = course.getLessons();
if (!indexIsValid(lessonIndex, lessons)) {
return null;
}
final Lesson lesson = lessons.get(lessonIndex);
int taskIndex = EduUtils.getIndex(taskDirName, EduNames.TASK);
final List<Task> tasks = lesson.getTaskList();
if (!indexIsValid(taskIndex, tasks)) {
return null;
}
final Task task = tasks.get(taskIndex);
return task.getFile(pathRelativeToTask(file));
}
}
return null;
}
示例11: pathRelativeToTask
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
public static String pathRelativeToTask(VirtualFile file) {
VirtualFile taskDir = getTaskDir(file);
if (taskDir == null) return file.getName();
VirtualFile srcDir = taskDir.findChild(EduNames.SRC);
if (srcDir != null) {
taskDir = srcDir;
}
return FileUtil.getRelativePath(taskDir.getPath(), file.getPath(), '/');
}
示例12: isTestFile
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Override
public boolean isTestFile(VirtualFile file) {
String name = file.getName();
return TEST_JAVA.equals(name) || name.contains(FileUtil.getNameWithoutExtension(TEST_JAVA)) && name.contains(EduNames.SUBTASK_MARKER);
}
示例13: isTestFile
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Override
public boolean isTestFile(VirtualFile file) {
String name = file.getName();
return TESTS_KT.equals(name) || LEGACY_TESTS_KT.equals(name) || name.contains(FileUtil.getNameWithoutExtension(TESTS_KT)) && name.contains(EduNames.SUBTASK_MARKER);
}
示例14: getFileTitle
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Override
public String getFileTitle(@NotNull Project project, @NotNull VirtualFile virtualFile) {
String fileCustomTitle;
try {
Module fileModule = FileIndexFacade.getInstance(project).getModuleForFile(virtualFile);
String projectDefaultTitle = defaultBuilder.getProjectTitle(project);
String projectName = project.getName();
String projectPath = project.getBasePath();
String fileDefaultTitle = defaultBuilder.getFileTitle(project, virtualFile);
String fileName = virtualFile.getName();
String filePath = virtualFile.getPath();
String fileExt = virtualFile.getExtension();
String moduleName = null;
String modulePath = null;
if (fileModule != null) {
moduleName = fileModule.getName();
modulePath = fileModule.getModuleFilePath();
}
fileCustomTitle = engine.eval("fileTemplate({" +
"projectDefaultTitle: '" + projectDefaultTitle + "'," +
"projectName: '" + projectName + "'," +
"projectPath: '" + projectPath + "'," +
"fileDefaultTitle: '" + fileDefaultTitle + "'," +
"fileName: '" + fileName + "'," +
"filePath: '" + filePath + "'," +
"fileExt: '" + fileExt + "'," +
"moduleName: '" + moduleName + "'," +
"modulePath: '" + modulePath + "'" +
"})").toString();
} catch (Exception e) {
fileCustomTitle = defaultBuilder.getFileTitle(project, virtualFile);
}
return fileCustomTitle;
}