本文整理汇总了Java中com.intellij.psi.util.PsiUtil.hasDefaultConstructor方法的典型用法代码示例。如果您正苦于以下问题:Java PsiUtil.hasDefaultConstructor方法的具体用法?Java PsiUtil.hasDefaultConstructor怎么用?Java PsiUtil.hasDefaultConstructor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.util.PsiUtil
的用法示例。
在下文中一共展示了PsiUtil.hasDefaultConstructor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: seemsLikeLambda
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
private static boolean seemsLikeLambda(@Nullable final PsiClass baseClass) {
return baseClass != null && PsiUtil.hasDefaultConstructor(baseClass, true);
}
示例2: checkExtendClass
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@NotNull
public static List<DomElementProblemDescriptor> checkExtendClass(final GenericDomValue element, final PsiClass value, final String name,
final boolean instantiatable, final boolean canBeDecorator, final boolean allowInterface,
final boolean allowNonPublic,
final boolean allowAbstract,
final boolean allowEnum,
final DomElementAnnotationHolder holder) {
final Project project = element.getManager().getProject();
PsiClass extendClass = JavaPsiFacade.getInstance(project).findClass(name, GlobalSearchScope.allScope(project));
final SmartList<DomElementProblemDescriptor> list = new SmartList<DomElementProblemDescriptor>();
if (extendClass != null) {
if (!name.equals(value.getQualifiedName()) && !value.isInheritor(extendClass, true)) {
String message = DomBundle.message("class.is.not.a.subclass", value.getQualifiedName(), extendClass.getQualifiedName());
list.add(holder.createProblem(element, message));
}
}
if (instantiatable) {
if (value.hasModifierProperty(PsiModifier.ABSTRACT)) {
list.add(holder.createProblem(element, DomBundle.message("class.is.not.concrete", value.getQualifiedName())));
}
else if (!allowNonPublic && !value.hasModifierProperty(PsiModifier.PUBLIC)) {
list.add(holder.createProblem(element, DomBundle.message("class.is.not.public", value.getQualifiedName())));
}
else if (!PsiUtil.hasDefaultConstructor(value, true)) {
if (canBeDecorator) {
boolean hasConstructor = false;
for (PsiMethod method : value.getConstructors()) {
final PsiParameterList psiParameterList = method.getParameterList();
if (psiParameterList.getParametersCount() != 1) continue;
PsiTypeElement typeElement = psiParameterList.getParameters()[0].getTypeElement();
if (typeElement != null) {
final PsiType psiType = typeElement.getType();
if (psiType instanceof PsiClassType) {
final PsiClass psiClass = ((PsiClassType)psiType).resolve();
if (psiClass != null && InheritanceUtil.isInheritorOrSelf(psiClass, extendClass, true)) {
hasConstructor = true;
break;
}
}
}
}
if (!hasConstructor) {
list.add(holder.createProblem(element, DomBundle.message("class.decorator.or.has.default.constructor", value.getQualifiedName())));
}
}
else {
list.add(holder.createProblem(element, DomBundle.message("class.has.no.default.constructor", value.getQualifiedName())));
}
}
}
if (!allowInterface && value.isInterface()) {
list.add(holder.createProblem(element, DomBundle.message("interface.not.allowed", value.getQualifiedName())));
}
if (!allowEnum && value.isEnum()) {
list.add(holder.createProblem(element, DomBundle.message("enum.not.allowed", value.getQualifiedName())));
}
if (!allowAbstract && value.hasModifierProperty(PsiModifier.ABSTRACT) && !value.isInterface()) {
list.add(holder.createProblem(element, DomBundle.message("abstract.class.not.allowed", value.getQualifiedName())));
}
return list;
}
示例3: hasDefaultConstructor
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
public static boolean hasDefaultConstructor(PsiType type) {
final PsiClass psiClass = PsiUtil.resolveClassInType(type);
return psiClass != null && PsiUtil.hasDefaultConstructor(psiClass, true, false);
}