@Override public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (element instanceof PsiField) { final PsiType type = ((PsiField)element).getType(); final String typeText = type instanceof PsiClassType ? CommonClassNames.JAVA_UTIL_COLLECTION + "<" + type.getCanonicalText() + ">" : CommonClassNames.JAVA_UTIL_COLLECTION; LightFieldBuilder lightField = new LightFieldBuilder(((PsiField)element).getName(), typeText, element); lightField.setContainingClass(myCollectionClass); lightField.setOriginInfo("spread collection field"); return super.execute(lightField, state); } return true; }
@Override public boolean execute(@NotNull PsiElement element, ResolveState state) { if (element instanceof PsiField) { final PsiType type = ((PsiField)element).getType(); final String typeText = type instanceof PsiClassType ? JAVA_UTIL_COLLECTION + "<" + type.getCanonicalText() + ">" : JAVA_UTIL_COLLECTION; LightFieldBuilder lightField = new LightFieldBuilder(((PsiField)element).getName(), typeText, element); lightField.setContainingClass(myCollectionClass); lightField.setOriginInfo("spread collection field"); return super.execute(lightField, state); } return true; }
@NotNull @Override public PsiField buildToPsi(@Nullable PsiElement parent) { LightFieldBuilder builder = new LightFieldBuilder(normalize(myName), normalizeType(myType), myNavTarget); builder.setModifiers(ArrayUtil.toStringArray(myModifiers)); builder.setContainingClass((PsiClass) parent); return builder; }
public LightPsiClassBuilder addField(PsiField field) { if (field instanceof LightFieldBuilder) { ((LightFieldBuilder) field).setContainingClass(this); } myFields.add(field); return this; }
private void addField(List<PsiField> fields, String name, String type) { PsiClassType classType = JavaPsiFacade.getElementFactory(getProject()).createTypeByFQClassName(type, getResolveScope()); LightFieldBuilder builder = new LightFieldBuilder(getManager(), name, classType); builder.setModifiers(PsiModifier.PRIVATE, PsiModifier.FINAL); builder.setContainingClass(this); fields.add(builder); }