Search in sources :

Example 41 with PropertiesFile

use of com.intellij.lang.properties.psi.PropertiesFile in project intellij-community by JetBrains.

the class MavenPropertyPsiReference method collectSystemEnvProperties.

private void collectSystemEnvProperties(String propertiesFileName, @Nullable String prefix, List<Object> result, Set<String> variants) {
    VirtualFile virtualFile = MavenPropertiesVirtualFileSystem.getInstance().findFileByPath(propertiesFileName);
    PropertiesFile file = MavenDomUtil.getPropertiesFile(myProject, virtualFile);
    collectPropertiesFileVariants(file, prefix, result, variants);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PropertiesFile(com.intellij.lang.properties.psi.PropertiesFile)

Example 42 with PropertiesFile

use of com.intellij.lang.properties.psi.PropertiesFile in project intellij-community by JetBrains.

the class XmlPropertiesTest method testAddPropertyInAlphaOrder.

public void testAddPropertyInAlphaOrder() {
    final PsiFile psiFile = myFixture.configureByFile("bar.xml");
    final PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile(psiFile);
    assertNotNull(propertiesFile);
    WriteCommandAction.runWriteCommandAction(getProject(), () -> {
        propertiesFile.addProperty("d", "vvv");
        propertiesFile.addProperty("a", "vvv");
        propertiesFile.addProperty("l", "vvv");
        propertiesFile.addProperty("v", "vvv");
    });
    assertTrue(propertiesFile.isAlphaSorted());
    assertTrue(PropertiesImplUtil.getPropertiesFile(psiFile).isAlphaSorted());
}
Also used : PsiFile(com.intellij.psi.PsiFile) PropertiesFile(com.intellij.lang.properties.psi.PropertiesFile)

Example 43 with PropertiesFile

use of com.intellij.lang.properties.psi.PropertiesFile in project intellij-community by JetBrains.

the class XmlPropertiesTest method testXmlProperties.

public void testXmlProperties() throws Exception {
    myFixture.configureByFile("foo.xml");
    List<PropertiesFile> files = PropertiesReferenceManager.getInstance(getProject()).findPropertiesFiles(myModule, "foo");
    assertEquals(1, files.size());
    PropertiesFile file = files.get(0);
    assertEquals(1, file.findPropertiesByKey("foo").size());
    List<IProperty> properties = PropertiesImplUtil.findPropertiesByKey(getProject(), "foo");
    assertEquals(1, properties.size());
}
Also used : IProperty(com.intellij.lang.properties.IProperty) PropertiesFile(com.intellij.lang.properties.psi.PropertiesFile)

Example 44 with PropertiesFile

use of com.intellij.lang.properties.psi.PropertiesFile in project intellij-community by JetBrains.

the class XmlPropertiesTest method testWrongFile.

public void testWrongFile() throws Exception {
    PsiFile psiFile = myFixture.configureByFile("wrong.xml");
    PropertiesFile file = PropertiesImplUtil.getPropertiesFile(psiFile);
    assertNull(file);
}
Also used : PsiFile(com.intellij.psi.PsiFile) PropertiesFile(com.intellij.lang.properties.psi.PropertiesFile)

Example 45 with PropertiesFile

use of com.intellij.lang.properties.psi.PropertiesFile in project intellij-community by JetBrains.

the class XmlPropertiesTest method testAddProperty.

public void testAddProperty() {
    final PsiFile psiFile = myFixture.configureByFile("foo.xml");
    final PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile(psiFile);
    assertNotNull(propertiesFile);
    WriteCommandAction.runWriteCommandAction(getProject(), () -> {
        propertiesFile.addProperty("kkk", "vvv");
    });
    final IProperty property = propertiesFile.findPropertyByKey("kkk");
    assertNotNull(property);
    assertEquals("vvv", property.getValue());
}
Also used : IProperty(com.intellij.lang.properties.IProperty) PsiFile(com.intellij.psi.PsiFile) PropertiesFile(com.intellij.lang.properties.psi.PropertiesFile)

Aggregations

PropertiesFile (com.intellij.lang.properties.psi.PropertiesFile)143 IProperty (com.intellij.lang.properties.IProperty)44 PsiFile (com.intellij.psi.PsiFile)42 VirtualFile (com.intellij.openapi.vfs.VirtualFile)22 ResourceBundle (com.intellij.lang.properties.ResourceBundle)19 PsiElement (com.intellij.psi.PsiElement)19 NotNull (org.jetbrains.annotations.NotNull)19 Nullable (org.jetbrains.annotations.Nullable)18 Property (com.intellij.lang.properties.psi.Property)15 Project (com.intellij.openapi.project.Project)10 XmlPropertiesFile (com.intellij.lang.properties.xml.XmlPropertiesFile)9 PsiDirectory (com.intellij.psi.PsiDirectory)8 IncorrectOperationException (com.intellij.util.IncorrectOperationException)8 THashSet (gnu.trove.THashSet)8 ArrayList (java.util.ArrayList)7 Module (com.intellij.openapi.module.Module)6 PsiFileSystemItem (com.intellij.psi.PsiFileSystemItem)6 HashSet (com.intellij.util.containers.HashSet)6 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)5 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)5