private static void processDummyConstructor(MethodsProcessor processor, PsiClass aClass) { if (aClass instanceof PsiAnonymousClass) return; try { PsiMethod[] constructors = aClass.getConstructors(); if (constructors.length != 0) { return; } final PsiElementFactory factory = JavaPsiFacade.getInstance(aClass.getProject()).getElementFactory(); final PsiMethod dummyConstructor = factory.createConstructor(); PsiIdentifier nameIdentifier = aClass.getNameIdentifier(); if (nameIdentifier != null) { dummyConstructor.getNameIdentifier().replace(nameIdentifier); } processor.forceAddResult(dummyConstructor); } catch (IncorrectOperationException e) { LOG.error(e); } }
private static boolean processQualifierResult(@NotNull JavaResolveResult qualifierResult, @NotNull MethodsProcessor processor, @NotNull PsiMethodCallExpression methodCall) throws MethodProcessorSetupFailedException { PsiElement resolve = qualifierResult.getElement(); if (resolve == null) { throw new MethodProcessorSetupFailedException("Cant determine qualifier class!"); } if (resolve instanceof PsiTypeParameter) { processor.setAccessClass((PsiClass)resolve); } else if (resolve instanceof PsiClass) { PsiExpression qualifier = methodCall.getMethodExpression().getQualifierExpression(); if (!(qualifier instanceof PsiSuperExpression)) { processor.setAccessClass((PsiClass)PsiUtil.getAccessObjectClass(qualifier).getElement()); } } processor.setIsConstructor(false); processor.setName(methodCall.getMethodExpression().getReferenceName()); ResolveState state = ResolveState.initial().put(PsiSubstitutor.KEY, qualifierResult.getSubstitutor()); return resolve.processDeclarations(processor, state, methodCall, methodCall); }
private static boolean processQualifierResult(@NotNull JavaResolveResult qualifierResult, @NotNull MethodsProcessor processor, @NotNull PsiMethodCallExpression methodCall) throws MethodProcessorSetupFailedException { PsiElement resolve = qualifierResult.getElement(); if (resolve == null) { throw new MethodProcessorSetupFailedException("Cant determine qualifier class!"); } if (resolve instanceof PsiTypeParameter) { processor.setAccessClass((PsiClass)resolve); } else if (resolve instanceof PsiClass) { PsiExpression qualifier = methodCall.getMethodExpression().getQualifierExpression(); if (!(qualifier instanceof PsiSuperExpression)) { processor.setAccessClass((PsiClass)PsiUtil.getAccessObjectClass(qualifier).getElement()); } else if (((PsiSuperExpression)qualifier).getQualifier() != null && PsiUtil.isLanguageLevel8OrHigher(qualifier) && CommonClassNames.JAVA_LANG_CLONEABLE.equals(((PsiClass)resolve).getQualifiedName()) && ((PsiClass)resolve).isInterface()) { processor.setAccessClass((PsiClass)resolve); } } processor.setIsConstructor(false); processor.setName(methodCall.getMethodExpression().getReferenceName()); ResolveState state = ResolveState.initial().put(PsiSubstitutor.KEY, qualifierResult.getSubstitutor()); return resolve.processDeclarations(processor, state, methodCall, methodCall); }
@Override public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) { if (isEnum()) { if (!PsiClassImplUtil.processDeclarationsInEnum(processor, state, myInnersCache)) return false; } LanguageLevel level = processor instanceof MethodsProcessor ? ((MethodsProcessor)processor).getLanguageLevel() : PsiUtil.getLanguageLevel(place); return PsiClassImplUtil.processDeclarationsInClass(this, processor, state, null, lastParent, place, level, false); }
@Override public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) { LanguageLevel languageLevel = processor instanceof MethodsProcessor ? ((MethodsProcessor)processor).getLanguageLevel() : PsiUtil.getLanguageLevel(place); return PsiClassImplUtil.processDeclarationsInClass(this, processor, state, null, lastParent, place, languageLevel, false); }
private static boolean processQualifierResult(@NotNull JavaResolveResult qualifierResult, @NotNull MethodsProcessor processor, @NotNull PsiMethodCallExpression methodCall) throws MethodProcessorSetupFailedException { PsiElement resolve = qualifierResult.getElement(); if(resolve == null) { throw new MethodProcessorSetupFailedException("Cant determine qualifier class!"); } if(resolve instanceof PsiTypeParameter) { processor.setAccessClass((PsiClass) resolve); } else if(resolve instanceof PsiClass) { PsiExpression qualifier = methodCall.getMethodExpression().getQualifierExpression(); if(!(qualifier instanceof PsiSuperExpression)) { processor.setAccessClass((PsiClass) PsiUtil.getAccessObjectClass(qualifier).getElement()); } else if(((PsiSuperExpression) qualifier).getQualifier() != null && PsiUtil.isLanguageLevel8OrHigher(qualifier) && CommonClassNames.JAVA_LANG_CLONEABLE.equals(((PsiClass) resolve).getQualifiedName()) && ((PsiClass) resolve).isInterface()) { processor.setAccessClass((PsiClass) resolve); } } processor.setIsConstructor(false); processor.setName(methodCall.getMethodExpression().getReferenceName()); ResolveState state = ResolveState.initial().put(PsiSubstitutor.KEY, qualifierResult.getSubstitutor()); return resolve.processDeclarations(processor, state, methodCall, methodCall); }
private static void processDummyConstructor(MethodsProcessor processor, PsiClass aClass) { if(aClass instanceof PsiAnonymousClass) { return; } try { PsiMethod[] constructors = aClass.getConstructors(); if(constructors.length != 0) { return; } final PsiElementFactory factory = JavaPsiFacade.getInstance(aClass.getProject()).getElementFactory(); final PsiMethod dummyConstructor = factory.createConstructor(); PsiIdentifier nameIdentifier = aClass.getNameIdentifier(); if(nameIdentifier != null) { dummyConstructor.getNameIdentifier().replace(nameIdentifier); } processor.forceAddResult(dummyConstructor); } catch(IncorrectOperationException e) { LOG.error(e); } }
@Override public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) { LanguageLevel level = processor instanceof MethodsProcessor ? ((MethodsProcessor) processor).getLanguageLevel() : PsiUtil.getLanguageLevel(place); return PsiClassImplUtil.processDeclarationsInClass(this, processor, state, null, lastParent, place, level, false); }