mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Provide Domain class dynamic methods via AST transformation. Methods should be getted from GormInstanceApi, GormStaticApi, GormValidationApi.
This commit is contained in:
@@ -264,21 +264,13 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
|
||||
final PsiTypeParameter[] typeParameters = aClass.getTypeParameters();
|
||||
assert typeParameters.length == 1 : aClass;
|
||||
|
||||
final Map<PsiTypeParameter, PsiType> map = Collections.singletonMap(typeParameters[0], parameter);
|
||||
return createType(aClass, createSubstitutor(map));
|
||||
return createType(aClass, PsiSubstitutor.EMPTY.put(typeParameters[0], parameter));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiClassType createType(@NotNull final PsiClass aClass, final PsiType... parameters) {
|
||||
final PsiTypeParameter[] typeParameters = aClass.getTypeParameters();
|
||||
assert parameters.length == typeParameters.length;
|
||||
|
||||
final Map<PsiTypeParameter, PsiType> map = new java.util.HashMap<PsiTypeParameter, PsiType>();
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
map.put(typeParameters[i], parameters[i]);
|
||||
}
|
||||
return createType(aClass, createSubstitutor(map));
|
||||
return createType(aClass, PsiSubstitutor.EMPTY.putAll(aClass, parameters));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -30,7 +31,7 @@ public class LightVariableBuilder<T extends LightVariableBuilder> extends LightE
|
||||
setNavigationElement(navigationElement);
|
||||
}
|
||||
|
||||
public LightVariableBuilder(PsiManager manager, @NotNull String name, @NotNull PsiType type, Language language) {
|
||||
public LightVariableBuilder(PsiManager manager, @Nullable String name, @NotNull PsiType type, Language language) {
|
||||
super(manager, language);
|
||||
myName = name;
|
||||
myType = type;
|
||||
|
||||
+17
-6
@@ -65,6 +65,8 @@ public class GrLightMethodBuilder extends LightElement implements GrMethod {
|
||||
private String[] myNamedParametersArray = ArrayUtil.EMPTY_STRING_ARRAY;
|
||||
private Runnable myOnRename;
|
||||
|
||||
private Object myData;
|
||||
|
||||
public GrLightMethodBuilder(PsiManager manager, String name) {
|
||||
this(manager, name, new GrLightParameterListBuilder(manager, GroovyFileType.GROOVY_LANGUAGE), null);
|
||||
}
|
||||
@@ -98,17 +100,14 @@ public class GrLightMethodBuilder extends LightElement implements GrMethod {
|
||||
}
|
||||
|
||||
public PsiTypeParameterList getTypeParameterList() {
|
||||
//todo
|
||||
return null;
|
||||
}
|
||||
|
||||
public GrDocComment getDocComment() {
|
||||
//todo
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isDeprecated() {
|
||||
//todo
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -202,6 +201,7 @@ public class GrLightMethodBuilder extends LightElement implements GrMethod {
|
||||
return myReturnType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GrTypeElement setReturnType(String returnType) {
|
||||
setReturnType(JavaPsiFacade.getInstance(myManager.getProject()).getElementFactory().createTypeByFQClassName(returnType, getResolveScope()));
|
||||
return null;
|
||||
@@ -242,7 +242,6 @@ public class GrLightMethodBuilder extends LightElement implements GrMethod {
|
||||
|
||||
@NotNull
|
||||
public PsiReferenceList getThrowsList() {
|
||||
//todo
|
||||
return new LightEmptyImplementsList(getManager());
|
||||
}
|
||||
|
||||
@@ -256,8 +255,9 @@ public class GrLightMethodBuilder extends LightElement implements GrMethod {
|
||||
}
|
||||
|
||||
public boolean isVarArgs() {
|
||||
//todo
|
||||
return false;
|
||||
GrParameter[] parameters = myParameterList.getParameters();
|
||||
if (parameters.length == 0) return false;
|
||||
return parameters[parameters.length - 1].isVarArgs();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -425,4 +425,15 @@ public class GrLightMethodBuilder extends LightElement implements GrMethod {
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public <T> T getData() {
|
||||
return (T)myData;
|
||||
}
|
||||
|
||||
public GrLightMethodBuilder setData(@Nullable Object data) {
|
||||
myData = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-6
@@ -15,10 +15,7 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.lang.psi.impl.synthetic;
|
||||
|
||||
import com.intellij.psi.PsiAnnotation;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.light.LightVariableBuilder;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
@@ -39,8 +36,9 @@ public class GrLightParameter extends LightVariableBuilder<GrLightParameter> imp
|
||||
private volatile boolean myOptional;
|
||||
private volatile GrModifierList myModifierList;
|
||||
private PsiElement myScope;
|
||||
private boolean myVarArg;
|
||||
|
||||
public GrLightParameter(@NotNull String name, @NotNull PsiType type, @NotNull PsiElement scope) {
|
||||
public GrLightParameter(@Nullable String name, @NotNull PsiType type, @NotNull PsiElement scope) {
|
||||
super(scope.getManager(), name, type, GroovyFileType.GROOVY_LANGUAGE);
|
||||
myScope = scope;
|
||||
myModifierList = new GrLightModifierList(this, ArrayUtil.EMPTY_STRING_ARRAY);
|
||||
@@ -54,7 +52,7 @@ public class GrLightParameter extends LightVariableBuilder<GrLightParameter> imp
|
||||
|
||||
@Override
|
||||
public boolean isVarArgs() {
|
||||
return false;
|
||||
return getType() instanceof PsiEllipsisType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user