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


Java PropertiesFile.getVirtualFile方法代码示例

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


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

示例1: getParent

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
/**
 * messages_en.properties is a parent of the messages_en_US.properties
 */
@Nullable
public static PropertiesFile getParent(PropertiesFile file, List<PropertiesFile> candidates) {
  VirtualFile virtualFile = file.getVirtualFile();
  if (virtualFile == null) return null;
  String name = virtualFile.getNameWithoutExtension();
  String[] parts = name.split("_");
  if (parts.length == 1) return null;
  List<String> partsList = Arrays.asList(parts);
  for (int i=parts.length-1; i>=1;i--) {
    String parentName = StringUtil.join(partsList.subList(0, i), "_") + "." + virtualFile.getExtension();
    for (PropertiesFile candidate : candidates) {
      if (parentName.equals(candidate.getName())) return candidate;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PropertiesUtil.java

示例2: suggestPropertiesFiles

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
protected List<String> suggestPropertiesFiles() {
  if (myCustomization.propertiesFiles != null && !myCustomization.propertiesFiles.isEmpty()) {
    ArrayList<String> list = new ArrayList<String>();
    for (PropertiesFile propertiesFile : myCustomization.propertiesFiles) {
      final VirtualFile virtualFile = propertiesFile.getVirtualFile();
      if (virtualFile != null) {
        list.add(virtualFile.getPath());
      }
    }
    return list;
  }
  return defaultSuggestPropertiesFiles();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:I18nizeQuickFixDialog.java

示例3: isValid

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
@Override
public boolean isValid() {
  if (myResourceBundle instanceof ResourceBundleImpl && !((ResourceBundleImpl)myResourceBundle).isValid()) {
    return false;
  }
  for (PropertiesFile propertiesFile : myResourceBundle.getPropertiesFiles()) {
    final VirtualFile virtualFile = propertiesFile.getVirtualFile();
    if (virtualFile == null || !virtualFile.isValid()) {
      return false;
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:ResourceBundleAsVirtualFile.java

示例4: elementContainsFile

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
public boolean elementContainsFile(final Object element, final VirtualFile vFile) {
  if (element instanceof ResourceBundle) {
    ResourceBundle bundle = (ResourceBundle)element;
    final List<PropertiesFile> propertiesFiles = bundle.getPropertiesFiles();
    for (PropertiesFile file : propertiesFiles) {
      final VirtualFile virtualFile = file.getVirtualFile();
      if (virtualFile == null) continue;
      if (vFile.getPath().equals(virtualFile.getPath())) {
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:ResourcesFavoriteNodeProvider.java

示例5: getResourceBundle

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
@Nullable
public static ResourceBundle getResourceBundle(@NotNull final PropertiesFile representative) {
  final PsiFile containingFile = representative.getContainingFile();
  if (!containingFile.isValid()) {
    return EmptyResourceBundle.getInstance();
  }
  final ResourceBundleManager manager = ResourceBundleManager.getInstance(representative.getProject());
  final CustomResourceBundle customResourceBundle =
    manager.getCustomResourceBundle(representative);
  if (customResourceBundle != null) {
    return customResourceBundle;
  }

  final VirtualFile virtualFile = representative.getVirtualFile();
  if (virtualFile == null) {
    return EmptyResourceBundle.getInstance();
  }
  if (manager.isDefaultDissociated(virtualFile)) {
    return new ResourceBundleImpl(representative);
  }


  final String baseName = manager.getBaseName(containingFile);
  final PsiDirectory directory = ApplicationManager.getApplication().runReadAction(new Computable<PsiDirectory>() {
    @Nullable
    public PsiDirectory compute() {
      return containingFile.getContainingDirectory();
    }});
  if (directory == null) return EmptyResourceBundle.getInstance();
  final ResourceBundle bundle = getResourceBundle(baseName, directory);
  return bundle == null ? new ResourceBundleImpl(representative) : bundle;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:PropertiesImplUtil.java

示例6: getCustomResourceBundle

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
@Nullable
public CustomResourceBundle getCustomResourceBundle(final @NotNull PropertiesFile file) {
  final VirtualFile virtualFile = file.getVirtualFile();
  if (virtualFile == null) {
    return null;
  }
  final CustomResourceBundleState state = getCustomResourceBundleState(virtualFile);
  return state == null ? null : CustomResourceBundle.fromState(state, file.getProject());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ResourceBundleManager.java


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