本文整理汇总了Java中com.intellij.psi.PsiAnnotationParameterList类的典型用法代码示例。如果您正苦于以下问题:Java PsiAnnotationParameterList类的具体用法?Java PsiAnnotationParameterList怎么用?Java PsiAnnotationParameterList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PsiAnnotationParameterList类属于com.intellij.psi包,在下文中一共展示了PsiAnnotationParameterList类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: isOnXParameterAnnotation
import com.intellij.psi.PsiAnnotationParameterList; //导入依赖的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: removeDefaultAnnotation
import com.intellij.psi.PsiAnnotationParameterList; //导入依赖的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
示例3: getValueStringFromAnnotationWithDefault
import com.intellij.psi.PsiAnnotationParameterList; //导入依赖的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
示例4: isOnXParameterValue
import com.intellij.psi.PsiAnnotationParameterList; //导入依赖的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
示例5: getOnX
import com.intellij.psi.PsiAnnotationParameterList; //导入依赖的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;
}
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:15,代码来源:LombokProcessorUtil.java
示例6: findDefaultValue
import com.intellij.psi.PsiAnnotationParameterList; //导入依赖的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
示例7: ClsAnnotationImpl
import com.intellij.psi.PsiAnnotationParameterList; //导入依赖的package包/类
public ClsAnnotationImpl(final PsiAnnotationStub stub)
{
super(stub);
myReferenceElement = new AtomicNotNullLazyValue<ClsJavaCodeReferenceElementImpl>()
{
@NotNull
@Override
protected ClsJavaCodeReferenceElementImpl compute()
{
String annotationText = getStub().getText();
int index = annotationText.indexOf('(');
String refText = index > 0 ? annotationText.substring(1, index) : annotationText.substring(1);
return new ClsJavaCodeReferenceElementImpl(ClsAnnotationImpl.this, refText);
}
};
myParameterList = new AtomicNotNullLazyValue<ClsAnnotationParameterListImpl>()
{
@NotNull
@Override
protected ClsAnnotationParameterListImpl compute()
{
PsiNameValuePair[] attrs = getStub().getText().indexOf('(') > 0 ? PsiTreeUtil.getRequiredChildOfType(getStub().getPsiElement(), PsiAnnotationParameterList.class).getAttributes() :
PsiNameValuePair.EMPTY_ARRAY;
return new ClsAnnotationParameterListImpl(ClsAnnotationImpl.this, attrs);
}
};
}
开发者ID:consulo,项目名称:consulo-java,代码行数:28,代码来源:ClsAnnotationImpl.java
示例8: getMovableSubElements
import com.intellij.psi.PsiAnnotationParameterList; //导入依赖的package包/类
@RequiredReadAction
@NotNull
@Override
public PsiElement[] getMovableSubElements(@NotNull PsiElement element)
{
if(element instanceof PsiParameterList)
{
return ((PsiParameterList) element).getParameters();
}
else if(element instanceof PsiExpressionList)
{
return ((PsiExpressionList) element).getExpressions();
}
else if(element instanceof PsiAnnotationParameterList)
{
return ((PsiAnnotationParameterList) element).getAttributes();
}
else if(element instanceof PsiArrayInitializerExpression)
{
return ((PsiArrayInitializerExpression) element).getInitializers();
}
else if(element instanceof PsiClass && ((PsiClass) element).isEnum())
{
PsiEnumConstant[] enumConstants = PsiTreeUtil.getChildrenOfType(element, PsiEnumConstant.class);
if(enumConstants != null)
{
return enumConstants;
}
}
return PsiElement.EMPTY_ARRAY;
}
开发者ID:consulo,项目名称:consulo-java,代码行数:32,代码来源:JavaMoveLeftRightHandler.java
示例9: visitAnnotationParameterList
import com.intellij.psi.PsiAnnotationParameterList; //导入依赖的package包/类
@Override
public void visitAnnotationParameterList(PsiAnnotationParameterList list) {
mVisitor.report("PsiAnnotationParameterList", list.getText(), list);
super.visitElement(list);
}
开发者ID:cch-robo,项目名称:Android_Lint_SRP_Practice_Example,代码行数:6,代码来源:PsiClassStructureDetector.java
示例10: createPsi
import com.intellij.psi.PsiAnnotationParameterList; //导入依赖的package包/类
@Override
public PsiAnnotationParameterList createPsi(@NotNull ASTNode node) {
return new PsiAnnotationParamListImpl(node);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:JavaAnnotationParameterListType.java
示例11: buildVisitor
import com.intellij.psi.PsiAnnotationParameterList; //导入依赖的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());
}
}
};
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:48,代码来源:ApiNameInspection.java
示例12: getParameterList
import com.intellij.psi.PsiAnnotationParameterList; //导入依赖的package包/类
@Override
@NotNull
public PsiAnnotationParameterList getParameterList()
{
return myParameterList.getValue();
}
开发者ID:consulo,项目名称:consulo-java,代码行数:7,代码来源:ClsAnnotationImpl.java
示例13: getParameterList
import com.intellij.psi.PsiAnnotationParameterList; //导入依赖的package包/类
@Override
@NotNull
public PsiAnnotationParameterList getParameterList()
{
return myParameterList;
}
开发者ID:consulo,项目名称:consulo-java,代码行数:7,代码来源:ClsAnnotationValueImpl.java
注:本文中的com.intellij.psi.PsiAnnotationParameterList类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论