use of org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightField in project intellij-community by JetBrains.
the class GrTraitUtil method createTraitField.
private static GrLightField createTraitField(TraitFieldDescriptor descriptor, PsiClass trait) {
GrLightField field = new GrLightField(trait, descriptor.name, descriptor.typeString);
if ((descriptor.flags & TraitFieldDescriptor.STATIC) != 0)
field.getModifierList().addModifier(STATIC_MASK);
field.getModifierList().addModifier((descriptor.flags & TraitFieldDescriptor.PUBLIC) != 0 ? PUBLIC_MASK : PRIVATE_MASK);
return field;
}
use of org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightField in project intellij-community by JetBrains.
the class LoggingContributor method applyTransformation.
@Override
public void applyTransformation(@NotNull TransformationContext context) {
GrModifierList modifierList = context.getCodeClass().getModifierList();
if (modifierList == null)
return;
for (GrAnnotation annotation : modifierList.getAnnotations()) {
String qname = annotation.getQualifiedName();
String logger = ourLoggers.get(qname);
if (logger != null) {
String fieldName = PsiUtil.getAnnoAttributeValue(annotation, "value", "log");
GrLightField field = new GrLightField(fieldName, logger, context.getCodeClass());
field.setNavigationElement(annotation);
field.getModifierList().setModifiers(PsiModifier.PRIVATE, PsiModifier.FINAL, PsiModifier.STATIC);
field.setOriginInfo("created by @" + annotation.getShortName());
context.addField(field);
}
}
}
use of org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightField in project intellij-community by JetBrains.
the class GebUtil method calculateContentElements.
private static Map<String, PsiField> calculateContentElements(@NotNull PsiClass pageOrModuleClass) {
PsiField contentField = pageOrModuleClass.findFieldByName("content", false);
if (!(contentField instanceof GrField))
return Collections.emptyMap();
GrExpression initializer = ((GrField) contentField).getInitializerGroovy();
if (!(initializer instanceof GrClosableBlock))
return Collections.emptyMap();
Map<String, PsiField> res = new HashMap<>();
PsiType objectType = PsiType.getJavaLangObject(pageOrModuleClass.getManager(), pageOrModuleClass.getResolveScope());
for (PsiElement e = initializer.getFirstChild(); e != null; e = e.getNextSibling()) {
if (e instanceof GrMethodCall) {
GrMethodCall methodCall = (GrMethodCall) e;
GrExpression invokedExpression = methodCall.getInvokedExpression();
if (!(invokedExpression instanceof GrReferenceExpression))
continue;
if (((GrReferenceExpression) invokedExpression).isQualified())
continue;
GrExpression[] arguments = PsiUtil.getAllArguments((GrCall) e);
if (arguments.length == 0)
continue;
final GrClosableBlock block;
if (arguments.length == 1 && arguments[0] instanceof GrClosableBlock) {
block = (GrClosableBlock) arguments[0];
} else if (arguments.length == 2 && arguments[0] == null && arguments[1] instanceof GrClosableBlock) {
block = (GrClosableBlock) arguments[1];
} else {
continue;
}
GrLightField field = new GrLightField(pageOrModuleClass, ((GrReferenceExpression) invokedExpression).getReferenceName(), objectType, invokedExpression) {
@Override
public PsiType getTypeGroovy() {
return block.getReturnType();
}
@Override
public PsiType getDeclaredType() {
return null;
}
};
field.getModifierList().addModifier(GrModifierFlags.STATIC_MASK);
res.put(field.getName(), field);
}
}
return res;
}
Aggregations