本文整理汇总了Java中com.intellij.psi.PsiModifierList.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java PsiModifierList.getParent方法的具体用法?Java PsiModifierList.getParent怎么用?Java PsiModifierList.getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiModifierList
的用法示例。
在下文中一共展示了PsiModifierList.getParent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transformModifiers
import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
@Override
public void transformModifiers(@NotNull PsiModifierList modifierList, @NotNull final Set<String> modifiers) {
final PsiModifierListOwner parentElement = PsiTreeUtil.getParentOfType(modifierList, PsiModifierListOwner.class, false);
if (null != parentElement) {
// FINAL
if (!PsiAnnotationSearchUtil.isAnnotatedWith(parentElement, lombok.experimental.NonFinal.class)) {
modifiers.add(PsiModifier.FINAL);
}
// PRIVATE
if (modifierList.getParent() instanceof PsiField &&
// Visibility is only changed for package private fields
hasPackagePrivateModifier(modifierList) &&
// except they are annotated with @PackagePrivate
!PsiAnnotationSearchUtil.isAnnotatedWith(parentElement, lombok.experimental.PackagePrivate.class)) {
modifiers.add(PsiModifier.PRIVATE);
// IDEA _right now_ checks if other modifiers are set, and ignores PACKAGE_LOCAL but may as well clean it up
modifiers.remove(PsiModifier.PACKAGE_LOCAL);
}
}
}
示例2: isSupported
import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
@Override
public boolean isSupported(@NotNull PsiModifierList modifierList) {
PsiElement modifierListParent = modifierList.getParent();
if (modifierListParent instanceof PsiClass) {
PsiClass parentClass = (PsiClass) modifierListParent;
if (PsiAnnotationSearchUtil.isAnnotatedWith(parentClass, UtilityClass.class)) {
return UtilityClassProcessor.validateOnRightType(parentClass, new ProblemNewBuilder());
}
}
if (!isElementFieldMethodOrInnerClass(modifierListParent)) {
return false;
}
PsiClass searchableClass = PsiTreeUtil.getParentOfType(modifierListParent, PsiClass.class, true);
return null != searchableClass && PsiAnnotationSearchUtil.isAnnotatedWith(searchableClass, UtilityClass.class) && UtilityClassProcessor.validateOnRightType(searchableClass, new ProblemNewBuilder());
}
示例3: transformModifiers
import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
@Override
public void transformModifiers(@NotNull PsiModifierList modifierList, @NotNull final Set<String> modifiers) {
final PsiElement parent = modifierList.getParent();
// FINAL
if (parent instanceof PsiClass) {
PsiClass psiClass = (PsiClass) parent;
if (PsiAnnotationSearchUtil.isAnnotatedWith(psiClass, UtilityClass.class)) {
modifiers.add(PsiModifier.FINAL);
}
}
// STATIC
if (isElementFieldMethodOrInnerClass(parent)) {
modifiers.add(PsiModifier.STATIC);
}
}
示例4: isSupported
import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
@Override
public boolean isSupported(@NotNull PsiModifierList modifierList) {
// FieldDefaults only change modifiers of class fields
// but nor for enum constants or lombok generated fields
final PsiElement psiElement = modifierList.getParent();
if (!(psiElement instanceof PsiField) || psiElement instanceof PsiEnumConstant || psiElement instanceof LombokLightFieldBuilder) {
return false;
}
PsiClass searchableClass = PsiTreeUtil.getParentOfType(modifierList, PsiClass.class, true);
return null != searchableClass && PsiAnnotationSearchUtil.isAnnotatedWith(searchableClass, lombok.experimental.FieldDefaults.class);
}
示例5: escalateVisibility
import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
public static void escalateVisibility(PsiModifierList modifierList, PsiElement place) throws IncorrectOperationException
{
final PsiElement parent = modifierList.getParent();
if(parent instanceof PsiMember)
{
escalateVisibility((PsiMember) parent, place);
}
}
示例6: transformModifiers
import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
@Override
public void transformModifiers(@NotNull PsiModifierList modifierList, @NotNull final Set<String> modifiers) {
PsiClass searchableClass = PsiTreeUtil.getParentOfType(modifierList, PsiClass.class, true);
if (searchableClass == null) {
return; // Should not get here, but safer to check
}
PsiAnnotation fieldDefaultsAnnotation = PsiAnnotationSearchUtil.findAnnotation(searchableClass, lombok.experimental.FieldDefaults.class);
if (fieldDefaultsAnnotation == null) {
return; // Should not get here, but safer to check
}
PsiField parentElement = (PsiField) modifierList.getParent();
// FINAL
// Is @FieldDefaults(makeFinal = true)?
if ((PsiAnnotationUtil.getBooleanAnnotationValue(fieldDefaultsAnnotation, "makeFinal", false)) && (!PsiAnnotationSearchUtil.isAnnotatedWith(parentElement, lombok.experimental.NonFinal.class))) {
modifiers.add(PsiModifier.FINAL);
}
// VISIBILITY
Collection<String> defaultLevels = PsiAnnotationUtil.getAnnotationValues(fieldDefaultsAnnotation, "level", String.class);
final AccessLevel defaultAccessLevel = AccessLevel.valueOf(Iterables.getFirst(defaultLevels, AccessLevel.NONE.name()));
if (// If explicit visibility modifier is set - no point to continue.
!hasPackagePrivateModifier(modifierList) ||
// If @PackagePrivate is requested, leave the field as is
PsiAnnotationSearchUtil.isAnnotatedWith(parentElement, lombok.experimental.PackagePrivate.class)) {
return;
}
switch (defaultAccessLevel) {
case PRIVATE:
modifiers.add(PsiModifier.PRIVATE);
modifiers.remove(PsiModifier.PACKAGE_LOCAL);
break;
case PROTECTED:
modifiers.add(PsiModifier.PROTECTED);
modifiers.remove(PsiModifier.PACKAGE_LOCAL);
break;
case PUBLIC:
modifiers.add(PsiModifier.PUBLIC);
modifiers.remove(PsiModifier.PACKAGE_LOCAL);
break;
default:
break;
}
}
示例7: isSupported
import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public boolean isSupported(@NotNull PsiModifierList modifierList) {
final PsiElement modifierListParent = modifierList.getParent();
if (!(modifierListParent instanceof PsiField || modifierListParent instanceof PsiClass)) {
return false;
}
PsiClass searchableClass = PsiTreeUtil.getParentOfType(modifierList, PsiClass.class, true);
return null != searchableClass && PsiAnnotationSearchUtil.isAnnotatedWith(searchableClass, lombok.Value.class, lombok.experimental.Value.class);
}
示例8: isSupported
import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
@Override
public boolean isSupported(@NotNull PsiModifierList modifierList) {
final PsiElement parent = modifierList.getParent();
return (parent instanceof PsiLocalVariable && ValProcessor.isVal((PsiLocalVariable) parent));
}