Java 类com.intellij.psi.impl.source.PsiExtensibleClass 实例源码

项目:manifold-ij    文件:ExtensionClassAnnotator.java   
private void verifyExtensionInterfaces( PsiElement element, AnnotationHolder holder )
{
  if( element instanceof PsiJavaCodeReferenceElementImpl &&
      ((PsiJavaCodeReferenceElementImpl)element).getTreeParent() instanceof ReferenceListElement &&
      ((PsiJavaCodeReferenceElementImpl)element).getTreeParent().getText().startsWith( PsiKeyword.IMPLEMENTS ) )
  {
    final PsiElement resolve = element.getReference().resolve();
    if( resolve instanceof PsiExtensibleClass )
    {
      PsiExtensibleClass iface = (PsiExtensibleClass)resolve;
      if( !isStructuralInterface( iface ) )
      {
        TextRange range = new TextRange( element.getTextRange().getStartOffset(),
                                         element.getTextRange().getEndOffset() );
        holder.createErrorAnnotation( range, ExtIssueMsg.MSG_ONLY_STRUCTURAL_INTERFACE_ALLOWED_HERE.get( iface.getName() ) );
      }
    }
  }
}
项目:intellij-ce-playground    文件:PsiMethodWithOverridingPercentMember.java   
private static int searchForOverridingCount(final PsiMethod method, final Collection<PsiClass> containingClassInheritors) {
  int counter = 0;
  for (final PsiClass inheritor : containingClassInheritors) {
    if (inheritor instanceof PsiExtensibleClass) {
      final List<PsiMethod> ownMethods = ((PsiExtensibleClass)inheritor).getOwnMethods();
      for (PsiMethod ownMethod : ownMethods) {
        if (maybeSuper(method, ownMethod)) {
          counter++;
          break;
        }
      }

    }
  }
  return counter;
}
项目:tools-idea    文件:PsiMethodWithOverridingPercentMember.java   
private static int searchForOverridingCount(final PsiMethod method, final Collection<PsiClass> containingClassInheritors) {
  int counter = 0;
  for (final PsiClass inheritor : containingClassInheritors) {
    if (inheritor instanceof PsiExtensibleClass) {
      final List<PsiMethod> ownMethods = ((PsiExtensibleClass)inheritor).getOwnMethods();
      for (PsiMethod ownMethod : ownMethods) {
        if (maybeSuper(method, ownMethod)) {
          counter++;
          break;
        }
      }

    }
  }
  return counter;
}
项目:consulo-java    文件:PsiMethodWithOverridingPercentMember.java   
private static int searchForOverridingCount(final PsiMethod method, final Collection<PsiClass> containingClassInheritors)
{
    int counter = 0;
    for(final PsiClass inheritor : containingClassInheritors)
    {
        if(inheritor instanceof PsiExtensibleClass)
        {
            final List<PsiMethod> ownMethods = ((PsiExtensibleClass) inheritor).getOwnMethods();
            for(PsiMethod ownMethod : ownMethods)
            {
                if(maybeSuper(method, ownMethod))
                {
                    counter++;
                    break;
                }
            }

        }
    }
    return counter;
}
项目:intellij-ce-playground    文件:AndroidPsiAugmentProvider.java   
@NotNull
private static Set<String> getOwnInnerClasses(@NotNull PsiExtensibleClass aClass) {
  final Set<String> result = new HashSet<String>();

  for (PsiClass innerClass : aClass.getOwnInnerClasses()) {
    result.add(innerClass.getName());
  }
  return result;
}
项目:intellij-ce-playground    文件:AndroidPsiAugmentProvider.java   
@NotNull
private static Set<String> getOwnFields(@NotNull PsiExtensibleClass aClass) {
  final Set<String> result = new HashSet<String>();

  for (PsiField field : aClass.getOwnFields()) {
    result.add(field.getName());
  }
  return result;
}
项目:sqlitemagic    文件:PsiClassUtil.java   
/**
 * Workaround to get all of original Methods of the psiClass, without calling PsiAugmentProvider infinitely
 *
 * @param psiClass psiClass to collect all of methods from
 * @return all intern methods of the class
 */
@NotNull
public static Collection<PsiMethod> collectClassMethodsIntern(@NotNull PsiClass psiClass) {
  if (psiClass instanceof PsiExtensibleClass) {
    return ((PsiExtensibleClass) psiClass).getOwnMethods();
  } else {
    return Collections2.transform(
        Collections2.filter(Lists.newArrayList(psiClass.getChildren()), Predicates.instanceOf(PsiMethod.class)),
        PSI_ELEMENT_TO_METHOD_FUNCTION);
  }
}
项目:sqlitemagic    文件:PsiClassUtil.java   
/**
 * Workaround to get all of original Fields of the psiClass, without calling PsiAugmentProvider infinitely
 *
 * @param psiClass psiClass to collect all of fields from
 * @return all intern fields of the class
 */
@NotNull
public static Collection<PsiField> collectClassFieldsIntern(@NotNull PsiClass psiClass) {
  if (psiClass instanceof PsiExtensibleClass) {
    return ((PsiExtensibleClass) psiClass).getOwnFields();
  } else {
    return Collections2.transform(
        Collections2.filter(Lists.newArrayList(psiClass.getChildren()), Predicates.instanceOf(PsiField.class)),
        PSI_ELEMENT_TO_FIELD_FUNCTION);
  }
}
项目:sqlitemagic    文件:PsiClassUtil.java   
/**
 * Workaround to get all of original inner classes of the psiClass, without calling PsiAugmentProvider infinitely
 *
 * @param psiClass psiClass to collect all inner classes from
 * @return all inner classes of the class
 */
@NotNull
public static Collection<PsiClass> collectInnerClassesIntern(@NotNull PsiClass psiClass) {
  if (psiClass instanceof PsiExtensibleClass) {
    return ((PsiExtensibleClass) psiClass).getOwnInnerClasses();
  } else {
    return Collections2.transform(
        Collections2.filter(Lists.newArrayList(psiClass.getChildren()), Predicates.instanceOf(PsiClass.class)),
        PSI_ELEMENT_TO_CLASS_FUNCTION);
  }
}
项目:holdr    文件:HoldrPsiAugmentProvider.java   
@NotNull
private static Set<String> getOwnFields(@NotNull PsiExtensibleClass holdrClass) {
    final Set<String> result = new HashSet<String>();

    for (PsiField field : holdrClass.getOwnFields()) {
        result.add(field.getName());
    }
    return result;
}
项目:holdr    文件:HoldrPsiAugmentProvider.java   
private static boolean hasOwnListenerMethod(@NotNull PsiExtensibleClass holdrClass) {
    for (PsiMethod method : holdrClass.getOwnMethods()) {
        if (method.getName().equals("setListener")) {
            return true;
        }
    }
    return false;
}
项目:holdr    文件:HoldrPsiAugmentProvider.java   
@NotNull
private static Set<String> getOwnListenerMethods(@NotNull PsiExtensibleClass listenerClass) {
    final Set<String> result = new HashSet<String>();
    for (PsiMethod method : listenerClass.getOwnMethods()) {
        result.add(method.getName());
    }
    return result;
}
项目:lombok-intellij-plugin    文件:LombokAugmentProvider.java   
@NotNull
@Override
public <Psi extends PsiElement> List<Psi> getAugments(@NotNull PsiElement element, @NotNull final Class<Psi> type) {
  final List<Psi> emptyResult = Collections.emptyList();
  // skip processing during index rebuild
  final Project project = element.getProject();
  if (DumbService.isDumb(project)) {
    return emptyResult;
  }
  // Expecting that we are only augmenting an PsiClass
  // Don't filter !isPhysical elements or code auto completion will not work
  if (!(element instanceof PsiExtensibleClass) || !element.isValid()) {
    return emptyResult;
  }
  // Skip processing of Annotations and Interfaces
  if (((PsiClass) element).isAnnotationType() || ((PsiClass) element).isInterface()) {
    return emptyResult;
  }

  // skip processing if plugin is disabled
  if (!ProjectSettings.isLombokEnabledInProject(project)) {
    return emptyResult;
  }

  final PsiClass psiClass = (PsiClass) element;

  if (type == PsiField.class) {
    return CachedValuesManager.getCachedValue(element, new FieldLombokCachedValueProvider<Psi>(type, psiClass));
  } else if (type == PsiMethod.class) {
    return CachedValuesManager.getCachedValue(element, new MethodLombokCachedValueProvider<Psi>(type, psiClass));
  } else if (type == PsiClass.class) {
    return CachedValuesManager.getCachedValue(element, new ClassLombokCachedValueProvider<Psi>(type, psiClass));
  } else {
    return emptyResult;
  }
}
项目:lombok-intellij-plugin    文件:PsiClassUtil.java   
/**
 * Workaround to get all of original Methods of the psiClass, without calling PsiAugmentProvider infinitely
 *
 * @param psiClass psiClass to collect all of methods from
 * @return all intern methods of the class
 */
@NotNull
public static Collection<PsiMethod> collectClassMethodsIntern(@NotNull PsiClass psiClass) {
  if (psiClass instanceof PsiExtensibleClass) {
    return new ArrayList<PsiMethod>(((PsiExtensibleClass) psiClass).getOwnMethods());
  } else {
    return filterPsiElements(psiClass, PsiMethod.class);
  }
}
项目:lombok-intellij-plugin    文件:PsiClassUtil.java   
/**
 * Workaround to get all of original Fields of the psiClass, without calling PsiAugmentProvider infinitely
 *
 * @param psiClass psiClass to collect all of fields from
 * @return all intern fields of the class
 */
@NotNull
public static Collection<PsiField> collectClassFieldsIntern(@NotNull PsiClass psiClass) {
  if (psiClass instanceof PsiExtensibleClass) {
    return ((PsiExtensibleClass) psiClass).getOwnFields();
  } else {
    return filterPsiElements(psiClass, PsiField.class);
  }
}
项目:lombok-intellij-plugin    文件:PsiClassUtil.java   
/**
 * Workaround to get all of original inner classes of the psiClass, without calling PsiAugmentProvider infinitely
 *
 * @param psiClass psiClass to collect all inner classes from
 * @return all inner classes of the class
 */
@NotNull
public static Collection<PsiClass> collectInnerClassesIntern(@NotNull PsiClass psiClass) {
  if (psiClass instanceof PsiExtensibleClass) {
    return ((PsiExtensibleClass) psiClass).getOwnInnerClasses();
  } else {
    return filterPsiElements(psiClass, PsiClass.class);
  }
}
项目:consulo-java    文件:ClsClassImpl.java   
@Override
public void setMirror(@NotNull TreeElement element) throws InvalidMirrorException
{
    setMirrorCheckingType(element, null);

    PsiClass mirror = SourceTreeToPsiMap.treeToPsiNotNull(element);

    setMirrorIfPresent(getDocComment(), mirror.getDocComment());

    setMirror(getModifierList(), mirror.getModifierList());
    setMirror(getNameIdentifier(), mirror.getNameIdentifier());
    setMirror(getTypeParameterList(), mirror.getTypeParameterList());
    setMirror(getExtendsList(), mirror.getExtendsList());
    setMirror(getImplementsList(), mirror.getImplementsList());

    if(mirror instanceof PsiExtensibleClass)
    {
        PsiExtensibleClass extMirror = (PsiExtensibleClass) mirror;
        setMirrors(getOwnFields(), extMirror.getOwnFields());
        setMirrors(getOwnMethods(), extMirror.getOwnMethods());
        setMirrors(getOwnInnerClasses(), extMirror.getOwnInnerClasses());
    }
    else
    {
        setMirrors(getOwnFields(), asList(mirror.getFields()));
        setMirrors(getOwnMethods(), asList(mirror.getMethods()));
        setMirrors(getOwnInnerClasses(), asList(mirror.getInnerClasses()));
    }
}
项目:sqlitemagic    文件:SqliteMagicAugmentProvider.java   
@NotNull
@Override
public <Psi extends PsiElement> List<Psi> getAugments(@NotNull PsiElement element, @NotNull Class<Psi> type) {
  final List<Psi> emptyResult = Collections.emptyList();
  // skip processing during index rebuild
  final Project project = element.getProject();
  if (DumbService.isDumb(project)) {
    return emptyResult;
  }
  // Expecting that we are only augmenting an PsiClass
  // Don't filter !isPhysical elements or code auto completion will not work
  if (!(element instanceof PsiExtensibleClass) || !element.isValid()) {
    return emptyResult;
  }
  // skip processing for other as supported types
  if (type != PsiMethod.class && type != PsiField.class && type != PsiClass.class) {
    return emptyResult;
  }

  final PsiFile containingFile = element.getContainingFile();
  if (containingFile == null) {
    return emptyResult;
  }

  initRegisteredAnnotations();

  final PsiClass psiClass = (PsiClass) element;

  boolean fileOpenInEditor = true;

  final VirtualFile virtualFile = containingFile.getVirtualFile();
  if (null != virtualFile) {
    fileOpenInEditor = FileEditorManager.getInstance(project).isFileOpen(virtualFile);
  }

  if (fileOpenInEditor || checkSqliteMagicPresent(psiClass)) {
    return process(type, project, psiClass);
  }

  return emptyResult;
}
项目:holdr    文件:HoldrPsiAugmentProvider.java   
private static boolean hasOwnListenerClass(@NotNull PsiExtensibleClass holdrClass) {
    return !holdrClass.getOwnInnerClasses().isEmpty();
}