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


Java PsiMethod.getName方法代码示例

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


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

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

示例2: toString

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
public String toString() {
  final PsiMethod method = (PsiMethod)getPsiElement();
  if (method == null || !method.isValid()) return "";
  if (DumbService.isDumb(myProject)) return method.getName();
  
  String name = PsiFormatUtil.formatMethod(
    method,
    PsiSubstitutor.EMPTY, PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_TYPE | PsiFormatUtil.TYPE_AFTER | PsiFormatUtil.SHOW_PARAMETERS,
    PsiFormatUtil.SHOW_TYPE
  );
  int c = name.indexOf('\n');
  if (c > -1) {
    name = name.substring(0, c - 1);
  }
  return name;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:MethodNode.java

示例3: configureLocalInspectionTools

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@NotNull
@Override
protected LocalInspectionTool[] configureLocalInspectionTools() {
  return new LocalInspectionTool[]{new NullableStuffInspection(){
    @Override
    protected AnnotateMethodFix createAnnotateMethodFix(String defaultNotNull, String[] annotationsToRemove) {
      return new AnnotateMethodFix(defaultNotNull, annotationsToRemove){
        @Override
        public int shouldAnnotateBaseMethod(final PsiMethod method, final PsiMethod superMethod, final Project project) {
          @NonNls String name = method.getName();
          int ret = name.startsWith("annotateBase") ? 0  // yes, annotate all
                    : name.startsWith("dontAnnotateBase") ? 1 // do not annotate base
                      : 2; //abort
          myMustBeAvailableAfterInvoke = ret == 2;
          return ret;
        }
      };
    }

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

示例4: visitMethod

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
  super.visitMethod(method);
  if (method.isConstructor()) {
    return;
  }
  if (!method.hasModifierProperty(PsiModifier.NATIVE)) {
    return;
  }
  final PsiIdentifier nameIdentifier = method.getNameIdentifier();
  if (nameIdentifier == null) {
    return;
  }
  final String name = method.getName();
  if (isValid(name)) {
    return;
  }
  if (!isOnTheFly() && MethodUtils.hasSuper(method)) {
    return;
  }
  if (LibraryUtil.isOverrideOfLibraryMethod(method)) {
    return;
  }
  registerMethodError(method, name);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:NativeMethodNamingConventionInspectionBase.java

示例5: visitMethod

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public void visitMethod(PsiMethod method) {
  super.visitMethod(method);
  if (!TestNGUtil.hasTest(method)) {
    return;
  }
  final PsiIdentifier nameIdentifier = method.getNameIdentifier();
  if (nameIdentifier == null) {
    return;
  }
  final String name = method.getName();
  if (isValid(name)) {
    return;
  }
  if (!isOnTheFly() && MethodUtils.hasSuper(method)) {
    return;
  }
  if (LibraryUtil.isOverrideOfLibraryMethod(method)) {
    return;
  }
  registerMethodError(method, name);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:TestNGMethodNamingConventionInspection.java

示例6: visitMethod

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
  if (!method.isVarArgs()) {
    return;
  }
  final PsiClass aClass = method.getContainingClass();
  if (aClass == null) {
    return;
  }
  final String methodName = method.getName();
  final PsiMethod[] sameNameMethods = aClass.findMethodsByName(methodName, true);
  for (PsiMethod sameNameMethod : sameNameMethods) {
    if (!MethodSignatureUtil.areSignaturesEqual(sameNameMethod, method)) {
      registerMethodError(method, method);
      return;
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:OverloadedVarargsMethodInspection.java

示例7: visitMethod

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
  super.visitMethod(method);
  final String name = method.getName();
  if (!HardcodedMethodConstants.CLONE.equals(name)) {
    return;
  }
  final PsiParameterList parameterList = method.getParameterList();
  if (parameterList.getParametersCount() != 0) {
    return;
  }
  if (method.hasModifierProperty(PsiModifier.FINAL)
      || method.hasModifierProperty(PsiModifier.ABSTRACT)) {
    return;
  }
  final PsiClass containingClass = method.getContainingClass();
  if (containingClass == null) {
    return;
  }
  if (containingClass.hasModifierProperty(PsiModifier.FINAL)
      || containingClass.isInterface()) {
    return;
  }
  registerMethodError(method);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:NonFinalCloneInspection.java

示例8: visitMethod

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
  // note: no call to super
  @NonNls final String methodName = method.getName();
  if (!"teardown".equals(methodName)) {
    return;
  }
  final PsiClass aClass = method.getContainingClass();
  if (aClass == null) {
    return;
  }
  if (!InheritanceUtil.isInheritor(aClass,
                                   "junit.framework.TestCase")) {
    return;
  }
  registerMethodError(method);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:MisspelledTearDownInspectionBase.java

示例9: visitMethod

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public void visitMethod(PsiMethod method) {
  super.visitMethod(method);
  if (!TestUtils.isJUnit3TestMethod(method) || !TestUtils.isRunnable(method)) {
    return;
  }
  final PsiIdentifier nameIdentifier = method.getNameIdentifier();
  if (nameIdentifier == null) {
    return;
  }
  final String name = method.getName();
  if (isValid(name)) {
    return;
  }
  if (!isOnTheFly() && MethodUtils.hasSuper(method)) {
    return;
  }
  if (LibraryUtil.isOverrideOfLibraryMethod(method)) {
    return;
  }
  registerMethodError(method, name);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:JUnit3MethodNamingConventionInspectionBase.java

示例10: getType

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
private static Class<?> getType(UExpression expression) {
  if (expression == null) {
    return null;
  }
  if (expression instanceof PsiMethodCallExpression) {
    PsiMethodCallExpression call = (PsiMethodCallExpression) expression;
    PsiMethod method = call.resolveMethod();
    if (method == null) {
      return null;
    }
    String methodName = method.getName();
    if (methodName.equals(GET_STRING_METHOD)) {
      return String.class;
    }
  } else if (expression instanceof PsiLiteralExpression) {
    PsiLiteralExpression literalExpression = (PsiLiteralExpression) expression;
    PsiType expressionType = literalExpression.getType();
    if (LintUtils.isString(expressionType)) {
      return String.class;
    } else if (expressionType == PsiType.INT) {
      return Integer.TYPE;
    } else if (expressionType == PsiType.FLOAT) {
      return Float.TYPE;
    } else if (expressionType == PsiType.CHAR) {
      return Character.TYPE;
    } else if (expressionType == PsiType.BOOLEAN) {
      return Boolean.TYPE;
    } else if (expressionType == PsiType.NULL) {
      return Object.class;
    }
  }

  PsiType type = expression.getExpressionType();
  if (type != null) {
    Class<?> typeClass = getTypeClass(type);
    return typeClass != null ? typeClass : Object.class;
  }

  return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:41,代码来源:WrongTimberUsageDetector.java

示例11: selectActionPerformed

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
protected void selectActionPerformed(AnActionEvent event, PsiElement element, String packageName) {
    if (!Utils.isAndroidClass(packageName)) {
        NotificationUtils.infoNotification("Must be Android class or Method");
        return;
    }
    String linkUrl = baseUrl;
    if (element instanceof PsiMethod) {
        PsiMethod psiMethod = (PsiMethod) element;
        PsiParameter[] parameters = psiMethod.getParameterList().getParameters();
        StringBuilder paramsBuilder = new StringBuilder("#" + psiMethod.getName());
        paramsBuilder.append("(");
        for (int i = 0; i < parameters.length; i++) {
            PsiParameter parameter = parameters[i];
            paramsBuilder.append(parameter.getType().getCanonicalText());
            if (i < parameters.length - 1) {
                paramsBuilder.append(",%20");
            }
        }
        paramsBuilder.append(")");
        linkUrl += getRealPackage(psiMethod.getContainingClass()) + paramsBuilder.toString();
    } else if (element instanceof PsiClass) {
        PsiClass psiClass = (PsiClass) element;
        linkUrl += getRealPackage(psiClass);
    }
    Log.debug("linkUrl= " + linkUrl);
    Utils.openUrl(linkUrl);
}
 
开发者ID:pengwei1024,项目名称:AndroidSourceViewer,代码行数:29,代码来源:AndroidDeveloperAction.java

示例12: plantMethodInPsiClass

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
private PsiMethod plantMethodInPsiClass( PsiMethod refMethod, PsiClass psiClass, PsiClass extClass )
{
  if( null != refMethod )
  {
    ManPsiElementFactory manPsiElemFactory = ManPsiElementFactory.instance();
    String methodName = refMethod.getName();
    ManLightMethodBuilder method = manPsiElemFactory.createLightMethod( psiClass.getManager(), methodName )
      .withMethodReturnType( refMethod.getReturnType() )
      .withContainingClass( psiClass );
    PsiElement navElem = findExtensionMethodNavigationElement( extClass, refMethod );
    if( navElem != null )
    {
      method.withNavigationElement( navElem );
    }
    addModifier( refMethod, method, PsiModifier.PUBLIC );
    addModifier( refMethod, method, PsiModifier.STATIC );
    addModifier( refMethod, method, PsiModifier.PACKAGE_LOCAL );
    addModifier( refMethod, method, PsiModifier.PROTECTED );

    for( PsiTypeParameter tv : refMethod.getTypeParameters() )
    {
      method.withTypeParameter( tv );
    }

    PsiParameter[] parameters = refMethod.getParameterList().getParameters();
    for( PsiParameter psiParameter : parameters )
    {
      method.withParameter( psiParameter.getName(), psiParameter.getType() );
    }

    for( PsiClassType psiClassType : refMethod.getThrowsList().getReferencedTypes() )
    {
      method.withException( psiClassType );
    }

    return method;
  }
  return null;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:40,代码来源:ManAugmentProvider.java

示例13: 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 );
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:32,代码来源:StubBuilder.java

示例14: visitMethod

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
  // note: no call to super
  @NonNls final String name = method.getName();
  if (!MethodUtils.methodMatches(method, CommonClassNames.JAVA_UTIL_ITERATOR, null,
                                 HardcodedMethodConstants.HAS_NEXT)) {
    return;
  }
  if (!IteratorUtils.containsCallToIteratorNext(method, null, true)) {
    return;
  }
  registerMethodError(method);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:IteratorHasNextCallsIteratorNextInspection.java

示例15: visitMethod

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
  //note: no call to super
  @NonNls final String methodName = method.getName();
  if (!"compareto".equals(methodName)) {
    return;
  }
  final PsiParameterList parameterList = method.getParameterList();
  if (parameterList.getParametersCount() != 1) {
    return;
  }
  registerMethodError(method);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:MisspelledCompareToInspectionBase.java


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