本文整理汇总了Java中com.intellij.openapi.vfs.VfsUtilCore.findRelativeFile方法的典型用法代码示例。如果您正苦于以下问题:Java VfsUtilCore.findRelativeFile方法的具体用法?Java VfsUtilCore.findRelativeFile怎么用?Java VfsUtilCore.findRelativeFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.vfs.VfsUtilCore
的用法示例。
在下文中一共展示了VfsUtilCore.findRelativeFile方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compute
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
@Nullable
@Override
public CachedValueProvider.Result<MultiMap<String, String>> compute() {
MultiMap<String, String> result = new MultiMap<String, String>();
Collection<Map<String, Resource>> values = myStandardResources.getValue().values();
for (Map<String, Resource> map : values) {
for (Map.Entry<String, Resource> entry : map.entrySet()) {
String url = entry.getValue().getResourceUrl();
if (url != null) {
VirtualFile file = VfsUtilCore.findRelativeFile(url, null);
if (file != null) {
String namespace = XmlNamespaceIndex.computeNamespace(file);
if (namespace != null) {
result.putValue(namespace, entry.getKey());
}
}
}
}
}
return CachedValueProvider.Result.create(result, ExternalResourceManagerExImpl.this);
}
示例2: getAdditionalRootsToIndex
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
@NotNull
@Override
public Set<VirtualFile> getAdditionalRootsToIndex() {
Set<VirtualFile> roots = new THashSet<VirtualFile>();
for (String url : myStandardResources.getValue()) {
VirtualFile file = VfsUtilCore.findRelativeFile(url, null);
if (file != null) {
roots.add(file);
}
}
String path = FetchExtResourceAction.getExternalResourcesPath();
VirtualFile extResources = LocalFileSystem.getInstance().findFileByPath(path);
ContainerUtil.addIfNotNull(extResources, roots);
return roots;
}
示例3: testPluginProject
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
public void testPluginProject() throws Exception {
createSdk("devkit", IdeaJdk.getInstance());
Project project = createProjectFromTemplate(PluginModuleType.getInstance().getName(), null, null);
VirtualFile baseDir = project.getBaseDir();
VirtualFile virtualFile = VfsUtilCore.findRelativeFile("resources/META-INF/plugin.xml", baseDir);
assertNotNull(virtualFile);
RunnerAndConfigurationSettings configuration = RunManager.getInstance(project).getSelectedConfiguration();
assertNotNull(configuration);
ConfigurationType type = configuration.getType();
assertNotNull(type);
assertEquals(DevKitBundle.message("run.configuration.title"), type.getDisplayName());
VirtualFile[] files = FileEditorManager.getInstance(project).getOpenFiles();
assertEquals(1, files.length);
}
示例4: findVfUp
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的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);
}
示例5: getDescriptionFile
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
public static VirtualFile getDescriptionFile(Project project, String path) {
return VfsUtilCore.findRelativeFile(path, project.getBaseDir());
}
示例6: findFile
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
@Nullable
private PsiFile findFile(String uri) {
final VirtualFile file =
uri != null ? VfsUtilCore.findRelativeFile(ExternalResourceManager.getInstance().getResourceLocation(uri), null) : null;
return file != null ? PsiManager.getInstance(myProject).findFile(file) : null;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:GenerateInstanceDocumentFromSchemaDialog.java
示例7: doAction
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
private static void doAction(final Project project, final GenerateSchemaFromInstanceDocumentDialog dialog) {
FileDocumentManager.getInstance().saveAllDocuments();
final String url = dialog.getUrl().getText();
final VirtualFile relativeFile = VfsUtilCore.findRelativeFile(ExternalResourceManager.getInstance().getResourceLocation(url), null);
VirtualFile relativeFileDir;
if (relativeFile == null) {
Messages.showErrorDialog(project, XmlBundle.message("file.doesnt.exist", url), XmlBundle.message("error"));
return;
} else {
relativeFileDir = relativeFile.getParent();
}
if (relativeFileDir == null) {
Messages.showErrorDialog(project, XmlBundle.message("file.doesnt.exist", url), XmlBundle.message("error"));
return;
}
@NonNls List<String> parameters = new LinkedList<String>();
parameters.add("-design");
parameters.add(DESIGN_TYPES.get(dialog.getDesignType()));
parameters.add("-simple-content-types");
parameters.add(CONTENT_TYPES.get(dialog.getSimpleContentType()));
parameters.add("-enumerations");
String enumLimit = dialog.getEnumerationsLimit();
parameters.add("0".equals(enumLimit) ? "never" : enumLimit);
parameters.add("-outDir");
final String dirPath = relativeFileDir.getPath();
parameters.add(dirPath);
final File expectedSchemaFile = new File(dirPath + File.separator + relativeFile.getName() + "0.xsd");
if (expectedSchemaFile.exists()) {
if (!expectedSchemaFile.delete()) {
Messages.showErrorDialog(project, XmlBundle.message("cant.delete.file", expectedSchemaFile.getPath()), XmlBundle.message("error"));
return;
}
}
parameters.add("-outPrefix");
parameters.add(relativeFile.getName());
parameters.add(url);
File xsd = new File(dirPath + File.separator + dialog.getTargetSchemaName());
final VirtualFile xsdFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(xsd);
if (xsdFile != null) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
try {
xsdFile.delete(null);
} catch (IOException e) {//
}
}
});
}
Inst2Xsd.main(ArrayUtil.toStringArray(parameters));
if (expectedSchemaFile.exists()) {
final boolean renamed = expectedSchemaFile.renameTo(xsd);
if (! renamed) {
Messages.showErrorDialog(project, XmlBundle.message("cant.rename.file", expectedSchemaFile.getPath(), xsd.getPath()), XmlBundle.message("error"));
}
}
VirtualFile xsdVFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(xsd);
if (xsdVFile != null) {
FileEditorManager.getInstance(project).openFile(xsdVFile, true);
} else {
Messages.showErrorDialog(project, XmlBundle.message("xml2xsd.generator.error.message"), XmlBundle.message("xml2xsd.generator.error"));
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:75,代码来源:GenerateSchemaFromInstanceDocumentAction.java
示例8: findRelativeFile
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
/** @see #findRelative(String, com.intellij.psi.PsiFileSystemItem) */
@Deprecated
@Nullable
public static VirtualFile findRelativeFile(String uri, VirtualFile base) {
return VfsUtilCore.findRelativeFile(ExternalResourceManager.getInstance().getResourceLocation(uri), base);
}
示例9: findRelative
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
@Nullable
public static VirtualFile findRelative(String uri, @NotNull PsiFileSystemItem base) {
String location = ExternalResourceManager.getInstance().getResourceLocation(uri, base.getProject());
return VfsUtilCore.findRelativeFile(location, base.getVirtualFile());
}
示例10: testGradleProject
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
public void testGradleProject() throws Exception {
final String projectName = "testProject";
Project project = createProject(new Consumer<Step>() {
@Override
public void consume(Step step) {
if (step instanceof ProjectTypeStep) {
assertTrue(((ProjectTypeStep)step).setSelectedTemplate("Gradle", null));
List<ModuleWizardStep> steps = myWizard.getSequence().getSelectedSteps();
assertEquals(5, steps.size());
final ProjectBuilder projectBuilder = myWizard.getProjectBuilder();
assertInstanceOf(projectBuilder, GradleModuleBuilder.class);
((GradleModuleBuilder)projectBuilder).setName(projectName);
}
}
});
assertEquals(projectName, project.getName());
Module[] modules = ModuleManager.getInstance(project).getModules();
assertEquals(1, modules.length);
final Module module = modules[0];
assertTrue(ModuleRootManager.getInstance(module).isSdkInherited());
assertEquals(projectName, module.getName());
VirtualFile root = ProjectRootManager.getInstance(project).getContentRoots()[0];
VirtualFile settingsScript = VfsUtilCore.findRelativeFile("settings.gradle", root);
assertNotNull(settingsScript);
assertEquals(String.format("rootProject.name = '%s'\n\n", projectName),
StringUtil.convertLineSeparators(VfsUtilCore.loadText(settingsScript)));
VirtualFile buildScript = VfsUtilCore.findRelativeFile("build.gradle", root);
assertNotNull(buildScript);
assertEquals("group '" + projectName + "'\n" +
"version '1.0-SNAPSHOT'\n" +
"\n" +
"apply plugin: 'java'\n" +
"\n" +
"sourceCompatibility = 1.5\n" +
"\n" +
"repositories {\n" +
" mavenCentral()\n" +
"}\n" +
"\n" +
"dependencies {\n" +
" testCompile group: 'junit', name: 'junit', version: '4.11'\n" +
"}\n",
StringUtil.convertLineSeparators(VfsUtilCore.loadText(buildScript)));
}