本文整理汇总了Java中com.intellij.xml.actions.GenerateXmlTagAction类的典型用法代码示例。如果您正苦于以下问题:Java GenerateXmlTagAction类的具体用法?Java GenerateXmlTagAction怎么用?Java GenerateXmlTagAction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GenerateXmlTagAction类属于com.intellij.xml.actions包,在下文中一共展示了GenerateXmlTagAction类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addRequiredSubTags
import com.intellij.xml.actions.GenerateXmlTagAction; //导入依赖的package包/类
private static boolean addRequiredSubTags(Template template, XmlElementDescriptor descriptor, PsiFile file, XmlTag context) {
if (!WebEditorOptions.getInstance().isAutomaticallyInsertRequiredSubTags()) return false;
List<XmlElementDescriptor> requiredSubTags = GenerateXmlTagAction.getRequiredSubTags(descriptor);
if (!requiredSubTags.isEmpty()) {
template.addTextSegment(">");
template.setToReformat(true);
}
for (XmlElementDescriptor subTag : requiredSubTags) {
if (subTag == null) { // placeholder for smart completion
template.addTextSegment("<");
template.addVariable(new MacroCallNode(new CompleteSmartMacro()), true);
continue;
}
String qname = subTag.getName();
if (subTag instanceof XmlElementDescriptorImpl) {
String prefixByNamespace = context.getPrefixByNamespace(((XmlElementDescriptorImpl)subTag).getNamespace());
if (StringUtil.isNotEmpty(prefixByNamespace)) {
qname = prefixByNamespace + ":" + subTag.getName();
}
}
template.addTextSegment("<" + qname);
addRequiredAttributes(subTag, null, template, file);
completeTagTail(template, subTag, file, context, false);
}
if (!requiredSubTags.isEmpty()) {
addTagEnd(template, descriptor, context);
}
return !requiredSubTags.isEmpty();
}
示例2: addRequiredSubTags
import com.intellij.xml.actions.GenerateXmlTagAction; //导入依赖的package包/类
private static boolean addRequiredSubTags(Template template, XmlElementDescriptor descriptor, PsiFile file, XmlTag context)
{
if(!XmlEditorOptions.getInstance().isAutomaticallyInsertRequiredSubTags())
{
return false;
}
List<XmlElementDescriptor> requiredSubTags = GenerateXmlTagAction.getRequiredSubTags(descriptor);
if(!requiredSubTags.isEmpty())
{
template.addTextSegment(">");
template.setToReformat(true);
}
for(XmlElementDescriptor subTag : requiredSubTags)
{
if(subTag == null)
{ // placeholder for smart completion
template.addTextSegment("<");
template.addVariable(new MacroCallNode(new CompleteSmartMacro()), true);
continue;
}
String qname = subTag.getName();
if(subTag instanceof XmlElementDescriptorImpl)
{
String prefixByNamespace = context.getPrefixByNamespace(((XmlElementDescriptorImpl) subTag).getNamespace());
if(StringUtil.isNotEmpty(prefixByNamespace))
{
qname = prefixByNamespace + ":" + subTag.getName();
}
}
template.addTextSegment("<" + qname);
addRequiredAttributes(subTag, null, template, file);
completeTagTail(template, subTag, file, context, false);
}
if(!requiredSubTags.isEmpty())
{
addTagEnd(template, descriptor, context);
}
return !requiredSubTags.isEmpty();
}