本文整理汇总了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;
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}