/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
public abstract class AbstractTreeScannerTest {
/**
* Run the program. A base directory can be provided for file arguments.
* In jtreg mode, the -r option can be given to change the default base
* directory to the test root directory. For other options, see usage().
* @param baseDir base directory for any file arguments.
* @param args command line args
* @return true if successful or in gui mode
*/
return true;
}
quiet = true;
verbose = true;
d = d.getParentFile();
if (d == null)
throw new Error("cannot find TEST.ROOT");
}
baseDir = d;
}
else {
}
}
else
}
if (fileCount != 1)
if (errors > 0)
return (errors == 0);
}
/**
* Print command line help.
* @param out output stream
*/
}
/**
* Test a file. If the file is a directory, it will be recursively scanned
* for java files.
* @param file the file or directory to test
*/
if (file.isDirectory()) {
test(f);
}
return;
}
try {
if (verbose)
fileCount++;
} catch (ParseException e) {
if (!quiet) {
}
} catch (IOException e) {
}
return;
}
if (!quiet)
}
// See CR: 6982992 Tests CheckAttributedTree.java, JavacTreeScannerTest.java, and SourceTreeeScannerTest.java timeout
/**
* Read a file.
* @param file the file to be read
* @return the tree for the content of the file
* @throws IOException if any IO errors occur
* @throws TreePosTest.ParseException if any errors occur while parsing the file
*/
r.errors = 0;
if (r.errors > 0)
throw new Error("no trees found");
throw new Error("too many trees found");
return t;
}
/**
* Report an error. When the program is complete, the program will either
* exit or throw an Error if any errors have been reported.
* @param msg the error message
*/
errors++;
}
/**
* Report an error. When the program is complete, the program will either
* exit or throw an Error if any errors have been reported.
* @param msg the error message
*/
errors++;
}
/**
* Report an error for a specific tree node.
* @param file the source file for the tree
* @param t the tree node
* @param label an indication of the error
*/
}
/**
* Get a trimmed string for a tree node, with normalized white space and limited length.
*/
}
/** Number of files that have been analyzed. */
int fileCount;
/** Number of trees that have been successfully compared. */
int treeCount;
/** Number of errors reported. */
int errors;
/** Flag: don't report irrelevant files. */
boolean quiet;
/** Flag: report files as they are processed. */
boolean verbose;
/**
* Thrown when errors are found parsing a java file.
*/
super(msg);
}
}
/**
* DiagnosticListener to report diagnostics and count any errors that occur.
*/
}
switch (diagnostic.getKind()) {
case ERROR:
errors++;
}
}
int errors;
}
/**
* Get the set of fields for a tree node that may contain child tree nodes.
* These are the fields that are subtypes of JCTree or List.
* The results are cached, based on the tree's tag.
*/
}
}
return fields;
}
// where
/** Get the line number for the primary position for a tree.
* The code is intended to be simple, although not necessarily efficient.
* However, note that a file manager such as JavacFileManager is likely
* to cache the results of file.getCharContent, avoiding the need to read
* the bits from disk each time this method is called.
*/
try {
int line = 1;
line++;
}
return line;
} catch (IOException e) {
return -1;
}
}
}