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

Java PsiModifier类代码示例

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

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



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

示例1: visitField

import com.intellij.psi.PsiModifier; //导入依赖的package包/类
@Override
public void visitField(@NotNull PsiField field) {
  super.visitField(field);
  if (field instanceof PsiEnumConstant) {
    return;
  }
  if (!field.hasModifierProperty(PsiModifier.STATIC) || !field.hasModifierProperty(PsiModifier.FINAL)) {
    return;
  }
  final String name = field.getName();
  if (name == null) {
    return;
  }
  final PsiType type = field.getType();
  if (onlyCheckImmutables && !ClassUtils.isImmutable(type)) {
    return;
  }
  if (isValid(name)) {
    return;
  }
  registerFieldError(field, name);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ConstantNamingConventionInspectionBase.java


示例2: hasGetAndSet

import com.intellij.psi.PsiModifier; //导入依赖的package包/类
private static boolean hasGetAndSet(@NonNull String getPrefix, @NonNull String setPrefix, @NonNull PsiClass cls, @NonNull PsiField field) {
    boolean isPublic = field.hasModifierProperty(PsiModifier.PUBLIC);
    if (isPublic) return true;

    String fieldName = captureName(field.getName());
    String getMethodName = getPrefix + fieldName;
    String setMethodName = setPrefix + fieldName;
    PsiMethod[] gets = cls.findMethodsByName(getMethodName, true);
    PsiMethod[] sets = cls.findMethodsByName(setMethodName, true);

    boolean hasGet = gets.length > 0;
    boolean hasSet = sets.length > 0;

    return hasGet && hasSet;

}
 
开发者ID:jessie345,项目名称:CustomLintRules,代码行数:17,代码来源:Utils.java


示例3: getAllModifierProperties

import com.intellij.psi.PsiModifier; //导入依赖的package包/类
public String getAllModifierProperties( LightModifierList modifierList )
{
  final StringBuilder builder = StringBuilderSpinAllocator.alloc();
  try
  {
    for( String modifier : modifierList.getModifiers() )
    {
      if( !PsiModifier.PACKAGE_LOCAL.equals( modifier ) )
      {
        builder.append( modifier ).append( ' ' );
      }
    }
    return builder.toString();
  }
  finally
  {
    StringBuilderSpinAllocator.dispose( builder );
  }
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:20,代码来源:ManLightMethodBuilderImpl.java


示例4: isGroovyStaticMemberStub

import com.intellij.psi.PsiModifier; //导入依赖的package包/类
public static boolean isGroovyStaticMemberStub(StubElement<?> stub) {
  StubElement<?> modifierOwner = stub instanceof GrMethodStub ? stub : stub.getParentStub();
  StubElement<GrModifierList> type = modifierOwner.findChildStubByType(GroovyElementTypes.MODIFIERS);
  if (!(type instanceof GrModifierListStub)) {
    return false;
  }
  int mask = ((GrModifierListStub)type).getModifiersFlags();
  if (GrModifierListImpl.hasMaskExplicitModifier(PsiModifier.PRIVATE, mask)) {
    return false;
  }
  if (GrModifierListImpl.hasMaskExplicitModifier(PsiModifier.STATIC, mask)) {
    return true;
  }

  StubElement parent = modifierOwner.getParentStub();
  StubElement classStub = parent == null ? null : parent.getParentStub();
  if (classStub instanceof GrTypeDefinitionStub &&
      (((GrTypeDefinitionStub)classStub).isAnnotationType() || ((GrTypeDefinitionStub)classStub).isInterface())) {
    return true;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:GrStubUtils.java


示例5: visitClass

import com.intellij.psi.PsiModifier; //导入依赖的package包/类
@Override
public void visitClass(@NotNull PsiClass aClass) {
  if (aClass.hasModifierProperty(PsiModifier.PUBLIC) ||
      aClass.hasModifierProperty(PsiModifier.PROTECTED) ||
      aClass.hasModifierProperty(PsiModifier.PRIVATE)) {
    return;
  }
  if (!ClassUtils.isInnerClass(aClass)) {
    return;
  }
  if (ignoreEnums && aClass.isEnum()) {
    return;
  }
  if (ignoreInterfaces && aClass.isInterface()) {
    return;
  }
  final PsiElement parent = aClass.getParent();
  // parent must be class to not warn on
  // the type parameters of classes, anonymous classes and
  // enum constants for example.
  if (!(parent instanceof PsiClass)) {
    return;
  }
  registerClassError(aClass);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:PackageVisibleInnerClassInspectionBase.java


示例6: visitAnnotation

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


示例7: visitField

import com.intellij.psi.PsiModifier; //导入依赖的package包/类
@Override
public void visitField(PsiField field) {
  super.visitField(field);
  if (field.hasModifierProperty(PsiModifier.FINAL)) {
    return;
  }
  final PsiClass containingClass = field.getContainingClass();
  if (containingClass == null) {
    return;
  }
  if (!InheritanceUtil.isInheritor(containingClass,
                                   CommonClassNames.JAVA_LANG_EXCEPTION)) {
    return;
  }
  registerFieldError(field, field);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:NonFinalFieldOfExceptionInspection.java


示例8: methodCallExpressionDefinitelyRecurses

import com.intellij.psi.PsiModifier; //导入依赖的package包/类
private static boolean methodCallExpressionDefinitelyRecurses(
    GrMethodCallExpression exp, GrMethod method) {
  final GrExpression invoked = exp.getInvokedExpression();
  if (invoked instanceof GrReferenceExpression) {
    final GrReferenceExpression methodExpression = (GrReferenceExpression) invoked;
    final PsiMethod referencedMethod = exp.resolveMethod();
    if (referencedMethod == null) {
      return false;
    }
    final GrExpression qualifier =
        methodExpression.getQualifierExpression();
    if (referencedMethod.equals(method)) {
      if (method.hasModifierProperty(PsiModifier.STATIC) ||
          method.hasModifierProperty(PsiModifier.PRIVATE)) {
        return true;
      }
      if (qualifier == null || qualifier instanceof GrReferenceExpression && PsiUtil.isThisReference(qualifier)) {
        return true;
      }
    }
    if (expressionDefinitelyRecurses(qualifier, method)) {
      return true;
    }
  }
  return callExpressionDefinitelyRecurses(exp, method);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:RecursionUtils.java


示例9: createFindWhatPanel

import com.intellij.psi.PsiModifier; //导入依赖的package包/类
@Override
protected JPanel createFindWhatPanel() {
  JPanel findWhatPanel = new JPanel();

  findWhatPanel.setBorder(IdeBorderFactory.createTitledBorder(FindBundle.message("find.what.group"), true));
  findWhatPanel.setLayout(new BoxLayout(findWhatPanel, BoxLayout.Y_AXIS));

  myCbUsages = addCheckboxToPanel(FindBundle.message("find.what.usages.checkbox"), getFindUsagesOptions().isUsages, findWhatPanel, true);

  PsiClass psiClass = (PsiClass)getPsiElement();
  myCbMethodsUsages = addCheckboxToPanel(FindBundle.message("find.what.methods.usages.checkbox"), getFindUsagesOptions().isMethodsUsages, findWhatPanel, true);

  if (!psiClass.isAnnotationType()) {
    myCbFieldsUsages = addCheckboxToPanel(FindBundle.message("find.what.fields.usages.checkbox"), getFindUsagesOptions().isFieldsUsages, findWhatPanel, true);
    if (psiClass.isInterface()){
      myCbImplementingClasses = addCheckboxToPanel(FindBundle.message("find.what.implementing.classes.checkbox"), getFindUsagesOptions().isImplementingClasses, findWhatPanel, true);
      myCbDerivedInterfaces = addCheckboxToPanel(FindBundle.message("find.what.derived.interfaces.checkbox"), getFindUsagesOptions().isDerivedInterfaces, findWhatPanel, true);
    }
    else if (!psiClass.hasModifierProperty(PsiModifier.FINAL)){
      myCbDerivedClasses = addCheckboxToPanel(FindBundle.message("find.what.derived.classes.checkbox"), getFindUsagesOptions().isDerivedClasses, findWhatPanel, true);
    }
  }
  return findWhatPanel;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:FindClassUsagesDialog.java


示例10: checkSuperMethod

import com.intellij.psi.PsiModifier; //导入依赖的package包/类
public static PsiMethod checkSuperMethod(@NotNull PsiMethod method, @NotNull String actionString) {
  PsiClass aClass = method.getContainingClass();
  if (aClass == null) return method;

  PsiMethod superMethod = method.findDeepestSuperMethod();
  if (superMethod == null) return method;

  if (ApplicationManager.getApplication().isUnitTestMode()) return superMethod;

  PsiClass containingClass = superMethod.getContainingClass();

  SuperMethodWarningDialog dialog =
      new SuperMethodWarningDialog(
          method.getProject(),
          DescriptiveNameUtil.getDescriptiveName(method), actionString, containingClass.isInterface() || superMethod.hasModifierProperty(PsiModifier.ABSTRACT),
          containingClass.isInterface(), aClass.isInterface(), containingClass.getQualifiedName()
      );
  dialog.show();

  if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) return superMethod;
  if (dialog.getExitCode() == SuperMethodWarningDialog.NO_EXIT_CODE) return method;

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


示例11: visitField

import com.intellij.psi.PsiModifier; //导入依赖的package包/类
@Override
public void visitField(@NotNull PsiField field) {
  super.visitField(field);
  if (!field.hasModifierProperty(PsiModifier.STATIC)) {
    return;
  }
  final PsiTypeElement typeElement = field.getTypeElement();
  if (typeElement == null) {
    return;
  }
  if (!ConcreteClassUtil.typeIsConcreteClass(typeElement,
                                             ignoreAbstractClasses)) {
    return;
  }
  final String variableName = field.getName();
  registerError(typeElement, variableName);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:StaticVariableOfConcreteClassInspection.java


示例12: getPsi

import com.intellij.psi.PsiModifier; //导入依赖的package包/类
@Override
@NotNull
public PsiVariable getPsi(PsiManager manager, final String containingClassName) {
  if (myPsi != null) return myPsi;

  Boolean isStatic = isStatic();

  String type = getType();
  if (type == null || type.trim().isEmpty()) {
    type = CommonClassNames.JAVA_LANG_OBJECT;
  }
  myPsi = new GrDynamicImplicitProperty(manager, getName(), type, containingClassName);

  if (isStatic != null && isStatic.booleanValue()) {
    myPsi.getModifierList().addModifier(PsiModifier.STATIC);
  }

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


示例13: visitField

import com.intellij.psi.PsiModifier; //导入依赖的package包/类
@Override
public void visitField(@NotNull PsiField field) {
  super.visitField(field);
  if (field.hasModifierProperty(PsiModifier.STATIC) &&
      field.hasModifierProperty(PsiModifier.FINAL)) {
    return;
  }
  final String fieldName = field.getName();
  if (fieldName == null) {
    return;
  }
  if (!fieldName.equals(fieldName.toUpperCase())) {
    return;
  }
  registerFieldError(field);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:UpperCaseFieldNameNotConstantInspectionBase.java


示例14: testPublicVisibility

import com.intellij.psi.PsiModifier; //导入依赖的package包/类
public void testPublicVisibility() throws Exception {
  doTest((rootDir, rootAfter) -> {
    PsiClass aClass = myJavaFacade.findClass("Test", GlobalSearchScope.projectScope(myProject));

    assertNotNull("Class Test not found", aClass);

    final ArrayList<PsiMethod> methods = new ArrayList<>();
    methods.add(aClass.findMethodsByName("foos", false)[0]);

    final ArrayList<PsiField> fields = new ArrayList<>();
    fields.add(aClass.findFieldByName("myT", false));

    final ExtractClassProcessor processor =
      new ExtractClassProcessor(aClass, fields, methods, new ArrayList<>(), "", null, "Extracted", PsiModifier.PUBLIC, false, Collections.<MemberInfo>emptyList());
    processor.run();
    LocalFileSystem.getInstance().refresh(false);
    FileDocumentManager.getInstance().saveAllDocuments();
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ExtractClassTest.java


示例15: visitMethod

import com.intellij.psi.PsiModifier; //导入依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
  super.visitMethod(method);
  if (method.isConstructor()) {
    return;
  }
  if (!method.hasModifierProperty(PsiModifier.NATIVE)) {
    return;
  }
  final PsiIdentifier nameIdentifier = method.getNameIdentifier();
  if (nameIdentifier == null) {
    return;
  }
  final String name = method.getName();
  if (isValid(name)) {
    return;
  }
  if (!isOnTheFly() && MethodUtils.hasSuper(method)) {
    return;
  }
  if (LibraryUtil.isOverrideOfLibraryMethod(method)) {
    return;
  }
  registerMethodError(method, name);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:NativeMethodNamingConventionInspectionBase.java


示例16: visitMethod

import com.intellij.psi.PsiModifier; //导入依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
  //no call to super, so we don't drill into anonymous classes
  if (method.isConstructor()) {
    return;
  }
  if (method.hasModifierProperty(PsiModifier.SYNCHRONIZED)) {
    return;
  }
  if (method.getNameIdentifier() == null) {
    return;
  }
  final PsiMethod[] superMethods = method.findSuperMethods();
  for (final PsiMethod superMethod : superMethods) {
    if (superMethod.hasModifierProperty(PsiModifier.SYNCHRONIZED)) {
      registerMethodError(method);
      return;
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:NonSynchronizedMethodOverridesSynchronizedMethodVisitor.java


示例17: showDialog

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


示例18: visitMethod

import com.intellij.psi.PsiModifier; //导入依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
  //note: no call to super;
  if (!CloneUtils.isClone(method)) {
    return;
  }
  if (method.hasModifierProperty(PsiModifier.ABSTRACT) ||
      method.hasModifierProperty(PsiModifier.NATIVE)) {
    return;
  }
  final PsiClass containingClass = method.getContainingClass();
  if (containingClass == null) {
    return;
  }
  if (containingClass.isInterface() ||
      containingClass.isAnnotationType()) {
    return;
  }
  if (CloneUtils.onlyThrowsException(method)) {
    return;
  }
  if (MethodCallUtils.containsSuperMethodCall(HardcodedMethodConstants.CLONE, method)) {
    return;
  }
  registerMethodError(method);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:CloneCallsSuperCloneInspection.java


示例19: buildFix

import com.intellij.psi.PsiModifier; //导入依赖的package包/类
@Override
protected InspectionGadgetsFix buildFix(Object... infos) {
  return new InspectionGadgetsFix() {
    @Override
    public void doFix(Project project, ProblemDescriptor descriptor) {
      final PsiMethod element = PsiTreeUtil.getParentOfType(descriptor.getPsiElement(), PsiMethod.class);
      if (element != null) {
        new MakeMethodStaticProcessor(project, element, new Settings(m_replaceQualifier, null, null)).run();
      }
    }

    @Override
    @NotNull
    public String getName() {
      return InspectionGadgetsBundle.message("change.modifier.quickfix", PsiModifier.STATIC);
    }

    @NotNull
    @Override
    public String getFamilyName() {
      return ChangeModifierFix.FAMILY_NAME;
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:MethodMayBeStaticInspection.java


示例20: visitMethod

import com.intellij.psi.PsiModifier; //导入依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
  // no call to super, so it doesn't drill down
  final PsiClass aClass = method.getContainingClass();
  if (aClass == null) {
    return;
  }
  if (aClass.isInterface() || aClass.isAnnotationType()) {
    return;
  }
  if (method.hasModifierProperty(PsiModifier.PRIVATE)) {
    return;
  }
  if (!SerializationUtils.isReadObject(method) &&
      !SerializationUtils.isWriteObject(method)) {
    return;
  }
  if (!SerializationUtils.isSerializable(aClass)) {
    return;
  }
  registerMethodError(method);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ReadObjectAndWriteObjectPrivateInspection.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java ByteArrayPool类代码示例发布时间:2022-05-21
下一篇:
Java Preference类代码示例发布时间: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