本文整理汇总了Java中com.intellij.openapi.vfs.VirtualFile.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java VirtualFile.getParent方法的具体用法?Java VirtualFile.getParent怎么用?Java VirtualFile.getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.vfs.VirtualFile
的用法示例。
在下文中一共展示了VirtualFile.getParent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: findExtensionRootFolder
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Nullable
public static VirtualFile findExtensionRootFolder(@NotNull VirtualFile file) {
if (file.isDirectory()) {
VirtualFile child = file.findChild("ext_emconf.php");
if (child != null) {
return file;
}
}
// dragons ahead.
if (file.getParent() != null) {
return findExtensionRootFolder(file.getParent());
}
return null;
}
示例3: parsePom
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Nullable
private static ProjectInfo parsePom(@NotNull VirtualFile file)
{
try
{
String content = VirtualFileHelper.read(file);
PomModel model = PomModel.parse(content);
PomModel parent = null;
if (file.getParent() != null && file.getParent().getParent() != null)
{
VirtualFile parentDirFile = file.getParent().getParent();
VirtualFile parentFile = parentDirFile.findChild("pom.xml");
if (parentFile != null)
{
String parentContent = VirtualFileHelper.read(parentFile);
parent = PomModel.parse(parentContent);
}
}
return ProjectInfo.parse(model, parent);
}
catch (IOException | JAXBException | XMLStreamException ex)
{
LOG.log(Level.SEVERE, ex.getMessage());
return null;
}
}
示例4: getTask
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Nullable
public static Task getTask(@NotNull Project project, @NotNull VirtualFile taskVF) {
Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null) {
return null;
}
VirtualFile lessonVF = taskVF.getParent();
if (lessonVF == null) {
return null;
}
Lesson lesson = course.getLesson(lessonVF.getName());
if (lesson == null) {
return null;
}
return lesson.getTask(taskVF.getName());
}
示例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: deleteTask
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
private static void deleteTask(@NotNull final Course course, @NotNull final VirtualFile removedTask) {
VirtualFile lessonDir = removedTask.getParent();
if (lessonDir == null || !lessonDir.getName().contains(EduNames.LESSON)) {
return;
}
final Lesson lesson = course.getLesson(lessonDir.getName());
if (lesson == null) {
return;
}
Task task = lesson.getTask(removedTask.getName());
if (task == null) {
return;
}
CCUtils.updateHigherElements(lessonDir.getChildren(), file -> lesson.getTask(file.getName()), task.getIndex(), EduNames.TASK, -1);
lesson.getTaskList().remove(task);
}
示例7: 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;
}
示例8: findVfUp
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
public static VirtualFile findVfUp(VirtualFile item, String searchItemName)
{
if (item.getParent() != null) {
VirtualFile vf = VfsUtilCore.findRelativeFile(searchItemName, item.getParent());
if (vf != null && !vf.isDirectory()) {
return vf;
}
}
return findVfUp(item.getParent(), searchItemName);
}
示例9: 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;
}
示例10: fileCreated
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Override
public void fileCreated(@NotNull VirtualFileEvent event) {
if (myProject.isDisposed()) return;
final VirtualFile createdFile = event.getFile();
final VirtualFile taskDir = StudyUtils.getTaskDir(createdFile);
final Course course = StudyTaskManager.getInstance(myProject).getCourse();
if (course == null || !EduNames.STUDY.equals(course.getCourseMode())) {
return;
}
if (taskDir != null && taskDir.getName().contains(EduNames.TASK)) {
int taskIndex = EduUtils.getIndex(taskDir.getName(), EduNames.TASK);
final VirtualFile lessonDir = taskDir.getParent();
if (lessonDir != null && lessonDir.getName().contains(EduNames.LESSON)) {
int lessonIndex = EduUtils.getIndex(lessonDir.getName(), EduNames.LESSON);
List<Lesson> lessons = course.getLessons();
if (StudyUtils.indexIsValid(lessonIndex, lessons)) {
final Lesson lesson = lessons.get(lessonIndex);
final List<Task> tasks = lesson.getTaskList();
if (StudyUtils.indexIsValid(taskIndex, tasks)) {
final Task task = tasks.get(taskIndex);
final TaskFile taskFile = new TaskFile();
taskFile.initTaskFile(task, false);
taskFile.setUserCreated(true);
final String name = FileUtil.getRelativePath(taskDir.getPath(), createdFile.getPath(), '/');
taskFile.name = name;
//TODO: put to other steps as well
task.getTaskFiles().put(name, taskFile);
}
}
}
}
}
示例11: deleteWindowDescriptions
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
public static void deleteWindowDescriptions(@NotNull final Task task, @NotNull final VirtualFile taskDir) {
for (Map.Entry<String, TaskFile> entry : task.getTaskFiles().entrySet()) {
String name = entry.getKey();
VirtualFile virtualFile = taskDir.findFileByRelativePath(name);
if (virtualFile == null) {
continue;
}
String windowsFileName = virtualFile.getNameWithoutExtension() + EduNames.WINDOWS_POSTFIX;
VirtualFile parentDir = virtualFile.getParent();
deleteWindowsFile(parentDir, windowsFileName);
}
}
示例12: isSourceFile
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
private static boolean isSourceFile(@Nullable VirtualFile file) {
String sources = Utils.getPropertyValue("sources", true);
List<String> sourcesList = Utils.getSourcesList(sources);
if (file == null) {
return false;
}
for (String src : sourcesList) {
if (src.equals(file.getName()) && file.getParent() != null && "values".equals(file.getParent().getName())) {
return true;
}
}
return false;
}
示例13: isAvailable
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Override
protected boolean isAvailable(VirtualFile dir) {
if (dir.getName().contains(EduNames.TASK)) {
return true;
}
VirtualFile parent = dir.getParent();
if (parent != null && parent.getName().contains(EduNames.TASK)) {
return true;
}
return false;
}
示例14: actionPerformed
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent event) {
VirtualFile file = DataKeys.VIRTUAL_FILE.getData(event.getDataContext());
Project project = event.getProject();
if (file == null || project == null) return;
VirtualFile folder = file.isDirectory() ? file : file.getParent();
WriteCommandAction.runWriteCommandAction(project, () -> {
createData(folder);
createDomain(folder);
createPresentation(folder);
});
}
示例15: getLanguageFileType
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
public static LangFileEditorType getLanguageFileType(@NotNull final VirtualFile file) {
VirtualFile parent = file.getParent();
if (GravYamlFiles.withYamlExtension(file) && parent != null && parent.exists() && parent.getName().equalsIgnoreCase("languages")) {
return LANGUAGE_FOLDER;
} else if (GravYamlFiles.withYamlExtension(file) && file.getNameWithoutExtension().equalsIgnoreCase("languages")) {
return LANGUAGE_FILE;
}
return NONE;
}