use of com.intellij.lang.properties.editor.inspections.incomplete.IncompletePropertyInspection in project intellij-community by JetBrains.
the class IgnoredPropertiesFilesSuffixesTest method testPropertyIsComplete.
public void testPropertyIsComplete() {
myFixture.addFileToProject("p.properties", "key=value");
myFixture.addFileToProject("p_en.properties", "key=value eng");
final PsiFile file = myFixture.addFileToProject("p_ru.properties", "");
final PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile(file);
assertNotNull(propertiesFile);
final ResourceBundle resourceBundle = propertiesFile.getResourceBundle();
assertSize(3, resourceBundle.getPropertiesFiles());
final IncompletePropertyInspection incompletePropertyInspection = IncompletePropertyInspection.getInstance(propertiesFile.getContainingFile());
incompletePropertyInspection.addSuffixes(Collections.singleton("ru"));
assertTrue(incompletePropertyInspection.isPropertyComplete("key", resourceBundle));
}
use of com.intellij.lang.properties.editor.inspections.incomplete.IncompletePropertyInspection 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.editor.inspections.incomplete.IncompletePropertyInspection 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.editor.inspections.incomplete.IncompletePropertyInspection in project intellij-community by JetBrains.
the class ResourceBundleEditor method selectNextIncompleteProperty.
public void selectNextIncompleteProperty() {
if (getSelectedNodes().size() != 1) {
return;
}
final IProperty selectedProperty = getSelectedProperty();
if (selectedProperty == null) {
return;
}
final ResourceBundleFileStructureViewElement root = (ResourceBundleFileStructureViewElement) myStructureViewComponent.getTreeModel().getRoot();
final Set<String> propertyKeys = ResourceBundleFileStructureViewElement.getPropertiesMap(myResourceBundle, root.isShowOnlyIncomplete()).keySet();
final boolean isAlphaSorted = myStructureViewComponent.isActionActive(Sorter.ALPHA_SORTER_ID);
final List<String> keysOrder = new ArrayList<>(propertyKeys);
if (isAlphaSorted) {
Collections.sort(keysOrder);
}
final String currentKey = selectedProperty.getKey();
final int idx = keysOrder.indexOf(currentKey);
LOG.assertTrue(idx != -1);
final IncompletePropertyInspection incompletePropertyInspection = IncompletePropertyInspection.getInstance(myResourceBundle.getDefaultPropertiesFile().getContainingFile());
for (int i = 1; i < keysOrder.size(); i++) {
int trimmedIndex = (i + idx) % keysOrder.size();
final String key = keysOrder.get(trimmedIndex);
if (!incompletePropertyInspection.isPropertyComplete(key, myResourceBundle)) {
selectProperty(key);
return;
}
}
}
use of com.intellij.lang.properties.editor.inspections.incomplete.IncompletePropertyInspection in project intellij-community by JetBrains.
the class IgnoredPropertiesFilesSuffixesTest method testPropertyIsIncomplete2.
public void testPropertyIsIncomplete2() {
myFixture.addFileToProject("p.properties", "key=value");
myFixture.addFileToProject("p_en.properties", "");
myFixture.addFileToProject("p_en_EN.properties", "");
myFixture.addFileToProject("p_en_GB.properties", "");
final PsiFile file = myFixture.addFileToProject("p_en_US.properties", "");
final PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile(file);
assertNotNull(propertiesFile);
final ResourceBundle resourceBundle = propertiesFile.getResourceBundle();
assertSize(5, resourceBundle.getPropertiesFiles());
final IncompletePropertyInspection incompletePropertyInspection = IncompletePropertyInspection.getInstance(propertiesFile.getContainingFile());
incompletePropertyInspection.addSuffixes(Collections.singleton("en"));
assertFalse(incompletePropertyInspection.isPropertyComplete("key", resourceBundle));
}
Aggregations