📄 netrexxc.java
字号:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */package org.apache.tools.ant.taskdefs.optional;import java.io.BufferedReader;import java.io.File;import java.io.IOException;import java.io.PrintWriter;import java.io.StringReader;import java.io.StringWriter;import java.util.Enumeration;import java.util.Hashtable;import java.util.Properties;import java.util.StringTokenizer;import java.util.Vector;import netrexx.lang.Rexx;import org.apache.tools.ant.BuildException;import org.apache.tools.ant.DirectoryScanner;import org.apache.tools.ant.Project;import org.apache.tools.ant.taskdefs.MatchingTask;import org.apache.tools.ant.types.EnumeratedAttribute;import org.apache.tools.ant.util.FileUtils;// CheckStyle:InnerAssignmentCheck OFF - used too much in the file to be removed/** * Compiles NetRexx source files. * This task can take the following * arguments: * <ul> * <li>binary</li> * <li>classpath</li> * <li>comments</li> * <li>compile</li> * <li>console</li> * <li>crossref</li> * <li>decimal</li> * <li>destdir</li> * <li>diag</li> * <li>explicit</li> * <li>format</li> * <li>keep</li> * <li>logo</li> * <li>replace</li> * <li>savelog</li> * <li>srcdir</li> * <li>sourcedir</li> * <li>strictargs</li> * <li>strictassign</li> * <li>strictcase</li> * <li>strictimport</li> * <li>symbols</li> * <li>time</li> * <li>trace</li> * <li>utf8</li> * <li>verbose</li> * <li>suppressMethodArgumentNotUsed</li> * <li>suppressPrivatePropertyNotUsed</li> * <li>suppressVariableNotUsed</li> * <li>suppressExceptionNotSignalled</li> * <li>suppressDeprecation</li> * </ul> * Of these arguments, the <b>srcdir</b> argument is required. * * <p>When this task executes, it will recursively scan the srcdir * looking for NetRexx source files to compile. This task makes its * compile decision based on timestamp. * <p>Before files are compiled they and any other file in the * srcdir will be copied to the destdir allowing support files to be * located properly in the classpath. The reason for copying the source files * before the compile is that NetRexxC has only two destinations for classfiles: * <ol> * <li>The current directory, and,</li> * <li>The directory the source is in (see sourcedir option) * </ol> * */public class NetRexxC extends MatchingTask { // variables to hold arguments private boolean binary; private String classpath; private boolean comments; private boolean compact = true; // should be the default, as it integrates better in ant. private boolean compile = true; private boolean console; private boolean crossref; private boolean decimal = true; private File destDir; private boolean diag; private boolean explicit; private boolean format; private boolean keep; private boolean logo = true; private boolean replace; private boolean savelog; private File srcDir; private boolean sourcedir = true; // ?? Should this be the default for ant? private boolean strictargs; private boolean strictassign; private boolean strictcase; private boolean strictimport; private boolean strictprops; private boolean strictsignal; private boolean symbols; private boolean time; private String trace = "trace2"; private boolean utf8; private String verbose = "verbose3"; private boolean suppressMethodArgumentNotUsed = false; private boolean suppressPrivatePropertyNotUsed = false; private boolean suppressVariableNotUsed = false; private boolean suppressExceptionNotSignalled = false; private boolean suppressDeprecation = false; // constants for the messages to suppress by flags and their corresponding properties static final String MSG_METHOD_ARGUMENT_NOT_USED = "Warning: Method argument is not used"; static final String MSG_PRIVATE_PROPERTY_NOT_USED = "Warning: Private property is defined but not used"; static final String MSG_VARIABLE_NOT_USED = "Warning: Variable is set but not used"; static final String MSG_EXCEPTION_NOT_SIGNALLED = "is in SIGNALS list but is not signalled within the method"; static final String MSG_DEPRECATION = "has been deprecated"; // other implementation variables private Vector compileList = new Vector(); private Hashtable filecopyList = new Hashtable(); /** * Set whether literals are treated as binary, rather than NetRexx types. * @param binary a <code>boolean</code> value. */ public void setBinary(boolean binary) { this.binary = binary; } /** * Set the classpath used for NetRexx compilation. * @param classpath the classpath to use. */ public void setClasspath(String classpath) { this.classpath = classpath; } /** * Set whether comments are passed through to the generated java source. * Valid true values are "on" or "true". Anything else sets the flag to * false. The default value is false * @param comments a <code>boolean</code> value. */ public void setComments(boolean comments) { this.comments = comments; } /** * Set whether error messages come out in compact or verbose format. Valid * true values are "on" or "true". Anything else sets the flag to false. * The default value is false * @param compact a <code>boolean</code> value. */ public void setCompact(boolean compact) { this.compact = compact; } /** * Set whether the NetRexx compiler should compile the generated java code * Valid true values are "on" or "true". Anything else sets the flag to * false. The default value is true. Setting this flag to false, will * automatically set the keep flag to true. * @param compile a <code>boolean</code> value. */ public void setCompile(boolean compile) { this.compile = compile; if (!this.compile && !this.keep) { this.keep = true; } } /** * Set whether or not messages should be displayed on the 'console' Valid * true values are "on" or "true". Anything else sets the flag to false. * The default value is true. * @param console a <code>boolean</code> value. */ public void setConsole(boolean console) { this.console = console; } /** * Whether variable cross references are generated. * @param crossref a <code>boolean</code> value. */ public void setCrossref(boolean crossref) { this.crossref = crossref; } /** * Set whether decimal arithmetic should be used for the netrexx code. * Binary arithmetic is used when this flag is turned off. Valid true * values are "on" or "true". Anything else sets the flag to false. The * default value is true. * @param decimal a <code>boolean</code> value. */ public void setDecimal(boolean decimal) { this.decimal = decimal; } /** * Set the destination directory into which the NetRexx source files * should be copied and then compiled. * @param destDirName the destination directory. */ public void setDestDir(File destDirName) { destDir = destDirName; } /** * Whether diagnostic information about the compile is generated * @param diag a <code>boolean</code> value. */ public void setDiag(boolean diag) { this.diag = diag; } /** * Sets whether variables must be declared explicitly before use. Valid * true values are "on" or "true". Anything else sets the flag to false. * The default value is false. * @param explicit a <code>boolean</code> value. */ public void setExplicit(boolean explicit) { this.explicit = explicit; } /** * Whether the generated java code is formatted nicely or left to match * NetRexx line numbers for call stack debugging. * @param format a <code>boolean</code> value. */ public void setFormat(boolean format) { this.format = format; } /** * Whether the generated java code is produced Valid true values are "on" * or "true". Anything else sets the flag to false. The default value is * false. * @param java a <code>boolean</code> value. */ public void setJava(boolean java) { log("The attribute java is currently unused.", Project.MSG_WARN); } /** * Sets whether the generated java source file should be kept after * compilation. The generated files will have an extension of .java.keep, * <b>not</b> .java Valid true values are "on" or "true". Anything else * sets the flag to false. The default value is false. * @param keep a <code>boolean</code> value. */ public void setKeep(boolean keep) { this.keep = keep; } /** * Whether the compiler text logo is displayed when compiling. * @param logo a <code>boolean</code> value. */ public void setLogo(boolean logo) { this.logo = logo; } /** * Whether the generated .java file should be replaced when compiling * Valid true values are "on" or "true". Anything else sets the flag to * false. The default value is false. * @param replace a <code>boolean</code> value. */ public void setReplace(boolean replace) { this.replace = replace; } /** * Sets whether the compiler messages will be written to NetRexxC.log as * well as to the console Valid true values are "on" or "true". Anything * else sets the flag to false. The default value is false. * @param savelog a <code>boolean</code> value. */ public void setSavelog(boolean savelog) { this.savelog = savelog;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -