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


Java DomUtil.getParentOfType方法代码示例

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


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

示例1: getPsiType

import com.intellij.util.xml.DomUtil; //导入方法依赖的package包/类
@NotNull
protected PsiType getPsiType(final ConvertContext context) {
  final Resource resource;
  final EjbReference ejbReference;
  final ServiceRef serviceReference;
  final PsiClass aClass;
  if ((resource = DomUtil.getParentOfType(context.getInvocationElement(), Resource.class, false)) != null) {
    aClass = resource.getType().getValue();
  }
  else if ((ejbReference = DomUtil.getParentOfType(context.getInvocationElement(), EjbReference.class, false)) != null) {
    aClass = ejbReference.getBeanInterface().getValue();
  }
  else if ((serviceReference = DomUtil.getParentOfType(context.getInvocationElement(), ServiceRef.class, false)) != null) {
    aClass = serviceReference.getServiceInterface().getValue();
  }
  else {
    aClass = null;
  }
  return aClass == null? super.getPsiType(context) : JavaPsiFacade.getInstance(aClass.getProject()).getElementFactory().createType(aClass);
}
 
开发者ID:consulo,项目名称:consulo-javaee,代码行数:21,代码来源:EjbInjectionTargetConverter.java

示例2: getVariants

import com.intellij.util.xml.DomUtil; //导入方法依赖的package包/类
@NotNull
@Override
public Collection<? extends FieldExpression> getVariants(ConvertContext context) {
  FieldDefinition fieldDefinition = DomUtil.getParentOfType(context.getInvocationElement(), FieldDefinition.class, false);
  FieldExpression expression = fieldDefinition.getValue();
  if (expression != null) {
    return expression.suggestVariants();
  }
  else {
    return Collections.emptyList();
  }
}
 
开发者ID:hypoport,项目名称:idea-dozer-plugin,代码行数:13,代码来源:FieldExpressionConverter.java

示例3: getVariants

import com.intellij.util.xml.DomUtil; //导入方法依赖的package包/类
@NotNull
@Override
public Collection<? extends PsiMethod> getVariants(ConvertContext context) {
  if (context.getInvocationElement() instanceof Class == false) {
    return Collections.emptyList();
  }
  Class clazz = (Class) context.getInvocationElement();

  Mapping mapping = DomUtil.getParentOfType(clazz, Mapping.class, false);
  if (mapping == null) {
    return Collections.emptyList();
  }

  PsiClass mappedClass;
  if (clazz.getXmlElementName().equals("a")) {
    mappedClass = mapping.getClassA().getValue();
  }
  else {
    mappedClass = mapping.getClassB().getValue();
  }

  if (mappedClass == null) {
    return Collections.emptyList();
  }

  return Collections.emptyList();
}
 
开发者ID:hypoport,项目名称:idea-dozer-plugin,代码行数:28,代码来源:SetMethodConverter.java

示例4: findClassElementForField

import com.intellij.util.xml.DomUtil; //导入方法依赖的package包/类
/**
 * Returns the related class-X-element for a field-definition.
 *
 * @param fieldDefinition
 *
 * @return
 */
public static Class findClassElementForField(FieldDefinition fieldDefinition) {
  Mapping mapping = DomUtil.getParentOfType(fieldDefinition, Mapping.class, true);

  if (mapping == null) {
    return null;
  }

  if (fieldDefinition.getXmlTag().getLocalName().equals("a")) { //$NON-NLS-1$
    return mapping.getClassA();
  }
  else {
    return mapping.getClassB();
  }
}
 
开发者ID:hypoport,项目名称:idea-dozer-plugin,代码行数:22,代码来源:PsiUtil.java

示例5: getSuggestions

import com.intellij.util.xml.DomUtil; //导入方法依赖的package包/类
private String[] getSuggestions(int level) {
  Collection<String> result = new THashSet<String>();

  String value = mySelectedString.trim();
  boolean addUnqualifiedForm = true;

  XmlTag parent = PsiTreeUtil.getParentOfType(myContext, XmlTag.class, false);

  DomElement domParent = DomUtil.getDomElement(parent);
  if (domParent != null) {
    DomElement domSuperParent = domParent.getParent();
    DomFileElement<DomElement> domFile = DomUtil.getFileElement(domParent);
    if (domSuperParent != null && domFile != null && domFile.getRootElement() == domSuperParent) {
      value = domSuperParent.getXmlElementName();
      addUnqualifiedForm = false;
    }
    else {
      MavenDomShortArtifactCoordinates coordinates = DomUtil.getParentOfType(domParent, MavenDomShortArtifactCoordinates.class, false);
      if (coordinates != null && !(coordinates instanceof MavenDomProjectModel) && domParent != coordinates.getArtifactId()) {
        String artifactId = coordinates.getArtifactId().getStringValue();
        if (!StringUtil.isEmptyOrSpaces(artifactId)) {
          value = artifactId;
          addUnqualifiedForm = false;
        }
      }
    }
  }

  while (true) {
    String newValue = value.replaceAll("  ", " ");
    if (newValue.equals(value)) break;
    value = newValue;
  }

  value = value.replaceAll(" ", ".");
  List<String> parts = StringUtil.split(value, ".");
  String shortValue = parts.get(parts.size() - 1);

  if (addUnqualifiedForm) {
    result.add(value);
    result.add(shortValue);
  }

  String suffix = "";
  while (parent != null && level != 0) {
    suffix = parent.getName() + suffix;
    result.add(suffix);
    result.add(value + "." + suffix);
    result.add(shortValue + "." + suffix);
    suffix = "." + suffix;
    parent = parent.getParentTag();
    level--;
  }

  result = new ArrayList<String>(result);
  Collections.sort((List)result, CodeStyleSettingsManager.getSettings(myProject).PREFER_LONGER_NAMES ?
                                 StringLenComparator.getDescendingInstance() : StringLenComparator.getInstance());
  return ArrayUtil.toStringArray(result);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:60,代码来源:IntroducePropertyDialog.java

示例6: checkDefaultBundle

import com.intellij.util.xml.DomUtil; //导入方法依赖的package包/类
private static void checkDefaultBundle(DomElement element, ProblemsHolder holder) {
  IdeaPlugin plugin = DomUtil.getParentOfType(element, IdeaPlugin.class, true);
  if (plugin != null && plugin.getResourceBundles().isEmpty()) {
    registerProblem(element, holder, "Bundle should be specified");
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:InspectionMappingConsistencyInspection.java

示例7: parseExpression

import com.intellij.util.xml.DomUtil; //导入方法依赖的package包/类
private FieldExpression parseExpression(String expr, ConvertContext context) {
  FieldDefinition fieldDefinition = DomUtil.getParentOfType(context.getInvocationElement(), FieldDefinition.class, false);
  return new FieldExpression(fieldDefinition, expr);
}
 
开发者ID:hypoport,项目名称:idea-dozer-plugin,代码行数:5,代码来源:FieldExpressionConverter.java

示例8: getClass

import com.intellij.util.xml.DomUtil; //导入方法依赖的package包/类
private Class getClass(ConvertContext context) {
  return DomUtil.getParentOfType(context.getInvocationElement(), Class.class, true);
}
 
开发者ID:hypoport,项目名称:idea-dozer-plugin,代码行数:4,代码来源:ClassCreateMethodConverter.java


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