예제 #1
0
  /**
   * This writes out summary information about JML fields.
   *
   * @param classDoc the class whose inherited fields are to be described.
   */
  public void writeJmlInheritedMemberSummary(@NonNull ClassDoc classDoc) {
    ClassSymbol csym = Utils.findNewClassSymbol(classDoc);
    TypeSpecs tspecs = JmlSpecs.instance(Main.jmlContext).get(csym);
    DocEnv denv = ((ClassDocImpl) classDoc).docenv();
    ArrayList<FieldDoc> list = new ArrayList<FieldDoc>();
    for (JmlTypeClause tc : tspecs.decls) {
      if (tc instanceof JmlTypeClauseDecl
          && ((JmlTypeClauseDecl) tc).decl instanceof JCTree.JCVariableDecl) {
        JmlVariableDecl vdecl = ((JmlVariableDecl) ((JmlTypeClauseDecl) tc).decl);
        VarSymbol msym = vdecl.sym;
        if (!denv.shouldDocument(msym)) continue;
        if (!Utils.isInherited(msym, currentClassSym)) continue;
        FieldDoc field =
            new FieldDocImpl(
                ((ClassDocImpl) classDoc).docenv(), msym, vdecl.docComment, vdecl, null);
        list.add(field);
      }
    }

    // FIXME - major change in b144
    //        if (!list.isEmpty()) {
    //            writer.br();
    //            writer.strong("Inherited JML ghost and model fields: ");
    //            Collections.sort(list);
    //            boolean isFirst = true;
    //            for (FieldDoc field: list) {
    //                writer.printInheritedSummaryMember(this, classDoc, field, isFirst);
    //                isFirst = false;
    //            }
    //        }
  }
예제 #2
0
 /**
  * Write out a summary of JML fields for the given class
  *
  * @param classDoc the class whose JML fields are to be written
  */
 public void writeJmlFieldSummary(@NonNull ClassDoc classDoc) {
   ArrayList<FieldDoc> list = new ArrayList<FieldDoc>();
   TypeSpecs tspecs = JmlSpecs.instance(Main.jmlContext).get(currentClassSym);
   DocEnv denv = ((ClassDocImpl) classDoc).docenv();
   for (JmlTypeClause tc : tspecs.decls) {
     if (tc instanceof JmlTypeClauseDecl
         && ((JmlTypeClauseDecl) tc).decl instanceof JCTree.JCVariableDecl) {
       JmlVariableDecl vdecl = ((JmlVariableDecl) ((JmlTypeClauseDecl) tc).decl);
       VarSymbol msym = vdecl.sym;
       if (!denv.shouldDocument(msym)) continue;
       FieldDoc field = new FieldDocImpl(denv, msym, vdecl.docComment, vdecl, null);
       list.add(field);
     }
   }
   if (list.isEmpty()) return;
   Collections.sort(list);
   writeJmlFieldSummaryHeader(classDoc);
   // The following loop is copied with modifications from MemberSummaryBuilder.buildSummary ???
   // FIXME
   // FIXME - major change in b144
   //        for (int i = 0; i<list.size(); i++) {
   //            FieldDoc member = list.get(i);
   //            Tag[] firstSentenceTags = member.firstSentenceTags();
   //            writeMemberSummary(classDoc, member, firstSentenceTags,
   //                i == 0, i == list.size() - 1);
   //        }
   //        super.writeMemberSummaryFooter(classDoc);
 }
예제 #3
0
  public void writeJmlGhostModelFieldDetail(
      @NonNull ClassDoc classDoc, @NonNull JmlTokenKind token, String showString) {
    // Hard coding this
    //        <Header/>
    //        <FieldDoc>
    //            <FieldHeader/>
    //            <Signature/>
    //            <DeprecationInfo/>
    //            <FieldComments/>
    //            <TagInfo/>
    //            <FieldFooter/>
    //        </FieldDoc>
    //        <Footer/>

    DocEnv denv = ((ClassDocImpl) classDoc).docenv();

    // Find ghost fields to see if we need to do anything at all
    LinkedList<JmlVariableDecl> list = new LinkedList<JmlVariableDecl>();
    TypeSpecs tspecs =
        JmlSpecs.instance(org.jmlspecs.openjml.jmldoc.Main.jmlContext).get(currentClassSym);
    for (JmlTypeClause tc : tspecs.decls) {
      if (tc instanceof JmlTypeClauseDecl
          && ((JmlTypeClauseDecl) tc).decl instanceof JmlVariableDecl) {
        JmlVariableDecl d = (JmlVariableDecl) ((JmlTypeClauseDecl) tc).decl;
        boolean use =
            JmlAttr.instance(org.jmlspecs.openjml.jmldoc.Main.jmlContext).findMod(d.mods, token)
                != null;
        if (use && denv.shouldDocument(d.sym)) {
          list.add(d);
        }
      }
    }
    if (list.isEmpty()) return;

    // Header
    writer.printTableHeadingBackground("JML " + showString + " Field Detail");
    writer.println();

    // Field Header
    boolean isFirst = true;
    // FIXME - major change in b144
    //        for (JmlVariableDecl tc: list) {
    //            FieldDoc fd = new
    // FieldDocImpl(((ClassDocImpl)classDoc).docenv(),tc.sym,tc.docComment,tc,null);
    //            // field header
    //            writeFieldHeader(fd,isFirst); isFirst = false;
    //
    //            // signature
    //            writeSignature(fd);
    //
    //            // deprecation
    //            writeDeprecated(fd);
    //
    //            // field comments
    //            isModel = token == JmlToken.MODEL;
    //            try {
    //                //writeComments(fd);
    //                // Extract some of the contents of writeComments to avoid some
    //                // problems with the dual contexts - in particular, a field looks
    //                // like it is inherited from a class or interface
    //                writer.dd();
    //                writer.printInlineComment(fd);
    //                writeJmlSpecs(fd);
    //                writer.ddEnd();
    //            } finally {
    //                isModel = false;
    //            }
    //
    //            // tag info
    //            writeTags(fd);
    //
    //            // Field footer
    //            writeFieldFooter();
    //        }
    //
    //
    //        //Footer
    //        super.writeFooter(classDoc);

  }