本文整理汇总了Java中com.intellij.psi.PsiMethod.getContainingClass方法的典型用法代码示例。如果您正苦于以下问题:Java PsiMethod.getContainingClass方法的具体用法?Java PsiMethod.getContainingClass怎么用?Java PsiMethod.getContainingClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiMethod
的用法示例。
在下文中一共展示了PsiMethod.getContainingClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: createMethodFilter
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
/**
* Override in case if your JVMNames slightly different then it can be provided by getJvmSignature method.
*
* @param stepTarget
* @return SmartStepFilter
*/
@Nullable
protected MethodFilter createMethodFilter(SmartStepTarget stepTarget) {
if (stepTarget instanceof MethodSmartStepTarget) {
final PsiMethod method = ((MethodSmartStepTarget)stepTarget).getMethod();
if (stepTarget.needsBreakpointRequest()) {
return Registry.is("debugger.async.smart.step.into") && method.getContainingClass() instanceof PsiAnonymousClass
? new ClassInstanceMethodFilter(method, stepTarget.getCallingExpressionLines())
: new AnonymousClassMethodFilter(method, stepTarget.getCallingExpressionLines());
}
else {
return new BasicStepMethodFilter(method, stepTarget.getCallingExpressionLines());
}
}
if (stepTarget instanceof LambdaSmartStepTarget) {
final LambdaSmartStepTarget lambdaTarget = (LambdaSmartStepTarget)stepTarget;
return new LambdaMethodFilter(lambdaTarget.getLambda(), lambdaTarget.getOrdinal(), stepTarget.getCallingExpressionLines());
}
return null;
}
示例3: visitMethod
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
// no call to super, so it doesn't drill down into inner classes
if (method.isConstructor()) {
return;
}
final String methodName = method.getName();
final PsiClass containingClass = method.getContainingClass();
if (containingClass == null) {
return;
}
final String className = containingClass.getName();
if (className == null) {
return;
}
if (!methodName.equals(className)) {
return;
}
registerMethodError(method, Boolean.valueOf(isOnTheFly()));
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:MethodNameSameAsClassNameInspectionBase.java
示例4: checkSuperMethod
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
public static PsiMethod checkSuperMethod(@NotNull PsiMethod method, @NotNull String actionString) {
PsiClass aClass = method.getContainingClass();
if (aClass == null) return method;
PsiMethod superMethod = method.findDeepestSuperMethod();
if (superMethod == null) return method;
if (ApplicationManager.getApplication().isUnitTestMode()) return superMethod;
PsiClass containingClass = superMethod.getContainingClass();
SuperMethodWarningDialog dialog =
new SuperMethodWarningDialog(
method.getProject(),
DescriptiveNameUtil.getDescriptiveName(method), actionString, containingClass.isInterface() || superMethod.hasModifierProperty(PsiModifier.ABSTRACT),
containingClass.isInterface(), aClass.isInterface(), containingClass.getQualifiedName()
);
dialog.show();
if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) return superMethod;
if (dialog.getExitCode() == SuperMethodWarningDialog.NO_EXIT_CODE) return method;
return null;
}
示例5: isRunFinalizersOnExit
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
private static boolean isRunFinalizersOnExit(
PsiMethodCallExpression expression) {
final PsiReferenceExpression methodExpression =
expression.getMethodExpression();
final String methodName = methodExpression.getReferenceName();
@NonNls final String runFinalizers = "runFinalizersOnExit";
if (!runFinalizers.equals(methodName)) {
return false;
}
final PsiMethod method = expression.resolveMethod();
if (method == null) {
return false;
}
final PsiClass aClass = method.getContainingClass();
if (aClass == null) {
return false;
}
final String className = aClass.getQualifiedName();
if (className == null) {
return false;
}
return "java.lang.System".equals(className);
}
示例6: processQuery
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public void processQuery(@NotNull MethodReferencesSearch.SearchParameters p, @NotNull Processor<PsiReference> consumer) {
final PsiMethod method = p.getMethod();
final PsiClass aClass = method.getContainingClass();
if (aClass == null) return;
final String name = method.getName();
if (StringUtil.isEmpty(name)) return;
final boolean strictSignatureSearch = p.isStrictSignatureSearch();
final PsiMethod[] methods = strictSignatureSearch ? new PsiMethod[]{method} : aClass.findMethodsByName(name, false);
SearchScope accessScope = GroovyScopeUtil.getEffectiveScope(methods);
final SearchScope restrictedByAccess = GroovyScopeUtil.restrictScopeToGroovyFiles(p.getEffectiveSearchScope(), accessScope);
final String textToSearch = findLongestWord(name);
p.getOptimizer().searchWord(textToSearch, restrictedByAccess, UsageSearchContext.IN_STRINGS, true, method,
new MethodTextOccurrenceProcessor(aClass, strictSignatureSearch, methods));
}
示例7: isThreadYield
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
private static boolean isThreadYield(
PsiMethodCallExpression expression) {
final PsiReferenceExpression methodExpression =
expression.getMethodExpression();
@NonNls final String methodName =
methodExpression.getReferenceName();
if (!"yield".equals(methodName)) {
return false;
}
final PsiMethod method = expression.resolveMethod();
if (method == null) {
return false;
}
final PsiClass aClass = method.getContainingClass();
if (aClass == null) {
return false;
}
final String className = aClass.getQualifiedName();
if (className == null) {
return false;
}
return "java.lang.Thread".equals(className);
}
示例8: visitMethod
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
// no call to super, so it doesn't drill down
final PsiClass aClass = method.getContainingClass();
if (aClass == null) {
return;
}
if (aClass.isInterface() || aClass.isAnnotationType()) {
return;
}
if (method.hasModifierProperty(PsiModifier.PRIVATE)) {
return;
}
if (!SerializationUtils.isReadObject(method) &&
!SerializationUtils.isWriteObject(method)) {
return;
}
if (!SerializationUtils.isSerializable(aClass)) {
return;
}
registerMethodError(method);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ReadObjectAndWriteObjectPrivateInspection.java
示例9: afterCheckClass
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
public void afterCheckClass(Context context) {
if (mMethods.size() == 0) return;
JavaContext javaContext = (JavaContext) context;
JavaEvaluator evaluator = javaContext.getEvaluator();
if (evaluator == null) return;
StringBuilder sb = new StringBuilder();
boolean methodInDataAdapter = false;
for (PsiMethod method : mMethods) {
PsiClass pc = method.getContainingClass();
boolean isSubclass = evaluator.implementsInterface(pc, CLASS_DATA_ADAPTER, false);
methodInDataAdapter = methodInDataAdapter || isSubclass;
if (!isSubclass) {
sb.append(method.getName())
.append(",");
}
}
if (!methodInDataAdapter) {
context.report(ISSUE_VIEW_GROUP, Location.create(context.file), "the Custom ViewGroup with data bind should extend DataAdapter,method names:" + sb.toString());
}
}
示例10: visitNewExpression
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public void visitNewExpression(PsiNewExpression expression) {
super.visitNewExpression(expression);
PsiMethod constructor = expression.resolveConstructor();
if (constructor == null) return;
JavaEvaluator evaluator = mContext.getEvaluator();
PsiClass cls = constructor.getContainingClass();
boolean isView = evaluator.extendsClass(cls, CLASS_VIEW, true);
if (!isView) return;
Location location = this.mContext.getLocation(expression);
PsiElement psiElement = expression.getParent();
//创建的变量没有赋值给本地变量,无法指定注解
if (!(psiElement instanceof PsiLocalVariable)) {
this.mContext.report(DynamicNewViewDetector.ISSUE, expression, location, "检测到动态创建view操作,new 操作的结果需要赋值给本地变量");
return;
}
PsiLocalVariable localVariable = (PsiLocalVariable) psiElement;
PsiModifierList modifierList = localVariable.getModifierList();
if (modifierList == null) {
this.mContext.report(DynamicNewViewDetector.ISSUE, expression, location, "检测到动态创建view操作,确认是否为view指定了唯一标识");
return;
}
PsiAnnotation[] annotations = modifierList.getAnnotations();
for (PsiAnnotation annotation : annotations) {
String fullName = annotation.getQualifiedName();
if (IDENTIFIER_ANNOTATION.equals(fullName)) {
return;
}
}
this.mContext.report(DynamicNewViewDetector.ISSUE, expression, location, "检测到动态创建view操作,确认是否为view指定了唯一标识");
}
示例11: isMissingOnError
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public boolean isMissingOnError(PsiMethod method) {
PsiClass clz = method.getContainingClass();
String type = clz.getQualifiedName();
if ("io.reactivex.Observable".equals(type) ||
"io.reactivex.Flowable".equals(type) ||
"io.reactivex.Completable".equals(type) ||
"io.reactivex.Single".equals(type) ||
"io.reactivex.Maybe".equals(type)) {
return checkMethodSignature(method);
}
return false;
}
示例12: isMissingOnError
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public boolean isMissingOnError(PsiMethod method) {
PsiClass clz = method.getContainingClass();
if ("rx.Observable".equals(clz.getQualifiedName()) || "rx.Single".equals(clz.getQualifiedName())) {
return method.getParameterList().getParametersCount() == 1 &&
method.getParameterList().getParameters()[0].getType().equalsToText("rx.functions.Action1");
} else if ("rx.Completable".equals(clz.getQualifiedName())) {
// only a completion callback
return method.getParameterList().getParametersCount() == 1 && method.getParameterList().getParameters()[0].getType().equalsToText("rx.functions.Action0");
}
return false;
}
示例13: getLanguagesToInject
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public void getLanguagesToInject(
@NotNull final PsiLanguageInjectionHost host,
@NotNull final InjectedLanguagePlaces injectionPlacesRegistrar
) {
final PsiElement hostParent = host.getParent();
if (host instanceof ImpexStringImpl) {
final String hostString = StringUtil.unquoteString(host.getText()).toLowerCase();
if (StringUtil.trim(hostString).startsWith("select ")) {
registerInjectionPlace(injectionPlacesRegistrar, host);
}
}
if (hostParent != null) {
if (hostParent.getParent() instanceof PsiMethodCallExpressionImpl) {
final PsiMethodCallExpressionImpl callExpression = (PsiMethodCallExpressionImpl) hostParent.getParent();
final PsiMethod method = callExpression.resolveMethod();
if (method != null) {
final PsiClass containingClass = method.getContainingClass();
if (containingClass != null
&& "FlexibleSearchService".equals(containingClass.getName())
&& "search".equals(method.getName())) {
registerInjectionPlace(injectionPlacesRegistrar, host);
}
}
}
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:30,代码来源:FlexibleSearchInjector.java
示例14: matches
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
public static boolean matches(SmcMethodLikeElement methodLikeElement, PsiMethod method) {
PsiClass containingClass = method.getContainingClass();
SmcFile containingFile = (SmcFile) methodLikeElement.getContainingFile();
PsiClass fsmClass = containingFile.getFsmClass();
if (fsmClass == null || containingClass == null) {
return false;
}
if (!containingClass.isEquivalentTo(fsmClass) && !containingClass.isInheritor(fsmClass, true)) {
return false;
}
return method.getName().equals(methodLikeElement.getName()) &&
method.getParameterList().getParametersCount() == methodLikeElement.getArgumentCount();
}
示例15: visitMethod
import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
final PsiClass aClass = method.getContainingClass();
if (aClass == null) {
return;
}
if (method.getNameIdentifier() == null) {
return;
}
final String methodName = method.getName();
final MethodSignature signature = method.getSignature(PsiSubstitutor.EMPTY);
PsiClass ancestorClass = aClass.getSuperClass();
final Set<PsiClass> visitedClasses = new HashSet<PsiClass>();
while (ancestorClass != null) {
if (!visitedClasses.add(ancestorClass)) {
return;
}
final PsiMethod[] methods =
ancestorClass.findMethodsByName(methodName, false);
for (final PsiMethod testMethod : methods) {
final MethodSignature testSignature = testMethod.getSignature(PsiSubstitutor.EMPTY);
if (!signature.equals(testSignature)) {
continue;
}
if (testMethod.hasModifierProperty(PsiModifier.STATIC) &&
!testMethod.hasModifierProperty(PsiModifier.PRIVATE)) {
registerMethodError(method);
return;
}
}
ancestorClass = ancestorClass.getSuperClass();
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:MethodOverridesStaticMethodInspectionBase.java