Java 类com.intellij.psi.impl.source.javadoc.PsiDocMethodOrFieldRef 实例源码

项目:intellij-ce-playground    文件:ReplaceImplementsWithStaticImportAction.java   
private static void bindReference(PsiFile psiFile,
                                  PsiField psiField,
                                  PsiClass containingClass,
                                  String fieldName,
                                  PsiReference reference,
                                  Project project) {
  if (reference instanceof PsiReferenceExpression) {
    PsiReferenceExpressionImpl.bindToElementViaStaticImport(containingClass, fieldName, ((PsiJavaFile)psiFile).getImportList());
    final PsiElement qualifier = ((PsiReferenceExpression)reference).getQualifier();
    if (qualifier != null) {
      final Boolean canRemoveQualifier = qualifier.getCopyableUserData(ChangeContextUtil.CAN_REMOVE_QUALIFIER_KEY);
      if (canRemoveQualifier != null && canRemoveQualifier.booleanValue()) {
        qualifier.delete();
      } else {
        final PsiJavaCodeReferenceElement classReferenceElement =
          JavaPsiFacade.getElementFactory(project).createReferenceExpression(containingClass);
        qualifier.replace(classReferenceElement);
      }
    }
  } else if (reference.getElement() instanceof PsiDocMethodOrFieldRef){
    reference.bindToElement(psiField);    //todo refs through inheritors
  }
}
项目:tools-idea    文件:ReplaceImplementsWithStaticImportAction.java   
private static void bindReference(PsiFile psiFile,
                                  PsiField psiField,
                                  PsiClass containingClass,
                                  String fieldName,
                                  PsiReference reference,
                                  Project project) {
  if (reference instanceof PsiReferenceExpression) {
    PsiReferenceExpressionImpl.bindToElementViaStaticImport(containingClass, fieldName, ((PsiJavaFile)psiFile).getImportList());
    final PsiElement qualifier = ((PsiReferenceExpression)reference).getQualifier();
    if (qualifier != null) {
      final Boolean canRemoveQualifier = qualifier.getCopyableUserData(ChangeContextUtil.CAN_REMOVE_QUALIFIER_KEY);
      if (canRemoveQualifier != null && canRemoveQualifier.booleanValue()) {
        qualifier.delete();
      } else {
        final PsiJavaCodeReferenceElement classReferenceElement =
          JavaPsiFacade.getElementFactory(project).createReferenceExpression(containingClass);
        qualifier.replace(classReferenceElement);
      }
    }
  } else if (reference.getElement() instanceof PsiDocMethodOrFieldRef){
    reference.bindToElement(psiField);    //todo refs through inheritors
  }
}
项目:consulo-java    文件:ReplaceImplementsWithStaticImportAction.java   
private static void bindReference(PsiFile psiFile,
                                  PsiField psiField,
                                  PsiClass containingClass,
                                  String fieldName,
                                  PsiReference reference,
                                  Project project) {
  if (reference instanceof PsiReferenceExpression) {
    PsiReferenceExpressionImpl.bindToElementViaStaticImport(containingClass, fieldName, ((PsiJavaFile)psiFile).getImportList());
    final PsiElement qualifier = ((PsiReferenceExpression)reference).getQualifier();
    if (qualifier != null) {
      final Boolean canRemoveQualifier = qualifier.getCopyableUserData(ChangeContextUtil.CAN_REMOVE_QUALIFIER_KEY);
      if (canRemoveQualifier != null && canRemoveQualifier.booleanValue()) {
        qualifier.delete();
      } else {
        final PsiJavaCodeReferenceElement classReferenceElement =
          JavaPsiFacade.getElementFactory(project).createReferenceExpression(containingClass);
        qualifier.replace(classReferenceElement);
      }
    }
  } else if (reference.getElement() instanceof PsiDocMethodOrFieldRef){
    reference.bindToElement(psiField);    //todo refs through inheritors
  }
}
项目:consulo-java    文件:HighlightVisitorImpl.java   
@Override
public void visitDocTagValue(PsiDocTagValue value)
{
    PsiReference reference = value.getReference();
    if(reference != null)
    {
        PsiElement element = reference.resolve();
        final TextAttributesScheme colorsScheme = myHolder.getColorsScheme();
        if(element instanceof PsiMethod)
        {
            PsiElement nameElement = ((PsiDocMethodOrFieldRef) value).getNameElement();
            if(nameElement != null)
            {
                myHolder.add(HighlightNamesUtil.highlightMethodName((PsiMethod) element, nameElement, false, colorsScheme));
            }
        }
        else if(element instanceof PsiParameter)
        {
            myHolder.add(HighlightNamesUtil.highlightVariableName((PsiVariable) element, value.getNavigationElement(), colorsScheme));
        }
    }
}
项目:consulo-java    文件:JavaSpacePropertyProcessor.java   
private static boolean shouldKeepSpace(final PsiElement parent)
{
    ASTNode node = parent.getNode();
    if(node == null)
    {
        return true;
    }

    final IElementType type = node.getElementType();
    if(type == JavaDocElementType.DOC_TAG_VALUE_ELEMENT)
    {
        return PsiTreeUtil.getParentOfType(parent, PsiDocMethodOrFieldRef.class) != null;
    }

    return type == JavaDocElementType.DOC_COMMENT || type == JavaDocElementType.DOC_TAG || type == JavaDocElementType.DOC_INLINE_TAG;
}
项目:intellij-ce-playground    文件:HighlightVisitorImpl.java   
@Override
public void visitDocTagValue(PsiDocTagValue value) {
  PsiReference reference = value.getReference();
  if (reference != null) {
    PsiElement element = reference.resolve();
    final TextAttributesScheme colorsScheme = myHolder.getColorsScheme();
    if (element instanceof PsiMethod) {
      myHolder.add(HighlightNamesUtil.highlightMethodName((PsiMethod)element, ((PsiDocMethodOrFieldRef)value).getNameElement(), false,
                                                          colorsScheme));
    }
    else if (element instanceof PsiParameter) {
      myHolder.add(HighlightNamesUtil.highlightVariableName((PsiVariable)element, value.getNavigationElement(), colorsScheme));
    }
  }
}
项目:intellij-ce-playground    文件:JavaSpacePropertyProcessor.java   
private static boolean shouldKeepSpace(final PsiElement parent) {
  ASTNode node = parent.getNode();
  if (node == null) {
    return true;
  }

  final IElementType type = node.getElementType();
  if (type == JavaDocElementType.DOC_TAG_VALUE_ELEMENT) {
    return PsiTreeUtil.getParentOfType(parent, PsiDocMethodOrFieldRef.class) != null;
  }

  return type == JavaDocElementType.DOC_COMMENT || type == JavaDocElementType.DOC_TAG || type == JavaDocElementType.DOC_INLINE_TAG;
}
项目:tools-idea    文件:HighlightVisitorImpl.java   
@Override
public void visitDocTagValue(PsiDocTagValue value) {
  PsiReference reference = value.getReference();
  if (reference != null) {
    PsiElement element = reference.resolve();
    final TextAttributesScheme colorsScheme = myHolder.getColorsScheme();
    if (element instanceof PsiMethod) {
      myHolder.add(HighlightNamesUtil.highlightMethodName((PsiMethod)element, ((PsiDocMethodOrFieldRef)value).getNameElement(), false,
                                                          colorsScheme));
    }
    else if (element instanceof PsiParameter) {
      myHolder.add(HighlightNamesUtil.highlightVariableName((PsiVariable)element, value.getNavigationElement(), colorsScheme));
    }
  }
}
项目:tools-idea    文件:JavaSpacePropertyProcessor.java   
private static boolean shouldKeepSpace(final PsiElement parent) {
  ASTNode node = parent.getNode();
  if (node == null) {
    return true;
  }

  final IElementType type = node.getElementType();
  if (type == JavaDocElementType.DOC_TAG_VALUE_ELEMENT) {
    return PsiTreeUtil.getParentOfType(parent, PsiDocMethodOrFieldRef.class) != null;
  }

  return type == JavaDocElementType.DOC_COMMENT || type == JavaDocElementType.DOC_TAG || type == JavaDocElementType.DOC_INLINE_TAG;
}
项目:intellij-ce-playground    文件:JavaSafeDeleteDelegateImpl.java   
@Override
public void createUsageInfoForParameter(final PsiReference reference,
                                        final List<UsageInfo> usages,
                                        final PsiParameter parameter,
                                        final PsiMethod method) {
  int index = method.getParameterList().getParameterIndex(parameter);
  final PsiElement element = reference.getElement();
  PsiCall call = null;
  if (element instanceof PsiCall) {
    call = (PsiCall)element;
  }
  else {
    final PsiElement parent = element.getParent();
    if (parent instanceof PsiCall) {
      call = (PsiCall)parent;
    } else if (parent instanceof PsiAnonymousClass) {
      call = (PsiNewExpression)parent.getParent();
    }
  }
  if (call != null) {
    final PsiExpressionList argList = call.getArgumentList();
    if (argList != null) {
      final PsiExpression[] args = argList.getExpressions();
      if (index < args.length) {
        if (!parameter.isVarArgs()) {
          usages.add(new SafeDeleteReferenceJavaDeleteUsageInfo(args[index], parameter, true));
        }
        else {
          for (int i = index; i < args.length; i++) {
            usages.add(new SafeDeleteReferenceJavaDeleteUsageInfo(args[i], parameter, true));
          }
        }
      }
    }
  }
  else if (element instanceof PsiDocMethodOrFieldRef) {
    if (((PsiDocMethodOrFieldRef)element).getSignature() != null) {
      @NonNls final StringBuffer newText = new StringBuffer();
      newText.append("/** @see #").append(method.getName()).append('(');
      final List<PsiParameter> parameters = new ArrayList<PsiParameter>(Arrays.asList(method.getParameterList().getParameters()));
      parameters.remove(parameter);
      newText.append(StringUtil.join(parameters, new Function<PsiParameter, String>() {
        @Override
        public String fun(PsiParameter psiParameter) {
          return psiParameter.getType().getCanonicalText();
        }
      }, ","));
      newText.append(")*/");
      usages.add(new SafeDeleteReferenceJavaDeleteUsageInfo(element, parameter, true) {
        public void deleteElement() throws IncorrectOperationException {
          final PsiDocMethodOrFieldRef.MyReference javadocMethodReference =
            (PsiDocMethodOrFieldRef.MyReference)element.getReference();
          if (javadocMethodReference != null) {
            javadocMethodReference.bindToText(method.getContainingClass(), newText);
          }
        }
      });
    }
  }
}
项目:tools-idea    文件:JavaSafeDeleteDelegateImpl.java   
@Override
public void createUsageInfoForParameter(final PsiReference reference,
                                        final List<UsageInfo> usages,
                                        final PsiParameter parameter,
                                        final PsiMethod method) {
  int index = method.getParameterList().getParameterIndex(parameter);
  final PsiElement element = reference.getElement();
  PsiCall call = null;
  if (element instanceof PsiCall) {
    call = (PsiCall)element;
  }
  else if (element.getParent() instanceof PsiCall) {
    call = (PsiCall)element.getParent();
  }
  if (call != null) {
    final PsiExpressionList argList = call.getArgumentList();
    if (argList != null) {
      final PsiExpression[] args = argList.getExpressions();
      if (index < args.length) {
        if (!parameter.isVarArgs()) {
          usages.add(new SafeDeleteReferenceJavaDeleteUsageInfo(args[index], parameter, true));
        }
        else {
          for (int i = index; i < args.length; i++) {
            usages.add(new SafeDeleteReferenceJavaDeleteUsageInfo(args[i], parameter, true));
          }
        }
      }
    }
  }
  else if (element instanceof PsiDocMethodOrFieldRef) {
    if (((PsiDocMethodOrFieldRef)element).getSignature() != null) {
      @NonNls final StringBuffer newText = new StringBuffer();
      newText.append("/** @see #").append(method.getName()).append('(');
      final List<PsiParameter> parameters = new ArrayList<PsiParameter>(Arrays.asList(method.getParameterList().getParameters()));
      parameters.remove(parameter);
      newText.append(StringUtil.join(parameters, new Function<PsiParameter, String>() {
        @Override
        public String fun(PsiParameter psiParameter) {
          return parameter.getType().getCanonicalText();
        }
      }, ","));
      newText.append(")*/");
      usages.add(new SafeDeleteReferenceJavaDeleteUsageInfo(element, parameter, true) {
        public void deleteElement() throws IncorrectOperationException {
          final PsiDocMethodOrFieldRef.MyReference javadocMethodReference =
            (PsiDocMethodOrFieldRef.MyReference)element.getReference();
          if (javadocMethodReference != null) {
            javadocMethodReference.bindToText(method.getContainingClass(), newText);
          }
        }
      });
    }
  }
}
项目:consulo-java    文件:JavaSafeDeleteDelegateImpl.java   
@Override
public void createUsageInfoForParameter(final PsiReference reference,
                                        final List<UsageInfo> usages,
                                        final PsiParameter parameter,
                                        final PsiMethod method) {
  int index = method.getParameterList().getParameterIndex(parameter);
  final PsiElement element = reference.getElement();
  PsiCall call = null;
  if (element instanceof PsiCall) {
    call = (PsiCall)element;
  }
  else if (element.getParent() instanceof PsiCall) {
    call = (PsiCall)element.getParent();
  }
  if (call != null) {
    final PsiExpressionList argList = call.getArgumentList();
    if (argList != null) {
      final PsiExpression[] args = argList.getExpressions();
      if (index < args.length) {
        if (!parameter.isVarArgs()) {
          usages.add(new SafeDeleteReferenceJavaDeleteUsageInfo(args[index], parameter, true));
        }
        else {
          for (int i = index; i < args.length; i++) {
            usages.add(new SafeDeleteReferenceJavaDeleteUsageInfo(args[i], parameter, true));
          }
        }
      }
    }
  }
  else if (element instanceof PsiDocMethodOrFieldRef) {
    if (((PsiDocMethodOrFieldRef)element).getSignature() != null) {
      @NonNls final StringBuffer newText = new StringBuffer();
      newText.append("/** @see #").append(method.getName()).append('(');
      final List<PsiParameter> parameters = new ArrayList<PsiParameter>(Arrays.asList(method.getParameterList().getParameters()));
      parameters.remove(parameter);
      newText.append(StringUtil.join(parameters, new Function<PsiParameter, String>() {
        @Override
        public String fun(PsiParameter psiParameter) {
          return parameter.getType().getCanonicalText();
        }
      }, ","));
      newText.append(")*/");
      usages.add(new SafeDeleteReferenceJavaDeleteUsageInfo(element, parameter, true) {
        public void deleteElement() throws IncorrectOperationException {
          final PsiDocMethodOrFieldRef.MyReference javadocMethodReference =
            (PsiDocMethodOrFieldRef.MyReference)element.getReference();
          if (javadocMethodReference != null) {
            javadocMethodReference.bindToText(method.getContainingClass(), newText);
          }
        }
      });
    }
  }
}