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


Java MethodSignatureBackedByPsiMethod类代码示例

本文整理汇总了Java中com.intellij.psi.util.MethodSignatureBackedByPsiMethod的典型用法代码示例。如果您正苦于以下问题:Java MethodSignatureBackedByPsiMethod类的具体用法?Java MethodSignatureBackedByPsiMethod怎么用?Java MethodSignatureBackedByPsiMethod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: execute

import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入依赖的package包/类
@Override
public boolean execute(@NotNull final SuperMethodsSearch.SearchParameters queryParameters, @NotNull final Processor<MethodSignatureBackedByPsiMethod> consumer) {
  final PsiClass parentClass = queryParameters.getPsiClass();
  final PsiMethod method = queryParameters.getMethod();
  return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
    @Override
    public Boolean compute() {
      HierarchicalMethodSignature signature = method.getHierarchicalMethodSignature();

      final boolean checkBases = queryParameters.isCheckBases();
      final boolean allowStaticMethod = queryParameters.isAllowStaticMethod();
      final List<HierarchicalMethodSignature> supers = signature.getSuperSignatures();
      for (HierarchicalMethodSignature superSignature : supers) {
        if (MethodSignatureUtil.isSubsignature(superSignature, signature)) {
          if (!addSuperMethods(superSignature, method, parentClass, allowStaticMethod, checkBases, consumer)) return false;
        }
      }

      return true;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:MethodSuperSearcher.java

示例2: addSuperMethods

import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入依赖的package包/类
private static boolean addSuperMethods(final HierarchicalMethodSignature signature,
                                       final PsiMethod method,
                                       final PsiClass parentClass,
                                       final boolean allowStaticMethod,
                                       final boolean checkBases,
                                       final Processor<MethodSignatureBackedByPsiMethod> consumer) {
  PsiMethod signatureMethod = signature.getMethod();
  PsiClass hisClass = signatureMethod.getContainingClass();
  if (parentClass == null || InheritanceUtil.isInheritorOrSelf(parentClass, hisClass, true)) {
    if (isAcceptable(signatureMethod, method, allowStaticMethod)) {
      if (parentClass != null && !parentClass.equals(hisClass) && !checkBases) {
        return true;
      }
      LOG.assertTrue(signatureMethod != method, method); // method != method.getsuper()
      return consumer.process(signature); //no need to check super classes
    }
  }
  for (HierarchicalMethodSignature superSignature : signature.getSuperSignatures()) {
    if (MethodSignatureUtil.isSubsignature(superSignature, signature)) {
      addSuperMethods(superSignature, method, parentClass, allowStaticMethod, checkBases, consumer);
    }
  }

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

示例3: definedInClass

import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入依赖的package包/类
public PsiMethodPattern definedInClass(final ElementPattern<? extends PsiClass> pattern) {
  return with(new PatternConditionPlus<PsiMethod, PsiClass>("definedInClass", pattern) {

    @Override
    public boolean processValues(PsiMethod t, final ProcessingContext context, final PairProcessor<PsiClass, ProcessingContext> processor) {
      if (!processor.process(t.getContainingClass(), context)) return false;
      final Ref<Boolean> result = Ref.create(Boolean.TRUE);
      SuperMethodsSearch.search(t, null, true, false).forEach(new Processor<MethodSignatureBackedByPsiMethod>() {
        @Override
        public boolean process(final MethodSignatureBackedByPsiMethod signature) {
          if (!processor.process(signature.getMethod().getContainingClass(), context)) {
            result.set(Boolean.FALSE);
            return false;
          }
          return true;
        }
      });
      return result.get();
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:PsiMethodPattern.java

示例4: checkMethodOverridesDeprecated

import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入依赖的package包/类
static void checkMethodOverridesDeprecated(MethodSignatureBackedByPsiMethod methodSignature,
                                           List<MethodSignatureBackedByPsiMethod> superMethodSignatures,
                                           boolean ignoreAbstractDeprecatedOverrides, ProblemsHolder holder) {
  PsiMethod method = methodSignature.getMethod();
  PsiElement methodName = method.getNameIdentifier();
  for (MethodSignatureBackedByPsiMethod superMethodSignature : superMethodSignatures) {
    PsiMethod superMethod = superMethodSignature.getMethod();
    PsiClass aClass = superMethod.getContainingClass();
    if (aClass == null) continue;
    // do not show deprecated warning for class implementing deprecated methods
    if (ignoreAbstractDeprecatedOverrides && !aClass.isDeprecated() && superMethod.hasModifierProperty(PsiModifier.ABSTRACT)) continue;
    if (superMethod.isDeprecated()) {
      String description = JavaErrorMessages.message("overrides.deprecated.method",
                                                     HighlightMessageUtil.getSymbolName(aClass, PsiSubstitutor.EMPTY));
      holder.registerProblem(methodName, description, ProblemHighlightType.LIKE_DEPRECATED);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:DeprecationInspection.java

示例5: visitMethod

import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
  final PsiParameterList parameterList = method.getParameterList();
  if (parameterList.getParametersCount() == 0) {
    return;
  }
  final Query<MethodSignatureBackedByPsiMethod> query =
    SuperMethodsSearch.search(
      method, method.getContainingClass(), true, false);
  final MethodSignatureBackedByPsiMethod methodSignature =
    query.findFirst();
  if (methodSignature == null) {
    return;
  }
  final PsiMethod superMethod = methodSignature.getMethod();
  final PsiParameter[] parameters = parameterList.getParameters();
  checkParameters(superMethod, parameters);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ParameterNameDiffersFromOverriddenParameterInspectionBase.java

示例6: execute

import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入依赖的package包/类
@Override
public boolean execute(@NotNull final SuperMethodsSearch.SearchParameters queryParameters, @NotNull final Processor<MethodSignatureBackedByPsiMethod> consumer) {
  final PsiClass parentClass = queryParameters.getPsiClass();
  final PsiMethod method = queryParameters.getMethod();
  HierarchicalMethodSignature signature = method.getHierarchicalMethodSignature();

  final boolean checkBases = queryParameters.isCheckBases();
  final boolean allowStaticMethod = queryParameters.isAllowStaticMethod();
  final List<HierarchicalMethodSignature> supers = signature.getSuperSignatures();
  for (HierarchicalMethodSignature superSignature : supers) {
    if (MethodSignatureUtil.isSubsignature(superSignature, signature)) {
      if (!addSuperMethods(superSignature, method, parentClass, allowStaticMethod, checkBases, consumer)) return false;
    }
  }

  return true;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:MethodSuperSearcher.java

示例7: compare

import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入依赖的package包/类
@Override
public int compare(MethodSignature o1, MethodSignature o2) {
  if (o1 instanceof MethodSignatureBackedByPsiMethod && o2 instanceof MethodSignatureBackedByPsiMethod) {
    PsiMethod m1 = ((MethodSignatureBackedByPsiMethod)o1).getMethod();
    PsiMethod m2 = ((MethodSignatureBackedByPsiMethod)o2).getMethod();
    PsiClass c1 = m1.getContainingClass();
    PsiClass c2 = m2.getContainingClass();
    if (c1 != null && c2 != null) {
      if (c1 == c2) {
        final List<PsiMethod> methods = Arrays.asList(c1.getMethods());
        return methods.indexOf(m1) - methods.indexOf(m2);
      }

      if (c1.isInheritor(c2, true)) return -1;
      if (c2.isInheritor(c1, true)) return 1;

      return StringUtil.notNullize(c1.getName()).compareTo(StringUtil.notNullize(c2.getName()));
    }
    return m1.getTextOffset() - m2.getTextOffset();
  }
  return 0;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:OverrideImplementExploreUtil.java

示例8: visitMethod

import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入依赖的package包/类
@Override
public void visitMethod(PsiMethod method) {
  ArrangementSettingsToken type = method.isConstructor() ? CONSTRUCTOR : METHOD;
  JavaElementArrangementEntry entry = createNewEntry(method, method.getTextRange(), type, method.getName(), true);
  if (entry == null) {
    return;
  }
  
  processEntry(entry, method, method.getBody());
  parseProperties(method, entry);
  myInfo.onMethodEntryCreated(method, entry);
  MethodSignatureBackedByPsiMethod overridden = SuperMethodsSearch.search(method, null, true, false).findFirst();
  if (overridden != null) {
    myInfo.onOverriddenMethod(overridden.getMethod(), method);
  }
  boolean reset = myMethodBodyProcessor.setBaseMethod(method);
  try {
    method.accept(myMethodBodyProcessor);
  }
  finally {
    if (reset) {
      myMethodBodyProcessor.setBaseMethod(null);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:JavaArrangementVisitor.java

示例9: checkMethod

import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入依赖的package包/类
@Nullable
@Override
public ProblemDescriptor[] checkMethod(PsiMethod method, InspectionManager manager, boolean isOnTheFly) {
    if (isNonPrivateMethod(method)) {
        List<ProblemDescriptor> problemDescriptors = new ArrayList<>();
        List<MethodSignatureBackedByPsiMethod> superMethodSignatures = superMethods(method);
        PsiParameter[] parameters = method.getParameterList().getParameters();
        checkMethodParams(manager, problemDescriptors, superMethodSignatures, parameters);
        checkMethodReturnType(method, manager, problemDescriptors);
        return problemDescriptors.isEmpty()
                ? null
                : problemDescriptors.toArray(new ProblemDescriptor[problemDescriptors.size()]);
    }
    return null;
}
 
开发者ID:stylismo,项目名称:nullability-annotations-inspection,代码行数:16,代码来源:NullabilityAnnotationsInspection.java

示例10: checkMethodParams

import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入依赖的package包/类
private void checkMethodParams(InspectionManager manager,
                               List<ProblemDescriptor> aProblemDescriptors,
                               List<MethodSignatureBackedByPsiMethod> aSuperMethodSignatures,
                               PsiParameter[] aParameters) {
    for (int i = 0, parametersLength = aParameters.length; i < parametersLength; i++) {
        PsiParameter parameter = aParameters[i];
        if (parameterNeedsAnnotation(parameter)) {
            if (!hasAnnotation(parameter) && !hasAnnotationInHierarchy(i, aSuperMethodSignatures)) {
                createProblemDescriptorWithQuickFixes(parameter, manager, aProblemDescriptors, parameter);
            }
        }
    }
}
 
开发者ID:stylismo,项目名称:nullability-annotations-inspection,代码行数:14,代码来源:NullabilityAnnotationsInspection.java

示例11: hasAnnotationInHierarchy

import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入依赖的package包/类
private boolean hasAnnotationInHierarchy(int parameter,
                                         List<MethodSignatureBackedByPsiMethod> superMethodSignatures) {
    for (MethodSignatureBackedByPsiMethod methodSignature : superMethodSignatures) {
        PsiMethod superMethod = methodSignature.getMethod();
        PsiParameter[] superParameters = superMethod.getParameterList().getParameters();
        PsiParameter superParameter = superParameters[parameter];
        if (hasAnnotation(superParameter)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:stylismo,项目名称:nullability-annotations-inspection,代码行数:13,代码来源:NullabilityAnnotationsInspection.java

示例12: superMethods

import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入依赖的package包/类
private List<MethodSignatureBackedByPsiMethod> superMethods(PsiMethod method) {
    List<MethodSignatureBackedByPsiMethod> signatures = method.findSuperMethodSignaturesIncludingStatic(true);
    signatures.removeIf(superSignature ->
            superSignature.getMethod().getParameterList().getParametersCount()
                    != method.getParameterList().getParametersCount());
    return signatures;
}
 
开发者ID:stylismo,项目名称:nullability-annotations-inspection,代码行数:8,代码来源:NullabilityAnnotationsInspection.java

示例13: superMethods

import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入依赖的package包/类
private static List<MethodSignatureBackedByPsiMethod> superMethods(PsiMethod method) {
    List<MethodSignatureBackedByPsiMethod> signatures = method.findSuperMethodSignaturesIncludingStatic(true);
    signatures.removeIf(superSignature ->
            superSignature.getMethod().getParameterList().getParametersCount()
                    != method.getParameterList().getParametersCount());
    return signatures;
}
 
开发者ID:stylismo,项目名称:nullability-annotations-inspection,代码行数:8,代码来源:NullabilityAnnotationsWithTypeQualifierDefault.java

示例14: search

import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入依赖的package包/类
@NotNull
public static Query<MethodSignatureBackedByPsiMethod> search(@NotNull PsiMethod derivedMethod,
                                                             @Nullable final PsiClass psiClass,
                                                             boolean checkBases,
                                                             boolean allowStaticMethod) {
  final SearchParameters parameters = new SearchParameters(derivedMethod, psiClass, checkBases, allowStaticMethod);
  return SUPER_METHODS_SEARCH_INSTANCE.createUniqueResultsQuery(parameters, MethodSignatureUtil.METHOD_BASED_HASHING_STRATEGY);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:SuperMethodsSearch.java

示例15: getLocationString

import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入依赖的package包/类
@Override
public String getLocationString() {
  if (!Registry.is("show.method.base.class.in.java.file.structure")) return null;
  final PsiMethod method = getElement();
  if (myLocation == null && method != null && !DumbService.isDumb(method.getProject())) {
    if (isInherited()) {
      return super.getLocationString();
    } else {
    try {
      final MethodSignatureBackedByPsiMethod baseMethod = SuperMethodsSearch.search(method, null, true, false).findFirst();
      if (baseMethod != null && !method.isEquivalentTo(baseMethod.getMethod())) {
        PsiMethod base = baseMethod.getMethod();
        PsiClass baseClass = base.getContainingClass();
        if (baseClass != null /*&& !CommonClassNames.JAVA_LANG_OBJECT.equals(baseClass.getQualifiedName())*/) {
          if (baseClass.getMethods().length > 1) {
            myLocation = baseClass.getName();
          }
        }
      }
    }
    catch (IndexNotReadyException e) {
      //some searchers (EJB) require indices. What shall we do?
    }

    if (StringUtil.isEmpty(myLocation)) {
      myLocation = "";
    } else {
      char upArrow = '\u2191';
      myLocation = UIUtil.getLabelFont().canDisplay(upArrow) ? upArrow + myLocation : myLocation;
    }
    }
  }
  return StringUtil.isEmpty(myLocation) ? null : myLocation;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:PsiMethodTreeElement.java


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