mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
create groovy method from usage by groovy ref
This commit is contained in:
+1
@@ -202,6 +202,7 @@ public class CreateFromUsageUtils {
|
||||
PsiDocumentManager manager = PsiDocumentManager.getInstance(method.getProject());
|
||||
manager.doPostponedOperationsAndUnblockDocument(manager.getDocument(containingFile));
|
||||
EditorModificationUtil.insertStringAtCaret(newEditor, lineIndent);
|
||||
EditorModificationUtil.insertStringAtCaret(newEditor, "\n", false, false);
|
||||
}
|
||||
else {
|
||||
//correct position caret for groovy and java methods
|
||||
|
||||
+1
-1
@@ -285,7 +285,7 @@ public class CreateMethodFromUsageFix extends CreateFromUsageBaseFix {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean checkTypeParam(final PsiMethod method, final PsiTypeParameter typeParameter) {
|
||||
public static boolean checkTypeParam(final PsiMethod method, final PsiTypeParameter typeParameter) {
|
||||
final String typeParameterName = typeParameter.getName();
|
||||
|
||||
final PsiTypeVisitor<Boolean> visitor = new PsiTypeVisitor<Boolean>() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -54,11 +54,15 @@ public class JavaTemplateUtil {
|
||||
PsiMethod method = PsiTreeUtil.getParentOfType(element, PsiMethod.class);
|
||||
if (method != null) {
|
||||
PsiTypeParameterList paramList = method.getTypeParameterList();
|
||||
PsiTypeParameter[] params = paramList.getTypeParameters();
|
||||
PsiTypeParameter[] params = paramList != null ? paramList.getTypeParameters() : PsiTypeParameter.EMPTY_ARRAY;
|
||||
for (PsiTypeParameter param : params) {
|
||||
if (param.getName().equals(aClass.getName())) return;
|
||||
}
|
||||
try {
|
||||
if (paramList == null) {
|
||||
final PsiTypeParameterList newList = JVMElementFactories.getFactory(method.getLanguage(), project).createTypeParameterList();
|
||||
paramList = (PsiTypeParameterList)method.addAfter(newList, method.getModifierList());
|
||||
}
|
||||
paramList.add(aClass.copy());
|
||||
PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(document);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user