本文整理汇总了Java中com.intellij.psi.PsiMethod.isConstructor方法的典型用法代码示例。如果您正苦于以下问题:Java PsiMethod.isConstructor方法的具体用法?Java PsiMethod.isConstructor怎么用?Java PsiMethod.isConstructor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiMethod
的用法示例。
在下文中一共展示了PsiMethod.isConstructor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: check
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
void check(@NonNull PsiMethod method) {
if (mClass == null) return;
Debug.checkedMethod(mClass, method);
if (!mUnusedMethods.remove(method)) {
// クラス内のインナークラスや匿名クラスに無名クラスのメソッドは、対象としていません。
return;
}
if (method.isConstructor()) return;
// メソッドを関数とフィールド変数変更メソッドに分離
WriteFieldGroupMethod writeFieldGroup = new WriteFieldGroupMethod(method, mClassFields);
if (writeFieldGroup.hasWriteFields()) {
mWriteFieldGroupMethods.add(writeFieldGroup);
} else {
mFunctions.add(writeFieldGroup);
}
if (mUnusedMethods.isEmpty()) {
Debug.methodTypes(mClass, mWriteFieldGroupMethods, mFunctions);
// フィールド変数変更メソッドのグループ分け開始
parse();
clean();
}
}
开发者ID:cch-robo,项目名称:Android_Lint_SRP_Practice_Example,代码行数:27,代码来源:SharingGroupClassificationDetector.java
示例2: isTheLastClassRef
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
static PsiMethod isTheLastClassRef(PsiElement element, PsiMethod member) {
final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(element, PsiMethod.class, false);
if ( containingMethod != null &&
!containingMethod.hasModifierProperty(PsiModifier.STATIC) &&
!containingMethod.isConstructor() &&
containingMethod.findDeepestSuperMethods().length == 0 &&
!containingMethod.equals(member)) {
final PsiClass containingClass = containingMethod.getContainingClass();
if (containingClass != null) {
final PsiClass gContainingClass = containingClass.getContainingClass();
if (gContainingClass == null || gContainingClass.hasModifierProperty(PsiModifier.STATIC)) {
final InternalUsageInfo[] refsInMember = MakeStaticUtil.findClassRefsInMember(containingMethod, true);
for (InternalUsageInfo info : refsInMember) {
final PsiElement referencedElement = info.getReferencedElement();
if (!member.equals(referencedElement) && !containingMethod.equals(referencedElement)) {
return null;
}
}
return containingMethod;
}
}
}
return null;
}
示例3: visitAnnotation
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public void visitAnnotation(GrAnnotation annotation) {
super.visitAnnotation(annotation);
PsiElement parent = annotation.getParent().getParent();
if (parent == null || !(parent instanceof GrTypeDefinition)) return;
if (SINGLETON.equals(annotation.getQualifiedName())) {
GrTypeDefinition typeDefinition = (GrTypeDefinition)parent;
PsiMethod[] methods = typeDefinition.getMethods();
for (PsiMethod method : methods) {
if (method.isConstructor()) {
PsiModifierList modifierList = method.getModifierList();
if (modifierList.hasModifierProperty(PsiModifier.PUBLIC)) {
registerClassError(typeDefinition);
}
}
}
}
}
示例4: visitMethod
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public void visitMethod(PsiMethod method) {
super.visitMethod(method);
if (!method.isConstructor()) {
return;
}
if (!method.hasModifierProperty(PsiModifier.PUBLIC)) {
return;
}
final PsiClass aClass = method.getContainingClass();
if (aClass == null || aClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
return;
}
if (SerializationUtils.isExternalizable(aClass)) {
final PsiParameterList parameterList = method.getParameterList();
if (parameterList.getParametersCount() == 0) {
return;
}
}
registerMethodError(method, Boolean.FALSE);
}
示例5: visitMethod
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
// note: no call to super
if (method.getNameIdentifier() == null) {
return;
}
if (method.isConstructor()) {
return;
}
final PsiParameterList parameterList = method.getParameterList();
final int parametersCount = parameterList.getParametersCount();
if (parametersCount <= getLimit()) {
return;
}
if (LibraryUtil.isOverrideOfLibraryMethod(method)) {
return;
}
registerMethodError(method, Integer.valueOf(parametersCount));
}
示例6: visitMethod
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
super.visitMethod(method);
if (method.isConstructor()) {
return;
}
final PsiTypeElement typeElement = method.getReturnTypeElement();
if (typeElement == null) {
return;
}
if (!ConcreteClassUtil.typeIsConcreteClass(typeElement,
ignoreAbstractClasses)) {
return;
}
registerError(typeElement);
}
示例7: calculateTotalMethodCount
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
private int calculateTotalMethodCount(PsiClass aClass) {
final PsiMethod[] methods = aClass.getMethods();
int totalCount = 0;
for (final PsiMethod method : methods) {
if (method.isConstructor()) {
continue;
}
if (ignoreGettersAndSetters) {
if (PropertyUtil.isSimpleGetter(method) || PropertyUtil.isSimpleSetter(method)) {
continue;
}
}
if (ignoreOverridingMethods) {
if (MethodUtils.hasSuper(method)) {
continue;
}
}
totalCount++;
}
return totalCount;
}
示例8: visitMethod
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
// note: no call to super
if (method.getNameIdentifier() == null) {
return;
}
if (!method.isConstructor()) {
return;
}
if (ignoreScope != Scope.NONE) {
switch (ignoreScope.ordinal()) {
case 3: if (method.hasModifierProperty(PsiModifier.PROTECTED)) return;
case 2: if (method.hasModifierProperty(PsiModifier.PACKAGE_LOCAL)) return;
case 1: if (method.hasModifierProperty(PsiModifier.PRIVATE)) return;
}
}
final PsiParameterList parameterList = method.getParameterList();
final int parametersCount = parameterList.getParametersCount();
if (parametersCount <= getLimit()) {
return;
}
registerMethodError(method, Integer.valueOf(parametersCount));
}
示例9: checkMethodReturnType
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
private void checkMethodReturnType(PsiMethod method,
InspectionManager manager,
List<ProblemDescriptor> aProblemDescriptors) {
if (!method.isConstructor()
&& !isIgnoredType(method.getReturnType())
&& !hasAnnotation(method)) {
PsiTypeElement returnTypeElement = method.getReturnTypeElement();
if (returnTypeElement == null) {
return;
}
createProblemDescriptorWithQuickFixes(method, manager, aProblemDescriptors, returnTypeElement);
}
}
开发者ID:stylismo,项目名称:nullability-annotations-inspection,代码行数:16,代码来源:NullabilityAnnotationsInspection.java
示例10: addMethod
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
private void addMethod( SrcClass srcClass, PsiMethod method )
{
SrcMethod srcMethod = new SrcMethod( srcClass );
addAnnotations( srcMethod, method );
srcMethod.modifiers( getModifiers( method.getModifierList() ) );
String name = method.getName();
srcMethod.name( name );
if( !method.isConstructor() )
{
srcMethod.returns( makeSrcType( method.getReturnType() ) );
}
for( PsiTypeParameter typeVar : method.getTypeParameters() )
{
srcMethod.addTypeVar( new SrcType( makeTypeVar( typeVar ) ) );
}
for( PsiParameter param : method.getParameterList().getParameters() )
{
SrcParameter srcParam = new SrcParameter( param.getName(), makeSrcType( param.getType() ) );
addAnnotations( srcParam, param );
srcMethod.addParam( srcParam );
}
for( PsiClassType throwType : method.getThrowsList().getReferencedTypes() )
{
srcMethod.addThrowType( makeSrcType( throwType ) );
}
srcMethod.body( new SrcStatementBlock()
.addStatement(
new SrcRawStatement()
.rawText( "throw new RuntimeException();" ) ) );
srcClass.addMethod( srcMethod );
}
示例11: cannotBeOverriden
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
private static boolean cannotBeOverriden(final PsiMethod method) {
final PsiClass parentClass = method.getContainingClass();
return parentClass == null
|| method.isConstructor()
|| method.hasModifierProperty(PsiModifier.STATIC)
|| method.hasModifierProperty(PsiModifier.FINAL)
|| method.hasModifierProperty(PsiModifier.PRIVATE)
|| parentClass instanceof PsiAnonymousClass
|| parentClass.hasModifierProperty(PsiModifier.FINAL);
}
示例12: getWeight
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
private int getWeight(final Object value) {
if (value instanceof JavaAnonymousClassTreeElement) {
return 55;
}
if (value instanceof JavaClassTreeElement) {
return isPopup ? 53 : 10;
}
if (value instanceof ClassInitializerTreeElement) {
return 15;
}
if (value instanceof SuperTypeGroup) {
return 20;
}
if (value instanceof PsiMethodTreeElement) {
final PsiMethodTreeElement methodTreeElement = (PsiMethodTreeElement)value;
final PsiMethod method = methodTreeElement.getMethod();
return method.isConstructor() ? 30 : 35;
}
if (value instanceof PropertyGroup) {
return 40;
}
if (value instanceof PsiFieldTreeElement) {
return 50;
}
return 60;
}
示例13: cannotBeOverridding
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
private static boolean cannotBeOverridding(final PsiMethod method) {
final PsiClass parentClass = method.getContainingClass();
return parentClass == null
|| method.isConstructor()
|| method.hasModifierProperty(PsiModifier.STATIC)
|| method.hasModifierProperty(PsiModifier.PRIVATE);
}
示例14: compare
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@SuppressWarnings("ConstantConditions")
public static CompareResult compare(final MethodsChain left, final MethodsChain right, final PsiManager psiManager) {
if (left.size() == 0) {
return CompareResult.RIGHT_CONTAINS_LEFT;
}
if (right.size() == 0) {
return CompareResult.LEFT_CONTAINS_RIGHT;
}
final Iterator<PsiMethod[]> leftIterator = left.myRevertedPath.iterator();
final Iterator<PsiMethod[]> rightIterator = right.myRevertedPath.iterator();
while (leftIterator.hasNext() && rightIterator.hasNext()) {
final PsiMethod thisNext = leftIterator.next()[0];
final PsiMethod thatNext = rightIterator.next()[0];
if (thisNext == null || thatNext == null) {
throw new NullPointerException();
}
if (((thisNext.isConstructor() != thatNext.isConstructor())) || !thisNext.getName().equals(thatNext.getName())) {
return CompareResult.NOT_EQUAL;
}
}
if (leftIterator.hasNext() && !rightIterator.hasNext()) {
return CompareResult.LEFT_CONTAINS_RIGHT;
}
if (!leftIterator.hasNext() && rightIterator.hasNext()) {
return CompareResult.RIGHT_CONTAINS_LEFT;
}
return hasBaseMethod(left.getPath().get(0), right.getPath().get(0), psiManager)
? CompareResult.EQUAL
: CompareResult.NOT_EQUAL;
}
示例15: createLookupElement
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
public static LookupElement createLookupElement(final PsiMethod method,
final @Nullable TIntObjectHashMap<SubLookupElement> replaceElements) {
if (method.isConstructor()) {
//noinspection ConstantConditions
return LookupElementBuilder.create(String.format("%s %s", PsiKeyword.NEW, method.getContainingClass().getName()));
} else if (method.hasModifierProperty(PsiModifier.STATIC)) {
return new ChainCompletionMethodCallLookupElement(method, replaceElements, false, true);
} else {
return new ChainCompletionMethodCallLookupElement(method, replaceElements);
}
}