当前位置: 首页>>代码示例>>Java>>正文


Java XmlAttributeDescriptor.getDeclaration方法代码示例

本文整理汇总了Java中com.intellij.xml.XmlAttributeDescriptor.getDeclaration方法的典型用法代码示例。如果您正苦于以下问题:Java XmlAttributeDescriptor.getDeclaration方法的具体用法?Java XmlAttributeDescriptor.getDeclaration怎么用?Java XmlAttributeDescriptor.getDeclaration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.xml.XmlAttributeDescriptor的用法示例。


在下文中一共展示了XmlAttributeDescriptor.getDeclaration方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getReferencesByElement

import com.intellij.xml.XmlAttributeDescriptor; //导入方法依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element,
                                             @NotNull ProcessingContext context) {
  final XmlAttributeValue attributeValue = (XmlAttributeValue)element;
  final PsiElement parent = attributeValue.getParent();
  if (parent instanceof XmlAttribute) {
    final XmlAttributeDescriptor descriptor = ((XmlAttribute)parent).getDescriptor();
    if (descriptor instanceof JavaFxPropertyAttributeDescriptor) {
      final PsiElement declaration = descriptor.getDeclaration();
      if (declaration instanceof PsiField) {
        final PsiField field = (PsiField)declaration;
        final PsiClassType propertyClassType = JavaFxPsiUtil.getPropertyClassType(field);
        if (propertyClassType != null && InheritanceUtil.isInheritor(propertyClassType, JavaFxCommonClassNames.JAVAFX_SCENE_PAINT)) {
          return new PsiReference[] {new JavaFxColorReference(attributeValue)};
        }
      }
    }
  }
  return PsiReference.EMPTY_ARRAY;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:JavaFxColorReferenceProvider.java

示例2: isOwnHtmlAttribute

import com.intellij.xml.XmlAttributeDescriptor; //导入方法依赖的package包/类
public static boolean isOwnHtmlAttribute(XmlAttributeDescriptor descriptor) {
  // common html attributes are defined mostly in common.rnc, core-scripting.rnc, etc
  // while own tag attributes are defined in meta.rnc
  final PsiElement declaration = descriptor.getDeclaration();
  final PsiFile file = declaration != null ? declaration.getContainingFile() : null;
  final String name = file != null ? file.getName() : null;
  return "meta.rnc".equals(name);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:HtmlUtil.java

示例3: visitXmlAttribute

import com.intellij.xml.XmlAttributeDescriptor; //导入方法依赖的package包/类
@Override
public void visitXmlAttribute(XmlAttribute attribute) {
  final XmlAttributeDescriptor descriptor = attribute.getDescriptor();
  if (descriptor instanceof JavaFxStaticPropertyAttributeDescriptor) {
    final PsiElement declaration = descriptor.getDeclaration();
    if (declaration instanceof PsiMember) {
      appendClassName(((PsiMember)declaration).getContainingClass());
    }
  }
  else if (descriptor instanceof JavaFxDefaultAttributeDescriptor && FxmlConstants.TYPE.equals(descriptor.getName())) {
    appendClassName(JavaFxPsiUtil.findPsiClass(attribute.getValue(), attribute));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:JavaFxImportsOptimizer.java

示例4: invoke

import com.intellij.xml.XmlAttributeDescriptor; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
  if (!FileModificationService.getInstance().preparePsiElementsForWrite(element)) return;
  final XmlAttribute attr = (XmlAttribute)element.getParent();
  final String name = attr.getName();
  final XmlAttributeDescriptor descriptor = attr.getDescriptor();
  LOG.assertTrue(descriptor != null);
  String value = attr.getValue();
  final PsiElement declaration = descriptor.getDeclaration();
  if (declaration instanceof PsiField) {
    final PsiType fieldType = ((PsiField)declaration).getType();
    final PsiType itemType = JavaGenericsUtil.getCollectionItemType(fieldType, declaration.getResolveScope());
    if (itemType != null) {
      final String typeNode = itemType.getPresentableText();
      JavaFxPsiUtil.insertImportWhenNeeded((XmlFile)attr.getContainingFile(), typeNode, itemType.getCanonicalText());
      final String[] vals = value.split(",");
      value = StringUtil.join(vals, new Function<String, String>() {
        @Override
        public String fun(String s) {
          return "<" + typeNode + " " + FxmlConstants.FX_VALUE + "=\"" + s.trim() + "\"/>";
        }
      }, "\n");
    }
  }
  final XmlTag childTag = XmlElementFactory.getInstance(project).createTagFromText("<" + name + ">" + value + "</" + name + ">");
  attr.getParent().add(childTag);
  attr.delete();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:JavaFxExpandAttributeIntention.java

示例5: isAvailable

import com.intellij.xml.XmlAttributeDescriptor; //导入方法依赖的package包/类
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
  if (element instanceof XmlToken && ((XmlToken)element).getTokenType() == XmlTokenType.XML_NAME) {
    final PsiElement parent = element.getParent();
    if (parent instanceof XmlAttribute) {
      final XmlAttributeDescriptor descriptor = ((XmlAttribute)parent).getDescriptor();
      if (descriptor instanceof JavaFxPropertyAttributeDescriptor && !(descriptor instanceof JavaFxDefaultAttributeDescriptor)) {

        PsiType tagType = null;
        final PsiElement declaration = descriptor.getDeclaration();
        if (declaration instanceof PsiField) {
          tagType = ((PsiField)declaration).getType();
        } else if (declaration instanceof PsiMethod) {
          final PsiParameter[] parameters = ((PsiMethod)declaration).getParameterList().getParameters();
          if (parameters.length == 1) {
            tagType = parameters[0].getType();
          }
        }
        PsiClass tagClass = PsiUtil.resolveClassInType(tagType instanceof PsiPrimitiveType ? ((PsiPrimitiveType)tagType).getBoxedType(parent) : tagType);
        if ((tagClass != null && JavaFxPsiUtil.isAbleToInstantiate(tagClass) == null) || descriptor instanceof JavaFxStaticPropertyAttributeDescriptor) {
          setText("Expand '" + ((XmlAttribute)parent).getName() + "' to tag");
          return true;
        }
      }
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:JavaFxExpandAttributeIntention.java

示例6: getVariants

import com.intellij.xml.XmlAttributeDescriptor; //导入方法依赖的package包/类
@NotNull
@Override
public Object[] getVariants() {
  final PsiElement parent = getElement().getParent();
  if (parent instanceof XmlAttribute) {
    final XmlAttributeDescriptor descriptor = ((XmlAttribute)parent).getDescriptor();
    if (descriptor != null) {
      final PsiElement declaration = descriptor.getDeclaration();
      if (declaration instanceof PsiField) {
        return collectProperties((PsiField)declaration);
      }
    }
  }
  return ArrayUtil.EMPTY_OBJECT_ARRAY;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:JavaFxComponentIdReferenceProvider.java

示例7: resolve

import com.intellij.xml.XmlAttributeDescriptor; //导入方法依赖的package包/类
@Override
public PsiElement resolve() {
  final XmlAttributeDescriptor descriptor = getDescriptor();
  return descriptor != null ? descriptor.getDeclaration() : null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:XmlAttributeReference.java


注:本文中的com.intellij.xml.XmlAttributeDescriptor.getDeclaration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。