当前位置: 首页>>代码示例>>Java>>正文


Java PsiModifier类代码示例

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


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


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