use of com.intellij.lang.properties.psi.PropertiesFile in project intellij-community by JetBrains.
the class I18nUtil method createProperty.
public static void createProperty(final Project project, final Collection<PropertiesFile> propertiesFiles, final String key, final String value) throws IncorrectOperationException {
for (PropertiesFile file : propertiesFiles) {
PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
documentManager.commitDocument(documentManager.getDocument(file.getContainingFile()));
IProperty existingProperty = file.findPropertyByKey(key);
if (existingProperty == null) {
file.addProperty(key, value);
}
}
}
use of com.intellij.lang.properties.psi.PropertiesFile in project intellij-community by JetBrains.
the class PropertyReference method getQuickFixes.
public LocalQuickFix[] getQuickFixes() {
List<PropertiesFile> propertiesFiles = retrievePropertyFilesByBundleName(myBundleName, getElement());
LocalQuickFix fix = PropertiesQuickFixFactory.getInstance().createCreatePropertyFix(myElement, myKey, propertiesFiles);
return new LocalQuickFix[] { fix };
}
use of com.intellij.lang.properties.psi.PropertiesFile in project intellij-community by JetBrains.
the class PropertyReferenceBase method multiResolve.
@NotNull
public ResolveResult[] multiResolve(final boolean incompleteCode) {
final String key = getKeyText();
List<IProperty> properties;
final List<PropertiesFile> propertiesFiles = getPropertiesFiles();
if (propertiesFiles == null) {
properties = PropertiesImplUtil.findPropertiesByKey(getElement().getProject(), key);
} else {
properties = new ArrayList<>();
for (PropertiesFile propertiesFile : propertiesFiles) {
properties.addAll(propertiesFile.findPropertiesByKey(key));
}
}
// put default properties file first
ContainerUtil.quickSort(properties, (o1, o2) -> {
String name1 = o1.getPropertiesFile().getName();
String name2 = o2.getPropertiesFile().getName();
return Comparing.compare(name1, name2);
});
return getResolveResults(properties);
}
use of com.intellij.lang.properties.psi.PropertiesFile in project intellij-community by JetBrains.
the class PropertiesUtil method findAllProperties.
/**
* @deprecated use PropertiesUtil.findAllProperties(ResourceBundle resourceBundle, String key)
*/
@NotNull
@Deprecated
public static List<IProperty> findAllProperties(Project project, @NotNull ResourceBundle resourceBundle, String key) {
List<IProperty> result = new SmartList<>();
List<PropertiesFile> propertiesFiles = resourceBundle.getPropertiesFiles();
for (PropertiesFile propertiesFile : propertiesFiles) {
result.addAll(propertiesFile.findPropertiesByKey(key));
}
return result;
}
use of com.intellij.lang.properties.psi.PropertiesFile in project intellij-community by JetBrains.
the class MvcModuleStructureUtil method findApplicationProperties.
@Nullable
public static PropertiesFile findApplicationProperties(@NotNull Module module, MvcFramework framework) {
VirtualFile root = framework.findAppRoot(module);
if (root == null)
return null;
VirtualFile appChild = root.findChild(APPLICATION_PROPERTIES);
if (appChild == null || !appChild.isValid())
return null;
PsiManager manager = PsiManager.getInstance(module.getProject());
PsiFile psiFile = manager.findFile(appChild);
if (psiFile instanceof PropertiesFile) {
return (PropertiesFile) psiFile;
}
return null;
}
Aggregations