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


Java DomUtil.getDomElement方法代码示例

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


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

示例1: resolve

import com.intellij.util.xml.DomUtil; //导入方法依赖的package包/类
public PsiElement resolve(@NotNull PsiReference psiReference, boolean incompleteCode) {
  final PsiElement element = psiReference.getElement();
  if (element == null) {
    return null;
  }
  final DomElement domElement = DomUtil.getDomElement(element);
  if (domElement == null) {
    return null;
  }
  final AntDomMacroDef macrodef = domElement.getParentOfType(AntDomMacroDef.class, false);
  if (macrodef == null) {
    return null;
  }
  final String name = AntStringResolver.computeString(domElement, psiReference.getCanonicalText());
  for (AntDomMacrodefAttribute attribute : macrodef.getMacroAttributes()) {
    if (name.equals(attribute.getName().getStringValue())) {
      final DomTarget target = DomTarget.getTarget(attribute);
      return target != null? PomService.convertToPsi(target) : null;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:AntDomMacrodefAttributeReference.java

示例2: isSuppressedFor

import com.intellij.util.xml.DomUtil; //导入方法依赖的package包/类
@Override
public boolean isSuppressedFor(@NotNull PsiElement element, @NotNull String name) {
  DomElement domElement = DomUtil.getDomElement(element);
  if (domElement != null) {
    if (domElement.getAnnotation(NoSpellchecking.class) != null) {
      return true;
    }
  }

  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:XmlSpellcheckingStrategy.java

示例3: toDomElement

import com.intellij.util.xml.DomUtil; //导入方法依赖的package包/类
@Nullable 
public static DomElement toDomElement(PsiElement resolve) {
  if (resolve instanceof PomTargetPsiElement) {
    final PomTarget target = ((PomTargetPsiElement)resolve).getTarget();
    if(target instanceof DomTarget) {
      return ((DomTarget)target).getDomElement();
    }
    return null;
  }
  return DomUtil.getDomElement(resolve);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:AntDomReferenceBase.java

示例4: addMacrodefParameterRefs

import com.intellij.util.xml.DomUtil; //导入方法依赖的package包/类
public static void addMacrodefParameterRefs(@NotNull XmlAttributeValue element, final Collection<PsiReference> refs) {
  final DomElement domElement = DomUtil.getDomElement(element);
  if (domElement == null) {
    return;
  }
  final AntDomMacroDef macrodef = domElement.getParentOfType(AntDomMacroDef.class, true);
  if (macrodef == null) {
    return;
  }
  final String text = ElementManipulators.getValueText(element);
  final int valueBeginingOffset = Math.abs(element.getTextRange().getStartOffset() - element.getValueTextRange().getStartOffset());
  int startIndex;
  int endIndex = -1;
  while ((startIndex = text.indexOf("@{", endIndex + 1)) > endIndex) {
    startIndex += 2;
    endIndex = startIndex;
    int nestedBrackets = 0;
    while (text.length() > endIndex) {
      final char ch = text.charAt(endIndex);
      if (ch == '}') {
        if (nestedBrackets == 0) {
          break;
        }
        --nestedBrackets;
      }
      else if (ch == '{') {
        ++nestedBrackets;
      }
      ++endIndex;
    }
    if(nestedBrackets > 0 || endIndex == text.length()) return;
    if (endIndex >= startIndex) {
      //final String name = text.substring(startIndex, endIndex);
       refs.add(new AntDomMacrodefAttributeReference(element, new TextRange(valueBeginingOffset + startIndex, valueBeginingOffset + endIndex)));
    }
    endIndex = startIndex; 
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:AntReferenceInjector.java

示例5: getHostingAntDomElement

import com.intellij.util.xml.DomUtil; //导入方法依赖的package包/类
@Nullable 
private AntDomElement getHostingAntDomElement() {
  final DomElement selfElement = DomUtil.getDomElement(getElement());
  if (selfElement == null) {
    return null;
  }
  return selfElement.getParentOfType(AntDomElement.class, false);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:AntDomTargetReference.java

示例6: getParentMacrodef

import com.intellij.util.xml.DomUtil; //导入方法依赖的package包/类
@Nullable 
private AntDomMacroDef getParentMacrodef() {
  final PsiElement element = getElement();
  if (element == null) {
    return null;
  }
  final DomElement domElement = DomUtil.getDomElement(element);
  if (domElement == null) {
    return null;
  }
  return domElement.getParentOfType(AntDomMacroDef.class, false);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:AntDomMacrodefAttributeReference.java

示例7: testPropertyInMacrodefParam

import com.intellij.util.xml.DomUtil; //导入方法依赖的package包/类
public void testPropertyInMacrodefParam() throws Exception {
  PsiReference ref = configure();
  final PsiElement result = ref.resolve();
  assertTrue(result instanceof PomTargetPsiElement);
  final PsiElement naviElem = ((DomTarget)((PomTargetPsiElement)result).getTarget()).getNavigationElement();
  final DomElement domElement = DomUtil.getDomElement(naviElem);
  assertNotNull(domElement);
  assertNotNull(domElement.getParentOfType(AntDomMacrodefAttribute.class, false));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:AntResolveTest.java

示例8: buildVisitor

import com.intellij.util.xml.DomUtil; //导入方法依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder,
                                      boolean isOnTheFly,
                                      @NotNull LocalInspectionToolSession session) {
  return new XmlElementVisitor()  {
    @Override
    public void visitXmlTag(XmlTag tag) {
      DomElement element = DomUtil.getDomElement(tag);
      if (element instanceof Extension) {
        ExtensionPoint extensionPoint = ((Extension)element).getExtensionPoint();
        if (extensionPoint != null && InheritanceUtil.isInheritor(extensionPoint.getBeanClass().getValue(), "com.intellij.codeInspection.InspectionEP")) {
          boolean key = tag.getAttribute("key") != null;
          boolean groupKey = tag.getAttribute("groupKey") != null;
          if (key) {
            if (tag.getAttribute("bundle") == null) {
              checkDefaultBundle(element, holder);
            }
          }
          else if (tag.getAttribute("displayName") == null) {
            registerProblem(element, holder, "displayName or key should be specified", "displayName", "key");
          }
          if (groupKey) {
            if (tag.getAttribute("bundle") == null && tag.getAttribute("groupBundle") == null) {
              checkDefaultBundle(element, holder);
            }
          }
          else if (tag.getAttribute("groupName") == null) {
            registerProblem(element, holder, "groupName or groupKey should be specified", "groupName", "groupKey");
          }
        }
      }
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:InspectionMappingConsistencyInspection.java

示例9: getPluginResourceBundles

import com.intellij.util.xml.DomUtil; //导入方法依赖的package包/类
private static List<String> getPluginResourceBundles(PsiElement element) {
  final DomElement domElement = DomUtil.getDomElement(element);
  if (domElement == null) return Collections.emptyList();
  final DomElement rootElement = DomUtil.getFileElement(domElement).getRootElement();
  if (!(rootElement instanceof IdeaPlugin)) return Collections.emptyList();

  IdeaPlugin plugin = (IdeaPlugin)rootElement;
  return ContainerUtil.map(plugin.getResourceBundles(), new Function<GenericDomValue<String>, String>() {
    @Override
    public String fun(GenericDomValue<String> value) {
      return value.getStringValue();
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:PropertyKeyReferenceProvider.java

示例10: 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

示例11: findPropertiesParentTag

import com.intellij.util.xml.DomUtil; //导入方法依赖的package包/类
private static XmlTag findPropertiesParentTag(@NotNull PsiElement element) {
  DomElement domElement = DomUtil.getDomElement(element);
  return domElement instanceof MavenDomProperties ? domElement.getXmlTag() : null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:MavenPropertyPsiReferenceProvider.java

示例12: applyFix

import com.intellij.util.xml.DomUtil; //导入方法依赖的package包/类
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
  DomElement element = DomUtil.getDomElement(descriptor.getPsiElement());
  if (!(element instanceof ExtensionPoint)) {
    return;
  }
  ExtensionPoint extensionPoint = (ExtensionPoint)element;
  List<PsiField> fields = ExtensionPointBeanClassInspection.collectMissingWithTags(extensionPoint);
  PsiElement navTarget = null;
  for (PsiField field : fields) {
    With with = extensionPoint.addWith();
    String tagName = PluginFieldNameConverter.getAnnotationValue(field, Tag.class);
    if (tagName != null) {
      with.getTag().setStringValue(tagName);
    }
    else {
      String attributeName = PluginFieldNameConverter.getAttributeAnnotationValue(field);
      if (attributeName == null) {
        attributeName = field.getName();
      }
      if (attributeName.equals("forClass")) {
        continue;
      }
      with.getAttribute().setStringValue(attributeName);
    }
    String epName = extensionPoint.getName().getStringValue();
    String className = "";
    if (epName != null) {
      int pos = epName.lastIndexOf('.');
      epName = StringUtil.capitalize(pos >= 0 ? epName.substring(pos+1) : epName);
      PsiClass[] classesByName = PsiShortNamesCache.getInstance(project).getClassesByName(epName,
                                                                                          ProjectScope.getAllScope(project));
      if (classesByName.length == 1) {
        className = classesByName[0].getQualifiedName();
      }
    }
    with.getImplements().setStringValue(className);
    if (navTarget == null) {
      navTarget = with.getImplements().getXmlAttributeValue();
    }
  }
  if (navTarget != null) {
    PsiNavigateUtil.navigate(navTarget);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:46,代码来源:AddWithTagFix.java

示例13: getEPName

import com.intellij.util.xml.DomUtil; //导入方法依赖的package包/类
@Nullable
private static String getEPName(XmlTag tag) {
  final DomElement domElement = DomUtil.getDomElement(tag);
  if (!(domElement instanceof ExtensionPoint)) return null;
  return ((ExtensionPoint)domElement).getEffectiveQualifiedName();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:ExtensionPointLocator.java


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