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


Java GenerateMembersUtil.insertMembersAtOffset方法代码示例

本文整理汇总了Java中com.intellij.codeInsight.generation.GenerateMembersUtil.insertMembersAtOffset方法的典型用法代码示例。如果您正苦于以下问题:Java GenerateMembersUtil.insertMembersAtOffset方法的具体用法?Java GenerateMembersUtil.insertMembersAtOffset怎么用?Java GenerateMembersUtil.insertMembersAtOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.codeInsight.generation.GenerateMembersUtil的用法示例。


在下文中一共展示了GenerateMembersUtil.insertMembersAtOffset方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: insertGenerationInfos

import com.intellij.codeInsight.generation.GenerateMembersUtil; //导入方法依赖的package包/类
private static void insertGenerationInfos(InsertionContext context, List<PsiGenerationInfo<PsiMethod>> infos)
{
	List<PsiGenerationInfo<PsiMethod>> newInfos = GenerateMembersUtil.insertMembersAtOffset(context.getFile(), context.getStartOffset(), infos);
	if(!newInfos.isEmpty())
	{
		final List<PsiElement> elements = new ArrayList<PsiElement>();
		for(GenerationInfo member : newInfos)
		{
			if(!(member instanceof TemplateGenerationInfo))
			{
				final PsiMember psiMember = member.getPsiMember();
				if(psiMember != null)
				{
					elements.add(psiMember);
				}
			}
		}

		GlobalInspectionContextBase.cleanupElements(context.getProject(), null, elements.toArray(new PsiElement[elements.size()]));
		newInfos.get(0).positionCaret(context.getEditor(), true);
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:23,代码来源:JavaGenerateMemberCompletionContributor.java

示例2: addOrReplaceMethod

import com.intellij.codeInsight.generation.GenerateMembersUtil; //导入方法依赖的package包/类
private static void addOrReplaceMethod(final PsiMethod method, final PsiClass implementor) throws IncorrectOperationException {
  final PsiMethod accept = implementor.findMethodBySignature(method, false);
  if (accept != null) {
    accept.replace(method);
  }
  else {
    GenerateMembersUtil.insertMembersAtOffset(implementor.getContainingFile(), implementor.getLastChild().getTextOffset(), Collections.<GenerationInfo>singletonList(new PsiGenerationInfo<PsiMethod>(method)));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:GenerateVisitorByHierarchyAction.java

示例3: generateDummyMethod

import com.intellij.codeInsight.generation.GenerateMembersUtil; //导入方法依赖的package包/类
@Nullable
private static PsiMethod generateDummyMethod(Editor editor, PsiFile file) throws IncorrectOperationException {
  final PsiMethod method = TestIntegrationUtils.createDummyMethod(file);
  final PsiGenerationInfo<PsiMethod> info = OverrideImplementUtil.createGenerationInfo(method);

  int offset = findOffsetToInsertMethodTo(editor, file);
  GenerateMembersUtil.insertMembersAtOffset(file, offset, Collections.singletonList(info));

  final PsiMethod member = info.getPsiMember();
  return member != null ? CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(member) : null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:BaseGenerateTestSupportMethodAction.java

示例4: doTest

import com.intellij.codeInsight.generation.GenerateMembersUtil; //导入方法依赖的package包/类
private void doTest() throws Exception {
  configureByFile(BASE_PATH + getTestName(false) + ".java");
  PsiElementFactory factory = JavaPsiFacade.getInstance(getProject()).getElementFactory();
  PsiMethod method = factory.createMethod("foo", PsiType.VOID);
  int offset = getEditor().getCaretModel().getOffset();
  List<GenerationInfo> list = Collections.<GenerationInfo>singletonList(new PsiGenerationInfo<PsiMethod>(method));
  List<GenerationInfo> members = GenerateMembersUtil.insertMembersAtOffset(getFile(), offset, list);
  members.get(0).positionCaret(myEditor, true);
  checkResultByFile(null, BASE_PATH + getTestName(false) + "_after.java", true);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:GenerateMembersUtilTest.java

示例5: handleInsert

import com.intellij.codeInsight.generation.GenerateMembersUtil; //导入方法依赖的package包/类
@Override
public void handleInsert(InsertionContext context, LookupElement item) {
  context.getDocument().deleteString(context.getStartOffset(), context.getTailOffset());
  PsiMethod method = (PsiMethod)item.getObject();
  List<PsiMethod> prototypes = OverrideImplementUtil.overrideOrImplementMethod(myPsiClass, method, false);
  context.commitDocument();
  GenerateMembersUtil.insertMembersAtOffset(context.getFile(), context.getStartOffset(),
                                            OverrideImplementUtil.convert2GenerationInfos(prototypes));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:GroovyMethodOverrideHandler.java

示例6: insertGenerationInfos

import com.intellij.codeInsight.generation.GenerateMembersUtil; //导入方法依赖的package包/类
private static void insertGenerationInfos(InsertionContext context, List<PsiGenerationInfo<PsiMethod>> infos) {
  List<PsiGenerationInfo<PsiMethod>> newInfos = GenerateMembersUtil
    .insertMembersAtOffset(context.getFile(), context.getStartOffset(), infos);
  if (!newInfos.isEmpty()) {
    newInfos.get(0).positionCaret(context.getEditor(), true);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:8,代码来源:JavaGenerateMemberCompletionContributor.java

示例7: insertNewMethod

import com.intellij.codeInsight.generation.GenerateMembersUtil; //导入方法依赖的package包/类
@Override
public PsiMethod insertNewMethod(PsiClass clazz, @NotNull PsiMethod newMethod, Editor editor)
{
	int offset = (editor != null) ? editor.getCaretModel().getOffset() : (clazz.getTextRange().getEndOffset() - 1);
	final PsiGenerationInfo<PsiMethod> generationInfo = new PsiGenerationInfo<PsiMethod>(newMethod, false);
	GenerateMembersUtil.insertMembersAtOffset(clazz.getContainingFile(), offset, Arrays.asList(generationInfo));
	return generationInfo.getPsiMember();
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:9,代码来源:InsertAtCaretStrategy.java

示例8: generateDummyMethod

import com.intellij.codeInsight.generation.GenerateMembersUtil; //导入方法依赖的package包/类
@Nullable
private static PsiMethod generateDummyMethod(Editor editor, PsiFile file) throws IncorrectOperationException {
  final PsiMethod method = TestIntegrationUtils.createDummyMethod(file);
  final PsiGenerationInfo<PsiMethod> info = OverrideImplementUtil.createGenerationInfo(method);

  int offset = findOffsetToInsertMethodTo(editor, file);
  GenerateMembersUtil.insertMembersAtOffset(file, offset, Collections.singletonList(info));

  final PsiMethod member = info.getPsiMember();
  return member != null ? CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(member) : null;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:12,代码来源:BaseGenerateTestSupportMethodAction.java

示例9: insertNewMethod

import com.intellij.codeInsight.generation.GenerateMembersUtil; //导入方法依赖的package包/类
public PsiMethod insertNewMethod(PsiClass clazz, @NotNull PsiMethod newMethod, Editor editor) {
  int offset = (editor != null) ? editor.getCaretModel().getOffset() : (clazz.getTextRange().getEndOffset() - 1);
  final PsiGenerationInfo<PsiMethod> generationInfo = new PsiGenerationInfo<PsiMethod>(newMethod, false);
  GenerateMembersUtil.insertMembersAtOffset(clazz.getContainingFile(), offset, Arrays.asList(generationInfo));
  return generationInfo.getPsiMember();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:InsertAtCaretStrategy.java


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