本文整理匯總了Java中com.intellij.psi.PsiClass.findMethodsByName方法的典型用法代碼示例。如果您正苦於以下問題:Java PsiClass.findMethodsByName方法的具體用法?Java PsiClass.findMethodsByName怎麽用?Java PsiClass.findMethodsByName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.psi.PsiClass
的用法示例。
在下文中一共展示了PsiClass.findMethodsByName方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: hasGetAndSet
import com.intellij.psi.PsiClass; //導入方法依賴的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;
}
示例2: findExtensionMethodNavigationElement
import com.intellij.psi.PsiClass; //導入方法依賴的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;
}
示例3: findInstancePropertySetter
import com.intellij.psi.PsiClass; //導入方法依賴的package包/類
@Nullable
public static PsiMethod findInstancePropertySetter(@NotNull PsiClass psiClass,
@Nullable String propertyName) {
if (StringUtil.isEmpty(propertyName))
return null;
final String suggestedSetterName = PropertyUtil.suggestSetterName(propertyName);
final PsiMethod[] setters = psiClass.findMethodsByName(suggestedSetterName, true);
for (PsiMethod setter : setters) {
if (setter.hasModifierProperty(PUBLIC) && !setter.hasModifierProperty(STATIC)
&& isSimplePropertySetter(setter)) {
return setter;
}
}
return null;
}
示例4: findAssignableMethod
import com.intellij.psi.PsiClass; //導入方法依賴的package包/類
public static PsiMethod findAssignableMethod( boolean structural, PsiClass fromMethods, PsiMethod miTo, TypeVarToTypeMap inferenceMap )
{
String mname = miTo.getName();
PsiMethod[] methods = fromMethods.findMethodsByName( mname, true );
if( methods.length == 0 )
{
return null;
}
PsiClass ownersType = miTo.getContainingClass();
PsiMethod foundMethod = null;
TypeVarToTypeMap foundInferenceMap = null;
PsiParameter[] toParams = miTo.getParameterList().getParameters();
int iTopScore = 0;
outer:
for( PsiMethod miFrom : methods )
{
if( miFrom.getName().equals( mname ) )
{
TypeVarToTypeMap copyInferenceMap = new TypeVarToTypeMap( inferenceMap );
PsiType toReturnType = maybeInferReturnType( copyInferenceMap, type( ownersType ), miFrom.getReturnType(), miTo.getReturnType() );
PsiType fromReturnType = replaceTypeVariableTypeParametersWithBoundingTypes( miFrom.getReturnType(), type( miFrom.getContainingClass() ) );
if( !isAssignable( structural, true, toReturnType, fromReturnType ) )
{
continue;
}
PsiParameter[] fromParams = miFrom.getParameterList().getParameters();
if( fromParams.length == toParams.length )
{
if( fromParams.length == 0 )
{
foundMethod = miFrom;
foundInferenceMap = copyInferenceMap;
}
int iScore = 0;
for( int ip = 0; ip < fromParams.length; ip++ )
{
PsiParameter fromParam = fromParams[ip];
PsiParameter toParam = toParams[ip];
PsiType toParamType = maybeInferParamType( copyInferenceMap, type( ownersType ), fromParam.getType(), toParam.getType() );
PsiType fromParamType = replaceTypeVariableTypeParametersWithBoundingTypes( fromParam.getType(), type( miFrom.getContainingClass() ) );
if( fromParamType.equals( toParamType ) )
{
// types are the same
iScore += 2;
}
else if( isAssignable( structural, false, fromParamType, toParamType ) )
{
// types are contravariant
iScore += 1;
}
else
{
continue outer;
}
}
if( iTopScore < iScore )
{
foundMethod = miFrom;
foundInferenceMap = copyInferenceMap;
iTopScore = iScore;
}
}
}
}
if( foundMethod != null )
{
inferenceMap.putAllAndInferred( foundInferenceMap );
}
return foundMethod;
}