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);
}
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();
}
}
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);
}
Aggregations