use of com.intellij.lang.properties.psi.PropertiesFile in project intellij-community by JetBrains.
the class IgnoredPropertiesFilesSuffixesTest method testPropertyIsComplete2.
public void testPropertyIsComplete2() {
myFixture.addFileToProject("p.properties", "key=value");
myFixture.addFileToProject("p_en.properties", "key=value eng");
final PsiFile file = myFixture.addFileToProject("p_ru.properties", "key=value rus");
final PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile(file);
assertNotNull(propertiesFile);
final ResourceBundle resourceBundle = propertiesFile.getResourceBundle();
assertSize(3, resourceBundle.getPropertiesFiles());
final IncompletePropertyInspection incompletePropertyInspection = IncompletePropertyInspection.getInstance(propertiesFile.getContainingFile());
assertTrue(incompletePropertyInspection.isPropertyComplete("key", resourceBundle));
}
use of com.intellij.lang.properties.psi.PropertiesFile in project intellij-community by JetBrains.
the class IgnoredPropertiesFilesSuffixesTest method testPropertyIsIncomplete.
public void testPropertyIsIncomplete() {
myFixture.addFileToProject("p.properties", "key=value");
myFixture.addFileToProject("p_en.properties", "key=value eng");
myFixture.addFileToProject("p_fr.properties", "");
final PsiFile file = myFixture.addFileToProject("p_ru.properties", "");
final PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile(file);
assertNotNull(propertiesFile);
final ResourceBundle resourceBundle = propertiesFile.getResourceBundle();
assertSize(4, resourceBundle.getPropertiesFiles());
final IncompletePropertyInspection incompletePropertyInspection = IncompletePropertyInspection.getInstance(propertiesFile.getContainingFile());
incompletePropertyInspection.addSuffixes(Collections.singleton("ru"));
assertFalse(incompletePropertyInspection.isPropertyComplete("key", resourceBundle));
}
use of com.intellij.lang.properties.psi.PropertiesFile in project intellij-community by JetBrains.
the class PropertiesFileTest method testAddPropertyAfter.
public void testAddPropertyAfter() throws IncorrectOperationException {
final PropertiesFile propertiesFile = PropertiesElementFactory.createPropertiesFile(getProject(), "a=b\nc=d\ne=f");
final Property c = (Property) propertiesFile.findPropertyByKey("c");
WriteCommandAction.runWriteCommandAction(null, () -> {
propertiesFile.addPropertyAfter(myPropertyToAdd, c);
});
assertEquals("a=b\nc=d\nkkk=vvv\ne=f", propertiesFile.getText());
}
use of com.intellij.lang.properties.psi.PropertiesFile in project intellij-community by JetBrains.
the class ResourceBundleTest method testDefaultPropertyFile.
public void testDefaultPropertyFile() {
final PsiFile rawDefault = myFixture.addFileToProject("p.properties", "");
myFixture.addFileToProject("p_en.properties", "");
final PropertiesFile defaultFile = PropertiesImplUtil.getPropertiesFile(rawDefault);
assertNotNull(defaultFile);
final PropertiesFile file = defaultFile.getResourceBundle().getDefaultPropertiesFile();
assertTrue(file.getContainingFile().isEquivalentTo(defaultFile.getContainingFile()));
}
use of com.intellij.lang.properties.psi.PropertiesFile in project intellij-community by JetBrains.
the class ResourceBundleTest method testDifferentPropertiesDontCombinedToResourceBundle.
public void testDifferentPropertiesDontCombinedToResourceBundle() {
final PsiFile xmlFile = myFixture.addFileToProject("p.xml", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<!DOCTYPE properties SYSTEM \"http://java.sun.com/dtd/properties.dtd\">\n" + "<properties>\n" + "</properties>");
final PsiFile propFile = myFixture.addFileToProject("p.properties", "");
final PropertiesFile xmlPropFile = PropertiesImplUtil.getPropertiesFile(xmlFile);
final PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile(propFile);
assertNotNull(xmlPropFile);
assertNotNull(propertiesFile);
assertEquals(xmlPropFile, assertOneElement(xmlPropFile.getResourceBundle().getPropertiesFiles()));
assertEquals(propertiesFile, assertOneElement(propertiesFile.getResourceBundle().getPropertiesFiles()));
}
Aggregations