本文整理汇总了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);
}
示例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();
}
}
示例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();
}
示例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();
}
}
示例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);
}
示例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");
}
}
示例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);
}
示例8: getClass
import com.intellij.util.xml.DomUtil; //导入方法依赖的package包/类
private Class getClass(ConvertContext context) {
return DomUtil.getParentOfType(context.getInvocationElement(), Class.class, true);
}