use of com.intellij.lang.properties.psi.Property in project intellij-community by JetBrains.
the class PropertiesInheritorsSearcher method processQuery.
@Override
public void processQuery(@NotNull DefinitionsScopedSearch.SearchParameters queryParameters, @NotNull Processor<PsiElement> consumer) {
final PsiElement element = queryParameters.getElement();
Property prop = ReadAction.compute(() -> GotoPropertyParentDeclarationHandler.findProperty(element));
if (prop == null || !(queryParameters.getScope() instanceof GlobalSearchScope)) {
return;
}
ReadAction.run(() -> {
final String key = prop.getKey();
if (!prop.isValid() || key == null)
return;
final PropertiesFile currentFile = PropertiesImplUtil.getPropertiesFile(prop.getContainingFile());
LOG.assertTrue(currentFile != null);
final GlobalSearchScope scope = (GlobalSearchScope) queryParameters.getScope();
currentFile.getResourceBundle().getPropertiesFiles().stream().filter(f -> f.equals(currentFile)).filter(f -> scope.contains(f.getVirtualFile())).filter(f -> PropertiesUtil.getParent(f, Collections.singleton(currentFile)) == currentFile).map(f -> f.findPropertyByKey(key)).filter(Objects::nonNull).map(IProperty::getPsiElement).anyMatch(psiElement -> {
ProgressManager.checkCanceled();
return !consumer.process(psiElement);
});
});
}
use of com.intellij.lang.properties.psi.Property 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.Property in project intellij-community by JetBrains.
the class FormPropertyUsageTest method doPropertyUsageTest.
private void doPropertyUsageTest(final String propertyFileName) {
PropertiesFile propFile = (PropertiesFile) myPsiManager.findFile(myTestProjectRoot.findChild(propertyFileName));
assertNotNull(propFile);
final Property prop = (Property) propFile.findPropertyByKey("key");
assertNotNull(prop);
final Query<PsiReference> query = ReferencesSearch.search(prop);
final Collection<PsiReference> result = query.findAll();
assertEquals(1, result.size());
verifyReference(result, 0, "form.form", 960);
}
use of com.intellij.lang.properties.psi.Property in project android by JetBrains.
the class GradleImplicitPropertyUsageProviderTest method testGradleWrapper.
public void testGradleWrapper() {
VirtualFile vFile = myFixture.copyFileToProject("projects/projectWithAppandLib/gradle/wrapper/gradle-wrapper.properties", "gradle/wrapper/gradle-wrapper.properties");
PsiFile file = PsiManager.getInstance(getProject()).findFile(vFile);
assertNotNull(file);
PropertiesFile propertiesFile = (PropertiesFile) file;
GradleImplicitPropertyUsageProvider provider = new GradleImplicitPropertyUsageProvider();
for (IProperty property : propertiesFile.getProperties()) {
// All properties are considered used in this file
String name = property.getName();
assertTrue(name, provider.isUsed((Property) property));
}
}
use of com.intellij.lang.properties.psi.Property in project android by JetBrains.
the class GradleImplicitPropertyUsageProviderTest method testLocalProperties.
public void testLocalProperties() {
VirtualFile vFile = myFixture.copyFileToProject("test.properties", "local.properties");
PsiFile file = PsiManager.getInstance(getProject()).findFile(vFile);
assertNotNull(file);
PropertiesFile propertiesFile = (PropertiesFile) file;
GradleImplicitPropertyUsageProvider provider = new GradleImplicitPropertyUsageProvider();
for (IProperty property : propertiesFile.getProperties()) {
Property p = (Property) property;
// Only but the property with "unused" in its name are considered used
String name = property.getName();
if (name.contains("unused")) {
assertFalse(name, provider.isUsed(p));
} else {
assertTrue(name, provider.isUsed(p));
}
}
}
Aggregations