本文整理汇总了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);
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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));
}