本文整理汇总了Java中com.intellij.util.xml.DomElement.getParentOfType方法的典型用法代码示例。如果您正苦于以下问题:Java DomElement.getParentOfType方法的具体用法?Java DomElement.getParentOfType怎么用?Java DomElement.getParentOfType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.xml.DomElement
的用法示例。
在下文中一共展示了DomElement.getParentOfType方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: annotate
import com.intellij.util.xml.DomElement; //导入方法依赖的package包/类
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder holder) {
if (psiElement instanceof XmlTag) {
final DomElement element = DomManager.getDomManager(psiElement.getProject()).getDomElement((XmlTag)psiElement);
if (element instanceof MavenDomDependency) {
if (element.getParentOfType(MavenDomPlugin.class, true) != null) return;
MavenDomDependency dependency = (MavenDomDependency)element;
if (isDependencyManagementSection(dependency)) {
annotateDependencyUsages(dependency, holder);
}
else {
annotateManagedDependency(dependency, holder);
}
}
else if (element instanceof MavenDomParent) {
annotateMavenDomParent((MavenDomParent)element, holder);
}
else if (element instanceof MavenDomProjectModel) {
annotateMavenDomProjectChildren((MavenDomProjectModel)element, holder);
}
else if (element instanceof MavenDomPlugin) {
annotateMavenDomPlugin((MavenDomPlugin)element, holder);
}
}
}
示例2: getElementText
import com.intellij.util.xml.DomElement; //导入方法依赖的package包/类
@Override
public String getElementText(XmlTag tag) {
DomElement domElement = DomManager.getDomManager(tag.getProject()).getDomElement(tag);
if (domElement != null) {
MavenDomProjectModel model = domElement.getParentOfType(MavenDomProjectModel.class, false);
if (model != null) {
MavenProject mavenProject = MavenDomUtil.findProject(model);
if (mavenProject != null) return mavenProject.getDisplayName();
String name = model.getName().getStringValue();
if (!StringUtil.isEmptyOrSpaces(name)) {
return name;
}
}
}
return tag.getContainingFile().getName();
}
示例3: resolve
import com.intellij.util.xml.DomElement; //导入方法依赖的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;
}
示例4: canNavigate
import com.intellij.util.xml.DomElement; //导入方法依赖的package包/类
@Override
public boolean canNavigate(DomElement element) {
final Class<DomElement> aClass = (Class<DomElement>)ReflectionUtil.getRawType(myChildDescription.getType());
final DomElement domElement = element.getParentOfType(aClass, false);
return domElement != null && myCollectionElements.contains(domElement);
}
示例5: navigate
import com.intellij.util.xml.DomElement; //导入方法依赖的package包/类
@Override
public void navigate(DomElement element) {
final Class<DomElement> aClass = (Class<DomElement>)ReflectionUtil.getRawType(myChildDescription.getType());
final DomElement domElement = element.getParentOfType(aClass, false);
int index = myCollectionElements.indexOf(domElement);
if (index < 0) index = 0;
myCollectionPanel.getTable().setRowSelectionInterval(index, index);
}
示例6: getMavenPluginModel
import com.intellij.util.xml.DomElement; //导入方法依赖的package包/类
@Nullable
public static MavenDomPluginModel getMavenPluginModel(DomElement element) {
Project project = element.getManager().getProject();
MavenDomPlugin pluginElement = element.getParentOfType(MavenDomPlugin.class, false);
if (pluginElement == null) return null;
String groupId = pluginElement.getGroupId().getStringValue();
String artifactId = pluginElement.getArtifactId().getStringValue();
String version = pluginElement.getVersion().getStringValue();
return getMavenPluginModel(project, groupId, artifactId, version);
}
示例7: getDependency
import com.intellij.util.xml.DomElement; //导入方法依赖的package包/类
@Nullable
private static MavenDomDependency getDependency(PsiFile file, Editor editor) {
PsiElement el = PsiUtilCore.getElementAtOffset(file, editor.getCaretModel().getOffset());
XmlTag tag = PsiTreeUtil.getParentOfType(el, XmlTag.class, false);
if (tag == null) return null;
DomElement dom = DomManager.getDomManager(el.getProject()).getDomElement(tag);
if (dom == null) return null;
return dom.getParentOfType(MavenDomDependency.class, false);
}
示例8: addMacrodefParameterRefs
import com.intellij.util.xml.DomElement; //导入方法依赖的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;
}
}
示例9: getHostingAntDomElement
import com.intellij.util.xml.DomElement; //导入方法依赖的package包/类
@Nullable
private AntDomElement getHostingAntDomElement() {
final DomElement selfElement = DomUtil.getDomElement(getElement());
if (selfElement == null) {
return null;
}
return selfElement.getParentOfType(AntDomElement.class, false);
}
示例10: getParentMacrodef
import com.intellij.util.xml.DomElement; //导入方法依赖的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);
}
示例11: computeString
import com.intellij.util.xml.DomElement; //导入方法依赖的package包/类
@NotNull
public static String computeString(@NotNull final DomElement context, @NotNull String valueString) {
PropertyExpander expander = new PropertyExpander(valueString);
if (!expander.hasPropertiesToExpand()) {
return valueString;
}
final Map<String, String> cached = RESOLVED_STRINGS_MAP_KEY.get(context);
if (cached != null) {
expander.acceptProvider(new CachedPropertiesProvider(cached));
if (!expander.hasPropertiesToExpand()) {
return expander.getResult();
}
}
expander.setPropertyExpansionListener(new PropertyExpander.PropertyExpansionListener() {
public void onPropertyExpanded(String propName, String propValue) {
cacheResult(context, RESOLVED_STRINGS_MAP_KEY, propName, propValue);
}
});
AntDomProject project = context.getParentOfType(AntDomProject.class, false);
if (project == null) {
return expander.getResult();
}
project = project.getContextAntProject();
new AntStringResolver(context, expander).execute(project, project.getDefaultTarget().getRawText());
return expander.getResult();
}
示例12: visitXmlTag
import com.intellij.util.xml.DomElement; //导入方法依赖的package包/类
public void visitXmlTag(XmlTag tag) {
final PsiFile file = tag.getContainingFile();
if (file.getFileType() != StdFileTypes.XML) {
return;
}
if (!tag.getLocalName().equals("define")) {
return;
}
if (!tag.getNamespace().equals(ApplicationLoader.RNG_NAMESPACE)) {
return;
}
if (tag.getAttribute("combine") != null) {
return; // ?
}
final XmlAttribute attr = tag.getAttribute("name");
if (attr == null) return;
final XmlAttributeValue value = attr.getValueElement();
if (value == null) return;
final String s = value.getValue();
if (s == null || s.length() == 0) {
return;
}
final PsiElement parent = value.getParent();
if (!(parent instanceof XmlAttribute)) {
return;
}
if (!"name".equals(((XmlAttribute)parent).getName())) {
return;
}
final PsiElement grandParent = parent.getParent();
if (!(grandParent instanceof XmlTag)) {
return;
}
final DomElement element = DomManager.getDomManager(tag.getProject()).getDomElement(tag);
if (element == null) {
return;
}
final RngGrammar rngGrammar = element.getParentOfType(RngGrammar.class, true);
if (rngGrammar != null) {
if (processUsages(tag, value, new LocalSearchScope(rngGrammar.getXmlTag()))) return;
} else {
if (processUsages(tag, value, new LocalSearchScope(file))) return;
}
final PsiElementProcessor.CollectElements<XmlFile> collector = new PsiElementProcessor.CollectElements<XmlFile>();
RelaxIncludeIndex.processBackwardDependencies((XmlFile)file, collector);
if (processUsages(tag, value, new LocalSearchScope(collector.toArray()))) return;
myHolder.registerProblem(value, "Unreferenced define", ProblemHighlightType.LIKE_UNUSED_SYMBOL, new MyFix<XmlTag>(tag));
}
示例13: PropertyProviderFinder
import com.intellij.util.xml.DomElement; //导入方法依赖的package包/类
protected PropertyProviderFinder(DomElement contextElement) {
myContextElement = contextElement != null? contextElement.getParentOfType(AntDomElement.class, false) : null;
}