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

Java PsiModifierList类代码示例

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

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



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

示例1: findAnnotations

import com.intellij.psi.PsiModifierList; //导入依赖的package包/类
static List<String> findAnnotations(PsiModifierListOwner element, boolean nullable) {
    if (overridesSuper(element)) {
        return Collections.emptyList();
    }

    List<String> annotations = new ArrayList<>();
    Project project = element.getProject();
    PsiModifierList modifierList = element.getModifierList();
    List<String> nullabilityAnnotations = nullable
            ? NullableNotNullManager.getInstance(project).getNullables()
            : NullableNotNullManager.getInstance(project).getNotNulls();
    for (String notNullAnnotationFqn : nullabilityAnnotations) {
        PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
        PsiAnnotation annotation = factory.createAnnotationFromText("@" + notNullAnnotationFqn, null);
        PsiAnnotation.TargetType[] targetTypes = getTargetsForLocation(modifierList);
        if (isNullabilityAnnotationForTypeQualifierDefault(annotation, nullable, targetTypes)) {
            annotations.add(annotation.getQualifiedName());
        }
    }
    return annotations;
}
 
开发者ID:stylismo,项目名称:nullability-annotations-inspection,代码行数:22,代码来源:NullabilityAnnotationsWithTypeQualifierDefault.java


示例2: visitClass

import com.intellij.psi.PsiModifierList; //导入依赖的package包/类
@Override
public void visitClass(UClass uClass) {
    //only check interface
    if(!uClass.isInterface()){
        return;
    }
    Set<PropInfo> infos = getPropInfoWithSupers(uClass);
    if(infos.isEmpty()){
        return;
    }
   //check method is relative of any field
    for(UMethod method: uClass.getMethods()){
        PsiModifierList list = method.getModifierList();
        PsiAnnotation pa_keep = list.findAnnotation(NAME_KEEP);
        PsiAnnotation pa_impl = list.findAnnotation(NAME_IMPL_METHOD);
        if (pa_keep == null && pa_impl == null) {
            if(!hasPropInfo(infos, method.getName())){
                report(method);
            }
        }
    }
}
 
开发者ID:LightSun,项目名称:data-mediator,代码行数:23,代码来源:PropertyDetector.java


示例3: find

import com.intellij.psi.PsiModifierList; //导入依赖的package包/类
public static PsiElement find( PsiModifierListOwner resolve, ManifoldPsiClass facade )
{
  PsiModifierList modifierList = resolve.getModifierList();
  if( modifierList == null )
  {
    return null;
  }

  PsiAnnotation[] annotations = modifierList.getAnnotations();
  if( annotations.length > 0 &&
      Objects.equals( annotations[0].getQualifiedName(), SourcePosition.class.getName() ) )
  {
    return findTargetFeature( annotations[0], facade );
  }

  if( !facade.getRawFiles().isEmpty() &&
      DarkJavaTypeManifold.FILE_EXTENSIONS.stream()
        .anyMatch( ext -> ext.equalsIgnoreCase( facade.getRawFiles().get( 0 ).getVirtualFile().getExtension() ) ) )
  {
    // DarkJava is Java
    return facade.getRawFiles().get( 0 ).findElementAt( resolve.getTextOffset() );
  }

  return null;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:26,代码来源:ManGotoDeclarationHandler.java


示例4: errrantThisOrExtension

import com.intellij.psi.PsiModifierList; //导入依赖的package包/类
private void errrantThisOrExtension( PsiElement element, AnnotationHolder holder )
{
  if( element instanceof PsiModifierList )
  {
    PsiModifierList mods = (PsiModifierList)element;
    PsiAnnotation annotation;
    if( (annotation = mods.findAnnotation( Extension.class.getName() )) != null ||
        (annotation = mods.findAnnotation( This.class.getName() )) != null)
    {
      TextRange range = new TextRange( annotation.getTextRange().getStartOffset(),
                                       annotation.getTextRange().getEndOffset() );
      //noinspection ConstantConditions
      holder.createErrorAnnotation( range, ExtIssueMsg.MSG_NOT_IN_EXTENSION_CLASS.get( ClassUtil.extractClassName( annotation.getQualifiedName() ) ) );
    }
  }
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:17,代码来源:ExtensionClassAnnotator.java


示例5: findAnnotation

import com.intellij.psi.PsiModifierList; //导入依赖的package包/类
static PsiAnnotation findAnnotation(PsiElement element, String annotationName) {
    if (element instanceof PsiModifierListOwner) {
        PsiModifierListOwner listOwner = (PsiModifierListOwner) element;
        PsiModifierList modifierList = listOwner.getModifierList();

        if (modifierList != null) {
            for (PsiAnnotation psiAnnotation : modifierList.getAnnotations()) {
                if (annotationName.equals(psiAnnotation.getQualifiedName())) {
                    return psiAnnotation;
                }
            }
        }

    }
    return null;
}
 
开发者ID:anupcowkur,项目名称:here-be-dragons,代码行数:17,代码来源:AnnotationDetector.java


示例6: showDialog

import com.intellij.psi.PsiModifierList; //导入依赖的package包/类
@Override
protected String showDialog() {
  Project project = getProject();
  final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
  Module module = myModuleSelector.getModule();
  if (module == null) {
    Messages.showErrorDialog(project, ExecutionBundle.message("module.not.specified.error.text"), CommonBundle.getErrorTitle());
    return null;
  }
  GlobalSearchScope scope =
    myIncludeLibraryClasses ? module.getModuleWithDependenciesAndLibrariesScope(true) : module.getModuleWithDependenciesScope();
  PsiClass initialSelection = facade.findClass(getText(), scope);
  TreeClassChooser chooser = createTreeClassChooser(project, scope, initialSelection, new ClassFilter() {
    @Override
    public boolean isAccepted(PsiClass aClass) {
      if (aClass.isInterface()) return false;
      final PsiModifierList modifierList = aClass.getModifierList();
      return modifierList == null || !modifierList.hasModifierProperty(PsiModifier.ABSTRACT);
    }
  });
  if (chooser == null) return null;
  chooser.showDialog();
  PsiClass selClass = chooser.getSelected();
  return selClass != null ? selClass.getQualifiedName() : null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:AndroidClassBrowserBase.java


示例7: doFix

import com.intellij.psi.PsiModifierList; //导入依赖的package包/类
@Override
protected void doFix(final Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
  final PsiMethod method = PsiTreeUtil.getParentOfType(descriptor.getPsiElement(), PsiMethod.class);
  if (method != null) {
    final PsiModifierList modifierList = method.getModifierList();
    if (!modifierList.hasModifierProperty(PsiModifier.PUBLIC)) {
      modifierList.setModifierProperty(PsiModifier.PUBLIC, true);
    }
    if (!modifierList.hasModifierProperty(PsiModifier.STATIC)) {
      modifierList.setModifierProperty(PsiModifier.STATIC, true);
    }

    if (method.getReturnType() != PsiType.VOID) {
      ChangeSignatureProcessor csp =
        new ChangeSignatureProcessor(project, method, false, PsiModifier.PUBLIC, method.getName(), PsiType.VOID,
                                     new ParameterInfoImpl[0]);
      csp.run();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:BeforeClassOrAfterClassIsPublicStaticVoidNoArgInspection.java


示例8: doFix

import com.intellij.psi.PsiModifierList; //导入依赖的package包/类
@Override
protected void doFix(Project project, ProblemDescriptor descriptor) {
  final PsiElement psiElement = descriptor.getPsiElement();
  final Iterable<String> ids;
  if (psiElement instanceof PsiAnnotation) {
    ids = JavaSuppressionUtil.getInspectionIdsSuppressedInAnnotation((PsiModifierList)psiElement.getParent());
  }
  else {
    final String suppressedIds = JavaSuppressionUtil.getSuppressedInspectionIdsIn(psiElement);
    if (suppressedIds == null) {
      return;
    }
    ids = StringUtil.tokenize(suppressedIds, ",");
  }
  for (String id : ids) {
    if (!myAllowedSuppressions.contains(id)) {
      myAllowedSuppressions.add(id);
    }
  }
  saveProfile(project);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:SuppressionAnnotationInspection.java


示例9: visitAnnotation

import com.intellij.psi.PsiModifierList; //导入依赖的package包/类
@Override
public void visitAnnotation(GrAnnotation annotation) {
  super.visitAnnotation(annotation);

  PsiElement parent = annotation.getParent().getParent();
  if (parent == null || !(parent instanceof GrTypeDefinition)) return;

  if (SINGLETON.equals(annotation.getQualifiedName())) {
    GrTypeDefinition typeDefinition = (GrTypeDefinition)parent;

    PsiMethod[] methods = typeDefinition.getMethods();
    for (PsiMethod method : methods) {
      if (method.isConstructor()) {
        PsiModifierList modifierList = method.getModifierList();

        if (modifierList.hasModifierProperty(PsiModifier.PUBLIC)) {
          registerClassError(typeDefinition);
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:GroovySingletonAnnotationInspection.java


示例10: checkApplicability

import com.intellij.psi.PsiModifierList; //导入依赖的package包/类
@Override
public boolean checkApplicability(@NotNull AnnotationHolder holder, @NotNull GrAnnotation annotation) {
  final String qname = annotation.getQualifiedName();
  if (!GroovyCommonClassNames.GROOVY_TRANSFORM_FIELD.equals(qname)) return false;

  checkScriptField(holder, annotation);

  PsiElement annoParent = annotation.getParent();
  PsiElement ownerToUse = annoParent instanceof PsiModifierList ? annoParent.getParent() : annoParent;
  if (!(ownerToUse instanceof GrVariableDeclaration) ||
      !PsiUtil.isLocalVariable(((GrVariableDeclaration)ownerToUse).getVariables()[0])) {
    return false;
  }

  if (!GrAnnotationImpl.isAnnotationApplicableTo(annotation, PsiAnnotation.TargetType.LOCAL_VARIABLE)) {
    GrCodeReferenceElement ref = annotation.getClassReference();
    String target = JavaErrorMessages.message("annotation.target.LOCAL_VARIABLE");
    String description = JavaErrorMessages.message("annotation.not.applicable", ref.getText(), target);
    holder.createErrorAnnotation(ref, description);
  }

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


示例11: writeModifiers

import com.intellij.psi.PsiModifierList; //导入依赖的package包/类
public static boolean writeModifiers(StringBuilder builder, PsiModifierList modifierList, String[] modifiers, boolean writeAnnotations) {
  boolean wasAddedModifiers = false;

  if (writeAnnotations && modifierList instanceof GrModifierList) {
    GrAnnotation[] annotations = ((GrModifierList)modifierList).getAnnotations();
    AnnotationGenerator annotationGenerator = new AnnotationGenerator(builder, new ExpressionContext(modifierList.getProject(), GroovyFile.EMPTY_ARRAY));
    wasAddedModifiers = annotations.length > 0;
    for (GrAnnotation annotation : annotations) {
      annotation.accept(annotationGenerator);
      builder.append(' ');
    }
  }

  for (String modifierType : modifiers) {
    if (modifierList.hasModifierProperty(modifierType)) {
      builder.append(modifierType);
      builder.append(' ');
      wasAddedModifiers = true;
    }
  }



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


示例12: writeClassModifiers

import com.intellij.psi.PsiModifierList; //导入依赖的package包/类
public static void writeClassModifiers(StringBuilder text,
                                       @Nullable PsiModifierList modifierList,
                                       boolean isInterface,
                                       boolean isEnum,
                                       boolean toplevel,
                                       boolean generateAnnotations) {
  if (modifierList == null) {
    text.append("public ");
    return;
  }

  List<String> allowedModifiers = new ArrayList<String>();
  allowedModifiers.add(PsiModifier.PUBLIC);
  if (!isEnum) allowedModifiers.add(PsiModifier.FINAL);
  if (!toplevel) {
    allowedModifiers.addAll(Arrays.asList(PsiModifier.PROTECTED, PsiModifier.PRIVATE, PsiModifier.STATIC));
  }
  if (!isInterface && !isEnum) {
    allowedModifiers.add(PsiModifier.ABSTRACT);
  }

  writeModifiers(text, modifierList, ArrayUtil.toStringArray(allowedModifiers), generateAnnotations);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:ModifierListGenerator.java


示例13: hasParameterName

import com.intellij.psi.PsiModifierList; //导入依赖的package包/类
private boolean hasParameterName(PsiParameter psiParameter) {
  PsiModifierList modifierList = psiParameter.getModifierList();
  if (modifierList == null) {
    return false;
  }

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

  annotation = modifierList.findAnnotation(GctConstants.APP_ENGINE_ANNOTATION_NAMED);
  if (annotation != null) {
    return true;
  }

  return false;
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:19,代码来源:ApiParameterInspection.java


示例14: isPublicNullaryConstructor

import com.intellij.psi.PsiModifierList; //导入依赖的package包/类
/** Checks if the supplied method is a public constructor with no parameters. */
public static boolean isPublicNullaryConstructor(PsiMethod method) {
  if (!method.isConstructor()) {
    return false;
  }

  if (method.getParameterList().getParametersCount() > 0) {
    return false;
  }

  PsiModifierList modifierList = method.getModifierList();
  if (modifierList.hasModifierProperty(PsiModifier.PUBLIC)) {
    return true;
  }

  return false;
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:18,代码来源:EndpointUtilities.java


示例15: initializePsiMethod

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


示例16: initializePsiClass

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


示例17: invoke

import com.intellij.psi.PsiModifierList; //导入依赖的package包/类
@Override
public final void invoke(@NotNull final Project project,
                   final Editor editor,
                   final PsiFile file) throws IncorrectOperationException {
  final PsiModifierList modifierList = element.getModifierList();

  if(modifierList == null) {
    return;
  }

  for(final PsiAnnotation annotation : modifierList.getAnnotations()) {
    if(isAnnotation(annotation)) {
      annotation.delete();
    }
  }
}
 
开发者ID:defrac,项目名称:defrac-plugin-intellij,代码行数:17,代码来源:RemoveAnnotationQuickFix.java


示例18: checkApplicability

import com.intellij.psi.PsiModifierList; //导入依赖的package包/类
@Override
public boolean checkApplicability(@NotNull AnnotationHolder holder, @NotNull GrAnnotation annotation) {
  final String qname = annotation.getQualifiedName();
  if (!GroovyCommonClassNames.GROOVY_TRANSFORM_FIELD.equals(qname)) return false;

  checkScriptField(holder, annotation);

  PsiElement annoParent = annotation.getParent();
  PsiElement ownerToUse = annoParent instanceof PsiModifierList ? annoParent.getParent() : annoParent;
  if (!(ownerToUse instanceof GrVariableDeclaration) ||
      !GroovyRefactoringUtil.isLocalVariable(((GrVariableDeclaration)ownerToUse).getVariables()[0])) {
    return false;
  }

  if (!GrAnnotationImpl.isAnnotationApplicableTo(annotation, PsiAnnotation.TargetType.LOCAL_VARIABLE)) {
    GrCodeReferenceElement ref = annotation.getClassReference();
    String target = JavaErrorMessages.message("annotation.target.LOCAL_VARIABLE");
    String description = JavaErrorMessages.message("annotation.not.applicable", ref.getText(), target);
    holder.createErrorAnnotation(ref, description);
  }

  return true;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:FieldAnnotationChecker.java


示例19: visitAnnotation

import com.intellij.psi.PsiModifierList; //导入依赖的package包/类
public void visitAnnotation(GrAnnotation annotation) {
  super.visitAnnotation(annotation);

  PsiElement parent = annotation.getParent().getParent();
  if (parent == null || !(parent instanceof GrTypeDefinition)) return;

  if (SINGLETON.equals(annotation.getQualifiedName())) {
    GrTypeDefinition typeDefinition = (GrTypeDefinition)parent;

    PsiMethod[] methods = typeDefinition.getMethods();
    for (PsiMethod method : methods) {
      if (method.isConstructor()) {
        PsiModifierList modifierList = method.getModifierList();

        if (modifierList.hasModifierProperty(PsiModifier.PUBLIC)) {
          registerClassError(typeDefinition);
        }
      }
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:GroovySingletonAnnotationInspection.java


示例20: transformModifiers

import com.intellij.psi.PsiModifierList; //导入依赖的package包/类
@Override
public void transformModifiers(@NotNull PsiModifierList modifierList, @NotNull final Set<String> modifiers) {

  final PsiModifierListOwner parentElement = PsiTreeUtil.getParentOfType(modifierList, PsiModifierListOwner.class, false);
  if (null != parentElement) {

    // FINAL
    if (!PsiAnnotationSearchUtil.isAnnotatedWith(parentElement, lombok.experimental.NonFinal.class)) {
      modifiers.add(PsiModifier.FINAL);
    }

    // PRIVATE
    if (modifierList.getParent() instanceof PsiField &&
      // Visibility is only changed for package private fields
      hasPackagePrivateModifier(modifierList) &&
      // except they are annotated with @PackagePrivate
      !PsiAnnotationSearchUtil.isAnnotatedWith(parentElement, lombok.experimental.PackagePrivate.class)) {
      modifiers.add(PsiModifier.PRIVATE);

      // IDEA _right now_ checks if other modifiers are set, and ignores PACKAGE_LOCAL but may as well clean it up
      modifiers.remove(PsiModifier.PACKAGE_LOCAL);
    }
  }
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:25,代码来源:ValueModifierProcessor.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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