Search in sources :

Example 11 with PomTargetPsiElement

use of com.intellij.pom.PomTargetPsiElement in project intellij-community by JetBrains.

the class RenameUtil method isValidName.

public static boolean isValidName(final Project project, final PsiElement psiElement, final String newName) {
    if (newName == null || newName.length() == 0) {
        return false;
    }
    final Condition<String> inputValidator = RenameInputValidatorRegistry.getInputValidator(psiElement);
    if (inputValidator != null) {
        return inputValidator.value(newName);
    }
    if (psiElement instanceof PsiFile || psiElement instanceof PsiDirectory) {
        return newName.indexOf('\\') < 0 && newName.indexOf('/') < 0;
    }
    if (psiElement instanceof PomTargetPsiElement) {
        return !StringUtil.isEmptyOrSpaces(newName);
    }
    final PsiFile file = psiElement.getContainingFile();
    final Language elementLanguage = psiElement.getLanguage();
    final Language fileLanguage = file == null ? null : file.getLanguage();
    Language language = fileLanguage == null ? elementLanguage : fileLanguage.isKindOf(elementLanguage) ? fileLanguage : elementLanguage;
    return LanguageNamesValidation.INSTANCE.forLanguage(language).isIdentifier(newName.trim(), project);
}
Also used : Language(com.intellij.lang.Language) PomTargetPsiElement(com.intellij.pom.PomTargetPsiElement)

Example 12 with PomTargetPsiElement

use of com.intellij.pom.PomTargetPsiElement in project intellij-community by JetBrains.

the class ResourceBundlePropertiesUpdateManager method deletePropertyIfExist.

public void deletePropertyIfExist(String key, PropertiesFile file) {
    final IProperty property = file.findPropertyByKey(key);
    if (property != null && myKeysOrder != null) {
        boolean keyExistInOtherPropertiesFiles = false;
        for (PropertiesFile propertiesFile : myResourceBundle.getPropertiesFiles()) {
            if (!propertiesFile.equals(file) && propertiesFile.findPropertyByKey(key) != null) {
                keyExistInOtherPropertiesFiles = true;
                break;
            }
        }
        if (!keyExistInOtherPropertiesFiles) {
            myKeysOrder.remove(key);
        }
    }
    if (property != null) {
        PsiElement anElement = property.getPsiElement();
        if (anElement instanceof PomTargetPsiElement) {
            final PomTarget xmlProperty = ((PomTargetPsiElement) anElement).getTarget();
            LOG.assertTrue(xmlProperty instanceof XmlProperty);
            anElement = ((XmlProperty) xmlProperty).getNavigationElement();
        }
        anElement.delete();
    }
}
Also used : PomTarget(com.intellij.pom.PomTarget) IProperty(com.intellij.lang.properties.IProperty) XmlProperty(com.intellij.lang.properties.xml.XmlProperty) PropertiesFile(com.intellij.lang.properties.psi.PropertiesFile) PomTargetPsiElement(com.intellij.pom.PomTargetPsiElement) PomTargetPsiElement(com.intellij.pom.PomTargetPsiElement) PsiElement(com.intellij.psi.PsiElement)

Example 13 with PomTargetPsiElement

use of com.intellij.pom.PomTargetPsiElement in project intellij-community by JetBrains.

the class DomDocumentationProvider method generateDoc.

@Override
public String generateDoc(PsiElement element, final PsiElement originalElement) {
    if (element instanceof PomTargetPsiElement) {
        PomTarget target = ((PomTargetPsiElement) element).getTarget();
        if (target instanceof DelegatePsiTarget) {
            element = ((DelegatePsiTarget) target).getNavigationElement();
        }
    }
    final DomElement domElement = DomUtil.getDomElement(element);
    if (domElement == null) {
        return null;
    }
    ElementPresentationTemplate template = domElement.getChildDescription().getPresentationTemplate();
    if (template != null) {
        String documentation = template.createPresentation(domElement).getDocumentation();
        if (documentation != null)
            return documentation;
    }
    return ElementPresentationManager.getDocumentationForElement(domElement);
}
Also used : PomTarget(com.intellij.pom.PomTarget) DelegatePsiTarget(com.intellij.psi.DelegatePsiTarget) PomTargetPsiElement(com.intellij.pom.PomTargetPsiElement)

Aggregations

PomTargetPsiElement (com.intellij.pom.PomTargetPsiElement)13 PsiElement (com.intellij.psi.PsiElement)9 PomTarget (com.intellij.pom.PomTarget)6 PsiReference (com.intellij.psi.PsiReference)4 Nullable (org.jetbrains.annotations.Nullable)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 PsiFile (com.intellij.psi.PsiFile)2 DomElement (com.intellij.util.xml.DomElement)2 DomTarget (com.intellij.util.xml.DomTarget)2 ResourceUrl (com.android.ide.common.resources.ResourceUrl)1 ResourceType (com.android.resources.ResourceType)1 Language (com.intellij.lang.Language)1 AntDomElement (com.intellij.lang.ant.dom.AntDomElement)1 AntDomMacrodefAttribute (com.intellij.lang.ant.dom.AntDomMacrodefAttribute)1 AntDomTarget (com.intellij.lang.ant.dom.AntDomTarget)1 InjectedLanguageManager (com.intellij.lang.injection.InjectedLanguageManager)1 IProperty (com.intellij.lang.properties.IProperty)1 PropertiesFile (com.intellij.lang.properties.psi.PropertiesFile)1 XmlProperty (com.intellij.lang.properties.xml.XmlProperty)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1