本文整理汇总了Java中com.intellij.psi.xml.XmlTag.setName方法的典型用法代码示例。如果您正苦于以下问题:Java XmlTag.setName方法的具体用法?Java XmlTag.setName怎么用?Java XmlTag.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.xml.XmlTag
的用法示例。
在下文中一共展示了XmlTag.setName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleElementRename
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Override
@Nullable
public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException {
final XmlTag element = getTagElement();
if (element == null || !myStartTagFlag) return element;
if (newElementName.indexOf(':') == -1) {
final String namespacePrefix = element.getNamespacePrefix();
final int index = newElementName.lastIndexOf('.');
if (index != -1) {
final PsiElement psiElement = resolve();
if (psiElement instanceof PsiFile || (psiElement != null && psiElement.isEquivalentTo(psiElement.getContainingFile()))) {
newElementName = newElementName.substring(0, index);
}
}
newElementName = prependNamespacePrefix(newElementName, namespacePrefix);
}
element.setName(newElementName);
return element;
}
示例2: bindToElement
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Override
public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException {
if (element instanceof PsiClass) {
final String qualifiedName = ((PsiClass)element).getQualifiedName();
if (qualifiedName != null) {
final String shortName = StringUtil.getShortName(qualifiedName);
final XmlTag tagElement = getTagElement();
if (tagElement != null) {
final String oldTagName = tagElement.getName();
if (oldTagName.contains(".")) {
return tagElement.setName(qualifiedName);
}
return tagElement.setName(shortName);
}
return getElement();
}
}
return super.bindToElement(element);
}
示例3: handleElementRename
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Override
public PsiElement handleElementRename(String name) throws IncorrectOperationException {
if (myElement instanceof XmlAttribute) {
final XmlAttribute attr = (XmlAttribute)myElement;
return ("xmlns".equals(attr.getNamespacePrefix()))
? attr.setName(attr.getNamespacePrefix() + ":" + name)
: attr.setName(name + ":" + attr.getLocalName());
}
else if (myElement instanceof XmlTag) {
final XmlTag tag = (XmlTag)myElement;
return tag.setName(name + ":" + tag.getLocalName());
}
return super.handleElementRename(name);
}
示例4: addExtension
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Override
public Extension addExtension(String qualifiedEPName) {
Extension extension = addExtension();
XmlTag tag = extension.getXmlTag();
tag.setName(StringUtil.trimStart(qualifiedEPName, getEpPrefix()));
return extension;
}