本文整理汇总了Java中com.intellij.psi.xml.XmlTag.getDescriptor方法的典型用法代码示例。如果您正苦于以下问题:Java XmlTag.getDescriptor方法的具体用法?Java XmlTag.getDescriptor怎么用?Java XmlTag.getDescriptor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.xml.XmlTag
的用法示例。
在下文中一共展示了XmlTag.getDescriptor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMuleElementTypeFromXmlElement
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Nullable
public static MuleElementType getMuleElementTypeFromXmlElement(XmlTag xmlTag) {
final XmlElementDescriptor descriptor = xmlTag.getDescriptor();
if (descriptor instanceof XmlElementDescriptorImpl) {
final XmlElementDescriptorImpl xmlElementDescriptor = (XmlElementDescriptorImpl) descriptor;
final TypeDescriptor schemaType = xmlElementDescriptor.getType();
if (schemaType instanceof ComplexTypeDescriptor) {
final XmlTag complexTypeTag = schemaType.getDeclaration();
final MuleElementType typeReference = MuleSchemaUtils.getElementTypeFromComplexType(complexTypeTag);
if (typeReference != null) {
return typeReference;
}
}
} else {
//This is to handle unknown elements
if (!(xmlTag.getName().equals("description")) && isContainer(xmlTag.getParentTag())) {
return (isKnownMS(xmlTag)) ? MuleElementType.MESSAGE_SOURCE : MuleElementType.MESSAGE_PROCESSOR;
}
}
return null;
}
示例2: getDefaultComparator
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Nullable
protected Comparator<AbstractDomElementNode> getDefaultComparator(DomElement element) {
final XmlTag tag = element.getXmlTag();
if (tag != null) {
final XmlElementDescriptor descriptor = tag.getDescriptor();
if (descriptor != null) {
final XmlElementDescriptor[] childDescriptors = descriptor.getElementsDescriptors(tag);
if (childDescriptors != null && childDescriptors.length > 1) {
return new Comparator<AbstractDomElementNode>() {
@Override
public int compare(final AbstractDomElementNode o1, final AbstractDomElementNode o2) {
return findDescriptor(childDescriptors, o1.getTagName()) - findDescriptor(childDescriptors, o2.getTagName());
}
};
}
}
}
return null;
}
示例3: resolve
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Override
public PsiElement resolve() {
final XmlTag tag = getTagElement();
final XmlElementDescriptor descriptor = tag != null ? tag.getDescriptor():null;
if (LOG.isDebugEnabled()) {
LOG.debug("Descriptor for tag " +
(tag != null ? tag.getName() : "NULL") +
" is " +
(descriptor != null ? (descriptor.toString() + ": " + descriptor.getClass().getCanonicalName()) : "NULL"));
}
if (descriptor != null){
return descriptor instanceof AnyXmlElementDescriptor ? tag : descriptor.getDeclaration();
}
return null;
}
示例4: bindToElement
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Override
public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException {
PsiMetaData metaData = null;
if (element instanceof PsiMetaOwner){
final PsiMetaOwner owner = (PsiMetaOwner)element;
metaData = owner.getMetaData();
if (metaData instanceof XmlElementDescriptor){
return getTagElement().setName(metaData.getName(getElement())); // TODO: need to evaluate new ns prefix
}
} else if (element instanceof PsiFile) {
final XmlTag tagElement = getTagElement();
if (tagElement == null || !myStartTagFlag) return tagElement;
String newElementName = ((PsiFile)element).getName();
final int index = newElementName.lastIndexOf('.');
// TODO: need to evaluate new ns prefix
newElementName = prependNamespacePrefix(newElementName.substring(0, index), tagElement.getNamespacePrefix());
return getTagElement().setName(newElementName);
}
final XmlTag tag = getTagElement();
throw new IncorrectOperationException("Cant bind to not a xml element definition!"+element+","+metaData + "," + tag + "," + (tag != null ? tag.getDescriptor() : "unknown descriptor"));
}
示例5: configure
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
private Map<String, XmlElementDescriptor> configure(String... files) {
myFixture.configureByFiles(files);
XmlTag tag = ((XmlFile)getFile()).getRootTag();
assertNotNull(tag);
XmlElementDescriptor descriptor = tag.getDescriptor();
assertNotNull(descriptor);
XmlElementDescriptor[] descriptors = descriptor.getElementsDescriptors(tag);
Map<String, XmlElementDescriptor> map =
ContainerUtil.newMapFromValues(Arrays.asList(descriptors).iterator(), new Convertor<XmlElementDescriptor, String>() {
@Override
public String convert(XmlElementDescriptor o) {
return o.getName();
}
});
map.put(tag.getName(), tag.getDescriptor());
return map;
}
示例6: getElementDescriptor
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Nullable
@Override
public XmlElementDescriptor getElementDescriptor(@NotNull XmlTag tag) {
final String name = tag.getName();
if (tag.getName().equals(FxmlConstants.FX_ROOT)) {
return new JavaFxDefaultPropertyElementDescriptor(name, tag);
}
final XmlTag parentTag = tag.getParentTag();
if (parentTag != null) {
final XmlElementDescriptor descriptor = parentTag.getDescriptor();
if (descriptor != null) {
return descriptor.getElementDescriptor(tag, parentTag);
}
}
return new JavaFxClassBackedElementDescriptor(name, tag);
}
示例7: visitXmlTag
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Override
public void visitXmlTag(XmlTag tag) {
super.visitXmlTag(tag);
if (tag.getNamespace().isEmpty()) {
final XmlElementDescriptor descriptor = tag.getDescriptor();
if (descriptor instanceof AndroidAnyTagDescriptor) {
final XmlToken startTagNameElement = XmlTagUtil.getStartTagNameElement(tag);
if (startTagNameElement != null && !isUnknownCustomView(tag)) {
myResult.add(myInspectionManager.createProblemDescriptor(startTagNameElement, XmlErrorMessages.message(
"element.is.not.allowed.here", tag.getName()), myOnTheFly, LocalQuickFix.EMPTY_ARRAY,
ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
}
final XmlToken endTagNameElement = XmlTagUtil.getEndTagNameElement(tag);
if (endTagNameElement != null && !isUnknownCustomView(tag)) {
myResult.add(myInspectionManager.createProblemDescriptor(endTagNameElement, XmlErrorMessages.message(
"element.is.not.allowed.here", tag.getName()), myOnTheFly, LocalQuickFix.EMPTY_ARRAY,
ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
}
}
}
}
示例8: checkClass
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
private static PsiClass checkClass(XmlTag tag) {
if (tag != null) {
final XmlElementDescriptor descriptor = tag.getDescriptor();
if (descriptor instanceof JavaFxClassBackedElementDescriptor) {
final PsiElement declaration = descriptor.getDeclaration();
if (declaration instanceof PsiClass) {
return (PsiClass)declaration;
}
} else if (descriptor instanceof JavaFxDefaultPropertyElementDescriptor) {
final XmlTag includedRoot = JavaFxDefaultPropertyElementDescriptor.getIncludedRoot(tag);
if (includedRoot != null && !includedRoot.equals(tag)) {
return checkClass(includedRoot);
}
}
}
return null;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:JavaFxUnresolvedFxIdReferenceInspection.java
示例9: 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));
}
}
}
}
};
}
示例10: isAvailable
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
if (element instanceof XmlToken && ((XmlToken)element).getTokenType() == XmlTokenType.XML_NAME && element.getParent() instanceof XmlTag) {
final XmlTag tag = (XmlTag)element.getParent();
for (XmlTag xmlTag : tag.getSubTags()) {
if (xmlTag.getAttribute(FxmlConstants.FX_VALUE) == null) return false;
}
final XmlTag parentTag = tag.getParentTag();
if (parentTag != null &&
tag.getDescriptor() instanceof JavaFxPropertyElementDescriptor &&
parentTag.getDescriptor() instanceof JavaFxClassBackedElementDescriptor) {
setText("Collapse tag '" + tag.getName() + "' to attribute");
return true;
}
}
return false;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:JavaFxCollapseSubTagToAttributeIntention.java
示例11: getAttributeDescriptor
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Nullable
@Override
public XmlAttributeDescriptor getAttributeDescriptor(@NonNls String attributeName, @Nullable XmlTag context) {
final List<String> defaultAttributeList = FxmlConstants.FX_ELEMENT_ATTRIBUTES.get(getName());
if (defaultAttributeList != null) {
if (defaultAttributeList.contains(attributeName)) {
return new JavaFxDefaultAttributeDescriptor(attributeName, getName());
}
final PsiMethod propertySetter = JavaFxPsiUtil.findPropertySetter(attributeName, context);
if (propertySetter != null) {
return new JavaFxStaticPropertyAttributeDescriptor(propertySetter, attributeName);
}
final XmlTag referencedTag = getReferencedTag(myXmlTag);
if (referencedTag != null) {
final XmlElementDescriptor referencedDescriptor = referencedTag.getDescriptor();
if (referencedDescriptor != null) {
return referencedDescriptor.getAttributeDescriptor(attributeName, referencedTag);
}
}
final JavaFxClassBackedElementDescriptor rootTagDescriptor = getRootTagDescriptor(context);
if (rootTagDescriptor != null) {
return rootTagDescriptor.getAttributeDescriptor(attributeName, context);
}
if (context != null && FxmlConstants.FX_INCLUDE.equals(getName())) {
final XmlTag includedRoot = getIncludedRoot(context);
if (includedRoot != null) {
final XmlElementDescriptor includedRootDescriptor = includedRoot.getDescriptor();
if (includedRootDescriptor != null) {
return includedRootDescriptor.getAttributeDescriptor(attributeName, includedRoot);
}
}
}
}
return null;
}
示例12: getAttributeDescriptors
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Override
public XmlAttributeDescriptor[] getAttributeDescriptors(XmlTag xmlTag) {
final Project project = xmlTag.getProject();
CatberryProjectConfigurationManager manager = CatberryProjectConfigurationManager.getInstance(project);
if (manager.isCatberryEnabled() && (xmlTag.getDescriptor() instanceof CatberryComponentTagDescriptor)) {
return new CatberryAttributeDescriptor[] {new CatberryAttributeDescriptor(project, "cat-store")};
}
return XmlAttributeDescriptor.EMPTY;
}
示例13: collectParentStaticProperties
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
private static <T> void collectParentStaticProperties(XmlTag context, List<T> children, Function<PsiMethod, T> factory) {
XmlTag tag = context;
while (tag != null) {
final XmlElementDescriptor descr = tag.getDescriptor();
if (descr instanceof JavaFxClassBackedElementDescriptor) {
final PsiElement element = descr.getDeclaration();
if (element instanceof PsiClass) {
final List<PsiMethod> setters = CachedValuesManager.getCachedValue(element, new CachedValueProvider<List<PsiMethod>>() {
@Nullable
@Override
public Result<List<PsiMethod>> compute() {
final List<PsiMethod> meths = new ArrayList<PsiMethod>();
for (PsiMethod method : ((PsiClass)element).getAllMethods()) {
if (method.hasModifierProperty(PsiModifier.STATIC) && method.getName().startsWith("set")) {
final PsiParameter[] parameters = method.getParameterList().getParameters();
if (parameters.length == 2 &&
InheritanceUtil.isInheritor(parameters[0].getType(), JavaFxCommonClassNames.JAVAFX_SCENE_NODE)) {
meths.add(method);
}
}
}
return Result.create(meths, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
}
});
for (PsiMethod setter : setters) {
children.add(factory.fun(setter));
}
}
}
tag = tag.getParentTag();
}
}
示例14: checkAttribute
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Override
protected void checkAttribute(@NotNull final XmlAttribute attribute, @NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
final XmlTag tag = attribute.getParent();
if (tag instanceof HtmlTag) {
XmlElementDescriptor elementDescriptor = tag.getDescriptor();
if (elementDescriptor == null || elementDescriptor instanceof AnyXmlElementDescriptor) {
return;
}
XmlAttributeDescriptor attributeDescriptor = elementDescriptor.getAttributeDescriptor(attribute);
if (attributeDescriptor == null && !attribute.isNamespaceDeclaration()) {
final String name = attribute.getName();
if (!XmlUtil.attributeFromTemplateFramework(name, tag) && (!isCustomValuesEnabled() || !isCustomValue(name))) {
boolean maySwitchToHtml5 = HtmlUtil.isCustomHtml5Attribute(name) && !HtmlUtil.hasNonHtml5Doctype(tag);
LocalQuickFix[] quickfixes = new LocalQuickFix[maySwitchToHtml5 ? 3 : 2];
quickfixes[0] = new AddCustomHtmlElementIntentionAction(ATTRIBUTE_KEY, name, XmlBundle.message("add.custom.html.attribute", name));
quickfixes[1] = new RemoveAttributeIntentionAction(name);
if (maySwitchToHtml5) {
quickfixes[2] = new SwitchToHtml5WithHighPriorityAction();
}
registerProblemOnAttributeName(attribute, XmlErrorMessages.message("attribute.is.not.allowed.here", attribute.getName()), holder,
quickfixes);
}
}
}
}
示例15: shouldBeQualified
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
private boolean shouldBeQualified(String targetNs, XmlTag contextTag) {
boolean attributeShouldBeQualified = false;
String contextNs = contextTag.getNamespace();
if (!contextNs.equals(targetNs)) {
final XmlElementDescriptor xmlElementDescriptor = contextTag.getDescriptor();
if (xmlElementDescriptor instanceof XmlElementDescriptorImpl) {
final XmlElementDescriptorImpl elementDescriptor = (XmlElementDescriptorImpl)xmlElementDescriptor;
final TypeDescriptor type = elementDescriptor.getType();
if (type instanceof ComplexTypeDescriptor) {
final ComplexTypeDescriptor typeDescriptor = (ComplexTypeDescriptor)type;
if (myReferenceName != null) {
return myReferenceName.indexOf(':') != 0;
}
XmlAttributeDescriptor[] attributes = ((ComplexTypeDescriptor)type).getAttributes(contextTag);
if (ArrayUtil.contains(this, attributes)) {
return false;
}
attributeShouldBeQualified = typeDescriptor.canContainAttribute(targetNs, null) != ComplexTypeDescriptor.CanContainAttributeType.CanNotContain;
}
if (!attributeShouldBeQualified && contextNs.length() == 0 && targetNs.length() > 0) {
attributeShouldBeQualified = !targetNs.equals(elementDescriptor.getNamespace());
}
}
}
return attributeShouldBeQualified;
}