Clover coverage report - Ant Coverage
Coverage timestamp: Tue Apr 8 2003 20:43:55 EST
file stats: LOC: 372   Methods: 27
NCLOC: 126   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
VisualBasicCompile.java 0% 0% 0% 0%
 1   
 /*
 2   
  * The Apache Software License, Version 1.1
 3   
  *
 4   
  * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
 5   
  * reserved.
 6   
  *
 7   
  * Redistribution and use in source and binary forms, with or without
 8   
  * modification, are permitted provided that the following conditions
 9   
  * are met:
 10   
  *
 11   
  * 1. Redistributions of source code must retain the above copyright
 12   
  *    notice, this list of conditions and the following disclaimer.
 13   
  *
 14   
  * 2. Redistributions in binary form must reproduce the above copyright
 15   
  *    notice, this list of conditions and the following disclaimer in
 16   
  *    the documentation and/or other materials provided with the
 17   
  *    distribution.
 18   
  *
 19   
  * 3. The end-user documentation included with the redistribution, if
 20   
  *    any, must include the following acknowlegement:
 21   
  *       "This product includes software developed by the
 22   
  *        Apache Software Foundation (http://www.apache.org/)."
 23   
  *    Alternately, this acknowlegement may appear in the software itself,
 24   
  *    if and wherever such third-party acknowlegements normally appear.
 25   
  *
 26   
  * 4. The names "Ant" and "Apache Software
 27   
  *    Foundation" must not be used to endorse or promote products derived
 28   
  *    from this software without prior written permission. For written
 29   
  *    permission, please contact apache@apache.org.
 30   
  *
 31   
  * 5. Products derived from this software may not be called "Apache"
 32   
  *    nor may "Apache" appear in their names without prior written
 33   
  *    permission of the Apache Group.
 34   
  *
 35   
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 36   
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 37   
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 38   
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 39   
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 40   
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 41   
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 42   
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 43   
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 44   
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 45   
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 46   
  * SUCH DAMAGE.
 47   
  * ====================================================================
 48   
  *
 49   
  * This software consists of voluntary contributions made by many
 50   
  * individuals on behalf of the Apache Software Foundation.  For more
 51   
  * information on the Apache Software Foundation, please see
 52   
  * <http://www.apache.org/>.
 53   
  */
 54   
 
 55   
 package org.apache.tools.ant.taskdefs.optional.dotnet;
 56   
 
 57   
 import org.apache.tools.ant.BuildException;
 58   
 
 59   
 
 60   
 /**
 61   
  * This task compiles Visual Basic.NET source into executables or modules.
 62   
  * The task will only work on win2K until other platforms support vbc.exe or
 63   
  * an equivalent. VBC.exe must be on the execute path, too.
 64   
  *
 65   
  * <p>
 66   
  * All parameters are optional: &lt;vbc/&gt; should suffice to produce a debug
 67   
  * build of all *.vb files.
 68   
  *
 69   
  * @author Brian Felder bfelder@providence.org
 70   
  * @author Steve Loughran
 71   
  * @ant.task    name="vbc" category="dotnet"
 72   
  */
 73   
 
 74   
 public class VisualBasicCompile extends DotnetCompile {
 75   
 
 76   
     /**
 77   
      * Compiler option to remove integer checks. Default: false.
 78   
      */
 79   
     private boolean removeIntChecks = false;
 80   
 
 81   
     /**
 82   
      * Require explicit declaration of variables? Default: false.
 83   
      */
 84   
     private boolean optionExplicit = false;
 85   
 
 86   
     /**
 87   
      * Enforce strict language semantics? Default: false.
 88   
      */
 89   
     private boolean optionStrict = false;
 90   
 
 91   
     /**
 92   
      * Whether to compare strings as "text" or "binary". Default: "binary".
 93   
      */
 94   
     private String optionCompare;
 95   
 
 96   
     /**
 97   
      * Root namespace for all type declarations.
 98   
      */
 99   
     private String rootNamespace;
 100   
 
 101   
     /**
 102   
      * Declare global imports fornamespaces in referenced metadata files.
 103   
      */
 104   
     private String imports;
 105   
 
 106   
     /**
 107   
      * Constructor for VisualBasicCompile.
 108   
      */
 109  0
     public VisualBasicCompile() {
 110  0
         super();
 111   
     }
 112   
 
 113   
     /**
 114   
      *  reset all contents.
 115   
      */
 116  0
     public void clear() {
 117  0
         super.clear();
 118  0
         imports = null;
 119  0
         rootNamespace = null;
 120  0
         optionCompare = null;
 121  0
         optionExplicit = false;
 122  0
         optionStrict = false;
 123  0
         removeIntChecks = false;
 124   
     }
 125   
 
 126   
     /**
 127   
      *  get the argument or null for no argument needed
 128   
      *  This is overridden from DotnetCompile.java because VBC uses
 129   
      *  "/win32resource:" rather than "/win32res:"
 130   
      *
 131   
      *@return    The Win32Res Parameter to CSC
 132   
      */
 133  0
     protected String getWin32ResParameter() {
 134  0
         if (getWin32Res() != null) {
 135  0
             return "/win32resource:" + getWin32Res().toString();
 136   
         } else {
 137  0
             return null;
 138   
         }
 139   
     }
 140   
 
 141   
     /**
 142   
      * Whether to remove integer checks. Default false.
 143   
      * @param  flag  on/off flag
 144   
      */
 145  0
     public void setRemoveIntChecks(boolean flag) {
 146  0
         removeIntChecks = flag;
 147   
     }
 148   
 
 149   
     /**
 150   
      * Get the flag for removing integer checks.
 151   
      * @return    true if flag is turned on
 152   
      */
 153  0
     public boolean getRemoveIntChecks() {
 154  0
         return removeIntChecks;
 155   
     }
 156   
 
 157   
     /**
 158   
      * Form the option string for removeIntChecks.
 159   
      * @return The parameter string.
 160   
      */
 161  0
     public String getRemoveIntChecksParameter() {
 162  0
         return "/removeintchecks" + (removeIntChecks ? "+" : "-");
 163   
     }
 164   
 
 165   
     /**
 166   
      * Whether to require explicit declaration of variables.
 167   
      * @param  flag  on/off flag
 168   
      */
 169  0
     public void setOptionExplicit(boolean flag) {
 170  0
         optionExplicit = flag;
 171   
     }
 172   
 
 173   
     /**
 174   
      * Get the flag for whether to require explicit declaration of variables.
 175   
      *@return    true if flag is turned on
 176   
      */
 177  0
     public boolean getOptionExplicit() {
 178  0
         return optionExplicit;
 179   
     }
 180   
 
 181   
     /**
 182   
      * Form the option string for optionExplicit..
 183   
      * @return The parameter string.
 184   
      */
 185  0
     public String getOptionExplicitParameter() {
 186  0
         return "/optionexplicit" + (optionExplicit ? "+" : "-");
 187   
     }
 188   
 
 189   
     /**
 190   
      * Enforce strict language semantics.
 191   
      * @param  flag  on/off flag
 192   
      */
 193  0
     public void setOptionStrict(boolean flag) {
 194  0
         optionStrict = flag;
 195   
     }
 196   
 
 197   
     /**
 198   
      * Get the flag for whether to enforce strict language semantics.
 199   
      * @return    true if flag is turned on
 200   
      */
 201  0
     public boolean getOptionStrict() {
 202  0
         return optionStrict;
 203   
     }
 204   
 
 205   
     /**
 206   
      * Forn the option string for optionStrict.
 207   
      * @return The parameter string.
 208   
      */
 209  0
     public String getOptionStrictParameter() {
 210  0
         return "/optionstrict" + (optionStrict ? "+" : "-");
 211   
     }
 212   
 
 213   
 
 214   
     /**
 215   
      * Specifies the root namespace for all type declarations.
 216   
      * @param  a root namespace.
 217   
      */
 218  0
     public void setRootNamespace(String rootNamespace) {
 219  0
         this.rootNamespace = rootNamespace;
 220   
     }
 221   
 
 222   
 
 223   
     /**
 224   
      * Get the root namespace.
 225   
      * @return  the root namespace.
 226   
      */
 227  0
     public String getRootNamespace() {
 228  0
         return this.rootNamespace;
 229   
     }
 230   
 
 231   
 
 232   
     /**
 233   
      * Form the option string for rootNamespace.
 234   
      * @return  the root namespace option string.
 235   
      */
 236  0
     protected String getRootNamespaceParameter() {
 237  0
         if (rootNamespace != null && rootNamespace.length() != 0) {
 238  0
             return "/rootnamespace:" + rootNamespace;
 239   
         } else {
 240  0
             return null;
 241   
         }
 242   
     }
 243   
 
 244   
 
 245   
     /**
 246   
      * Declare global imports for namespaces in referenced metadata files.
 247   
      * @param imports the imports string
 248   
      */
 249  0
     public void setImports(String imports) {
 250  0
         this.imports = imports;
 251   
     }
 252   
 
 253   
 
 254   
     /**
 255   
      * Get global imports for namespaces in referenced metadata files.
 256   
      * @return  the imports string.
 257   
      */
 258  0
     public String getImports() {
 259  0
         return this.imports;
 260   
     }
 261   
 
 262   
 
 263   
     /**
 264   
      * Format the option for imports.
 265   
      * @return  the formatted import option.
 266   
      */
 267  0
     protected String getImportsParameter() {
 268  0
         if (imports != null && imports.length() != 0) {
 269  0
             return "/imports:" + imports;
 270   
         } else {
 271  0
             return null;
 272   
         }
 273   
     }
 274   
 
 275   
 
 276   
     /**
 277   
      * Specify binary- or text-style string comparisons. Defaults
 278   
      * to "binary"
 279   
      * @param optionCompare the option compare style. "text" | "binary".
 280   
      */
 281  0
     public void setOptionCompare(String optionCompare) {
 282  0
         if ("text".equalsIgnoreCase(optionCompare)) {
 283  0
             this.optionCompare = "text";
 284   
         } else {
 285  0
             this.optionCompare = "binary";
 286   
         }
 287   
     }
 288   
 
 289   
 
 290   
     /**
 291   
      * "binary" or "text" for the string-comparison style.
 292   
      * @return  the option compare style.
 293   
      */
 294  0
     public String getOptionCompare() {
 295  0
         return this.optionCompare;
 296   
     }
 297   
 
 298   
     /**
 299   
      * Format the option for string comparison style.
 300   
      * @return  The formatted option.
 301   
      */
 302  0
     protected String getOptionCompareParameter() {
 303  0
         if (optionCompare != null && "text".equalsIgnoreCase(optionCompare)) {
 304  0
             return "/optioncompare:text";
 305   
         } else {
 306  0
             return "/optioncompare:binary";
 307   
         }
 308   
     }
 309   
 
 310   
     /**
 311   
      * implement VBC commands
 312   
      * @param command
 313   
      */
 314  0
     protected void addCompilerSpecificOptions(NetCommand command) {
 315  0
         command.addArgument(getRemoveIntChecksParameter());
 316  0
         command.addArgument(getImportsParameter());
 317  0
         command.addArgument(getOptionExplicitParameter());
 318  0
         command.addArgument(getOptionStrictParameter());
 319  0
         command.addArgument(getRootNamespaceParameter());
 320  0
         command.addArgument(getOptionCompareParameter());
 321   
     }
 322   
 
 323   
     /**
 324   
      * Get the delimiter that the compiler uses between references.
 325   
      * For example, c# will return ";"; VB.NET will return ","
 326   
      * @return The string delimiter for the reference string.
 327   
      */
 328  0
     public String getReferenceDelimiter() {
 329  0
         return ",";
 330   
     }
 331   
 
 332   
 
 333   
 
 334   
     /**
 335   
      * Get the extension of filenames to compile.
 336   
      * @return The string extension of files to compile.
 337   
      */
 338  0
     public String getFileExtension() {
 339  0
         return "vb";
 340   
     }
 341   
 
 342   
     /**
 343   
      * from a resource, get the resource param
 344   
      * @param resource
 345   
      * @return a string containing the resource param, or a null string
 346   
      * to conditionally exclude a resource.
 347   
      */
 348  0
     protected String createResourceParameter(DotnetResource resource) {
 349  0
         return resource.getVbStyleParameter();
 350   
     }
 351   
 
 352   
     /**
 353   
      * Get the name of the compiler executable.
 354   
      * @return The name of the compiler executable.
 355   
      */
 356  0
     public String getCompilerExeName() {
 357  0
         return "vbc";
 358   
     }
 359   
 
 360   
     /**
 361   
      * validation code
 362   
      * @throws  BuildException  if validation failed
 363   
      */
 364  0
     protected void validate()
 365   
             throws BuildException {
 366  0
         super.validate();
 367  0
         if(getDestFile()==null) {
 368  0
             throw new BuildException("DestFile was not specified");
 369   
         }
 370   
     }
 371   
 }
 372