• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PsiNameValuePair类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: isJavaElementForType

import com.intellij.psi.PsiNameValuePair; //导入依赖的package包/类
private static boolean isJavaElementForType( PsiModifierListOwner modifierListOwner, PsiClass psiClass )
{
  PsiAnnotation annotation = modifierListOwner.getModifierList().findAnnotation( TypeReference.class.getName() );
  if( annotation != null )
  {
    PsiNameValuePair[] attributes = annotation.getParameterList().getAttributes();
    for( PsiNameValuePair pair : attributes )
    {
      String fqn = pair.getLiteralValue();
      if( psiClass.getQualifiedName().contains( fqn ) )
      {
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:18,代码来源:ResourceToManifoldUtil.java


示例2: toStringImpl

import com.intellij.psi.PsiNameValuePair; //导入依赖的package包/类
/**
 * Implementation of dynamicProxy.toString()
 */
private String toStringImpl() {
  StringBuilder result = new StringBuilder(128);
  result.append('@');
  result.append(type.getName());
  result.append('(');
  boolean firstMember = true;
  PsiNameValuePair[] attributes = myAnnotation.getParameterList().getAttributes();
  for (PsiNameValuePair e : attributes) {
    if (firstMember) {
      firstMember = false;
    }
    else {
      result.append(", ");
    }

    result.append(e.getName());
    result.append('=');
    PsiAnnotationMemberValue value = e.getValue();
    result.append(value == null ? "null" : value.getText());
  }
  result.append(')');
  return result.toString();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:AnnotationInvocationHandler.java


示例3: 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


示例4: removeDefaultAnnotation

import com.intellij.psi.PsiNameValuePair; //导入依赖的package包/类
protected void removeDefaultAnnotation(@NotNull PsiModifierListOwner targetElement, @NotNull Class<? extends Annotation> annotationClass) {
  final PsiAnnotation psiAnnotation = PsiAnnotationSearchUtil.findAnnotation(targetElement, annotationClass);
  if (null != psiAnnotation) {
    boolean hasOnlyDefaultValues = true;

    final PsiAnnotationParameterList psiAnnotationParameterList = psiAnnotation.getParameterList();
    for (PsiNameValuePair nameValuePair : psiAnnotationParameterList.getAttributes()) {
      if (null != psiAnnotation.findDeclaredAttributeValue(nameValuePair.getName())) {
        hasOnlyDefaultValues = false;
        break;
      }
    }

    if (hasOnlyDefaultValues) {
      psiAnnotation.delete();
    }
  }
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:19,代码来源:BaseLombokHandler.java


示例5: getDescription

import com.intellij.psi.PsiNameValuePair; //导入依赖的package包/类
@NotNull
public String getDescription(boolean full) {
    if ( !element.equals(resolve(element.getNameReferenceElement())) ) {
        return element.getText();
    }
    StringBuilder buf = new StringBuilder();
    buf.append('@');
    buf.append(element.getQualifiedName());
    if ( full && element.getParameterList().getAttributes().length > 0 ) {
        buf.append('(');
        boolean first = true;
        for( PsiNameValuePair value : element.getParameterList().getAttributes() ) {
            if ( first ) {
                first = false;
            }
            else {
                buf.append(", ");
            }
            buf.append(value.getName()).append("=");
            buf.append(value.getValue() == null ? "?" : value.getValue().getText());
        }
        buf.append(')');
    }
    return buf.toString();
}
 
开发者ID:Abnaxos,项目名称:guards,代码行数:26,代码来源:PsiGuard.java


示例6: accepts

import com.intellij.psi.PsiNameValuePair; //导入依赖的package包/类
@Override
public boolean accepts(@Nullable Object o, ProcessingContext context) {
  if (o instanceof PsiLiteralExpression) {
    final PsiAnnotation parentOfType = PsiTreeUtil.getParentOfType((PsiLiteralExpression) o, PsiAnnotation.class);

    if (parentOfType != null && type.equals(parentOfType.getQualifiedName())) {
      if (attributeName != null) {
        final PsiNameValuePair nvp = PsiTreeUtil.getParentOfType((PsiLiteralExpression) o, PsiNameValuePair.class);
        return nvp != null && attributeName.equals(nvp.getName());
      }
      else {
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:errai,项目名称:errai-intellij-idea-plugin,代码行数:18,代码来源:AnnotationMatchingPattern.java


示例7: getValueStringFromAnnotationWithDefault

import com.intellij.psi.PsiNameValuePair; //导入依赖的package包/类
public static AnnotationValueElement getValueStringFromAnnotationWithDefault(PsiAnnotation annotation) {
  final PsiAnnotationParameterList parameterList = annotation.getParameterList();
  final PsiNameValuePair[] attributes = parameterList.getAttributes();
  final PsiElement logicalElement = getImmediateOwnerElement(annotation);

  if (logicalElement == null) {
    return null;
  }

  final String value;
  final PsiElement errorElement;

  if (attributes.length == 0) {
    value = getNameOfElement(logicalElement);
    errorElement = annotation;
  }
  else {
    final String text = attributes[0].getText();
    value = text.substring(1, text.length() - 1);
    errorElement = attributes[0];
  }

  return new AnnotationValueElement(value, errorElement);
}
 
开发者ID:errai,项目名称:errai-intellij-idea-plugin,代码行数:25,代码来源:Util.java


示例8: buildBlocks

import com.intellij.psi.PsiNameValuePair; //导入依赖的package包/类
public List<Block> buildBlocks()
{
	final Wrap wrap = Wrap.createWrap(getWrapType(myJavaSettings.ANNOTATION_PARAMETER_WRAP), false);
	final Alignment alignment = myJavaSettings.ALIGN_MULTILINE_ANNOTATION_PARAMETERS ? Alignment.createAlignment() : null;

	ChildrenBlocksBuilder.Config config = new ChildrenBlocksBuilder.Config().setDefaultIndent(Indent.getContinuationWithoutFirstIndent()).setIndent(JavaTokenType.RPARENTH, Indent.getNoneIndent()
	).setIndent(JavaTokenType.LPARENTH, Indent.getNoneIndent())

			.setDefaultWrap(wrap).setNoWrap(JavaTokenType.COMMA).setNoWrap(JavaTokenType.RPARENTH).setNoWrap(JavaTokenType.LPARENTH)

			.setDefaultAlignment(alignment).setNoAlignment(JavaTokenType.COMMA).setNoAlignment(JavaTokenType.LPARENTH).setNoAlignmentIf(JavaTokenType.RPARENTH, node -> {
				PsiElement prev = PsiTreeUtil.skipSiblingsBackward(node.getPsi(), PsiWhiteSpace.class);
				if(prev == null)
				{
					return false;
				}
				return prev instanceof PsiNameValuePair && !PsiTreeUtil.hasErrorElements(prev);
			});

	return config.createBuilder().buildNodeChildBlocks(myNode, myFactory);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:22,代码来源:AnnotationInitializerBlocksBuilder.java


示例9: getAnnotationValue

import com.intellij.psi.PsiNameValuePair; //导入依赖的package包/类
@Nullable
PsiExpression getAnnotationValue(PsiAnnotation annotation, String annotationKey) {
    PsiNameValuePair[] attributes = annotation.getParameterList().getAttributes();
    return Arrays.stream(attributes)
            .filter(a -> annotationKey.equalsIgnoreCase(a.getName()))
            .map(PsiNameValuePair::getValue)
            .filter(v -> v instanceof PsiExpression)
            .map(v -> (PsiExpression) v)
            .findFirst().orElse(null);
}
 
开发者ID:TNG,项目名称:jgiven-intellij-plugin,代码行数:11,代码来源:AnnotationValueProvider.java


示例10: isJavaElementFor

import com.intellij.psi.PsiNameValuePair; //导入依赖的package包/类
private static boolean isJavaElementFor( PsiModifierListOwner modifierListOwner, PsiElement element )
{
  PsiAnnotation annotation = modifierListOwner.getModifierList().findAnnotation( SourcePosition.class.getName() );
  if( annotation != null )
  {
    int textOffset = element.getTextOffset();
    int textLength = element instanceof PsiNamedElement ? ((PsiNamedElement)element).getName().length() : element.getTextLength();
    PsiNameValuePair[] attributes = annotation.getParameterList().getAttributes();
    int offset = -1;
    for( PsiNameValuePair pair : attributes )
    {
      if( pair.getNameIdentifier().getText().equals( SourcePosition.OFFSET ) )
      {
        String literalValue = pair.getLiteralValue();
        if( literalValue == null )
        {
          return false;
        }
        offset = Integer.parseInt( literalValue );
        break;
      }
    }
    if( offset >= textOffset && offset <= textOffset + textLength )
    {
      return true;
    }
  }
  return false;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:30,代码来源:ResourceToManifoldUtil.java


示例11: addAnnotations

import com.intellij.psi.PsiNameValuePair; //导入依赖的package包/类
private void addAnnotations( SrcAnnotated<?> srcAnnotated, PsiModifierListOwner annotated )
{
  for( PsiAnnotation psiAnno : annotated.getModifierList().getAnnotations() )
  {
    SrcAnnotationExpression annoExpr = new SrcAnnotationExpression( psiAnno.getQualifiedName() );
    for( PsiNameValuePair value : psiAnno.getParameterList().getAttributes() )
    {
      SrcArgument srcArg = new SrcArgument( new SrcRawExpression( value.getLiteralValue() ) );
      annoExpr.addArgument( srcArg ).name( value.getName() );
    }
    srcAnnotated.addAnnotation( annoExpr );
  }
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:14,代码来源:StubBuilder.java


示例12: withName

import com.intellij.psi.PsiNameValuePair; //导入依赖的package包/类
public PsiNameValuePairPattern withName(@NotNull @NonNls final String requiredName) {
  return with(new PatternCondition<PsiNameValuePair>("withName") {
    public boolean accepts(@NotNull final PsiNameValuePair psiNameValuePair, final ProcessingContext context) {
      String actualName = psiNameValuePair.getName();
      return requiredName.equals(actualName) || actualName == null && "value".equals(requiredName);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:PsiNameValuePairPattern.java


示例13: annotateMethod

import com.intellij.psi.PsiNameValuePair; //导入依赖的package包/类
private void annotateMethod(@NotNull PsiMethod method) {
  try {
    AddAnnotationPsiFix fix = new AddAnnotationPsiFix(myAnnotation, method, PsiNameValuePair.EMPTY_ARRAY, myAnnotationsToRemove);
    fix.invoke(method.getProject(), method.getContainingFile(), method, method);
  }
  catch (IncorrectOperationException e) {
    LOG.error(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:AnnotateMethodFix.java


示例14: buildBlocks

import com.intellij.psi.PsiNameValuePair; //导入依赖的package包/类
public List<Block> buildBlocks() {
  final Wrap wrap = Wrap.createWrap(getWrapType(myJavaSettings.ANNOTATION_PARAMETER_WRAP), false);
  final Alignment alignment = myJavaSettings.ALIGN_MULTILINE_ANNOTATION_PARAMETERS ? Alignment.createAlignment() : null;

  ChildrenBlocksBuilder.Config config = new ChildrenBlocksBuilder.Config()
    .setDefaultIndent(Indent.getContinuationWithoutFirstIndent())
    .setIndent(JavaTokenType.RPARENTH, Indent.getNoneIndent())
    .setIndent(JavaTokenType.LPARENTH, Indent.getNoneIndent())

    .setDefaultWrap(wrap)
    .setNoWrap(JavaTokenType.COMMA)
    .setNoWrap(JavaTokenType.RPARENTH)
    .setNoWrap(JavaTokenType.LPARENTH)

    .setDefaultAlignment(alignment)
    .setNoAlignment(JavaTokenType.COMMA)
    .setNoAlignment(JavaTokenType.LPARENTH)
    .setNoAlignmentIf(JavaTokenType.RPARENTH, new Condition<ASTNode>() {
      @Override
      public boolean value(ASTNode node) {
        PsiElement prev = PsiTreeUtil.skipSiblingsBackward(node.getPsi(), PsiWhiteSpace.class);
        if (prev == null) return false;
        return prev instanceof PsiNameValuePair && !PsiTreeUtil.hasErrorElements(prev);
      }
    });

  return config.createBuilder().buildNodeChildBlocks(myNode, myFactory);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:AnnotationInitializerBlocksBuilder.java


示例15: 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


示例16: getNamedAnnotationValue

import com.intellij.psi.PsiNameValuePair; //导入依赖的package包/类
/**
 * Returns the value for @Named if it exists for <code>psiParameter</code> or null if it does not
 * exist.
 *
 * @param psiParameter The parameter whose @Named value is to be returned.
 * @return The @Named value if it exists for <code>psiParameter</code> or null if it does not
 *     exist.
 */
@Nullable
public PsiAnnotationMemberValue getNamedAnnotationValue(PsiParameter psiParameter) {
  PsiModifierList modifierList = psiParameter.getModifierList();
  if (modifierList == null) {
    return null;
  }

  PsiAnnotation annotation = modifierList.findAnnotation("javax.inject.Named");
  if (annotation == null) {
    annotation = modifierList.findAnnotation(GctConstants.APP_ENGINE_ANNOTATION_NAMED);
    if (annotation == null) {
      return null;
    }
  }

  PsiNameValuePair[] nameValuePairs = annotation.getParameterList().getAttributes();
  if (nameValuePairs.length != 1) {
    return null;
  }

  if (nameValuePairs[0] == null) {
    return null;
  }

  return nameValuePairs[0].getValue();
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:35,代码来源:EndpointPsiElementVisitor.java


示例17: 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


示例18: isOnXParameterValue

import com.intellij.psi.PsiNameValuePair; //导入依赖的package包/类
public static boolean isOnXParameterValue(HighlightInfo highlightInfo, PsiFile file) {
  if (!CANNOT_FIND_METHOD_VALUE_MESSAGE.equals(highlightInfo.getDescription())) {
    return false;
  }

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

  PsiElement leftSibling = nameValuePair.getContext().getPrevSibling();
  return (leftSibling != null && UNDERSCORES.matcher(StringUtil.notNullize(leftSibling.getText())).matches());
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:15,代码来源:OnXAnnotationHandler.java


示例19: findContainingNameValuePair

import com.intellij.psi.PsiNameValuePair; //导入依赖的package包/类
private static PsiNameValuePair findContainingNameValuePair(PsiElement highlightedElement) {
  PsiElement nameValuePair = highlightedElement;
  while (!(nameValuePair == null || nameValuePair instanceof PsiNameValuePair)) {
    nameValuePair = nameValuePair.getContext();
  }

  return (PsiNameValuePair) nameValuePair;
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:9,代码来源:OnXAnnotationHandler.java


示例20: isEqualsAndHashCodeCallSuperDefault

import com.intellij.psi.PsiNameValuePair; //导入依赖的package包/类
public static boolean isEqualsAndHashCodeCallSuperDefault(HighlightInfo highlightInfo, PsiFile file) {
  PsiElement element = file.findElementAt(highlightInfo.getStartOffset());

  PsiNameValuePair psiNameValuePair = PsiTreeUtil.getParentOfType(element, PsiNameValuePair.class);
  if (psiNameValuePair == null) {
    return false;
  }
  PsiAnnotation psiAnnotation = PsiTreeUtil.getParentOfType(psiNameValuePair, PsiAnnotation.class);
  if (psiAnnotation == null) {
    return false;
  }

  return "callSuper".equals(psiNameValuePair.getName()) && "EqualsAndHashCode".equals(PsiAnnotationSearchUtil.getSimpleNameOf(psiAnnotation));
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:15,代码来源:EqualsAndHashCodeCallSuperHandler.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ModelLoader类代码示例发布时间:2022-05-22
下一篇:
Java FindUsagesOptions类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap