本文整理汇总了Java中com.intellij.psi.PsiAnnotationMemberValue类的典型用法代码示例。如果您正苦于以下问题:Java PsiAnnotationMemberValue类的具体用法?Java PsiAnnotationMemberValue怎么用?Java PsiAnnotationMemberValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PsiAnnotationMemberValue类属于com.intellij.psi包,在下文中一共展示了PsiAnnotationMemberValue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: buildVisitor
import com.intellij.psi.PsiAnnotationMemberValue; //导入依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new EndpointPsiElementVisitor() {
@Override
public void visitAnnotation(PsiAnnotation annotation) {
if (!EndpointUtilities.isEndpointClass(annotation)) {
return;
}
if (!GctConstants.APP_ENGINE_ANNOTATION_API_METHOD.equals(annotation.getQualifiedName())) {
return;
}
PsiAnnotationMemberValue memberValue = annotation.findAttributeValue(API_NAME_ATTRIBUTE);
if (memberValue == null) {
return;
}
String nameValueWithQuotes = memberValue.getText();
String nameValue = EndpointUtilities.removeBeginningAndEndingQuotes(nameValueWithQuotes);
if (nameValue.isEmpty()) {
return;
}
if (!API_NAME_PATTERN
.matcher(EndpointUtilities.collapseSequenceOfDots(nameValue))
.matches()) {
holder.registerProblem(
memberValue,
"Invalid method name: letters, digits, underscores and dots are acceptable "
+ "characters. Leading and trailing dots are prohibited.",
new MyQuickFix());
}
}
};
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:38,代码来源:MethodNameInspection.java
示例17: hasTransformer
import com.intellij.psi.PsiAnnotationMemberValue; //导入依赖的package包/类
/**
* Returns true if the class containing <code>psiElement</code> has a transformer specified by
* using the @ApiTransformer annotation on a class or by using the transformer attribute of the
*
* @return True if the class containing <code>psiElement</code> has a transformer and false
* otherwise. @Api annotation. Returns false otherwise.
*/
public boolean hasTransformer(PsiElement psiElement) {
PsiClass psiClass = PsiUtils.findClass(psiElement);
if (psiClass == null) {
return false;
}
PsiModifierList modifierList = psiClass.getModifierList();
if (modifierList == null) {
return false;
}
// Check if class has @ApiTransformer to specify a transformer
PsiAnnotation apiTransformerAnnotation =
modifierList.findAnnotation(GctConstants.APP_ENGINE_ANNOTATION_API_TRANSFORMER);
if (apiTransformerAnnotation != null) {
return true;
}
// Check if class utilizes the transformer attribute of the @Api annotation
// to specify its transformer
PsiAnnotation apiAnnotation =
modifierList.findAnnotation(GctConstants.APP_ENGINE_ANNOTATION_API);
if (apiAnnotation != null) {
PsiAnnotationMemberValue transformerMember =
apiAnnotation.findAttributeValue(API_TRANSFORMER_ATTRIBUTE);
if (transformerMember != null && !transformerMember.getText().equals("{}")) {
return true;
}
}
return false;
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:40,代码来源:EndpointPsiElementVisitor.java
示例18: getNamedAnnotationValue
import com.intellij.psi.PsiAnnotationMemberValue; //导入依赖的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
示例19: addOwnerDomainAndNameAttributes
import com.intellij.psi.PsiAnnotationMemberValue; //导入依赖的package包/类
private void addOwnerDomainAndNameAttributes(
@NotNull final Project project, final PsiAnnotation annotation) {
new WriteCommandAction(project, annotation.getContainingFile()) {
@Override
protected void run(final Result result) throws Throwable {
// @A(ownerName = "YourCo", ownerDomain = "your-company.com")
String annotationString =
"@A("
+ API_NAMESPACE_NAME_ATTRIBUTE
+ " = \""
+ SUGGESTED_OWNER_ATTRIBUTE
+ "\", "
+ API_NAMESPACE_DOMAIN_ATTRIBUTE
+ " = \""
+ "your-company.com"
+ "\")";
PsiAnnotation newAnnotation =
JavaPsiFacade.getInstance(project)
.getElementFactory()
.createAnnotationFromText(annotationString, null);
PsiAnnotationMemberValue newDomainMemberValue =
newAnnotation.findDeclaredAttributeValue(API_NAMESPACE_DOMAIN_ATTRIBUTE);
PsiAnnotationMemberValue newNameMemberValue =
newAnnotation.findDeclaredAttributeValue(API_NAMESPACE_NAME_ATTRIBUTE);
annotation.setDeclaredAttributeValue(API_NAMESPACE_NAME_ATTRIBUTE, newNameMemberValue);
annotation.setDeclaredAttributeValue(
API_NAMESPACE_DOMAIN_ATTRIBUTE, newDomainMemberValue);
}
}.execute();
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:32,代码来源:ApiNamespaceInspection.java
示例20: getPathParameter
import com.intellij.psi.PsiAnnotationMemberValue; //导入依赖的package包/类
/**
* Returns "/{}" for every parameter with a valid @Named annotation in {@code method} that does
* not have @Nullable/@Default.
*/
private String getPathParameter(PsiMethod method) {
StringBuilder path = new StringBuilder();
EndpointPsiElementVisitor elementVisitor = new EndpointPsiElementVisitor();
List<String> annotions =
Arrays.asList(
GctConstants.APP_ENGINE_ANNOTATION_NULLABLE,
"javax.annotation.Nullable",
GctConstants.APP_ENGINE_ANNOTATION_DEFAULT_VALUE);
for (PsiParameter param : method.getParameterList().getParameters()) {
// Check for @Nullable/@Default
PsiModifierList modifierList = param.getModifierList();
if (modifierList == null) {
continue;
}
if (AnnotationUtil.isAnnotated(param, annotions)) {
continue;
}
PsiAnnotationMemberValue namedValue = elementVisitor.getNamedAnnotationValue(param);
if (namedValue != null) {
path.append("/{}");
}
}
return path.toString();
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:33,代码来源:RestSignatureInspection.java
注:本文中的com.intellij.psi.PsiAnnotationMemberValue类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论