本文整理汇总了Java中com.intellij.psi.xml.XmlTag.getParentTag方法的典型用法代码示例。如果您正苦于以下问题:Java XmlTag.getParentTag方法的具体用法?Java XmlTag.getParentTag怎么用?Java XmlTag.getParentTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.xml.XmlTag
的用法示例。
在下文中一共展示了XmlTag.getParentTag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildVisitor
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(final @NotNull ProblemsHolder holder,
boolean isOnTheFly,
@NotNull LocalInspectionToolSession session) {
return new XmlElementVisitor() {
@Override
public void visitXmlTag(XmlTag tag) {
super.visitXmlTag(tag);
final XmlElementDescriptor descriptor = tag.getDescriptor();
if (descriptor instanceof JavaFxPropertyElementDescriptor) {
final XmlTag parentTag = tag.getParentTag();
if (parentTag != null) {
final String propertyName = JavaFxPsiUtil.getDefaultPropertyName(JavaFxPsiUtil.getTagClass(parentTag));
final String tagName = tag.getName();
if (Comparing.strEqual(tagName, propertyName)) {
holder.registerProblem(tag.getFirstChild(),
"Default property tag could be removed",
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
new UnwrapTagFix(tagName));
}
}
}
}
};
}
示例2: getVariants
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@NotNull
@Override
public Object[] getVariants() {
String skippedPropertyName = null;
XmlTag xmlTag = PsiTreeUtil.getParentOfType(getElement(), XmlTag.class, false);
if (xmlTag != null && myProperties == xmlTag.getParentTag()) {
skippedPropertyName = xmlTag.getName();
}
List<String> res = new ArrayList<String>();
for (XmlTag subTag : myProperties.getSubTags()) {
String name = subTag.getName();
if (!name.equals(skippedPropertyName)) {
res.add(name);
}
}
return res.toArray();
}
示例3: measureChild
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
/**
* Measure the given child in context, applying the given filter to the
* pull parser's attribute values.
*
* @param tag the child to measure
* @param filter the filter to apply to the attribute values
* @return a view info, if found
*/
@Nullable
public ViewInfo measureChild(XmlTag tag, final AttributeFilter filter) {
XmlTag parent = tag.getParentTag();
if (parent != null) {
Map<XmlTag, ViewInfo> map = measureChildren(parent, filter);
if (map != null) {
for (Map.Entry<XmlTag, ViewInfo> entry : map.entrySet()) {
if (entry.getKey() == tag) {
return entry.getValue();
}
}
}
}
return null;
}
示例4: getValueTag
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Nullable
private static XmlTag getValueTag(@Nullable XmlTag tag) {
XmlTag current = null;
if (tag != null) {
current = tag;
XmlTag parent = current.getParentTag();
while (parent != null) {
XmlTag parentParent = parent.getParentTag();
if (parentParent == null) {
break;
}
current = parent;
parent = parentParent;
}
}
return current;
}
示例5: apply
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Override
public void apply(@NotNull PsiElement startElement, @NotNull PsiElement endElement, @NotNull AndroidQuickfixContexts.Context context) {
final XmlTag tag = PsiTreeUtil.getParentOfType(startElement, XmlTag.class);
if (tag == null) {
return;
}
final XmlTag parentTag = tag.getParentTag();
if (parentTag == null) {
return;
}
String attrName;
if (AndroidLintUtil.ATTR_VALUE_VERTICAL
.equals(parentTag.getAttributeValue(AndroidLintUtil.ATTR_ORIENTATION, SdkConstants.NS_RESOURCES))) {
attrName = AndroidLintUtil.ATTR_LAYOUT_HEIGHT;
}
else {
attrName = AndroidLintUtil.ATTR_LAYOUT_WIDTH;
}
tag.setAttribute(attrName, SdkConstants.NS_RESOURCES, "0dp");
}
示例6: getMulePath
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
public static String getMulePath(XmlTag tag) {
final LinkedList<XmlTag> elements = new LinkedList<>();
while (!isMuleTag(tag)) {
elements.push(tag);
tag = tag.getParentTag();
}
String path = "";
for (int i = 0; i < elements.size(); i++) {
final XmlTag element = elements.get(i);
switch (i) {
case 0: {
final XmlAttribute name = element.getAttribute(MuleConfigConstants.NAME_ATTRIBUTE);
if (name != null) {
path = "/" + MulePathUtils.escape(name.getValue()) + getGlobalElementCategory(element);
}
break;
}
default: {
final XmlTag parentTag = element.getParentTag();
int index = 0;
for (XmlTag xmlTag : parentTag.getSubTags()) {
if (xmlTag == element) {
break;
}
final MuleElementType muleElementType = getMuleElementTypeFromXmlElement(xmlTag);
if (muleElementType == MuleElementType.MESSAGE_PROCESSOR) {
index = index + 1;
}
}
path = path + "/" + index;
}
}
}
System.out.println("path = " + path);
return path;
}
示例7: getElementDescriptor
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Override
public XmlElementDescriptor getElementDescriptor(XmlTag childTag, XmlTag contextTag) {
XmlTag parent = contextTag.getParentTag();
if (parent == null) return null;
final XmlNSDescriptor descriptor = parent.getNSDescriptor(childTag.getNamespace(), true);
return descriptor == null ? null : descriptor.getElementDescriptor(childTag);
}
示例8: isCamelRouteStart
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Override
public boolean isCamelRouteStart(PsiElement element) {
if (element.getText().equals("from")) {
XmlTag xml = PsiTreeUtil.getParentOfType(element, XmlTag.class);
if (xml != null) {
String name = xml.getLocalName();
XmlTag parentTag = xml.getParentTag();
if (parentTag != null) {
return "from".equals(name) && "route".equals(parentTag.getLocalName());
}
}
}
return false;
}
示例9: computeBaseClass
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Nullable
private static String computeBaseClass(XmlTag context) {
final XmlTag parentTag = context.getParentTag();
final Pair<AndroidDomElement, String> pair =
AndroidDomElementDescriptorProvider.getDomElementAndBaseClassQName(parentTag != null ? parentTag : context);
return pair != null ? pair.getSecond() : null;
}
示例10: addNoinspectionComment
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
private void addNoinspectionComment(Project project, XmlTag anchor) throws IncorrectOperationException {
final XmlComment newComment = createComment(project, "noinspection " + myToolId);
PsiElement parent = anchor.getParentTag();
if (parent == null) {
parent = PsiTreeUtil.getPrevSiblingOfType(anchor, XmlProlog.class);
if (parent != null) {
CodeStyleManager.getInstance(PsiManager.getInstance(project).getProject()).reformat(parent.add(newComment));
}
} else {
CodeStyleManager.getInstance(PsiManager.getInstance(project).getProject()).reformat(parent.addBefore(newComment, anchor));
}
}
示例11: findScopeTag
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Nullable
public static XmlTag findScopeTag(@Nullable XmlTag context) {
Map<String, XmlTag> id2tag = findScopesWithItemRef(context != null ? context.getContainingFile() : null);
XmlTag tag = context;
while (tag != null) {
if (tag != context && tag.getAttribute(ITEM_SCOPE) != null) return tag;
final String id = getStripedAttributeValue(tag, HtmlUtil.ID_ATTRIBUTE_NAME);
if (id != null && id2tag.containsKey(id)) return id2tag.get(id);
tag = tag.getParentTag();
}
return null;
}
示例12: process
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Override
public void process(@NotNull XmlName attrName, @NotNull DomExtension extension, @NotNull DomElement element) {
// Mark layout_width and layout_height required - if the context calls for it
String localName = attrName.getLocalName();
if (!(ATTR_LAYOUT_WIDTH.equals(localName) || ATTR_LAYOUT_HEIGHT.equals(localName))) {
return;
}
if ((element instanceof LayoutViewElement || element instanceof Fragment) &&
SdkConstants.NS_RESOURCES.equals(attrName.getNamespaceKey())) {
XmlElement xmlElement = element.getXmlElement();
XmlTag tag = xmlElement instanceof XmlTag ? (XmlTag)xmlElement : null;
String tagName = tag != null ? tag.getName() : null;
if (!VIEW_MERGE.equals(tagName) &&
!TABLE_ROW.equals(tagName) &&
!VIEW_INCLUDE.equals(tagName) &&
!REQUEST_FOCUS.equals(tagName) &&
!TAG_LAYOUT.equals(tagName) &&
!TAG_DATA.equals(tagName) &&
!TAG_VARIABLE.equals(tagName) &&
!TAG_IMPORT.equals(tagName) &&
!TAG.equals(tagName) &&
(tag == null || tag.getAttribute(ATTR_STYLE) == null)) {
XmlTag parentTag = tag != null ? tag.getParentTag() : null;
String parentTagName = parentTag != null ? parentTag.getName() : null;
if (!TABLE_ROW.equals(parentTagName) &&
!TABLE_LAYOUT.equals(parentTagName) &&
!VIEW_MERGE.equals(parentTagName) &&
!GRID_LAYOUT.equals(parentTagName) &&
!FQCN_GRID_LAYOUT_V7.equals(parentTagName)) {
extension.addCustomAnnotation(new MyRequired());
}
}
}
}
示例13: createXmlPolicy
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Override
public XmlPolicy createXmlPolicy(CodeStyleSettings settings, FormattingDocumentModel documentModel) {
return new AndroidXmlPolicy(settings, this, documentModel) {
@Override
public boolean insertLineBreakBeforeTag(XmlTag xmlTag) {
if (GROUP_TAGS_WITH_SAME_NAME) {
PsiElement element = getPrevSiblingElement(xmlTag);
if (element instanceof XmlTag) {
final String name1 = ((XmlTag)element).getName();
final String name2 = xmlTag.getName();
if (!name1.equals(name2)) {
element = getPrevSiblingElement(element);
if (element instanceof XmlTag && ((XmlTag)element).getName().equals(name1)) {
return true;
}
element = getNextSiblingElement(xmlTag);
return element instanceof XmlTag && ((XmlTag)element).getName().equals(name2);
}
}
}
return false;
}
@Override
public boolean insertLineBreakAfterTagBegin(XmlTag tag) {
return GROUP_TAGS_WITH_SAME_NAME && tag.getParentTag() == null;
}
};
}
示例14: findValueResourceTagInContext
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Nullable
static XmlTag findValueResourceTagInContext(@NotNull Editor editor, @NotNull PsiFile file) {
if (!(file instanceof XmlFile)) {
return null;
}
final AndroidFacet facet = AndroidFacet.getInstance(file);
if (facet == null) {
return null;
}
if (!AndroidResourceUtil.isInResourceSubdirectory(file, ResourceFolderType.VALUES.getName())) {
return null;
}
final PsiElement element = file.findElementAt(editor.getCaretModel().getOffset());
if (element == null) {
return null;
}
final XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class);
if (tag == null) {
return null;
}
XmlTag current = tag.getParentTag();
if (current == null) {
return null;
}
// Handle nested elements, e.g. <attr> in <declare-styleable> and <item> in <style>
while (true) {
XmlTag parentTag = current.getParentTag();
if (parentTag == null) {
return TAG_RESOURCES.equals(current.getName()) ? tag : null;
} else {
current = parentTag;
}
}
}
示例15: isApplicable
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Override
public boolean isApplicable(@NotNull PsiElement startElement,
@NotNull PsiElement endElement,
@NotNull AndroidQuickfixContexts.ContextType contextType) {
final XmlTag tag = PsiTreeUtil.getParentOfType(startElement, XmlTag.class);
if (tag == null) {
return false;
}
return tag.getParentTag() != null;
}