本文整理汇总了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;
}
}
示例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;
}
示例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;
}
};
}
}};
}
示例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);
}
示例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;
}
}
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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 );
}
示例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);
}