本文整理汇总了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);
}
}
示例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)));
}
}
示例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;
}
示例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);
}
示例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));
}
示例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();
}
示例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;
}
示例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();
}