本文整理汇总了Java中com.intellij.psi.PsiAnnotation.getParameterList方法的典型用法代码示例。如果您正苦于以下问题:Java PsiAnnotation.getParameterList方法的具体用法?Java PsiAnnotation.getParameterList怎么用?Java PsiAnnotation.getParameterList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiAnnotation
的用法示例。
在下文中一共展示了PsiAnnotation.getParameterList方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeDefaultAnnotation
import com.intellij.psi.PsiAnnotation; //导入方法依赖的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();
}
}
}
示例2: getValueStringFromAnnotationWithDefault
import com.intellij.psi.PsiAnnotation; //导入方法依赖的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);
}
示例3: getOnX
import com.intellij.psi.PsiAnnotation; //导入方法依赖的package包/类
@NotNull
public static Collection<String> getOnX(@NotNull PsiAnnotation psiAnnotation, @NotNull String parameterName) {
PsiAnnotationMemberValue onXValue = psiAnnotation.findAttributeValue(parameterName);
if (!(onXValue instanceof PsiAnnotation)) {
return Collections.emptyList();
}
Collection<PsiAnnotation> annotations = PsiAnnotationUtil.getAnnotationValues((PsiAnnotation) onXValue, "value", PsiAnnotation.class);
Collection<String> annotationStrings = new ArrayList<String>();
for (PsiAnnotation annotation : annotations) {
PsiAnnotationParameterList params = annotation.getParameterList();
annotationStrings.add(PsiAnnotationSearchUtil.getSimpleNameOf(annotation) + params.getText());
}
return annotationStrings;
}
示例4: findDefaultValue
import com.intellij.psi.PsiAnnotation; //导入方法依赖的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;
}
示例5: buildVisitor
import com.intellij.psi.PsiAnnotation; //导入方法依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(
@NotNull final com.intellij.codeInspection.ProblemsHolder holder, boolean isOnTheFly) {
return new EndpointPsiElementVisitor() {
@Override
public void visitAnnotation(PsiAnnotation annotation) {
if (annotation == null) {
return;
}
if (!GctConstants.APP_ENGINE_ANNOTATION_API.equals(annotation.getQualifiedName())) {
return;
}
// Need to check for user added attributes because default values are used when not
// specified by user and we are only interested in the user specified values
PsiAnnotationParameterList parameterList = annotation.getParameterList();
if (parameterList.getAttributes().length == 0) {
return;
}
PsiAnnotationMemberValue annotationMemberValue =
annotation.findAttributeValue(API_NAME_ATTRIBUTE);
if (annotationMemberValue == null) {
return;
}
String nameValueWithQuotes = annotationMemberValue.getText();
String nameValue = EndpointUtilities.removeBeginningAndEndingQuotes(nameValueWithQuotes);
// Empty API name is valid
if (nameValue.isEmpty()) {
return;
}
if (!API_NAME_PATTERN.matcher(nameValue).matches()) {
holder.registerProblem(
annotationMemberValue,
"Invalid api name: it must start with a lower case letter and consists only of "
+ "letter and digits",
new MyQuickFix());
}
}
};
}