当前位置: 首页>>代码示例>>Java>>正文


Java ClassMember类代码示例

本文整理汇总了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");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:GenerateConstructorTest.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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:GroovyGeneratePropertyMissingHandler.java

示例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");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:GenerateGetterSetterTest.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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:GroovyGeneratePropertyMissingHandler.java

示例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();
      }
    }
  }
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:18,代码来源:RefactorSetterHandler.java

示例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();
        }
      }
    }
  }
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:20,代码来源:RefactorGetterHandler.java

示例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()]);
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:25,代码来源:LombokGenerateConstructorHandler.java

示例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");
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:18,代码来源:GenerateConstructorHandlerTest.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;
}
 
开发者ID:jkovacs,项目名称:CopyConstructorPlugin,代码行数:23,代码来源:GenerateCopyConstructorHandler.java

示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:GroovyGenerateMethodMissingHandler.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:GroovyGenerateMethodMissingHandler.java

示例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;
}
 
开发者ID:phajduk,项目名称:dagger2-intellij-plugin,代码行数:13,代码来源:GenerateInjectedConstructorHandler.java

示例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();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:14,代码来源:GroovyGenerateMethodMissingHandler.java

示例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");
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:16,代码来源:GenerateGetterSetterTest.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);
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:14,代码来源:BaseRefactorHandler.java


注:本文中的com.intellij.codeInsight.generation.ClassMember类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。