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


Java PsiMethod类代码示例

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


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

示例1: checkNestedStringFormat

import com.intellij.psi.PsiMethod; //导入依赖的package包/类
private static void checkNestedStringFormat(JavaContext context, UCallExpression call) {
  UElement current = call;
  while (true) {
    current = LintUtils.skipParentheses(current.getUastParent());
    if (current == null || current instanceof UMethod) {
      // Reached AST root or code block node; String.format not inside Timber.X(..).
      return;
    }
    if (current instanceof UCallExpression) {
      UCallExpression maybeTimberLogCall = (UCallExpression) current;
      JavaEvaluator evaluator = context.getEvaluator();
      PsiMethod psiMethod = maybeTimberLogCall.resolve();
      if (Pattern.matches(TIMBER_TREE_LOG_METHOD_REGEXP, psiMethod.getName())
          && evaluator.isMemberInClass(psiMethod, "timber.log.Timber")) {
        LintFix fix = quickFixIssueFormat(call);
        context.report(ISSUE_FORMAT, call, context.getLocation(call),
            "Using 'String#format' inside of 'Timber'", fix);
        return;
      }
    }
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:WrongTimberUsageDetector.java

示例2: getWritablePropertyType

import com.intellij.psi.PsiMethod; //导入依赖的package包/类
@Nullable
public static PsiType getWritablePropertyType(@Nullable PsiClass containingClass,
    @Nullable PsiElement declaration) {
  if (declaration instanceof PsiField) {
    return getWrappedPropertyType((PsiField) declaration, JavaFxCommonNames.ourWritableMap);
  }
  if (declaration instanceof PsiMethod) {
    final PsiMethod method = (PsiMethod) declaration;
    if (method.getParameterList().getParametersCount() != 0) {
      return getSetterArgumentType(method);
    }
    final String propertyName = PropertyUtil.getPropertyName(method);
    final PsiClass psiClass =
        containingClass != null ? containingClass : method.getContainingClass();
    if (propertyName != null && containingClass != null) {
      final PsiMethod setter = findInstancePropertySetter(psiClass, propertyName);
      if (setter != null) {
        final PsiType setterArgumentType = getSetterArgumentType(setter);
        if (setterArgumentType != null)
          return setterArgumentType;
      }
    }
    return getGetterReturnType(method);
  }
  return null;
}
 
开发者ID:1tontech,项目名称:intellij-spring-assistant,代码行数:27,代码来源:PsiUtil.java

示例3: hasGetAndSet

import com.intellij.psi.PsiMethod; //导入依赖的package包/类
private static boolean hasGetAndSet(@NonNull String getPrefix, @NonNull String setPrefix, @NonNull PsiClass cls, @NonNull PsiField field) {
    boolean isPublic = field.hasModifierProperty(PsiModifier.PUBLIC);
    if (isPublic) return true;

    String fieldName = captureName(field.getName());
    String getMethodName = getPrefix + fieldName;
    String setMethodName = setPrefix + fieldName;
    PsiMethod[] gets = cls.findMethodsByName(getMethodName, true);
    PsiMethod[] sets = cls.findMethodsByName(setMethodName, true);

    boolean hasGet = gets.length > 0;
    boolean hasSet = sets.length > 0;

    return hasGet && hasSet;

}
 
开发者ID:jessie345,项目名称:CustomLintRules,代码行数:17,代码来源:Utils.java

示例4: visitMethod

import com.intellij.psi.PsiMethod; //导入依赖的package包/类
@Override
public void visitMethod(@NonNull JavaContext context, @Nullable JavaElementVisitor visitor,
                        @NonNull PsiMethodCallExpression node, @NonNull PsiMethod method) {

    boolean isLayoutInflaterCall = isLayoutInflaterCall(context, node, method);
    boolean isViewInflateCall = isInViewCall(context, node, method);

    String name = method.getName();
    boolean fromMethod = LAYOUTINFLATER_FROM.equals(name);
    boolean viewInflateMethod = VIEW_INFLATE.equals(name);

    if (isLayoutInflaterCall && fromMethod) {

        context.report(ISSUE_LAYOUTINFLATER, node, context.getLocation(node),
                "error use system LayoutInflater,should use LayoutInflaterWrapper.");
        return;
    }

    if (viewInflateMethod && isViewInflateCall) {

        context.report(ISSUE_VIEW_INFLATE, node, context.getLocation(node),
                "error use View.inflate(),should use LayoutInflaterWrapper.inflate.");
        return;
    }

}
 
开发者ID:jessie345,项目名称:CustomLintRules,代码行数:27,代码来源:AutoPointLayoutInflaterDetector.java

示例5: visitMethod

import com.intellij.psi.PsiMethod; //导入依赖的package包/类
@Override
public void visitMethod(JavaContext context, JavaElementVisitor visitor,
    PsiMethodCallExpression call, PsiMethod method) {
  JavaEvaluator evaluator = context.getEvaluator();
  if (evaluator.getParameterCount(method) == 0) {
    PsiMethod parent = PsiTreeUtil.getParentOfType(call, PsiMethod.class);
    if (parent != null) {
      if (evaluator.isMemberInClass(method, CLASS_DIRECTOR) &&
          evaluator.isMemberInSubClassOf(parent, CLASS_DIRECTOR_BACK_HANDLER, false)) {
        context.report(ISSUE, call, context.getLocation(call),
            "Can't call Stage.handleBack() in Stage.BackHandler.handleBack()");
      } else if (evaluator.isMemberInClass(method, CLASS_STAGE) &&
          evaluator.isMemberInSubClassOf(parent, CLASS_STAGE_BACK_HANDLER, false)) {
        context.report(ISSUE, call, context.getLocation(call),
            "Can't call Director.handleBack() in Director.BackHandler.handleBack()");
      }
    }
  }
}
 
开发者ID:seven332,项目名称:Stage,代码行数:20,代码来源:BackHandlerDetector.java

示例6: checkMethodSignature

import com.intellij.psi.PsiMethod; //导入依赖的package包/类
private boolean checkMethodSignature(PsiMethod method) {
    // subscribe() calls that have no return type are custom Observers whose error handling we cannot check
    if (PsiType.VOID.equals(method.getReturnType())) {
        return false;
    }
    int argCount = method.getParameterList().getParametersCount();
    // when more than one argument is given, there is usually one error callback included
    if (argCount > 1) {
        return false;
    }
    // no arguments, no error handling
    if (argCount == 0) {
        return true;
    }
    // if we have only one argument, check that it's not a BiConsumer
    PsiParameter parameter = method.getParameterList().getParameters()[0];
    return !"io.reactivex.functions.BiConsumer".equals(parameter.getType().getCanonicalText());
}
 
开发者ID:IlyaGulya,项目名称:rxlint,代码行数:19,代码来源:RxJava2SubscriberCheck.java

示例7: visitMethod

import com.intellij.psi.PsiMethod; //导入依赖的package包/类
@Override
public void visitMethod(JavaContext context, JavaElementVisitor visitor, PsiMethodCallExpression call, PsiMethod method) {
    super.visitMethod(context, visitor, call, method);
    if (isRxSubscribeableClass(method.getContainingClass()) && !PsiType.VOID.equals(method.getReturnType())) {
        PsiElement element = LintUtils.skipParentheses(call.getParent());
        if (element instanceof PsiExpressionStatement) {
            String message;
            if (isRx2(method.getContainingClass())) {
                message = "No reference to the disposable is kept";
            } else {
                message = "No reference to the subscription is kept";
            }
            context.report(ISSUE, call, context.getLocation(call), message);
        }
    }
}
 
开发者ID:IlyaGulya,项目名称:rxlint,代码行数:17,代码来源:DanglingSubscriptionDetector.java

示例8: canProcessElement

import com.intellij.psi.PsiMethod; //导入依赖的package包/类
@Override
public boolean canProcessElement( @NotNull PsiElement elem )
{
  PsiElement[] element = new PsiElement[]{elem};
  List<PsiElement> javaElems = findJavaElements( element );
  if( javaElems.isEmpty() )
  {
    return false;
  }

  for( PsiElement javaElem : javaElems )
  {
    if( !(javaElem instanceof PsiMethod) &&
        !(javaElem instanceof PsiField) &&
        !(javaElem instanceof PsiClass) )
    {
      return false;
    }
  }

  return true;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:23,代码来源:RenameResourceElementProcessor.java

示例9: makePsiMethod

import com.intellij.psi.PsiMethod; //导入依赖的package包/类
private PsiMethod makePsiMethod( AbstractSrcMethod method, PsiClass psiClass )
{
  PsiElementFactory elementFactory = JavaPsiFacade.getInstance( psiClass.getProject() ).getElementFactory();
  StringBuilder sb = new StringBuilder();
  method.render( sb, 0 );
  try
  {
    return elementFactory.createMethodFromText( sb.toString(), psiClass );
  }
  catch( IncorrectOperationException ioe )
  {
    // the text of the method does not conform to method grammar, probably being edited in an IJ editor,
    // ignore these since the editor provides error information
    return null;
  }
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:17,代码来源:ManAugmentProvider.java

示例10: findExtensionMethodNavigationElement

import com.intellij.psi.PsiMethod; //导入依赖的package包/类
private PsiElement findExtensionMethodNavigationElement( PsiClass extClass, PsiMethod plantedMethod )
{
  PsiMethod[] found = extClass.findMethodsByName( plantedMethod.getName(), false );
  outer:
  for( PsiMethod m : found )
  {
    PsiParameter[] extParams = m.getParameterList().getParameters();
    PsiParameter[] plantedParams = plantedMethod.getParameterList().getParameters();
    if( extParams.length - 1 == plantedParams.length )
    {
      for( int i = 1; i < extParams.length; i++ )
      {
        PsiParameter extParam = extParams[i];
        PsiParameter plantedParam = plantedParams[i - 1];
        PsiType extErased = TypeConversionUtil.erasure( extParam.getType() );
        PsiType plantedErased = TypeConversionUtil.erasure( plantedParam.getType() );
        if( !extErased.toString().equals( plantedErased.toString() ) )
        {
          continue outer;
        }
      }
      return m.getNavigationElement();
    }
  }
  return null;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:27,代码来源:ManAugmentProvider.java

示例11: makeSrcClass

import com.intellij.psi.PsiMethod; //导入依赖的package包/类
public SrcClass makeSrcClass( String fqn, PsiClass psiClass, ManModule module )
{
  SrcClass srcClass = new SrcClass( fqn, getKind( psiClass ) )
    .modifiers( getModifiers( psiClass.getModifierList() ) );
  for( PsiTypeParameter typeVar : psiClass.getTypeParameters() )
  {
    srcClass.addTypeVar( new SrcType( makeTypeVar( typeVar ) ) );
  }
  setSuperTypes( srcClass, psiClass );
  for( PsiMethod psiMethod : psiClass.getMethods() )
  {
    addMethod( srcClass, psiMethod );
  }
  for( PsiField psiField : psiClass.getFields() )
  {
    addField( srcClass, psiField );
  }
  for( PsiClass psiInnerClass : psiClass.getInnerClasses() )
  {
    addInnerClass( srcClass, psiInnerClass, module );
  }
  return srcClass;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:24,代码来源:StubBuilder.java

示例12: check

import com.intellij.psi.PsiMethod; //导入依赖的package包/类
void check(@NonNull PsiMethod method) {
    if (mClass != null &&
            !mClassFields.isEmpty()) {

        // メソッド引数に boolean のパラメータがある場合のみ対象とする
        Map<String, PsiParameter> parameters = new HashMap<>();
        PsiParameter[] params = method.getParameterList().getParameters();
        for (PsiParameter param : params) {
            if (param.getType() != PsiType.BOOLEAN) continue;
            parameters.put(param.getName(), param);
        }
        if (parameters.isEmpty()) return;

        mMethod = method;
        mFlagMethodParameters.clear();
        mFlagMethodParameters.putAll(parameters);
        mFlagLogic = null;
    }
}
 
开发者ID:cch-robo,项目名称:Android_Lint_SRP_Practice_Example,代码行数:20,代码来源:MultiFunctionFlagStructureDetector.java

示例13: 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

示例14: applyTestMethodConfiguration

import com.intellij.psi.PsiMethod; //导入依赖的package包/类
private static boolean applyTestMethodConfiguration(@NotNull ExternalSystemRunConfiguration configuration,
                                                    @NotNull ConfigurationContext context,
                                                    @NotNull PsiMethod psiMethod,
                                                    @NotNull PsiClass... containingClasses) {
  if (!StringUtil.equals(
    context.getModule().getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY),
    GradleConstants.SYSTEM_ID.toString())) {
    return false;
  }

  configuration.getSettings().setExternalProjectPath(context.getModule().getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY));
  configuration.getSettings().setTaskNames(TASKS_TO_RUN);

  StringBuilder buf = new StringBuilder();
  for (PsiClass aClass : containingClasses) {
    buf.append(creatTestFilter(aClass, psiMethod));
  }

  configuration.getSettings().setScriptParameters(buf.toString().trim());
  configuration.setName(psiMethod.getName());
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:TestMethodGradleConfigurationProducer.java

示例15: visitMethod

import com.intellij.psi.PsiMethod; //导入依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
  //no call to super, so we don't drill into anonymous classes
  if (method.isConstructor()) {
    return;
  }
  if (method.hasModifierProperty(PsiModifier.SYNCHRONIZED)) {
    return;
  }
  if (method.getNameIdentifier() == null) {
    return;
  }
  final PsiMethod[] superMethods = method.findSuperMethods();
  for (final PsiMethod superMethod : superMethods) {
    if (superMethod.hasModifierProperty(PsiModifier.SYNCHRONIZED)) {
      registerMethodError(method);
      return;
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:NonSynchronizedMethodOverridesSynchronizedMethodVisitor.java


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