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


Java PsiAnnotationMemberValue类代码示例

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


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

示例1: toStringImpl

import com.intellij.psi.PsiAnnotationMemberValue; //导入依赖的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

示例2: checkArgumentList

import com.intellij.psi.PsiAnnotationMemberValue; //导入依赖的package包/类
@Override
public boolean checkArgumentList(@NotNull AnnotationHolder holder, @NotNull GrAnnotation annotation) {
  if (!GroovyCommonClassNames.GROOVY_LANG_DELEGATES_TO.equals(annotation.getQualifiedName())) return false;

  final PsiAnnotationMemberValue valueAttribute = annotation.findAttributeValue("value");

  if (valueAttribute == null) {
    final PsiAnnotationOwner owner = annotation.getOwner();
    if (owner instanceof GrModifierList) {
      final PsiElement parent1 = ((GrModifierList)owner).getParent();
      if (parent1 instanceof GrParameter) {
        final PsiElement parent = parent1.getParent();
        if (parent instanceof GrParameterList) {
          for (GrParameter parameter : ((GrParameterList)parent).getParameters()) {
            if (parameter.getModifierList().findAnnotation(GroovyCommonClassNames.GROOVY_LANG_DELEGATES_TO_TARGET) != null) {
              return true;
            }
          }
        }
      }
    }
  }

  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:DelegatesToAnnotationChecker.java

示例3: addOwnerDomainAttribute

import com.intellij.psi.PsiAnnotationMemberValue; //导入依赖的package包/类
private void addOwnerDomainAttribute(
    @NotNull final Project project, final PsiAnnotation annotation) {
  new WriteCommandAction(project, annotation.getContainingFile()) {
    @Override
    protected void run(final Result result) throws Throwable {
      // @A(ownerDomain = "your-company.com")
      PsiAnnotationMemberValue newMemberValue =
          JavaPsiFacade.getInstance(project)
              .getElementFactory()
              .createAnnotationFromText(
                  "@A("
                      + API_NAMESPACE_DOMAIN_ATTRIBUTE
                      + " = \""
                      + SUGGESTED_DOMAIN_ATTRIBUTE
                      + "\")",
                  null)
              .findDeclaredAttributeValue(API_NAMESPACE_DOMAIN_ATTRIBUTE);

      annotation.setDeclaredAttributeValue(API_NAMESPACE_DOMAIN_ATTRIBUTE, newMemberValue);
    }
  }.execute();
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:23,代码来源:ApiNamespaceInspection.java

示例4: addOwnerNameAttribute

import com.intellij.psi.PsiAnnotationMemberValue; //导入依赖的package包/类
private void addOwnerNameAttribute(
    @NotNull final Project project, final PsiAnnotation annotation) {
  new WriteCommandAction(project, annotation.getContainingFile()) {
    @Override
    protected void run(final Result result) throws Throwable {
      // @A(ownerName = "YourCo")
      PsiAnnotationMemberValue newMemberValue =
          JavaPsiFacade.getInstance(project)
              .getElementFactory()
              .createAnnotationFromText(
                  "@A("
                      + API_NAMESPACE_NAME_ATTRIBUTE
                      + " = \""
                      + SUGGESTED_OWNER_ATTRIBUTE
                      + "\")",
                  null)
              .findDeclaredAttributeValue(API_NAMESPACE_NAME_ATTRIBUTE);

      annotation.setDeclaredAttributeValue(API_NAMESPACE_NAME_ATTRIBUTE, newMemberValue);
    }
  }.execute();
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:23,代码来源:ApiNamespaceInspection.java

示例5: getAttributeFromAnnotation

import com.intellij.psi.PsiAnnotationMemberValue; //导入依赖的package包/类
private String getAttributeFromAnnotation(
    PsiAnnotation annotation, String annotationType, final String attribute)
    throws InvalidAnnotationException, MissingAttributeException {

  String annotationQualifiedName = annotation.getQualifiedName();
  if (annotationQualifiedName == null) {
    throw new InvalidAnnotationException(annotation, annotationType);
  }

  if (annotationQualifiedName.equals(annotationType)) {
    PsiAnnotationMemberValue annotationMemberValue = annotation.findAttributeValue(attribute);
    if (annotationMemberValue == null) {
      throw new MissingAttributeException(annotation, attribute);
    }

    String httpMethodWithQuotes = annotationMemberValue.getText();
    return httpMethodWithQuotes.substring(1, httpMethodWithQuotes.length() - 1);
  } else {
    throw new InvalidAnnotationException(annotation, annotationType);
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:22,代码来源:RestSignatureInspection.java

示例6: initializePsiMethod

import com.intellij.psi.PsiAnnotationMemberValue; //导入依赖的package包/类
private void initializePsiMethod(String methodName, String httpMethodValue, String pathValue) {
  PsiAnnotationMemberValue mockAnnotationMemberValue1 = mock(PsiAnnotationMemberValue.class);
  when(mockAnnotationMemberValue1.getText()).thenReturn(httpMethodValue);

  PsiAnnotationMemberValue mockAnnotationMemberValue2 = mock(PsiAnnotationMemberValue.class);
  when(mockAnnotationMemberValue2.getText()).thenReturn(pathValue);

  PsiAnnotation mockAnnotation = mock(PsiAnnotation.class);
  when(mockAnnotation.getQualifiedName())
      .thenReturn(GctConstants.APP_ENGINE_ANNOTATION_API_METHOD);
  when(mockAnnotation.findAttributeValue("httpMethod")).thenReturn(mockAnnotationMemberValue1);
  when(mockAnnotation.findAttributeValue("path")).thenReturn(mockAnnotationMemberValue2);
  PsiAnnotation[] mockAnnotationsArray = {mockAnnotation};

  PsiModifierList mockModifierList = mock(PsiModifierList.class);
  when(mockModifierList.getAnnotations()).thenReturn(mockAnnotationsArray);

  mockPsiMethod = mock(PsiMethod.class);
  when(mockPsiMethod.getModifierList()).thenReturn(mockModifierList);
  when(mockPsiMethod.getName()).thenReturn(methodName);
  when(mockPsiMethod.getContainingClass()).thenReturn(mockPsiClass);

  PsiParameterList mockParameterList = mock(PsiParameterList.class);
  when(mockParameterList.getParameters()).thenReturn(new PsiParameter[0]);
  when(mockPsiMethod.getParameterList()).thenReturn(mockParameterList);
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:27,代码来源:RestSignatureInspectionTest.java

示例7: initializePsiClass

import com.intellij.psi.PsiAnnotationMemberValue; //导入依赖的package包/类
private void initializePsiClass(String apiResource, String apiClassResource) {
  PsiAnnotationMemberValue mockAnnotationMemberValue1 = mock(PsiAnnotationMemberValue.class);
  when(mockAnnotationMemberValue1.getText()).thenReturn(apiResource);

  PsiAnnotationMemberValue mockAnnotationMemberValue2 = mock(PsiAnnotationMemberValue.class);
  when(mockAnnotationMemberValue2.getText()).thenReturn(apiClassResource);

  // Mock @Api(resource = "")
  PsiAnnotation mockAnnotation1 = mock(PsiAnnotation.class);
  when(mockAnnotation1.getQualifiedName()).thenReturn(GctConstants.APP_ENGINE_ANNOTATION_API);
  when(mockAnnotation1.findAttributeValue("resource")).thenReturn(mockAnnotationMemberValue1);

  // Mock @ApiClass(resource = "")
  PsiAnnotation mockAnnotation2 = mock(PsiAnnotation.class);
  when(mockAnnotation2.getQualifiedName())
      .thenReturn(GctConstants.APP_ENGINE_ANNOTATION_API_CLASS);
  when(mockAnnotation2.findAttributeValue("resource")).thenReturn(mockAnnotationMemberValue2);

  PsiAnnotation[] mockAnnotationsArray = {mockAnnotation1, mockAnnotation2};

  PsiModifierList mockModifierList = mock(PsiModifierList.class);
  when(mockModifierList.getAnnotations()).thenReturn(mockAnnotationsArray);

  mockPsiClass = mock(PsiClass.class);
  when(mockPsiClass.getModifierList()).thenReturn(mockModifierList);
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:27,代码来源:RestSignatureInspectionTest.java

示例8: getAttributeValue

import com.intellij.psi.PsiAnnotationMemberValue; //导入依赖的package包/类
public static String getAttributeValue(PsiAnnotation annotation, String attributeName, DefaultPolicy policy) {
  final PsiAnnotationMemberValue value = getAnnotationMemberValue(annotation, attributeName);
  if (value != null) {
    if (value instanceof PsiClassObjectAccessExpression) {
      final PsiType type = ((PsiClassObjectAccessExpression) value).getType();
      if (type == null) {
        return null;
      }
      return type.getCanonicalText();
    }
    else {
      final String text = value.getText();
      return text.substring(1, text.length() - 1);
    }
  }

  if (policy == DefaultPolicy.OWNER_IDENTIFIER_NAME) {
    return PsiUtil.getName(getImmediateOwnerElement(annotation));
  }
  else {
    return null;
  }
}
 
开发者ID:errai,项目名称:errai-intellij-idea-plugin,代码行数:24,代码来源:Util.java

示例9: shouldShow

import com.intellij.psi.PsiAnnotationMemberValue; //导入依赖的package包/类
@Override public boolean shouldShow(UsageTarget target, Usage usage) {
  PsiElement element = ((UsageInfo2UsageAdapter) usage).getElement();
  PsiMethod psimethod = PsiConsultantImpl.findMethod(element);

  PsiAnnotationMemberValue attribValue = PsiConsultantImpl
      .findTypeAttributeOfProvidesAnnotation(psimethod);

  // Is it a @Provides method?
  return psimethod != null
      // Ensure it has an @Provides.
      && PsiConsultantImpl.hasAnnotation(psimethod, CLASS_PROVIDES)
      // Check for Qualifier annotations.
      && PsiConsultantImpl.hasQuailifierAnnotations(psimethod, qualifierAnnotations)
      // Right return type.
      && PsiConsultantImpl.getReturnClassFromMethod(psimethod, false)
      .getName()
      .equals(target.getName())
      // Right type parameters.
      && PsiConsultantImpl.hasTypeParameters(psimethod, typeParameters)
      // @Provides(type=SET)
      && attribValue != null
      && attribValue.textMatches(SET_TYPE);
}
 
开发者ID:square,项目名称:dagger-intellij-plugin,代码行数:24,代码来源:Decider.java

示例10: getParameterizedLocation

import com.intellij.psi.PsiAnnotationMemberValue; //导入依赖的package包/类
public static Location getParameterizedLocation(PsiClass psiClass, String paramSetName, String parameterizedClassName)
{
	final PsiAnnotation annotation = AnnotationUtil.findAnnotationInHierarchy(psiClass, Collections.singleton(JUnitUtil.RUN_WITH));
	if(annotation != null)
	{
		final PsiAnnotationMemberValue attributeValue = annotation.findAttributeValue("value");
		if(attributeValue instanceof PsiClassObjectAccessExpression)
		{
			final PsiTypeElement operand = ((PsiClassObjectAccessExpression) attributeValue).getOperand();
			if(InheritanceUtil.isInheritor(operand.getType(), parameterizedClassName))
			{
				return new PsiMemberParameterizedLocation(psiClass.getProject(), psiClass, null, paramSetName);
			}
		}
	}
	return null;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:18,代码来源:PsiMemberParameterizedLocation.java

示例11: extractNullityFromWhenValue

import com.intellij.psi.PsiAnnotationMemberValue; //导入依赖的package包/类
@NotNull
private static Nullness extractNullityFromWhenValue(PsiAnnotation nonNull)
{
	PsiAnnotationMemberValue when = nonNull.findAttributeValue("when");
	if(when instanceof PsiReferenceExpression)
	{
		String refName = ((PsiReferenceExpression) when).getReferenceName();
		if("ALWAYS".equals(refName))
		{
			return Nullness.NOT_NULL;
		}
		if("MAYBE".equals(refName) || "NEVER".equals(refName))
		{
			return Nullness.NULLABLE;
		}
	}
	return Nullness.UNKNOWN;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:NullableNotNullManagerImpl.java

示例12: findTargetFeature

import com.intellij.psi.PsiAnnotationMemberValue; //导入依赖的package包/类
private static PsiElement findTargetFeature( PsiAnnotation psiAnnotation, ManifoldPsiClass facade )
  {
    PsiAnnotationMemberValue value = psiAnnotation.findAttributeValue( SourcePosition.FEATURE );
    String featureName = StringUtil.unquoteString( value.getText() );
//    value = psiAnnotation.findAttributeValue( SourcePosition.TYPE );
//    if( value != null )
//    {
//      String ownersType = StringUtil.unquoteString( value.getText() );
//      if( ownersType != null )
//      {
//        PsiElement target = findIndirectTarget( ownersType, featureName, facade.getRawFile().getProject() );
//        if( target != null )
//        {
//          return target;
//        }
//      }
//    }

    int iOffset = Integer.parseInt( psiAnnotation.findAttributeValue( SourcePosition.OFFSET ).getText() );
    int iLength = Integer.parseInt( psiAnnotation.findAttributeValue( SourcePosition.LENGTH ).getText() );

    List<PsiFile> sourceFiles = facade.getRawFiles();
    if( iOffset >= 0 )
    {
      //PsiElement target = sourceFile.findElementAt( iOffset );
      //## todo: handle multiple files
      return new FakeTargetElement( sourceFiles.get( 0 ), iOffset, iLength >= 0 ? iLength : 1, featureName );
    }
    return facade;
  }
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:31,代码来源:ManGotoDeclarationHandler.java

示例13: RemoveAnnotationValueFix

import com.intellij.psi.PsiAnnotationMemberValue; //导入依赖的package包/类
private RemoveAnnotationValueFix( @NotNull PsiAnnotationMemberValue annotationValueToRemove,
                                  @NotNull PsiJavaCodeReferenceElement sideEffectClassReference )
{
    super( message( "side.effects.annotation.declared.correctly.fix.remove.class.reference",
                    sideEffectClassReference.getQualifiedName() ) );
    this.annotationValueToRemove = annotationValueToRemove;
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:8,代码来源:SideEffectsAnnotationDeclaredCorrectlyInspection.java

示例14: RemoveInvalidConcernClassReferenceFix

import com.intellij.psi.PsiAnnotationMemberValue; //导入依赖的package包/类
public RemoveInvalidConcernClassReferenceFix( @NotNull PsiAnnotationMemberValue annotationValueToRemove,
                                              @NotNull PsiJavaCodeReferenceElement concernClassReference )
{
    super( message( "concerns.annotation.declared.correctly.fix.remove.concern.class.reference",
                    concernClassReference.getQualifiedName() ) );
    this.concernClassAnnotationValue = annotationValueToRemove;
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:8,代码来源:ConcernsAnnotationDeclaredCorrectlyInspection.java

示例15: createProblemDescriptor

import com.intellij.psi.PsiAnnotationMemberValue; //导入依赖的package包/类
private ProblemDescriptor createProblemDescriptor( @NotNull InspectionManager manager,
                                                   @NotNull PsiAnnotationMemberValue mixinAnnotationValue,
                                                   @NotNull PsiJavaCodeReferenceElement mixinClassReference,
                                                   @NotNull String message )
{
    RemoveInvalidMixinClassReferenceFix fix = new RemoveInvalidMixinClassReferenceFix(
        mixinAnnotationValue, mixinClassReference
    );
    return manager.createProblemDescriptor( mixinAnnotationValue, message, fix, GENERIC_ERROR_OR_WARNING );
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:11,代码来源:MixinImplementsMixinType.java


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