use of org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList 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.api.auxiliary.modifiers.GrModifierList in project intellij-community by JetBrains.
the class GrFinalVariableAccessInspection method isImmutableField.
private static boolean isImmutableField(@NotNull GrField field) {
GrModifierList fieldModifierList = field.getModifierList();
if (fieldModifierList != null && fieldModifierList.hasExplicitVisibilityModifiers())
return false;
PsiClass aClass = field.getContainingClass();
if (aClass == null)
return false;
PsiModifierList modifierList = aClass.getModifierList();
if (modifierList == null)
return false;
return PsiImplUtil.hasImmutableAnnotation(modifierList);
}
use of org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList in project intellij-community by JetBrains.
the class GrChangeSignatureUsageProcessor method processClassUsage.
private static void processClassUsage(GrTypeDefinition psiClass, JavaChangeInfo changeInfo) {
String name = psiClass.getName();
GrMethod constructor = GroovyPsiElementFactory.getInstance(psiClass.getProject()).createConstructorFromText(name, ArrayUtil.EMPTY_STRING_ARRAY, ArrayUtil.EMPTY_STRING_ARRAY, "{}", null);
GrModifierList list = constructor.getModifierList();
if (psiClass.hasModifierProperty(PsiModifier.PRIVATE))
list.setModifierProperty(PsiModifier.PRIVATE, true);
if (psiClass.hasModifierProperty(PsiModifier.PROTECTED))
list.setModifierProperty(PsiModifier.PROTECTED, true);
if (!list.hasExplicitVisibilityModifiers()) {
list.setModifierProperty(GrModifier.DEF, true);
}
constructor = (GrMethod) psiClass.add(constructor);
processConstructor(constructor, changeInfo);
}
use of org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList in project intellij-community by JetBrains.
the class GroovyOverrideImplementUtil method setupReturnType.
private static void setupReturnType(GrMethod result, PsiMethod method) {
if (method instanceof GrMethod && ((GrMethod) method).getReturnTypeElementGroovy() == null) {
result.setReturnType(null);
GrModifierList modifierList = result.getModifierList();
if (!modifierList.hasExplicitVisibilityModifiers()) {
modifierList.setModifierProperty(GrModifier.DEF, true);
}
}
}
use of org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList in project intellij-community by JetBrains.
the class SuppressForMemberFix method createSuppression.
@Override
protected void createSuppression(@NotNull Project project, @NotNull PsiElement element, @NotNull PsiElement container) throws IncorrectOperationException {
final GrModifierList modifierList = (GrModifierList) ((PsiModifierListOwner) container).getModifierList();
if (modifierList != null) {
addSuppressAnnotation(project, modifierList, myID);
}
DaemonCodeAnalyzer.getInstance(project).restart();
}
Aggregations