当前位置: 首页>>代码示例>>Java>>正文


Java PsiFileSystemItem.getVirtualFile方法代码示例

本文整理汇总了Java中com.intellij.psi.PsiFileSystemItem.getVirtualFile方法的典型用法代码示例。如果您正苦于以下问题:Java PsiFileSystemItem.getVirtualFile方法的具体用法?Java PsiFileSystemItem.getVirtualFile怎么用?Java PsiFileSystemItem.getVirtualFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.PsiFileSystemItem的用法示例。


在下文中一共展示了PsiFileSystemItem.getVirtualFile方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPathResolveRoot

import com.intellij.psi.PsiFileSystemItem; //导入方法依赖的package包/类
protected String getPathResolveRoot(ConvertContext context, AntDomProject antProject) {
  final AntDomAnt antElement = context.getInvocationElement().getParentOfType(AntDomAnt.class, false);
  if (antElement != null) {
    PsiFileSystemItem dir = antElement.getAntFileDir().getValue();
    if (dir == null) {
      if (antElement.isInheritAllProperties().getValue()) {
        dir = antProject.getProjectBasedir();
      }
    }
    if (dir != null) {
      final VirtualFile vFile = dir.getVirtualFile();
      if (vFile != null) {
        return vFile.getPath();
      }
    }
  }
  return super.getPathResolveRoot(context, antProject);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:AntDomAnt.java

示例2: calcPropertyValue

import com.intellij.psi.PsiFileSystemItem; //导入方法依赖的package包/类
@Nullable
protected final String calcPropertyValue(String propertyName) {
  final PsiFileSystemItem fsItem = getFile().getValue();
  if (fsItem != null) {
    final PsiFileSystemItem parent = fsItem.getParent();
    if (parent != null) {
      final VirtualFile vFile = parent.getVirtualFile();
      if (vFile != null) {
        return FileUtil.toSystemDependentName(vFile.getPath());
      }
    }
  }
  // according to the doc, defaulting to project's current dir
  final String projectBasedirPath = getContextAntProject().getProjectBasedirPath();
  if (projectBasedirPath == null) {
    return null;
  }
  return FileUtil.toSystemDependentName(projectBasedirPath);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:AntDomDirname.java

示例3: showCoverage

import com.intellij.psi.PsiFileSystemItem; //导入方法依赖的package包/类
private boolean showCoverage(PsiFileSystemItem psiFile) {
  if (coverageFilePaths.isEmpty()) {
    return false;
  }
  VirtualFile vf = psiFile.getVirtualFile();
  if (vf == null) {
    return false;
  }
  String filePath = normalizeFilePath(vf.getPath());
  for (String path : coverageFilePaths) {
    if (filePath.startsWith(path)) {
      return true;
    }
  }
  return false;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:17,代码来源:BlazeCoverageAnnotator.java

示例4: findPsiClass

import com.intellij.psi.PsiFileSystemItem; //导入方法依赖的package包/类
/**
 * Find the Manifold PisClass corresponding with a resource file.
 *
 * @param fileElem a psiFile, normally this should be a resource file
 *
 * @return The corresponding Manifold PsiClass or null
 */
public static PsiClass findPsiClass( PsiFileSystemItem fileElem )
{
  Project project = fileElem.getProject();
  ManProject manProject = ManProject.manProjectFrom( project );
  VirtualFile virtualFile = fileElem.getVirtualFile();
  if( virtualFile == null )
  {
    return null;
  }
  for( ManModule module : manProject.getModules() )
  {
    IjFile file = FileUtil.toIFile( manProject, virtualFile );
    Set<ITypeManifold> set = module.findTypeManifoldsFor( file );
    if( set != null )
    {
      for( ITypeManifold tf : set )
      {
        if( tf.getProducerKind() == ITypeManifold.ProducerKind.Primary )
        {
          String[] fqns = tf.getTypesForFile( file );
          for( String fqn : fqns )
          {
            PsiClass psiClass = ManifoldPsiClassCache.instance().getPsiClass( GlobalSearchScope.moduleWithDependenciesAndLibrariesScope( module.getIjModule() ), module, fqn );
            if( psiClass != null )
            {
              return psiClass;
            }
          }
        }
      }
    }
  }
  return null;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:42,代码来源:ResourceToManifoldUtil.java

示例5: getPreviewComponent

import com.intellij.psi.PsiFileSystemItem; //导入方法依赖的package包/类
public static JComponent getPreviewComponent(@Nullable final PsiElement parent) {
  if (parent == null) {
    return null;
  }
  final PsiReference[] references = parent.getReferences();
  for (final PsiReference reference : references) {
    final PsiElement fileItem = reference.resolve();
    if (fileItem instanceof PsiFileSystemItem) {
      final PsiFileSystemItem item = (PsiFileSystemItem)fileItem;
      if (!item.isDirectory()) {
        final VirtualFile file = item.getVirtualFile();
        if (file != null && supportedExtensions.contains(file.getExtension())) {
          try {
            refresh(file);
            SoftReference<BufferedImage> imageRef = file.getUserData(BUFFERED_IMAGE_REF_KEY);
            final BufferedImage image = SoftReference.dereference(imageRef);
            if (image != null) {
              return new ImagePreviewComponent(image, file.getLength());
            }
          }
          catch (IOException ignored) {
            // nothing
          }
        }
      }
    }
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:ImagePreviewComponent.java

示例6: createSelectInTarget

import com.intellij.psi.PsiFileSystemItem; //导入方法依赖的package包/类
@Override
public SelectInTarget createSelectInTarget() {
  return new ProjectViewSelectInTarget(myProject) {

    @Override
    protected boolean canSelect(PsiFileSystemItem file) {
      if (!super.canSelect(file)) return false;
      final VirtualFile vFile = file.getVirtualFile();
      if (vFile == null || !vFile.isValid()) return false;
      return ScratchFileService.getInstance().getRootType(vFile) != null;
    }

    @Override
    protected boolean canWorkWithCustomObjects() {
      return false;
    }

    @Override
    public String toString() {
      return getTitle();
    }

    @Override
    public String getMinorViewId() {
      return getId();
    }

    @Override
    public float getWeight() {
      return ScratchProjectViewPane.this.getWeight();
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:ScratchProjectViewPane.java

示例7: updateImpl

import com.intellij.psi.PsiFileSystemItem; //导入方法依赖的package包/类
@Override
protected void updateImpl(PresentationData data) {
  PsiFileSystemItem value = getValue();
  VirtualFile virtualFile = value == null ? null : value.getVirtualFile();
  if (virtualFile != null && virtualFile.isValid()) {
    data.setIcon(value.getIcon(0));
    data.setPresentableText(ObjectUtils.chooseNotNull(myRootType.substituteName(value.getProject(), virtualFile), virtualFile.getName()));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ScratchProjectViewPane.java

示例8: setupConfigurationFromContext

import com.intellij.psi.PsiFileSystemItem; //导入方法依赖的package包/类
@Override
protected boolean setupConfigurationFromContext(AbstractPythonTestRunConfiguration configuration,
                                                ConfigurationContext context,
                                                Ref<PsiElement> sourceElement) {
  final PsiElement element = sourceElement.get();
  final Module module = ModuleUtilCore.findModuleForPsiElement(element);
  if (!(configuration instanceof PyTestRunConfiguration)) return false;
  if (module == null) return false;
  if (!(TestRunnerService.getInstance(module).getProjectConfiguration().equals(
         PythonTestConfigurationsModel.PY_TEST_NAME))) return false;

  final PsiFileSystemItem file = element instanceof PsiDirectory ? (PsiDirectory)element : element.getContainingFile();
  if (file == null) return false;
  final VirtualFile virtualFile = file.getVirtualFile();
  if (virtualFile == null) return false;

  if (file instanceof PyFile || file instanceof PsiDirectory) {
    final List<PyStatement> testCases = PyTestUtil.getPyTestCasesFromFile(file);
    if (testCases.isEmpty()) return false;
  } else return false;

  final Sdk sdk = PythonSdkType.findPythonSdk(context.getModule());
  if (sdk == null) return false;

  configuration.setUseModuleSdk(true);
  configuration.setModule(ModuleUtilCore.findModuleForPsiElement(element));
  ((PyTestRunConfiguration)configuration).setTestToRun(virtualFile.getPath());

  final String keywords = getKeywords(element, sdk);
  if (keywords != null) {
    ((PyTestRunConfiguration)configuration).useKeyword(true);
    ((PyTestRunConfiguration)configuration).setKeywords(keywords);
    configuration.setName("py.test in " + keywords);
  }
  else
    configuration.setName("py.test in " + file.getName());
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:PyTestConfigurationProducer.java

示例9: isConfigurationFromContext

import com.intellij.psi.PsiFileSystemItem; //导入方法依赖的package包/类
@Override
public boolean isConfigurationFromContext(AbstractPythonTestRunConfiguration configuration, ConfigurationContext context) {
  final Location location = context.getLocation();
  if (location == null) return false;
  if (!(configuration instanceof PyTestRunConfiguration)) return false;
  final PsiElement element = location.getPsiElement();

  final PsiFileSystemItem file = element instanceof PsiDirectory ? (PsiDirectory)element : element.getContainingFile();
  if (file == null) return false;
  final VirtualFile virtualFile = file.getVirtualFile();
  if (virtualFile == null) return false;

  if (file instanceof PyFile || file instanceof PsiDirectory) {
    final List<PyStatement> testCases = PyTestUtil.getPyTestCasesFromFile(file);
    if (testCases.isEmpty()) return false;
  } else return false;

  final Sdk sdk = PythonSdkType.findPythonSdk(context.getModule());
  if (sdk == null) return false;
  final String keywords = getKeywords(element, sdk);
  final String scriptName = ((PyTestRunConfiguration)configuration).getTestToRun();
  final String workingDirectory = configuration.getWorkingDirectory();
  final String path = virtualFile.getPath();
  final boolean isTestFileEquals = scriptName.equals(path) ||
                                   path.equals(new File(workingDirectory, scriptName).getAbsolutePath());

  final String configurationKeywords = ((PyTestRunConfiguration)configuration).getKeywords();
  return isTestFileEquals && (configurationKeywords.equals(keywords) ||
                              StringUtil.isEmptyOrSpaces(((PyTestRunConfiguration)configuration).getKeywords()) && keywords == null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:PyTestConfigurationProducer.java

示例10: getModule

import com.intellij.psi.PsiFileSystemItem; //导入方法依赖的package包/类
@Nullable
public static Module getModule(@NotNull PsiFileSystemItem item) {
    Project project = item.getProject();
    VirtualFile file = item.getVirtualFile();
    return getModule(project, file);
}
 
开发者ID:apsun,项目名称:XposedPlugin,代码行数:7,代码来源:IdeaUtils.java

示例11: computeDefaultContexts

import com.intellij.psi.PsiFileSystemItem; //导入方法依赖的package包/类
@NotNull
@Override
public Collection<PsiFileSystemItem> computeDefaultContexts() {
  final AntDomElement element = myValue.getParentOfType(AntDomElement.class, false);
  final AntDomProject containingProject = element != null? element.getAntProject() : null;

  if (containingProject != null) {
    if (isAbsolutePathReference()) {
      return toFileSystemItems(ManagingFS.getInstance().getLocalRoots());
    }
    else {
      VirtualFile root = null;

      if (element instanceof AntDomAnt) {
        final PsiFileSystemItem dirValue = ((AntDomAnt)element).getAntFileDir().getValue();
        if (dirValue instanceof PsiDirectory) {
          root = dirValue.getVirtualFile();
        }
      }

      if (root == null) {
        final String basedir;
        if (element instanceof AntDomIncludingDirective) {
          basedir = containingProject.getContainingFileDir();
        }
        else {
          basedir = containingProject.getContextAntProject().getProjectBasedirPath();
        }
        if (basedir != null) {
          root = LocalFileSystem.getInstance().findFileByPath(basedir);
        }
      }

      if (root != null) {
        return toFileSystemItems(root);
      }
    }
  }

  return super.computeDefaultContexts();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:42,代码来源:AntDomFileReferenceSet.java


注:本文中的com.intellij.psi.PsiFileSystemItem.getVirtualFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。