Project

General

Profile

uast-hints-unit-test-type.diff

Vladimir Tsichevski, 09/23/2022 08:54 AM

Download (5.18 KB)

View differences:

src/com/goldencode/p2j/uast/HintsConstants.java 2022-09-22 18:07:41 +0000
140 140
   /** Root element tag name of schema sub-hierarchy */
141 141
   public static final String ELEM_SCHEMA = "schema";
142 142
   
143
   /** Element tag name of unit test type */
144
   public static final String ELEM_UNITTESTTYPE = "legacy-unit-test";
145
   
143 146
   /** Table element tag name */
144 147
   public static final String ELEM_TABLE = "table";
145 148
   
src/com/goldencode/p2j/uast/UastHints.java 2022-09-22 21:50:17 +0000
457 457
   
458 458
   /** Best efforts attempt to detect the JVM word/pointer size, may be different from the system value. */
459 459
   private static final int DEFAULT_ARCH;
460

  
461
   /** Unit test legacy type key */
462
   private static final String UNITTESTTYPE = "legacy-unit-test";
460 463
   
461 464
   /** The list of databases that must be connected before parsing. */ 
462 465
   private Set<String> databases = null;
......
554 557
   /** The source charset. */
555 558
   private Charset sourceCharset = Charset.forName(Configuration.getParameter(SOURCE_CHARSET));
556 559

  
560
   /** Unit test legacy type: valid values are "OEUnit" and "ABLUnit", no default */
561
   private String unitTestType;
562
   
557 563
   /** 
558 564
    * Get a UastHints instance for the file. 
559 565
    * @param sourceName 
......
674 680
   }
675 681
   
676 682
   /**
683
    * Provides a standard way to get the default value for the unit test
684
    * legacy type: valid values are "OEUnit" and "ABLUnit", no default.
685
    * 
686
    * @return   The default unit test legacy type, may be {@code null}
687
    */
688
   public static String defaultUnitTestType()
689
   {
690
      return Configuration.getParameter(UNITTESTTYPE);
691
   }
692
   
693
   /**
677 694
    * Get a list of all database names that must be connected before the ProgressParser can execute.
678 695
    *
679 696
    * @return  Array of database names or {@code null} if only the default databases are required.
......
868 885
   }
869 886
   
870 887
   /**
888
    * Get unit test legacy type. Valid values are "OEUnit" and "ABLUnit", no default.
889
    * 
890
    * @return see above
891
    */
892
   public String getUnitTestType()
893
   {
894
      return unitTestType;
895
   }
896

  
897
   /**
871 898
    * Get an unmodifiable map of schema table hints, keyed by table name.
872 899
    *
873 900
    * @return  The map of table hints, or <code>null</code> if none have
......
1158 1185
    *
1159 1186
    * @return   The containing directory or "." on failure.
1160 1187
    */
1161
   private String containingDirectory(File file)
1188
   private static String containingDirectory(File file)
1162 1189
   {
1163 1190
      String result = ".";
1164 1191
      
......
1703 1730
         Document  dom  = XmlHelper.parse(hintsFile);
1704 1731
         Element   root = dom.getDocumentElement();
1705 1732
         
1733
         readUnitTestType(root);
1706 1734
         readDatabases(root);
1707 1735
         readAliases(root);
1708 1736
         readVariables(root);
......
1721 1749
   }
1722 1750
   
1723 1751
   /**
1752
    * Unit test type from XML hints file
1753
    *
1754
    * @param    root
1755
    *           The root element of the XML document.
1756
     */
1757
   private void readUnitTestType(Element root)
1758
   throws Exception
1759
   {
1760
      final NodeList ppNodes = root.getElementsByTagName(ELEM_UNITTESTTYPE);
1761

  
1762
      switch (ppNodes.getLength())
1763
      {
1764
         case 1:
1765
         {
1766
            final String attVal = ((Element) ppNodes.item(0)).getAttribute("type");
1767
            switch(attVal)
1768
            {
1769
               case "OEUnit":
1770
               case "ABLUnit":
1771
                  unitTestType = attVal;
1772
                  return;
1773
               default:
1774
                  throw new AstException("Invalid value for " + ELEM_UNITTESTTYPE
1775
                           + ": only \"OEUnit\" and \"ABLUnit\" allowed.");
1776
            }
1777
         }
1778
         case 0:
1779
            return;
1780
            
1781
         default:
1782
            throw new AstException("More than one element " + ELEM_UNITTESTTYPE);
1783
      }
1784
   }
1785

  
1786
   /**
1724 1787
    * Initialize the base path and source path for this file.
1725 1788
    *
1726 1789
    * @param    hints
......
1782 1845
      // we return an iterator that walks backward
1783 1846
      return list.descendingIterator();
1784 1847
   }
1848

  
1785 1849
}
src/com/goldencode/p2j/uast/UastHintsWorker.java 2022-09-22 21:20:03 +0000
141 141
    *          The root node of the source AST about to be processed by the
142 142
    *          pattern engine.
143 143
    */
144
   @Override
144 145
   public void visitAst(Aast ast)
145 146
   {
146 147
      hints = null;
......
492 493
      }
493 494
      
494 495
      /**
496
       * Get unit test legacy type. Valid values are "OEUnit" and "ABLUnit", no default.
497
       * 
498
       * @return see above
499
       */
500
      public String getUnitTestType()
501
      {
502
         if (!loadHints())
503
         {
504
            return null;
505
         }
506

  
507
         return hints.getUnitTestType();
508
      }
509
      
510
      /**
495 511
       * Checks if table is dirty-read  (that is, it needs to be tracked by the dirty share
496 512
       * manager).
497 513
       *