use of com.intellij.lang.properties.PropertiesFileProcessor in project intellij-community by JetBrains.
the class I18nUtil method defaultSuggestPropertiesFiles.
public static List<String> defaultSuggestPropertiesFiles(Project project) {
final List<String> paths = new ArrayList<>();
final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
PropertiesReferenceManager.getInstance(project).processAllPropertiesFiles(new PropertiesFileProcessor() {
@Override
public boolean process(String baseName, PropertiesFile propertiesFile) {
if (propertiesFile instanceof XmlPropertiesFile) {
return true;
}
VirtualFile virtualFile = propertiesFile.getVirtualFile();
if (projectFileIndex.isInContent(virtualFile)) {
String path = FileUtil.toSystemDependentName(virtualFile.getPath());
paths.add(path);
}
return true;
}
});
return paths;
}
use of com.intellij.lang.properties.PropertiesFileProcessor in project intellij-community by JetBrains.
the class PropertiesPsiCompletionUtil method getPropertiesKeys.
static Set<Object> getPropertiesKeys(final PropertyReferenceBase propertyReference) {
final Set<Object> variants = new THashSet<>(new TObjectHashingStrategy<Object>() {
public int computeHashCode(final Object object) {
if (object instanceof IProperty) {
final String key = ((IProperty) object).getKey();
return key == null ? 0 : key.hashCode();
} else {
return 0;
}
}
public boolean equals(final Object o1, final Object o2) {
return o1 instanceof IProperty && o2 instanceof IProperty && Comparing.equal(((IProperty) o1).getKey(), ((IProperty) o2).getKey(), true);
}
});
List<PropertiesFile> propertiesFileList = propertyReference.getPropertiesFiles();
if (propertiesFileList == null) {
PropertiesReferenceManager.getInstance(propertyReference.getElement().getProject()).processAllPropertiesFiles(new PropertiesFileProcessor() {
@Override
public boolean process(String baseName, PropertiesFile propertiesFile) {
addVariantsFromFile(propertyReference, propertiesFile, variants);
return true;
}
});
} else {
for (PropertiesFile propFile : propertiesFileList) {
addVariantsFromFile(propertyReference, propFile, variants);
}
}
return variants;
}
Aggregations