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


Java PsiNameValuePair.getName方法代码示例

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


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

示例1: isOnXParameterAnnotation

import com.intellij.psi.PsiNameValuePair; //导入方法依赖的package包/类
public static boolean isOnXParameterAnnotation(HighlightInfo highlightInfo, PsiFile file) {
  if (!(ANNOTATION_TYPE_EXPECTED.equals(highlightInfo.getDescription())
    || CANNOT_RESOLVE_UNDERSCORES_MESSAGE.matcher(StringUtil.notNullize(highlightInfo.getDescription())).matches())) {
    return false;
  }

  PsiElement highlightedElement = file.findElementAt(highlightInfo.getStartOffset());

  PsiNameValuePair nameValuePair = findContainingNameValuePair(highlightedElement);
  if (nameValuePair == null || !(nameValuePair.getContext() instanceof PsiAnnotationParameterList)) {
    return false;
  }

  String parameterName = nameValuePair.getName();
  if (!ONX_PARAMETERS.contains(parameterName)) {
    return false;
  }

  PsiElement containingAnnotation = nameValuePair.getContext().getContext();
  return containingAnnotation instanceof PsiAnnotation && ONXABLE_ANNOTATIONS.contains(((PsiAnnotation) containingAnnotation).getQualifiedName());
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:22,代码来源:OnXAnnotationHandler.java

示例2: addInternal

import com.intellij.psi.PsiNameValuePair; //导入方法依赖的package包/类
@Override
public ASTNode addInternal(ASTNode first, ASTNode last, ASTNode anchor, Boolean before) {
  if (first.getElementType() == GroovyElementTypes.ANNOTATION_MEMBER_VALUE_PAIR && last.getElementType() ==
                                                                                   GroovyElementTypes.ANNOTATION_MEMBER_VALUE_PAIR) {
    ASTNode lparenth = getNode().getFirstChildNode();
    ASTNode rparenth = getNode().getLastChildNode();
    if (lparenth == null) {
      getNode().addLeaf(GroovyTokenTypes.mLPAREN, "(", null);
    }
    if (rparenth == null) {
      getNode().addLeaf(GroovyTokenTypes.mRPAREN, ")", null);
    }

    final PsiNameValuePair[] nodes = getAttributes();
    if (nodes.length == 1) {
      final PsiNameValuePair pair = nodes[0];
      if (pair.getName() == null) {
        final String text = pair.getValue().getText();
        try {
          final PsiAnnotation annotation = GroovyPsiElementFactory.getInstance(getProject()).createAnnotationFromText("@AAA(value = " + text + ")");
          getNode().replaceChild(pair.getNode(), annotation.getParameterList().getAttributes()[0].getNode());
        }
        catch (IncorrectOperationException e) {
          LOG.error(e);
        }
      }
    }

    if (anchor == null && before != null) {
      anchor = before.booleanValue() ? getNode().getLastChildNode() : getNode().getFirstChildNode();
    }
  }

  return super.addInternal(first, last, anchor, before);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:GrAnnotationArgumentListImpl.java

示例3: addInternal

import com.intellij.psi.PsiNameValuePair; //导入方法依赖的package包/类
@Override
public ASTNode addInternal(ASTNode first, ASTNode last, ASTNode anchor, Boolean before) {
  if (first.getElementType() == ANNOTATION_MEMBER_VALUE_PAIR && last.getElementType() == ANNOTATION_MEMBER_VALUE_PAIR) {
    ASTNode lparenth = getNode().getFirstChildNode();
    ASTNode rparenth = getNode().getLastChildNode();
    if (lparenth == null) {
      getNode().addLeaf(mLPAREN, "(", null);
    }
    if (rparenth == null) {
      getNode().addLeaf(mRPAREN, ")", null);
    }

    final PsiNameValuePair[] nodes = getAttributes();
    if (nodes.length == 1) {
      final PsiNameValuePair pair = nodes[0];
      if (pair.getName() == null) {
        final String text = pair.getValue().getText();
        try {
          final PsiAnnotation annotation = GroovyPsiElementFactory.getInstance(getProject()).createAnnotationFromText("@AAA(value = " + text + ")");
          getNode().replaceChild(pair.getNode(), annotation.getParameterList().getAttributes()[0].getNode());
        }
        catch (IncorrectOperationException e) {
          LOG.error(e);
        }
      }
    }

    if (anchor == null && before != null) {
      anchor = before.booleanValue() ? getNode().getLastChildNode() : getNode().getFirstChildNode();
    }
  }

  return super.addInternal(first, last, anchor, before);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:35,代码来源:GrAnnotationArgumentListImpl.java

示例4: selectAnnotationAttribute

import com.intellij.psi.PsiNameValuePair; //导入方法依赖的package包/类
private PsiNameValuePair selectAnnotationAttribute() {
  PsiNameValuePair result = null;
  PsiNameValuePair[] attributes = myAnnotation.getParameterList().getAttributes();
  for (PsiNameValuePair attribute : attributes) {
    @NonNls final String attributeName = attribute.getName();
    if (equals(myName, attributeName) || attributeName == null && myName.equals(PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME)) {
      result = attribute;
      break;
    }
  }
  return result;
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:13,代码来源:ChangeAnnotationParameterQuickFix.java

示例5: findDefaultValue

import com.intellij.psi.PsiNameValuePair; //导入方法依赖的package包/类
public static PsiElement findDefaultValue(PsiAnnotation annotation){
    final PsiAnnotationParameterList parameters = annotation.getParameterList();
    final PsiNameValuePair[] pairs = parameters.getAttributes();
    for(PsiNameValuePair pair : pairs){
        final String name = pair.getName();
        if("value".equals(name) || name == null){
            return pair.getValue();
        }
    }
    return null;
}
 
开发者ID:consulo,项目名称:consulo-google-guice,代码行数:12,代码来源:AnnotationUtils.java


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