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


Java PsiMember.getContainingClass方法代码示例

本文整理汇总了Java中com.intellij.psi.PsiMember.getContainingClass方法的典型用法代码示例。如果您正苦于以下问题:Java PsiMember.getContainingClass方法的具体用法?Java PsiMember.getContainingClass怎么用?Java PsiMember.getContainingClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.PsiMember的用法示例。


在下文中一共展示了PsiMember.getContainingClass方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initText

import com.intellij.psi.PsiMember; //导入方法依赖的package包/类
public static String initText(final PsiMember member, final boolean showContainingClass, final String modifier, final boolean doSet) {
  String name;
  if (showContainingClass) {
    final PsiClass containingClass = member.getContainingClass();
    String containingClassName;
    if (containingClass != null) {
      containingClassName = containingClass.getName() + ".";
    }
    else {
      containingClassName = "";
    }

    name = containingClassName + member.getName();
  }
  else {
    name = member.getName();
  }
  String modifierText = toPresentableText(modifier);

  if (doSet) {
    return GroovyBundle.message("change.modifier", name, modifierText);
  }
  else {
    return GroovyBundle.message("change.modifier.not", name, modifierText);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:27,代码来源:GrModifierFix.java

示例2: getLambdaPrefix

import com.intellij.psi.PsiMember; //导入方法依赖的package包/类
public static String getLambdaPrefix(@NotNull PsiLambdaExpression lambdaExpression)
{
	PsiMember member = PsiTreeUtil.getParentOfType(lambdaExpression, PsiMethod.class, PsiClass.class, PsiField.class);
	final String methodPrefix;
	if(member instanceof PsiMethod)
	{
		methodPrefix = member.getContainingClass() instanceof PsiAnonymousClass ? "" : "$" + member.getName();
	}
	else if(member instanceof PsiField && member.getContainingClass() instanceof PsiAnonymousClass)
	{
		methodPrefix = "";
	}
	else
	{
		//inside class initializer everywhere or field in a named class
		methodPrefix = "$new";
	}
	return methodPrefix;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:20,代码来源:PsiLambdaNameHelper.java

示例3: doFix

import com.intellij.psi.PsiMember; //导入方法依赖的package包/类
@Override
public void doFix(Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
  final PsiReferenceExpression expression = (PsiReferenceExpression)descriptor.getPsiElement();
  if (expression.getQualifierExpression() != null) {
    return;
  }
  final PsiElement target = expression.resolve();
  if (!(target instanceof PsiMember)) {
    return;
  }
  final PsiMember member = (PsiMember)target;
  final PsiClass memberClass = member.getContainingClass();
  if (memberClass == null) {
    return;
  }
  PsiClass containingClass = ClassUtils.getContainingClass(expression);
  @NonNls final String newExpression;
  if (InheritanceUtil.isInheritorOrSelf(containingClass, memberClass, true)) {
    newExpression = "this." + expression.getText();
  }
  else {
    containingClass = ClassUtils.getContainingClass(containingClass);
    if (containingClass == null) {
      return;
    }
    while (!InheritanceUtil.isInheritorOrSelf(containingClass, memberClass, true)) {
      containingClass = ClassUtils.getContainingClass(containingClass);
      if (containingClass == null) {
        return;
      }
    }
    newExpression = containingClass.getQualifiedName() + ".this." + expression.getText();
  }
  PsiReplacementUtil.replaceExpressionAndShorten(expression, newExpression);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:AddThisQualifierFix.java

示例4: doFix

import com.intellij.psi.PsiMember; //导入方法依赖的package包/类
@Override
public void doFix(Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
  final PsiReferenceExpression expression = (PsiReferenceExpression)descriptor.getPsiElement();
  if (expression.getQualifierExpression() != null) {
    return;
  }
  final PsiElement target = expression.resolve();
  if (!(target instanceof PsiMember)) {
    return;
  }
  final PsiMember member = (PsiMember)target;
  final PsiClass memberClass = member.getContainingClass();
  if (memberClass == null) {
    return;
  }
  PsiClass containingClass = ClassUtils.getContainingClass(expression);
  @NonNls final String newExpression;
  if (InheritanceUtil.isInheritorOrSelf(containingClass, memberClass, true)) {
    newExpression = "this." + expression.getText();
  }
  else {
    containingClass = ClassUtils.getContainingClass(containingClass);
    if (containingClass == null) {
      return;
    }
    while (!InheritanceUtil.isInheritorOrSelf(containingClass, memberClass, true)) {
      containingClass = ClassUtils.getContainingClass(containingClass);
      if (containingClass == null) {
        return;
      }
    }
    newExpression = containingClass.getQualifiedName() + ".this." + expression.getText();
  }
  replaceExpressionAndShorten(expression, newExpression);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:36,代码来源:AddThisQualifierFix.java

示例5: verifyLombokAnnotationPresent

import com.intellij.psi.PsiMember; //导入方法依赖的package包/类
private boolean verifyLombokAnnotationPresent(@NotNull PsiMember psiMember) {
  if (PsiAnnotationSearchUtil.checkAnnotationsSimpleNameExistsIn(psiMember, registeredAnnotationNames)) {
    return true;
  }

  final PsiClass psiClass = psiMember.getContainingClass();
  return null != psiClass && verifyLombokAnnotationPresent(psiClass);
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:9,代码来源:LombokProcessorProvider.java

示例6: getApplicableProcessors

import com.intellij.psi.PsiMember; //导入方法依赖的package包/类
@NotNull
public Collection<LombokProcessorData> getApplicableProcessors(@NotNull PsiMember psiMember) {
  Collection<LombokProcessorData> result = Collections.emptyList();
  if (verifyLombokAnnotationPresent(psiMember)) {
    result = new ArrayList<LombokProcessorData>();

    addApplicableProcessors(psiMember, result);
    final PsiClass psiClass = psiMember.getContainingClass();
    if (null != psiClass) {
      addApplicableProcessors(psiClass, result);
    }
  }
  return result;
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:15,代码来源:LombokProcessorProvider.java

示例7: eraseFreeTypeParameters

import com.intellij.psi.PsiMember; //导入方法依赖的package包/类
@Nullable
private static PsiType eraseFreeTypeParameters(@Nullable PsiType psiType,
    @NotNull PsiMember member) {
  final PsiClass containingClass = member.getContainingClass();
  return eraseFreeTypeParameters(psiType, containingClass);
}
 
开发者ID:1tontech,项目名称:intellij-spring-assistant,代码行数:7,代码来源:PsiUtil.java

示例8: isPotentiallyAccessible

import com.intellij.psi.PsiMember; //导入方法依赖的package包/类
/**
 * Non-public members of superclass/superinterface can't be obtained via reflection, they need to be filtered out.
 */
@Contract("null, _ -> false")
private static boolean isPotentiallyAccessible(PsiMember member, PsiClass psiClass)
{
	return member != null && (member.getContainingClass() == psiClass || isPublic(member));
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:9,代码来源:JavaLangClassMemberReference.java


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