@Nullable @Override public GrTypeArgumentList findElementForParameterInfo(@NotNull CreateParameterInfoContext context) { final GrTypeArgumentList parameterList = ParameterInfoUtils.findParentOfType(context.getFile(), context.getOffset(), GrTypeArgumentList.class); if (parameterList != null) { if (!(parameterList.getParent() instanceof GrCodeReferenceElement)) return null; final GrCodeReferenceElement ref = ((GrCodeReferenceElement)parameterList.getParent()); final PsiElement resolved = ref.resolve(); if (!(resolved instanceof PsiTypeParameterListOwner)) return null; final PsiTypeParameter[] typeParams = ((PsiTypeParameterListOwner)resolved).getTypeParameters(); if (typeParams.length == 0) return null; context.setItemsToShow(typeParams); return parameterList; } return null; }
@Nullable @Override public GrTypeArgumentList findElementForParameterInfo(CreateParameterInfoContext context) { final GrTypeArgumentList parameterList = ParameterInfoUtils.findParentOfType(context.getFile(), context.getOffset(), GrTypeArgumentList.class); if (parameterList != null) { if (!(parameterList.getParent() instanceof GrCodeReferenceElement)) return null; final GrCodeReferenceElement ref = ((GrCodeReferenceElement)parameterList.getParent()); final PsiElement resolved = ref.resolve(); if (!(resolved instanceof PsiTypeParameterListOwner)) return null; final PsiTypeParameter[] typeParams = ((PsiTypeParameterListOwner)resolved).getTypeParameters(); if (typeParams.length == 0) return null; context.setItemsToShow(typeParams); return parameterList; } return null; }
public static PsiSubstitutor getBuilderSubstitutor(@NotNull PsiTypeParameterListOwner classOrMethodToBuild, @NotNull PsiClass innerClass) { PsiSubstitutor substitutor = PsiSubstitutor.EMPTY; if (innerClass.hasModifierProperty(PsiModifier.STATIC)) { PsiTypeParameter[] typeParameters = classOrMethodToBuild.getTypeParameters(); PsiTypeParameter[] builderParams = innerClass.getTypeParameters(); if (typeParameters.length == builderParams.length) { for (int i = 0; i < typeParameters.length; i++) { PsiTypeParameter typeParameter = typeParameters[i]; substitutor = substitutor.put(typeParameter, PsiSubstitutor.EMPTY.substitute(builderParams[i])); } } } return substitutor; }
@NotNull private LombokLightClassBuilder createBuilderClass(@NotNull PsiClass psiClass, @NotNull PsiTypeParameterListOwner psiTypeParameterListOwner, @NotNull String builderClassName, final boolean isStatic, @NotNull PsiAnnotation psiAnnotation) { final String builderClassQualifiedName = psiClass.getQualifiedName() + "." + builderClassName; final LombokLightClassBuilder classBuilder = new LombokLightClassBuilder(psiClass, builderClassName, builderClassQualifiedName) .withContainingClass(psiClass) .withNavigationElement(psiAnnotation) .withParameterTypes(psiTypeParameterListOwner instanceof PsiMethod && ((PsiMethod) psiTypeParameterListOwner).isConstructor() ? psiClass.getTypeParameterList() : psiTypeParameterListOwner.getTypeParameterList()) .withModifier(PsiModifier.PUBLIC); if (isStatic) { classBuilder.withModifier(PsiModifier.STATIC); } return classBuilder; }
private void rebuildTypeParameter(@NotNull PsiTypeParameterListOwner listOwner, @NotNull PsiTypeParameterListOwner resultOwner) { final PsiTypeParameterList fromMethodTypeParameterList = listOwner.getTypeParameterList(); if (listOwner.hasTypeParameters() && null != fromMethodTypeParameterList) { PsiTypeParameterList typeParameterList = PsiMethodUtil.createTypeParameterList(fromMethodTypeParameterList); if (null != typeParameterList) { final PsiTypeParameterList resultOwnerTypeParameterList = resultOwner.getTypeParameterList(); if (null != resultOwnerTypeParameterList) { resultOwnerTypeParameterList.replace(typeParameterList); } } } }
public MakeParameterizedStaticDialog(Project project, PsiTypeParameterListOwner member, String[] nameSuggestions, InternalUsageInfo[] internalUsages) { super(project, member); myProject = project; myNameSuggestions = nameSuggestions; String type = UsageViewUtil.getType(myMember); setTitle(RefactoringBundle.message("make.0.static", StringUtil.capitalize(type))); myAnyNonFieldMembersUsed = buildVariableData(internalUsages); init(); }
public LightTypeParameterBuilder(@NotNull String name, PsiTypeParameterListOwner owner, int index) { super(owner, name); myOwner = owner; myIndex = index; }
@Nullable @Override public PsiTypeParameterListOwner getOwner() { return myOwner; }
public SimpleMakeStaticDialog(Project project, PsiTypeParameterListOwner member) { super(project, member); String type = UsageViewUtil.getType(myMember); setTitle(RefactoringBundle.message("make.0.static", StringUtil.capitalize(type))); init(); }
public AbstractMakeStaticDialog(Project project, PsiTypeParameterListOwner member) { super(project, true); myMember = member; myMemberName = member.getName(); }
@Override public PsiTypeParameterListOwner getOwner() { return getDelegate().getOwner(); }
@Override public PsiTypeParameterListOwner getOwner() { return null; }