當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。