本文整理汇总了Java中com.intellij.codeInsight.generation.ClassMember类的典型用法代码示例。如果您正苦于以下问题:Java ClassMember类的具体用法?Java ClassMember怎么用?Java ClassMember使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ClassMember类属于com.intellij.codeInsight.generation包,在下文中一共展示了ClassMember类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doTest
import com.intellij.codeInsight.generation.ClassMember; //导入依赖的package包/类
private void doTest(final boolean preSelect) throws Exception {
String name = getTestName(false);
configureByFile("/codeInsight/generateConstructor/before" + name + ".java");
new GenerateConstructorHandler() {
@Override
protected ClassMember[] chooseMembers(ClassMember[] members,
boolean allowEmptySelection,
boolean copyJavadocCheckbox,
Project project, Editor editor) {
if (preSelect) {
final List<ClassMember> preselection = GenerateConstructorHandler.preselect(members);
return preselection.toArray(new ClassMember[preselection.size()]);
}
else {
return members;
}
}
}.invoke(getProject(), getEditor(), getFile());
checkResultByFile("/codeInsight/generateConstructor/after" + name + ".java");
}
示例2: generateMemberPrototypes
import com.intellij.codeInsight.generation.ClassMember; //导入依赖的package包/类
@NotNull
@Override
protected List<? extends GenerationInfo> generateMemberPrototypes(PsiClass aClass, ClassMember[] members)
throws IncorrectOperationException {
final String templName = JavaTemplateUtil.TEMPLATE_FROM_USAGE_METHOD_BODY;
final FileTemplate template = FileTemplateManager.getInstance(aClass.getProject()).getCodeTemplate(templName);
final GrMethod getter = genGetter(aClass, template);
final GrMethod setter = genSetter(aClass, template);
final ArrayList<GroovyGenerationInfo<GrMethod>> result = new ArrayList<GroovyGenerationInfo<GrMethod>>();
if (getter != null) result.add(new GroovyGenerationInfo<GrMethod>(getter, true));
if (setter != null) result.add(new GroovyGenerationInfo<GrMethod>(setter, true));
return result;
}
示例3: doTest
import com.intellij.codeInsight.generation.ClassMember; //导入依赖的package包/类
protected void doTest() throws Exception {
configureByFile("/generateGetterSetter/before" + getTestName(false) + ".java");
new GenerateGetterAndSetterHandler() {
@Nullable
@Override
protected ClassMember[] chooseMembers(ClassMember[] members,
boolean allowEmptySelection,
boolean copyJavadocCheckbox,
Project project,
@Nullable Editor editor) {
return members;
}
}.invoke(getProject(), getEditor(), getFile());
UIUtil.dispatchAllInvocationEvents();
checkResultByFile("/generateGetterSetter/after" + getTestName(false) + ".java");
}
示例4: generateMemberPrototypes
import com.intellij.codeInsight.generation.ClassMember; //导入依赖的package包/类
@NotNull
@Override
protected List<? extends GenerationInfo> generateMemberPrototypes(PsiClass aClass, ClassMember[] members)
throws IncorrectOperationException {
final String templName = JavaTemplateUtil.TEMPLATE_FROM_USAGE_METHOD_BODY;
final FileTemplate template = FileTemplateManager.getInstance().getCodeTemplate(templName);
final GrMethod getter = genGetter(aClass, template);
final GrMethod setter = genSetter(aClass, template);
final ArrayList<GroovyGenerationInfo<GrMethod>> result = new ArrayList<GroovyGenerationInfo<GrMethod>>();
if (getter != null) result.add(new GroovyGenerationInfo<GrMethod>(getter, true));
if (setter != null) result.add(new GroovyGenerationInfo<GrMethod>(setter, true));
return result;
}
示例5: process
import com.intellij.codeInsight.generation.ClassMember; //导入依赖的package包/类
@Override
protected void process(List<ClassMember> classMembers) {
for (ClassMember classMember : classMembers) {
final PsiElementClassMember elementClassMember = (PsiElementClassMember) classMember;
PsiField psiField = (PsiField) elementClassMember.getPsiElement();
PsiMethod psiMethod = PropertyUtil.findPropertySetter(psiField.getContainingClass(), psiField.getName(), false, false);
if (null != psiMethod) {
PsiModifierList modifierList = psiField.getModifierList();
if (null != modifierList) {
PsiAnnotation psiAnnotation = modifierList.addAnnotation(Setter.class.getName());
psiMethod.delete();
}
}
}
}
示例6: process
import com.intellij.codeInsight.generation.ClassMember; //导入依赖的package包/类
@Override
protected void process(List<ClassMember> classMembers) {
for (ClassMember classMember : classMembers) {
final PsiElementClassMember elementClassMember = (PsiElementClassMember) classMember;
PsiField psiField = (PsiField) elementClassMember.getPsiElement();
PsiMethod psiMethod = PropertyUtil.findPropertyGetter(psiField.getContainingClass(), psiField.getName(), false, false);
if (null != psiMethod) {
PsiModifierList modifierList = psiField.getModifierList();
if (null != modifierList) {
PsiAnnotation psiAnnotation = modifierList.addAnnotation(Getter.class.getName());
// psiAnnotation.setDeclaredAttributeValue("value", )
psiMethod.delete();
}
}
}
}
示例7: getAllOriginalMembers
import com.intellij.codeInsight.generation.ClassMember; //导入依赖的package包/类
@Override
protected ClassMember[] getAllOriginalMembers(PsiClass aClass) {
PsiField[] fields = aClass.getFields();
ArrayList<ClassMember> array = new ArrayList<ClassMember>();
ImplicitUsageProvider[] implicitUsageProviders = Extensions.getExtensions(ImplicitUsageProvider.EP_NAME);
fieldLoop:
for (PsiField field : fields) {
if (field.hasModifierProperty(PsiModifier.STATIC)) {
continue;
}
if (field.hasModifierProperty(PsiModifier.FINAL) && field.getInitializer() != null) {
continue;
}
for (ImplicitUsageProvider provider : implicitUsageProviders) {
if (!(provider instanceof LombokImplicitUsageProvider) && provider.isImplicitWrite(field)) {
continue fieldLoop;
}
}
array.add(new PsiFieldMember(field));
}
return array.toArray(new ClassMember[array.size()]);
}
示例8: doTest
import com.intellij.codeInsight.generation.ClassMember; //导入依赖的package包/类
protected void doTest(final boolean preSelect) throws Exception {
myFixture.configureByFile(getBasePath() + "/before" + getTestName(false) + ".java");
new LombokGenerateConstructorHandler() {
@Override
protected ClassMember[] chooseMembers(ClassMember[] members, boolean allowEmpty, boolean copyJavadoc, Project project, Editor editor) {
if (preSelect) {
List<ClassMember> preselection = GenerateConstructorHandler.preselect(members);
return preselection.toArray(new ClassMember[preselection.size()]);
} else {
return members;
}
}
}.invoke(getProject(), getEditor(), getFile());
checkResultByFile(getBasePath() + "/after" + getTestName(false) + ".java");
}
示例9: generateCopyConstructor
import com.intellij.codeInsight.generation.ClassMember; //导入依赖的package包/类
private PsiMethod generateCopyConstructor(PsiClass psiClass, ClassMember[] copyableFields) {
String parameterName = "other";
StringBuilder code = new StringBuilder();
code.append(String.format("public %s(%s %s) {", psiClass.getName(), psiClass.getName(), parameterName));
boolean superclassHasCopyConstructor = ConstructorUtil.hasCopyConstructor(psiClass.getSuperClass());
if (superclassHasCopyConstructor) {
code.append(String.format("super(%s);", parameterName));
}
for (ClassMember fieldMember : copyableFields) {
PsiField field = ((PsiFieldMember) fieldMember).getElement();
String name = field.getName();
code.append(String.format("this.%s = %s.%s;", name, parameterName, name));
}
code.append("}");
PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(psiClass.getProject());
PsiMethod constructor = elementFactory.createMethodFromText(code.toString(), psiClass);
return constructor;
}
示例10: generateMemberPrototypes
import com.intellij.codeInsight.generation.ClassMember; //导入依赖的package包/类
@NotNull
@Override
protected List<? extends GenerationInfo> generateMemberPrototypes(PsiClass aClass, ClassMember[] members)
throws IncorrectOperationException {
final String templName = JavaTemplateUtil.TEMPLATE_FROM_USAGE_METHOD_BODY;
final FileTemplate template = FileTemplateManager.getInstance(aClass.getProject()).getCodeTemplate(templName);
final GrMethod method = genMethod(aClass, template);
return method != null
? Collections.singletonList(new GroovyGenerationInfo<GrMethod>(method, true))
: Collections.<GenerationInfo>emptyList();
}
示例11: chooseMembers
import com.intellij.codeInsight.generation.ClassMember; //导入依赖的package包/类
@Nullable
@Override
protected ClassMember[] chooseMembers(ClassMember[] members,
boolean allowEmptySelection,
boolean copyJavadocCheckbox,
Project project,
@Nullable Editor editor) {
return ClassMember.EMPTY_ARRAY;
}
示例12: generateMemberPrototypes
import com.intellij.codeInsight.generation.ClassMember; //导入依赖的package包/类
@NotNull
@Override
protected List<? extends GenerationInfo> generateMemberPrototypes(PsiClass aClass, ClassMember[] members) throws IncorrectOperationException {
List<? extends GenerationInfo> memberPrototypes = super.generateMemberPrototypes(aClass, members);
for (GenerationInfo memberPrototype : memberPrototypes) {
PsiModifierList modifierList = memberPrototype.getPsiMember().getModifierList();
if (modifierList != null) {
modifierList.addAnnotation("javax.inject.Inject");
}
}
return memberPrototypes;
}
示例13: generateMemberPrototypes
import com.intellij.codeInsight.generation.ClassMember; //导入依赖的package包/类
@NotNull
@Override
protected List<? extends GenerationInfo> generateMemberPrototypes(PsiClass aClass, ClassMember[] members)
throws IncorrectOperationException {
final String templName = JavaTemplateUtil.TEMPLATE_FROM_USAGE_METHOD_BODY;
final FileTemplate template = FileTemplateManager.getInstance().getCodeTemplate(templName);
final GrMethod method = genMethod(aClass, template);
return method != null
? Collections.singletonList(new GroovyGenerationInfo<GrMethod>(method, true))
: Collections.<GenerationInfo>emptyList();
}
示例14: doTest
import com.intellij.codeInsight.generation.ClassMember; //导入依赖的package包/类
protected void doTest() throws Exception {
configureByFile("/generateGetterSetter/before" + getTestName(false) + ".java");
new GenerateGetterAndSetterHandler() {
@Nullable
@Override
protected ClassMember[] chooseMembers(ClassMember[] members,
boolean allowEmptySelection,
boolean copyJavadocCheckbox,
Project project,
@Nullable Editor editor) {
return members;
}
}.invoke(getProject(), getEditor(), getFile());
checkResultByFile("/generateGetterSetter/after" + getTestName(false) + ".java");
}
示例15: BaseRefactorHandler
import com.intellij.codeInsight.generation.ClassMember; //导入依赖的package包/类
public BaseRefactorHandler(DataContext dataContext, Project project) {
this.project = project;
editor = PlatformDataKeys.EDITOR.getData(dataContext);
PsiFile psiFile = DataKeys.PSI_FILE.getData(dataContext);
PsiClass psiClass = OverrideImplementUtil.getContextClass(project, editor, psiFile, false);
List<EncapsulatableClassMember> classMembers = getEncapsulatableClassMembers(psiClass);
chooser = new MemberChooser<ClassMember>(
classMembers.toArray(new ClassMember[classMembers.size()]), true, true, project);
chooser.setTitle(getChooserTitle());
chooser.setCopyJavadocVisible(false);
}