use of com.intellij.lang.properties.IProperty in project intellij-community by JetBrains.
the class ResourceBundleFileStructureViewElement method getPropertiesMap.
public static MultiMap<String, IProperty> getPropertiesMap(ResourceBundle resourceBundle, boolean onlyIncomplete) {
List<PropertiesFile> propertiesFiles = resourceBundle.getPropertiesFiles();
final MultiMap<String, IProperty> propertyNames;
if (onlyIncomplete) {
propertyNames = getChildrenIdShowOnlyIncomplete(resourceBundle);
} else {
propertyNames = MultiMap.createLinked();
for (PropertiesFile propertiesFile : propertiesFiles) {
List<IProperty> properties = propertiesFile.getProperties();
for (IProperty property : properties) {
String name = property.getKey();
propertyNames.putValue(name, property);
}
}
}
return propertyNames;
}
use of com.intellij.lang.properties.IProperty in project intellij-community by JetBrains.
the class PropertiesPrefixGroup method getChildren.
@NotNull
public Collection<TreeElement> getChildren() {
Collection<TreeElement> result = new ArrayList<>();
List<String> prefixWords = StringUtil.split(myPrefix, mySeparator);
for (TreeElement treeElement : myProperties) {
if (!(treeElement instanceof StructureViewTreeElement)) {
continue;
}
Object value = ((StructureViewTreeElement) treeElement).getValue();
if (!(value instanceof IProperty)) {
continue;
}
final String key = ((IProperty) value).getUnescapedKey();
if (key == null) {
continue;
}
boolean startsWith;
if (!key.equals(myPrefix)) {
List<String> keyWords = StringUtil.split(key, mySeparator);
startsWith = prefixWords.size() < keyWords.size();
if (startsWith) {
for (int i = 0; i < prefixWords.size(); i++) {
String prefixWord = prefixWords.get(i);
String keyWord = keyWords.get(i);
if (!Comparing.strEqual(keyWord, prefixWord)) {
startsWith = false;
break;
}
}
}
} else {
startsWith = true;
}
if (startsWith) {
result.add(treeElement);
String presentableName = key.substring(myPrefix.length());
presentableName = StringUtil.trimStart(presentableName, mySeparator);
if (treeElement instanceof PropertiesStructureViewElement) {
((PropertiesStructureViewElement) treeElement).setPresentableName(presentableName);
}
if (treeElement instanceof ResourceBundlePropertyStructureViewElement) {
((ResourceBundlePropertyStructureViewElement) treeElement).setPresentableName(presentableName);
}
}
}
return result;
}
use of com.intellij.lang.properties.IProperty in project intellij-community by JetBrains.
the class XmlPropertiesFileImpl method ensurePropertiesLoaded.
private void ensurePropertiesLoaded() {
while (myFileModificationStamp != myFile.getModificationStamp() || myPropertiesMap == null) {
myFileModificationStamp = myFile.getModificationStamp();
MostlySingularMultiMap<String, IProperty> propertiesMap = new MostlySingularMultiMap<>();
XmlTag rootTag = myFile.getRootTag();
final List<IProperty> propertiesOrder = new ArrayList<>();
if (rootTag != null) {
XmlTag[] entries = rootTag.findSubTags(ENTRY_TAG_NAME);
for (XmlTag entry : entries) {
XmlProperty property = new XmlProperty(entry, this);
propertiesOrder.add(property);
final String key = property.getKey();
if (key != null) {
propertiesMap.add(key, property);
}
}
}
myAlphaSorted = PropertiesImplUtil.isAlphaSorted(propertiesOrder);
myProperties = propertiesOrder;
myPropertiesMap = propertiesMap;
}
}
use of com.intellij.lang.properties.IProperty in project intellij-community by JetBrains.
the class ResourceBundleKeyReference method resolve.
public PsiElement resolve() {
final Project project = myFile.getProject();
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
final VirtualFile formVirtualFile = myFile.getVirtualFile();
if (formVirtualFile == null) {
return null;
}
final Module module = fileIndex.getModuleForFile(formVirtualFile);
if (module == null) {
return null;
}
final PropertiesFile propertiesFile = PropertiesUtilBase.getPropertiesFile(myBundleName, module, null);
if (propertiesFile == null) {
return null;
}
IProperty property = propertiesFile.findPropertyByKey(getRangeText());
return property == null ? null : property.getPsiElement();
}
use of com.intellij.lang.properties.IProperty in project intellij-community by JetBrains.
the class FormReferencesSearcher method execute.
@Override
public boolean execute(@NotNull final ReferencesSearch.SearchParameters p, @NotNull final Processor<PsiReference> consumer) {
SearchScope userScope = p.getScopeDeterminedByUser();
if (!scopeCanContainForms(userScope))
return true;
final PsiElement refElement = p.getElementToSearch();
final PsiFile psiFile = ApplicationManager.getApplication().runReadAction(new Computable<PsiFile>() {
@Override
public PsiFile compute() {
if (!refElement.isValid())
return null;
return refElement.getContainingFile();
}
});
if (psiFile == null)
return true;
final VirtualFile virtualFile = psiFile.getVirtualFile();
if (virtualFile == null)
return true;
final GlobalSearchScope[] scope = new GlobalSearchScope[1];
Project project = ApplicationManager.getApplication().runReadAction(new Computable<Project>() {
@Override
public Project compute() {
Project project = psiFile.getProject();
Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(virtualFile);
if (module != null) {
scope[0] = GlobalSearchScope.moduleWithDependenciesScope(module);
}
return project;
}
});
if (scope[0] == null) {
return true;
}
final LocalSearchScope filterScope = userScope instanceof LocalSearchScope ? (LocalSearchScope) userScope : null;
PsiManager psiManager = PsiManager.getInstance(project);
if (refElement instanceof PsiPackage) {
//no need to do anything
//if (!UIFormUtil.processReferencesInUIForms(consumer, (PsiPackage)refElement, scope)) return false;
} else if (refElement instanceof PsiClass) {
if (!processReferencesInUIForms(consumer, psiManager, (PsiClass) refElement, scope[0], filterScope))
return false;
} else if (refElement instanceof PsiEnumConstant) {
if (!processEnumReferencesInUIForms(consumer, psiManager, (PsiEnumConstant) refElement, scope[0], filterScope))
return false;
} else if (refElement instanceof PsiField) {
if (!processReferencesInUIForms(consumer, psiManager, (PsiField) refElement, scope[0], filterScope))
return false;
} else if (refElement instanceof IProperty) {
if (!processReferencesInUIForms(consumer, psiManager, (Property) refElement, scope[0], filterScope))
return false;
} else if (refElement instanceof PropertiesFile) {
if (!processReferencesInUIForms(consumer, psiManager, (PropertiesFile) refElement, scope[0], filterScope))
return false;
}
return true;
}
Aggregations