553N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 481N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 481N/A * This code is free software; you can redistribute it and/or modify it 481N/A * under the terms of the GNU General Public License version 2 only, as 481N/A * published by the Free Software Foundation. 481N/A * This code is distributed in the hope that it will be useful, but WITHOUT 481N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 481N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 481N/A * version 2 for more details (a copy is included in the LICENSE file that 481N/A * accompanied this code). 481N/A * You should have received a copy of the GNU General Public License version 481N/A * 2 along with this work; if not, write to the Free Software Foundation, 481N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 553N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 553N/A * or visit www.oracle.com if you need additional information or have any 481N/A * Utility and test program to check validity of tree positions for tree nodes. 481N/A * The program can be run standalone, or as a jtreg test. In standalone mode, 481N/A * errors can be displayed in a gui viewer. For info on command line args, 481N/A * run program with no args. 481N/A * jtreg: Note that by using the -r switch in the test description below, this test 481N/A * covering any new language features that may be tested in this test suite. 481N/A * @summary assorted position errors in compiler syntax trees 481N/A * If test.src is set, program runs in jtreg mode, and will throw an Error 481N/A * if any errors arise, otherwise System.exit will be used, unless the gui 481N/A * viewer is being used. In jtreg mode, the default base directory for file 481N/A * args is the value of ${test.src}. In jtreg mode, the -r option can be 481N/A * given to change the default base directory to the root test directory. 481N/A * Run the program. A base directory can be provided for file arguments. 481N/A * In jtreg mode, the -r option can be given to change the default base 481N/A * directory to the test root directory. For other options, see usage(). 481N/A * @param baseDir base directory for any file arguments. 481N/A * @param args command line args 481N/A * @return true if successful or in gui mode 481N/A * Print command line help. 481N/A * @param out output stream 481N/A out.
println(
"non java files, or java files which cannot be parsed, will be ignored");
481N/A * Test a file. If the file is a directory, it will be recursively scanned 481N/A * @param file the file or directory to test 481N/A * @param file the file to be read 481N/A * @return the tree for the content of the file 481N/A * @throws IOException if any IO errors occur 481N/A * @throws TreePosTest.ParseException if any errors occur while parsing the file 481N/A * Report an error. When the program is complete, the program will either 481N/A * exit or throw an Error if any errors have been reported. 481N/A * @param msg the error message 481N/A /** Number of files that have been analyzed. */ 481N/A /** Number of errors reported. */ 481N/A /** Flag: don't report irrelevant files. */ 481N/A /** Flag: report files as they are processed. */ 481N/A /** Flag: show errors in GUI viewer. */ 481N/A /** Option: encoding for test files. */ 481N/A /** The GUI viewer for errors. */ 481N/A /** The set of tags for tree nodes to be analyzed; if empty, all tree nodes 481N/A /** Set of files and directories to be excluded from analysis. */ 492N/A /** Set of tag names to be excluded from analysis. */ 481N/A /** Table of printable names for tree tag values. */ 481N/A * Main class for testing assertions concerning tree positions for tree nodes. 481N/A // Modifiers nodes are present throughout the tree even where 481N/A // there is no corresponding source text. 481N/A // Redundant semicolons in a class definition can cause empty 481N/A // initializer blocks with no positions. 481N/A // If pos is NOPOS, so should be the start and end positions 481N/A // For this node, start , pos, and endpos should be all defined 481N/A // The following should normally be ordered 481N/A // encl.start <= start <= pos <= end <= encl.end 481N/A // In addition, the position of the enclosing node should be 481N/A // The primary exceptions are for array type nodes, because of the 481N/A // need to support legacy syntax: 481N/A // e.g. int a[]; int[] b[]; int f()[] { return null; } 481N/A // and because of inconsistent nesting of left and right of 481N/A // e.g. int[][] a = new int[2][]; 481N/A // enum member declarations are desugared in the parser and have 481N/A // ill-defined semantics for tree positions, so for now, we 481N/A // skip the synthesized bits and just check parts which came from 481N/A // the original source text 481N/A * Utility class providing easy access to position and other info for a tree node. 481N/A * javac does not provide an API to convert tag values to strings, so this class uses 481N/A * reflection to determine names of public static final int values in JCTree. 481N/A * Thrown when errors are found parsing a java file. 481N/A * DiagnosticListener to report diagnostics and count any errors that occur. 481N/A * GUI viewer for issues found by TreePosTester. The viewer provides a drop 481N/A * down list for selecting error conditions, a header area providing details 481N/A * about an error, and a text area with the ranges of text highlighted as 481N/A * Add another entry to the list of errors. 481N/A * @param file The file containing the error 481N/A * @param check The condition that was being tested, and which failed 481N/A * @param encl the enclosing tree node 481N/A * @param self the tree node containing the error 481N/A * Initialize the GUI window. 481N/A /** Show an entry that has been selected. */ 481N/A // update simple fields 481N/A // show file text with highlights 481N/A /** Create a test field. */ 481N/A /** Add a highlighted region based on the positions in an Info object. */ 481N/A /** Get the minimum valid position in a set of info objects. */ 481N/A /** Set the background on a component. */ 481N/A /** Scroll a text area to display a given position near the middle of the visible area. */ 481N/A // Using invokeLater appears to give text a chance to sort itself out 481N/A // before the scroll happens; otherwise scrollRectToVisible doesn't work. 481N/A // Maybe there's a better way to sync with the text... 481N/A /** Panel to display an Info object. */ 481N/A /** Object to record information about an error to be displayed. */