@Override
 public void serialize(@NotNull final GrFileStub stub, @NotNull final StubOutputStream dataStream)
     throws IOException {
   dataStream.writeName(stub.getName().toString());
   dataStream.writeBoolean(stub.isScript());
   GrStubUtils.writeStringArray(dataStream, stub.getAnnotations());
 }
 @NotNull
 @Override
 public GrFileStub deserialize(
     @NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException {
   StringRef name = dataStream.readName();
   boolean isScript = dataStream.readBoolean();
   return new GrFileStub(name, isScript, GrStubUtils.readStringArray(dataStream));
 }
 @NotNull
 @Override
 public GrReferenceListStub createStub(@NotNull T psi, StubElement parentStub) {
   List<String> refNames = new ArrayList<>();
   for (GrCodeReferenceElement element : psi.getReferenceElementsGroovy()) {
     final String name = GrStubUtils.getReferenceName(element);
     if (StringUtil.isNotEmpty(name)) {
       refNames.add(name);
     }
   }
   return new GrReferenceListStub(parentStub, this, ArrayUtil.toStringArray(refNames));
 }
  @Override
  public void indexStub(@NotNull GrFileStub stub, @NotNull IndexSink sink) {
    String name = stub.getName().toString();
    if (stub.isScript() && name != null) {
      sink.occurrence(GrScriptClassNameIndex.KEY, name);
      final String pName = GrStubUtils.getPackageName(stub);
      final String fqn = StringUtil.isEmpty(pName) ? name : pName + "." + name;
      sink.occurrence(GrFullScriptNameIndex.KEY, fqn.hashCode());
    }

    for (String anno : stub.getAnnotations()) {
      sink.occurrence(GrAnnotatedMemberIndex.KEY, anno);
    }

    Integer fileId = stub.getUserData(IndexingDataKeys.VIRTUAL_FILE_ID);
    if (fileId == null) return;
    IndexTree.Unit unit = GrStubIndexer.translate(fileId, stub);
    sink.occurrence(JavaStubIndexKeys.UNITS, unit);
  }
 @Override
 @NotNull
 public GrReferenceListStub deserialize(
     @NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
   return new GrReferenceListStub(parentStub, this, GrStubUtils.readStringArray(dataStream));
 }
 @Override
 public void serialize(@NotNull GrReferenceListStub stub, @NotNull StubOutputStream dataStream)
     throws IOException {
   GrStubUtils.writeStringArray(dataStream, stub.getBaseClasses());
 }