当前位置: 首页>>代码示例>>Java>>正文


Java PsiModifierList.getParent方法代码示例

本文整理汇总了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);
    }
  }
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:25,代码来源:ValueModifierProcessor.java

示例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());
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:21,代码来源:UtilityClassModifierProcessor.java

示例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);
  }
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:19,代码来源:UtilityClassModifierProcessor.java

示例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);
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:15,代码来源:FieldDefaultsModifierProcessor.java

示例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);
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:9,代码来源:VisibilityUtil.java

示例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;
  }
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:50,代码来源:FieldDefaultsModifierProcessor.java

示例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);

}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:16,代码来源:ValueModifierProcessor.java

示例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));
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:8,代码来源:ValModifierProcessor.java


注:本文中的com.intellij.psi.PsiModifierList.getParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。