Exemplo n.º 1
0
  public boolean isCompiled(StubT stub) {
    StubElement parent = stub;
    while (!(parent instanceof PsiFileStub)) {
      parent = parent.getParentStub();
    }

    return ((PsiJavaFileStub) parent).isCompiled();
  }
  protected final PsiElement getParentByStub() {
    final StubElement<?> stub = getStub();
    if (stub != null) {
      return stub.getParentStub().getPsi();
    }

    return SharedImplUtil.getParent(getNode());
  }
Exemplo n.º 3
0
 private static void recordClassOrObjectByPackage(
     StubElement<? extends JetClassOrObject> stub, IndexSink sink) {
   StubElement parentStub = stub.getParentStub();
   if (parentStub instanceof PsiJetFileStub) {
     PsiJetFileStub jetFileStub = (PsiJetFileStub) parentStub;
     String packageName = jetFileStub.getPackageName();
     if (packageName != null) {
       sink.occurrence(JetClassByPackageIndex.getInstance().getKey(), packageName);
     }
   }
 }
  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;
  }
  @Override
  @NotNull
  public PsiFile getContainingFile() {
    StubElement stub = myStub;
    if (stub != null) {
      while (!(stub instanceof PsiFileStub)) {
        stub = stub.getParentStub();
      }
      PsiFile psi = (PsiFile) stub.getPsi();
      if (psi == null) {
        throw new PsiInvalidElementAccessException(this, "no psi for file stub " + stub, null);
      }
      return psi;
    }

    PsiFile file = super.getContainingFile();
    if (file == null) {
      throw new PsiInvalidElementAccessException(this);
    }

    return file;
  }