本文整理汇总了Java中com.intellij.openapi.vfs.VirtualFile.findChild方法的典型用法代码示例。如果您正苦于以下问题:Java VirtualFile.findChild方法的具体用法?Java VirtualFile.findChild怎么用?Java VirtualFile.findChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.vfs.VirtualFile
的用法示例。
在下文中一共展示了VirtualFile.findChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例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: 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: getTestsFile
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Nullable
@Override
protected VirtualFile getTestsFile() {
VirtualFile taskDir = myTask.getTaskDir(myProject);
if (taskDir == null) {
return null;
}
for (String testFileName : myTask.getTestsText().keySet()) {
VirtualFile testFile = VfsUtil.findRelativeFile(taskDir, testFileName);
if (testFile != null) {
return testFile;
}
}
VirtualFile testsFile = taskDir.findChild(EduKotlinPluginConfigurator.LEGACY_TESTS_KT);
if (testsFile != null) {
return testsFile;
}
return taskDir.findChild(EduKotlinPluginConfigurator.TESTS_KT);
}
示例5: generateFolder
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Nullable
public static VirtualFile generateFolder(@NotNull Project project, @NotNull Module module, String name) {
VirtualFile generatedRoot = getGeneratedFilesFolder(project, module);
if (generatedRoot == null) {
return null;
}
final Ref<VirtualFile> folder = new Ref<>(generatedRoot.findChild(name));
//need to delete old folder
ApplicationManager.getApplication().runWriteAction(() -> {
try {
if (folder.get() != null) {
folder.get().delete(null);
}
folder.set(generatedRoot.createChildDirectory(null, name));
}
catch (IOException e) {
LOG.info("Failed to generate folder " + name, e);
}
});
return folder.get();
}
示例6: getTestsText
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@NotNull
public String getTestsText(@NotNull final Project project) {
final Course course = getLesson().getCourse();
final Language language = course.getLanguageById();
final EduPluginConfigurator configurator = EduPluginConfigurator.INSTANCE.forLanguage(language);
final VirtualFile taskDir = getTaskDir(project);
if (taskDir != null) {
final VirtualFile file = taskDir.findChild(configurator.getTestFileName());
if (file == null) return "";
final Document document = FileDocumentManager.getInstance().getDocument(file);
if (document != null) {
return document.getImmutableCharSequence().toString();
}
}
return "";
}
示例7: createModule
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel) throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
Module module = super.createModule(moduleModel);
Course course = myTask.getLesson().getCourse();
String directory = getModuleFileDirectory();
if (directory == null) {
return module;
}
VirtualFile moduleDir = VfsUtil.findFileByIoFile(new File(directory), true);
if (moduleDir == null) {
return module;
}
VirtualFile src = moduleDir.findChild(EduNames.SRC);
if (src == null) {
return module;
}
createTask(module.getProject(), course, src);
ModuleRootModificationUtil.addDependency(module, myUtilModule);
EduIntellijUtils.addJUnit(module);
return module;
}
示例8: createChildFile
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
public static void createChildFile(@NotNull VirtualFile taskDir, @NotNull String name, @NotNull String text) throws IOException {
String newDirectories = null;
String fileName = name;
VirtualFile dir = taskDir;
if (name.contains("/")) {
int pos = name.lastIndexOf("/");
fileName = name.substring(pos + 1);
newDirectories = name.substring(0, pos);
}
if (newDirectories != null) {
dir = VfsUtil.createDirectoryIfMissing(taskDir, newDirectories);
}
if (dir != null) {
VirtualFile virtualTaskFile = dir.findChild(fileName);
if (virtualTaskFile == null) {
virtualTaskFile = dir.createChildData(taskDir, fileName);
}
if (EduUtils.isImage(name)) {
virtualTaskFile.setBinaryContent(Base64.decodeBase64(text));
}
else {
VfsUtil.saveText(virtualTaskFile, text);
}
}
}
示例9: projectOpened
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Override
public void projectOpened() {
VirtualFile baseDir = Platform.findBaseRoot(m_project);
VirtualFile bsconfig = baseDir.findChild("bsconfig.json");
if (bsconfig != null) {
m_config = BsConfig.read(bsconfig);
String bsbBin = Platform.getBinary("REASON_BSB_BIN", "reasonBsb", "node_modules/bs-platform/lib/bsb.exe");
String bsbPath = Platform.getBinaryPath(m_project, bsbBin);
if (bsbPath == null) {
bsbPath = Platform.getBinaryPath(m_project, "node_modules/bs-platform/bin/bsb.exe");
}
if (bsbPath == null) {
Notifications.Bus.notify(new RmlNotification("Bsb",
"<html>Can't find bsb using value '" + bsbBin + "' from property 'reasonBsb'.\n"
+ "Base directory is '" + baseDir.getCanonicalPath() + "'.\n"
+ "Be sure that bsb is installed and reachable from base directory, "
+ "see <a href=\"https://github.com/reasonml-editor/reasonml-idea-plugin#bucklescript\">github</a>.</html>",
ERROR, URL_OPENING_LISTENER));
} else {
m_compiler = new BsCompiler(baseDir, bsbPath);
m_queryTypes = new BsQueryTypesServiceComponent(m_project, baseDir, bsbPath.replace("bsb.exe", "bsc.exe"));
m_errorsManager = new BsErrorsManagerImpl();
}
}
}
示例10: findBaseRoot
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
public static VirtualFile findBaseRoot(Project project) {
VirtualFile baseDir = m_baseDirs.get(project);
if (baseDir == null) {
baseDir = project.getBaseDir();
if (baseDir.findChild("node_modules") == null) {
// try to find it one level deeper
baseDir = Arrays.stream(baseDir.getChildren()).filter(file -> file.findChild("node_modules") != null).findFirst().orElse(baseDir);
}
m_baseDirs.put(project, baseDir);
}
return baseDir;
}
示例11: getIndexer
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {
return inputData -> {
Map<String, Void> map = new THashMap<>();
String path = inputData.getFile().getPath();
if (path.contains("sysext") || path.contains("typo3conf/ext")) {
map.put(compileId(inputData), null);
return map;
}
VirtualFile extensionRootFolder = FilesystemUtil.findExtensionRootFolder(inputData.getFile());
if (extensionRootFolder != null) {
// 1. try to read sibling composer.json
VirtualFile composerJsonFile = extensionRootFolder.findChild("composer.json");
if (composerJsonFile != null) {
String extensionKey = findExtensionKey(composerJsonFile);
if (extensionKey != null) {
map.put(compileId(extensionRootFolder, extensionKey, inputData.getFile()), null);
return map;
}
}
// 2. try to infer from directory name
map.put(compileId(extensionRootFolder.getName(), extensionRootFolder.getPath(), inputData.getFile()), null);
}
return map;
};
}
示例12: generateFromStudentCourse
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
public static void generateFromStudentCourse(Project project, Course course) {
StudyTaskManager.getInstance(project).setCourse(course);
course.setCourseMode(CCUtils.COURSE_MODE);
final VirtualFile baseDir = project.getBaseDir();
final Application application = ApplicationManager.getApplication();
application.invokeAndWait(() -> application.runWriteAction(() -> {
final VirtualFile[] children = baseDir.getChildren();
for (VirtualFile child : children) {
StudyUtils.deleteFile(child);
}
StudyGenerator.createCourse(course, baseDir);
}));
baseDir.refresh(false, true);
int index = 1;
int taskIndex = 1;
for (Lesson lesson : course.getLessons()) {
final VirtualFile lessonDir = project.getBaseDir().findChild(EduNames.LESSON + String.valueOf(index));
lesson.setIndex(index);
if (lessonDir == null) continue;
for (Task task : lesson.getTaskList()) {
final VirtualFile taskDir = lessonDir.findChild(EduNames.TASK + String.valueOf(taskIndex));
task.setIndex(taskIndex);
task.setLesson(lesson);
if (taskDir == null) continue;
for (final Map.Entry<String, TaskFile> entry : task.getTaskFiles().entrySet()) {
application.invokeAndWait(() -> application.runWriteAction(() -> createAnswerFile(project, taskDir, entry)));
}
taskIndex += 1;
}
index += 1;
taskIndex = 1;
}
course.initCourse(true);
application.invokeAndWait(() -> StudyUtils.registerStudyToolWindow(course, project));
synchronize(project);
}
示例13: createFiles
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
private static void createFiles(@NotNull VirtualFile taskDir, @NotNull Map<String, String> texts) throws IOException {
for (Map.Entry<String, String> entry : texts.entrySet()) {
final String name = entry.getKey();
VirtualFile virtualTaskFile = taskDir.findChild(name);
if (virtualTaskFile == null) {
createChildFile(taskDir, name, entry.getValue());
}
}
}
示例14: watchThisProject
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
/**
* watch the root .git/HEAD for changes (if it exists)
*
* @return gitHeadFile if exists or null otherwise.
*/
private VirtualFile watchThisProject(Project project) {
VirtualFile gitDir = project.getBaseDir().findChild(".git");
if (gitDir != null) {
VirtualFile gitHeadSymRefFile = gitDir.findChild("HEAD");
if (gitHeadSymRefFile != null) {
registerFileChangedListener(gitHeadSymRefFile.getCanonicalPath());
return gitHeadSymRefFile;
}
}
return null;
}
示例15: updateOpenedTestFiles
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
private static void updateOpenedTestFiles(@NotNull Project project,
@NotNull VirtualFile taskDir,
int fromTaskNumber,
int toSubtaskNumber) {
String fromSubtaskTestName = getTestFileName(project, fromTaskNumber);
String toSubtaskTestName = getTestFileName(project, toSubtaskNumber);
if (fromSubtaskTestName == null || toSubtaskTestName == null) {
return;
}
VirtualFile fromTest = taskDir.findChild(fromSubtaskTestName);
VirtualFile toTest = taskDir.findChild(toSubtaskTestName);
if (fromTest == null || toTest == null) {
return;
}
FileEditorManager editorManager = FileEditorManager.getInstance(project);
if (editorManager.isFileOpen(fromTest)) {
VirtualFile[] selectedFiles = editorManager.getSelectedFiles();
boolean isSelected = ArrayUtil.contains(fromTest, selectedFiles);
editorManager.closeFile(fromTest);
editorManager.openFile(toTest, isSelected);
if (!isSelected) {
for (VirtualFile file : selectedFiles) {
editorManager.openFile(file, true);
}
}
}
}