mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
create parameter be name and type in context: now also for java
This commit is contained in:
@@ -111,6 +111,7 @@ public interface JVMElementFactory {
|
||||
*/
|
||||
@NotNull
|
||||
PsiParameter createParameter(@NotNull @NonNls String name, PsiType type) throws IncorrectOperationException;
|
||||
PsiParameter createParameter(@NotNull @NonNls String name, PsiType type, PsiElement context) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a parameter list from the specified parameter names and types.
|
||||
|
||||
@@ -282,6 +282,13 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
|
||||
return (PsiParameter)codeStyleManager.reformat(parameter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiParameter createParameter(@NotNull @NonNls String name, PsiType type, PsiElement context) throws IncorrectOperationException {
|
||||
final PsiMethod psiMethod = createMethodFromText("void f(" + type.getCanonicalText() + " " + name + ") {}", context);
|
||||
final PsiParameter[] parameters = psiMethod.getParameterList().getParameters();
|
||||
return parameters[0];
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiCodeBlock createCodeBlock() {
|
||||
|
||||
+6
@@ -978,6 +978,12 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
|
||||
return createParameter(name, type == null ? null : type.getCanonicalText(), null, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public GrParameter createParameter(@NotNull @NonNls String name, @Nullable PsiType type, PsiElement context) throws IncorrectOperationException {
|
||||
return createParameter(name, type == null ? null : type.getCanonicalText(), null, context instanceof GroovyPsiElement ? (GroovyPsiElement)context : null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiParameterList createParameterList(@NotNull @NonNls String[] names, @NotNull PsiType[] types) throws IncorrectOperationException {
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ public class ClosureSyntheticParameter extends GrLightParameter implements Navig
|
||||
|
||||
public PsiElement setName(@NotNull String newName) throws IncorrectOperationException {
|
||||
if (!newName.equals(getName())) {
|
||||
GrParameter parameter = GroovyPsiElementFactory.getInstance(getProject()).createParameter(newName, null, null);
|
||||
GrParameter parameter = GroovyPsiElementFactory.getInstance(getProject()).createParameter(newName, (String)null, null);
|
||||
myClosure.addParameter(parameter);
|
||||
}
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user