本文整理汇总了Java中com.intellij.openapi.vfs.VfsUtil.findRelativeFile方法的典型用法代码示例。如果您正苦于以下问题:Java VfsUtil.findRelativeFile方法的具体用法?Java VfsUtil.findRelativeFile怎么用?Java VfsUtil.findRelativeFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.vfs.VfsUtil
的用法示例。
在下文中一共展示了VfsUtil.findRelativeFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTestsFile
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的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);
}
示例2: configure
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
@Override
public void configure(@NotNull MavenProject mavenProject, @NotNull Project project, @Nullable Module module) {
if (module == null) return;
CompilerConfiguration configuration = CompilerConfiguration.getInstance(project);
if (!Boolean.TRUE.equals(module.getUserData(IGNORE_MAVEN_COMPILER_TARGET_KEY))) {
String targetLevel = mavenProject.getTargetLevel();
// default source and target settings of maven-compiler-plugin is 1.5, see details at http://maven.apache.org/plugins/maven-compiler-plugin
configuration.setBytecodeTargetLevel(module, ObjectUtils.notNull(targetLevel, "1.5"));
}
module.putUserData(IGNORE_MAVEN_COMPILER_TARGET_KEY, Boolean.FALSE);
// Exclude src/main/archetype-resources
VirtualFile dir = VfsUtil.findRelativeFile(mavenProject.getDirectoryFile(), "src", "main", "resources", "archetype-resources");
if (dir != null && !configuration.isExcludedFromCompilation(dir)) {
ExcludesConfiguration cfg = configuration.getExcludedEntriesConfiguration();
cfg.addExcludeEntryDescription(new ExcludeEntryDescription(dir, true, false, project));
}
}
示例3: findModuleWithoutLibrary
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
@Nullable
private static Pair<Module, MvcFramework> findModuleWithoutLibrary(Project project) {
MvcFramework[] frameworks = MvcFramework.EP_NAME.getExtensions();
for (Module module : ModuleManager.getInstance(project).getModules()) {
for (MvcFramework framework : frameworks) {
if (framework.hasFrameworkStructure(module) && !framework.hasFrameworkJar(module)) {
if (VfsUtil.findRelativeFile(framework.findAppRoot(module), "application.properties") != null) {
return Pair.create(module, framework);
}
}
}
}
return null;
}
示例4: triggerCleanAll
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
private void triggerCleanAll(final Project project) {
final HybrisProjectSettings yProjectSettings = HybrisProjectSettingsComponent.getInstance(project).getState();
final File platformDir = new File(project.getBasePath() + "/" +
yProjectSettings.getHybrisDirectory() + PLATFORM_MODULE_PREFIX);
final VirtualFile vfPlatformDir = VfsUtil.findFileByIoFile(platformDir, true);
final VirtualFile vfBuildFile = VfsUtil.findRelativeFile(vfPlatformDir, HybrisConstants.ANT_BUILD_XML);
if (vfBuildFile == null) {
return;
}
final PsiFile psiBuildFile = PsiManager.getInstance(project).findFile(vfBuildFile);
if (psiBuildFile == null) {
return;
}
final AntConfigurationBase antConfiguration = AntConfigurationBase.getInstance(project);
final AntBuildFileBase antBuildFile = antConfiguration.getAntBuildFile(psiBuildFile);
if (antBuildFile != null) {
ExecutionHandler.runBuild(
antBuildFile,
antCleanAll,
null,
getDataContext(project),
Collections.emptyList(),
AntBuildListener.NULL
);
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:30,代码来源:HybrisAntBuildListener.java
示例5: run
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
@Override
public void run() {
if (sketchDataDirectory == null) {
return;
}
VirtualFile projectResourceDirectory = VfsUtil.findRelativeFile(project.getBaseDir(), "src", "main", "resources");
if (projectResourceDirectory == null) {
throw new IllegalStateException("Cannot find directory 'src/main/resources' into which sketch resources are to be copied. Sketch resources cannot be imported.");
}
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
for (VirtualFile resourceEntry : sketchDataDirectory.getChildren()) {
try {
logger.debug("Copying '" + resourceEntry.getPath() + "' into sketch project.");
resourceEntry.copy(this, projectResourceDirectory, resourceEntry.getName());
logger.debug("Copy of '" + resourceEntry.getPath() + "' succeeded.");
} catch (IOException io) {
// @TODO This failure is silent. Spawn a notification to inform the user.
logger.error("Whilst importing sketch resources into project, encountered an exception.", io);
}
}
}
});
}
示例6: initComponent
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
@Override
public void initComponent() {
settings = GravProjectSettings.getInstance(project);
if (settings != null) {
if (project != null && VfsUtil.findRelativeFile(project.getBaseDir(), "src") == null) {
settings.withSrcDirectory = false;
} else {
settings.withSrcDirectory = true;
}
}
}
示例7: checkProject
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
public static boolean checkProject(Project project) {
if (VfsUtil.findRelativeFile(project.getBaseDir(), "src", "user") != null
&& VfsUtil.findRelativeFile(project.getBaseDir(), "src", "bin") != null
&& VfsUtil.findRelativeFile(project.getBaseDir(), "src", "vendor") != null
) {
return true;
}
return false;
}
示例8: getDefaultTheme
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
/**
* Return the current theme which is set in the system/config/system.yaml file
*
* @param project the project
* @return theme name or null
*/
public static String getDefaultTheme(Project project) {
VirtualFile vfile = VfsUtil.findRelativeFile(project.getBaseDir(), "system", "config", "system.yaml");
if (vfile == null) return null;
PsiFile psiFile = PsiManager.getInstance(project).findFile(vfile);
if (psiFile == null) return null;
YAMLKeyValue yamlKeyValue = GravYAMLUtils.getKeyValue((YAMLFile) psiFile, Arrays.asList(new String[]{"pages", "theme"}));
if (yamlKeyValue == null) return null;
return yamlKeyValue.getValueText();
}
示例9: findCandidates
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
private void findCandidates(@NotNull List<? extends FilePatch> list,
@NotNull final PatchBaseDirectoryDetector directoryDetector,
@NotNull List<PatchAndVariants> candidates, @NotNull List<FilePatch> newOrWithoutMatches) {
for (final FilePatch patch : list) {
final String fileName = patch.getBeforeFileName();
if (patch.isNewFile() || (patch.getBeforeName() == null)) {
newOrWithoutMatches.add(patch);
continue;
}
final Collection<VirtualFile> files = findFilesFromIndex(directoryDetector, fileName);
// for directories outside the project scope but under version control
if (patch.getBeforeName() != null && patch.getBeforeName().startsWith("..")) {
final VirtualFile relativeFile = VfsUtil.findRelativeFile(myBaseDir, patch.getBeforeName().replace('\\', '/').split("/"));
if (relativeFile != null) {
files.add(relativeFile);
}
}
if (files.isEmpty()) {
newOrWithoutMatches.add(patch);
}
else {
//files order is not defined, so get the best variant depends on it, too
final List<AbstractFilePatchInProgress> variants =
ObjectsConvertor.convert(files, new Convertor<VirtualFile, AbstractFilePatchInProgress>() {
@Override
public AbstractFilePatchInProgress convert(VirtualFile o) {
return processMatch(patch, o);
}
}, ObjectsConvertor.NOT_NULL);
if (variants.isEmpty()) {
newOrWithoutMatches.add(patch); // just to be sure
}
else {
candidates.add(new PatchAndVariants(variants));
}
}
}
}
示例10: createOpenFileHyperlink
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
protected HyperlinkInfo createOpenFileHyperlink(String fileName, final int line, int column) {
if ((fileName == null || fileName.length() == 0)) {
if (myBase != null) {
fileName = myBase.getPresentableUrl();
} else {
return null;
}
}
fileName = fileName.replace(File.separatorChar, '/');
VirtualFile file;
// try to interpret the filename as URL
if (URLUtil.containsScheme(fileName)) {
try {
file = VfsUtil.findFileByURL(new URL(fileName));
} catch (MalformedURLException e) {
file = VirtualFileManager.getInstance().findFileByUrl(VfsUtil.pathToUrl(fileName));
}
} else {
file = VfsUtil.findRelativeFile(fileName, myBase);
}
if (file == null) {
//noinspection ConstantConditions
return null;
}
final FileType fileType = file.getFileType();
if (fileType != null && column > 0) {
final Document document = FileDocumentManager.getInstance().getDocument(file);
final int start = document.getLineStartOffset(line);
final int max = document.getLineEndOffset(line);
final int tabSize = CodeStyleSettingsManager.getInstance(myProject).getCurrentSettings().getTabSize(fileType);
column = EditorUtil.calcColumnNumber(null, document.getCharsSequence(), start, Math.min(start + column, max), tabSize);
}
return new OpenFileHyperlinkInfo(myProject, file, line, column);
}
示例11: resolveFile
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
@Nullable
public static PsiFile resolveFile(String name, PsiFile baseFile) {
if (baseFile == null) return null;
final VirtualFile virtualFile = VfsUtil.findRelativeFile(name, baseFile.getVirtualFile());
if (virtualFile != null) {
final PsiFile file = baseFile.getManager().findFile(virtualFile);
if (file != baseFile && file instanceof XmlFile) {
return file;
}
}
return null;
}
示例12: isValidGravSDK
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
public static boolean isValidGravSDK(VirtualFile root) {
return root.findChild("user") != null &&
VfsUtil.findRelativeFile(root, "system") != null &&
root.findFileByRelativePath("bin") != null;
}
示例13: isNeosProject
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
public static boolean isNeosProject(Project project) {
return (VfsUtil.findRelativeFile(project.getBaseDir(), "Packages") != null
&& VfsUtil.findRelativeFile(project.getBaseDir(), "Configuration") != null
&& (VfsUtil.findRelativeFile(project.getBaseDir(), "Packages", "Application", "TYPO3.Neos") != null
|| VfsUtil.findRelativeFile(project.getBaseDir(), "Packages", "Application", "Neos.Neos") != null));
}
示例14: addAttachArtifactDependency
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
private void addAttachArtifactDependency(@NotNull Element buildHelperCfg,
@NotNull DependencyScope scope,
@NotNull MavenProject mavenProject,
@NotNull MavenArtifact artifact) {
Library.ModifiableModel libraryModel = null;
for (Element artifactsElement : buildHelperCfg.getChildren("artifacts")) {
for (Element artifactElement : artifactsElement.getChildren("artifact")) {
String typeString = artifactElement.getChildTextTrim("type");
if (typeString != null && !typeString.equals("jar")) continue;
OrderRootType rootType = OrderRootType.CLASSES;
String classifier = artifactElement.getChildTextTrim("classifier");
if ("sources".equals(classifier)) {
rootType = OrderRootType.SOURCES;
}
else if ("javadoc".equals(classifier)) {
rootType = JavadocOrderRootType.getInstance();
}
String filePath = artifactElement.getChildTextTrim("file");
if (StringUtil.isEmpty(filePath)) continue;
VirtualFile file = VfsUtil.findRelativeFile(filePath, mavenProject.getDirectoryFile());
if (file == null) continue;
file = JarFileSystem.getInstance().getJarRootForLocalFile(file);
if (file == null) continue;
if (libraryModel == null) {
String libraryName = getAttachedJarsLibName(artifact);
Library library = myModifiableModelsProvider.getLibraryByName(libraryName);
if (library == null) {
library = myModifiableModelsProvider.createLibrary(libraryName);
}
libraryModel = myModifiableModelsProvider.getModifiableLibraryModel(library);
LibraryOrderEntry entry = myRootModelAdapter.getRootModel().addLibraryEntry(library);
entry.setScope(scope);
}
libraryModel.addRoot(file, rootType);
}
}
}
示例15: hasFrameworkStructure
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
@Override
public boolean hasFrameworkStructure(@NotNull Module module) {
return framework.hasFrameworkStructure(module) &&
VfsUtil.findRelativeFile(framework.findAppRoot(module), "application.properties") != null;
}