text
stringlengths
30
1.67M
<s> package com . wuntee . oter . logcat ; import java . io . BufferedReader ; import org . apache . log4j . Logger ; import com . wuntee . oter . adb . BackgroundAdbCommand ; public class LogCatCommand extends BackgroundAdbCommand { private static Logger logger = Logger . getLogger ( LogCatBean . class ) ; public static final String ANSI_RESET = "<STR_LIT>" ; public static final String ANSI_BLACK = "<STR_LIT>" ; public static final String ANSI_RED = "<STR_LIT>" ; public static final String ANSI_GREEN = "<STR_LIT>" ; public static final String ANSI_YELLOW = "<STR_LIT>" ; public static final String ANSI_BLUE = "<STR_LIT>" ; public static final String ANSI_PURPLE = "<STR_LIT>" ; public static final String ANSI_CYAN = "<STR_LIT>" ; public static final String ANSI_WHITE = "<STR_LIT>" ; public LogCatCommand ( ) { super ( "<STR_LIT>" ) ; } public static void main ( String args [ ] ) throws Exception { LogCatCommand lc = new LogCatCommand ( ) ; logger . debug ( "<STR_LIT>" ) ; lc . execute ( ) ; BufferedReader read = lc . getStdout ( ) ; BufferedReader error = lc . getStderr ( ) ; logger . debug ( "<STR_LIT>" ) ; Runnable errorRunnable = lc . new ErrorLineReaderThread ( error ) ; Thread errorThread = new Thread ( errorRunnable ) ; errorThread . start ( ) ; logger . debug ( "<STR_LIT>" ) ; Runnable readRunnable = lc . new AdbLineReaderThread ( read ) ; Thread readThread = new Thread ( readRunnable ) ; readThread . start ( ) ; while ( true ) { } } public class ErrorLineReaderThread implements Runnable { private BufferedReader read ; public ErrorLineReaderThread ( BufferedReader read ) { this . read = read ; } public void run ( ) { String line = null ; try { while ( ( line = read . readLine ( ) ) != null ) { System . err . println ( "<STR_LIT>" + line ) ; } } catch ( Exception e ) { System . out . println ( "<STR_LIT>" + line ) ; e . printStackTrace ( ) ; } } } public class AdbLineReaderThread implements Runnable { private BufferedReader read ; public AdbLineReaderThread ( BufferedReader read ) { this . read = read ; } public void run ( ) { String line = null ; try { while ( ( line = read . readLine ( ) ) != null ) { LogCatBean l = LogCatBean . parse ( line ) ; if ( l . getLevel ( ) == LogCatLevelEnum . DEBUG ) System . out . println ( ANSI_BLUE + l + ANSI_RESET ) ; else if ( l . getLevel ( ) == LogCatLevelEnum . INFO ) System . out . println ( ANSI_BLUE + l + ANSI_RESET ) ; else if ( l . getLevel ( ) == LogCatLevelEnum . WARN ) System . out . println ( ANSI_YELLOW + l + ANSI_RESET ) ; else if ( l . getLevel ( ) == LogCatLevelEnum . ERROR ) System . out . println ( ANSI_RED + l + ANSI_RESET ) ; } } catch ( Exception e ) { System . out . println ( "<STR_LIT>" + line ) ; e . printStackTrace ( ) ; } } } } </s>
<s> package com . wuntee . oter . logcat ; import java . io . BufferedReader ; import java . io . IOException ; import java . text . SimpleDateFormat ; import java . util . Date ; import java . util . LinkedList ; import java . util . List ; import org . apache . log4j . Logger ; import org . eclipse . swt . SWT ; import org . eclipse . swt . widgets . Table ; import org . eclipse . swt . widgets . TableItem ; import org . eclipse . wb . swt . SWTResourceManager ; import com . wuntee . oter . OterStatics ; import com . wuntee . oter . OterWorkshop ; import com . wuntee . oter . exception . ParseException ; import com . wuntee . oter . view . Gui ; import com . wuntee . oter . view . GuiWorkshop ; public class LogCatController { private static Logger logger = Logger . getLogger ( LogCatController . class ) ; private LogCatCommand logcat ; private Gui gui ; private SimpleDateFormat dateFormat = new SimpleDateFormat ( "<STR_LIT>" ) ; private List < LogCatBean > logcatCurrent ; private int maxBufferSize ; public static int DEFAULT_MAX_LINES = <NUM_LIT> ; public LogCatController ( Gui gui ) { this . gui = gui ; logcatCurrent = new LinkedList < LogCatBean > ( ) ; try { maxBufferSize = Integer . parseInt ( OterWorkshop . getProperty ( OterStatics . PROPERTY_LOGCAT_MAXLINES ) ) ; } catch ( Exception e ) { maxBufferSize = DEFAULT_MAX_LINES ; } } public void copy ( ) { TableItem [ ] selected = this . gui . getLogcatTable ( ) . getSelection ( ) ; String clipboard = "<STR_LIT>" ; for ( TableItem item : selected ) { String date = item . getText ( <NUM_LIT:0> ) ; String level = item . getText ( <NUM_LIT:1> ) ; String c = item . getText ( <NUM_LIT:2> ) ; String pid = item . getText ( <NUM_LIT:3> ) ; String message = item . getText ( <NUM_LIT:4> ) ; String line = String . format ( "<STR_LIT>" , date , level , c , pid , message ) ; clipboard = clipboard + line ; } GuiWorkshop . setClipboardContents ( clipboard ) ; } public void start ( ) throws Exception { if ( logcat != null && logcat . isRunning ( ) ) logcat . close ( ) ; try { maxBufferSize = Integer . parseInt ( OterWorkshop . getProperty ( OterStatics . PROPERTY_LOGCAT_MAXLINES ) ) ; } catch ( Exception e ) { maxBufferSize = DEFAULT_MAX_LINES ; } logcat = new LogCatCommand ( ) ; logger . debug ( "<STR_LIT>" ) ; gui . getLogcatTable ( ) . clearAll ( ) ; logger . debug ( "<STR_LIT>" ) ; logcat . execute ( ) ; BufferedReader read = logcat . getStdout ( ) ; BufferedReader error = logcat . getStderr ( ) ; logger . debug ( "<STR_LIT>" ) ; Runnable errorRunnable = new ErrorLineReaderThread ( error ) ; Thread errorThread = new Thread ( errorRunnable ) ; errorThread . start ( ) ; logger . debug ( "<STR_LIT>" ) ; Runnable readRunnable = new AdbLineReaderThread ( read ) ; Thread readThread = new Thread ( readRunnable ) ; readThread . start ( ) ; } public void stop ( ) { logger . debug ( "<STR_LIT>" ) ; if ( logcat . isRunning ( ) ) logcat . close ( ) ; } public void addLine ( LogCatBean l ) { this . gui . getDisplay ( ) . asyncExec ( new AddLineRunnable ( l ) ) ; } public void stopAutoscroll ( ) { gui . getLogcatCheckAutoscroll ( ) . setSelection ( false ) ; } public void reFilterTable ( ) { gui . runRunnableAsync ( new ReFilterTableRunnable ( ) ) ; } public class ReFilterTableRunnable implements Runnable { public void run ( ) { Table table = gui . getLogcatTable ( ) ; boolean debug = gui . getLogcatCheckDebug ( ) . getSelection ( ) ; logger . debug ( debug ) ; boolean info = gui . getLogcatCheckInfo ( ) . getSelection ( ) ; boolean error = gui . getLogcatCheckError ( ) . getSelection ( ) ; boolean warn = gui . getLogcatCheckWarn ( ) . getSelection ( ) ; boolean verbose = gui . getLogcatCheckVerbose ( ) . getSelection ( ) ; table . removeAll ( ) ; for ( LogCatBean bean : logcatCurrent ) { if ( matchesFilter ( bean ) ) { if ( bean . getLevel ( ) == LogCatLevelEnum . ERROR && error == true ) { TableItem tableItem = new TableItem ( table , SWT . NONE ) ; tableItem . setText ( new String [ ] { dateFormat . format ( bean . getDate ( ) ) , bean . getLevel ( ) . toString ( ) , bean . getClazz ( ) , String . valueOf ( bean . getPid ( ) ) , bean . getMessage ( ) } ) ; tableItem . setForeground ( SWTResourceManager . getColor ( SWT . COLOR_RED ) ) ; } else if ( bean . getLevel ( ) == LogCatLevelEnum . WARN && warn == true ) { TableItem tableItem = new TableItem ( table , SWT . NONE ) ; tableItem . setText ( new String [ ] { dateFormat . format ( bean . getDate ( ) ) , bean . getLevel ( ) . toString ( ) , bean . getClazz ( ) , String . valueOf ( bean . getPid ( ) ) , bean . getMessage ( ) } ) ; tableItem . setForeground ( SWTResourceManager . getColor ( <NUM_LIT:255> , <NUM_LIT> , <NUM_LIT:0> ) ) ; } else if ( bean . getLevel ( ) == LogCatLevelEnum . INFO && info == true ) { TableItem tableItem = new TableItem ( table , SWT . NONE ) ; tableItem . setText ( new String [ ] { dateFormat . format ( bean . getDate ( ) ) , bean . getLevel ( ) . toString ( ) , bean . getClazz ( ) , String . valueOf ( bean . getPid ( ) ) , bean . getMessage ( ) } ) ; tableItem . setForeground ( SWTResourceManager . getColor ( SWT . COLOR_BLUE ) ) ; } else if ( bean . getLevel ( ) == LogCatLevelEnum . DEBUG && debug == true ) { TableItem tableItem = new TableItem ( table , SWT . NONE ) ; tableItem . setText ( new String [ ] { dateFormat . format ( bean . getDate ( ) ) , bean . getLevel ( ) . toString ( ) , bean . getClazz ( ) , String . valueOf ( bean . getPid ( ) ) , bean . getMessage ( ) } ) ; tableItem . setForeground ( SWTResourceManager . getColor ( SWT . COLOR_BLACK ) ) ; } else if ( bean . getLevel ( ) == LogCatLevelEnum . VERBOSE && verbose == true ) { TableItem tableItem = new TableItem ( table , SWT . NONE ) ; tableItem . setText ( new String [ ] { dateFormat . format ( bean . getDate ( ) ) , bean . getLevel ( ) . toString ( ) , bean . getClazz ( ) , String . valueOf ( bean . getPid ( ) ) , bean . getMessage ( ) } ) ; tableItem . setForeground ( SWTResourceManager . getColor ( SWT . COLOR_CYAN ) ) ; } } } int bottom = gui . getLogcatTable ( ) . getItemCount ( ) ; gui . getLogcatTable ( ) . setTopIndex ( bottom - <NUM_LIT:1> ) ; } } public boolean matchesFilter ( LogCatBean bean ) { try { String filter = gui . getLogcatTextFilter ( ) . getText ( ) . toLowerCase ( ) . trim ( ) ; String filterRegex = "<STR_LIT>" + filter + "<STR_LIT>" ; if ( filter == "<STR_LIT>" ) { return ( true ) ; } else { if ( bean . getMessage ( ) . toLowerCase ( ) . matches ( filterRegex ) ) { return ( true ) ; } else if ( bean . getClazz ( ) . toLowerCase ( ) . matches ( filterRegex ) ) { return ( true ) ; } } } catch ( Exception e ) { return ( true ) ; } return ( false ) ; } public class AddLineRunnable implements Runnable { private LogCatBean l ; public AddLineRunnable ( LogCatBean l ) { this . l = l ; } public void run ( ) { if ( logcatCurrent . size ( ) >= maxBufferSize ) { logger . info ( "<STR_LIT>" ) ; logcatCurrent . remove ( <NUM_LIT:0> ) ; } logcatCurrent . add ( l ) ; if ( matchesFilter ( l ) ) { Table logCatTable = gui . getLogcatTable ( ) ; if ( logCatTable . getItemCount ( ) >= maxBufferSize ) { logger . info ( "<STR_LIT>" ) ; logCatTable . remove ( logCatTable . getTopIndex ( ) ) ; } if ( l . getLevel ( ) == LogCatLevelEnum . ERROR && gui . getLogcatCheckError ( ) . getSelection ( ) == true ) { TableItem tableItem = new TableItem ( logCatTable , SWT . NONE ) ; tableItem . setText ( new String [ ] { dateFormat . format ( l . getDate ( ) ) , l . getLevel ( ) . toString ( ) , l . getClazz ( ) , String . valueOf ( l . getPid ( ) ) , l . getMessage ( ) } ) ; tableItem . setForeground ( SWTResourceManager . getColor ( SWT . COLOR_RED ) ) ; } else if ( l . getLevel ( ) == LogCatLevelEnum . WARN && gui . getLogcatCheckWarn ( ) . getSelection ( ) == true ) { TableItem tableItem = new TableItem ( logCatTable , SWT . NONE ) ; tableItem . setText ( new String [ ] { dateFormat . format ( l . getDate ( ) ) , l . getLevel ( ) . toString ( ) , l . getClazz ( ) , String . valueOf ( l . getPid ( ) ) , l . getMessage ( ) } ) ; tableItem . setForeground ( SWTResourceManager . getColor ( <NUM_LIT:255> , <NUM_LIT> , <NUM_LIT:0> ) ) ; } else if ( l . getLevel ( ) == LogCatLevelEnum . INFO && gui . getLogcatCheckInfo ( ) . getSelection ( ) == true ) { TableItem tableItem = new TableItem ( logCatTable , SWT . NONE ) ; tableItem . setText ( new String [ ] { dateFormat . format ( l . getDate ( ) ) , l . getLevel ( ) . toString ( ) , l . getClazz ( ) , String . valueOf ( l . getPid ( ) ) , l . getMessage ( ) } ) ; tableItem . setForeground ( SWTResourceManager . getColor ( SWT . COLOR_BLUE ) ) ; } else if ( l . getLevel ( ) == LogCatLevelEnum . DEBUG && gui . getLogcatCheckDebug ( ) . getSelection ( ) == true ) { TableItem tableItem = new TableItem ( logCatTable , SWT . NONE ) ; tableItem . setText ( new String [ ] { dateFormat . format ( l . getDate ( ) ) , l . getLevel ( ) . toString ( ) , l . getClazz ( ) , String . valueOf ( l . getPid ( ) ) , l . getMessage ( ) } ) ; tableItem . setForeground ( SWTResourceManager . getColor ( SWT . COLOR_BLACK ) ) ; } else if ( l . getLevel ( ) == LogCatLevelEnum . VERBOSE && gui . getLogcatCheckVerbose ( ) . getSelection ( ) == true ) { TableItem tableItem = new TableItem ( logCatTable , SWT . NONE ) ; tableItem . setText ( new String [ ] { dateFormat . format ( l . getDate ( ) ) , l . getLevel ( ) . toString ( ) , l . getClazz ( ) , String . valueOf ( l . getPid ( ) ) , l . getMessage ( ) } ) ; tableItem . setForeground ( SWTResourceManager . getColor ( SWT . COLOR_CYAN ) ) ; } if ( gui . getLogcatCheckAutoscroll ( ) . getSelection ( ) == true ) { int bottom = gui . getLogcatTable ( ) . getItemCount ( ) ; gui . getLogcatTable ( ) . setTopIndex ( bottom - <NUM_LIT:1> ) ; } } } } public class ErrorLineReaderThread implements Runnable { private BufferedReader read ; public ErrorLineReaderThread ( BufferedReader read ) { this . read = read ; } public void run ( ) { String line = null ; try { while ( ( line = read . readLine ( ) ) != null ) { System . err . println ( "<STR_LIT>" + line ) ; } } catch ( Exception e ) { System . out . println ( "<STR_LIT>" + line ) ; e . printStackTrace ( ) ; } } } public class AdbLineReaderThread implements Runnable { private BufferedReader read ; public AdbLineReaderThread ( BufferedReader read ) { this . read = read ; } public void run ( ) { logger . debug ( "<STR_LIT>" ) ; String line = null ; try { while ( ( line = read . readLine ( ) ) != null ) { try { LogCatBean l = LogCatBean . parse ( line ) ; addLine ( l ) ; } catch ( ParseException e ) { logger . error ( "<STR_LIT>" + line , e ) ; } } } catch ( IOException e1 ) { logger . error ( "<STR_LIT>" , e1 ) ; } } } } </s>
<s> package com . wuntee . oter . logcat ; public enum LogCatLevelEnum { DEBUG , INFO , WARN , ERROR , VERBOSE ; public String toString ( ) { return ( super . toString ( ) . toLowerCase ( ) ) ; } } </s>
<s> package com . wuntee . oter . sqlite ; import java . io . File ; import java . sql . Connection ; import java . sql . DriverManager ; import java . sql . ResultSet ; import java . sql . ResultSetMetaData ; import java . sql . SQLException ; import java . sql . Statement ; import java . util . LinkedList ; import java . util . List ; import org . apache . log4j . Logger ; public class SqliteHelper { private static Logger logger = Logger . getLogger ( SqliteHelper . class ) ; public static String SQL_TABLES = "<STR_LIT>" ; private Connection connection ; private Statement statement ; public SqliteHelper ( File f ) throws ClassNotFoundException , SQLException { Class . forName ( "<STR_LIT>" ) ; connection = DriverManager . getConnection ( "<STR_LIT>" + f . getAbsolutePath ( ) ) ; statement = connection . createStatement ( ) ; statement . setQueryTimeout ( <NUM_LIT:30> ) ; } public List < String > getTables ( ) throws SQLException { ResultSet rs = statement . executeQuery ( SQL_TABLES ) ; List < String > ret = new LinkedList < String > ( ) ; while ( rs . next ( ) ) { ret . add ( rs . getString ( <NUM_LIT:1> ) ) ; } return ( ret ) ; } public List < String > getTableColumnNames ( String tableName ) throws SQLException { ResultSet rs = statement . executeQuery ( "<STR_LIT>" + tableName + "<STR_LIT:)>" ) ; List < String > ret = new LinkedList < String > ( ) ; while ( rs . next ( ) ) { ret . add ( rs . getString ( <NUM_LIT:2> ) ) ; } return ( ret ) ; } public List < List < String > > getTableData ( String tableName ) throws SQLException { List < List < String > > ret = new LinkedList < List < String > > ( ) ; ResultSet rs = statement . executeQuery ( "<STR_LIT>" + tableName ) ; ResultSetMetaData rsmd = rs . getMetaData ( ) ; int cols = rsmd . getColumnCount ( ) ; logger . debug ( tableName + "<STR_LIT>" + cols + "<STR_LIT>" ) ; while ( rs . next ( ) ) { List < String > col = new LinkedList < String > ( ) ; for ( int i = <NUM_LIT:1> ; i <= cols ; i ++ ) { col . add ( rs . getString ( i ) ) ; } ret . add ( col ) ; } logger . error ( ret ) ; return ( ret ) ; } } </s>
<s> package com . wuntee . oter ; public class OterStatics { public static final String META_INF = "<STR_LIT>" ; public static String PROPERTY_FILE = "<STR_LIT>" ; public static String PROPERTY_ADB_ARGUMENTS = "<STR_LIT>" ; public static String PROPERTY_ANDROID_HOME = "<STR_LIT>" ; public static String PROPERTY_LOGCAT_MAXLINES = "<STR_LIT>" ; public static String PROPERTY_JAVATOSMALI_CLASSPATH = "<STR_LIT>" ; public static String PROPERTY_DEVICE = "<STR_LIT>" ; public static String ICON_FILE = "<STR_LIT>" ; public static String ICON_DIRECTORY = "<STR_LIT>" ; public static String ICON_PACKAGE = "<STR_LIT>" ; public static String ICON_APP = "<STR_LIT>" ; public static String [ ] BAD_DIRECTORIES = new String [ ] { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" } ; public static String [ ] ADB_SHELLS = new String [ ] { "<STR_LIT>" , "<STR_LIT>" } ; public static String ADB_ROOT_SHELL = "<STR_LIT>" ; public static String ANDROID_CERT_FILE = "<STR_LIT>" ; public static String CLASSES_DEX = "<STR_LIT>" ; public static String SMALI_EXTENSION = "<STR_LIT>" ; public static String TEMP_PREFIX = "<STR_LIT>" ; public static String SOME_STRING = "<STR_LIT>" ; public static String getAndroidHome ( ) { return ( OterWorkshop . getProperty ( PROPERTY_ANDROID_HOME ) ) ; } public static String getEmulatorCommand ( ) { return ( getAndroidHome ( ) + System . getProperty ( "<STR_LIT>" ) + "<STR_LIT>" + System . getProperty ( "<STR_LIT>" ) + "<STR_LIT>" ) ; } public static String getAdbExecutable ( ) { return ( getAndroidHome ( ) + System . getProperty ( "<STR_LIT>" ) + "<STR_LIT>" + System . getProperty ( "<STR_LIT>" ) + "<STR_LIT>" ) ; } public static String getAndroidCommand ( ) { return ( getAndroidHome ( ) + System . getProperty ( "<STR_LIT>" ) + "<STR_LIT>" + System . getProperty ( "<STR_LIT>" ) + "<STR_LIT>" ) ; } public static String getAaptCommand ( ) { return ( getAndroidHome ( ) + System . getProperty ( "<STR_LIT>" ) + "<STR_LIT>" + System . getProperty ( "<STR_LIT>" ) + "<STR_LIT>" ) ; } public static String getDxCommand ( ) { return ( getAndroidHome ( ) + System . getProperty ( "<STR_LIT>" ) + "<STR_LIT>" + System . getProperty ( "<STR_LIT>" ) + "<STR_LIT>" ) ; } public static String getConfigFileName ( ) { return ( System . getProperty ( "<STR_LIT>" ) + System . getProperty ( "<STR_LIT>" ) + OterStatics . PROPERTY_FILE ) ; } } </s>
<s> package com . wuntee . oter . security . tools ; import java . io . ByteArrayInputStream ; import java . io . ByteArrayOutputStream ; import java . io . File ; import java . io . FileOutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . OutputStream ; import java . io . PrintStream ; import java . math . BigInteger ; import java . net . SocketTimeoutException ; import java . net . URI ; import java . net . URISyntaxException ; import java . net . URL ; import java . security . IdentityScope ; import java . security . InvalidKeyException ; import java . security . Key ; import java . security . KeyStore ; import java . security . KeyStoreException ; import java . security . MessageDigest ; import java . security . NoSuchAlgorithmException ; import java . security . NoSuchProviderException ; import java . security . Principal ; import java . security . PrivateKey ; import java . security . Signature ; import java . security . SignatureException ; import java . security . UnrecoverableKeyException ; import java . security . cert . CertificateException ; import java . security . cert . CertificateExpiredException ; import java . security . cert . CertificateNotYetValidException ; import java . security . cert . X509Certificate ; import java . text . Collator ; import java . text . MessageFormat ; import java . util . Enumeration ; import java . util . HashMap ; import java . util . Iterator ; import java . util . List ; import java . util . Map ; import java . util . Vector ; import java . util . jar . Attributes ; import java . util . jar . JarFile ; import java . util . jar . Manifest ; import java . util . zip . ZipEntry ; import java . util . zip . ZipFile ; import java . util . zip . ZipOutputStream ; import org . apache . log4j . Logger ; import sun . misc . BASE64Encoder ; import sun . security . tools . KeyStoreUtil ; import sun . security . tools . TimestampedSigner ; import sun . security . util . DerInputStream ; import sun . security . util . DerValue ; import sun . security . util . ManifestDigester ; import sun . security . util . SignatureFileVerifier ; import sun . security . x509 . AlgorithmId ; import sun . security . x509 . CertificateIssuerName ; import sun . security . x509 . NetscapeCertTypeExtension ; import sun . security . x509 . X500Name ; import sun . security . x509 . X509CertInfo ; import com . sun . jarsigner . ContentSigner ; import com . sun . jarsigner . ContentSignerParameters ; import com . wuntee . oter . exception . JarSigningException ; public class JarSigner { private static Logger logger = Logger . getLogger ( JarSigner . class ) ; private static final java . util . ResourceBundle rb = java . util . ResourceBundle . getBundle ( "<STR_LIT>" ) ; private static final Collator collator = Collator . getInstance ( ) ; static { collator . setStrength ( Collator . PRIMARY ) ; } private static final String META_INF = "<STR_LIT>" ; private static final String SIG_PREFIX = META_INF + "<STR_LIT>" ; private static final Class [ ] PARAM_STRING = { String . class } ; private static final String NONE = "<STR_LIT>" ; private static final String P11KEYSTORE = "<STR_LIT>" ; private static final long SIX_MONTHS = <NUM_LIT> * <NUM_LIT:24> * <NUM_LIT> * <NUM_LIT> * <NUM_LIT> ; static final int IN_KEYSTORE = <NUM_LIT> ; static final int IN_SCOPE = <NUM_LIT> ; X509Certificate [ ] certChain ; PrivateKey privateKey ; KeyStore store ; IdentityScope scope ; String keystore ; boolean nullStream = false ; boolean token = false ; String jarfile ; String alias ; char [ ] storepass ; boolean protectedPath ; String storetype ; String providerName ; Vector < String > providers = null ; HashMap < String , String > providerArgs = new HashMap < String , String > ( ) ; char [ ] keypass ; String sigfile ; String sigalg ; String digestalg = "<STR_LIT>" ; String signedjar ; String tsaUrl ; String tsaAlias ; boolean verify = false ; boolean verbose = false ; boolean showcerts = false ; boolean debug = false ; boolean signManifest = true ; boolean externalSF = true ; private ByteArrayOutputStream baos = new ByteArrayOutputStream ( <NUM_LIT> ) ; private byte [ ] buffer = new byte [ <NUM_LIT> ] ; private ContentSigner signingMechanism = null ; private String altSignerClass = null ; private String altSignerClasspath = null ; private ZipFile zipFile = null ; private boolean hasExpiredCert = false ; private boolean hasExpiringCert = false ; private boolean notYetValidCert = false ; private boolean badKeyUsage = false ; private boolean badExtendedKeyUsage = false ; private boolean badNetscapeCertType = false ; public void signJar ( String keystore , String keystorePassword , String jarName , String alias ) throws Exception { this . keystore = keystore ; this . storepass = keystorePassword . toCharArray ( ) ; storetype = KeyStoreUtil . niceStoreTypeName ( KeyStore . getDefaultType ( ) ) ; if ( P11KEYSTORE . equalsIgnoreCase ( storetype ) || KeyStoreUtil . isWindowsKeyStore ( storetype ) ) { token = true ; } hasExpiredCert = false ; hasExpiringCert = false ; notYetValidCert = false ; badKeyUsage = false ; badExtendedKeyUsage = false ; badNetscapeCertType = false ; loadKeyStore ( keystore , true ) ; getAliasInfo ( alias ) ; signJar ( jarName , alias , null ) ; } void signJar ( String jarName , String alias , String [ ] args ) throws Exception { boolean aliasUsed = false ; X509Certificate tsaCert = null ; if ( sigfile == null ) { sigfile = alias ; aliasUsed = true ; } if ( sigfile . length ( ) > <NUM_LIT:8> ) { sigfile = sigfile . substring ( <NUM_LIT:0> , <NUM_LIT:8> ) . toUpperCase ( ) ; } else { sigfile = sigfile . toUpperCase ( ) ; } StringBuilder tmpSigFile = new StringBuilder ( sigfile . length ( ) ) ; for ( int j = <NUM_LIT:0> ; j < sigfile . length ( ) ; j ++ ) { char c = sigfile . charAt ( j ) ; if ( ! ( ( c >= '<CHAR_LIT:A>' && c <= '<CHAR_LIT:Z>' ) || ( c >= '<CHAR_LIT:0>' && c <= '<CHAR_LIT:9>' ) || ( c == '<CHAR_LIT:->' ) || ( c == '<CHAR_LIT:_>' ) ) ) { if ( aliasUsed ) { c = '<CHAR_LIT:_>' ; } else { throw new RuntimeException ( rb . getString ( "<STR_LIT>" ) ) ; } } tmpSigFile . append ( c ) ; } sigfile = tmpSigFile . toString ( ) ; String tmpJarName ; if ( signedjar == null ) tmpJarName = jarName + "<STR_LIT>" ; else tmpJarName = signedjar ; File jarFile = new File ( jarName ) ; File signedJarFile = new File ( tmpJarName ) ; try { zipFile = new ZipFile ( jarName ) ; } catch ( IOException ioe ) { error ( rb . getString ( "<STR_LIT>" ) + jarName , ioe ) ; } FileOutputStream fos = null ; try { fos = new FileOutputStream ( signedJarFile ) ; } catch ( IOException ioe ) { error ( rb . getString ( "<STR_LIT>" ) + tmpJarName , ioe ) ; } PrintStream ps = new PrintStream ( fos ) ; ZipOutputStream zos = new ZipOutputStream ( ps ) ; String sfFilename = ( META_INF + sigfile + "<STR_LIT>" ) . toUpperCase ( ) ; String bkFilename = ( META_INF + sigfile + "<STR_LIT>" ) . toUpperCase ( ) ; Manifest manifest = new Manifest ( ) ; Map < String , Attributes > mfEntries = manifest . getEntries ( ) ; Attributes oldAttr = null ; boolean mfModified = false ; boolean mfCreated = false ; byte [ ] mfRawBytes = null ; try { MessageDigest digests [ ] = { MessageDigest . getInstance ( digestalg ) } ; ZipEntry mfFile ; if ( ( mfFile = getManifestFile ( zipFile ) ) != null ) { mfRawBytes = getBytes ( zipFile , mfFile ) ; manifest . read ( new ByteArrayInputStream ( mfRawBytes ) ) ; oldAttr = ( Attributes ) ( manifest . getMainAttributes ( ) . clone ( ) ) ; } else { Attributes mattr = manifest . getMainAttributes ( ) ; mattr . putValue ( Attributes . Name . MANIFEST_VERSION . toString ( ) , "<STR_LIT:1.0>" ) ; String javaVendor = System . getProperty ( "<STR_LIT>" ) ; String jdkVersion = System . getProperty ( "<STR_LIT>" ) ; mattr . putValue ( "<STR_LIT>" , jdkVersion + "<STR_LIT:U+0020(>" + javaVendor + "<STR_LIT:)>" ) ; mfFile = new ZipEntry ( JarFile . MANIFEST_NAME ) ; mfCreated = true ; } BASE64Encoder encoder = new JarBASE64Encoder ( ) ; Vector < ZipEntry > mfFiles = new Vector < ZipEntry > ( ) ; for ( Enumeration < ? extends ZipEntry > enum_ = zipFile . entries ( ) ; enum_ . hasMoreElements ( ) ; ) { ZipEntry ze = enum_ . nextElement ( ) ; if ( ze . getName ( ) . startsWith ( META_INF ) ) { mfFiles . addElement ( ze ) ; if ( signatureRelated ( ze . getName ( ) ) ) { continue ; } } if ( manifest . getAttributes ( ze . getName ( ) ) != null ) { if ( updateDigests ( ze , zipFile , digests , encoder , manifest ) == true ) { mfModified = true ; } } else if ( ! ze . isDirectory ( ) ) { Attributes attrs = getDigestAttributes ( ze , zipFile , digests , encoder ) ; mfEntries . put ( ze . getName ( ) , attrs ) ; mfModified = true ; } } if ( mfModified ) { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; manifest . write ( baos ) ; byte [ ] newBytes = baos . toByteArray ( ) ; if ( mfRawBytes != null && oldAttr . equals ( manifest . getMainAttributes ( ) ) ) { int newPos = findHeaderEnd ( newBytes ) ; int oldPos = findHeaderEnd ( mfRawBytes ) ; if ( newPos == oldPos ) { System . arraycopy ( mfRawBytes , <NUM_LIT:0> , newBytes , <NUM_LIT:0> , oldPos ) ; } else { byte [ ] lastBytes = new byte [ oldPos + newBytes . length - newPos ] ; System . arraycopy ( mfRawBytes , <NUM_LIT:0> , lastBytes , <NUM_LIT:0> , oldPos ) ; System . arraycopy ( newBytes , newPos , lastBytes , oldPos , newBytes . length - newPos ) ; newBytes = lastBytes ; } } mfRawBytes = newBytes ; } if ( mfModified ) { mfFile = new ZipEntry ( JarFile . MANIFEST_NAME ) ; } zos . putNextEntry ( mfFile ) ; zos . write ( mfRawBytes ) ; ManifestDigester manDig = new ManifestDigester ( mfRawBytes ) ; SignatureFile sf = new SignatureFile ( digests , manifest , manDig , sigfile , signManifest ) ; if ( tsaAlias != null ) { tsaCert = getTsaCert ( tsaAlias ) ; } SignatureFile . Block block = null ; try { block = sf . generateBlock ( privateKey , sigalg , certChain , externalSF , tsaUrl , tsaCert , signingMechanism , args , zipFile ) ; } catch ( SocketTimeoutException e ) { error ( rb . getString ( "<STR_LIT>" ) + rb . getString ( "<STR_LIT>" ) + rb . getString ( "<STR_LIT>" ) + rb . getString ( "<STR_LIT>" ) + "<STR_LIT>" + "<STR_LIT>" , e ) ; } sfFilename = sf . getMetaName ( ) ; bkFilename = block . getMetaName ( ) ; ZipEntry sfFile = new ZipEntry ( sfFilename ) ; ZipEntry bkFile = new ZipEntry ( bkFilename ) ; long time = System . currentTimeMillis ( ) ; sfFile . setTime ( time ) ; bkFile . setTime ( time ) ; zos . putNextEntry ( sfFile ) ; sf . write ( zos ) ; zos . putNextEntry ( bkFile ) ; block . write ( zos ) ; for ( int i = <NUM_LIT:0> ; i < mfFiles . size ( ) ; i ++ ) { ZipEntry ze = mfFiles . elementAt ( i ) ; if ( ! ze . getName ( ) . equalsIgnoreCase ( JarFile . MANIFEST_NAME ) && ! ze . getName ( ) . equalsIgnoreCase ( sfFilename ) && ! ze . getName ( ) . equalsIgnoreCase ( bkFilename ) ) { writeEntry ( zipFile , zos , ze ) ; } } for ( Enumeration < ? extends ZipEntry > enum_ = zipFile . entries ( ) ; enum_ . hasMoreElements ( ) ; ) { ZipEntry ze = enum_ . nextElement ( ) ; if ( ! ze . getName ( ) . startsWith ( META_INF ) ) { writeEntry ( zipFile , zos , ze ) ; } } } catch ( IOException ioe ) { error ( rb . getString ( "<STR_LIT>" ) + ioe , ioe ) ; } finally { if ( zipFile != null ) { zipFile . close ( ) ; zipFile = null ; } if ( zos != null ) { zos . close ( ) ; } } if ( signedjar == null ) { if ( ! signedJarFile . renameTo ( jarFile ) ) { File origJar = new File ( jarName + "<STR_LIT>" ) ; if ( jarFile . renameTo ( origJar ) ) { if ( signedJarFile . renameTo ( jarFile ) ) { origJar . delete ( ) ; } else { MessageFormat form = new MessageFormat ( rb . getString ( "<STR_LIT>" ) ) ; Object [ ] source = { signedJarFile , jarFile } ; error ( form . format ( source ) ) ; } } else { MessageFormat form = new MessageFormat ( rb . getString ( "<STR_LIT>" ) ) ; Object [ ] source = { jarFile , origJar } ; error ( form . format ( source ) ) ; } } } if ( hasExpiredCert || hasExpiringCert || notYetValidCert || badKeyUsage || badExtendedKeyUsage || badNetscapeCertType ) { logger . warn ( rb . getString ( "<STR_LIT>" ) ) ; if ( badKeyUsage ) { logger . warn ( rb . getString ( "<STR_LIT>" ) ) ; } if ( badExtendedKeyUsage ) { logger . warn ( rb . getString ( "<STR_LIT>" ) ) ; } if ( badNetscapeCertType ) { logger . warn ( rb . getString ( "<STR_LIT>" ) ) ; } if ( hasExpiredCert ) { logger . warn ( rb . getString ( "<STR_LIT>" ) ) ; } else if ( hasExpiringCert ) { logger . warn ( rb . getString ( "<STR_LIT>" ) ) ; } else if ( notYetValidCert ) { logger . warn ( rb . getString ( "<STR_LIT>" ) ) ; } } } private int findHeaderEnd ( byte [ ] bs ) { for ( int i = <NUM_LIT:0> ; i < bs . length - <NUM_LIT:3> ; i ++ ) { if ( bs [ i ] == '<STR_LIT>' && bs [ i + <NUM_LIT:1> ] == '<STR_LIT:\n>' && bs [ i + <NUM_LIT:2> ] == '<STR_LIT>' && bs [ i + <NUM_LIT:3> ] == '<STR_LIT:\n>' ) { return i ; } } return <NUM_LIT:0> ; } private boolean signatureRelated ( String name ) { String ucName = name . toUpperCase ( ) ; if ( ucName . equals ( JarFile . MANIFEST_NAME ) || ucName . equals ( META_INF ) || ( ucName . startsWith ( SIG_PREFIX ) && ucName . indexOf ( "<STR_LIT:/>" ) == ucName . lastIndexOf ( "<STR_LIT:/>" ) ) ) { return true ; } if ( ucName . startsWith ( META_INF ) && SignatureFileVerifier . isBlockOrSF ( ucName ) ) { return ( ucName . indexOf ( "<STR_LIT:/>" ) == ucName . lastIndexOf ( "<STR_LIT:/>" ) ) ; } return false ; } private void writeEntry ( ZipFile zf , ZipOutputStream os , ZipEntry ze ) throws IOException { ZipEntry ze2 = new ZipEntry ( ze . getName ( ) ) ; ze2 . setMethod ( ze . getMethod ( ) ) ; ze2 . setTime ( ze . getTime ( ) ) ; ze2 . setComment ( ze . getComment ( ) ) ; ze2 . setExtra ( ze . getExtra ( ) ) ; if ( ze . getMethod ( ) == ZipEntry . STORED ) { ze2 . setSize ( ze . getSize ( ) ) ; ze2 . setCrc ( ze . getCrc ( ) ) ; } os . putNextEntry ( ze2 ) ; writeBytes ( zf , ze , os ) ; } private synchronized void writeBytes ( ZipFile zf , ZipEntry ze , ZipOutputStream os ) throws IOException { int n ; InputStream is = null ; try { is = zf . getInputStream ( ze ) ; long left = ze . getSize ( ) ; while ( ( left > <NUM_LIT:0> ) && ( n = is . read ( buffer , <NUM_LIT:0> , buffer . length ) ) != - <NUM_LIT:1> ) { os . write ( buffer , <NUM_LIT:0> , n ) ; left -= n ; } } finally { if ( is != null ) { is . close ( ) ; } } } X509Certificate getTsaCert ( String alias ) throws JarSigningException { java . security . cert . Certificate cs = null ; try { cs = store . getCertificate ( alias ) ; } catch ( KeyStoreException kse ) { } if ( cs == null || ( ! ( cs instanceof X509Certificate ) ) ) { MessageFormat form = new MessageFormat ( rb . getString ( "<STR_LIT>" ) ) ; Object [ ] source = { alias , alias } ; error ( form . format ( source ) ) ; } return ( X509Certificate ) cs ; } void checkCertUsage ( X509Certificate userCert , boolean [ ] bad ) { if ( bad != null ) { bad [ <NUM_LIT:0> ] = bad [ <NUM_LIT:1> ] = bad [ <NUM_LIT:2> ] = false ; } boolean [ ] keyUsage = userCert . getKeyUsage ( ) ; if ( keyUsage != null ) { if ( keyUsage . length < <NUM_LIT:1> || ! keyUsage [ <NUM_LIT:0> ] ) { if ( bad != null ) { bad [ <NUM_LIT:0> ] = true ; } else { badKeyUsage = true ; } } } try { List < String > xKeyUsage = userCert . getExtendedKeyUsage ( ) ; if ( xKeyUsage != null ) { if ( ! xKeyUsage . contains ( "<STR_LIT>" ) && ! xKeyUsage . contains ( "<STR_LIT>" ) ) { if ( bad != null ) { bad [ <NUM_LIT:1> ] = true ; } else { badExtendedKeyUsage = true ; } } } } catch ( java . security . cert . CertificateParsingException e ) { } try { byte [ ] netscapeEx = userCert . getExtensionValue ( "<STR_LIT>" ) ; if ( netscapeEx != null ) { DerInputStream in = new DerInputStream ( netscapeEx ) ; byte [ ] encoded = in . getOctetString ( ) ; encoded = new DerValue ( encoded ) . getUnalignedBitString ( ) . toByteArray ( ) ; NetscapeCertTypeExtension extn = new NetscapeCertTypeExtension ( encoded ) ; Boolean val = ( Boolean ) extn . get ( NetscapeCertTypeExtension . OBJECT_SIGNING ) ; if ( ! val ) { if ( bad != null ) { bad [ <NUM_LIT:2> ] = true ; } else { badNetscapeCertType = true ; } } } } catch ( IOException e ) { } } void error ( String message ) throws JarSigningException { logger . error ( rb . getString ( "<STR_LIT>" ) + message ) ; throw new JarSigningException ( message ) ; } void error ( String message , Exception e ) throws JarSigningException { logger . error ( rb . getString ( "<STR_LIT>" ) + message , e ) ; throw new JarSigningException ( e . getMessage ( ) ) ; } private synchronized byte [ ] getBytes ( ZipFile zf , ZipEntry ze ) throws IOException { int n ; InputStream is = null ; try { is = zf . getInputStream ( ze ) ; baos . reset ( ) ; long left = ze . getSize ( ) ; while ( ( left > <NUM_LIT:0> ) && ( n = is . read ( buffer , <NUM_LIT:0> , buffer . length ) ) != - <NUM_LIT:1> ) { baos . write ( buffer , <NUM_LIT:0> , n ) ; left -= n ; } } finally { if ( is != null ) { is . close ( ) ; } } return baos . toByteArray ( ) ; } private ZipEntry getManifestFile ( ZipFile zf ) { ZipEntry ze = zf . getEntry ( JarFile . MANIFEST_NAME ) ; if ( ze == null ) { Enumeration < ? extends ZipEntry > enum_ = zf . entries ( ) ; while ( enum_ . hasMoreElements ( ) && ze == null ) { ze = enum_ . nextElement ( ) ; if ( ! JarFile . MANIFEST_NAME . equalsIgnoreCase ( ze . getName ( ) ) ) { ze = null ; } } } return ze ; } private synchronized String [ ] getDigests ( ZipEntry ze , ZipFile zf , MessageDigest [ ] digests , BASE64Encoder encoder ) throws IOException { int n , i ; InputStream is = null ; try { is = zf . getInputStream ( ze ) ; long left = ze . getSize ( ) ; while ( ( left > <NUM_LIT:0> ) && ( n = is . read ( buffer , <NUM_LIT:0> , buffer . length ) ) != - <NUM_LIT:1> ) { for ( i = <NUM_LIT:0> ; i < digests . length ; i ++ ) { digests [ i ] . update ( buffer , <NUM_LIT:0> , n ) ; } left -= n ; } } finally { if ( is != null ) { is . close ( ) ; } } String [ ] base64Digests = new String [ digests . length ] ; for ( i = <NUM_LIT:0> ; i < digests . length ; i ++ ) { base64Digests [ i ] = encoder . encode ( digests [ i ] . digest ( ) ) ; } return base64Digests ; } private Attributes getDigestAttributes ( ZipEntry ze , ZipFile zf , MessageDigest [ ] digests , BASE64Encoder encoder ) throws IOException { String [ ] base64Digests = getDigests ( ze , zf , digests , encoder ) ; Attributes attrs = new Attributes ( ) ; for ( int i = <NUM_LIT:0> ; i < digests . length ; i ++ ) { attrs . putValue ( digests [ i ] . getAlgorithm ( ) + "<STR_LIT>" , base64Digests [ i ] ) ; } return attrs ; } private boolean updateDigests ( ZipEntry ze , ZipFile zf , MessageDigest [ ] digests , BASE64Encoder encoder , Manifest mf ) throws IOException { boolean update = false ; Attributes attrs = mf . getAttributes ( ze . getName ( ) ) ; String [ ] base64Digests = getDigests ( ze , zf , digests , encoder ) ; for ( int i = <NUM_LIT:0> ; i < digests . length ; i ++ ) { String name = digests [ i ] . getAlgorithm ( ) + "<STR_LIT>" ; String mfDigest = attrs . getValue ( name ) ; if ( mfDigest == null && digests [ i ] . getAlgorithm ( ) . equalsIgnoreCase ( "<STR_LIT>" ) ) { mfDigest = attrs . getValue ( "<STR_LIT>" ) ; } if ( mfDigest == null ) { attrs . putValue ( name , base64Digests [ i ] ) ; update = true ; } else { if ( ! mfDigest . equalsIgnoreCase ( base64Digests [ i ] ) ) { attrs . putValue ( name , base64Digests [ i ] ) ; update = true ; } } } return update ; } void loadKeyStore ( String keyStoreName , boolean prompt ) { if ( ! nullStream && keyStoreName == null ) { keyStoreName = System . getProperty ( "<STR_LIT>" ) + File . separator + "<STR_LIT>" ; } try { if ( providerName == null ) { store = KeyStore . getInstance ( storetype ) ; } else { store = KeyStore . getInstance ( storetype , providerName ) ; } if ( nullStream ) { store . load ( null , storepass ) ; } else { keyStoreName = keyStoreName . replace ( File . separatorChar , '<CHAR_LIT:/>' ) ; URL url = null ; try { url = new URL ( keyStoreName ) ; } catch ( java . net . MalformedURLException e ) { url = new File ( keyStoreName ) . toURI ( ) . toURL ( ) ; } InputStream is = null ; try { is = url . openStream ( ) ; store . load ( is , storepass ) ; } finally { if ( is != null ) { is . close ( ) ; } } } } catch ( IOException ioe ) { throw new RuntimeException ( rb . getString ( "<STR_LIT>" ) + ioe . getMessage ( ) ) ; } catch ( java . security . cert . CertificateException ce ) { throw new RuntimeException ( rb . getString ( "<STR_LIT>" ) + ce . getMessage ( ) ) ; } catch ( NoSuchProviderException pe ) { throw new RuntimeException ( rb . getString ( "<STR_LIT>" ) + pe . getMessage ( ) ) ; } catch ( NoSuchAlgorithmException nsae ) { throw new RuntimeException ( rb . getString ( "<STR_LIT>" ) + nsae . getMessage ( ) ) ; } catch ( KeyStoreException kse ) { throw new RuntimeException ( rb . getString ( "<STR_LIT>" ) + kse . getMessage ( ) ) ; } } void getAliasInfo ( String alias ) throws JarSigningException { Key key = null ; try { java . security . cert . Certificate [ ] cs = null ; try { cs = store . getCertificateChain ( alias ) ; } catch ( KeyStoreException kse ) { } if ( cs == null ) { MessageFormat form = new MessageFormat ( rb . getString ( "<STR_LIT>" ) ) ; Object [ ] source = { alias , alias } ; error ( form . format ( source ) ) ; } certChain = new X509Certificate [ cs . length ] ; for ( int i = <NUM_LIT:0> ; i < cs . length ; i ++ ) { if ( ! ( cs [ i ] instanceof X509Certificate ) ) { error ( rb . getString ( "<STR_LIT>" ) ) ; } certChain [ i ] = ( X509Certificate ) cs [ i ] ; } X509Certificate userCert = ( X509Certificate ) store . getCertificate ( alias ) ; try { userCert . checkValidity ( ) ; if ( userCert . getNotAfter ( ) . getTime ( ) < System . currentTimeMillis ( ) + SIX_MONTHS ) { hasExpiringCert = true ; } } catch ( CertificateExpiredException cee ) { hasExpiredCert = true ; } catch ( CertificateNotYetValidException cnyve ) { notYetValidCert = true ; } checkCertUsage ( userCert , null ) ; if ( ! userCert . equals ( certChain [ <NUM_LIT:0> ] ) ) { X509Certificate [ ] certChainTmp = new X509Certificate [ certChain . length ] ; certChainTmp [ <NUM_LIT:0> ] = userCert ; Principal issuer = userCert . getIssuerDN ( ) ; for ( int i = <NUM_LIT:1> ; i < certChain . length ; i ++ ) { int j ; for ( j = <NUM_LIT:0> ; j < certChainTmp . length ; j ++ ) { if ( certChainTmp [ j ] == null ) continue ; Principal subject = certChainTmp [ j ] . getSubjectDN ( ) ; if ( issuer . equals ( subject ) ) { certChain [ i ] = certChainTmp [ j ] ; issuer = certChainTmp [ j ] . getIssuerDN ( ) ; certChainTmp [ j ] = null ; break ; } } if ( j == certChainTmp . length ) { error ( rb . getString ( "<STR_LIT>" ) ) ; } } certChain = certChainTmp ; } try { if ( ! token && keypass == null ) key = store . getKey ( alias , storepass ) ; else key = store . getKey ( alias , keypass ) ; } catch ( UnrecoverableKeyException e ) { if ( token ) { throw e ; } } } catch ( NoSuchAlgorithmException e ) { error ( e . getMessage ( ) ) ; } catch ( UnrecoverableKeyException e ) { error ( rb . getString ( "<STR_LIT>" ) ) ; } catch ( KeyStoreException kse ) { } if ( ! ( key instanceof PrivateKey ) ) { MessageFormat form = new MessageFormat ( rb . getString ( "<STR_LIT>" ) ) ; Object [ ] source = { alias } ; error ( form . format ( source ) ) ; } else { privateKey = ( PrivateKey ) key ; } } class JarBASE64Encoder extends BASE64Encoder { protected void encodeLineSuffix ( OutputStream aStream ) throws IOException { } } class SignatureFile { Manifest sf ; String baseName ; public SignatureFile ( MessageDigest digests [ ] , Manifest mf , ManifestDigester md , String baseName , boolean signManifest ) { this . baseName = baseName ; String version = System . getProperty ( "<STR_LIT>" ) ; String javaVendor = System . getProperty ( "<STR_LIT>" ) ; sf = new Manifest ( ) ; Attributes mattr = sf . getMainAttributes ( ) ; BASE64Encoder encoder = new JarBASE64Encoder ( ) ; mattr . putValue ( Attributes . Name . SIGNATURE_VERSION . toString ( ) , "<STR_LIT:1.0>" ) ; mattr . putValue ( "<STR_LIT>" , version + "<STR_LIT:U+0020(>" + javaVendor + "<STR_LIT:)>" ) ; if ( signManifest ) { for ( int i = <NUM_LIT:0> ; i < digests . length ; i ++ ) { mattr . putValue ( digests [ i ] . getAlgorithm ( ) + "<STR_LIT>" , encoder . encode ( md . manifestDigest ( digests [ i ] ) ) ) ; } } ManifestDigester . Entry mde = md . get ( ManifestDigester . MF_MAIN_ATTRS , false ) ; if ( mde != null ) { for ( int i = <NUM_LIT:0> ; i < digests . length ; i ++ ) { mattr . putValue ( digests [ i ] . getAlgorithm ( ) + "<STR_LIT>" + ManifestDigester . MF_MAIN_ATTRS , encoder . encode ( mde . digest ( digests [ i ] ) ) ) ; } } else { throw new IllegalStateException ( "<STR_LIT>" + "<STR_LIT>" ) ; } Map < String , Attributes > entries = sf . getEntries ( ) ; Iterator < Map . Entry < String , Attributes > > mit = mf . getEntries ( ) . entrySet ( ) . iterator ( ) ; while ( mit . hasNext ( ) ) { Map . Entry < String , Attributes > e = mit . next ( ) ; String name = e . getKey ( ) ; mde = md . get ( name , false ) ; if ( mde != null ) { Attributes attr = new Attributes ( ) ; for ( int i = <NUM_LIT:0> ; i < digests . length ; i ++ ) { attr . putValue ( digests [ i ] . getAlgorithm ( ) + "<STR_LIT>" , encoder . encode ( mde . digest ( digests [ i ] ) ) ) ; } entries . put ( name , attr ) ; } } } public void write ( OutputStream out ) throws IOException { sf . write ( out ) ; } public String getMetaName ( ) { return "<STR_LIT>" + baseName + "<STR_LIT>" ; } public String getBaseName ( ) { return baseName ; } public Block generateBlock ( PrivateKey privateKey , String sigalg , X509Certificate [ ] certChain , boolean externalSF , String tsaUrl , X509Certificate tsaCert , ContentSigner signingMechanism , String [ ] args , ZipFile zipFile ) throws NoSuchAlgorithmException , InvalidKeyException , IOException , SignatureException , CertificateException { return new Block ( this , privateKey , sigalg , certChain , externalSF , tsaUrl , tsaCert , signingMechanism , args , zipFile ) ; } public class Block { private byte [ ] block ; private String blockFileName ; Block ( SignatureFile sfg , PrivateKey privateKey , String sigalg , X509Certificate [ ] certChain , boolean externalSF , String tsaUrl , X509Certificate tsaCert , ContentSigner signingMechanism , String [ ] args , ZipFile zipFile ) throws NoSuchAlgorithmException , InvalidKeyException , IOException , SignatureException , CertificateException { Principal issuerName = certChain [ <NUM_LIT:0> ] . getIssuerDN ( ) ; if ( ! ( issuerName instanceof X500Name ) ) { X509CertInfo tbsCert = new X509CertInfo ( certChain [ <NUM_LIT:0> ] . getTBSCertificate ( ) ) ; issuerName = ( Principal ) tbsCert . get ( CertificateIssuerName . NAME + "<STR_LIT:.>" + CertificateIssuerName . DN_NAME ) ; } BigInteger serial = certChain [ <NUM_LIT:0> ] . getSerialNumber ( ) ; String digestAlgorithm ; String signatureAlgorithm ; String keyAlgorithm = privateKey . getAlgorithm ( ) ; if ( sigalg == null ) { if ( keyAlgorithm . equalsIgnoreCase ( "<STR_LIT>" ) ) digestAlgorithm = "<STR_LIT>" ; else if ( keyAlgorithm . equalsIgnoreCase ( "<STR_LIT>" ) ) digestAlgorithm = "<STR_LIT>" ; else { throw new RuntimeException ( "<STR_LIT>" + "<STR_LIT>" ) ; } signatureAlgorithm = digestAlgorithm + "<STR_LIT>" + keyAlgorithm ; } else { signatureAlgorithm = sigalg ; } String sigAlgUpperCase = signatureAlgorithm . toUpperCase ( ) ; if ( ( sigAlgUpperCase . endsWith ( "<STR_LIT>" ) && ! keyAlgorithm . equalsIgnoreCase ( "<STR_LIT>" ) ) || ( sigAlgUpperCase . endsWith ( "<STR_LIT>" ) && ! keyAlgorithm . equalsIgnoreCase ( "<STR_LIT>" ) ) ) { throw new SignatureException ( "<STR_LIT>" ) ; } blockFileName = "<STR_LIT>" + sfg . getBaseName ( ) + "<STR_LIT:.>" + keyAlgorithm ; AlgorithmId sigAlg = AlgorithmId . get ( signatureAlgorithm ) ; AlgorithmId digEncrAlg = AlgorithmId . get ( keyAlgorithm ) ; Signature sig = Signature . getInstance ( signatureAlgorithm ) ; sig . initSign ( privateKey ) ; ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; sfg . write ( baos ) ; byte [ ] content = baos . toByteArray ( ) ; sig . update ( content ) ; byte [ ] signature = sig . sign ( ) ; if ( signingMechanism == null ) { signingMechanism = new TimestampedSigner ( ) ; } URI tsaUri = null ; try { if ( tsaUrl != null ) { tsaUri = new URI ( tsaUrl ) ; } } catch ( URISyntaxException e ) { IOException ioe = new IOException ( ) ; ioe . initCause ( e ) ; throw ioe ; } ContentSignerParameters params = new JarSignerParameters ( args , tsaUri , tsaCert , signature , signatureAlgorithm , certChain , content , zipFile ) ; block = signingMechanism . generateSignedData ( params , externalSF , ( tsaUrl != null || tsaCert != null ) ) ; } public String getMetaName ( ) { return blockFileName ; } public void write ( OutputStream out ) throws IOException { out . write ( block ) ; } } } class JarSignerParameters implements ContentSignerParameters { private String [ ] args ; private URI tsa ; private X509Certificate tsaCertificate ; private byte [ ] signature ; private String signatureAlgorithm ; private X509Certificate [ ] signerCertificateChain ; private byte [ ] content ; private ZipFile source ; JarSignerParameters ( String [ ] args , URI tsa , X509Certificate tsaCertificate , byte [ ] signature , String signatureAlgorithm , X509Certificate [ ] signerCertificateChain , byte [ ] content , ZipFile source ) { if ( signature == null || signatureAlgorithm == null || signerCertificateChain == null ) { throw new NullPointerException ( ) ; } this . args = args ; this . tsa = tsa ; this . tsaCertificate = tsaCertificate ; this . signature = signature ; this . signatureAlgorithm = signatureAlgorithm ; this . signerCertificateChain = signerCertificateChain ; this . content = content ; this . source = source ; } public String [ ] getCommandLine ( ) { return args ; } public URI getTimestampingAuthority ( ) { return tsa ; } public X509Certificate getTimestampingAuthorityCertificate ( ) { return tsaCertificate ; } public byte [ ] getSignature ( ) { return signature ; } public String getSignatureAlgorithm ( ) { return signatureAlgorithm ; } public X509Certificate [ ] getSignerCertificateChain ( ) { return signerCertificateChain ; } public byte [ ] getContent ( ) { return content ; } public ZipFile getSource ( ) { return source ; } } } </s>
<s> package com . wuntee . oter . javatosmali ; import java . io . BufferedReader ; import java . io . BufferedWriter ; import java . io . File ; import java . io . FileReader ; import java . io . FileWriter ; import java . io . IOException ; import java . util . Map ; import org . apache . commons . lang3 . StringUtils ; import org . apache . log4j . Logger ; import com . wuntee . oter . OterStatics ; import com . wuntee . oter . OterWorkshop ; import com . wuntee . oter . command . TerminatingCommand ; import com . wuntee . oter . exception . CommandFailedException ; import com . wuntee . oter . exception . UnknownClassnameException ; import com . wuntee . oter . smali . SmaliWorkshop ; public class JavaToSmaliWorkshop { private static Logger logger = Logger . getLogger ( JavaToSmaliController . class ) ; public static boolean isValidJava ( String java ) { return ( true ) ; } public static File writeJavaToFile ( String javaSource ) throws IOException , UnknownClassnameException { String className = findClassNameFromJavaSource ( javaSource ) ; if ( className == null ) { logger . error ( "<STR_LIT>" ) ; throw new UnknownClassnameException ( ) ; } File tempDir = OterWorkshop . createTemporaryDirectory ( "<STR_LIT>" ) ; tempDir . deleteOnExit ( ) ; File javaSourceFile = new File ( tempDir , className + "<STR_LIT>" ) ; BufferedWriter out = new BufferedWriter ( new FileWriter ( javaSourceFile ) ) ; out . write ( javaSource ) ; out . close ( ) ; return ( javaSourceFile ) ; } public static String findClassNameFromJavaSource ( String javaSource ) { javaSource = javaSource . replace ( "<STR_LIT:n>" , "<STR_LIT:U+0020>" ) ; if ( javaSource . matches ( "<STR_LIT>" ) ) { int startIndex = javaSource . indexOf ( "<STR_LIT:class>" ) + "<STR_LIT:class>" . length ( ) ; int endIndex = javaSource . indexOf ( "<STR_LIT:{>" ) ; return ( javaSource . substring ( startIndex , endIndex ) . trim ( ) ) ; } return ( null ) ; } public static String javaSourceToSmali ( String javaSourceText , String classpathString ) throws Exception { File javaSource ; String className ; String classFile ; try { className = JavaToSmaliWorkshop . findClassNameFromJavaSource ( javaSourceText ) ; classFile = className + "<STR_LIT>" ; javaSource = JavaToSmaliWorkshop . writeJavaToFile ( javaSourceText ) ; } catch ( IOException e ) { logger . error ( "<STR_LIT>" + e . getMessage ( ) ) ; throw new Exception ( "<STR_LIT>" ) ; } catch ( UnknownClassnameException e ) { logger . error ( "<STR_LIT>" + e . getMessage ( ) ) ; throw new Exception ( "<STR_LIT>" ) ; } logger . debug ( "<STR_LIT>" ) ; TerminatingCommand javacCmd = null ; if ( classpathString != null ) { javacCmd = new TerminatingCommand ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" , classpathString , javaSource . getAbsolutePath ( ) } ) ; } else { javacCmd = new TerminatingCommand ( new String [ ] { "<STR_LIT>" , javaSource . getAbsolutePath ( ) } ) ; } javacCmd . execute ( ) ; try { logger . debug ( "<STR_LIT>" ) ; TerminatingCommand dxCommand = new TerminatingCommand ( new String [ ] { OterStatics . getDxCommand ( ) , "<STR_LIT>" + classFile , "<STR_LIT>" , className + "<STR_LIT:.class>" } , javaSource . getParentFile ( ) ) ; dxCommand . execute ( ) ; } catch ( Exception e ) { logger . debug ( "<STR_LIT>" + e . getMessage ( ) ) ; throw new Exception ( "<STR_LIT>" ) ; } try { logger . debug ( "<STR_LIT>" ) ; File dexFile = new File ( javaSource . getParentFile ( ) + System . getProperty ( "<STR_LIT>" ) + classFile ) ; Map < String , File > smaliMap = SmaliWorkshop . getSmaliSource ( dexFile , javaSource . getParentFile ( ) ) ; logger . debug ( "<STR_LIT>" + smaliMap . size ( ) ) ; File smaliSourceFile = ( File ) smaliMap . values ( ) . toArray ( ) [ <NUM_LIT:0> ] ; BufferedReader in = new BufferedReader ( new FileReader ( smaliSourceFile ) ) ; String buf = "<STR_LIT>" ; String str ; while ( ( str = in . readLine ( ) ) != null ) { buf = buf + str + "<STR_LIT:n>" ; } return ( buf ) ; } catch ( Exception e ) { logger . debug ( "<STR_LIT>" + e . getMessage ( ) ) ; throw new Exception ( "<STR_LIT>" ) ; } } } </s>
<s> package com . wuntee . oter . javatosmali ; import org . apache . log4j . Logger ; import org . eclipse . swt . custom . StyledText ; import com . wuntee . oter . OterStatics ; import com . wuntee . oter . OterWorkshop ; import com . wuntee . oter . exception . CommandFailedException ; import com . wuntee . oter . styler . SmaliLineStyler ; import com . wuntee . oter . view . Gui ; public class JavaToSmaliController { private static Logger logger = Logger . getLogger ( JavaToSmaliController . class ) ; private Gui gui ; public JavaToSmaliController ( Gui gui ) { this . gui = gui ; } public void tryToCompileJava ( StyledText javaStyledText , StyledText smaliStyledText ) { gui . setStatus ( "<STR_LIT>" ) ; gui . runRunnableAsync ( new TryToCompileJavaToSmali ( javaStyledText , smaliStyledText ) ) ; } public class TryToCompileJavaToSmali implements Runnable { private StyledText javaStyledText ; private StyledText smaliStyledText ; public TryToCompileJavaToSmali ( StyledText javaStyledText , StyledText smaliStyledText ) { this . javaStyledText = javaStyledText ; this . smaliStyledText = smaliStyledText ; } public void run ( ) { smaliStyledText . setText ( "<STR_LIT>" ) ; try { smaliStyledText . setText ( JavaToSmaliWorkshop . javaSourceToSmali ( javaStyledText . getText ( ) , OterWorkshop . getProperty ( OterStatics . PROPERTY_JAVATOSMALI_CLASSPATH ) ) ) ; gui . clearStatus ( ) ; } catch ( CommandFailedException e ) { smaliStyledText . setText ( e . getMessage ( ) ) ; gui . setStatus ( "<STR_LIT>" ) ; } catch ( Exception e ) { gui . setStatus ( "<STR_LIT>" + e . getMessage ( ) ) ; } } } } </s>
<s> package com . wuntee . oter ; import java . io . BufferedInputStream ; import java . io . BufferedOutputStream ; import java . io . File ; import java . io . FileInputStream ; import java . io . FileNotFoundException ; import java . io . FileOutputStream ; import java . io . IOException ; import java . util . Collection ; import java . util . Enumeration ; import java . util . LinkedList ; import java . util . List ; import java . util . Properties ; import java . util . zip . ZipEntry ; import java . util . zip . ZipFile ; import java . util . zip . ZipOutputStream ; import org . apache . commons . io . FileUtils ; import org . apache . commons . io . FilenameUtils ; import org . apache . commons . io . IOUtils ; import org . apache . log4j . Logger ; import com . wuntee . oter . command . TerminatingCommand ; public class OterWorkshop { private static Logger logger = Logger . getLogger ( OterWorkshop . class ) ; public static void addAndroidjarToClasspath ( ) throws Exception { String androidHome = getProperty ( OterStatics . PROPERTY_ANDROID_HOME ) ; if ( androidHome == null ) { throw new Exception ( "<STR_LIT>" ) ; } Collection < File > files = FileUtils . listFiles ( new File ( androidHome ) , new String [ ] { "<STR_LIT>" } , true ) ; for ( File f : files ) { if ( f . getAbsolutePath ( ) . endsWith ( "<STR_LIT>" ) ) { Properties prop = getProperties ( ) ; String currentClasspath = prop . getProperty ( OterStatics . PROPERTY_JAVATOSMALI_CLASSPATH ) ; String newClasspath = "<STR_LIT>" ; if ( currentClasspath . split ( "<STR_LIT::>" ) . length == <NUM_LIT:0> ) { newClasspath = f . getAbsolutePath ( ) ; } else { newClasspath = currentClasspath + "<STR_LIT::>" + f . getAbsolutePath ( ) ; } prop . setProperty ( OterStatics . PROPERTY_JAVATOSMALI_CLASSPATH , newClasspath ) ; writeProp ( prop , new File ( OterStatics . getConfigFileName ( ) ) ) ; return ; } } throw new Exception ( "<STR_LIT>" + androidHome ) ; } public static String getProperty ( String key ) { return ( getProperties ( ) . getProperty ( key ) ) ; } public static Properties getProperties ( ) { Properties prop = new Properties ( ) ; File propFile = new File ( OterStatics . getConfigFileName ( ) ) ; if ( propFile . exists ( ) == false ) { writeDefaultProp ( propFile ) ; } else { logger . info ( "<STR_LIT>" + OterStatics . getConfigFileName ( ) ) ; try { prop . load ( new FileInputStream ( OterStatics . getConfigFileName ( ) ) ) ; } catch ( FileNotFoundException e ) { logger . error ( "<STR_LIT>" + e . getMessage ( ) ) ; } catch ( IOException e ) { logger . error ( "<STR_LIT>" ) ; prop = getDefaultProp ( ) ; } if ( prop . isEmpty ( ) || prop . get ( OterStatics . PROPERTY_LOGCAT_MAXLINES ) == null ) { prop = writeDefaultProp ( propFile ) ; } } return ( prop ) ; } private static Properties writeDefaultProp ( File propFile ) { Properties prop = getDefaultProp ( ) ; writeProp ( prop , propFile ) ; return ( prop ) ; } private static Properties writeProp ( Properties prop , File propFile ) { try { prop . store ( new FileOutputStream ( propFile ) , null ) ; } catch ( Exception e ) { logger . error ( "<STR_LIT>" , e ) ; } return ( prop ) ; } private static Properties getDefaultProp ( ) { Properties prop = new Properties ( ) ; prop . put ( OterStatics . PROPERTY_LOGCAT_MAXLINES , "<STR_LIT>" ) ; return ( prop ) ; } public static File createTemporaryDirectory ( String prefix ) throws IOException { File tmp = File . createTempFile ( prefix , Long . toString ( System . nanoTime ( ) ) ) ; logger . debug ( "<STR_LIT>" + tmp . getAbsolutePath ( ) ) ; tmp . delete ( ) ; tmp . mkdir ( ) ; tmp . deleteOnExit ( ) ; return ( tmp ) ; } public static File createDirectoryRecursive ( String directory ) throws IOException { File f = new File ( FilenameUtils . separatorsToSystem ( directory ) ) ; FileUtils . forceMkdir ( f ) ; return ( f ) ; } public static void unzipArchive ( File archive , File outputDir ) { try { ZipFile zipfile = new ZipFile ( archive ) ; for ( Enumeration e = zipfile . entries ( ) ; e . hasMoreElements ( ) ; ) { ZipEntry entry = ( ZipEntry ) e . nextElement ( ) ; unzipEntry ( zipfile , entry , outputDir ) ; } } catch ( Exception e ) { logger . error ( "<STR_LIT>" + archive , e ) ; } } private static void unzipEntry ( ZipFile zipfile , ZipEntry entry , File outputDir ) throws IOException { if ( entry . isDirectory ( ) ) { createDir ( new File ( outputDir , entry . getName ( ) ) ) ; } else { File outputFile = new File ( outputDir , entry . getName ( ) ) ; if ( ! outputFile . getParentFile ( ) . exists ( ) ) { createDir ( outputFile . getParentFile ( ) ) ; } logger . debug ( "<STR_LIT>" + entry ) ; BufferedInputStream inputStream = new BufferedInputStream ( zipfile . getInputStream ( entry ) ) ; BufferedOutputStream outputStream = new BufferedOutputStream ( new FileOutputStream ( outputFile ) ) ; try { IOUtils . copy ( inputStream , outputStream ) ; } finally { outputStream . close ( ) ; inputStream . close ( ) ; } } } private static void createDir ( File dir ) { logger . debug ( "<STR_LIT>" + dir . getName ( ) ) ; dir . mkdirs ( ) ; } public static void zipArchive ( File destArchive , File baseDirectory ) throws IOException { logger . debug ( "<STR_LIT>" + destArchive + "<STR_LIT>" + baseDirectory ) ; ZipOutputStream out = new ZipOutputStream ( new BufferedOutputStream ( new FileOutputStream ( destArchive ) ) ) ; addDirToZip ( baseDirectory , baseDirectory , out ) ; out . close ( ) ; } private static void addDirToZip ( File baseDirectory , File directory , ZipOutputStream zipOutputStream ) throws IOException { String [ ] files = directory . list ( ) ; for ( String file : files ) { String fullFilePath = directory . getAbsoluteFile ( ) + System . getProperty ( "<STR_LIT>" ) + file ; File fullFilePathFileObj = new File ( fullFilePath ) ; String zipFilePath = fullFilePath . substring ( baseDirectory . getAbsolutePath ( ) . length ( ) + <NUM_LIT:1> ) ; logger . debug ( "<STR_LIT>" + zipFilePath ) ; if ( fullFilePathFileObj . isDirectory ( ) ) { addDirToZip ( baseDirectory , fullFilePathFileObj , zipOutputStream ) ; } else { addFileToZip ( zipFilePath , fullFilePath , zipOutputStream ) ; } } } private static void addFileToZip ( String zipFilePath , String fullFilePath , ZipOutputStream zipOutputStream ) throws IOException { int BUFFER_SIZE = <NUM_LIT> ; ZipEntry entry = new ZipEntry ( zipFilePath ) ; zipOutputStream . putNextEntry ( entry ) ; FileInputStream fis = new FileInputStream ( fullFilePath ) ; BufferedInputStream origin = new BufferedInputStream ( fis , BUFFER_SIZE ) ; byte data [ ] = new byte [ BUFFER_SIZE ] ; int count ; while ( ( count = origin . read ( data , <NUM_LIT:0> , BUFFER_SIZE ) ) != - <NUM_LIT:1> ) { zipOutputStream . write ( data , <NUM_LIT:0> , count ) ; } origin . close ( ) ; } public static String classPathToFilePath ( String clazz ) { return ( clazz . replace ( "<STR_LIT:.>" , System . getProperty ( "<STR_LIT>" ) ) ) ; } } </s>
<s> package com . wuntee . oter . testing ; import com . android . ddmlib . AndroidDebugBridge ; import com . android . ddmlib . Client ; import com . android . ddmlib . IDevice ; public class Test { public static void main ( String [ ] args ) throws InterruptedException { AndroidDebugBridge . init ( true ) ; AndroidDebugBridge adb = AndroidDebugBridge . createBridge ( "<STR_LIT>" , true ) ; while ( ! adb . hasInitialDeviceList ( ) ) { System . out . println ( "<STR_LIT>" ) ; Thread . sleep ( <NUM_LIT:1000> ) ; } for ( IDevice dev : adb . getDevices ( ) ) { System . out . println ( dev ) ; for ( Client client : dev . getClients ( ) ) { System . out . println ( "<STR_LIT>" + client ) ; } } IDevice dev = adb . getDevices ( ) [ <NUM_LIT:0> ] ; Client cli = dev . getClients ( ) [ <NUM_LIT:0> ] ; AndroidDebugBridge . disconnectBridge ( ) ; } } </s>
<s> package com . wuntee . oter . adb ; import java . io . File ; import java . io . FileInputStream ; import java . io . FileOutputStream ; import java . io . IOException ; import java . security . KeyStore ; import java . security . Security ; import java . security . cert . Certificate ; import java . security . cert . CertificateFactory ; import java . util . LinkedList ; import java . util . List ; import org . apache . log4j . Logger ; import org . bouncycastle . jce . provider . BouncyCastleProvider ; import com . wuntee . oter . OterStatics ; import com . wuntee . oter . command . TerminatingCommand ; import com . wuntee . oter . exception . AatException ; import com . wuntee . oter . exception . CommandFailedException ; import com . wuntee . oter . exception . NotRootedException ; import com . wuntee . oter . exception . ParseException ; import com . wuntee . oter . exception . UninstallException ; import com . wuntee . oter . packagemanager . PackageBean ; public class AdbWorkshop { private static Logger logger = Logger . getLogger ( AdbWorkshop . class ) ; public static List < String > getDeviceList ( ) { TerminatingCommand c = AdbWorkshop . getTerminatingAdbCommand ( new String [ ] { "<STR_LIT>" } ) ; List < String > ret = new LinkedList < String > ( ) ; try { c . execute ( ) ; for ( String l : c . getOutput ( ) ) { if ( ! l . startsWith ( "<STR_LIT>" ) && ! l . trim ( ) . equals ( "<STR_LIT>" ) ) { ret . add ( l . trim ( ) . split ( "<STR_LIT>" ) [ <NUM_LIT:0> ] ) ; } } } catch ( Exception e ) { logger . error ( "<STR_LIT>" , e ) ; } return ( ret ) ; } public static TerminatingCommand getTerminatingAdbCommand ( String [ ] args ) { return ( new TerminatingAdbCommand ( args ) ) ; } public static boolean isConnected ( ) { TerminatingCommand c = AdbWorkshop . getTerminatingAdbCommand ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" } ) ; try { int ret = c . execute ( ) ; if ( ret == <NUM_LIT:0> ) { return ( true ) ; } } catch ( Exception e ) { logger . error ( "<STR_LIT>" , e ) ; } return ( false ) ; } public static void installApk ( String apk ) throws IOException , InterruptedException , CommandFailedException { TerminatingCommand c = AdbWorkshop . getTerminatingAdbCommand ( new String [ ] { "<STR_LIT>" , apk } ) ; c . execute ( ) ; for ( String l : c . getOutput ( ) ) { if ( l . matches ( "<STR_LIT>" ) ) { throw new CommandFailedException ( c . getCommand ( ) , c . getOutput ( ) , l ) ; } } } public static void restartAdb ( ) throws IOException , InterruptedException , CommandFailedException { TerminatingCommand c = AdbWorkshop . getTerminatingAdbCommand ( new String [ ] { "<STR_LIT>" } ) ; c . execute ( ) ; c = AdbWorkshop . getTerminatingAdbCommand ( new String [ ] { "<STR_LIT>" } ) ; c . execute ( ) ; } public static File pullFileTo ( String remoteFile , String localFile ) throws IOException , InterruptedException , CommandFailedException { TerminatingCommand c = AdbWorkshop . getTerminatingAdbCommand ( new String [ ] { "<STR_LIT>" , remoteFile , localFile } ) ; c . execute ( ) ; return ( new File ( localFile ) ) ; } public static File pullFile ( String remoteFile ) throws IOException , InterruptedException , CommandFailedException { File tmpFile = AdbWorkshop . getTemporaryFile ( ) ; TerminatingCommand c = AdbWorkshop . getTerminatingAdbCommand ( new String [ ] { "<STR_LIT>" , remoteFile , tmpFile . getAbsolutePath ( ) } ) ; c . execute ( ) ; return ( tmpFile ) ; } public static File pushFile ( File localFile , String remotePath ) throws IOException , InterruptedException , CommandFailedException { File tmpFile = AdbWorkshop . getTemporaryFile ( ) ; TerminatingCommand c = AdbWorkshop . getTerminatingAdbCommand ( new String [ ] { "<STR_LIT>" , localFile . getAbsolutePath ( ) , remotePath } ) ; c . execute ( ) ; return ( tmpFile ) ; } public static void mountFilesystemReadWrite ( ) throws IOException , InterruptedException , CommandFailedException , AatException { TerminatingCommand c = AdbWorkshop . getTerminatingAdbCommand ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , AdbWorkshop . findSystemDirectory ( ) , "<STR_LIT>" } ) ; c . execute ( ) ; } public static void changeFilePermissions ( String filename , String permissions ) throws IOException , InterruptedException , CommandFailedException { TerminatingCommand c = AdbWorkshop . getTerminatingAdbCommand ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" , permissions , filename } ) ; c . execute ( ) ; } public static File getTemporaryFile ( ) throws IOException { File tmp = File . createTempFile ( "<STR_LIT>" , Long . toString ( System . nanoTime ( ) ) ) ; tmp . delete ( ) ; return ( tmp ) ; } public static boolean canGetRoot ( ) throws Exception { AdbShell tmpShell = new AdbShell ( ) ; tmpShell . start ( ) ; try { tmpShell . getRootShell ( ) ; return ( true ) ; } catch ( Exception e ) { return ( false ) ; } finally { tmpShell . close ( ) ; } } public static List < String > runAdbCommand ( String [ ] cmd ) throws IOException , InterruptedException , CommandFailedException { TerminatingCommand tc = AdbWorkshop . getTerminatingAdbCommand ( cmd ) ; tc . execute ( ) ; return ( tc . getOutput ( ) ) ; } public static void installCert ( File certfile , String password ) throws NotRootedException , Exception { if ( ! AdbWorkshop . canGetRoot ( ) ) { throw new NotRootedException ( ) ; } Security . addProvider ( new BouncyCastleProvider ( ) ) ; logger . debug ( "<STR_LIT>" ) ; File cacerts = AdbWorkshop . pullFile ( OterStatics . ANDROID_CERT_FILE ) ; KeyStore ks = KeyStore . getInstance ( "<STR_LIT>" ) ; FileInputStream fis = new java . io . FileInputStream ( cacerts ) ; ks . load ( fis , password . toCharArray ( ) ) ; logger . debug ( "<STR_LIT>" + certfile . getName ( ) ) ; FileInputStream is = new FileInputStream ( certfile ) ; CertificateFactory cf = CertificateFactory . getInstance ( "<STR_LIT>" ) ; Certificate cert = cf . generateCertificate ( is ) ; ks . setCertificateEntry ( certfile . getName ( ) , cert ) ; logger . debug ( "<STR_LIT>" ) ; File localFile = AdbWorkshop . getTemporaryFile ( ) ; FileOutputStream fos = new java . io . FileOutputStream ( localFile ) ; ks . store ( fos , password . toCharArray ( ) ) ; logger . debug ( "<STR_LIT>" ) ; AdbWorkshop . mountFilesystemReadWrite ( ) ; logger . debug ( "<STR_LIT>" ) ; AdbWorkshop . changeFilePermissions ( OterStatics . ANDROID_CERT_FILE , "<STR_LIT>" ) ; logger . debug ( "<STR_LIT>" ) ; AdbWorkshop . pushFile ( localFile , OterStatics . ANDROID_CERT_FILE ) ; logger . debug ( "<STR_LIT>" ) ; AdbWorkshop . changeFilePermissions ( OterStatics . ANDROID_CERT_FILE , "<STR_LIT>" ) ; logger . debug ( "<STR_LIT>" + localFile ) ; localFile . delete ( ) ; } public static String findSystemDirectory ( ) throws IOException , InterruptedException , CommandFailedException , AatException { logger . debug ( "<STR_LIT>" ) ; List < String > mountCmd = AdbWorkshop . runAdbCommand ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" } ) ; for ( String out : mountCmd ) { if ( out . matches ( "<STR_LIT>" ) ) { logger . debug ( "<STR_LIT>" + out ) ; String ret = out . split ( "<STR_LIT:U+0020>" ) [ <NUM_LIT:0> ] ; logger . debug ( "<STR_LIT>" + ret ) ; return ( ret ) ; } } throw new AatException ( "<STR_LIT>" ) ; } public static List < PackageBean > listPackages ( ) throws IOException , InterruptedException , CommandFailedException , ParseException { logger . debug ( "<STR_LIT>" ) ; List < String > packageStrings = AdbWorkshop . runAdbCommand ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:list>" , "<STR_LIT>" , "<STR_LIT>" } ) ; List < PackageBean > ret = new LinkedList < PackageBean > ( ) ; for ( String s : packageStrings ) { ret . add ( PackageBean . parse ( s ) ) ; } return ( ret ) ; } public static void uninstallPackage ( String clazz ) throws IOException , InterruptedException , CommandFailedException , UninstallException { logger . debug ( "<STR_LIT>" + clazz ) ; List < String > out = AdbWorkshop . runAdbCommand ( new String [ ] { "<STR_LIT>" , clazz } ) ; for ( String s : out ) { if ( s . toLowerCase ( ) . matches ( "<STR_LIT>" ) == true ) { throw new UninstallException ( s ) ; } } } } </s>
<s> package com . wuntee . oter . adb ; import java . util . LinkedList ; import java . util . List ; import org . apache . log4j . Logger ; import com . wuntee . oter . OterStatics ; import com . wuntee . oter . OterWorkshop ; import com . wuntee . oter . command . TerminatingCommand ; public class TerminatingAdbCommand extends TerminatingCommand { private static Logger logger = Logger . getLogger ( TerminatingAdbCommand . class ) ; public TerminatingAdbCommand ( String [ ] command ) { super ( getAdbArray ( command ) ) ; } private static String [ ] getAdbArray ( String [ ] command ) { List < String > cmd = new LinkedList < String > ( ) ; cmd . add ( OterStatics . getAdbExecutable ( ) ) ; String device = OterWorkshop . getProperty ( OterStatics . PROPERTY_DEVICE ) ; if ( device != null ) { cmd . add ( "<STR_LIT>" ) ; cmd . add ( device ) ; } for ( String a : command ) { cmd . add ( a ) ; } logger . debug ( cmd ) ; return ( cmd . toArray ( command ) ) ; } } </s>
<s> package com . wuntee . oter . adb ; import java . io . IOException ; import java . util . LinkedList ; import java . util . List ; import org . apache . log4j . Logger ; import com . wuntee . oter . OterStatics ; import com . wuntee . oter . exception . CommandFailedException ; public class AdbShell extends BackgroundAdbCommand { public static void main ( String [ ] args ) throws Exception { AdbShell s = new AdbShell ( ) ; s . start ( ) ; s . getRootShell ( ) ; } private static Logger logger = Logger . getLogger ( AdbShell . class ) ; private String prompt ; public AdbShell ( ) { super ( "<STR_LIT>" ) ; } public boolean isRootShell ( ) { return ( prompt . equals ( OterStatics . ADB_ROOT_SHELL ) ) ; } public int start ( ) throws Exception { return ( execute ( ) ) ; } public int execute ( ) throws Exception { super . execute ( ) ; waitForNewPrompt ( ) ; return ( <NUM_LIT:0> ) ; } private List < String > waitForNewPrompt ( ) throws IOException { List < String > ret = new LinkedList < String > ( ) ; String line = "<STR_LIT>" ; while ( ! isPrompt ( line ) ) { char c = ( char ) this . stdout . read ( ) ; if ( c == '<STR_LIT>' || c == '<STR_LIT:\n>' ) { if ( ! line . trim ( ) . equals ( "<STR_LIT>" ) ) { logger . debug ( "<STR_LIT>" + line ) ; ret . add ( line ) ; } line = "<STR_LIT>" ; } else { line = line + c ; } } this . prompt = line ; logger . debug ( "<STR_LIT>" + line + "<STR_LIT:'>" ) ; return ( ret ) ; } private boolean isPrompt ( String line ) { for ( String prompt : OterStatics . ADB_SHELLS ) { if ( line . equals ( prompt ) ) { return ( true ) ; } } return ( false ) ; } public List < String > sendCommand ( String command ) throws IOException , CommandFailedException { List < String > ret = _sendCommand ( command ) ; List < String > code = _sendCommand ( "<STR_LIT>" ) ; if ( ! code . get ( <NUM_LIT:0> ) . equals ( "<STR_LIT:0>" ) ) { throw new CommandFailedException ( command , ret , code . get ( <NUM_LIT:0> ) ) ; } return ( ret ) ; } private List < String > _sendCommand ( String command ) throws IOException { logger . debug ( "<STR_LIT>" + command ) ; List < String > ret = new LinkedList < String > ( ) ; this . stdin . write ( command + "<STR_LIT:n>" ) ; this . stdin . flush ( ) ; logger . debug ( "<STR_LIT>" ) ; String line = "<STR_LIT>" ; while ( ! line . equals ( prompt ) ) { char c = ( char ) this . stdout . read ( ) ; if ( c == '<STR_LIT>' || c == '<STR_LIT:\n>' ) { if ( ! line . trim ( ) . equals ( "<STR_LIT>" ) ) { logger . debug ( "<STR_LIT>" + line ) ; ret . add ( line ) ; } line = "<STR_LIT>" ; } else { line = line + c ; } } ret = ret . subList ( <NUM_LIT:1> , ret . size ( ) ) ; logger . debug ( "<STR_LIT>" + ret ) ; return ( ret ) ; } public void getRootShell ( ) throws IOException , CommandFailedException { if ( ! isRootShell ( ) ) { logger . debug ( "<STR_LIT>" ) ; this . stdin . write ( "<STR_LIT>" ) ; this . stdin . flush ( ) ; logger . debug ( "<STR_LIT>" ) ; List < String > line = waitForNewPrompt ( ) ; if ( ! this . isRootShell ( ) ) { throw new CommandFailedException ( "<STR_LIT>" , line , "<STR_LIT:-1>" ) ; } logger . debug ( "<STR_LIT>" ) ; } else { logger . debug ( "<STR_LIT>" ) ; } } } </s>
<s> package com . wuntee . oter . adb ; import org . apache . log4j . Logger ; import com . wuntee . oter . OterStatics ; import com . wuntee . oter . command . BackgroundCommand ; import com . wuntee . oter . exception . CommandExecutionException ; public class BackgroundAdbCommand extends BackgroundCommand { private static Logger logger = Logger . getLogger ( BackgroundAdbCommand . class ) ; public BackgroundAdbCommand ( String command ) { super ( new String [ ] { OterStatics . getAdbExecutable ( ) , command } ) ; } public BackgroundAdbCommand ( String command [ ] ) { super ( command ) ; String [ ] newCommand = new String [ command . length + <NUM_LIT:1> ] ; newCommand [ <NUM_LIT:0> ] = OterStatics . getAdbExecutable ( ) ; for ( int i = <NUM_LIT:0> ; i < command . length ; i ++ ) { newCommand [ i + <NUM_LIT:1> ] = command [ i ] ; } this . command = newCommand ; } public int execute ( ) throws Exception { logger . debug ( "<STR_LIT>" ) ; if ( ! AdbWorkshop . isConnected ( ) ) { throw new CommandExecutionException ( "<STR_LIT>" ) ; } return ( super . execute ( ) ) ; } } </s>
<s> package com . wuntee . oter . styler ; import java . util . HashMap ; import java . util . LinkedList ; import java . util . List ; import java . util . Map ; import org . apache . log4j . Logger ; import org . eclipse . swt . SWT ; import org . eclipse . swt . custom . LineStyleEvent ; import org . eclipse . swt . custom . LineStyleListener ; import org . eclipse . swt . custom . StyleRange ; import org . eclipse . swt . graphics . Color ; import org . eclipse . swt . graphics . RGB ; import org . eclipse . swt . widgets . Display ; public class SmaliLineStyler implements LineStyleListener { private static Logger logger = Logger . getLogger ( SmaliLineStyler . class ) ; private Display display ; private Map < String , Color > colorMap ; public SmaliLineStyler ( ) { this . display = Display . getDefault ( ) ; colorMap = new HashMap < String , Color > ( ) ; colorMap . put ( "<STR_LIT>" , new Color ( display , new RGB ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:255> ) ) ) ; colorMap . put ( "<STR_LIT>" , display . getSystemColor ( SWT . COLOR_DARK_GREEN ) ) ; colorMap . put ( "<STR_LIT>" , new Color ( display , new RGB ( <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> ) ) ) ; colorMap . put ( "<STR_LIT>" , display . getSystemColor ( SWT . COLOR_DARK_CYAN ) ) ; colorMap . put ( "<STR_LIT>" , display . getSystemColor ( SWT . COLOR_DARK_RED ) ) ; } public void lineGetStyle ( LineStyleEvent event ) { boolean midStyle = false ; int start = <NUM_LIT:0> ; char terminator = '<CHAR_LIT:;>' ; char lastChar = '<CHAR_LIT>' ; List < StyleRange > styles = new LinkedList < StyleRange > ( ) ; StyleRange x = new StyleRange ( ) ; StyleRange style = null ; for ( int i = <NUM_LIT:0> ; i < event . lineText . length ( ) ; i ++ ) { char subj = event . lineText . charAt ( i ) ; if ( midStyle == false ) { if ( subj == '<CHAR_LIT>' ) { logger . debug ( "<STR_LIT>" ) ; style = new StyleRange ( ) ; style . start = event . lineOffset + i ; style . foreground = colorMap . get ( "<STR_LIT>" ) ; midStyle = true ; start = i ; } else if ( subj == '<CHAR_LIT:">' || subj == '<STR_LIT>' ) { logger . debug ( "<STR_LIT>" ) ; style = new StyleRange ( ) ; style . start = event . lineOffset + i ; style . foreground = colorMap . get ( "<STR_LIT>" ) ; midStyle = true ; start = i ; } else if ( subj == '<CHAR_LIT::>' && lastChar == '<CHAR_LIT:U+0020>' ) { logger . debug ( "<STR_LIT>" ) ; style = new StyleRange ( ) ; style . start = event . lineOffset + i ; style . foreground = colorMap . get ( "<STR_LIT>" ) ; terminator = '<CHAR_LIT:U+0020>' ; midStyle = true ; start = i ; } else if ( subj == '<CHAR_LIT:.>' ) { logger . debug ( "<STR_LIT>" ) ; style = new StyleRange ( ) ; style . start = event . lineOffset + i ; style . foreground = colorMap . get ( "<STR_LIT>" ) ; terminator = '<CHAR_LIT:U+0020>' ; midStyle = true ; start = i ; } } else { if ( i == event . lineText . length ( ) - <NUM_LIT:1> ) { style . length = event . lineText . length ( ) - start ; styles . add ( style ) ; logger . debug ( "<STR_LIT>" + style . start + "<STR_LIT>" + style . length ) ; midStyle = false ; start = <NUM_LIT:0> ; } else { if ( subj == '<CHAR_LIT:;>' ) { } else if ( subj == '<CHAR_LIT:">' || subj == '<STR_LIT>' ) { style . length = i - start ; styles . add ( style ) ; logger . debug ( "<STR_LIT>" + style . start + "<STR_LIT>" + style . length ) ; midStyle = false ; start = <NUM_LIT:0> ; terminator = '<CHAR_LIT:;>' ; } else if ( subj == '<CHAR_LIT:}>' || subj == '<CHAR_LIT:U+002C>' ) { style . length = i - start ; styles . add ( style ) ; logger . debug ( "<STR_LIT>" + style . start + "<STR_LIT>" + style . length ) ; midStyle = false ; start = <NUM_LIT:0> ; terminator = '<CHAR_LIT:;>' ; } else if ( subj == terminator ) { style . length = i - start ; styles . add ( style ) ; logger . debug ( "<STR_LIT>" + style . start + "<STR_LIT>" + style . length ) ; midStyle = false ; start = <NUM_LIT:0> ; terminator = '<CHAR_LIT:;>' ; } } } lastChar = subj ; } if ( style != null ) { styles . add ( style ) ; } event . styles = ( StyleRange [ ] ) styles . toArray ( new StyleRange [ <NUM_LIT:0> ] ) ; } } </s>
<s> package com . wuntee . oter . fs ; import java . io . IOException ; import java . util . LinkedList ; import java . util . List ; import org . apache . log4j . Logger ; import com . wuntee . oter . OterStatics ; import com . wuntee . oter . adb . AdbShell ; import com . wuntee . oter . exception . CommandFailedException ; public class FsWorkshop { private static Logger logger = Logger . getLogger ( FsNode . class ) ; public static List < FsNode > getFilesystem ( ) throws Exception { AdbShell shell = new AdbShell ( ) ; shell . execute ( ) ; return ( listDirectoryRecursive ( "<STR_LIT:/>" , shell ) ) ; } public static List < FsNode > getDirectoryRecursive ( String directory ) throws Exception { AdbShell shell = new AdbShell ( ) ; shell . execute ( ) ; return ( listDirectoryRecursive ( directory , shell ) ) ; } private static List < FsNode > listDirectoryRecursive ( String root , AdbShell shell ) throws IOException , CommandFailedException { logger . debug ( "<STR_LIT>" + root ) ; List < FsNode > ret = new LinkedList < FsNode > ( ) ; List < String > lines = shell . sendCommand ( "<STR_LIT>" + root ) ; for ( String line : lines ) { FsNode node = FsNode . getNode ( line , root ) ; if ( ! isBadDirectory ( node . getFullPath ( ) ) ) { if ( node . getType ( ) . equals ( "<STR_LIT:d>" ) ) { logger . debug ( "<STR_LIT>" + node . getFullPath ( ) ) ; List < FsNode > secRet = listDirectoryRecursive ( node . getFullPath ( ) , shell ) ; for ( FsNode sec : secRet ) { node . addChild ( sec ) ; } } logger . debug ( "<STR_LIT>" + node . getName ( ) + "<STR_LIT>" + node . getChildren ( ) . size ( ) ) ; ret . add ( node ) ; } } return ( ret ) ; } public static boolean isBadDirectory ( String dir ) { logger . debug ( "<STR_LIT>" + dir ) ; for ( String bad : OterStatics . BAD_DIRECTORIES ) { if ( dir . equals ( bad ) ) { logger . debug ( "<STR_LIT>" ) ; return ( true ) ; } } logger . debug ( "<STR_LIT>" ) ; return ( false ) ; } } </s>
<s> package com . wuntee . oter . fs ; import java . util . LinkedList ; import java . util . List ; import org . apache . log4j . Logger ; public class FsNode { private static Logger logger = Logger . getLogger ( FsNode . class ) ; private List < FsNode > children ; private FsNode parent ; private String permissions ; private String user = "<STR_LIT>" ; private String group = "<STR_LIT>" ; private int size ; private String date = "<STR_LIT>" ; private String name = "<STR_LIT>" ; private String link = "<STR_LIT>" ; private String type = "<STR_LIT>" ; private String raw = "<STR_LIT>" ; private String fullPath = "<STR_LIT>" ; private String root = "<STR_LIT>" ; public FsNode ( String raw , FsNode root ) { this ( raw , root . getName ( ) ) ; } public FsNode ( String raw , String root ) { children = new LinkedList < FsNode > ( ) ; this . raw = raw ; this . root = root ; } public void parse ( ) { logger . debug ( "<STR_LIT>" + raw ) ; this . type = raw . substring ( <NUM_LIT:0> , <NUM_LIT:1> ) ; logger . debug ( "<STR_LIT>" + type ) ; this . permissions = raw . substring ( <NUM_LIT:1> , <NUM_LIT:11> ) ; logger . debug ( "<STR_LIT>" + permissions ) ; String [ ] split = raw . split ( "<STR_LIT>" ) ; this . user = split [ <NUM_LIT:1> ] ; logger . debug ( "<STR_LIT>" + user + "<STR_LIT:'>" ) ; this . group = split [ <NUM_LIT:2> ] ; logger . debug ( "<STR_LIT>" + group + "<STR_LIT:'>" ) ; if ( this . type . equals ( "<STR_LIT:->" ) ) { this . size = Integer . valueOf ( split [ <NUM_LIT:3> ] ) ; this . date = split [ <NUM_LIT:4> ] + "<STR_LIT:U+0020>" + split [ <NUM_LIT:5> ] ; this . name = split [ <NUM_LIT:6> ] ; this . link = "<STR_LIT>" ; } else if ( this . type . equals ( "<STR_LIT:d>" ) ) { this . size = - <NUM_LIT:1> ; this . date = split [ <NUM_LIT:3> ] + "<STR_LIT:U+0020>" + split [ <NUM_LIT:4> ] ; if ( split . length > <NUM_LIT:5> ) { this . name = split [ <NUM_LIT:5> ] ; } else { this . name = "<STR_LIT:U+0020>" ; } this . link = "<STR_LIT>" ; } else if ( this . type . equals ( "<STR_LIT>" ) ) { this . size = - <NUM_LIT:1> ; this . date = split [ <NUM_LIT:3> ] + "<STR_LIT:U+0020>" + split [ <NUM_LIT:4> ] ; this . name = split [ <NUM_LIT:5> ] ; this . link = split [ <NUM_LIT:7> ] ; } else if ( this . type . equals ( "<STR_LIT:c>" ) ) { this . size = - <NUM_LIT:1> ; this . date = split [ <NUM_LIT:5> ] + "<STR_LIT:U+0020>" + split [ <NUM_LIT:6> ] ; this . name = split [ <NUM_LIT:7> ] ; this . link = "<STR_LIT>" ; } if ( ! this . root . endsWith ( "<STR_LIT:/>" ) ) { this . root = this . root + "<STR_LIT:/>" ; } if ( this . type . equals ( "<STR_LIT:d>" ) ) { this . fullPath = this . root + this . name + "<STR_LIT:/>" ; } else { this . fullPath = this . root + this . name ; } logger . debug ( "<STR_LIT>" + size + "<STR_LIT:'>" ) ; logger . debug ( "<STR_LIT>" + date + "<STR_LIT:'>" ) ; logger . debug ( "<STR_LIT>" + name + "<STR_LIT:'>" ) ; logger . debug ( "<STR_LIT>" + link + "<STR_LIT:'>" ) ; logger . debug ( "<STR_LIT>" + root + "<STR_LIT:'>" ) ; logger . debug ( "<STR_LIT>" + fullPath + "<STR_LIT:'>" ) ; } @ Override public boolean equals ( Object obj ) { logger . debug ( "<STR_LIT>" ) ; FsNode n = null ; try { n = ( FsNode ) obj ; } catch ( Exception e ) { logger . debug ( "<STR_LIT>" ) ; return ( false ) ; } logger . debug ( "<STR_LIT>" ) ; logger . debug ( this . fullPath . equals ( n . getFullPath ( ) ) + "<STR_LIT:U+0020>" + this . getFullPath ( ) + "<STR_LIT:U+0020:U+0020>" + n . getFullPath ( ) ) ; logger . debug ( ( this . size == n . getSize ( ) ) + "<STR_LIT:U+0020>" + this . size + "<STR_LIT:U+0020:U+0020>" + n . getSize ( ) ) ; logger . debug ( this . date . equals ( n . getDate ( ) ) + "<STR_LIT:U+0020>" + this . date + "<STR_LIT:U+0020:U+0020>" + n . getDate ( ) ) ; logger . debug ( this . link . equals ( n . getLink ( ) ) + "<STR_LIT:U+0020>" + this . link + "<STR_LIT:U+0020:U+0020>" + n . getLink ( ) ) ; if ( this . fullPath . equals ( n . getFullPath ( ) ) && this . size == n . getSize ( ) && this . date . equals ( n . getDate ( ) ) && this . link . equals ( n . getLink ( ) ) ) { logger . debug ( "<STR_LIT>" ) ; return ( true ) ; } else { return ( false ) ; } } public static FsNode getNode ( String raw , String root ) { FsNode ret = new FsNode ( raw , root ) ; ret . parse ( ) ; return ( ret ) ; } public static FsNode getNode ( String raw , FsNode root ) { FsNode ret = new FsNode ( raw , root ) ; ret . parse ( ) ; return ( ret ) ; } public boolean isDirectory ( ) { return ( this . type . equals ( "<STR_LIT:d>" ) ) ; } public boolean isLink ( ) { return ( this . type . equals ( "<STR_LIT>" ) ) ; } public void addChild ( FsNode node ) { children . add ( node ) ; } public List < FsNode > getChildren ( ) { return ( children ) ; } public FsNode getParent ( ) { return parent ; } public void setParent ( FsNode parent ) { this . parent = parent ; } public String getPermissions ( ) { return permissions ; } public void setPermissions ( String permissions ) { this . permissions = permissions ; } public String getUser ( ) { return user ; } public void setUser ( String user ) { this . user = user ; } public String getGroup ( ) { return group ; } public void setGroup ( String group ) { this . group = group ; } public int getSize ( ) { return size ; } public void setSize ( int size ) { this . size = size ; } public String getDate ( ) { return date ; } public void setDate ( String date ) { this . date = date ; } public String getName ( ) { return name ; } public void setName ( String name ) { this . name = name ; } public String getLink ( ) { return link ; } public void setLink ( String link ) { this . link = link ; } public String getType ( ) { return type ; } public void setType ( String type ) { this . type = type ; } public String getRaw ( ) { return raw ; } public void setRaw ( String raw ) { this . raw = raw ; } public String getFullPath ( ) { return fullPath ; } public void setFullPath ( String fullPath ) { this . fullPath = fullPath ; } } </s>
<s> package com . wuntee . oter . fs ; import java . io . IOException ; import java . util . LinkedList ; import java . util . List ; import org . apache . log4j . Logger ; import org . eclipse . swt . SWT ; import org . eclipse . swt . widgets . Tree ; import org . eclipse . swt . widgets . TreeItem ; import org . eclipse . wb . swt . SWTResourceManager ; import com . wuntee . oter . OterStatics ; import com . wuntee . oter . adb . AdbShell ; import com . wuntee . oter . exception . CommandFailedException ; import com . wuntee . oter . view . Gui ; import com . wuntee . oter . view . widgets . runnable . FsListToTreeRunnable ; public class FsDiffController { private static Logger logger = Logger . getLogger ( FsDiffController . class ) ; private Gui gui ; private List < FsNode > first ; private List < FsNode > second ; public FsDiffController ( Gui gui ) { this . gui = gui ; } public void scanFirst ( ) throws Exception { this . gui . getFsDiffSashForm ( ) . setWeights ( new int [ ] { <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> } ) ; this . gui . getFsDiffFirstTree ( ) . removeAll ( ) ; this . gui . getFsDiffSecondTree ( ) . removeAll ( ) ; this . gui . getFsDifferencesTree ( ) . removeAll ( ) ; Thread first = new Thread ( new FirstFsScanRunnable ( this . gui . getFsDiffFirstTree ( ) ) ) ; first . start ( ) ; } public void scanSecond ( ) { this . gui . getFsDiffSecondTree ( ) . removeAll ( ) ; Thread second = new Thread ( new SecondFsScanRunnable ( this . gui . getFsDiffSecondTree ( ) ) ) ; second . start ( ) ; } public void generateDifferences ( ) { this . gui . setStatus ( "<STR_LIT>" ) ; logger . debug ( "<STR_LIT>" ) ; List < FsNode > flatFirst = new LinkedList < FsNode > ( ) ; for ( FsNode node : first ) flatFirst . addAll ( flattenFsNode ( node ) ) ; logger . debug ( "<STR_LIT>" ) ; List < FsNode > flatSecond = new LinkedList < FsNode > ( ) ; for ( FsNode node : second ) flatSecond . addAll ( flattenFsNode ( node ) ) ; logger . debug ( "<STR_LIT>" ) ; List < FsNode > newNodes = new LinkedList < FsNode > ( ) ; List < List < FsNode > > updatedNodes = new LinkedList < List < FsNode > > ( ) ; List < FsNode > deletedNodes = new LinkedList < FsNode > ( ) ; for ( FsNode secondNode : flatSecond ) { if ( getNodeInList ( secondNode , flatFirst ) == null ) { newNodes . add ( secondNode ) ; } } logger . debug ( "<STR_LIT>" + newNodes . size ( ) ) ; for ( FsNode firstNode : flatFirst ) { FsNode secondNode = getNodeInList ( firstNode , flatSecond ) ; if ( secondNode != null && ! secondNode . equals ( firstNode ) ) { List < FsNode > update = new LinkedList < FsNode > ( ) ; update . add ( firstNode ) ; update . add ( secondNode ) ; updatedNodes . add ( update ) ; } } logger . debug ( "<STR_LIT>" + updatedNodes . size ( ) ) ; for ( FsNode firstNode : flatFirst ) { if ( getNodeInList ( firstNode , flatSecond ) == null ) { deletedNodes . add ( firstNode ) ; } } logger . debug ( "<STR_LIT>" + deletedNodes . size ( ) ) ; Tree tree = this . gui . getFsDifferencesTree ( ) ; this . gui . getDisplay ( ) . asyncExec ( new ListToDiffTree ( tree , newNodes , updatedNodes , deletedNodes ) ) ; this . gui . setSashFormWeights ( this . gui . getFsDiffSashForm ( ) , new int [ ] { <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:6> } ) ; this . gui . setStatus ( "<STR_LIT>" ) ; } public class ListToDiffTree implements Runnable { private Tree tree ; private List < FsNode > newNodes ; private List < List < FsNode > > updatedNodes ; private List < FsNode > deletedNodes ; public ListToDiffTree ( Tree tree , List < FsNode > newNodes , List < List < FsNode > > updatedNodes , List < FsNode > deletedNodes ) { this . tree = tree ; this . newNodes = newNodes ; this . updatedNodes = updatedNodes ; this . deletedNodes = deletedNodes ; } public void run ( ) { for ( FsNode node : newNodes ) { TreeItem trtmTest = new TreeItem ( tree , SWT . NONE ) ; trtmTest . setForeground ( SWTResourceManager . getColor ( SWT . COLOR_DARK_GREEN ) ) ; if ( node . isLink ( ) ) { trtmTest . setText ( new String [ ] { node . getFullPath ( ) + "<STR_LIT>" + node . getLink ( ) , node . getPermissions ( ) , node . getGroup ( ) , node . getUser ( ) , ( node . getSize ( ) == - <NUM_LIT:1> ? "<STR_LIT>" : String . valueOf ( node . getSize ( ) ) ) , node . getDate ( ) } ) ; } else { trtmTest . setText ( new String [ ] { node . getFullPath ( ) , node . getPermissions ( ) , node . getGroup ( ) , node . getUser ( ) , ( node . getSize ( ) == - <NUM_LIT:1> ? "<STR_LIT>" : String . valueOf ( node . getSize ( ) ) ) , node . getDate ( ) } ) ; } if ( node . isDirectory ( ) ) { trtmTest . setImage ( SWTResourceManager . getImage ( Gui . class , OterStatics . ICON_FILE ) ) ; } else { trtmTest . setImage ( SWTResourceManager . getImage ( Gui . class , OterStatics . ICON_FILE ) ) ; } } for ( List < FsNode > nodes : updatedNodes ) { FsNode oldNode = nodes . get ( <NUM_LIT:0> ) ; FsNode newNode = nodes . get ( <NUM_LIT:1> ) ; TreeItem trtmTest = new TreeItem ( tree , SWT . NONE ) ; trtmTest . setForeground ( SWTResourceManager . getColor ( SWT . COLOR_BLUE ) ) ; if ( oldNode . isLink ( ) ) { trtmTest . setText ( oldNode . getFullPath ( ) + "<STR_LIT>" + oldNode . getLink ( ) ) ; } else { trtmTest . setText ( oldNode . getFullPath ( ) ) ; } if ( oldNode . isDirectory ( ) ) { trtmTest . setImage ( SWTResourceManager . getImage ( Gui . class , OterStatics . ICON_DIRECTORY ) ) ; } else { trtmTest . setImage ( SWTResourceManager . getImage ( Gui . class , OterStatics . ICON_FILE ) ) ; } TreeItem oldTreeItem = new TreeItem ( trtmTest , SWT . NONE ) ; oldTreeItem . setText ( new String [ ] { "<STR_LIT>" , oldNode . getPermissions ( ) , oldNode . getGroup ( ) , oldNode . getUser ( ) , ( oldNode . getSize ( ) == - <NUM_LIT:1> ? "<STR_LIT>" : String . valueOf ( oldNode . getSize ( ) ) ) , oldNode . getDate ( ) } ) ; TreeItem newTreeItem = new TreeItem ( trtmTest , SWT . NONE ) ; newTreeItem . setText ( new String [ ] { "<STR_LIT>" , newNode . getPermissions ( ) , newNode . getGroup ( ) , newNode . getUser ( ) , ( newNode . getSize ( ) == - <NUM_LIT:1> ? "<STR_LIT>" : String . valueOf ( newNode . getSize ( ) ) ) , newNode . getDate ( ) } ) ; } for ( FsNode node : deletedNodes ) { TreeItem trtmTest = new TreeItem ( tree , SWT . NONE ) ; trtmTest . setForeground ( SWTResourceManager . getColor ( SWT . COLOR_RED ) ) ; if ( node . isLink ( ) ) { trtmTest . setText ( new String [ ] { node . getFullPath ( ) + "<STR_LIT>" + node . getLink ( ) , node . getPermissions ( ) , node . getGroup ( ) , node . getUser ( ) , ( node . getSize ( ) == - <NUM_LIT:1> ? "<STR_LIT>" : String . valueOf ( node . getSize ( ) ) ) , node . getDate ( ) } ) ; } else { trtmTest . setText ( new String [ ] { node . getFullPath ( ) , node . getPermissions ( ) , node . getGroup ( ) , node . getUser ( ) , ( node . getSize ( ) == - <NUM_LIT:1> ? "<STR_LIT>" : String . valueOf ( node . getSize ( ) ) ) , node . getDate ( ) } ) ; } if ( node . isDirectory ( ) ) { trtmTest . setImage ( SWTResourceManager . getImage ( Gui . class , OterStatics . ICON_FILE ) ) ; } else { trtmTest . setImage ( SWTResourceManager . getImage ( Gui . class , OterStatics . ICON_FILE ) ) ; } } } } private FsNode getNodeInList ( FsNode node , List < FsNode > list ) { for ( FsNode scanNode : list ) if ( node . getFullPath ( ) . equals ( scanNode . getFullPath ( ) ) ) return ( scanNode ) ; return ( null ) ; } private List < FsNode > flattenFsNode ( FsNode source ) { List < FsNode > ret = new LinkedList < FsNode > ( ) ; ret . add ( source ) ; if ( source . isDirectory ( ) ) { for ( FsNode node : source . getChildren ( ) ) { ret . addAll ( flattenFsNode ( node ) ) ; } } return ( ret ) ; } public List < FsNode > getFilesystem ( ) throws Exception { AdbShell shell = new AdbShell ( ) ; shell . execute ( ) ; shell . getRootShell ( ) ; return ( listDirectoryRecursive ( "<STR_LIT:/>" , shell ) ) ; } private List < FsNode > listDirectoryRecursive ( String root , AdbShell shell ) throws IOException , CommandFailedException { logger . debug ( "<STR_LIT>" + root ) ; List < FsNode > ret = new LinkedList < FsNode > ( ) ; List < String > lines = shell . sendCommand ( "<STR_LIT>" + root ) ; for ( String line : lines ) { FsNode node = FsNode . getNode ( line , root ) ; if ( ! FsWorkshop . isBadDirectory ( node . getFullPath ( ) ) ) { if ( node . getType ( ) . equals ( "<STR_LIT:d>" ) ) { gui . setStatus ( "<STR_LIT>" + node . getFullPath ( ) ) ; logger . debug ( "<STR_LIT>" + node . getFullPath ( ) ) ; List < FsNode > secRet = listDirectoryRecursive ( node . getFullPath ( ) , shell ) ; for ( FsNode sec : secRet ) { node . addChild ( sec ) ; } } logger . debug ( "<STR_LIT>" + node . getName ( ) + "<STR_LIT>" + node . getChildren ( ) . size ( ) ) ; ret . add ( node ) ; } } return ( ret ) ; } private void setFsToTree ( List < FsNode > fs , Tree tree ) { this . gui . getDisplay ( ) . asyncExec ( new FsListToTreeRunnable ( fs , tree ) ) ; } public class FirstFsScanRunnable implements Runnable { private Tree tree ; public FirstFsScanRunnable ( Tree tree ) { this . tree = tree ; } public void run ( ) { try { first = getFilesystem ( ) ; setFsToTree ( first , tree ) ; } catch ( Exception e ) { gui . messageError ( "<STR_LIT>" + e . getMessage ( ) ) ; logger . error ( "<STR_LIT>" , e ) ; } } } public class SecondFsScanRunnable implements Runnable { private Tree tree ; public SecondFsScanRunnable ( Tree tree ) { this . tree = tree ; } public void run ( ) { try { second = getFilesystem ( ) ; setFsToTree ( second , tree ) ; generateDifferences ( ) ; } catch ( Exception e ) { gui . messageError ( "<STR_LIT>" + e . getMessage ( ) ) ; logger . error ( "<STR_LIT>" , e ) ; } } } } </s>
<s> package com . wuntee . oter . command ; import java . io . BufferedReader ; import java . io . File ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . LinkedList ; import java . util . List ; import org . apache . log4j . Logger ; import com . wuntee . oter . exception . CommandFailedException ; public class TerminatingCommand extends AbstractCommand { private static Logger logger = Logger . getLogger ( TerminatingCommand . class ) ; protected List < String > output ; protected List < String > error ; private int returnCode ; private File workingDirectory ; public TerminatingCommand ( String [ ] command , File workingDirectory ) { super ( command ) ; this . workingDirectory = workingDirectory ; } public TerminatingCommand ( String command , File workingDirectory ) { this ( new String [ ] { command } , workingDirectory ) ; } public TerminatingCommand ( String [ ] command ) { super ( command ) ; output = new LinkedList < String > ( ) ; error = new LinkedList < String > ( ) ; } public TerminatingCommand ( String command ) { this ( new String [ ] { command } ) ; } public int execute ( ) throws IOException , InterruptedException , CommandFailedException { if ( workingDirectory != null ) { String cmd = "<STR_LIT>" ; for ( String c : this . command ) { cmd = cmd + c + "<STR_LIT:U+0020>" ; } logger . debug ( "<STR_LIT>" + cmd + "<STR_LIT>" + workingDirectory ) ; this . child = Runtime . getRuntime ( ) . exec ( this . command , new String [ ] { } , workingDirectory ) ; } else { this . child = Runtime . getRuntime ( ) . exec ( this . command ) ; } BufferedReader b = new BufferedReader ( new InputStreamReader ( this . child . getErrorStream ( ) ) ) ; String l ; while ( ( l = b . readLine ( ) ) != null ) { logger . debug ( "<STR_LIT>" + l ) ; error . add ( l ) ; } b = new BufferedReader ( new InputStreamReader ( this . child . getInputStream ( ) ) ) ; while ( ( l = b . readLine ( ) ) != null ) { logger . debug ( "<STR_LIT>" + l ) ; ; output . add ( l ) ; } this . returnCode = this . child . waitFor ( ) ; logger . debug ( "<STR_LIT>" + this . returnCode ) ; if ( this . returnCode != <NUM_LIT:0> ) { List < String > ex = new LinkedList < String > ( ) ; ex . addAll ( output ) ; ex . addAll ( error ) ; throw new CommandFailedException ( this . command , ex , this . returnCode ) ; } return ( this . returnCode ) ; } public int executeNoErrorMonitor ( ) throws CommandFailedException , InterruptedException , IOException { this . child = Runtime . getRuntime ( ) . exec ( this . command ) ; BufferedReader b = new BufferedReader ( new InputStreamReader ( this . child . getInputStream ( ) ) ) ; String l ; while ( ( l = b . readLine ( ) ) != null ) { logger . debug ( "<STR_LIT>" + l ) ; ; output . add ( l ) ; } this . returnCode = this . child . waitFor ( ) ; logger . debug ( "<STR_LIT>" + this . returnCode ) ; if ( this . returnCode != <NUM_LIT:0> ) { List < String > ex = new LinkedList < String > ( ) ; ex . addAll ( output ) ; ex . addAll ( error ) ; throw new CommandFailedException ( this . command , ex , this . returnCode ) ; } return ( this . returnCode ) ; } public void checkError ( ) { } public int getReturnCode ( ) { return returnCode ; } public List < String > getOutput ( ) { return output ; } public void setOutput ( List < String > output ) { this . output = output ; } public List < String > getError ( ) { return error ; } public void setError ( List < String > error ) { this . error = error ; } } </s>
<s> package com . wuntee . oter . command ; import org . apache . log4j . Logger ; public abstract class AbstractCommand { private static Logger logger = Logger . getLogger ( AbstractCommand . class ) ; protected String [ ] command ; protected Process child ; public AbstractCommand ( String [ ] command ) { String fullCommand = "<STR_LIT>" ; for ( int i = <NUM_LIT:0> ; i < command . length ; i ++ ) fullCommand = fullCommand + "<STR_LIT:U+0020>" + command [ i ] ; logger . info ( "<STR_LIT>" + fullCommand ) ; this . command = command ; } public AbstractCommand ( String command ) { this ( new String [ ] { command } ) ; } public abstract int execute ( ) throws Exception ; public abstract void checkError ( ) ; public String [ ] getCommand ( ) { return command ; } public void setCommand ( String [ ] command ) { this . command = command ; } } </s>
<s> package com . wuntee . oter . command ; import java . io . BufferedReader ; import java . io . BufferedWriter ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ; import org . apache . log4j . Logger ; public class BackgroundCommand extends AbstractCommand { private static Logger logger = Logger . getLogger ( BackgroundCommand . class ) ; private boolean running = false ; protected BufferedReader stdout ; protected BufferedReader stderr ; protected BufferedWriter stdin ; public BackgroundCommand ( String [ ] command ) { super ( command ) ; } public BackgroundCommand ( String command ) { super ( command ) ; } @ Override public int execute ( ) throws Exception { logger . debug ( "<STR_LIT>" ) ; String fullCommand = "<STR_LIT>" ; for ( int i = <NUM_LIT:0> ; i < this . command . length ; i ++ ) fullCommand = fullCommand + "<STR_LIT:U+0020>" + command [ i ] ; logger . debug ( "<STR_LIT>" + fullCommand ) ; this . running = true ; this . child = Runtime . getRuntime ( ) . exec ( this . command ) ; this . stdout = new BufferedReader ( new InputStreamReader ( this . child . getInputStream ( ) ) ) ; this . stderr = new BufferedReader ( new InputStreamReader ( this . child . getErrorStream ( ) ) ) ; this . stdin = new BufferedWriter ( new OutputStreamWriter ( this . child . getOutputStream ( ) ) ) ; logger . debug ( "<STR_LIT>" ) ; return ( <NUM_LIT:0> ) ; } public void close ( ) { this . running = false ; this . child . destroy ( ) ; } public BufferedReader getStdout ( ) { return ( stdout ) ; } public BufferedReader getStderr ( ) { return ( stderr ) ; } @ Override public void checkError ( ) { } public boolean isRunning ( ) { return running ; } public void setRunning ( boolean running ) { this . running = running ; } public BufferedWriter getStdin ( ) { return stdin ; } } </s>
<s> package com . wuntee . oter . avd ; import java . io . File ; import java . io . IOException ; import org . apache . commons . io . FileUtils ; import org . apache . log4j . Logger ; import com . android . prefs . AndroidLocation ; import com . android . prefs . AndroidLocation . AndroidLocationException ; import com . android . sdklib . IAndroidTarget ; import com . android . sdklib . ISdkLog ; import com . android . sdklib . ISystemImage ; import com . android . sdklib . SdkManager ; import com . android . sdklib . internal . avd . AvdInfo ; import com . android . sdklib . internal . avd . AvdManager ; import com . wuntee . oter . OterStatics ; import com . wuntee . oter . command . BackgroundCommand ; import com . wuntee . oter . exception . GenericException ; import com . wuntee . oter . view . bean . CreateAvdBean ; public class AvdWorkshop { private static Logger logger = Logger . getLogger ( AvdWorkshop . class ) ; public static AvdInfo createAvd ( CreateAvdBean bean ) throws AndroidLocationException , IOException , GenericException { ISdkLog sdkLogger = AvdWorkshop . getAvdLogger ( ) ; SdkManager sdkManager = SdkManager . createManager ( OterStatics . getAndroidHome ( ) , sdkLogger ) ; AvdManager avdManager = new AvdManager ( sdkManager , sdkLogger ) ; File avdFolder = new File ( AndroidLocation . getFolder ( ) + "<STR_LIT>" , bean . getName ( ) + "<STR_LIT>" ) ; IAndroidTarget target = getAndroidTargetFromString ( sdkManager , bean . getTarget ( ) ) ; ISystemImage [ ] abiTypes = target . getSystemImages ( ) ; if ( abiTypes . length == <NUM_LIT:0> ) { throw new GenericException ( "<STR_LIT>" ) ; } String abiType = abiTypes [ <NUM_LIT:0> ] . getAbiType ( ) ; AvdInfo ret = avdManager . createAvd ( avdFolder , bean . getName ( ) , target , abiType , null , null , null , false , false , false , sdkLogger ) ; if ( ret == null ) { logger . error ( "<STR_LIT>" ) ; throw new GenericException ( "<STR_LIT>" ) ; } if ( bean . isPersistant ( ) == true ) { makeAvdPersistant ( ret ) ; } return ( ret ) ; } public static boolean isAvdExist ( String avd ) throws AndroidLocationException { ISdkLog sdkLogger = AvdWorkshop . getAvdLogger ( ) ; SdkManager sdkManager = SdkManager . createManager ( OterStatics . getAndroidHome ( ) , sdkLogger ) ; AvdManager avdManager = new AvdManager ( sdkManager , sdkLogger ) ; for ( AvdInfo i : avdManager . getAllAvds ( ) ) { if ( i . getName ( ) . equals ( avd ) ) { return ( true ) ; } } return ( false ) ; } public static void makeAvdPersistant ( AvdInfo info ) throws IOException { logger . debug ( "<STR_LIT>" + info . getName ( ) + "<STR_LIT>" ) ; File avdPath = new File ( info . getDataFolderPath ( ) ) ; ISystemImage [ ] sysImages = null ; if ( info . getTarget ( ) . isPlatform ( ) == false ) { for ( ISystemImage iSysImg : info . getTarget ( ) . getParent ( ) . getSystemImages ( ) ) { File f = new File ( iSysImg . getLocation ( ) . getAbsoluteFile ( ) + System . getProperty ( "<STR_LIT>" ) + "<STR_LIT>" ) ; FileUtils . copyFileToDirectory ( f , avdPath ) ; } } sysImages = info . getTarget ( ) . getSystemImages ( ) ; for ( ISystemImage iSysImg : info . getTarget ( ) . getSystemImages ( ) ) { File f = new File ( iSysImg . getLocation ( ) . getAbsoluteFile ( ) + System . getProperty ( "<STR_LIT>" ) + "<STR_LIT>" ) ; FileUtils . copyFileToDirectory ( f , avdPath ) ; } File sysImg = new File ( avdPath + System . getProperty ( "<STR_LIT>" ) + "<STR_LIT>" ) ; if ( sysImg . exists ( ) ) { sysImg . renameTo ( new File ( avdPath + System . getProperty ( "<STR_LIT>" ) + "<STR_LIT>" ) ) ; } } private static void copyDirContentsToDir ( String firstDir , String destDir ) throws IOException { logger . debug ( "<STR_LIT>" + firstDir + "<STR_LIT>" + destDir + "<STR_LIT:'>" ) ; File src = new File ( firstDir ) ; File dst = new File ( destDir ) ; for ( File x : src . listFiles ( ) ) { FileUtils . copyFileToDirectory ( x , dst ) ; } } public static IAndroidTarget getAndroidTargetFromString ( SdkManager sdkManager , String target ) { for ( IAndroidTarget t : sdkManager . getTargets ( ) ) { if ( t . hashString ( ) . equals ( target ) ) { return ( t ) ; } } return ( null ) ; } public static void launchAvd ( AvdInfo avd ) throws Exception { String avdName = "<STR_LIT:@>" + avd . getName ( ) ; BackgroundCommand c = new BackgroundCommand ( new String [ ] { OterStatics . getEmulatorCommand ( ) , "<STR_LIT>" , "<STR_LIT>" , avdName } ) ; c . execute ( ) ; } public static void launchPersistantAvd ( AvdInfo avd ) throws Exception { String avdName = "<STR_LIT:@>" + avd . getName ( ) ; String sysImage = avd . getDataFolderPath ( ) + System . getProperty ( "<STR_LIT>" ) + "<STR_LIT>" ; BackgroundCommand c = new BackgroundCommand ( new String [ ] { OterStatics . getEmulatorCommand ( ) , "<STR_LIT>" , sysImage , "<STR_LIT>" , "<STR_LIT>" , avdName } ) ; c . execute ( ) ; } public static ISdkLog getAvdLogger ( ) { ISdkLog sdkLogger = new ISdkLog ( ) { public void error ( Throwable t , String errorFormat , Object [ ] args ) { logger . error ( "<STR_LIT>" , t ) ; } public void warning ( String warningFormat , Object [ ] args ) { logger . warn ( args ) ; } public void printf ( String msgFormat , Object [ ] args ) { logger . debug ( args ) ; } } ; return ( sdkLogger ) ; } } </s>
<s> package com . wuntee . oter . avd ; import java . io . IOException ; import org . apache . log4j . Logger ; import com . android . prefs . AndroidLocation . AndroidLocationException ; import com . android . sdklib . internal . avd . AvdInfo ; import com . wuntee . oter . view . Gui ; import com . wuntee . oter . view . GuiWorkshop ; import com . wuntee . oter . view . bean . CreateAvdBean ; public class AvdController { private static Logger logger = Logger . getLogger ( AvdController . class ) ; private Gui gui ; public AvdController ( Gui gui ) { this . gui = gui ; } public void createAvd ( CreateAvdBean bean ) { try { AvdInfo avd = AvdWorkshop . createAvd ( bean ) ; if ( bean . isLaunch ( ) ) { if ( bean . isPersistant ( ) ) { AvdWorkshop . launchPersistantAvd ( avd ) ; } else { AvdWorkshop . launchAvd ( avd ) ; } } else { GuiWorkshop . messageDialog ( gui . getShell ( ) , "<STR_LIT>" + bean . getName ( ) + "<STR_LIT>" ) ; } } catch ( AndroidLocationException e ) { GuiWorkshop . messageError ( gui . getShell ( ) , "<STR_LIT>" + e . getMessage ( ) ) ; logger . error ( "<STR_LIT>" , e ) ; } catch ( IOException e ) { GuiWorkshop . messageError ( gui . getShell ( ) , "<STR_LIT>" + e . getMessage ( ) ) ; logger . error ( "<STR_LIT>" , e ) ; } catch ( Exception e ) { GuiWorkshop . messageError ( gui . getShell ( ) , "<STR_LIT>" + e . getMessage ( ) ) ; logger . error ( "<STR_LIT>" , e ) ; } } } </s>
<s> package com . wuntee . oter . smali ; import java . io . ByteArrayInputStream ; import java . io . ByteArrayOutputStream ; import java . io . File ; import java . io . FileInputStream ; import java . io . FileOutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . OutputStream ; import java . lang . reflect . Constructor ; import java . lang . reflect . InvocationTargetException ; import java . lang . reflect . Method ; import java . security . InvalidKeyException ; import java . security . Key ; import java . security . KeyFactory ; import java . security . KeyStore ; import java . security . MessageDigest ; import java . security . NoSuchAlgorithmException ; import java . security . PrivateKey ; import java . security . SignatureException ; import java . security . cert . CertificateException ; import java . security . cert . CertificateFactory ; import java . security . cert . X509Certificate ; import java . security . spec . DSAPrivateKeySpec ; import java . security . spec . KeySpec ; import java . util . Enumeration ; import java . util . Iterator ; import java . util . Map ; import java . util . jar . Attributes ; import java . util . jar . JarEntry ; import java . util . jar . JarFile ; import java . util . jar . JarOutputStream ; import java . util . jar . Manifest ; import java . util . zip . ZipFile ; import org . apache . log4j . Logger ; import sun . misc . BASE64Encoder ; import sun . security . util . ManifestDigester ; public class JarSigner15 { private static Logger logger = Logger . getLogger ( JarSigner15 . class ) ; private String alias ; private PrivateKey privateKey ; private X509Certificate [ ] certChain ; public JarSigner15 ( String alias , PrivateKey privateKey , X509Certificate [ ] certChain ) { this . alias = alias ; this . privateKey = privateKey ; this . certChain = certChain ; } private static Manifest getManifestFile ( JarFile jarFile ) throws IOException { JarEntry je = jarFile . getJarEntry ( "<STR_LIT>" ) ; if ( je != null ) { Enumeration entries = jarFile . entries ( ) ; while ( entries . hasMoreElements ( ) ) { je = ( JarEntry ) entries . nextElement ( ) ; if ( "<STR_LIT>" . equalsIgnoreCase ( je . getName ( ) ) ) break ; else je = null ; } } Manifest manifest = new Manifest ( ) ; if ( je != null ) manifest . read ( jarFile . getInputStream ( je ) ) ; return manifest ; } private static Map pruneManifest ( Manifest manifest , JarFile jarFile ) throws IOException { Map map = manifest . getEntries ( ) ; Iterator elements = map . keySet ( ) . iterator ( ) ; while ( elements . hasNext ( ) ) { String element = ( String ) elements . next ( ) ; if ( jarFile . getEntry ( element ) == null ) elements . remove ( ) ; } return map ; } private static Map createEntries ( Manifest manifest , JarFile jarFile ) throws IOException { Map entries = null ; if ( manifest . getEntries ( ) . size ( ) > <NUM_LIT:0> ) entries = pruneManifest ( manifest , jarFile ) ; else { Attributes attributes = manifest . getMainAttributes ( ) ; attributes . putValue ( Attributes . Name . MANIFEST_VERSION . toString ( ) , "<STR_LIT:1.0>" ) ; attributes . putValue ( "<STR_LIT>" , System . getProperty ( "<STR_LIT>" ) + "<STR_LIT:U+0020(>" + System . getProperty ( "<STR_LIT>" ) + "<STR_LIT:)>" ) ; entries = manifest . getEntries ( ) ; } return entries ; } private static BASE64Encoder b64Encoder = new BASE64Encoder ( ) ; private static String updateDigest ( MessageDigest digest , InputStream inputStream ) throws IOException { byte [ ] buffer = new byte [ <NUM_LIT> ] ; int read = <NUM_LIT:0> ; while ( ( read = inputStream . read ( buffer ) ) > <NUM_LIT:0> ) digest . update ( buffer , <NUM_LIT:0> , read ) ; inputStream . close ( ) ; return b64Encoder . encode ( digest . digest ( ) ) ; } private static Map updateManifestDigest ( Manifest manifest , JarFile jarFile , MessageDigest messageDigest , Map entries ) throws IOException { Enumeration jarElements = jarFile . entries ( ) ; while ( jarElements . hasMoreElements ( ) ) { JarEntry jarEntry = ( JarEntry ) jarElements . nextElement ( ) ; if ( jarEntry . getName ( ) . startsWith ( "<STR_LIT>" ) ) continue ; else if ( manifest . getAttributes ( jarEntry . getName ( ) ) != null ) { Attributes attributes = manifest . getAttributes ( jarEntry . getName ( ) ) ; attributes . putValue ( "<STR_LIT>" , updateDigest ( messageDigest , jarFile . getInputStream ( jarEntry ) ) ) ; } else if ( ! jarEntry . isDirectory ( ) ) { Attributes attributes = new Attributes ( ) ; attributes . putValue ( "<STR_LIT>" , updateDigest ( messageDigest , jarFile . getInputStream ( jarEntry ) ) ) ; entries . put ( jarEntry . getName ( ) , attributes ) ; } } return entries ; } private byte [ ] serialiseManifest ( Manifest manifest ) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; manifest . write ( baos ) ; baos . flush ( ) ; baos . close ( ) ; return baos . toByteArray ( ) ; } private SignatureFile createSignatureFile ( Manifest manifest , MessageDigest messageDigest ) throws IOException , IllegalAccessException , NoSuchMethodException , InvocationTargetException , InstantiationException , ClassNotFoundException { ManifestDigester manifestDigester = new ManifestDigester ( serialiseManifest ( manifest ) ) ; return new SignatureFile ( new MessageDigest [ ] { messageDigest } , manifest , manifestDigester , this . alias , true ) ; } private static void writeJarEntry ( JarEntry je , JarFile jarFile , JarOutputStream jos ) throws IOException { jos . putNextEntry ( je ) ; byte [ ] buffer = new byte [ <NUM_LIT> ] ; int read = <NUM_LIT:0> ; InputStream is = jarFile . getInputStream ( je ) ; while ( ( read = is . read ( buffer ) ) > <NUM_LIT:0> ) jos . write ( buffer , <NUM_LIT:0> , read ) ; jos . closeEntry ( ) ; } public void signJarFile ( JarFile jarFile , OutputStream outputStream ) throws NoSuchAlgorithmException , InvalidKeyException , SignatureException , IOException , IllegalAccessException , InvocationTargetException , NoSuchMethodException , CertificateException , InstantiationException , ClassNotFoundException { Manifest manifest = getManifestFile ( jarFile ) ; Map entries = createEntries ( manifest , jarFile ) ; MessageDigest messageDigest = MessageDigest . getInstance ( "<STR_LIT>" ) ; updateManifestDigest ( manifest , jarFile , messageDigest , entries ) ; SignatureFile signatureFile = createSignatureFile ( manifest , messageDigest ) ; SignatureFile . Block block = signatureFile . generateBlock ( privateKey , certChain , true , jarFile ) ; String manifestFileName = "<STR_LIT>" ; JarOutputStream jos = new JarOutputStream ( outputStream ) ; JarEntry manifestFile = new JarEntry ( manifestFileName ) ; jos . putNextEntry ( manifestFile ) ; byte manifestBytes [ ] = serialiseManifest ( manifest ) ; jos . write ( manifestBytes , <NUM_LIT:0> , manifestBytes . length ) ; jos . closeEntry ( ) ; String signatureFileName = signatureFile . getMetaName ( ) ; JarEntry signatureFileEntry = new JarEntry ( signatureFileName ) ; jos . putNextEntry ( signatureFileEntry ) ; signatureFile . write ( jos ) ; jos . closeEntry ( ) ; String signatureBlockName = block . getMetaName ( ) ; JarEntry signatureBlockEntry = new JarEntry ( signatureBlockName ) ; jos . putNextEntry ( signatureBlockEntry ) ; block . write ( jos ) ; jos . closeEntry ( ) ; Enumeration metaEntries = jarFile . entries ( ) ; while ( metaEntries . hasMoreElements ( ) ) { JarEntry metaEntry = ( JarEntry ) metaEntries . nextElement ( ) ; if ( metaEntry . getName ( ) . startsWith ( "<STR_LIT>" ) && ! ( manifestFileName . equalsIgnoreCase ( metaEntry . getName ( ) ) || signatureFileName . equalsIgnoreCase ( metaEntry . getName ( ) ) || signatureBlockName . equalsIgnoreCase ( metaEntry . getName ( ) ) ) ) writeJarEntry ( metaEntry , jarFile , jos ) ; } Enumeration allEntries = jarFile . entries ( ) ; while ( allEntries . hasMoreElements ( ) ) { JarEntry entry = ( JarEntry ) allEntries . nextElement ( ) ; if ( ! entry . getName ( ) . startsWith ( "<STR_LIT>" ) ) writeJarEntry ( entry , jarFile , jos ) ; } jos . flush ( ) ; jos . finish ( ) ; jarFile . close ( ) ; } private static Constructor findConstructor ( Class c , Class ... argTypes ) throws NoSuchMethodException { Constructor ct = c . getDeclaredConstructor ( argTypes ) ; if ( ct == null ) { throw new RuntimeException ( c . getName ( ) ) ; } ct . setAccessible ( true ) ; return ct ; } private static Method findMethod ( Class c , String methodName , Class ... argTypes ) throws NoSuchMethodException { Method m = c . getDeclaredMethod ( methodName , argTypes ) ; if ( m == null ) { throw new RuntimeException ( c . getName ( ) ) ; } m . setAccessible ( true ) ; return m ; } private class SignatureFile { private Object sigFile ; private Class JDKsfClass ; private Method getMetaNameMethod ; private Method writeMethod ; private static final String JDK_SIGNATURE_FILE = "<STR_LIT>" ; private static final String GETMETANAME_METHOD = "<STR_LIT>" ; private static final String WRITE_METHOD = "<STR_LIT>" ; public SignatureFile ( MessageDigest digests [ ] , Manifest mf , ManifestDigester md , String baseName , boolean signManifest ) throws ClassNotFoundException , NoSuchMethodException , InstantiationException , IllegalAccessException , InvocationTargetException { JDKsfClass = getClass ( ) . forName ( JDK_SIGNATURE_FILE ) ; Constructor constructor = findConstructor ( JDKsfClass , MessageDigest [ ] . class , Manifest . class , ManifestDigester . class , String . class , Boolean . TYPE ) ; sigFile = constructor . newInstance ( digests , mf , md , baseName , signManifest ) ; getMetaNameMethod = findMethod ( JDKsfClass , GETMETANAME_METHOD ) ; writeMethod = findMethod ( JDKsfClass , WRITE_METHOD , OutputStream . class ) ; } public Block generateBlock ( PrivateKey privateKey , X509Certificate [ ] certChain , boolean externalSF , ZipFile zipFile ) throws NoSuchAlgorithmException , InvalidKeyException , IOException , SignatureException , CertificateException , ClassNotFoundException , NoSuchMethodException , InstantiationException , IllegalAccessException , InvocationTargetException { return new Block ( this , privateKey , certChain , externalSF , zipFile ) ; } public Class getJDKSignatureFileClass ( ) { return JDKsfClass ; } public Object getJDKSignatureFile ( ) { return sigFile ; } public String getMetaName ( ) throws IllegalAccessException , InvocationTargetException { return ( String ) getMetaNameMethod . invoke ( sigFile ) ; } public void write ( OutputStream os ) throws IllegalAccessException , InvocationTargetException { writeMethod . invoke ( sigFile , os ) ; } private class Block { private Object block ; private static final String JDK_BLOCK = JDK_SIGNATURE_FILE + "<STR_LIT>" ; private static final String JDK_CONTENT_SIGNER = "<STR_LIT>" ; private Method getMetaNameMethod ; private Method writeMethod ; public Block ( SignatureFile sfg , PrivateKey privateKey , X509Certificate [ ] certChain , boolean externalSF , ZipFile zipFile ) throws ClassNotFoundException , NoSuchMethodException , InstantiationException , IllegalAccessException , InvocationTargetException { Class blockClass = getClass ( ) . forName ( JDK_BLOCK ) ; Class contentSignerClass = getClass ( ) . forName ( JDK_CONTENT_SIGNER ) ; Constructor constructor = findConstructor ( blockClass , sfg . getJDKSignatureFileClass ( ) , PrivateKey . class , X509Certificate [ ] . class , Boolean . TYPE , String . class , X509Certificate . class , contentSignerClass , String [ ] . class , ZipFile . class ) ; getMetaNameMethod = findMethod ( blockClass , GETMETANAME_METHOD ) ; writeMethod = findMethod ( blockClass , WRITE_METHOD , OutputStream . class ) ; block = constructor . newInstance ( sfg . getJDKSignatureFile ( ) , privateKey , certChain , externalSF , null , null , null , null , zipFile ) ; } public String getMetaName ( ) throws IllegalAccessException , InvocationTargetException { return ( String ) getMetaNameMethod . invoke ( block ) ; } public void write ( OutputStream os ) throws IllegalAccessException , InvocationTargetException { writeMethod . invoke ( block , os ) ; } } } public static File sign ( File jar , String newName , String keystoreLocation , String alias , char [ ] passwd , char [ ] keypasswd ) throws Exception { FileInputStream fileIn = new FileInputStream ( keystoreLocation ) ; KeyStore keyStore = KeyStore . getInstance ( "<STR_LIT>" ) ; keyStore . load ( fileIn , passwd ) ; java . security . cert . Certificate [ ] chain = keyStore . getCertificateChain ( alias ) ; X509Certificate certChain [ ] = new X509Certificate [ chain . length ] ; CertificateFactory cf = CertificateFactory . getInstance ( "<STR_LIT>" ) ; for ( int count = <NUM_LIT:0> ; count < chain . length ; count ++ ) { ByteArrayInputStream certIn = new ByteArrayInputStream ( chain [ <NUM_LIT:0> ] . getEncoded ( ) ) ; X509Certificate cert = ( X509Certificate ) cf . generateCertificate ( certIn ) ; certChain [ count ] = cert ; } Key key = keyStore . getKey ( alias , keypasswd ) ; logger . debug ( "<STR_LIT>" + key . getAlgorithm ( ) ) ; KeyFactory keyFactory = KeyFactory . getInstance ( key . getAlgorithm ( ) ) ; KeySpec keySpec = keyFactory . getKeySpec ( key , DSAPrivateKeySpec . class ) ; PrivateKey privateKey = keyFactory . generatePrivate ( keySpec ) ; JarSigner15 jarSigner = new JarSigner15 ( alias , privateKey , certChain ) ; JarFile jarFile = new JarFile ( jar . getCanonicalPath ( ) ) ; File newJar = new File ( jar . getParentFile ( ) , newName ) ; OutputStream outStream = new FileOutputStream ( newJar ) ; jarSigner . signJarFile ( jarFile , outStream ) ; fileIn . close ( ) ; return newJar ; } public static File sign ( File jar , String keystoreLocation , String alias , char [ ] passwd , char [ ] keypasswd ) throws Exception { return sign ( jar , "<STR_LIT>" + jar . getName ( ) , keystoreLocation , alias , passwd , keypasswd ) ; } } </s>
<s> package com . wuntee . oter . smali ; import java . io . BufferedReader ; import java . io . BufferedWriter ; import java . io . DataInputStream ; import java . io . File ; import java . io . FileInputStream ; import java . io . FileReader ; import java . io . FileWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Map ; import org . apache . log4j . Logger ; import org . eclipse . swt . SWT ; import org . eclipse . swt . custom . CTabFolder ; import org . eclipse . swt . custom . CTabItem ; import org . eclipse . swt . custom . StyledText ; import org . eclipse . swt . events . ModifyEvent ; import org . eclipse . swt . events . ModifyListener ; import org . eclipse . swt . events . SelectionAdapter ; import org . eclipse . swt . events . SelectionEvent ; import org . eclipse . swt . widgets . Menu ; import org . eclipse . swt . widgets . MenuItem ; import org . eclipse . swt . widgets . Shell ; import org . eclipse . swt . widgets . Table ; import org . eclipse . swt . widgets . TableItem ; import org . eclipse . swt . widgets . Tree ; import org . eclipse . swt . widgets . TreeItem ; import org . eclipse . wb . swt . SWTResourceManager ; import com . wuntee . oter . OterStatics ; import com . wuntee . oter . OterWorkshop ; import com . wuntee . oter . adb . AdbWorkshop ; import com . wuntee . oter . exception . BuildApkException ; import com . wuntee . oter . exception . CommandFailedException ; import com . wuntee . oter . packagemanager . PackageBean ; import com . wuntee . oter . styler . SmaliLineStyler ; import com . wuntee . oter . view . FindDialog ; import com . wuntee . oter . view . Gui ; import com . wuntee . oter . view . GuiWorkshop ; import com . wuntee . oter . view . bean . BuildAndSignApkBean ; import com . wuntee . oter . view . widgets . CTabItemWithStyledText ; public class SmaliController { private static Logger logger = Logger . getLogger ( SmaliController . class ) ; private Map < String , File > smaliMap ; private File currentApk ; private File baksmaliDir ; public static final String FILENAME = "<STR_LIT>" ; public static final String LINENUMBER = "<STR_LIT>" ; public static final String CLASS = "<STR_LIT:class>" ; public static final String NAME = "<STR_LIT:name>" ; public static final String PACKAGE = "<STR_LIT>" ; public static final String MODIFIED = "<STR_LIT>" ; public static final String ORIGINAL_TEXT = "<STR_LIT>" ; private Gui gui ; public SmaliController ( Gui gui ) { this . gui = gui ; } public void search ( ) { String searchString = gui . getSmaliSearchText ( ) . getText ( ) ; gui . setStatus ( "<STR_LIT>" + searchString ) ; logger . debug ( "<STR_LIT>" + searchString + "<STR_LIT:'>" ) ; if ( currentApk == null ) { GuiWorkshop . messageError ( gui . getShell ( ) , "<STR_LIT>" ) ; } else if ( searchString == null || searchString . equals ( "<STR_LIT>" ) ) { GuiWorkshop . messageError ( gui . getShell ( ) , "<STR_LIT>" ) ; } else { if ( gui . getSmaliSearchRegex ( ) . getSelection ( ) == true ) { try { OterStatics . SOME_STRING . matches ( searchString ) ; } catch ( Exception e ) { GuiWorkshop . messageError ( gui . getShell ( ) , "<STR_LIT>" + e . getMessage ( ) ) ; return ; } } gui . runRunnableAsync ( new SearchRunnable ( searchString ) ) ; } } private class SearchRunnable implements Runnable { private Table table ; private String searchString ; public SearchRunnable ( String searchString ) { this . searchString = searchString ; this . table = gui . getSmaliSearchTable ( ) ; this . table . removeAll ( ) ; } public void run ( ) { synchronized ( baksmaliDir ) { search ( baksmaliDir ) ; } gui . clearStatus ( ) ; } private void search ( File file ) { if ( file . isDirectory ( ) ) { for ( File f : file . listFiles ( ) ) { search ( f ) ; } } else { searchFile ( file ) ; } } private void searchFile ( File f ) { try { int start = ( int ) baksmaliDir . getAbsolutePath ( ) . length ( ) + <NUM_LIT:1> ; String clazz = f . getAbsolutePath ( ) . substring ( start , f . getAbsolutePath ( ) . length ( ) - "<STR_LIT>" . length ( ) ) . replace ( System . getProperty ( "<STR_LIT>" ) , "<STR_LIT:.>" ) ; logger . debug ( "<STR_LIT>" + searchString + "<STR_LIT>" + f . getAbsolutePath ( ) ) ; FileInputStream fstream = new FileInputStream ( f ) ; DataInputStream in = new DataInputStream ( fstream ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( in ) ) ; String strLine ; int line = <NUM_LIT:0> ; String searchStrLine ; while ( ( strLine = br . readLine ( ) ) != null ) { searchStrLine = strLine ; if ( gui . getSmaliSearchIgnoreCase ( ) . getSelection ( ) == true ) { searchStrLine = strLine . toLowerCase ( ) ; searchString = searchString . toLowerCase ( ) ; } if ( gui . getSmaliSearchRegex ( ) . getSelection ( ) == true ) { if ( searchStrLine . matches ( searchString ) ) { addResult ( f , line , strLine ) ; } } else { if ( searchStrLine . indexOf ( searchString ) != - <NUM_LIT:1> ) { addResult ( f , line , strLine ) ; } } line ++ ; } } catch ( Exception e ) { GuiWorkshop . messageError ( gui . getShell ( ) , "<STR_LIT>" + e . getMessage ( ) ) ; logger . error ( "<STR_LIT>" , e ) ; } } private void addResult ( File f , int line , String lineContents ) { TableItem ti = new TableItem ( table , SWT . NONE ) ; int start = ( int ) baksmaliDir . getAbsolutePath ( ) . length ( ) + <NUM_LIT:1> ; String clazz = f . getAbsolutePath ( ) . substring ( start , f . getAbsolutePath ( ) . length ( ) - "<STR_LIT>" . length ( ) ) . replace ( System . getProperty ( "<STR_LIT>" ) , "<STR_LIT:.>" ) ; String name = f . getName ( ) . substring ( <NUM_LIT:0> , f . getName ( ) . length ( ) - "<STR_LIT>" . length ( ) ) ; String pkg = "<STR_LIT>" ; if ( clazz . length ( ) != name . length ( ) ) { pkg = clazz . substring ( <NUM_LIT:0> , clazz . length ( ) - name . length ( ) - <NUM_LIT:1> ) ; } logger . debug ( "<STR_LIT>" + clazz ) ; logger . debug ( "<STR_LIT>" + pkg ) ; logger . debug ( "<STR_LIT>" + name ) ; ti . setText ( new String [ ] { clazz , lineContents } ) ; ti . setData ( NAME , name ) ; ti . setData ( FILENAME , clazz ) ; ti . setData ( LINENUMBER , line ) ; ti . setData ( CLASS , clazz ) ; ti . setData ( PACKAGE , pkg ) ; } } public void saveTab ( CTabItem tab ) throws IOException { if ( ( Boolean ) tab . getData ( MODIFIED ) == true ) { String file = ( String ) tab . getData ( FILENAME ) ; logger . debug ( "<STR_LIT>" + file ) ; BufferedWriter out = new BufferedWriter ( new FileWriter ( file ) ) ; StyledText styledText = ( StyledText ) tab . getData ( StyledText . class . getName ( ) ) ; out . write ( styledText . getText ( ) ) ; out . flush ( ) ; out . close ( ) ; tab . setData ( ORIGINAL_TEXT , styledText . getText ( ) ) ; tab . setData ( MODIFIED , false ) ; tab . setText ( tab . getText ( ) . substring ( <NUM_LIT:2> ) ) ; } } public void loadApk ( File apk ) { Thread x = new Thread ( new LoadApkRunnable ( apk ) ) ; x . start ( ) ; } public void loadApkFromDevice ( PackageBean bean ) { try { File f = AdbWorkshop . pullFile ( bean . getApk ( ) ) ; loadApk ( f ) ; } catch ( Exception e ) { logger . error ( "<STR_LIT>" , e ) ; GuiWorkshop . messageError ( gui . getShell ( ) , "<STR_LIT>" + e . getMessage ( ) ) ; } } public void loadSmaliSource ( String pkg , String name ) { logger . debug ( "<STR_LIT>" + pkg ) ; logger . debug ( "<STR_LIT>" + name ) ; this . gui . runRunnableAsync ( new LoadSmaliSource ( pkg , name ) ) ; } public void loadSmaliSourceWithLineNumber ( String pkg , String name , int line ) { logger . debug ( "<STR_LIT>" + pkg ) ; logger . debug ( "<STR_LIT>" + name ) ; this . gui . runRunnableAsync ( new LoadSmaliSource ( pkg , name , line ) ) ; } public File rebuildApk ( String filename ) { gui . setStatus ( "<STR_LIT>" + filename ) ; try { SmaliWorkshop . buildApk ( this . currentApk , this . baksmaliDir , new File ( filename ) ) ; GuiWorkshop . messageDialog ( gui . getShell ( ) , "<STR_LIT>" ) ; } catch ( Exception e ) { GuiWorkshop . messageError ( gui . getShell ( ) , "<STR_LIT>" + e . getMessage ( ) ) ; logger . error ( "<STR_LIT>" , e ) ; } gui . clearStatus ( ) ; return ( new File ( filename ) ) ; } public void rebuildAndSignApk ( BuildAndSignApkBean bean ) { try { gui . setStatus ( "<STR_LIT>" + bean . getApkFilename ( ) ) ; SmaliWorkshop . buildApk ( this . currentApk , this . baksmaliDir , new File ( bean . getApkFilename ( ) ) ) ; try { gui . setStatus ( "<STR_LIT>" + bean . getApkFilename ( ) ) ; SmaliWorkshop . signJar ( bean . getCertFilename ( ) , bean . getPassword ( ) , bean . getApkFilename ( ) , bean . getCertAlias ( ) ) ; GuiWorkshop . messageDialog ( gui . getShell ( ) , "<STR_LIT>" ) ; } catch ( Exception e ) { GuiWorkshop . messageError ( gui . getShell ( ) , "<STR_LIT>" + e . getMessage ( ) ) ; logger . error ( "<STR_LIT>" , e ) ; } } catch ( BuildApkException e ) { GuiWorkshop . messageError ( gui . getShell ( ) , "<STR_LIT>" + e . getMessage ( ) ) ; logger . error ( "<STR_LIT>" , e ) ; } gui . clearStatus ( ) ; } public boolean unsavedFilesOpen ( ) { for ( CTabItem tab : gui . getSmaliTabFolder ( ) . getItems ( ) ) { if ( tab . getShowClose ( ) == true ) { if ( ( Boolean ) tab . getData ( MODIFIED ) == true ) { return ( true ) ; } } } return ( false ) ; } private CTabItem getTabByFullClasspath ( String classPath ) { for ( CTabItem tab : gui . getSmaliTabFolder ( ) . getItems ( ) ) { if ( tab . getShowClose ( ) == true ) { if ( ( ( String ) tab . getData ( CLASS ) ) . equals ( classPath ) ) { return ( tab ) ; } } } return ( null ) ; } private StyledText getStyledTextByFullClasspath ( String classPath ) { for ( CTabItem tab : gui . getSmaliTabFolder ( ) . getItems ( ) ) { if ( tab . getShowClose ( ) == true ) { if ( ( ( String ) tab . getData ( CLASS ) ) . equals ( classPath ) ) { return ( ( StyledText ) tab . getData ( StyledText . class . getName ( ) ) ) ; } } } return ( null ) ; } private class LoadSmaliSource implements Runnable { private int line = - <NUM_LIT:1> ; private String pkg ; private String name ; private String full ; public LoadSmaliSource ( String pkg , String name , int line ) { this . line = line ; this . pkg = pkg ; this . name = name ; this . full = ( pkg . equals ( "<STR_LIT>" ) ) ? name : pkg + "<STR_LIT:.>" + name ; } public LoadSmaliSource ( String pkg , String name ) { this . pkg = pkg ; this . name = name ; this . full = ( pkg . equals ( "<STR_LIT>" ) ) ? name : pkg + "<STR_LIT:.>" + name ; } public void run ( ) { CTabFolder smaliTabFolder = gui . getSmaliTabFolder ( ) ; CTabItem openFileTab = getTabByFullClasspath ( full ) ; if ( openFileTab != null ) { smaliTabFolder . setSelection ( openFileTab ) ; if ( this . line > - <NUM_LIT:1> ) { StyledText styledText = getStyledTextByFullClasspath ( full ) ; if ( styledText != null ) { styledText . setTopIndex ( this . line ) ; } } } else { try { File source = smaliMap . get ( full ) ; logger . debug ( "<STR_LIT>" + full + "<STR_LIT:U+0020:U+0020>" + source ) ; BufferedReader in = new BufferedReader ( new FileReader ( source ) ) ; String buf = "<STR_LIT>" ; String line ; while ( ( line = in . readLine ( ) ) != null ) { buf = buf + "<STR_LIT:n>" + line ; } CTabItemWithStyledText tabItem = new CTabItemWithStyledText ( smaliTabFolder , name , SWT . CLOSE ) ; tabItem . getStyledText ( ) . addLineStyleListener ( new SmaliLineStyler ( ) ) ; tabItem . getStyledText ( ) . setText ( buf ) ; tabItem . getStyledText ( ) . addModifyListener ( new ModifyListener ( ) { public void modifyText ( ModifyEvent arg0 ) { for ( CTabItem tab : gui . getSmaliTabFolder ( ) . getItems ( ) ) { if ( tab . getShowClose ( ) == true ) { StyledText styledText = ( ( StyledText ) tab . getData ( StyledText . class . getName ( ) ) ) ; if ( styledText == arg0 . getSource ( ) ) { if ( ( Boolean ) tab . getData ( MODIFIED ) == false ) { tab . setData ( MODIFIED , true ) ; tab . setText ( "<STR_LIT>" + tab . getText ( ) ) ; } else { if ( styledText . getText ( ) . equals ( tab . getData ( ORIGINAL_TEXT ) ) ) { tab . setData ( MODIFIED , false ) ; tab . setText ( tab . getText ( ) . substring ( <NUM_LIT:2> ) ) ; } } } } } } } ) ; addTextMenu ( tabItem . getStyledText ( ) ) ; if ( this . line > - <NUM_LIT:1> ) { tabItem . getStyledText ( ) . setTopIndex ( this . line ) ; } tabItem . setData ( ORIGINAL_TEXT , buf ) ; tabItem . setData ( MODIFIED , false ) ; tabItem . setData ( CLASS , full ) ; tabItem . setData ( FILENAME , source . getAbsolutePath ( ) ) ; } catch ( Exception e ) { gui . messageError ( "<STR_LIT>" + e . getMessage ( ) ) ; logger . error ( "<STR_LIT>" , e ) ; } } } } private class LoadApkRunnable implements Runnable { private Tree tree ; private File apk ; public LoadApkRunnable ( File apk ) { this . apk = apk ; tree = gui . getSmaliTree ( ) ; } public void run ( ) { gui . setStatus ( "<STR_LIT>" + apk . getAbsolutePath ( ) ) ; try { baksmaliDir = OterWorkshop . createTemporaryDirectory ( "<STR_LIT>" ) ; smaliMap = SmaliWorkshop . getSmaliSource ( apk , baksmaliDir ) ; gui . getDisplay ( ) . asyncExec ( new Runnable ( ) { public void run ( ) { tree . removeAll ( ) ; currentApk = apk ; for ( String c : smaliMap . keySet ( ) ) { int lastSlash = c . lastIndexOf ( "<STR_LIT:.>" ) ; String pkg = "<STR_LIT>" ; String name ; if ( lastSlash == - <NUM_LIT:1> ) { name = c ; TreeItem item = new TreeItem ( tree , SWT . NONE ) ; item . setText ( name ) ; } else { pkg = c . substring ( <NUM_LIT:0> , lastSlash ) ; name = c . substring ( ( lastSlash + <NUM_LIT:1> ) , c . length ( ) ) ; TreeItem existsInTree = getInTree ( pkg ) ; if ( existsInTree != null ) { TreeItem item = new TreeItem ( existsInTree , SWT . NONE ) ; item . setText ( name ) ; } else { TreeItem pkgTreeItem = new TreeItem ( tree , SWT . NONE ) ; pkgTreeItem . setImage ( SWTResourceManager . getImage ( Gui . class , OterStatics . ICON_PACKAGE ) ) ; pkgTreeItem . setText ( pkg ) ; TreeItem item = new TreeItem ( pkgTreeItem , SWT . NONE ) ; item . setText ( name ) ; } } } } } ) ; } catch ( final Exception e ) { logger . error ( "<STR_LIT>" , e ) ; GuiWorkshop . messageErrorThreaded ( gui , "<STR_LIT>" + e . getMessage ( ) ) ; } gui . clearStatus ( ) ; } private TreeItem getInTree ( String pkg ) { for ( TreeItem i : tree . getItems ( ) ) { if ( i . getText ( ) . equals ( pkg ) ) { return ( i ) ; } } return ( null ) ; } } private void addTextMenu ( final StyledText styledText ) { Shell shell = styledText . getShell ( ) ; Menu menu = new Menu ( shell , SWT . POP_UP ) ; MenuItem findItem = new MenuItem ( menu , SWT . NULL ) ; findItem . setText ( "<STR_LIT>" ) ; findItem . setAccelerator ( SWT . MOD1 + '<CHAR_LIT>' ) ; findItem . addSelectionListener ( new SelectionAdapter ( ) { public void widgetSelected ( SelectionEvent event ) { new FindDialog ( gui . getShell ( ) , styledText ) . open ( ) ; } } ) ; MenuItem item = new MenuItem ( menu , SWT . NULL ) ; item . setText ( "<STR_LIT>" ) ; item . setAccelerator ( SWT . MOD1 + '<CHAR_LIT>' ) ; item . addSelectionListener ( new SelectionAdapter ( ) { public void widgetSelected ( SelectionEvent event ) { styledText . cut ( ) ; } } ) ; item = new MenuItem ( menu , SWT . NULL ) ; item . setText ( "<STR_LIT>" ) ; item . setAccelerator ( SWT . MOD1 + '<CHAR_LIT>' ) ; item . addSelectionListener ( new SelectionAdapter ( ) { public void widgetSelected ( SelectionEvent event ) { styledText . copy ( ) ; } } ) ; item = new MenuItem ( menu , SWT . NULL ) ; item . setText ( "<STR_LIT>" ) ; item . setAccelerator ( SWT . MOD1 + '<CHAR_LIT>' ) ; item . addSelectionListener ( new SelectionAdapter ( ) { public void widgetSelected ( SelectionEvent event ) { styledText . paste ( ) ; } } ) ; new MenuItem ( menu , SWT . SEPARATOR ) ; item = new MenuItem ( menu , SWT . NULL ) ; item . setText ( "<STR_LIT>" ) ; item . setAccelerator ( SWT . MOD1 + '<CHAR_LIT:A>' ) ; item . addSelectionListener ( new SelectionAdapter ( ) { public void widgetSelected ( SelectionEvent event ) { styledText . selectAll ( ) ; } } ) ; new MenuItem ( menu , SWT . SEPARATOR ) ; item = new MenuItem ( menu , SWT . NULL ) ; item . setText ( "<STR_LIT>" ) ; item . setAccelerator ( SWT . MOD1 + '<CHAR_LIT>' ) ; item . addSelectionListener ( new SelectionAdapter ( ) { public void widgetSelected ( SelectionEvent event ) { try { saveTab ( getOpenSmaliTabByStyledText ( styledText ) ) ; } catch ( IOException e ) { GuiWorkshop . messageError ( gui . getShell ( ) , "<STR_LIT>" + e . getMessage ( ) ) ; logger . error ( "<STR_LIT>" , e ) ; } } } ) ; styledText . setMenu ( menu ) ; } private CTabItem getOpenSmaliTabByStyledText ( StyledText item ) { for ( CTabItem tab : gui . getSmaliTabFolder ( ) . getItems ( ) ) { if ( tab . getShowClose ( ) == true ) { if ( ( ( StyledText ) tab . getData ( StyledText . class . getName ( ) ) ) . equals ( item ) ) { return ( tab ) ; } } } return ( null ) ; } } </s>
<s> package com . wuntee . oter . smali ; import java . io . BufferedWriter ; import java . io . File ; import java . io . FileInputStream ; import java . io . FileOutputStream ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ; import java . security . InvalidKeyException ; import java . security . KeyStore ; import java . security . KeyStoreException ; import java . security . NoSuchAlgorithmException ; import java . security . NoSuchProviderException ; import java . security . PrivateKey ; import java . security . SignatureException ; import java . security . cert . CertificateException ; import java . security . cert . X509Certificate ; import java . util . HashMap ; import java . util . LinkedHashSet ; import java . util . Map ; import java . util . Set ; import java . util . TreeMap ; import org . antlr . runtime . CommonTokenStream ; import org . antlr . runtime . RecognitionException ; import org . antlr . runtime . TokenSource ; import org . antlr . runtime . tree . CommonTree ; import org . antlr . runtime . tree . CommonTreeNodeStream ; import org . apache . log4j . Logger ; import org . jf . baksmali . Adaptors . ClassDefinition ; import org . jf . dexlib . ClassDefItem ; import org . jf . dexlib . DexFile ; import org . jf . dexlib . Util . ByteArrayAnnotatedOutput ; import org . jf . smali . LexerErrorInterface ; import org . jf . smali . smaliFlexLexer ; import org . jf . smali . smaliParser ; import org . jf . smali . smaliTreeWalker ; import org . jf . util . IndentingWriter ; import sun . security . x509 . CertAndKeyGen ; import sun . security . x509 . X500Name ; import com . wuntee . oter . OterStatics ; import com . wuntee . oter . OterWorkshop ; import com . wuntee . oter . command . TerminatingCommand ; import com . wuntee . oter . exception . BuildApkException ; import com . wuntee . oter . exception . SmaliDexException ; import com . wuntee . oter . exception . SmaliSyntaxException ; import com . wuntee . oter . security . tools . JarSigner ; public class SmaliWorkshop { private static Logger logger = Logger . getLogger ( SmaliWorkshop . class ) ; public static String CLASSTYPE_HEAD = "<STR_LIT>" ; public static String classDefItemToFilename ( ClassDefItem c ) { String ct = c . getClassType ( ) . toString ( ) ; String ret = ct . substring ( CLASSTYPE_HEAD . length ( ) , ( ct . length ( ) - <NUM_LIT:1> ) ) . replace ( "<STR_LIT:/>" , "<STR_LIT:.>" ) ; return ( ret ) ; } public static File createSmaliClassFile ( File tmpDir , ClassDefItem c ) throws IOException { String ct = c . getClassType ( ) . toString ( ) ; String fullPath = tmpDir . getAbsolutePath ( ) + System . getProperty ( "<STR_LIT>" ) + ct . substring ( CLASSTYPE_HEAD . length ( ) , ( ct . length ( ) - <NUM_LIT:1> ) ) + "<STR_LIT>" ; logger . debug ( "<STR_LIT>" + fullPath ) ; String dirPath = fullPath . substring ( <NUM_LIT:0> , fullPath . lastIndexOf ( System . getProperty ( "<STR_LIT>" ) ) ) ; logger . debug ( "<STR_LIT>" + dirPath ) ; File dir = OterWorkshop . createDirectoryRecursive ( dirPath ) ; File ret = new File ( fullPath ) ; return ( ret ) ; } public static Map < String , File > getSmaliSource ( File sourceSmaliOrDexFile , File destinationDirectory ) throws IOException { Map < String , File > ret = new HashMap < String , File > ( ) ; DexFile dexFile = new DexFile ( sourceSmaliOrDexFile ) ; IndentingWriter idWriter ; for ( ClassDefItem c : dexFile . ClassDefsSection . getItems ( ) ) { File classFile = SmaliWorkshop . createSmaliClassFile ( destinationDirectory , c ) ; String className = SmaliWorkshop . classDefItemToFilename ( c ) ; logger . debug ( "<STR_LIT>" + className + "<STR_LIT>" + classFile + "<STR_LIT:]>" ) ; BufferedWriter fileWriter = new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( classFile ) ) ) ; idWriter = new IndentingWriter ( fileWriter ) ; ClassDefinition cd = new ClassDefinition ( c ) ; cd . writeTo ( idWriter ) ; ret . put ( className , classFile ) ; idWriter . close ( ) ; } return ( sortMapByKey ( ret ) ) ; } private static Map < String , File > sortMapByKey ( Map < String , File > aItems ) { TreeMap < String , File > result = new TreeMap < String , File > ( String . CASE_INSENSITIVE_ORDER ) ; result . putAll ( aItems ) ; return result ; } public static void buildApk ( File sourceApk , File smaliSourceDirectory , File destinationApkFile ) throws BuildApkException { try { File apkDirectory = OterWorkshop . createTemporaryDirectory ( "<STR_LIT>" ) ; OterWorkshop . unzipArchive ( sourceApk , apkDirectory ) ; File metaInfDirectory = new File ( apkDirectory . getAbsolutePath ( ) + System . getProperty ( "<STR_LIT>" ) + OterStatics . META_INF ) ; if ( metaInfDirectory . exists ( ) && metaInfDirectory . isDirectory ( ) ) { logger . info ( "<STR_LIT>" + metaInfDirectory . getAbsolutePath ( ) ) ; for ( File f : metaInfDirectory . listFiles ( ) ) { f . delete ( ) ; } } else { logger . warn ( "<STR_LIT>" ) ; } logger . debug ( metaInfDirectory . getAbsoluteFile ( ) ) ; metaInfDirectory . mkdir ( ) ; File destinationDexFile = new File ( apkDirectory . getAbsoluteFile ( ) + System . getProperty ( "<STR_LIT>" ) + OterStatics . CLASSES_DEX ) ; logger . debug ( "<STR_LIT>" + destinationDexFile . getAbsolutePath ( ) ) ; buildDex ( smaliSourceDirectory , destinationDexFile ) ; logger . debug ( "<STR_LIT>" + destinationApkFile . getAbsolutePath ( ) ) ; OterWorkshop . zipArchive ( destinationApkFile , apkDirectory ) ; } catch ( Exception e ) { logger . error ( "<STR_LIT>" , e ) ; throw new BuildApkException ( e . getMessage ( ) ) ; } } private static void buildDex ( File smaliSourceDirectory , File destination ) throws RecognitionException , SmaliSyntaxException , SmaliDexException , IOException { DexFile dexFile = new DexFile ( ) ; logger . debug ( "<STR_LIT>" ) ; LinkedHashSet < File > filesToProcess = new LinkedHashSet < File > ( ) ; getSmaliFilesInDir ( smaliSourceDirectory , filesToProcess ) ; logger . debug ( "<STR_LIT>" ) ; for ( File file : filesToProcess ) { logger . debug ( "<STR_LIT>" + file . getAbsolutePath ( ) ) ; FileInputStream fis = new FileInputStream ( file . getAbsolutePath ( ) ) ; InputStreamReader reader = new InputStreamReader ( fis , "<STR_LIT:UTF-8>" ) ; LexerErrorInterface lexer = new smaliFlexLexer ( reader ) ; ( ( smaliFlexLexer ) lexer ) . setSourceFile ( file ) ; CommonTokenStream tokens = new CommonTokenStream ( ( TokenSource ) lexer ) ; smaliParser parser = new smaliParser ( tokens ) ; smaliParser . smali_file_return result = parser . smali_file ( ) ; if ( parser . getNumberOfSyntaxErrors ( ) > <NUM_LIT:0> ) { throw new SmaliSyntaxException ( file , parser . getNumberOfSyntaxErrors ( ) ) ; } if ( lexer . getNumberOfSyntaxErrors ( ) > <NUM_LIT:0> ) { throw new SmaliSyntaxException ( file , lexer . getNumberOfSyntaxErrors ( ) ) ; } CommonTree t = ( CommonTree ) result . getTree ( ) ; CommonTreeNodeStream treeStream = new CommonTreeNodeStream ( t ) ; treeStream . setTokenStream ( tokens ) ; smaliTreeWalker dexGen = new smaliTreeWalker ( treeStream ) ; dexGen . dexFile = dexFile ; dexGen . smali_file ( ) ; if ( dexGen . getNumberOfSyntaxErrors ( ) > <NUM_LIT:0> ) { throw new SmaliDexException ( file , dexGen . getNumberOfSyntaxErrors ( ) ) ; } } logger . debug ( "<STR_LIT>" ) ; dexFile . place ( ) ; ByteArrayAnnotatedOutput out = new ByteArrayAnnotatedOutput ( ) ; dexFile . writeTo ( out ) ; byte [ ] bytes = out . toByteArray ( ) ; DexFile . calcSignature ( bytes ) ; DexFile . calcChecksum ( bytes ) ; FileOutputStream fileOutputStream = new FileOutputStream ( destination ) ; fileOutputStream . write ( bytes ) ; fileOutputStream . close ( ) ; } private static void getSmaliFilesInDir ( File dir , Set < File > smaliFiles ) { for ( File file : dir . listFiles ( ) ) { if ( file . isDirectory ( ) ) { getSmaliFilesInDir ( file , smaliFiles ) ; } else if ( file . getName ( ) . endsWith ( "<STR_LIT>" ) ) { smaliFiles . add ( file ) ; } } } public static void signJar ( String keystore , String keystorePassword , String jarFile , String alias ) throws Exception { TerminatingCommand c = new TerminatingCommand ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , keystore , "<STR_LIT>" , keystorePassword , jarFile , alias } ) ; int ret = c . execute ( ) ; if ( ret != <NUM_LIT:0> ) { String output = "<STR_LIT>" ; for ( String o : c . getOutput ( ) ) { output = output + o + "<STR_LIT:n>" ; } throw new Exception ( "<STR_LIT>" + output ) ; } } public static KeyStore createKeystoreWithSecretKey ( String alias ) throws KeyStoreException , NoSuchAlgorithmException , NoSuchProviderException , CertificateException , IOException , InvalidKeyException , SignatureException { KeyStore ret = KeyStore . getInstance ( KeyStore . getDefaultType ( ) ) ; ret . load ( null ) ; int keysize = <NUM_LIT> ; int validity = <NUM_LIT> ; String keyAlgName = "<STR_LIT>" ; String sigAlgName = "<STR_LIT>" ; CertAndKeyGen keypair = new CertAndKeyGen ( keyAlgName , sigAlgName , null ) ; X500Name x500Name = new X500Name ( OterStatics . SOME_STRING , OterStatics . SOME_STRING , OterStatics . SOME_STRING , OterStatics . SOME_STRING , OterStatics . SOME_STRING , OterStatics . SOME_STRING ) ; keypair . generate ( keysize ) ; PrivateKey privKey = keypair . getPrivateKey ( ) ; X509Certificate [ ] chain = new X509Certificate [ <NUM_LIT:1> ] ; chain [ <NUM_LIT:0> ] = keypair . getSelfCertificate ( x500Name , ( long ) validity * <NUM_LIT:24> * <NUM_LIT> * <NUM_LIT> ) ; ret . setKeyEntry ( alias , privKey , OterStatics . SOME_STRING . toCharArray ( ) , chain ) ; return ( ret ) ; } public static File writeKeystoreToTemporaryFile ( KeyStore ks , String password ) throws IOException , KeyStoreException , NoSuchAlgorithmException , CertificateException { File tmp = File . createTempFile ( OterStatics . TEMP_PREFIX , "<STR_LIT>" ) ; logger . debug ( "<STR_LIT>" + tmp . getAbsolutePath ( ) ) ; FileOutputStream out = new FileOutputStream ( tmp ) ; ks . store ( out , password . toCharArray ( ) ) ; return ( tmp ) ; } } </s>
<s> package controllers ; import models . Tick ; import play . db . ebean . Model ; import play . mvc . Controller ; import play . mvc . Result ; import java . util . List ; public class Application extends Controller { public static Result index ( ) { Tick tick = new Tick ( "<STR_LIT>" ) ; tick . save ( ) ; List < Tick > ticks = new Model . Finder ( Long . class , Tick . class ) . all ( ) ; return ok ( views . html . index . render ( ticks ) ) ; } } </s>
<s> package jobs ; import models . Tick ; import play . api . Play ; import play . api . Mode ; import play . api . Application ; import java . io . File ; public class TickJob { public static void main ( String [ ] args ) { Application application = new Application ( new File ( args [ <NUM_LIT:0> ] ) , TickJob . class . getClassLoader ( ) , null , Mode . Prod ( ) ) ; Play . start ( application ) ; Tick tick = new Tick ( "<STR_LIT>" ) ; tick . save ( ) ; } } </s>
<s> package models ; import play . db . ebean . Model ; import javax . persistence . Entity ; import javax . persistence . Id ; import java . util . Date ; @ Entity public class Tick extends Model { @ Id public Long id ; public Date createDate ; public String message ; public Tick ( ) { } public Tick ( String message ) { this . createDate = new Date ( ) ; this . message = message ; } } </s>
<s> package net . contrapunctus . lzma ; import java . io . ByteArrayInputStream ; import java . io . ByteArrayOutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . OutputStream ; import java . util . concurrent . ArrayBlockingQueue ; import org . junit . Test ; import static org . junit . Assert . * ; public class ApiDriftTest { @ Test public void versionAPI ( ) { int x = Version . major ; int y = Version . minor ; String s = Version . context ; Version . main ( new String [ <NUM_LIT:0> ] ) ; Version . main ( new String [ <NUM_LIT:1> ] ) ; Version v = new Version ( ) ; } @ Test public void outstreamAPI ( ) { LzmaOutputStream . LZMA_HEADER = false ; LzmaOutputStream los ; los = new LzmaOutputStream ( new ByteArrayOutputStream ( ) ) ; los = new LzmaOutputStream ( new ByteArrayOutputStream ( ) , <NUM_LIT:8> , <NUM_LIT:2> ) ; assertTrue ( los instanceof OutputStream ) ; } @ Test public void instreamAPI ( ) { LzmaInputStream lis ; lis = new LzmaInputStream ( new ByteArrayInputStream ( new byte [ <NUM_LIT:0> ] ) ) ; assertTrue ( lis instanceof InputStream ) ; } @ Test public void entryPoints ( ) throws IOException { RoundTripTest . main ( new String [ <NUM_LIT:0> ] ) ; RoundTripTest . main ( new String [ ] { "<STR_LIT>" } ) ; } @ Test public void strings ( ) { ArrayBlockingQueue < byte [ ] > q = ConcurrentBufferOutputStream . newQueue ( ) ; InputStream is = ConcurrentBufferInputStream . create ( q ) ; System . out . println ( is ) ; OutputStream os = ConcurrentBufferOutputStream . create ( q ) ; System . out . println ( os ) ; Thread th = new DecoderThread ( is ) ; System . out . println ( th ) ; th = new EncoderThread ( os , <NUM_LIT:0> , <NUM_LIT:0> ) ; System . out . println ( th ) ; is = new LzmaInputStream ( is ) ; System . out . println ( is ) ; os = new LzmaOutputStream ( os ) ; System . out . println ( os ) ; } } </s>
<s> package net . contrapunctus . lzma ; import java . io . IOException ; import java . io . OutputStream ; import java . util . ArrayList ; import java . util . Collection ; import java . util . Random ; import java . util . concurrent . ArrayBlockingQueue ; import java . util . zip . CRC32 ; import org . junit . Assert ; import org . junit . Test ; import org . junit . runner . RunWith ; import org . junit . runners . Parameterized . Parameters ; import org . junit . runners . Parameterized ; import static net . contrapunctus . lzma . ConcurrentBufferOutputStream . * ; @ RunWith ( Parameterized . class ) public class ConcurrentBufferOutputTest { @ Parameters public static Collection < Object [ ] > parameters ( ) { Collection < Object [ ] > args = new ArrayList < Object [ ] > ( ) ; args . add ( new Object [ ] { <NUM_LIT> } ) ; args . add ( new Object [ ] { System . currentTimeMillis ( ) } ) ; args . add ( new Object [ ] { <NUM_LIT> } ) ; return args ; } public static void main ( String [ ] args ) throws InterruptedException { new ConcurrentBufferOutputTest ( Long . parseLong ( args [ <NUM_LIT:0> ] ) ) . run ( ) ; } private long seed ; private Writer wr ; public ConcurrentBufferOutputTest ( long seed ) { this . seed = seed ; this . wr = ( <NUM_LIT> == seed ) ? new BoundaryWriter ( ) : new RandomWriter ( new Random ( seed ) ) ; } public String toString ( ) { return "<STR_LIT>" + seed + "<STR_LIT>" ; } @ Test ( timeout = <NUM_LIT> ) public void run ( ) throws InterruptedException { System . out . printf ( "<STR_LIT>" , this ) ; testReadWrite ( wr ) ; } static final int MAX_BUFFER = BUFSIZE * <NUM_LIT:2> ; static final int MAX_ITERS = QUEUESIZE * <NUM_LIT:2> ; private static final boolean DEBUG ; static { String ds = null ; try { ds = System . getProperty ( "<STR_LIT>" ) ; } catch ( SecurityException e ) { } DEBUG = ds != null ; } static abstract class Summer extends Thread { protected CRC32 sum = new CRC32 ( ) ; Exception exn ; long getSum ( ) { return sum . getValue ( ) ; } protected abstract void checkedRun ( ) throws IOException , InterruptedException ; public void run ( ) { try { checkedRun ( ) ; } catch ( Exception exn ) { System . out . println ( exn ) ; exn . printStackTrace ( ) ; this . exn = exn ; } } } abstract class Writer extends Summer { protected OutputStream os ; Writer init ( OutputStream os ) { this . os = os ; return this ; } void write ( int i ) throws IOException { os . write ( i ) ; sum . update ( i ) ; if ( DEBUG ) System . out . println ( "<STR_LIT>" ) ; } void write ( byte [ ] buf ) throws IOException { os . write ( buf ) ; sum . update ( buf , <NUM_LIT:0> , buf . length ) ; if ( DEBUG ) System . out . println ( "<STR_LIT>" + buf . length + "<STR_LIT>" ) ; } void write ( byte [ ] buf , int off , int len ) throws IOException { os . write ( buf , off , len ) ; sum . update ( buf , off , len ) ; if ( DEBUG ) System . out . println ( "<STR_LIT>" + len + "<STR_LIT>" + off ) ; } } class BoundaryWriter extends Writer { protected void checkedRun ( ) throws IOException { for ( int i = - <NUM_LIT:255> ; i <= <NUM_LIT:255> ; i ++ ) { write ( i ) ; } write ( new byte [ <NUM_LIT:0> ] ) ; write ( new byte [ <NUM_LIT:0> ] , <NUM_LIT:0> , <NUM_LIT:0> ) ; write ( <NUM_LIT> ) ; os . close ( ) ; } } class RandomWriter extends Writer { protected Random rng ; RandomWriter ( Random rng ) { this . rng = rng ; } void write ( ) throws IOException { byte [ ] bs = new byte [ rng . nextInt ( MAX_BUFFER ) + <NUM_LIT:2> ] ; rng . nextBytes ( bs ) ; switch ( rng . nextInt ( <NUM_LIT:4> ) ) { case <NUM_LIT:0> : write ( bs [ <NUM_LIT:0> ] ) ; break ; case <NUM_LIT:1> : int off = rng . nextInt ( bs . length - <NUM_LIT:1> ) ; int len = rng . nextInt ( bs . length - off - <NUM_LIT:1> ) + <NUM_LIT:1> ; write ( bs , off , len ) ; break ; default : write ( bs ) ; } } protected void checkedRun ( ) throws IOException { for ( int i = rng . nextInt ( MAX_ITERS ) + <NUM_LIT:5> ; i >= <NUM_LIT:0> ; i -- ) { if ( rng . nextBoolean ( ) ) yield ( ) ; write ( ) ; } os . close ( ) ; } } class Reader extends Summer { protected ArrayBlockingQueue < byte [ ] > q ; Reader ( ArrayBlockingQueue < byte [ ] > q ) { this . q = q ; } protected void checkedRun ( ) throws InterruptedException { byte [ ] bs = q . take ( ) ; while ( bs . length > <NUM_LIT:0> ) { if ( DEBUG ) System . out . println ( "<STR_LIT>" + bs . length + "<STR_LIT>" ) ; sum . update ( bs , <NUM_LIT:0> , bs . length ) ; if ( bs . length % <NUM_LIT:11> == <NUM_LIT:0> ) Thread . yield ( ) ; bs = q . take ( ) ; } } } private void testReadWrite ( Writer wr ) throws InterruptedException { ArrayBlockingQueue < byte [ ] > q = newQueue ( ) ; OutputStream os = create ( q ) ; wr . init ( os ) ; wr . start ( ) ; Reader rd = new Reader ( q ) ; rd . run ( ) ; wr . join ( ) ; Assert . assertNull ( wr . exn ) ; Assert . assertNull ( rd . exn ) ; System . out . printf ( "<STR_LIT>" , wr . getSum ( ) , rd . getSum ( ) ) ; Assert . assertEquals ( wr . getSum ( ) , rd . getSum ( ) ) ; } } </s>
<s> package net . contrapunctus . lzma ; import SevenZip . Compression . LZMA . Decoder ; import java . io . IOException ; import java . io . InputStream ; import java . io . OutputStream ; import java . io . PrintStream ; import java . util . concurrent . ArrayBlockingQueue ; class DecoderThread extends Thread { protected ArrayBlockingQueue < byte [ ] > q ; protected InputStream in ; protected OutputStream out ; protected Decoder dec ; protected IOException exn ; private static final PrintStream dbg = System . err ; private static final boolean DEBUG ; static { String ds = null ; try { ds = System . getProperty ( "<STR_LIT>" ) ; } catch ( SecurityException e ) { } DEBUG = ds != null ; } DecoderThread ( InputStream _in ) { q = ConcurrentBufferOutputStream . newQueue ( ) ; in = _in ; out = ConcurrentBufferOutputStream . create ( q ) ; dec = new Decoder ( ) ; exn = null ; if ( DEBUG ) dbg . printf ( "<STR_LIT>" , this , out , q ) ; } static final int propSize = <NUM_LIT:5> ; static final byte [ ] props = new byte [ propSize ] ; static { props [ <NUM_LIT:0> ] = <NUM_LIT> ; props [ <NUM_LIT:1> ] = <NUM_LIT:0x00> ; props [ <NUM_LIT:2> ] = <NUM_LIT:0x00> ; props [ <NUM_LIT:3> ] = <NUM_LIT> ; props [ <NUM_LIT:4> ] = <NUM_LIT:0x00> ; } public void run ( ) { try { long outSize = <NUM_LIT:0> ; if ( LzmaOutputStream . LZMA_HEADER ) { int n = in . read ( props , <NUM_LIT:0> , propSize ) ; if ( n != propSize ) throw new IOException ( "<STR_LIT>" ) ; dec . SetDecoderProperties ( props ) ; for ( int i = <NUM_LIT:0> ; i < <NUM_LIT:8> ; i ++ ) { int v = in . read ( ) ; if ( v < <NUM_LIT:0> ) throw new IOException ( "<STR_LIT>" ) ; outSize |= ( ( long ) v ) << ( <NUM_LIT:8> * i ) ; } } else { outSize = - <NUM_LIT:1> ; dec . SetDecoderProperties ( props ) ; } if ( DEBUG ) dbg . printf ( "<STR_LIT>" , this ) ; dec . Code ( in , out , outSize ) ; if ( DEBUG ) dbg . printf ( "<STR_LIT>" , this ) ; in . close ( ) ; } catch ( IOException _exn ) { exn = _exn ; if ( DEBUG ) dbg . printf ( "<STR_LIT>" , this , exn . getMessage ( ) ) ; } try { out . close ( ) ; } catch ( IOException _exn ) { } } public void maybeThrow ( ) throws IOException { if ( exn != null ) { throw exn ; } } public String toString ( ) { return String . format ( "<STR_LIT>" , hashCode ( ) ) ; } } </s>
<s> package net . contrapunctus . lzma ; import java . io . * ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collection ; import org . junit . Assert ; import org . junit . Test ; import org . junit . runner . RunWith ; import org . junit . runners . Parameterized . Parameters ; import org . junit . runners . Parameterized ; import static org . junit . Assert . * ; @ RunWith ( Parameterized . class ) public class RoundTripTest { @ Parameters public static Collection < Object [ ] > files ( ) throws FileNotFoundException { File dir = new File ( "<STR_LIT>" ) ; File [ ] fs = dir . listFiles ( ) ; if ( null == fs ) { throw new FileNotFoundException ( "<STR_LIT>" ) ; } Collection < Object [ ] > args = new ArrayList < Object [ ] > ( ) ; for ( File f : fs ) { args . add ( new Object [ ] { f , false } ) ; args . add ( new Object [ ] { f , true } ) ; } args . add ( new Object [ ] { null , false } ) ; args . add ( new Object [ ] { null , true } ) ; return args ; } String name ; byte [ ] original ; boolean header ; boolean DEBUG ; public RoundTripTest ( File file , boolean header ) throws IOException { this . header = header ; if ( file != null ) { this . name = file . getName ( ) ; RandomAccessFile f = new RandomAccessFile ( file , "<STR_LIT:r>" ) ; long len = f . length ( ) ; assert len < Integer . MAX_VALUE ; original = new byte [ ( int ) len ] ; f . readFully ( original ) ; f . close ( ) ; } else { String s = null ; try { s = System . getProperty ( "<STR_LIT>" ) ; } catch ( SecurityException e ) { } if ( s == null ) s = "<STR_LIT>" ; this . name = "<STR_LIT:->" ; this . original = s . getBytes ( ) ; this . DEBUG = true ; } } public String toString ( ) { return name + '<CHAR_LIT:[>' + ( header ? '<CHAR_LIT>' : '<CHAR_LIT:->' ) + '<CHAR_LIT:]>' ; } @ Test public void run ( ) throws IOException { System . out . printf ( "<STR_LIT>" , this ) ; LzmaOutputStream . LZMA_HEADER = header ; ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; LzmaOutputStream los = new LzmaOutputStream ( baos ) ; los . write ( original ) ; los . close ( ) ; byte [ ] compressed = baos . toByteArray ( ) ; System . out . printf ( "<STR_LIT>" , original . length , compressed . length ) ; if ( DEBUG ) { for ( int i = <NUM_LIT:0> ; i < compressed . length ; i ++ ) { System . out . printf ( "<STR_LIT>" , compressed [ i ] ) ; } System . out . println ( ) ; } ByteArrayInputStream bais = new ByteArrayInputStream ( compressed ) ; LzmaInputStream lis = new LzmaInputStream ( bais ) ; DataInputStream dis = new DataInputStream ( lis ) ; byte [ ] expanded = new byte [ original . length ] ; dis . readFully ( expanded ) ; Assert . assertTrue ( Arrays . equals ( original , expanded ) ) ; } @ Test public void withLzmaCommand ( ) throws IOException , InterruptedException { if ( ! header ) return ; LzmaOutputStream . LZMA_HEADER = header ; System . out . printf ( "<STR_LIT>" , this ) ; File lzfile = File . createTempFile ( "<STR_LIT>" , "<STR_LIT>" ) ; FileOutputStream fos = new FileOutputStream ( lzfile ) ; LzmaOutputStream los = new LzmaOutputStream ( fos ) ; los . write ( original ) ; los . close ( ) ; System . out . printf ( "<STR_LIT>" , lzfile . getName ( ) ) ; Runtime rt = Runtime . getRuntime ( ) ; Process p = rt . exec ( "<STR_LIT>" + lzfile ) ; int r = p . waitFor ( ) ; assertEquals ( r , <NUM_LIT:0> ) ; String path = lzfile . getPath ( ) ; assertTrue ( path . endsWith ( "<STR_LIT>" ) ) ; int k = path . lastIndexOf ( '<CHAR_LIT:.>' ) ; File plain = new File ( path . substring ( <NUM_LIT:0> , k ) ) ; assertTrue ( plain . exists ( ) ) ; RandomAccessFile raf = new RandomAccessFile ( plain , "<STR_LIT:r>" ) ; long len = raf . length ( ) ; assert len < Integer . MAX_VALUE ; byte [ ] copy = new byte [ ( int ) len ] ; raf . readFully ( copy ) ; raf . close ( ) ; assertTrue ( Arrays . equals ( original , copy ) ) ; lzfile . delete ( ) ; plain . delete ( ) ; } public static void main ( String [ ] args ) throws IOException { if ( <NUM_LIT:0> == args . length ) { new RoundTripTest ( null , false ) . run ( ) ; new RoundTripTest ( null , true ) . run ( ) ; } else { for ( String s : args ) { new RoundTripTest ( new File ( s ) , false ) . run ( ) ; new RoundTripTest ( new File ( s ) , true ) . run ( ) ; } } } } </s>
<s> package net . contrapunctus . lzma ; import java . io . ByteArrayInputStream ; import java . io . ByteArrayOutputStream ; import java . io . IOException ; import java . util . Random ; import java . util . zip . Adler32 ; import java . util . zip . Checksum ; public class Benchmark { private static byte [ ] [ ] data = null ; private static final Random rnd = new Random ( <NUM_LIT> ) ; private static final Checksum ck = new Adler32 ( ) ; private static final int EXPONENT = <NUM_LIT> ; private static final int ITERATIONS = <NUM_LIT> ; private static final int BUFSIZE = <NUM_LIT> ; static { data = new byte [ EXPONENT ] [ ] ; int num = <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < data . length ; i ++ , num *= <NUM_LIT:2> ) { data [ i ] = new byte [ num ] ; rnd . nextBytes ( data [ i ] ) ; } } public static void doit ( ) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; LzmaOutputStream lo = new LzmaOutputStream ( baos ) ; int byteCount = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < ITERATIONS ; i ++ ) { int k = rnd . nextInt ( data . length ) ; lo . write ( data [ k ] ) ; ck . update ( data [ k ] , <NUM_LIT:0> , data [ k ] . length ) ; byteCount += data [ k ] . length ; } lo . close ( ) ; byte [ ] buf = baos . toByteArray ( ) ; long sum = ck . getValue ( ) ; System . out . printf ( "<STR_LIT>" , byteCount , buf . length , sum ) ; ByteArrayInputStream bais = new ByteArrayInputStream ( buf ) ; LzmaInputStream li = new LzmaInputStream ( bais ) ; buf = new byte [ BUFSIZE ] ; ck . reset ( ) ; int k = li . read ( buf ) ; byteCount = <NUM_LIT:0> ; while ( k > <NUM_LIT:0> ) { byteCount += k ; ck . update ( buf , <NUM_LIT:0> , k ) ; k = li . read ( buf ) ; } System . out . printf ( "<STR_LIT>" , byteCount , ck . getValue ( ) ) ; assert sum == ck . getValue ( ) ; } public static void main ( String [ ] args ) throws IOException { long start = System . nanoTime ( ) ; doit ( ) ; long elapsed = System . nanoTime ( ) - start ; elapsed /= <NUM_LIT:1000> ; System . out . printf ( "<STR_LIT>" , elapsed ) ; } } </s>
<s> package net . contrapunctus . lzma ; import java . io . BufferedInputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . InterruptedIOException ; import java . io . PrintStream ; import java . util . concurrent . ArrayBlockingQueue ; class ConcurrentBufferInputStream extends InputStream { protected ArrayBlockingQueue < byte [ ] > q ; protected byte [ ] buf = null ; protected int next = <NUM_LIT:0> ; protected boolean eof = false ; private static final PrintStream dbg = System . err ; private static final boolean DEBUG ; static { String ds = null ; try { ds = System . getProperty ( "<STR_LIT>" ) ; } catch ( SecurityException e ) { } DEBUG = ds != null ; } private ConcurrentBufferInputStream ( ArrayBlockingQueue < byte [ ] > q ) { if ( DEBUG ) dbg . printf ( "<STR_LIT>" , this , q ) ; this . q = q ; this . eof = false ; } static InputStream create ( ArrayBlockingQueue < byte [ ] > q ) { InputStream in = new ConcurrentBufferInputStream ( q ) ; return in ; } protected byte [ ] guarded_take ( ) throws IOException { try { return q . take ( ) ; } catch ( InterruptedException exn ) { throw new InterruptedIOException ( exn . getMessage ( ) ) ; } } protected boolean prepareAndCheckEOF ( ) throws IOException { if ( eof ) return true ; if ( buf == null || next >= buf . length ) { buf = guarded_take ( ) ; next = <NUM_LIT:0> ; if ( buf . length == <NUM_LIT:0> ) { eof = true ; return true ; } } return false ; } public int read ( ) throws IOException { if ( prepareAndCheckEOF ( ) ) { return - <NUM_LIT:1> ; } int x = buf [ next ] ; next ++ ; return x & <NUM_LIT> ; } public int read ( byte [ ] b , int off , int len ) throws IOException { if ( prepareAndCheckEOF ( ) ) { return - <NUM_LIT:1> ; } int k = buf . length - next ; if ( len < k ) { k = len ; } System . arraycopy ( buf , next , b , off , k ) ; next += k ; return k ; } public String toString ( ) { return String . format ( "<STR_LIT>" , hashCode ( ) ) ; } } </s>
<s> package net . contrapunctus . lzma ; import java . io . InputStream ; import java . io . OutputStream ; import java . io . IOException ; public class Command { static void copy ( InputStream in , OutputStream out ) throws IOException { final int BUFSIZE = <NUM_LIT> ; byte [ ] buf = new byte [ BUFSIZE ] ; int n = in . read ( buf ) ; while ( n != - <NUM_LIT:1> ) { out . write ( buf , <NUM_LIT:0> , n ) ; n = in . read ( buf ) ; } out . close ( ) ; } public static void main ( String [ ] args ) throws IOException { copy ( System . in , new LzmaOutputStream ( System . out ) ) ; } } </s>
<s> package net . contrapunctus . lzma ; import java . io . BufferedReader ; import java . io . FileInputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Collection ; import java . util . Random ; import java . util . concurrent . ArrayBlockingQueue ; import org . junit . Assert ; import org . junit . Test ; import org . junit . runner . RunWith ; import org . junit . runners . Parameterized . Parameters ; import org . junit . runners . Parameterized ; import static net . contrapunctus . lzma . ConcurrentBufferInputStream . create ; import static net . contrapunctus . lzma . ConcurrentBufferOutputStream . newQueue ; import static net . contrapunctus . lzma . ConcurrentBufferOutputTest . * ; @ RunWith ( Parameterized . class ) public class ConcurrentBufferInputTest { @ Parameters public static Collection < Object [ ] > parameters ( ) throws IOException { Collection < Object [ ] > args = new ArrayList < Object [ ] > ( ) ; args . add ( new Object [ ] { System . currentTimeMillis ( ) , true } ) ; args . add ( new Object [ ] { System . currentTimeMillis ( ) , false } ) ; args . add ( new Object [ ] { <NUM_LIT> , false } ) ; return args ; } public static void main ( String [ ] args ) throws InterruptedException { new ConcurrentBufferInputTest ( Long . parseLong ( args [ <NUM_LIT:0> ] ) , Boolean . parseBoolean ( args [ <NUM_LIT:1> ] ) ) . run ( ) ; } boolean boundary ; long seed ; public ConcurrentBufferInputTest ( long seed , boolean boundary ) { this . seed = seed ; this . boundary = boundary ; } public String toString ( ) { return ( boundary ? "<STR_LIT>" : "<STR_LIT>" ) + "<STR_LIT>" + seed + '<CHAR_LIT>' ; } @ Test ( timeout = <NUM_LIT> ) public void run ( ) throws InterruptedException { System . out . printf ( "<STR_LIT>" , this ) ; Random rng = new Random ( seed ) ; if ( boundary ) { testReadWrite ( rng , new BoundaryWriter ( ) ) ; } else { Random rng2 = new Random ( rng . nextLong ( ) ) ; testReadWrite ( rng , new RandomWriter ( rng2 ) ) ; } } abstract class Writer extends Summer { protected ArrayBlockingQueue < byte [ ] > q ; Writer init ( ArrayBlockingQueue < byte [ ] > q ) { this . q = q ; return this ; } void write ( int i ) throws InterruptedException { byte b [ ] = new byte [ <NUM_LIT:1> ] ; b [ <NUM_LIT:0> ] = ( byte ) i ; q . put ( b ) ; sum . update ( i ) ; } void write ( byte [ ] buf ) throws InterruptedException { q . put ( buf ) ; sum . update ( buf , <NUM_LIT:0> , buf . length ) ; } } class BoundaryWriter extends Writer { protected void checkedRun ( ) throws InterruptedException { for ( int i = - <NUM_LIT:255> ; i <= <NUM_LIT:255> ; i ++ ) { write ( i ) ; } write ( <NUM_LIT> ) ; write ( new byte [ <NUM_LIT:0> ] ) ; } } class RandomWriter extends Writer { protected Random rng ; RandomWriter ( Random rng ) { this . rng = rng ; } void write ( ) throws InterruptedException { byte [ ] bs = new byte [ rng . nextInt ( MAX_BUFFER ) + <NUM_LIT:1> ] ; rng . nextBytes ( bs ) ; switch ( rng . nextInt ( <NUM_LIT:4> ) ) { case <NUM_LIT:0> : write ( bs [ <NUM_LIT:0> ] ) ; break ; default : write ( bs ) ; } } protected void checkedRun ( ) throws InterruptedException { for ( int i = rng . nextInt ( MAX_ITERS ) + <NUM_LIT:5> ; i >= <NUM_LIT:0> ; i -- ) { if ( rng . nextBoolean ( ) ) yield ( ) ; write ( ) ; } q . put ( new byte [ <NUM_LIT:0> ] ) ; } } class Reader extends Summer { protected Random rng ; protected InputStream is ; Reader ( Random rng , InputStream is ) { this . rng = rng ; this . is = is ; } boolean read ( ) throws IOException { byte [ ] bs = new byte [ rng . nextInt ( MAX_BUFFER ) + <NUM_LIT:2> ] ; int n ; switch ( rng . nextInt ( <NUM_LIT:4> ) ) { case <NUM_LIT:0> : int b = is . read ( ) ; if ( b != - <NUM_LIT:1> ) { sum . update ( b ) ; return true ; } return false ; case <NUM_LIT:1> : int off = rng . nextInt ( bs . length - <NUM_LIT:1> ) ; int len = rng . nextInt ( bs . length - off - <NUM_LIT:1> ) + <NUM_LIT:1> ; n = is . read ( bs , off , len ) ; if ( n != - <NUM_LIT:1> ) { sum . update ( bs , off , n ) ; return true ; } return false ; default : n = is . read ( bs ) ; if ( n != - <NUM_LIT:1> ) { sum . update ( bs , <NUM_LIT:0> , n ) ; return true ; } return false ; } } protected void checkedRun ( ) throws IOException { while ( read ( ) ) { } is . close ( ) ; } } private void testReadWrite ( Random rng , Writer wr ) throws InterruptedException { ArrayBlockingQueue < byte [ ] > q = newQueue ( ) ; InputStream is = create ( q ) ; wr . init ( q ) ; wr . start ( ) ; Reader rd = new Reader ( rng , is ) ; rd . run ( ) ; wr . join ( ) ; Assert . assertNull ( wr . exn ) ; Assert . assertNull ( rd . exn ) ; System . out . printf ( "<STR_LIT>" , wr . getSum ( ) , rd . getSum ( ) ) ; Assert . assertEquals ( wr . getSum ( ) , rd . getSum ( ) ) ; } } </s>
<s> package net . contrapunctus . lzma ; import SevenZip . Compression . LZMA . Encoder ; import SevenZip . Compression . LZMA . Decoder ; import java . io . * ; public class LzmaInputStream extends FilterInputStream { protected DecoderThread dth ; private static final PrintStream dbg = System . err ; private static final boolean DEBUG ; static { String ds = null ; try { ds = System . getProperty ( "<STR_LIT>" ) ; } catch ( SecurityException e ) { } DEBUG = ds != null ; } public LzmaInputStream ( InputStream _in ) { super ( null ) ; dth = new DecoderThread ( _in ) ; in = ConcurrentBufferInputStream . create ( dth . q ) ; if ( DEBUG ) dbg . printf ( "<STR_LIT>" , this , in , dth . q ) ; dth . start ( ) ; } public int read ( ) throws IOException { int k = in . read ( ) ; dth . maybeThrow ( ) ; return k ; } public int read ( byte [ ] b , int off , int len ) throws IOException { int k = in . read ( b , off , len ) ; dth . maybeThrow ( ) ; return k ; } public void close ( ) throws IOException { if ( DEBUG ) dbg . printf ( "<STR_LIT>" , this ) ; super . close ( ) ; } public String toString ( ) { return String . format ( "<STR_LIT>" , hashCode ( ) ) ; } } </s>
<s> package net . contrapunctus . lzma ; import java . io . * ; import java . util . ArrayList ; import java . util . Collection ; import java . util . zip . CRC32 ; import java . util . zip . CheckedInputStream ; import org . junit . Test ; import org . junit . runner . RunWith ; import org . junit . runners . Parameterized . Parameters ; import org . junit . runners . Parameterized ; import static org . junit . Assert . assertTrue ; @ RunWith ( Parameterized . class ) public class LzmaCompatTest { @ Parameters public static Collection < Object [ ] > parameters ( ) throws FileNotFoundException { File dir = new File ( "<STR_LIT>" ) ; File [ ] fs = dir . listFiles ( ) ; if ( null == fs ) { throw new FileNotFoundException ( "<STR_LIT>" ) ; } Collection < Object [ ] > args = new ArrayList < Object [ ] > ( ) ; for ( File f : fs ) { args . add ( new Object [ ] { f } ) ; } return args ; } File file ; public LzmaCompatTest ( File file ) { this . file = file ; } public String toString ( ) { return file . toString ( ) ; } @ Test public void decode ( ) throws IOException { System . out . printf ( "<STR_LIT>" , this ) ; FileInputStream fis = new FileInputStream ( file ) ; LzmaInputStream lis = new LzmaInputStream ( fis ) ; CRC32 sum = new CRC32 ( ) ; CheckedInputStream cis = new CheckedInputStream ( lis , sum ) ; byte [ ] buf = new byte [ <NUM_LIT> ] ; int k , n = <NUM_LIT:0> ; while ( - <NUM_LIT:1> != ( k = cis . read ( buf ) ) ) { n += k ; } cis . close ( ) ; long val = sum . getValue ( ) ; System . out . printf ( "<STR_LIT>" , n , val ) ; assertTrue ( file . getName ( ) . startsWith ( Long . toHexString ( val ) ) ) ; } } </s>
<s> package net . contrapunctus . lzma ; import SevenZip . Compression . LZMA . Encoder ; import java . io . IOException ; import java . io . InputStream ; import java . io . OutputStream ; import java . io . PrintStream ; import java . util . concurrent . ArrayBlockingQueue ; class EncoderThread extends Thread { public static final Integer DEFAULT_DICT_SZ_POW2 = new Integer ( <NUM_LIT:20> ) ; protected ArrayBlockingQueue < byte [ ] > q ; protected InputStream in ; protected OutputStream out ; protected Encoder enc ; protected IOException exn ; private static final PrintStream dbg = System . err ; private static final boolean DEBUG ; static { String ds = null ; try { ds = System . getProperty ( "<STR_LIT>" ) ; } catch ( SecurityException e ) { } DEBUG = ds != null ; } EncoderThread ( OutputStream _out , Integer dictSzPow2 , Integer fastBytes ) { q = ConcurrentBufferOutputStream . newQueue ( ) ; in = ConcurrentBufferInputStream . create ( q ) ; out = _out ; enc = new Encoder ( ) ; exn = null ; enc . SetDictionarySize ( <NUM_LIT:1> << ( dictSzPow2 == null ? DEFAULT_DICT_SZ_POW2 : dictSzPow2 ) . intValue ( ) ) ; if ( fastBytes != null ) enc . SetNumFastBytes ( fastBytes . intValue ( ) ) ; if ( DEBUG ) dbg . printf ( "<STR_LIT>" , this , in , q ) ; } public void run ( ) { try { enc . SetEndMarkerMode ( true ) ; if ( LzmaOutputStream . LZMA_HEADER ) { enc . WriteCoderProperties ( out ) ; long fileSize = - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < <NUM_LIT:8> ; i ++ ) out . write ( ( int ) ( fileSize > > > ( <NUM_LIT:8> * i ) ) & <NUM_LIT> ) ; } if ( DEBUG ) dbg . printf ( "<STR_LIT>" , this ) ; enc . Code ( in , out , - <NUM_LIT:1> , - <NUM_LIT:1> , null ) ; if ( DEBUG ) dbg . printf ( "<STR_LIT>" , this ) ; out . close ( ) ; } catch ( IOException _exn ) { exn = _exn ; if ( DEBUG ) dbg . printf ( "<STR_LIT>" , exn . getMessage ( ) ) ; } } public String toString ( ) { return String . format ( "<STR_LIT>" , hashCode ( ) ) ; } } </s>
<s> package net . contrapunctus . lzma ; import java . io . BufferedOutputStream ; import java . io . IOException ; import java . io . InterruptedIOException ; import java . io . OutputStream ; import java . io . PrintStream ; import java . util . concurrent . ArrayBlockingQueue ; class ConcurrentBufferOutputStream extends OutputStream { protected ArrayBlockingQueue < byte [ ] > q ; static final int BUFSIZE = <NUM_LIT> ; static final int QUEUESIZE = <NUM_LIT> ; private static final PrintStream dbg = System . err ; private static final boolean DEBUG ; static { String ds = null ; try { ds = System . getProperty ( "<STR_LIT>" ) ; } catch ( SecurityException e ) { } DEBUG = ds != null ; } private ConcurrentBufferOutputStream ( ArrayBlockingQueue < byte [ ] > q ) { if ( DEBUG ) dbg . printf ( "<STR_LIT>" , this , q ) ; this . q = q ; } static OutputStream create ( ArrayBlockingQueue < byte [ ] > q ) { OutputStream out = new ConcurrentBufferOutputStream ( q ) ; out = new BufferedOutputStream ( out , BUFSIZE ) ; return out ; } static ArrayBlockingQueue < byte [ ] > newQueue ( ) { return new ArrayBlockingQueue < byte [ ] > ( QUEUESIZE ) ; } protected void guarded_put ( byte [ ] a ) throws IOException { try { q . put ( a ) ; } catch ( InterruptedException exn ) { throw new InterruptedIOException ( exn . getMessage ( ) ) ; } } public void write ( int i ) throws IOException { byte b [ ] = new byte [ <NUM_LIT:1> ] ; b [ <NUM_LIT:0> ] = ( byte ) ( i & <NUM_LIT> ) ; guarded_put ( b ) ; } public void write ( byte [ ] b , int off , int len ) throws IOException { byte [ ] a = new byte [ len ] ; System . arraycopy ( b , off , a , <NUM_LIT:0> , len ) ; guarded_put ( a ) ; } public void close ( ) throws IOException { if ( DEBUG ) dbg . printf ( "<STR_LIT>" , this ) ; byte b [ ] = new byte [ <NUM_LIT:0> ] ; guarded_put ( b ) ; } } </s>
<s> package net . contrapunctus . lzma ; import java . io . ByteArrayOutputStream ; import java . io . FilterOutputStream ; import java . io . IOException ; import java . io . InterruptedIOException ; import java . io . OutputStream ; import java . io . PrintStream ; import SevenZip . Compression . LZMA . Encoder ; import java . io . ByteArrayInputStream ; public class LzmaOutputStream extends FilterOutputStream { protected EncoderThread eth ; public static boolean LZMA_HEADER = true ; private static final PrintStream dbg = System . err ; private static final boolean DEBUG ; static { String ds = null ; try { ds = System . getProperty ( "<STR_LIT>" ) ; } catch ( SecurityException e ) { } DEBUG = ds != null ; } public LzmaOutputStream ( OutputStream _out ) { this ( _out , EncoderThread . DEFAULT_DICT_SZ_POW2 , null ) ; } public LzmaOutputStream ( OutputStream _out , Integer dictSzPow2 , Integer fastBytes ) { super ( null ) ; eth = new EncoderThread ( _out , dictSzPow2 , fastBytes ) ; out = ConcurrentBufferOutputStream . create ( eth . q ) ; if ( DEBUG ) dbg . printf ( "<STR_LIT>" , this , out , eth . q ) ; eth . start ( ) ; } public void write ( int i ) throws IOException { if ( eth . exn != null ) { throw eth . exn ; } out . write ( i ) ; } public void close ( ) throws IOException { if ( DEBUG ) dbg . printf ( "<STR_LIT>" , this ) ; out . close ( ) ; try { eth . join ( ) ; if ( DEBUG ) dbg . printf ( "<STR_LIT>" , this , eth ) ; } catch ( InterruptedException exn ) { throw new InterruptedIOException ( exn . getMessage ( ) ) ; } if ( eth . exn != null ) { throw eth . exn ; } } public String toString ( ) { return String . format ( "<STR_LIT>" , hashCode ( ) ) ; } } </s>
<s> package net . contrapunctus . lzma ; import java . io . ByteArrayInputStream ; import java . io . IOException ; import org . junit . Test ; public class ExceptionTest { private void readLzma ( byte [ ] bs ) throws IOException { ByteArrayInputStream bais = new ByteArrayInputStream ( bs ) ; LzmaInputStream lis = new LzmaInputStream ( bais ) ; int x = lis . read ( ) ; } @ Test ( timeout = <NUM_LIT> , expected = IOException . class ) public void truncatedLzma ( ) throws IOException { readLzma ( new byte [ ] { <NUM_LIT> , <NUM_LIT:0x00> , <NUM_LIT:0x00> } ) ; } @ Test ( timeout = <NUM_LIT> , expected = IOException . class ) public void truncatedLzma2 ( ) throws IOException { readLzma ( DecoderThread . props ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . model ; import groovy . time . BaseDuration . From ; import junit . framework . Test ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . IProject ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . IMember ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . internal . core . BinaryType ; public class GroovyClassFileTests extends AbstractGroovyTypeRootTests { public GroovyClassFileTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( GroovyClassFileTests . class ) ; } public void testClassFileHasNoNonSourceChildren ( ) throws Exception { IProject project = createSimpleGroovyProject ( ) . getProject ( ) ; env . addJar ( project . getFullPath ( ) , "<STR_LIT>" ) ; IJavaProject javaProject = JavaCore . create ( project ) ; IType binaryType = javaProject . findType ( "<STR_LIT>" ) ; ( ( BinaryType ) binaryType ) . getSource ( ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:2> , binaryType . getChildren ( ) . length ) ; assertEquals ( "<STR_LIT>" , "<STR_LIT>" , binaryType . getChildren ( ) [ <NUM_LIT:0> ] . getElementName ( ) ) ; assertEquals ( "<STR_LIT>" , "<STR_LIT>" , binaryType . getChildren ( ) [ <NUM_LIT:1> ] . getElementName ( ) ) ; assertTrue ( "<STR_LIT>" , ( ( IMember ) binaryType . getChildren ( ) [ <NUM_LIT:0> ] ) . getSourceRange ( ) . getOffset ( ) > <NUM_LIT:0> ) ; assertTrue ( "<STR_LIT>" , ( ( IMember ) binaryType . getChildren ( ) [ <NUM_LIT:1> ] ) . getSourceRange ( ) . getOffset ( ) > <NUM_LIT:0> ) ; } public void testClassFileInJavaProjectHasNonSourceChildren ( ) throws Exception { IProject project = createSimpleJavaProject ( ) . getProject ( ) ; env . addJar ( project . getFullPath ( ) , "<STR_LIT>" ) ; IJavaProject javaProject = JavaCore . create ( project ) ; IType binaryType = javaProject . findType ( "<STR_LIT>" ) ; ( ( BinaryType ) binaryType ) . getSource ( ) ; assertTrue ( "<STR_LIT>" , binaryType . getChildren ( ) . length > <NUM_LIT:2> ) ; assertTrue ( "<STR_LIT>" , binaryType . getField ( "<STR_LIT>" ) . getSourceRange ( ) . getOffset ( ) > <NUM_LIT:0> ) ; assertTrue ( "<STR_LIT>" , binaryType . getField ( "<STR_LIT>" ) . getSourceRange ( ) . getOffset ( ) > <NUM_LIT:0> ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . model ; import junit . framework . Test ; import org . codehaus . groovy . ast . ClassCodeVisitorSupport ; import org . codehaus . groovy . ast . ClassNode ; import org . codehaus . groovy . ast . ConstructorNode ; import org . codehaus . groovy . ast . FieldNode ; import org . codehaus . groovy . ast . MethodNode ; import org . codehaus . groovy . ast . Parameter ; import org . codehaus . groovy . ast . expr . ClosureExpression ; import org . codehaus . groovy . ast . expr . Expression ; import org . codehaus . groovy . ast . expr . ListExpression ; import org . codehaus . groovy . ast . stmt . BlockStatement ; import org . codehaus . groovy . ast . stmt . Statement ; import org . codehaus . groovy . control . SourceUnit ; import org . codehaus . jdt . groovy . model . GroovyCompilationUnit ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . IProject ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; public class GroovyPartialModelTests extends AbstractGroovyTypeRootTests { public GroovyPartialModelTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( GroovyPartialModelTests . class ) ; } public void testStaticFieldInitializerIsNotMoved1 ( ) throws Exception { findFieldInitializer ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" , ListExpression . class ) ; } public void testStaticFieldInitializerIsNotMoved2 ( ) throws Exception { findFieldInitializer ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" , ClosureExpression . class ) ; } public void testClosureReturner ( ) throws Exception { IProject project = createSimpleGroovyProject ( ) . getProject ( ) ; env . addGroovyClass ( project . getFullPath ( ) . append ( "<STR_LIT:src>" ) , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; IFile javaFile = getFile ( "<STR_LIT>" ) ; GroovyCompilationUnit unit = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( javaFile ) ; ClassNode inClass = unit . getModuleNode ( ) . getClasses ( ) . get ( <NUM_LIT:0> ) ; FieldNode field = inClass . getField ( "<STR_LIT>" ) ; Expression initialExpression = field . getInitialExpression ( ) ; ClosureExpression cEx = ( ClosureExpression ) initialExpression ; BlockStatement bSt = ( BlockStatement ) cEx . getCode ( ) ; Statement st = bSt . getStatements ( ) . get ( <NUM_LIT:0> ) ; assertEquals ( "<STR_LIT>" , st . getClass ( ) . getName ( ) ) ; } private Expression findFieldInitializer ( String contents , Class < ? extends Expression > expressionClass ) throws JavaModelException { IProject project = createSimpleGroovyProject ( ) . getProject ( ) ; env . addGroovyClass ( project . getFullPath ( ) . append ( "<STR_LIT:src>" ) , "<STR_LIT>" , "<STR_LIT>" , contents ) ; IFile javaFile = getFile ( "<STR_LIT>" ) ; GroovyCompilationUnit unit = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( javaFile ) ; ClassNode inClass = unit . getModuleNode ( ) . getClasses ( ) . get ( <NUM_LIT:0> ) ; FieldNode field = inClass . getField ( "<STR_LIT>" ) ; Expression initialExpression = field . getInitialExpression ( ) ; assertNotNull ( initialExpression ) ; assertTrue ( expressionClass . isInstance ( initialExpression ) ) ; checkClinitAndAllConstructors ( initialExpression , inClass ) ; return initialExpression ; } private void checkClinitAndAllConstructors ( Expression expr , ClassNode inClass ) { for ( ConstructorNode cons : inClass . getDeclaredConstructors ( ) ) { assertUnique ( expr , cons ) ; } assertUnique ( expr , inClass . getMethod ( "<STR_LIT>" , new Parameter [ <NUM_LIT:0> ] ) ) ; } private void assertUnique ( Expression expr , MethodNode cons ) { UniquenessVisitor visitor = new UniquenessVisitor ( expr ) ; visitor . visitMethod ( cons ) ; } class UniquenessVisitor extends ClassCodeVisitorSupport { public UniquenessVisitor ( Expression exprToCheck ) { this . exprToCheck = exprToCheck ; } private final Expression exprToCheck ; @ Override protected SourceUnit getSourceUnit ( ) { return null ; } @ Override public void visitListExpression ( ListExpression expression ) { doCheck ( expression ) ; super . visitListExpression ( expression ) ; } @ Override public void visitClosureExpression ( ClosureExpression expression ) { doCheck ( expression ) ; super . visitClosureExpression ( expression ) ; } void doCheck ( Expression expr ) { assertFalse ( "<STR_LIT>" + expr , expr == exprToCheck ) ; } } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . model ; import junit . framework . Test ; import org . codehaus . jdt . groovy . model . GroovyCompilationUnit ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . ResourcesPlugin ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . IPackageFragment ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . tests . builder . BuilderTests ; import org . eclipse . jdt . core . tests . util . Util ; public class MoveRenameCopyTests extends BuilderTests { public MoveRenameCopyTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( MoveRenameCopyTests . class ) ; } final static String GROOVY_CLASS_CONTENTS = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; final static String GROOVY_SCRIPT_CONTENTS = "<STR_LIT>" ; public void testRenameGroovyClass ( ) throws Exception { GroovyCompilationUnit unit = createSimpleGroovyProject ( "<STR_LIT:foo>" , GROOVY_CLASS_CONTENTS ) ; unit . rename ( "<STR_LIT>" , true , null ) ; GroovyCompilationUnit newUnit = ( GroovyCompilationUnit ) ( ( IPackageFragment ) unit . getParent ( ) ) . getCompilationUnit ( "<STR_LIT>" ) ; checkNoExist ( unit ) ; checkExist ( newUnit ) ; newUnit . rename ( unit . getElementName ( ) , true , null ) ; checkNoExist ( newUnit ) ; checkExist ( unit ) ; } public void testCopyGroovyClass ( ) throws Exception { GroovyCompilationUnit unit = createSimpleGroovyProject ( "<STR_LIT:foo>" , GROOVY_CLASS_CONTENTS ) ; unit . copy ( unit . getParent ( ) , unit , "<STR_LIT>" , true , null ) ; GroovyCompilationUnit newUnit = ( GroovyCompilationUnit ) ( ( IPackageFragment ) unit . getParent ( ) ) . getCompilationUnit ( "<STR_LIT>" ) ; checkExist ( unit ) ; checkExist ( newUnit ) ; } public void testMoveGroovyClass ( ) throws Exception { GroovyCompilationUnit unit = createSimpleGroovyProject ( "<STR_LIT>" , GROOVY_CLASS_CONTENTS ) ; IPackageFragment pack = unit . getPackageFragmentRoot ( ) . createPackageFragment ( "<STR_LIT:foo>" , true , null ) ; unit . move ( pack , null , "<STR_LIT>" , true , null ) ; GroovyCompilationUnit newUnit = ( GroovyCompilationUnit ) pack . getCompilationUnit ( "<STR_LIT>" ) ; checkNoExist ( unit ) ; checkExist ( newUnit ) ; } public void testRenameGroovyScript ( ) throws Exception { GroovyCompilationUnit unit = createSimpleGroovyProject ( "<STR_LIT:foo>" , GROOVY_SCRIPT_CONTENTS ) ; unit . rename ( "<STR_LIT>" , true , null ) ; GroovyCompilationUnit newUnit = ( GroovyCompilationUnit ) ( ( IPackageFragment ) unit . getParent ( ) ) . getCompilationUnit ( "<STR_LIT>" ) ; checkNoExist ( unit ) ; checkExist ( newUnit ) ; newUnit . rename ( unit . getElementName ( ) , true , null ) ; checkNoExist ( newUnit ) ; checkExist ( unit ) ; } public void testCopyGroovyScript ( ) throws Exception { GroovyCompilationUnit unit = createSimpleGroovyProject ( "<STR_LIT:foo>" , GROOVY_SCRIPT_CONTENTS ) ; unit . copy ( unit . getParent ( ) , unit , "<STR_LIT>" , true , null ) ; GroovyCompilationUnit newUnit = ( GroovyCompilationUnit ) ( ( IPackageFragment ) unit . getParent ( ) ) . getCompilationUnit ( "<STR_LIT>" ) ; checkExist ( unit ) ; checkExist ( newUnit ) ; } public void testMoveGroovyScript ( ) throws Exception { GroovyCompilationUnit unit = createSimpleGroovyProject ( "<STR_LIT>" , GROOVY_SCRIPT_CONTENTS ) ; IPackageFragment pack = unit . getPackageFragmentRoot ( ) . createPackageFragment ( "<STR_LIT:foo>" , true , null ) ; unit . move ( pack , null , "<STR_LIT>" , true , null ) ; GroovyCompilationUnit newUnit = ( GroovyCompilationUnit ) pack . getCompilationUnit ( "<STR_LIT>" ) ; checkNoExist ( unit ) ; checkExist ( newUnit ) ; } private void checkNoExist ( GroovyCompilationUnit unit ) { assertFalse ( "<STR_LIT>" + unit . getElementName ( ) + "<STR_LIT>" , unit . exists ( ) ) ; assertFalse ( "<STR_LIT>" + unit . getElementName ( ) + "<STR_LIT>" , unit . isWorkingCopy ( ) ) ; assertFalse ( "<STR_LIT>" + unit . getResource ( ) . getName ( ) + "<STR_LIT>" , unit . getResource ( ) . exists ( ) ) ; } private void checkExist ( GroovyCompilationUnit unit ) { assertTrue ( "<STR_LIT>" + unit . getElementName ( ) + "<STR_LIT>" , unit . exists ( ) ) ; assertTrue ( "<STR_LIT>" + unit . getResource ( ) . getName ( ) + "<STR_LIT>" , unit . getResource ( ) . exists ( ) ) ; env . fullBuild ( ) ; expectingNoProblems ( ) ; assertTrue ( unit . getType ( unit . getElementName ( ) . substring ( <NUM_LIT:0> , unit . getElementName ( ) . length ( ) - "<STR_LIT>" . length ( ) ) ) . exists ( ) ) ; } private GroovyCompilationUnit createSimpleGroovyProject ( String pack , String contents ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addGroovyNature ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath path = env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , contents ) ; IFile file = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getFile ( path ) ; return ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( file ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . model ; import java . util . Arrays ; import junit . framework . AssertionFailedError ; import junit . framework . Test ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . IProject ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . resources . ResourcesPlugin ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . Path ; import org . eclipse . jdt . core . tests . builder . BuilderTests ; import org . eclipse . jdt . groovy . core . util . ContentTypeUtils ; import org . eclipse . jdt . internal . core . util . Util ; public class GroovyContentTypeTests extends BuilderTests { public GroovyContentTypeTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( GroovyContentTypeTests . class ) ; } public void testContentTypes ( ) throws Exception { Runnable runner = new Runnable ( ) { public void run ( ) { char [ ] [ ] groovyLikeExtensions = ContentTypeUtils . getGroovyLikeExtensions ( ) ; char [ ] [ ] javaLikeExtensions = Util . getJavaLikeExtensions ( ) ; char [ ] [ ] javaButNotGroovyExtensions = ContentTypeUtils . getJavaButNotGroovyLikeExtensions ( ) ; assertEquals ( "<STR_LIT>" + charCharToString ( javaLikeExtensions ) + "<STR_LIT>" + charCharToString ( groovyLikeExtensions ) + "<STR_LIT>" + charCharToString ( javaButNotGroovyExtensions ) , javaLikeExtensions . length , groovyLikeExtensions . length + javaButNotGroovyExtensions . length ) ; charCharContains ( groovyLikeExtensions , "<STR_LIT>" ) ; charCharContains ( groovyLikeExtensions , "<STR_LIT>" ) ; charCharContains ( javaButNotGroovyExtensions , "<STR_LIT>" ) ; charCharContains ( javaButNotGroovyExtensions , "<STR_LIT>" ) ; charCharContains ( javaLikeExtensions , "<STR_LIT>" ) ; charCharContains ( javaLikeExtensions , "<STR_LIT>" ) ; charCharContains ( javaLikeExtensions , "<STR_LIT>" ) ; charCharContains ( javaLikeExtensions , "<STR_LIT>" ) ; charCharNoContains ( groovyLikeExtensions , "<STR_LIT>" ) ; charCharNoContains ( groovyLikeExtensions , "<STR_LIT>" ) ; charCharNoContains ( javaButNotGroovyExtensions , "<STR_LIT>" ) ; charCharNoContains ( javaButNotGroovyExtensions , "<STR_LIT>" ) ; } } ; runMultipleTimes ( runner ) ; } public void testJavaOnlyProject ( ) throws Exception { final IProject proj = createProject ( ) ; Runnable runner = new Runnable ( ) { public void run ( ) { try { env . removeGroovyNature ( "<STR_LIT>" ) ; env . fullBuild ( ) ; checkJavaProject ( proj ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } } ; runMultipleTimes ( runner ) ; } public void testGroovyProject ( ) throws Exception { final IProject proj = createProject ( ) ; Runnable runner = new Runnable ( ) { public void run ( ) { try { env . addGroovyJars ( proj . getFullPath ( ) ) ; env . fullBuild ( ) ; checkGroovyProject ( proj ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } } ; runMultipleTimes ( runner ) ; } public void testGroovyThenJavaProject ( ) throws Exception { final IProject proj = createProject ( ) ; env . addGroovyJars ( proj . getFullPath ( ) ) ; env . fullBuild ( ) ; Runnable runner = new Runnable ( ) { public void run ( ) { try { checkGroovyProject ( proj ) ; env . removeGroovyNature ( proj . getName ( ) ) ; fullBuild ( ) ; checkJavaProject ( proj ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } } ; runMultipleTimes ( runner ) ; } public void testJavaThenGroovyProject ( ) throws Exception { final IProject proj = createProject ( ) ; Runnable runner = new Runnable ( ) { public void run ( ) { try { env . removeGroovyNature ( proj . getName ( ) ) ; env . fullBuild ( ) ; checkJavaProject ( proj ) ; env . addGroovyNature ( proj . getName ( ) ) ; env . addGroovyJars ( proj . getFullPath ( ) ) ; fullBuild ( ) ; checkGroovyProject ( proj ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } } ; runMultipleTimes ( runner ) ; } void checkGroovyProject ( IProject proj ) throws CoreException { expectingNoProblems ( ) ; IFile javaClass = proj . getFile ( new Path ( "<STR_LIT>" ) ) ; IFile javaTestClass = proj . getFile ( new Path ( "<STR_LIT>" ) ) ; IFile groovyClass = proj . getFile ( new Path ( "<STR_LIT>" ) ) ; IFile groovyTestClass = proj . getFile ( new Path ( "<STR_LIT>" ) ) ; assertTrue ( javaClass + "<STR_LIT>" , javaClass . exists ( ) ) ; assertTrue ( javaTestClass + "<STR_LIT>" , javaTestClass . exists ( ) ) ; assertTrue ( groovyClass + "<STR_LIT>" , groovyClass . exists ( ) ) ; assertTrue ( groovyTestClass + "<STR_LIT>" , groovyTestClass . exists ( ) ) ; proj . getFile ( new Path ( "<STR_LIT>" ) ) . touch ( null ) ; proj . getFile ( new Path ( "<STR_LIT>" ) ) . touch ( null ) ; proj . getFile ( new Path ( "<STR_LIT>" ) ) . touch ( null ) ; proj . getFile ( new Path ( "<STR_LIT>" ) ) . touch ( null ) ; env . incrementalBuild ( ) ; expectingNoProblems ( ) ; assertTrue ( javaClass + "<STR_LIT>" , javaClass . exists ( ) ) ; assertTrue ( javaTestClass + "<STR_LIT>" , javaTestClass . exists ( ) ) ; assertTrue ( groovyClass + "<STR_LIT>" , groovyClass . exists ( ) ) ; assertTrue ( groovyTestClass + "<STR_LIT>" , groovyTestClass . exists ( ) ) ; } void checkJavaProject ( IProject proj ) throws CoreException { expectingNoProblems ( ) ; ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . refreshLocal ( IResource . DEPTH_INFINITE , null ) ; IFile javaClass = proj . getFile ( new Path ( "<STR_LIT>" ) ) ; IFile javaTestClass = proj . getFile ( new Path ( "<STR_LIT>" ) ) ; IFile groovyClass = proj . getFile ( new Path ( "<STR_LIT>" ) ) ; IFile groovyTestClass = proj . getFile ( new Path ( "<STR_LIT>" ) ) ; assertTrue ( javaClass + "<STR_LIT>" , javaClass . exists ( ) ) ; assertTrue ( javaTestClass + "<STR_LIT>" , javaTestClass . exists ( ) ) ; assertFalse ( groovyClass + "<STR_LIT>" , groovyClass . exists ( ) ) ; assertFalse ( groovyTestClass + "<STR_LIT>" , groovyTestClass . exists ( ) ) ; proj . getFile ( new Path ( "<STR_LIT>" ) ) . touch ( null ) ; proj . getFile ( new Path ( "<STR_LIT>" ) ) . touch ( null ) ; proj . getFile ( new Path ( "<STR_LIT>" ) ) . touch ( null ) ; proj . getFile ( new Path ( "<STR_LIT>" ) ) . touch ( null ) ; env . incrementalBuild ( ) ; env . waitForAutoBuild ( ) ; expectingNoProblems ( ) ; assertTrue ( javaClass + "<STR_LIT>" , javaClass . exists ( ) ) ; assertTrue ( javaTestClass + "<STR_LIT>" , javaTestClass . exists ( ) ) ; assertFalse ( groovyClass + "<STR_LIT>" , groovyClass . exists ( ) ) ; assertFalse ( groovyTestClass + "<STR_LIT>" , groovyTestClass . exists ( ) ) ; } IProject createProject ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , org . eclipse . jdt . core . tests . util . Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath javaTest = env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IFile javaTestFile = getFile ( javaTest ) ; javaTestFile . move ( javaTestFile . getParent ( ) . getFullPath ( ) . append ( "<STR_LIT>" ) , true , null ) ; IPath groovy = env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IFile groovyFile = getFile ( groovy ) ; groovyFile . move ( groovyFile . getParent ( ) . getFullPath ( ) . append ( "<STR_LIT>" ) , true , null ) ; IPath groovyTest = env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IFile groovyTestFile = getFile ( groovyTest ) ; groovyTestFile . move ( groovyTestFile . getParent ( ) . getFullPath ( ) . append ( "<STR_LIT>" ) , true , null ) ; return env . getProject ( projectPath ) ; } void charCharContains ( char [ ] [ ] charChar , String containsStr ) { char [ ] contains = containsStr . toCharArray ( ) ; for ( char [ ] chars : charChar ) { if ( chars . length == contains . length ) { for ( int i = <NUM_LIT:0> ; i < chars . length ; i ++ ) { if ( chars [ i ] != contains [ i ] ) { continue ; } } return ; } } fail ( "<STR_LIT>" + new String ( contains ) + "<STR_LIT>" + charCharToString ( charChar ) + "<STR_LIT:'>" ) ; } void charCharNoContains ( char [ ] [ ] charChar , String containsStr ) { char [ ] contains = containsStr . toCharArray ( ) ; for ( char [ ] chars : charChar ) { if ( Arrays . equals ( chars , contains ) ) { fail ( "<STR_LIT>" + new String ( contains ) + "<STR_LIT>" + charCharToString ( charChar ) + "<STR_LIT:'>" ) ; } } } String charCharToString ( char [ ] [ ] charChar ) { StringBuffer sb = new StringBuffer ( ) ; for ( char [ ] chars : charChar ) { for ( char c : chars ) { sb . append ( c ) ; } sb . append ( "<STR_LIT>" ) ; } return sb . toString ( ) ; } IFile getFile ( IPath path ) { return ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getFile ( path ) ; } private void runMultipleTimes ( Runnable runner ) { AssertionFailedError currentException = null ; for ( int attempt = <NUM_LIT:0> ; attempt < <NUM_LIT:4> ; attempt ++ ) { try { runner . run ( ) ; return ; } catch ( AssertionFailedError e ) { currentException = e ; System . out . println ( "<STR_LIT>" + attempt + "<STR_LIT>" ) ; } } if ( currentException != null ) { throw currentException ; } } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . model ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . ResourcesPlugin ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . Path ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . tests . builder . BuilderTests ; import org . eclipse . jdt . core . tests . util . Util ; import org . eclipse . jdt . internal . core . JavaModelManager ; public class AbstractGroovyTypeRootTests extends BuilderTests { public AbstractGroovyTypeRootTests ( String name ) { super ( name ) ; } @ Override protected void tearDown ( ) throws Exception { ICompilationUnit [ ] workingCopies = JavaModelManager . getJavaModelManager ( ) . getWorkingCopies ( null , true ) ; if ( workingCopies != null ) { for ( ICompilationUnit workingCopy : workingCopies ) { while ( workingCopy . isWorkingCopy ( ) ) { workingCopy . discardWorkingCopy ( ) ; } } } super . tearDown ( ) ; } protected IFile getFile ( String path ) { return ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getFile ( new Path ( path ) ) ; } protected IFile createProject ( boolean isGroovy ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; if ( ! isGroovy ) { env . removeGroovyNature ( "<STR_LIT>" ) ; } env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; if ( isGroovy ) { env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; } IFile groovyFile = getFile ( "<STR_LIT>" ) ; return groovyFile ; } protected IFile createSimpleGroovyProject ( ) throws JavaModelException { return createProject ( true ) ; } protected IFile createSimpleJavaProject ( ) throws JavaModelException { return createProject ( false ) ; } protected IPath createAnnotationGroovyProject ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyNature ( "<STR_LIT>" ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; return root ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . model ; import java . util . HashMap ; import junit . framework . Test ; import org . codehaus . groovy . ast . ModuleNode ; import org . codehaus . jdt . groovy . model . GroovyCompilationUnit ; import org . codehaus . jdt . groovy . model . ModuleNodeMapper ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . IAnnotatable ; import org . eclipse . jdt . core . IAnnotation ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IField ; import org . eclipse . jdt . core . IMemberValuePair ; import org . eclipse . jdt . core . IMethod ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . dom . AST ; import org . eclipse . jdt . core . tests . util . Util ; public class GroovyCompilationUnitTests extends AbstractGroovyTypeRootTests { public GroovyCompilationUnitTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( GroovyCompilationUnitTests . class ) ; } public void testCreateJavaCompilationUnit ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IFile javaFile = getFile ( "<STR_LIT>" ) ; ICompilationUnit unit = JavaCore . createCompilationUnitFrom ( javaFile ) ; assertTrue ( "<STR_LIT>" + javaFile + "<STR_LIT>" , unit . exists ( ) ) ; assertFalse ( "<STR_LIT>" + javaFile + "<STR_LIT>" , unit instanceof GroovyCompilationUnit ) ; } public void testCreateGroovyCompilationUnit ( ) throws Exception { IFile groovyFile = createSimpleGroovyProject ( ) ; ICompilationUnit unit = JavaCore . createCompilationUnitFrom ( groovyFile ) ; assertTrue ( "<STR_LIT>" + groovyFile + "<STR_LIT>" , unit . exists ( ) ) ; assertTrue ( "<STR_LIT>" + groovyFile + "<STR_LIT>" , unit instanceof GroovyCompilationUnit ) ; } public void testGetModuleNode_1 ( ) throws Exception { IFile groovyFile = createSimpleGroovyProject ( ) ; GroovyCompilationUnit unit1 = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( groovyFile ) ; unit1 . becomeWorkingCopy ( null ) ; ModuleNode node1 = unit1 . getModuleNode ( ) ; ModuleNode node2 = unit1 . getModuleNode ( ) ; assertTrue ( "<STR_LIT>" , node1 == node2 ) ; unit1 . discardWorkingCopy ( ) ; } public void testGetModuleNode_2 ( ) throws Exception { IFile groovyFile = createSimpleGroovyProject ( ) ; GroovyCompilationUnit unit1 = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( groovyFile ) ; unit1 . becomeWorkingCopy ( null ) ; ModuleNode node1 = unit1 . getModuleNode ( ) ; GroovyCompilationUnit unit2 = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( groovyFile ) ; unit2 . becomeWorkingCopy ( null ) ; ModuleNode node2 = unit2 . getModuleNode ( ) ; assertTrue ( "<STR_LIT>" , node1 == node2 ) ; unit1 . discardWorkingCopy ( ) ; unit2 . discardWorkingCopy ( ) ; } public void testGetModuleNode_3 ( ) throws Exception { IFile groovyFile = createSimpleGroovyProject ( ) ; GroovyCompilationUnit unit1 = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( groovyFile ) ; unit1 . becomeWorkingCopy ( null ) ; ModuleNode node1 = unit1 . getModuleNode ( ) ; unit1 . reconcile ( AST . JLS3 , true , unit1 . owner , null ) ; ModuleNode node2 = unit1 . getModuleNode ( ) ; assertTrue ( "<STR_LIT>" , node1 != node2 ) ; unit1 . discardWorkingCopy ( ) ; } @ SuppressWarnings ( "<STR_LIT:unchecked>" ) public void testGetModuleNode_4 ( ) throws Exception { IFile groovyFile = createSimpleGroovyProject ( ) ; GroovyCompilationUnit unit1 = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( groovyFile ) ; unit1 . becomeWorkingCopy ( null ) ; ModuleNode node1 = unit1 . getModuleNode ( ) ; unit1 . makeConsistent ( AST . JLS3 , true , ICompilationUnit . FORCE_PROBLEM_DETECTION , new HashMap ( ) , null ) ; ModuleNode node2 = unit1 . getModuleNode ( ) ; assertTrue ( "<STR_LIT>" , node1 == node2 ) ; unit1 . discardWorkingCopy ( ) ; } public void testGetModuleNode_5 ( ) throws Exception { IFile groovyFile = createSimpleGroovyProject ( ) ; GroovyCompilationUnit unit1 = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( groovyFile ) ; unit1 . becomeWorkingCopy ( null ) ; ModuleNode node1 = unit1 . getModuleNode ( ) ; unit1 . getBuffer ( ) . append ( "<STR_LIT:U+0020>" ) ; ModuleNode node2 = unit1 . getModuleNode ( ) ; assertTrue ( "<STR_LIT>" , node1 != node2 ) ; unit1 . discardWorkingCopy ( ) ; } public void testGetModuleNode_6 ( ) throws Exception { IFile groovyFile = createSimpleGroovyProject ( ) ; GroovyCompilationUnit unit1 = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( groovyFile ) ; unit1 . becomeWorkingCopy ( null ) ; ModuleNode node1 = unit1 . getModuleNode ( ) ; GroovyCompilationUnit unit2 = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( groovyFile ) ; unit2 . becomeWorkingCopy ( null ) ; ModuleNode node2 = unit2 . getModuleNode ( ) ; unit1 . getBuffer ( ) . append ( "<STR_LIT:U+0020>" ) ; ModuleNode node3 = unit1 . getModuleNode ( ) ; ModuleNode node4 = unit2 . getModuleNode ( ) ; unit1 . discardWorkingCopy ( ) ; unit2 . discardWorkingCopy ( ) ; assertTrue ( "<STR_LIT>" , node1 == node2 ) ; assertTrue ( "<STR_LIT>" , node1 != node3 ) ; assertTrue ( "<STR_LIT>" , node3 == node4 ) ; } public void testGetModuleNode_7 ( ) throws Exception { IFile groovyFile = createSimpleGroovyProject ( ) ; GroovyCompilationUnit unit1 = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( groovyFile ) ; unit1 . becomeWorkingCopy ( null ) ; unit1 . getModuleNode ( ) ; GroovyCompilationUnit unit2 = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( groovyFile ) ; unit2 . becomeWorkingCopy ( null ) ; unit2 . getModuleNode ( ) ; unit1 . getBuffer ( ) . append ( "<STR_LIT:U+0020>" ) ; unit1 . getModuleNode ( ) ; unit2 . getModuleNode ( ) ; unit1 . discardWorkingCopy ( ) ; unit2 . discardWorkingCopy ( ) ; assertTrue ( "<STR_LIT>" , ModuleNodeMapper . isEmpty ( ) ) ; } public void testGetModuleNode_8 ( ) throws Exception { IFile groovyFile = createSimpleGroovyProject ( ) ; GroovyCompilationUnit unit1 = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( groovyFile ) ; ModuleNode node1 = unit1 . getModuleNode ( ) ; ModuleNode node2 = unit1 . getModuleNode ( ) ; assertFalse ( "<STR_LIT>" , node1 == node2 ) ; } public void testGetModuleNode_9 ( ) throws Exception { IFile groovyFile = createSimpleGroovyProject ( ) ; GroovyCompilationUnit unit1 = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( groovyFile ) ; unit1 . becomeWorkingCopy ( null ) ; ModuleNode node1 = unit1 . getModuleNode ( ) ; unit1 . reconcile ( true , null ) ; ModuleNode node2 = unit1 . getModuleNode ( ) ; unit1 . discardWorkingCopy ( ) ; assertFalse ( "<STR_LIT>" , node1 == node2 ) ; } public void testGetModuleNode_10 ( ) throws Exception { IFile groovyFile = createSimpleGroovyProject ( ) ; GroovyCompilationUnit unit1 = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( groovyFile ) ; unit1 . becomeWorkingCopy ( null ) ; ModuleNode node1 = unit1 . getModuleNode ( ) ; unit1 . reconcile ( false , null ) ; ModuleNode node2 = unit1 . getModuleNode ( ) ; unit1 . discardWorkingCopy ( ) ; assertTrue ( "<STR_LIT>" , node1 == node2 ) ; } public void testGetNewModuleNode ( ) throws Exception { IFile groovyFile = createSimpleGroovyProject ( ) ; GroovyCompilationUnit unit1 = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( groovyFile ) ; ModuleNode module1 = unit1 . getModuleNode ( ) ; ModuleNode module2 = unit1 . getNewModuleInfo ( ) . module ; assertTrue ( "<STR_LIT>" , module1 != module2 ) ; } public void testMarkerAnnotation_1 ( ) throws Exception { IPath root = createAnnotationGroovyProject ( ) ; env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; env . waitForAutoBuild ( ) ; expectingNoProblems ( ) ; IFile file = getFile ( "<STR_LIT>" ) ; GroovyCompilationUnit unit = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( file ) ; IType type = unit . getType ( "<STR_LIT:X>" ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:1> , type . getAnnotations ( ) . length ) ; IAnnotation annotation = type . getAnnotations ( ) [ <NUM_LIT:0> ] ; assertMarkerAnnotation ( annotation , "<STR_LIT>" ) ; } public void testMarkerAnnotation_2 ( ) throws Exception { IPath root = createAnnotationGroovyProject ( ) ; env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; env . waitForAutoBuild ( ) ; expectingNoProblems ( ) ; IFile file = getFile ( "<STR_LIT>" ) ; GroovyCompilationUnit unit = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( file ) ; IType type = unit . getType ( "<STR_LIT:X>" ) ; IField field = type . getField ( "<STR_LIT:foo>" ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:1> , field . getAnnotations ( ) . length ) ; IAnnotation annotation = field . getAnnotations ( ) [ <NUM_LIT:0> ] ; assertMarkerAnnotation ( annotation , "<STR_LIT>" ) ; } public void testMarkerAnnotation_3 ( ) throws Exception { IPath root = createAnnotationGroovyProject ( ) ; env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; env . waitForAutoBuild ( ) ; expectingNoProblems ( ) ; IFile file = getFile ( "<STR_LIT>" ) ; GroovyCompilationUnit unit = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( file ) ; IType type = unit . getType ( "<STR_LIT:X>" ) ; IMethod method = type . getMethod ( "<STR_LIT:m>" , new String [ <NUM_LIT:0> ] ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:1> , method . getAnnotations ( ) . length ) ; IAnnotation annotation = method . getAnnotations ( ) [ <NUM_LIT:0> ] ; assertMarkerAnnotation ( annotation , "<STR_LIT>" ) ; } public void testMarkerAnnotation_4 ( ) throws Exception { IPath root = createAnnotationGroovyProject ( ) ; env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; env . waitForAutoBuild ( ) ; expectingNoProblems ( ) ; IFile file = getFile ( "<STR_LIT>" ) ; GroovyCompilationUnit unit = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( file ) ; IType type = unit . getType ( "<STR_LIT:X>" ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:1> , type . getAnnotations ( ) . length ) ; IAnnotation annotation = type . getAnnotations ( ) [ <NUM_LIT:0> ] ; assertMarkerAnnotation ( annotation , "<STR_LIT>" ) ; } public void testMarkerAnnotation_5 ( ) throws Exception { IPath root = createAnnotationGroovyProject ( ) ; env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; env . waitForAutoBuild ( ) ; expectingNoProblems ( ) ; IFile file = getFile ( "<STR_LIT>" ) ; GroovyCompilationUnit unit = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( file ) ; IType type = unit . getType ( "<STR_LIT:X>" ) ; IField field = type . getField ( "<STR_LIT:foo>" ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:1> , field . getAnnotations ( ) . length ) ; IAnnotation annotation = field . getAnnotations ( ) [ <NUM_LIT:0> ] ; assertMarkerAnnotation ( annotation , "<STR_LIT>" ) ; } public void testMarkerAnnotation_6 ( ) throws Exception { IPath root = createAnnotationGroovyProject ( ) ; env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; env . waitForAutoBuild ( ) ; expectingNoProblems ( ) ; IFile file = getFile ( "<STR_LIT>" ) ; GroovyCompilationUnit unit = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( file ) ; IType type = unit . getType ( "<STR_LIT:X>" ) ; IMethod method = type . getMethod ( "<STR_LIT:m>" , new String [ <NUM_LIT:0> ] ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:1> , method . getAnnotations ( ) . length ) ; IAnnotation annotation = method . getAnnotations ( ) [ <NUM_LIT:0> ] ; assertMarkerAnnotation ( annotation , "<STR_LIT>" ) ; } private void assertMarkerAnnotation ( IAnnotation annotation , String expectedName ) throws JavaModelException { assertEquals ( "<STR_LIT>" , expectedName , annotation . getElementName ( ) ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:0> , annotation . getMemberValuePairs ( ) . length ) ; } public void testSingleMemberAnnotation_1 ( ) throws Exception { IPath root = createAnnotationGroovyProject ( ) ; env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; env . waitForAutoBuild ( ) ; expectingNoProblems ( ) ; IFile file = getFile ( "<STR_LIT>" ) ; GroovyCompilationUnit unit = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( file ) ; IType type = unit . getType ( "<STR_LIT:X>" ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:1> , type . getAnnotations ( ) . length ) ; assertSingleMemberAnnotation ( type , "<STR_LIT>" ) ; } public void testSingleMemberAnnotation_2 ( ) throws Exception { IPath root = createAnnotationGroovyProject ( ) ; env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; env . waitForAutoBuild ( ) ; expectingNoProblems ( ) ; IFile file = getFile ( "<STR_LIT>" ) ; GroovyCompilationUnit unit = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( file ) ; IType type = unit . getType ( "<STR_LIT:X>" ) ; IField field = type . getField ( "<STR_LIT:foo>" ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:1> , field . getAnnotations ( ) . length ) ; assertSingleMemberAnnotation ( field , "<STR_LIT>" ) ; } public void testSingleMemberAnnotation_3 ( ) throws Exception { IPath root = createAnnotationGroovyProject ( ) ; env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; env . waitForAutoBuild ( ) ; expectingNoProblems ( ) ; IFile file = getFile ( "<STR_LIT>" ) ; GroovyCompilationUnit unit = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( file ) ; IType type = unit . getType ( "<STR_LIT:X>" ) ; IMethod method = type . getMethod ( "<STR_LIT:m>" , new String [ <NUM_LIT:0> ] ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:1> , method . getAnnotations ( ) . length ) ; assertSingleMemberAnnotation ( method , "<STR_LIT>" ) ; } public void testSingleMemberAnnotation_4 ( ) throws Exception { IPath root = createAnnotationGroovyProject ( ) ; env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; env . waitForAutoBuild ( ) ; expectingNoProblems ( ) ; IFile file = getFile ( "<STR_LIT>" ) ; GroovyCompilationUnit unit = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( file ) ; IType type = unit . getType ( "<STR_LIT:X>" ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:1> , type . getAnnotations ( ) . length ) ; assertSingleMemberAnnotation ( type , "<STR_LIT>" ) ; } public void testSingleMemberAnnotation_5 ( ) throws Exception { IPath root = createAnnotationGroovyProject ( ) ; env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; env . waitForAutoBuild ( ) ; expectingNoProblems ( ) ; IFile file = getFile ( "<STR_LIT>" ) ; GroovyCompilationUnit unit = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( file ) ; IType type = unit . getType ( "<STR_LIT:X>" ) ; IField field = type . getField ( "<STR_LIT:foo>" ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:1> , field . getAnnotations ( ) . length ) ; assertSingleMemberAnnotation ( field , "<STR_LIT>" ) ; } public void testSingleMemberAnnotation_6 ( ) throws Exception { IPath root = createAnnotationGroovyProject ( ) ; env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; env . waitForAutoBuild ( ) ; expectingNoProblems ( ) ; IFile file = getFile ( "<STR_LIT>" ) ; GroovyCompilationUnit unit = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( file ) ; IType type = unit . getType ( "<STR_LIT:X>" ) ; IMethod method = type . getMethod ( "<STR_LIT:m>" , new String [ <NUM_LIT:0> ] ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:1> , method . getAnnotations ( ) . length ) ; assertSingleMemberAnnotation ( method , "<STR_LIT>" ) ; } public void testSingleMemberAnnotation_7 ( ) throws Exception { IPath root = createAnnotationGroovyProject ( ) ; env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; env . waitForAutoBuild ( ) ; expectingNoProblems ( ) ; IFile file = getFile ( "<STR_LIT>" ) ; GroovyCompilationUnit unit = ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( file ) ; IType type = unit . getType ( "<STR_LIT:X>" ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:0> , type . getAnnotations ( ) . length ) ; } private void assertSingleMemberAnnotation ( IAnnotatable type , String expectedName ) throws JavaModelException { IAnnotation annotation = type . getAnnotations ( ) [ <NUM_LIT:0> ] ; assertEquals ( "<STR_LIT>" , "<STR_LIT>" , annotation . getElementName ( ) ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:1> , annotation . getMemberValuePairs ( ) . length ) ; IMemberValuePair mvp = annotation . getMemberValuePairs ( ) [ <NUM_LIT:0> ] ; assertEquals ( "<STR_LIT:value>" , mvp . getMemberName ( ) ) ; assertEquals ( IMemberValuePair . K_CLASS , mvp . getValueKind ( ) ) ; assertEquals ( expectedName , mvp . getValue ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . model ; import java . util . List ; import junit . framework . Test ; import org . codehaus . groovy . ast . AnnotatedNode ; import org . codehaus . groovy . ast . AnnotationNode ; import org . codehaus . groovy . ast . ClassNode ; import org . codehaus . groovy . ast . FieldNode ; import org . codehaus . groovy . ast . MethodNode ; import org . codehaus . groovy . ast . expr . ClassExpression ; import org . codehaus . groovy . ast . stmt . ReturnStatement ; import org . codehaus . jdt . groovy . model . GroovyCompilationUnit ; import org . eclipse . core . resources . IProject ; import org . eclipse . core . resources . ResourcesPlugin ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . tests . builder . BuilderTests ; import org . eclipse . jdt . core . tests . util . Util ; public class AnnotationsTests extends BuilderTests { public AnnotationsTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( AnnotationsTests . class ) ; } private IProject project ; @ Override protected void setUp ( ) throws Exception { super . setUp ( ) ; IPath projectPath = env . addProject ( "<STR_LIT>" ) ; project = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; } public void testDelegateAnnotationFromOtherField ( ) throws Exception { createUnit ( "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; GroovyCompilationUnit unit = createUnit ( "<STR_LIT>" , "<STR_LIT>" ) ; env . fullBuild ( ) ; expectingNoProblems ( ) ; FieldNode field = getMeField ( unit ) ; assertAnnotation ( "<STR_LIT>" , field ) ; } public void testDelegateAnnotationFromOtherMethod ( ) throws Exception { createUnit ( "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; GroovyCompilationUnit unit = createUnit ( "<STR_LIT>" , "<STR_LIT>" ) ; env . fullBuild ( ) ; expectingNoProblems ( ) ; MethodNode method = getMethod ( unit , "<STR_LIT>" ) ; assertAnnotation ( "<STR_LIT>" , method ) ; } public void testSingletonAnnotationFromOtherClass ( ) throws Exception { createUnit ( "<STR_LIT>" , "<STR_LIT>" ) ; GroovyCompilationUnit unit = createUnit ( "<STR_LIT>" , "<STR_LIT>" ) ; env . fullBuild ( ) ; expectingNoProblems ( ) ; ClassNode clazz = getClassFromScript ( unit ) ; assertAnnotation ( "<STR_LIT>" , clazz ) ; } private void assertAnnotation ( String aName , AnnotatedNode node ) { assertEquals ( "<STR_LIT>" + aName + "<STR_LIT>" , <NUM_LIT:1> , node . getAnnotations ( ) . size ( ) ) ; assertEquals ( aName , ( ( AnnotationNode ) node . getAnnotations ( ) . get ( <NUM_LIT:0> ) ) . getClassNode ( ) . getName ( ) ) ; } private FieldNode getMeField ( GroovyCompilationUnit unit ) { ClassNode clazz = getClassFromScript ( unit ) ; clazz . getFields ( ) ; return clazz . getField ( "<STR_LIT>" ) ; } private MethodNode getMethod ( GroovyCompilationUnit unit , String name ) { ClassNode clazz = getClassFromScript ( unit ) ; clazz . getFields ( ) ; List < MethodNode > ms = clazz . getMethods ( ) ; for ( MethodNode m : ms ) { if ( m . getName ( ) . equals ( name ) ) { return m ; } } return null ; } private ClassNode getClassFromScript ( GroovyCompilationUnit unit ) { return ( ( ClassExpression ) ( ( ReturnStatement ) unit . getModuleNode ( ) . getStatementBlock ( ) . getStatements ( ) . get ( <NUM_LIT:0> ) ) . getExpression ( ) ) . getType ( ) ; } protected GroovyCompilationUnit createUnit ( String name , String contents ) { IPath path = env . addGroovyClass ( project . getFolder ( "<STR_LIT:src>" ) . getFullPath ( ) , name , contents ) ; return ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( env . getWorkspace ( ) . getRoot ( ) . getFile ( path ) ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . locations ; import groovy . lang . GroovyClassLoader ; import java . util . LinkedList ; import java . util . List ; import junit . framework . TestCase ; import org . codehaus . groovy . antlr . LocationSupport ; import org . codehaus . groovy . ast . ASTNode ; import org . codehaus . groovy . ast . MethodNode ; import org . codehaus . groovy . ast . ModuleNode ; import org . codehaus . groovy . ast . expr . DeclarationExpression ; import org . codehaus . groovy . ast . stmt . ExpressionStatement ; import org . codehaus . groovy . control . CompilerConfiguration ; import org . codehaus . groovy . control . ErrorCollector ; import org . codehaus . groovy . control . SourceUnit ; import org . codehaus . jdt . groovy . internal . compiler . ast . GroovyCompilationUnitDeclaration ; public class LocationSupportTests extends TestCase { public void testLocationSupport ( ) throws Exception { List < StringBuffer > sbuffers = new LinkedList < StringBuffer > ( ) ; sbuffers . add ( new StringBuffer ( "<STR_LIT>" ) ) ; sbuffers . add ( new StringBuffer ( "<STR_LIT>" ) ) ; sbuffers . add ( new StringBuffer ( "<STR_LIT>" ) ) ; LocationSupport locations = new LocationSupport ( sbuffers ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:0> , locations . findOffset ( <NUM_LIT:1> , <NUM_LIT:1> ) ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:1> , locations . findOffset ( <NUM_LIT:1> , <NUM_LIT:2> ) ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:2> , locations . findOffset ( <NUM_LIT:1> , <NUM_LIT:3> ) ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:3> , locations . findOffset ( <NUM_LIT:1> , <NUM_LIT:4> ) ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:4> , locations . findOffset ( <NUM_LIT:2> , <NUM_LIT:1> ) ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:5> , locations . findOffset ( <NUM_LIT:2> , <NUM_LIT:2> ) ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:6> , locations . findOffset ( <NUM_LIT:2> , <NUM_LIT:3> ) ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:7> , locations . findOffset ( <NUM_LIT:2> , <NUM_LIT:4> ) ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:8> , locations . findOffset ( <NUM_LIT:3> , <NUM_LIT:1> ) ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:9> , locations . findOffset ( <NUM_LIT:3> , <NUM_LIT:2> ) ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:10> , locations . findOffset ( <NUM_LIT:3> , <NUM_LIT:3> ) ) ; } public void testParserSourceLocationsBlock ( ) throws Exception { String content = "<STR_LIT>" ; SourceUnit sourceUnit = new SourceUnit ( "<STR_LIT>" , content , new CompilerConfiguration ( ) , new GroovyClassLoader ( ) , new ErrorCollector ( new CompilerConfiguration ( ) ) ) ; sourceUnit . parse ( ) ; sourceUnit . completePhase ( ) ; sourceUnit . convert ( ) ; ModuleNode module = sourceUnit . getAST ( ) ; assertEquals ( <NUM_LIT:0> , module . getStart ( ) ) ; assertEquals ( content . length ( ) , module . getEnd ( ) ) ; assertEquals ( <NUM_LIT:0> , module . getStatementBlock ( ) . getStart ( ) ) ; assertEquals ( content . length ( ) , module . getStatementBlock ( ) . getEnd ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , ( ( ASTNode ) module . getStatementBlock ( ) . getStatements ( ) . get ( <NUM_LIT:0> ) ) . getStart ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , ( ( ASTNode ) module . getStatementBlock ( ) . getStatements ( ) . get ( <NUM_LIT:0> ) ) . getEnd ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , ( ( ASTNode ) module . getStatementBlock ( ) . getStatements ( ) . get ( <NUM_LIT:1> ) ) . getStart ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , ( ( ASTNode ) module . getStatementBlock ( ) . getStatements ( ) . get ( <NUM_LIT:1> ) ) . getEnd ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , ( ( ASTNode ) module . getStatementBlock ( ) . getStatements ( ) . get ( <NUM_LIT:2> ) ) . getStart ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , ( ( ASTNode ) module . getStatementBlock ( ) . getStatements ( ) . get ( <NUM_LIT:2> ) ) . getEnd ( ) ) ; } public void testParserSourceLocationsEmpty ( ) throws Exception { String content = "<STR_LIT>" ; SourceUnit sourceUnit = new SourceUnit ( "<STR_LIT>" , content , new CompilerConfiguration ( ) , new GroovyClassLoader ( ) , new ErrorCollector ( new CompilerConfiguration ( ) ) ) ; sourceUnit . parse ( ) ; sourceUnit . completePhase ( ) ; sourceUnit . convert ( ) ; ModuleNode module = sourceUnit . getAST ( ) ; assertEquals ( <NUM_LIT:0> , module . getStart ( ) ) ; assertEquals ( content . length ( ) , module . getEnd ( ) ) ; } public void testParserSourceLocationsOneLine ( ) throws Exception { String content = "<STR_LIT>" ; SourceUnit sourceUnit = new SourceUnit ( "<STR_LIT>" , content , new CompilerConfiguration ( ) , new GroovyClassLoader ( ) , new ErrorCollector ( new CompilerConfiguration ( ) ) ) ; sourceUnit . parse ( ) ; sourceUnit . completePhase ( ) ; sourceUnit . convert ( ) ; ModuleNode module = sourceUnit . getAST ( ) ; assertEquals ( <NUM_LIT:0> , module . getStart ( ) ) ; assertEquals ( content . length ( ) , module . getEnd ( ) ) ; assertEquals ( <NUM_LIT:0> , module . getStatementBlock ( ) . getStart ( ) ) ; assertEquals ( content . length ( ) , module . getStatementBlock ( ) . getEnd ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , ( ( ASTNode ) module . getStatementBlock ( ) . getStatements ( ) . get ( <NUM_LIT:0> ) ) . getStart ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , ( ( ASTNode ) module . getStatementBlock ( ) . getStatements ( ) . get ( <NUM_LIT:0> ) ) . getEnd ( ) ) ; } public void testParserSourceLocationsNewLine ( ) throws Exception { String content = "<STR_LIT>" ; SourceUnit sourceUnit = new SourceUnit ( "<STR_LIT>" , content , new CompilerConfiguration ( ) , new GroovyClassLoader ( ) , new ErrorCollector ( new CompilerConfiguration ( ) ) ) ; sourceUnit . parse ( ) ; sourceUnit . completePhase ( ) ; sourceUnit . convert ( ) ; ModuleNode module = sourceUnit . getAST ( ) ; assertEquals ( <NUM_LIT:0> , module . getStart ( ) ) ; assertEquals ( content . length ( ) , module . getEnd ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , module . getStatementBlock ( ) . getStart ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , module . getStatementBlock ( ) . getEnd ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , ( ( ASTNode ) module . getStatementBlock ( ) . getStatements ( ) . get ( <NUM_LIT:0> ) ) . getStart ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , ( ( ASTNode ) module . getStatementBlock ( ) . getStatements ( ) . get ( <NUM_LIT:0> ) ) . getEnd ( ) ) ; } public void testParserSourceLocationsClass ( ) throws Exception { String content = "<STR_LIT>" ; SourceUnit sourceUnit = new SourceUnit ( "<STR_LIT>" , content , new CompilerConfiguration ( ) , new GroovyClassLoader ( ) , new ErrorCollector ( new CompilerConfiguration ( ) ) ) ; sourceUnit . parse ( ) ; sourceUnit . completePhase ( ) ; sourceUnit . convert ( ) ; ModuleNode module = sourceUnit . getAST ( ) ; assertEquals ( <NUM_LIT:0> , module . getStart ( ) ) ; assertEquals ( content . length ( ) , module . getEnd ( ) ) ; assertEquals ( <NUM_LIT:0> , ( ( ASTNode ) module . getClasses ( ) . get ( <NUM_LIT:0> ) ) . getStart ( ) ) ; assertEquals ( content . length ( ) , ( ( ASTNode ) module . getClasses ( ) . get ( <NUM_LIT:0> ) ) . getEnd ( ) ) ; } public void testParserSourceLocationsMethod ( ) throws Exception { String content = "<STR_LIT>" ; SourceUnit sourceUnit = new SourceUnit ( "<STR_LIT>" , content , new CompilerConfiguration ( ) , new GroovyClassLoader ( ) , new ErrorCollector ( new CompilerConfiguration ( ) ) ) ; sourceUnit . parse ( ) ; sourceUnit . completePhase ( ) ; sourceUnit . convert ( ) ; ModuleNode module = sourceUnit . getAST ( ) ; assertEquals ( <NUM_LIT:0> , module . getStart ( ) ) ; assertEquals ( content . length ( ) , module . getEnd ( ) ) ; assertEquals ( <NUM_LIT:0> , ( ( ASTNode ) module . getMethods ( ) . get ( <NUM_LIT:0> ) ) . getStart ( ) ) ; assertEquals ( content . indexOf ( '<CHAR_LIT>' ) , module . getMethods ( ) . get ( <NUM_LIT:0> ) . getNameStart ( ) ) ; assertEquals ( content . indexOf ( '<CHAR_LIT>' ) + "<STR_LIT:x>" . length ( ) - <NUM_LIT:1> , module . getMethods ( ) . get ( <NUM_LIT:0> ) . getNameEnd ( ) ) ; assertEquals ( content . length ( ) , ( ( ASTNode ) module . getMethods ( ) . get ( <NUM_LIT:0> ) ) . getEnd ( ) ) ; } public void testParserSourceLocationsMethod2 ( ) throws Exception { String content = "<STR_LIT>" ; SourceUnit sourceUnit = new SourceUnit ( "<STR_LIT>" , content , new CompilerConfiguration ( ) , new GroovyClassLoader ( ) , new ErrorCollector ( new CompilerConfiguration ( ) ) ) ; sourceUnit . parse ( ) ; sourceUnit . completePhase ( ) ; sourceUnit . convert ( ) ; ModuleNode module = sourceUnit . getAST ( ) ; assertEquals ( <NUM_LIT:0> , module . getStart ( ) ) ; assertEquals ( content . length ( ) , module . getEnd ( ) ) ; assertEquals ( <NUM_LIT:0> , ( ( ASTNode ) module . getMethods ( ) . get ( <NUM_LIT:0> ) ) . getStart ( ) ) ; assertEquals ( content . indexOf ( "<STR_LIT>" ) , ( module . getMethods ( ) . get ( <NUM_LIT:0> ) ) . getNameStart ( ) ) ; assertEquals ( content . indexOf ( "<STR_LIT>" ) + "<STR_LIT>" . length ( ) - <NUM_LIT:1> , ( module . getMethods ( ) . get ( <NUM_LIT:0> ) ) . getNameEnd ( ) ) ; assertEquals ( content . length ( ) , ( ( ASTNode ) module . getMethods ( ) . get ( <NUM_LIT:0> ) ) . getEnd ( ) ) ; } public void testParserSourceLocationsClassMethodStatement ( ) throws Exception { String content = "<STR_LIT>" ; SourceUnit sourceUnit = new SourceUnit ( "<STR_LIT>" , content , new CompilerConfiguration ( ) , new GroovyClassLoader ( ) , new ErrorCollector ( new CompilerConfiguration ( ) ) ) ; sourceUnit . parse ( ) ; sourceUnit . completePhase ( ) ; sourceUnit . convert ( ) ; ModuleNode module = sourceUnit . getAST ( ) ; assertEquals ( <NUM_LIT:0> , module . getStart ( ) ) ; assertEquals ( content . length ( ) , module . getEnd ( ) ) ; assertEquals ( <NUM_LIT:0> , module . getStatementBlock ( ) . getStart ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , module . getStatementBlock ( ) . getEnd ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , ( ( ASTNode ) module . getStatementBlock ( ) . getStatements ( ) . get ( <NUM_LIT:0> ) ) . getStart ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , ( ( ASTNode ) module . getStatementBlock ( ) . getStatements ( ) . get ( <NUM_LIT:0> ) ) . getEnd ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , ( ( ASTNode ) module . getStatementBlock ( ) . getStatements ( ) . get ( <NUM_LIT:1> ) ) . getStart ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , ( ( ASTNode ) module . getStatementBlock ( ) . getStatements ( ) . get ( <NUM_LIT:1> ) ) . getEnd ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , ( ( ASTNode ) module . getStatementBlock ( ) . getStatements ( ) . get ( <NUM_LIT:2> ) ) . getStart ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , ( ( ASTNode ) module . getStatementBlock ( ) . getStatements ( ) . get ( <NUM_LIT:2> ) ) . getEnd ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , ( ( ASTNode ) module . getMethods ( ) . get ( <NUM_LIT:0> ) ) . getStart ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , ( ( ASTNode ) module . getMethods ( ) . get ( <NUM_LIT:0> ) ) . getEnd ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , ( ( ASTNode ) module . getClasses ( ) . get ( <NUM_LIT:1> ) ) . getStart ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , ( ( ASTNode ) module . getClasses ( ) . get ( <NUM_LIT:1> ) ) . getEnd ( ) ) ; } public void testGRECLIPSE887_ImportStatements ( ) throws Exception { String content = "<STR_LIT>" ; SourceUnit sourceUnit = new SourceUnit ( "<STR_LIT>" , content , new CompilerConfiguration ( ) , new GroovyClassLoader ( ) , new ErrorCollector ( new CompilerConfiguration ( ) ) ) ; sourceUnit . parse ( ) ; sourceUnit . completePhase ( ) ; sourceUnit . convert ( ) ; ModuleNode module = sourceUnit . getAST ( ) ; assertEquals ( <NUM_LIT:0> , module . getStart ( ) ) ; assertEquals ( content . length ( ) , module . getEnd ( ) ) ; assertEquals ( <NUM_LIT:0> , module . getImport ( "<STR_LIT>" ) . getStart ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , module . getImport ( "<STR_LIT>" ) . getEnd ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , module . getStarImports ( ) . get ( <NUM_LIT:0> ) . getStart ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , module . getStarImports ( ) . get ( <NUM_LIT:0> ) . getEnd ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , module . getImport ( "<STR_LIT:A>" ) . getStart ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , module . getImport ( "<STR_LIT:A>" ) . getEnd ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , module . getStarImports ( ) . get ( <NUM_LIT:1> ) . getStart ( ) ) ; assertEquals ( "<STR_LIT>" . length ( ) , module . getStarImports ( ) . get ( <NUM_LIT:1> ) . getEnd ( ) ) ; MockGroovyCompilationUnitDeclaration cud = new MockGroovyCompilationUnitDeclaration ( ) ; cud . createImports ( module ) ; assertEquals ( module . getImport ( "<STR_LIT>" ) . getStart ( ) , cud . imports [ <NUM_LIT:0> ] . declarationSourceStart ) ; assertEquals ( module . getImport ( "<STR_LIT>" ) . getEnd ( ) , cud . imports [ <NUM_LIT:0> ] . declarationSourceEnd ) ; assertEquals ( module . getStarImports ( ) . get ( <NUM_LIT:0> ) . getStart ( ) , cud . imports [ <NUM_LIT:1> ] . declarationSourceStart ) ; assertEquals ( module . getStarImports ( ) . get ( <NUM_LIT:0> ) . getEnd ( ) , cud . imports [ <NUM_LIT:1> ] . declarationSourceEnd ) ; assertEquals ( module . getImport ( "<STR_LIT:A>" ) . getStart ( ) , cud . imports [ <NUM_LIT:2> ] . declarationSourceStart ) ; assertEquals ( module . getImport ( "<STR_LIT:A>" ) . getEnd ( ) , cud . imports [ <NUM_LIT:2> ] . declarationSourceEnd ) ; assertEquals ( module . getStarImports ( ) . get ( <NUM_LIT:1> ) . getStart ( ) , cud . imports [ <NUM_LIT:3> ] . declarationSourceStart ) ; assertEquals ( module . getStarImports ( ) . get ( <NUM_LIT:1> ) . getEnd ( ) , cud . imports [ <NUM_LIT:3> ] . declarationSourceEnd ) ; } class MockGroovyCompilationUnitDeclaration extends GroovyCompilationUnitDeclaration { public MockGroovyCompilationUnitDeclaration ( ) { super ( null , null , - <NUM_LIT:1> , null , null , null ) ; } @ Override protected void createImports ( ModuleNode moduleNode ) { super . createImports ( moduleNode ) ; } } public void testUnicodeEscapes1 ( ) throws Exception { String escapeSequence = "<STR_LIT>" ; String content = escapeSequence + "<STR_LIT>" ; SourceUnit sourceUnit = new SourceUnit ( "<STR_LIT>" , content , new CompilerConfiguration ( ) , new GroovyClassLoader ( ) , new ErrorCollector ( new CompilerConfiguration ( ) ) ) ; sourceUnit . parse ( ) ; sourceUnit . completePhase ( ) ; sourceUnit . convert ( ) ; ModuleNode module = sourceUnit . getAST ( ) ; assertEquals ( <NUM_LIT:0> , module . getStart ( ) ) ; assertEquals ( content . length ( ) , module . getEnd ( ) ) ; assertEquals ( escapeSequence . length ( ) , ( ( ASTNode ) module . getStatementBlock ( ) . getStatements ( ) . get ( <NUM_LIT:0> ) ) . getStart ( ) ) ; assertEquals ( content . length ( ) , ( ( ASTNode ) module . getStatementBlock ( ) . getStatements ( ) . get ( <NUM_LIT:0> ) ) . getEnd ( ) ) ; } public void testUnicodeEscapes2 ( ) throws Exception { String escapeSequence = "<STR_LIT>" ; String content = escapeSequence + "<STR_LIT>" ; SourceUnit sourceUnit = new SourceUnit ( "<STR_LIT>" , content , new CompilerConfiguration ( ) , new GroovyClassLoader ( ) , new ErrorCollector ( new CompilerConfiguration ( ) ) ) ; sourceUnit . parse ( ) ; sourceUnit . completePhase ( ) ; sourceUnit . convert ( ) ; ModuleNode module = sourceUnit . getAST ( ) ; assertEquals ( <NUM_LIT:0> , module . getStart ( ) ) ; assertEquals ( content . length ( ) , module . getEnd ( ) ) ; assertEquals ( content . indexOf ( "<STR_LIT>" ) , ( ( ASTNode ) module . getStatementBlock ( ) . getStatements ( ) . get ( <NUM_LIT:0> ) ) . getStart ( ) ) ; assertEquals ( content . length ( ) , ( ( ASTNode ) module . getStatementBlock ( ) . getStatements ( ) . get ( <NUM_LIT:0> ) ) . getEnd ( ) ) ; } public void testUnicodeEscapes3 ( ) throws Exception { String escapeSequence = "<STR_LIT>" ; String content = escapeSequence + "<STR_LIT>" ; SourceUnit sourceUnit = new SourceUnit ( "<STR_LIT>" , content , new CompilerConfiguration ( ) , new GroovyClassLoader ( ) , new ErrorCollector ( new CompilerConfiguration ( ) ) ) ; sourceUnit . parse ( ) ; sourceUnit . completePhase ( ) ; sourceUnit . convert ( ) ; ModuleNode module = sourceUnit . getAST ( ) ; assertEquals ( <NUM_LIT:0> , module . getStart ( ) ) ; assertEquals ( content . length ( ) , module . getEnd ( ) ) ; assertEquals ( content . indexOf ( "<STR_LIT>" ) , ( ( ASTNode ) module . getStatementBlock ( ) . getStatements ( ) . get ( <NUM_LIT:0> ) ) . getStart ( ) ) ; assertEquals ( content . length ( ) , ( ( ASTNode ) module . getStatementBlock ( ) . getStatements ( ) . get ( <NUM_LIT:0> ) ) . getEnd ( ) ) ; DeclarationExpression decl = ( DeclarationExpression ) ( ( ExpressionStatement ) module . getStatementBlock ( ) . getStatements ( ) . get ( <NUM_LIT:0> ) ) . getExpression ( ) ; assertEquals ( content . indexOf ( '<CHAR_LIT>' ) , decl . getLeftExpression ( ) . getStart ( ) ) ; assertEquals ( content . indexOf ( '<CHAR_LIT>' ) + <NUM_LIT:1> , decl . getLeftExpression ( ) . getEnd ( ) ) ; assertEquals ( content . indexOf ( '<CHAR_LIT>' ) , decl . getRightExpression ( ) . getStart ( ) ) ; assertEquals ( content . indexOf ( '<CHAR_LIT>' ) + <NUM_LIT:1> , decl . getRightExpression ( ) . getEnd ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . locations ; import java . util . Hashtable ; import junit . framework . Test ; import org . codehaus . jdt . groovy . integration . LanguageSupportFactory ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . dom . AST ; import org . eclipse . jdt . core . dom . ASTNode ; import org . eclipse . jdt . core . dom . ASTParser ; import org . eclipse . jdt . core . dom . CompilationUnit ; import org . eclipse . jdt . core . dom . NodeFinder ; import org . eclipse . jdt . core . dom . SimpleName ; import org . eclipse . jdt . core . tests . junit . extension . TestCase ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . parser . Parser ; public class ASTConverterTests extends TestCase { public ASTConverterTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( ASTConverterTests . class ) ; } public void testJavaASTConversionEnum ( ) throws Exception { checkJavaName ( "<STR_LIT>" , "<STR_LIT>" ) ; } public void testJavaASTConversionClass ( ) throws Exception { checkJavaName ( "<STR_LIT>" , "<STR_LIT>" ) ; } public void testJavaASTConversionInterface ( ) throws Exception { checkJavaName ( "<STR_LIT>" , "<STR_LIT>" ) ; } private void checkJavaName ( String contents , String expectedName ) { int start = contents . lastIndexOf ( expectedName ) ; int length = expectedName . length ( ) ; SimpleName name = ( SimpleName ) findJavaNodeAt ( contents , start , length ) ; assertEquals ( expectedName , name . getIdentifier ( ) ) ; assertEquals ( "<STR_LIT>" , start , name . getStartPosition ( ) ) ; assertEquals ( "<STR_LIT>" , length , name . getLength ( ) ) ; } private ASTNode findJavaNodeAt ( String contents , int start , int length ) { ASTParser parser = ASTParser . newParser ( AST . JLS3 ) ; Hashtable < String , String > options = JavaCore . getOptions ( ) ; options . put ( CompilerOptions . OPTION_Source , "<STR_LIT>" ) ; parser . setCompilerOptions ( options ) ; parser . setSource ( contents . toCharArray ( ) ) ; parser . setStatementsRecovery ( true ) ; CompilationUnit unit = ( CompilationUnit ) parser . createAST ( null ) ; assertEquals ( "<STR_LIT>" + printProblems ( unit ) , <NUM_LIT:0> , unit . getProblems ( ) . length ) ; return NodeFinder . perform ( unit , start , length ) ; } private String printProblems ( CompilationUnit unit ) { StringBuilder sb = new StringBuilder ( ) ; for ( int i = <NUM_LIT:0> ; i < unit . getProblems ( ) . length ; i ++ ) { sb . append ( unit . getProblems ( ) [ i ] ) ; sb . append ( "<STR_LIT:n>" ) ; } return sb . toString ( ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . locations ; import groovy . lang . GroovyClassLoader ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . List ; import java . util . SortedSet ; import junit . framework . Test ; import org . codehaus . groovy . ast . ASTNode ; import org . codehaus . groovy . ast . ClassCodeVisitorSupport ; import org . codehaus . groovy . ast . ClassNode ; import org . codehaus . groovy . ast . ImportNode ; import org . codehaus . groovy . ast . ImportNodeCompatibilityWrapper ; import org . codehaus . groovy . ast . ModuleNode ; import org . codehaus . groovy . ast . expr . BinaryExpression ; import org . codehaus . groovy . ast . expr . CastExpression ; import org . codehaus . groovy . ast . expr . MapEntryExpression ; import org . codehaus . groovy . ast . expr . MapExpression ; import org . codehaus . groovy . ast . stmt . AssertStatement ; import org . codehaus . groovy . control . CompilerConfiguration ; import org . codehaus . groovy . control . ErrorCollector ; import org . codehaus . groovy . control . SourceUnit ; import org . eclipse . jdt . core . groovy . tests . builder . GroovierBuilderTests ; public class ASTNodeSourceLocationsTests extends GroovierBuilderTests { public ASTNodeSourceLocationsTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( ASTNodeSourceLocationsTests . class ) ; } public void testBinaryExpr1 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" ; checkBinaryExprSLocs ( contents , new BinaryExpressionSLocTester ( ) , "<STR_LIT>" , "<STR_LIT>" ) ; } public void testBinaryExpr2 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" ; checkBinaryExprSLocs ( contents , new BinaryExpressionSLocTester ( ) , "<STR_LIT>" , "<STR_LIT>" ) ; } public void testBinaryExpr3 ( ) throws Exception { String contents = "<STR_LIT>" ; checkBinaryExprSLocs ( contents , new BinaryExpressionSLocTester ( ) , "<STR_LIT>" ) ; } public void testBinaryExpr4 ( ) throws Exception { String contents = "<STR_LIT>" ; checkBinaryExprSLocs ( contents , new BinaryExpressionSLocTester ( ) , "<STR_LIT>" ) ; } public void testBinaryExpr5 ( ) throws Exception { String contents = "<STR_LIT>" ; checkBinaryExprSLocsReverse ( contents , "<STR_LIT>" , "<STR_LIT>" ) ; } public void testBinaryExpr6 ( ) throws Exception { String contents = "<STR_LIT>" ; checkBinaryExprSLocsReverse ( contents , "<STR_LIT>" , "<STR_LIT>" ) ; } public void testBinaryExpr7 ( ) throws Exception { String contents = "<STR_LIT>" ; checkBinaryExprSLocs ( contents , new BinaryExpressionSLocTester ( ) , "<STR_LIT>" ) ; } public void testMapExpression1 ( ) throws Exception { checkBinaryExprSLocs ( "<STR_LIT>" , new MapExpressionSLocTester ( ) , "<STR_LIT>" ) ; } public void testMapExpression2 ( ) throws Exception { checkBinaryExprSLocs ( "<STR_LIT>" , new MapExpressionSLocTester ( ) , "<STR_LIT>" ) ; } public void testMapExpression3 ( ) throws Exception { checkBinaryExprSLocs ( "<STR_LIT>" , new MapExpressionSLocTester ( ) , "<STR_LIT>" ) ; } public void _testMapExpression4 ( ) throws Exception { checkBinaryExprSLocs ( "<STR_LIT>" , new MapExpressionSLocTester ( ) , "<STR_LIT>" ) ; } public void testMapEntryExpression1 ( ) throws Exception { checkBinaryExprSLocs ( "<STR_LIT>" , new MapEntryExpressionSLocTester ( ) , "<STR_LIT>" ) ; } public void testMapEntryExpression2 ( ) throws Exception { checkBinaryExprSLocs ( "<STR_LIT>" , new MapEntryExpressionSLocTester ( ) , "<STR_LIT>" ) ; } public void testMapEntryExpression3 ( ) throws Exception { checkBinaryExprSLocs ( "<STR_LIT>" , new MapEntryExpressionSLocTester ( ) , "<STR_LIT>" ) ; } public void testMapEntryExpression4 ( ) throws Exception { checkBinaryExprSLocs ( "<STR_LIT>" , new MapEntryExpressionSLocTester ( ) , "<STR_LIT>" , "<STR_LIT>" ) ; } public void testMapEntryExpression5 ( ) throws Exception { checkBinaryExprSLocs ( "<STR_LIT>" , new MapEntryExpressionSLocTester ( ) , "<STR_LIT>" , "<STR_LIT>" ) ; } public void testMapEntryExpression6 ( ) throws Exception { checkBinaryExprSLocs ( "<STR_LIT>" , new MapEntryExpressionSLocTester ( ) , "<STR_LIT>" , "<STR_LIT>" ) ; } public void testMapEntryExpression7 ( ) throws Exception { checkBinaryExprSLocs ( "<STR_LIT>" , new MapEntryExpressionSLocTester ( ) , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; } public void testCastExpression1 ( ) throws Exception { checkBinaryExprSLocs ( "<STR_LIT>" , new CastExpressionSLocTester ( ) , "<STR_LIT>" ) ; } public void testCastExpression2 ( ) throws Exception { checkBinaryExprSLocs ( "<STR_LIT>" , new CastExpressionSLocTester ( ) , "<STR_LIT>" ) ; } public void testCastExpression3 ( ) throws Exception { checkBinaryExprSLocs ( "<STR_LIT>" , new CastExpressionSLocTester ( ) , "<STR_LIT>" ) ; } public void testImportStatement1 ( ) throws Exception { checkBinaryExprSLocs ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" , new ImportStatementSLocTester ( ) , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; } public void testAssertStatement1 ( ) throws Exception { checkBinaryExprSLocs ( "<STR_LIT>" , new AssertStatementSLocTester ( ) , "<STR_LIT>" ) ; } class StartAndEnd { final int start ; final int end ; public StartAndEnd ( int start , int end ) { this . start = start ; this . end = end ; } public StartAndEnd ( ASTNode node ) { this ( node . getStart ( ) , node . getEnd ( ) ) ; } boolean isOK ( ASTNode node ) { return node . getStart ( ) == start && node . getEnd ( ) == end ; } @ Override public String toString ( ) { return "<STR_LIT>" + start + "<STR_LIT>" + end + "<STR_LIT:]>" ; } } abstract class AbstractSLocTester extends ClassCodeVisitorSupport { List < ASTNode > allCollectedNodes = new ArrayList < ASTNode > ( ) ; void doTest ( ModuleNode module , StartAndEnd ... sae ) { for ( ClassNode c : ( Iterable < ClassNode > ) module . getClasses ( ) ) { this . visitClass ( c ) ; } assertStartAndEnds ( sae ) ; } @ Override protected SourceUnit getSourceUnit ( ) { return null ; } void assertStartAndEnds ( StartAndEnd ... sae ) { assertEquals ( "<STR_LIT>" , sae . length , allCollectedNodes . size ( ) ) ; ASTNode [ ] bexprs = allCollectedNodes . toArray ( new ASTNode [ <NUM_LIT:0> ] ) ; List < Integer > problemIndices = new ArrayList < Integer > ( ) ; for ( int i = <NUM_LIT:0> ; i < bexprs . length ; i ++ ) { if ( ! sae [ i ] . isOK ( bexprs [ i ] ) ) { problemIndices . add ( i ) ; } } if ( problemIndices . size ( ) > <NUM_LIT:0> ) { StringBuilder sb = new StringBuilder ( ) ; for ( Integer integer : problemIndices ) { int val = integer . intValue ( ) ; sb . append ( "<STR_LIT>" + sae [ val ] + "<STR_LIT>" + bexprs [ val ] + "<STR_LIT>" + new StartAndEnd ( bexprs [ val ] ) + "<STR_LIT:n>" ) ; } fail ( sb . toString ( ) ) ; } } } class ImportStatementSLocTester extends AbstractSLocTester { public void visitImports ( ModuleNode module ) { ImportNodeCompatibilityWrapper wrapper = new ImportNodeCompatibilityWrapper ( module ) ; SortedSet < ImportNode > nodes = wrapper . getAllImportNodes ( ) ; for ( ImportNode node : nodes ) { allCollectedNodes . add ( node ) ; } } } class BinaryExpressionSLocTester extends AbstractSLocTester { @ Override public void visitBinaryExpression ( BinaryExpression expression ) { super . visitBinaryExpression ( expression ) ; allCollectedNodes . add ( expression ) ; } } class MapExpressionSLocTester extends AbstractSLocTester { @ Override public void visitMapExpression ( MapExpression expression ) { super . visitMapExpression ( expression ) ; allCollectedNodes . add ( expression ) ; } } class MapEntryExpressionSLocTester extends AbstractSLocTester { @ Override public void visitMapEntryExpression ( MapEntryExpression expression ) { super . visitMapEntryExpression ( expression ) ; allCollectedNodes . add ( expression ) ; } } class CastExpressionSLocTester extends AbstractSLocTester { @ Override public void visitCastExpression ( CastExpression expression ) { super . visitCastExpression ( expression ) ; allCollectedNodes . add ( expression ) ; } } class AssertStatementSLocTester extends AbstractSLocTester { @ Override public void visitAssertStatement ( AssertStatement statement ) { super . visitAssertStatement ( statement ) ; allCollectedNodes . add ( statement ) ; } } private void checkBinaryExprSLocs ( String contents , AbstractSLocTester tester , String ... exprStrings ) throws Exception { StartAndEnd [ ] points = convertToPoints ( contents , exprStrings ) ; ModuleNode module = createModuleNodeFor ( contents ) ; tester . doTest ( module , points ) ; } private void checkBinaryExprSLocsReverse ( String contents , String ... exprStrings ) throws Exception { StartAndEnd [ ] points = convertToPoints ( contents , exprStrings ) ; List < StartAndEnd > list = Arrays . asList ( points ) ; Collections . reverse ( list ) ; points = list . toArray ( points ) ; ModuleNode module = createModuleNodeFor ( contents ) ; BinaryExpressionSLocTester tester = new BinaryExpressionSLocTester ( ) ; tester . doTest ( module , points ) ; } private StartAndEnd [ ] convertToPoints ( String contents , String [ ] exprStrings ) { StartAndEnd [ ] points = new StartAndEnd [ exprStrings . length ] ; int prevEnd = <NUM_LIT:0> ; int prevStart = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < exprStrings . length ; i ++ ) { int start = contents . indexOf ( exprStrings [ i ] , prevEnd ) ; if ( start == - <NUM_LIT:1> ) { start = contents . indexOf ( exprStrings [ i ] , prevStart ) ; if ( start == - <NUM_LIT:1> ) { start = contents . indexOf ( exprStrings [ i ] ) ; if ( start == - <NUM_LIT:1> ) { fail ( "<STR_LIT>" ) ; } } } int end = start + exprStrings [ i ] . length ( ) ; points [ i ] = new StartAndEnd ( start , end ) ; prevStart = start ; prevEnd = end + <NUM_LIT:1> ; } return points ; } private ModuleNode createModuleNodeFor ( String contents ) throws Exception { SourceUnit sourceUnit = new SourceUnit ( "<STR_LIT>" , contents , new CompilerConfiguration ( ) , new GroovyClassLoader ( ) , new ErrorCollector ( new CompilerConfiguration ( ) ) ) ; sourceUnit . parse ( ) ; sourceUnit . completePhase ( ) ; sourceUnit . convert ( ) ; return sourceUnit . getAST ( ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . locations ; import java . util . List ; import junit . framework . Test ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . ResourcesPlugin ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IField ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IMember ; import org . eclipse . jdt . core . IMethod ; import org . eclipse . jdt . core . ISourceRange ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . SourceRange ; import org . eclipse . jdt . core . dom . AST ; import org . eclipse . jdt . core . dom . ASTParser ; import org . eclipse . jdt . core . dom . AbstractTypeDeclaration ; import org . eclipse . jdt . core . dom . AnnotationTypeMemberDeclaration ; import org . eclipse . jdt . core . dom . BodyDeclaration ; import org . eclipse . jdt . core . dom . FieldDeclaration ; import org . eclipse . jdt . core . dom . MethodDeclaration ; import org . eclipse . jdt . core . dom . SimpleName ; import org . eclipse . jdt . core . dom . VariableDeclarationFragment ; import org . eclipse . jdt . core . groovy . tests . builder . GroovierBuilderTests ; import org . eclipse . jdt . core . tests . util . Util ; import org . eclipse . jdt . internal . core . CompilationUnit ; public class SourceLocationsTests extends GroovierBuilderTests { public SourceLocationsTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( SourceLocationsTests . class ) ; } public void testSourceLocations ( ) throws Exception { String source = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; ICompilationUnit unit = createCompilationUnitFor ( "<STR_LIT>" , "<STR_LIT:Hello>" , source ) ; assertUnitWithSingleType ( source , unit ) ; } public void testSourceLocationsNoSemiColons ( ) throws Exception { String source = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; ICompilationUnit unit = createCompilationUnitFor ( "<STR_LIT>" , "<STR_LIT:Hello>" , source ) ; assertUnitWithSingleType ( source , unit ) ; } public void testSourceLocationsNoModifiers ( ) throws Exception { String source = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; ICompilationUnit unit = createCompilationUnitFor ( "<STR_LIT>" , "<STR_LIT:Hello>" , source ) ; assertUnitWithSingleType ( source , unit ) ; } public void testSourceLocationsMultipleVariableFragments ( ) throws Exception { String source = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; ICompilationUnit unit = createCompilationUnitFor ( "<STR_LIT>" , "<STR_LIT:Hello>" , source ) ; assertUnitWithSingleType ( source , unit ) ; } public void testSourceLocationsNoParameterTypes ( ) throws Exception { String source = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; ICompilationUnit unit = createCompilationUnitFor ( "<STR_LIT>" , "<STR_LIT:Hello>" , source ) ; assertUnitWithSingleType ( source , unit ) ; } public void testSourceLocationsNoParameters ( ) throws Exception { String source = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; ICompilationUnit unit = createCompilationUnitFor ( "<STR_LIT>" , "<STR_LIT:Hello>" , source ) ; assertUnitWithSingleType ( source , unit ) ; } public void testSourceLocationsDefaultParameters ( ) throws Exception { String source = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; ICompilationUnit unit = createCompilationUnitFor ( "<STR_LIT>" , "<STR_LIT:Hello>" , source ) ; assertUnitWithSingleType ( source , unit ) ; } public void testSourceLocationsConstructor ( ) throws Exception { String source = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; ICompilationUnit unit = createCompilationUnitFor ( "<STR_LIT>" , "<STR_LIT:Hello>" , source ) ; assertUnitWithSingleType ( source , unit ) ; } public void testSourceLocationsConstructorWithParam ( ) throws Exception { String source = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; ICompilationUnit unit = createCompilationUnitFor ( "<STR_LIT>" , "<STR_LIT:Hello>" , source ) ; assertUnitWithSingleType ( source , unit ) ; } public void testSourceLocationsConstructorWithParamNoType ( ) throws Exception { String source = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; ICompilationUnit unit = createCompilationUnitFor ( "<STR_LIT>" , "<STR_LIT:Hello>" , source ) ; assertUnitWithSingleType ( source , unit ) ; } public void testSourceLocationsConstructorWithDefaultParam ( ) throws Exception { String source = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; ICompilationUnit unit = createCompilationUnitFor ( "<STR_LIT>" , "<STR_LIT:Hello>" , source ) ; assertUnitWithSingleType ( source , unit ) ; } public void testSourceLocationsForScript1 ( ) throws Exception { String source = "<STR_LIT>" + "<STR_LIT>" ; ICompilationUnit unit = createCompilationUnitFor ( "<STR_LIT>" , "<STR_LIT:Hello>" , source ) ; assertScript ( source , unit , "<STR_LIT>" , "<STR_LIT>" ) ; assertUnit ( unit , source ) ; } public void testSourceLocationsForScript2 ( ) throws Exception { String source = "<STR_LIT>" + "<STR_LIT>" ; ICompilationUnit unit = createCompilationUnitFor ( "<STR_LIT>" , "<STR_LIT:Hello>" , source ) ; assertScript ( source , unit , "<STR_LIT>" , "<STR_LIT>" ) ; assertUnit ( unit , source ) ; } public void testSourceLocationsForScript3 ( ) throws Exception { String source = "<STR_LIT>" + "<STR_LIT>" ; ICompilationUnit unit = createCompilationUnitFor ( "<STR_LIT>" , "<STR_LIT:Hello>" , source ) ; assertScript ( source , unit , "<STR_LIT>" , "<STR_LIT>" ) ; assertUnit ( unit , source ) ; } public void testSourceLocationsForScript4 ( ) throws Exception { String source = "<STR_LIT>" + "<STR_LIT>" ; ICompilationUnit unit = createCompilationUnitFor ( "<STR_LIT>" , "<STR_LIT:Hello>" , source ) ; assertScript ( source , unit , "<STR_LIT>" , "<STR_LIT>" ) ; assertUnit ( unit , source ) ; } public void testSourceLocationsForScript5 ( ) throws Exception { String source = "<STR_LIT>" + "<STR_LIT>" ; ICompilationUnit unit = createCompilationUnitFor ( "<STR_LIT>" , "<STR_LIT:Hello>" , source ) ; assertScript ( source , unit , "<STR_LIT>" , "<STR_LIT>" ) ; assertUnit ( unit , source ) ; } public void testSourceLocationsForScript6 ( ) throws Exception { String source = "<STR_LIT>" + "<STR_LIT>" ; ICompilationUnit unit = createCompilationUnitFor ( "<STR_LIT>" , "<STR_LIT:Hello>" , source ) ; assertScript ( source , unit , "<STR_LIT>" , "<STR_LIT>" ) ; assertUnit ( unit , source ) ; } public void testSourceLocationsConstructorWithDefaultParams ( ) throws Exception { String source = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; ICompilationUnit unit = createCompilationUnitFor ( "<STR_LIT>" , "<STR_LIT:Hello>" , source ) ; assertUnitWithSingleType ( source , unit ) ; } public void testSourceLocationsInterface ( ) throws Exception { String source = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; ICompilationUnit unit = createCompilationUnitFor ( "<STR_LIT>" , "<STR_LIT:Hello>" , source ) ; assertUnitWithSingleType ( source , unit ) ; } public void testSourceLocationsAbstractClass ( ) throws Exception { String source = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; ICompilationUnit unit = createCompilationUnitFor ( "<STR_LIT>" , "<STR_LIT:Hello>" , source ) ; assertUnitWithSingleType ( source , unit ) ; } public void testSourceLocationsAnnotationDeclaration ( ) throws Exception { String source = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; ICompilationUnit unit = createCompilationUnitFor ( "<STR_LIT>" , "<STR_LIT:Hello>" , source ) ; assertUnitWithSingleType ( source , unit ) ; } public void testSourceLocationsEnumDeclaration ( ) throws Exception { String source = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; ICompilationUnit unit = createCompilationUnitFor ( "<STR_LIT>" , "<STR_LIT:Hello>" , source ) ; assertUnitWithSingleType ( source , unit ) ; } private void assertUnitWithSingleType ( String source , ICompilationUnit unit ) throws Exception , JavaModelException { assertUnit ( unit , source ) ; ASTParser newParser = ASTParser . newParser ( AST . JLS4 ) ; newParser . setSource ( unit ) ; org . eclipse . jdt . core . dom . CompilationUnit ast = ( org . eclipse . jdt . core . dom . CompilationUnit ) newParser . createAST ( null ) ; int maxLength = ( ( CompilationUnit ) unit ) . getContents ( ) . length - <NUM_LIT:1> ; IType decl = unit . getTypes ( ) [ <NUM_LIT:0> ] ; AbstractTypeDeclaration typeDecl = ( AbstractTypeDeclaration ) ast . types ( ) . get ( <NUM_LIT:0> ) ; assertDeclaration ( decl , typeDecl , <NUM_LIT:0> , source , maxLength ) ; IJavaElement [ ] children = decl . getChildren ( ) ; List < BodyDeclaration > bodyDecls = typeDecl . bodyDeclarations ( ) ; for ( int i = <NUM_LIT:0> , j = <NUM_LIT:0> ; i < children . length ; i ++ , j ++ ) { if ( i > <NUM_LIT:0> && ( children [ i ] instanceof IMethod ) && children [ i ] . getElementName ( ) . equals ( children [ i - <NUM_LIT:1> ] . getElementName ( ) ) ) { j -- ; } if ( decl . isEnum ( ) ) { IMember member = ( IMember ) children [ i ] ; assertEquals ( new SourceRange ( <NUM_LIT:0> , <NUM_LIT:0> ) , member . getSourceRange ( ) ) ; } else { assertDeclaration ( ( IMember ) children [ i ] , bodyDecls . get ( i ) , j , source , maxLength ) ; } } } private void assertDeclaration ( IMember decl , BodyDeclaration bd , int methodNumber , String source , int maxLength ) throws Exception { char astKind ; if ( decl instanceof IMethod ) { astKind = '<CHAR_LIT>' ; } else if ( decl instanceof IField ) { astKind = '<CHAR_LIT>' ; } else { astKind = '<CHAR_LIT>' ; } String startTag = "<STR_LIT>" + astKind + methodNumber + "<STR_LIT>" ; int start = source . indexOf ( startTag ) + startTag . length ( ) ; String endTag = "<STR_LIT>" + astKind + methodNumber + "<STR_LIT>" ; int end = Math . min ( source . indexOf ( endTag ) + endTag . length ( ) , maxLength ) ; boolean ignore = false ; if ( decl instanceof IField && ( start == <NUM_LIT:6> || end == <NUM_LIT:6> ) ) { ignore = true ; } if ( ! ignore ) { ISourceRange declRange = decl . getSourceRange ( ) ; assertEquals ( decl + "<STR_LIT>" , start , declRange . getOffset ( ) ) ; assertEquals ( decl + "<STR_LIT>" , end , declRange . getOffset ( ) + declRange . getLength ( ) ) ; assertEquals ( bd + "<STR_LIT>" , start , bd . getStartPosition ( ) ) ; int sourceEnd = bd . getStartPosition ( ) + bd . getLength ( ) ; if ( bd instanceof FieldDeclaration ) sourceEnd -- ; assertEquals ( bd + "<STR_LIT>" , end , sourceEnd ) ; } String nameStartTag = "<STR_LIT>" + astKind + methodNumber + "<STR_LIT>" ; int nameStart = source . indexOf ( nameStartTag ) + nameStartTag . length ( ) ; String nameEndTag = "<STR_LIT>" + astKind + methodNumber + "<STR_LIT>" ; int nameEnd = source . indexOf ( nameEndTag ) ; if ( decl instanceof IMethod && ( ( IMethod ) decl ) . isConstructor ( ) ) { nameEnd += nameEndTag . length ( ) ; } ISourceRange nameDeclRange = decl . getNameRange ( ) ; assertEquals ( decl + "<STR_LIT>" , nameStart , nameDeclRange . getOffset ( ) ) ; assertEquals ( decl + "<STR_LIT>" , nameEnd , nameDeclRange . getOffset ( ) + nameDeclRange . getLength ( ) ) ; if ( bd instanceof FieldDeclaration ) { FieldDeclaration fd = ( FieldDeclaration ) bd ; SimpleName name = ( ( VariableDeclarationFragment ) fd . fragments ( ) . get ( <NUM_LIT:0> ) ) . getName ( ) ; assertEquals ( bd + "<STR_LIT>" , nameStart , name . getStartPosition ( ) ) ; assertEquals ( bd + "<STR_LIT>" , nameEnd , name . getStartPosition ( ) + name . getLength ( ) ) ; } if ( bd instanceof MethodDeclaration ) { MethodDeclaration md = ( MethodDeclaration ) bd ; SimpleName name = md . getName ( ) ; assertEquals ( bd + "<STR_LIT>" , nameStart , name . getStartPosition ( ) ) ; assertEquals ( bd + "<STR_LIT>" , nameEnd , name . getStartPosition ( ) + name . getLength ( ) ) ; } if ( decl . getElementType ( ) == IJavaElement . METHOD ) { String bodyStartTag = "<STR_LIT>" + astKind + methodNumber + "<STR_LIT>" ; int bodyStart = source . indexOf ( bodyStartTag ) + bodyStartTag . length ( ) ; if ( bd instanceof MethodDeclaration ) { MethodDeclaration md = ( MethodDeclaration ) bd ; if ( md . getBody ( ) != null ) { int actualBodyStart = md . getBody ( ) . getStartPosition ( ) ; assertEquals ( bd + "<STR_LIT>" , bodyStart , actualBodyStart ) ; } } else if ( bd instanceof AnnotationTypeMemberDeclaration ) { } } } private void assertUnit ( ICompilationUnit unit , String source ) throws Exception { assertEquals ( unit + "<STR_LIT>" , <NUM_LIT:0> , unit . getSourceRange ( ) . getOffset ( ) ) ; assertEquals ( unit + "<STR_LIT>" , source . length ( ) , unit . getSourceRange ( ) . getLength ( ) ) ; } private void assertScript ( String source , ICompilationUnit unit , String startText , String endText ) throws Exception { IType script = unit . getTypes ( ) [ <NUM_LIT:0> ] ; IMethod runMethod = script . getMethod ( "<STR_LIT>" , new String [ <NUM_LIT:0> ] ) ; int start = source . indexOf ( startText ) ; int end = source . lastIndexOf ( endText ) + endText . length ( ) ; assertEquals ( "<STR_LIT>" + source , start , script . getSourceRange ( ) . getOffset ( ) ) ; assertEquals ( "<STR_LIT>" + source , end , script . getSourceRange ( ) . getOffset ( ) + script . getSourceRange ( ) . getLength ( ) ) ; assertEquals ( "<STR_LIT>" + source , start , runMethod . getSourceRange ( ) . getOffset ( ) ) ; assertEquals ( "<STR_LIT>" + source , end , runMethod . getSourceRange ( ) . getOffset ( ) + script . getSourceRange ( ) . getLength ( ) ) ; } private IPath createGenericProject ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; return root ; } private ICompilationUnit createCompilationUnitFor ( String pack , String name , String source ) throws Exception { IPath root = createGenericProject ( ) ; IPath path = env . addGroovyClass ( root , pack , name , source ) ; fullBuild ( ) ; expectingNoProblems ( ) ; IFile groovyFile = getFile ( path ) ; return JavaCore . createCompilationUnitFrom ( groovyFile ) ; } private IFile getFile ( IPath path ) { return ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getFile ( path ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . compiler ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; import org . codehaus . jdt . groovy . model . GroovyCompilationUnit ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . IPackageFragment ; import org . eclipse . jdt . core . IPackageFragmentRoot ; import org . eclipse . jdt . core . JavaModelException ; public class ReconcilerUtils { public static class ReconcileResults { public Map < ICompilationUnit , Long > reconcileTimes = new HashMap < ICompilationUnit , Long > ( ) ; public long getReconcileTime ( ICompilationUnit unit ) { return reconcileTimes . get ( unit ) ; } public long totalTime ; public String toString ( ) { StringBuilder s = new StringBuilder ( ) ; s . append ( "<STR_LIT>" + reconcileTimes . size ( ) + "<STR_LIT>" ) ; long totaltime = <NUM_LIT> ; for ( Map . Entry < ICompilationUnit , Long > entry : reconcileTimes . entrySet ( ) ) { s . append ( entry . getValue ( ) + "<STR_LIT>" + entry . getKey ( ) . getElementName ( ) + "<STR_LIT:n>" ) ; totaltime += entry . getValue ( ) ; } s . append ( "<STR_LIT>" + totaltime + "<STR_LIT>" ) ; return s . toString ( ) ; } public long getTotalTimeSpentReconciling ( ) { long totaltime = <NUM_LIT> ; for ( Map . Entry < ICompilationUnit , Long > entry : reconcileTimes . entrySet ( ) ) { totaltime += entry . getValue ( ) ; } return totaltime ; } } public static ReconcileResults reconcileAllCompilationUnits ( IJavaProject project , boolean onlyGroovy ) throws JavaModelException { List < ICompilationUnit > allUnits = findAllUnits ( project , onlyGroovy ) ; ReconcileResults results = new ReconcileResults ( ) ; long totalTime = <NUM_LIT:0> ; for ( ICompilationUnit unit : allUnits ) { long startTime = System . currentTimeMillis ( ) ; unit . becomeWorkingCopy ( null ) ; long timeForUnit = System . currentTimeMillis ( ) - startTime ; results . reconcileTimes . put ( unit , timeForUnit ) ; totalTime += timeForUnit ; unit . discardWorkingCopy ( ) ; } return results ; } private static List < ICompilationUnit > findAllUnits ( IJavaProject project , boolean onlyGroovy ) throws JavaModelException { IPackageFragmentRoot [ ] roots = project . getAllPackageFragmentRoots ( ) ; List < ICompilationUnit > units = new ArrayList < ICompilationUnit > ( ) ; for ( IPackageFragmentRoot root : roots ) { if ( ! root . isReadOnly ( ) ) { for ( IJavaElement child : root . getChildren ( ) ) { if ( child instanceof IPackageFragment ) { ICompilationUnit [ ] theseUnits = ( ( IPackageFragment ) child ) . getCompilationUnits ( ) ; for ( ICompilationUnit unit : theseUnits ) { if ( unit instanceof GroovyCompilationUnit || ! onlyGroovy ) { units . add ( unit ) ; } } } } } } return units ; } public static ICompilationUnit getWorkingCopy ( IJavaProject project , String name ) { try { ICompilationUnit icu = findUnit ( project , name ) ; return icu ; } catch ( Exception e ) { return null ; } } private static ICompilationUnit findUnit ( IJavaProject project , String name ) throws JavaModelException { IPackageFragmentRoot [ ] roots = project . getAllPackageFragmentRoots ( ) ; List < ICompilationUnit > units = new ArrayList < ICompilationUnit > ( ) ; for ( IPackageFragmentRoot root : roots ) { if ( ! root . isReadOnly ( ) ) { for ( IJavaElement child : root . getChildren ( ) ) { if ( child instanceof IPackageFragment ) { ICompilationUnit [ ] theseUnits = ( ( IPackageFragment ) child ) . getCompilationUnits ( ) ; for ( ICompilationUnit unit : theseUnits ) { if ( unit instanceof GroovyCompilationUnit ) { if ( unit . getElementName ( ) . equals ( name ) ) { return unit ; } else { System . out . println ( unit . getElementName ( ) ) ; } } } } } } } return null ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . compiler ; import java . util . Arrays ; import java . util . List ; import junit . framework . Test ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . IProject ; import org . eclipse . core . resources . IWorkspaceRoot ; import org . eclipse . core . resources . ProjectScope ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . Path ; import org . eclipse . core . runtime . preferences . IEclipsePreferences ; import org . eclipse . core . runtime . preferences . IScopeContext ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . groovy . tests . builder . ProjectUtils ; import org . eclipse . jdt . core . tests . builder . BuilderTests ; import org . eclipse . jdt . core . tests . util . Util ; import org . eclipse . jdt . groovy . core . Activator ; import org . eclipse . jdt . groovy . core . util . ScriptFolderSelector ; import org . eclipse . jdt . groovy . core . util . ScriptFolderSelector . FileKind ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . core . CompilationUnit ; public class ScriptFolderTests extends BuilderTests { class MockScriptFolderSelector extends ScriptFolderSelector { protected MockScriptFolderSelector ( String preferences , boolean isDisabled ) { super ( toListOfString ( preferences ) , isDisabled ) ; } } static List < String > toListOfString ( String preferences ) { String [ ] splits = preferences . split ( "<STR_LIT:U+002C>" ) ; return Arrays . asList ( splits ) ; } public ScriptFolderTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( ScriptFolderTests . class ) ; } private boolean origEnabled ; private String origPatterns ; @ Override protected void setUp ( ) throws Exception { try { super . setUp ( ) ; } finally { origEnabled = Activator . getDefault ( ) . getBooleanPreference ( null , Activator . GROOVY_SCRIPT_FILTERS_ENABLED , false ) ; origPatterns = Activator . getDefault ( ) . getStringPreference ( null , Activator . GROOVY_SCRIPT_FILTERS , Activator . DEFAULT_GROOVY_SCRIPT_FILTER ) ; } } @ Override protected void tearDown ( ) throws Exception { try { super . tearDown ( ) ; } finally { Activator . getDefault ( ) . setPreference ( null , Activator . GROOVY_SCRIPT_FILTERS_ENABLED , String . valueOf ( origEnabled ) ) ; Activator . getDefault ( ) . setPreference ( null , Activator . GROOVY_SCRIPT_FILTERS , origPatterns ) ; } } public void testScriptFolderDefaultSettings ( ) throws Exception { MockScriptFolderSelector selector = new MockScriptFolderSelector ( Activator . DEFAULT_GROOVY_SCRIPT_FILTER , true ) ; assertScript ( "<STR_LIT>" , selector ) ; assertScript ( "<STR_LIT>" , selector ) ; assertScript ( "<STR_LIT>" , selector ) ; assertSource ( "<STR_LIT>" , selector ) ; assertSource ( "<STR_LIT>" , selector ) ; assertSource ( "<STR_LIT>" , selector ) ; assertSource ( "<STR_LIT>" , selector ) ; assertSource ( "<STR_LIT>" , selector ) ; assertSource ( "<STR_LIT>" , selector ) ; } public void testScriptFolderDefaultSettingsNoCopy ( ) throws Exception { MockScriptFolderSelector selector = new MockScriptFolderSelector ( Activator . DEFAULT_GROOVY_SCRIPT_FILTER . replaceAll ( "<STR_LIT>" , "<STR_LIT>" ) , true ) ; assertScriptNoCopy ( "<STR_LIT>" , selector ) ; assertScriptNoCopy ( "<STR_LIT>" , selector ) ; assertScriptNoCopy ( "<STR_LIT>" , selector ) ; assertSource ( "<STR_LIT>" , selector ) ; assertSource ( "<STR_LIT>" , selector ) ; assertSource ( "<STR_LIT>" , selector ) ; assertSource ( "<STR_LIT>" , selector ) ; assertSource ( "<STR_LIT>" , selector ) ; assertSource ( "<STR_LIT>" , selector ) ; } public void testScriptFolderDisabled ( ) throws Exception { MockScriptFolderSelector selector = new MockScriptFolderSelector ( Activator . DEFAULT_GROOVY_SCRIPT_FILTER , false ) ; assertSource ( "<STR_LIT>" , selector ) ; assertSource ( "<STR_LIT>" , selector ) ; assertSource ( "<STR_LIT>" , selector ) ; assertSource ( "<STR_LIT>" , selector ) ; assertSource ( "<STR_LIT>" , selector ) ; assertSource ( "<STR_LIT>" , selector ) ; assertSource ( "<STR_LIT>" , selector ) ; assertSource ( "<STR_LIT>" , selector ) ; assertSource ( "<STR_LIT>" , selector ) ; } public void testScriptFolderCustomSettings ( ) throws Exception { MockScriptFolderSelector selector = new MockScriptFolderSelector ( "<STR_LIT>" , true ) ; assertScript ( "<STR_LIT>" , selector ) ; assertScriptNoCopy ( "<STR_LIT>" , selector ) ; assertSource ( "<STR_LIT>" , selector ) ; } public void testScriptFolderInvalidSettings ( ) throws Exception { MockScriptFolderSelector selector = new MockScriptFolderSelector ( "<STR_LIT>" , true ) ; assertScriptNoCopy ( "<STR_LIT>" , selector ) ; assertSource ( "<STR_LIT>" , selector ) ; assertSource ( "<STR_LIT>" , selector ) ; } private void assertScript ( String toCheck , MockScriptFolderSelector selector ) { assertEquals ( toCheck + "<STR_LIT>" , FileKind . SCRIPT , selector . getFileKind ( toCheck . toCharArray ( ) ) ) ; } private void assertScriptNoCopy ( String toCheck , MockScriptFolderSelector selector ) { assertEquals ( toCheck + "<STR_LIT>" , FileKind . SCRIPT_NO_COPY , selector . getFileKind ( toCheck . toCharArray ( ) ) ) ; } private void assertSource ( String toCheck , MockScriptFolderSelector selector ) { assertEquals ( toCheck + "<STR_LIT>" , FileKind . SOURCE , selector . getFileKind ( toCheck . toCharArray ( ) ) ) ; } public void testScriptInProjectNotCompiled ( ) throws Exception { Activator . getDefault ( ) . setPreference ( null , Activator . GROOVY_SCRIPT_FILTERS_ENABLED , "<STR_LIT:true>" ) ; Activator . getDefault ( ) . setPreference ( null , Activator . GROOVY_SCRIPT_FILTERS , Activator . DEFAULT_GROOVY_SCRIPT_FILTER ) ; createScriptInGroovyProject ( "<STR_LIT>" , "<STR_LIT>" , true ) ; assertNoExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; } public void testScriptInProjectNoCopy ( ) throws Exception { Activator . getDefault ( ) . setPreference ( null , Activator . GROOVY_SCRIPT_FILTERS_ENABLED , "<STR_LIT:true>" ) ; Activator . getDefault ( ) . setPreference ( null , Activator . GROOVY_SCRIPT_FILTERS , Activator . DEFAULT_GROOVY_SCRIPT_FILTER . replaceAll ( "<STR_LIT>" , "<STR_LIT>" ) ) ; createScriptInGroovyProject ( "<STR_LIT>" , "<STR_LIT>" , true ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; } public void testScriptInProjectDisabled ( ) throws Exception { Activator . getDefault ( ) . setPreference ( null , Activator . GROOVY_SCRIPT_FILTERS_ENABLED , "<STR_LIT:false>" ) ; Activator . getDefault ( ) . setPreference ( null , Activator . GROOVY_SCRIPT_FILTERS , Activator . DEFAULT_GROOVY_SCRIPT_FILTER ) ; createScriptInGroovyProject ( "<STR_LIT>" , "<STR_LIT>" , true ) ; assertExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; } public void testSourceInProjectCompiled ( ) throws Exception { Activator . getDefault ( ) . setPreference ( null , Activator . GROOVY_SCRIPT_FILTERS_ENABLED , "<STR_LIT:true>" ) ; Activator . getDefault ( ) . setPreference ( null , Activator . GROOVY_SCRIPT_FILTERS , Activator . DEFAULT_GROOVY_SCRIPT_FILTER ) ; createScriptInGroovyProject ( "<STR_LIT>" , "<STR_LIT>" , false ) ; assertExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; } public void testComplexScriptFolderProject ( ) throws Exception { Activator . getDefault ( ) . setPreference ( null , Activator . GROOVY_SCRIPT_FILTERS_ENABLED , "<STR_LIT:true>" ) ; Activator . getDefault ( ) . setPreference ( null , Activator . GROOVY_SCRIPT_FILTERS , "<STR_LIT>" ) ; ProjectUtils . createPredefinedProject ( "<STR_LIT>" ) ; env . fullBuild ( ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertExistsNotDerived ( "<STR_LIT>" ) ; assertExistsNotDerived ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; } public void testComplexScriptFolderProjectNoCopy ( ) throws Exception { Activator . getDefault ( ) . setPreference ( null , Activator . GROOVY_SCRIPT_FILTERS_ENABLED , "<STR_LIT:true>" ) ; Activator . getDefault ( ) . setPreference ( null , Activator . GROOVY_SCRIPT_FILTERS , "<STR_LIT>" ) ; ProjectUtils . createPredefinedProject ( "<STR_LIT>" ) ; env . fullBuild ( ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertExistsNotDerived ( "<STR_LIT>" ) ; assertExistsNotDerived ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; } public void testComplexScriptFolderProjectProjectSettings ( ) throws Exception { IProject project = ProjectUtils . createPredefinedProject ( "<STR_LIT>" ) ; ProjectUtils . createPredefinedProject ( "<STR_LIT>" ) ; IScopeContext projectScope = new ProjectScope ( project ) ; IEclipsePreferences preferences = projectScope . getNode ( Activator . PLUGIN_ID ) ; Activator . getDefault ( ) . setPreference ( preferences , Activator . USING_PROJECT_PROPERTIES , "<STR_LIT:true>" ) ; Activator . getDefault ( ) . setPreference ( preferences , Activator . GROOVY_SCRIPT_FILTERS_ENABLED , "<STR_LIT:true>" ) ; Activator . getDefault ( ) . setPreference ( preferences , Activator . GROOVY_SCRIPT_FILTERS , "<STR_LIT>" ) ; env . fullBuild ( ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertExistsNotDerived ( "<STR_LIT>" ) ; assertExistsNotDerived ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExistsNotDerived ( "<STR_LIT>" ) ; assertExistsNotDerived ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; Activator . getDefault ( ) . setPreference ( preferences , Activator . USING_PROJECT_PROPERTIES , "<STR_LIT:false>" ) ; env . fullBuild ( ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExistsNotDerived ( "<STR_LIT>" ) ; assertExistsNotDerived ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExistsNotDerived ( "<STR_LIT>" ) ; assertExistsNotDerived ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; Activator . getDefault ( ) . setPreference ( null , Activator . GROOVY_SCRIPT_FILTERS_ENABLED , "<STR_LIT:true>" ) ; Activator . getDefault ( ) . setPreference ( null , Activator . GROOVY_SCRIPT_FILTERS , "<STR_LIT>" ) ; Activator . getDefault ( ) . setPreference ( preferences , Activator . USING_PROJECT_PROPERTIES , "<STR_LIT:true>" ) ; Activator . getDefault ( ) . setPreference ( preferences , Activator . GROOVY_SCRIPT_FILTERS_ENABLED , "<STR_LIT:false>" ) ; env . fullBuild ( ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExistsNotDerived ( "<STR_LIT>" ) ; assertExistsNotDerived ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertExistsNotDerived ( "<STR_LIT>" ) ; assertExistsNotDerived ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; assertNoExists ( "<STR_LIT>" ) ; } protected CompilationUnit createScriptInGroovyProject ( String name , String contents , boolean isGroovy ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addGroovyNature ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IProject project = env . getProject ( "<STR_LIT>" ) ; IJavaProject javaProject = JavaCore . create ( project ) ; javaProject . setOption ( CompilerOptions . OPTION_Compliance , "<STR_LIT>" ) ; javaProject . setOption ( CompilerOptions . OPTION_Source , "<STR_LIT>" ) ; javaProject . setOption ( CompilerOptions . OPTION_TargetPlatform , "<STR_LIT>" ) ; IPath path ; if ( isGroovy ) { path = env . addGroovyClass ( project . getFolder ( "<STR_LIT>" ) . getFullPath ( ) , name , contents ) ; } else { path = env . addClass ( project . getFolder ( "<STR_LIT>" ) . getFullPath ( ) , name , contents ) ; } fullBuild ( projectPath ) ; return ( CompilationUnit ) JavaCore . createCompilationUnitFrom ( env . getWorkspace ( ) . getRoot ( ) . getFile ( path ) ) ; } private void assertExists ( String projectRelativePath ) { IWorkspaceRoot root = env . getWorkspace ( ) . getRoot ( ) ; IFile file = root . getFile ( new Path ( projectRelativePath ) ) ; assertTrue ( "<STR_LIT>" + file , file . exists ( ) ) ; assertTrue ( "<STR_LIT>" + file , file . isDerived ( ) ) ; } private void assertExistsNotDerived ( String projectRelativePath ) { IWorkspaceRoot root = env . getWorkspace ( ) . getRoot ( ) ; IFile file = root . getFile ( new Path ( projectRelativePath ) ) ; assertTrue ( "<STR_LIT>" + file , file . exists ( ) ) ; assertFalse ( "<STR_LIT>" + file , file . isDerived ( ) ) ; } private void assertNoExists ( String projectRelativePath ) { IWorkspaceRoot root = env . getWorkspace ( ) . getRoot ( ) ; IFile file = root . getFile ( new Path ( projectRelativePath ) ) ; assertFalse ( "<STR_LIT>" + file , file . exists ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . builder ; import java . io . BufferedReader ; import java . io . File ; import java . io . InputStreamReader ; import java . net . URL ; import java . util . ArrayList ; import java . util . Enumeration ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; import java . util . zip . ZipEntry ; import java . util . zip . ZipFile ; import junit . framework . Test ; import org . codehaus . groovy . ast . ClassNode ; import org . codehaus . groovy . ast . MethodNode ; import org . codehaus . jdt . groovy . model . GroovyCompilationUnit ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . Platform ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . IProblemRequestor ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . compiler . IProblem ; import org . eclipse . jdt . core . groovy . tests . compiler . ReconcilerUtils ; import org . eclipse . jdt . core . groovy . tests . compiler . ReconcilerUtils . ReconcileResults ; import org . eclipse . jdt . core . tests . util . GroovyUtils ; import org . eclipse . jdt . core . tests . util . Util ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; public class FullProjectTests extends GroovierBuilderTests { public FullProjectTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( FullProjectTests . class ) ; } public void testReconcilingWithTransforms_notransformallowed ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; IJavaProject p = env . getJavaProject ( projectPath ) ; ICompilationUnit icu = ReconcilerUtils . getWorkingCopy ( p , "<STR_LIT>" ) ; icu . becomeWorkingCopy ( null ) ; List < ClassNode > classes = ( ( GroovyCompilationUnit ) icu ) . getModuleNode ( ) . getClasses ( ) ; ClassNode cn = classes . get ( <NUM_LIT:0> ) ; assertDoesNotContainMethod ( cn , "<STR_LIT>" ) ; } public void testReconcilingWithTransforms_singletonallowed ( ) throws Exception { if ( GroovyUtils . GROOVY_LEVEL < <NUM_LIT:20> ) { return ; } IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; setTransformsOption ( env . getJavaProject ( projectPath ) , "<STR_LIT>" ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; IJavaProject p = env . getJavaProject ( projectPath ) ; ICompilationUnit icu = ReconcilerUtils . getWorkingCopy ( p , "<STR_LIT>" ) ; icu . becomeWorkingCopy ( null ) ; List < ClassNode > classes = ( ( GroovyCompilationUnit ) icu ) . getModuleNode ( ) . getClasses ( ) ; ClassNode cn = classes . get ( <NUM_LIT:0> ) ; assertContainsMethod ( cn , "<STR_LIT>" ) ; } public void testReconcilingWithTransforms_singletonallowedspecialchar ( ) throws Exception { if ( GroovyUtils . GROOVY_LEVEL < <NUM_LIT:20> ) { return ; } IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; setTransformsOption ( env . getJavaProject ( projectPath ) , "<STR_LIT>" ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; IJavaProject p = env . getJavaProject ( projectPath ) ; ICompilationUnit icu = ReconcilerUtils . getWorkingCopy ( p , "<STR_LIT>" ) ; icu . becomeWorkingCopy ( null ) ; List < ClassNode > classes = ( ( GroovyCompilationUnit ) icu ) . getModuleNode ( ) . getClasses ( ) ; ClassNode cn = classes . get ( <NUM_LIT:0> ) ; assertContainsMethod ( cn , "<STR_LIT>" ) ; } public void testReconcilingWithTransforms_multipleButOnlyOneAllowed ( ) throws Exception { if ( GroovyUtils . GROOVY_LEVEL < <NUM_LIT> ) { return ; } IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; setTransformsOption ( env . getJavaProject ( projectPath ) , "<STR_LIT>" ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; IJavaProject p = env . getJavaProject ( projectPath ) ; ICompilationUnit icu = ReconcilerUtils . getWorkingCopy ( p , "<STR_LIT>" ) ; icu . becomeWorkingCopy ( null ) ; List < ClassNode > classes = ( ( GroovyCompilationUnit ) icu ) . getModuleNode ( ) . getClasses ( ) ; ClassNode cn = classes . get ( <NUM_LIT:0> ) ; assertContainsMethod ( cn , "<STR_LIT>" ) ; assertDoesNotContainMethod ( cn , "<STR_LIT>" ) ; } public void testReconcilingWithTransforms_multipleAndBothAllowed ( ) throws Exception { if ( GroovyUtils . GROOVY_LEVEL < <NUM_LIT> ) { return ; } IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; setTransformsOption ( env . getJavaProject ( projectPath ) , "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; IJavaProject p = env . getJavaProject ( projectPath ) ; ICompilationUnit icu = ReconcilerUtils . getWorkingCopy ( p , "<STR_LIT>" ) ; icu . becomeWorkingCopy ( null ) ; List < ClassNode > classes = ( ( GroovyCompilationUnit ) icu ) . getModuleNode ( ) . getClasses ( ) ; ClassNode cn = classes . get ( <NUM_LIT:0> ) ; assertContainsMethod ( cn , "<STR_LIT>" ) ; assertContainsMethod ( cn , "<STR_LIT>" ) ; } @ SuppressWarnings ( "<STR_LIT:deprecation>" ) public void testReconcilingWithTransforms_compileStatic ( ) throws Exception { if ( GroovyUtils . GROOVY_LEVEL < <NUM_LIT:20> ) { return ; } IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; IJavaProject ijp = env . getJavaProject ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; System . err . println ( "<STR_LIT>" ) ; ICompilationUnit icu = ReconcilerUtils . getWorkingCopy ( ijp , "<STR_LIT>" ) ; PR pr = new PR ( ) ; icu . becomeWorkingCopy ( pr , null ) ; assertContains ( pr . problems , "<STR_LIT>" ) ; } @ SuppressWarnings ( "<STR_LIT:deprecation>" ) public void testReconcilingWithTransforms_typeChecked ( ) throws Exception { if ( GroovyUtils . GROOVY_LEVEL < <NUM_LIT:20> ) { return ; } IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; IJavaProject ijp = env . getJavaProject ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; ICompilationUnit icu = ReconcilerUtils . getWorkingCopy ( ijp , "<STR_LIT>" ) ; PR pr = new PR ( ) ; icu . becomeWorkingCopy ( pr , null ) ; assertContains ( pr . problems , "<STR_LIT>" ) ; } static class PR implements IProblemRequestor { public String problems = "<STR_LIT>" ; public void acceptProblem ( IProblem problem ) { problems = problems + "<STR_LIT:n>" + problem . toString ( ) ; } public void beginReporting ( ) { } public void endReporting ( ) { } public boolean isActive ( ) { return true ; } } public void testReconcilingWithTransforms_multipleAndWildcard ( ) throws Exception { if ( GroovyUtils . GROOVY_LEVEL < <NUM_LIT> ) { return ; } IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; IJavaProject p = env . getJavaProject ( projectPath ) ; setTransformsOption ( p , "<STR_LIT:*>" ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; ICompilationUnit icu = ReconcilerUtils . getWorkingCopy ( p , "<STR_LIT>" ) ; icu . becomeWorkingCopy ( null ) ; List < ClassNode > classes = ( ( GroovyCompilationUnit ) icu ) . getModuleNode ( ) . getClasses ( ) ; ClassNode cn = classes . get ( <NUM_LIT:0> ) ; assertContainsMethod ( cn , "<STR_LIT>" ) ; assertContainsMethod ( cn , "<STR_LIT>" ) ; } public static void assertContainsMethod ( ClassNode cn , String methodname ) { for ( MethodNode mn : cn . getMethods ( ) ) { if ( mn . getName ( ) . equals ( methodname ) ) { return ; } } fail ( "<STR_LIT>" + methodname + "<STR_LIT>" + cn . getName ( ) + "<STR_LIT:'>" ) ; } public static void assertContains ( String data , String expected ) { if ( data . indexOf ( expected ) != - <NUM_LIT:1> ) { return ; } fail ( "<STR_LIT>" + expected + "<STR_LIT>" + data + "<STR_LIT:'>" ) ; } public static void assertDoesNotContainMethod ( ClassNode cn , String methodname ) { for ( MethodNode mn : cn . getMethods ( ) ) { if ( mn . getName ( ) . equals ( methodname ) ) { fail ( "<STR_LIT>" + methodname + "<STR_LIT>" + cn . getName ( ) + "<STR_LIT:'>" ) ; } } } private void setTransformsOption ( IJavaProject javaproject , String transformsSpec ) { Map < String , String > m = new HashMap < String , String > ( ) ; m . put ( CompilerOptions . OPTIONG_GroovyTransformsToRunOnReconcile , transformsSpec ) ; javaproject . setOptions ( m ) ; } public void xtestReconcilingGPars ( ) throws Exception { String fixture = "<STR_LIT>" ; IPath projectPath = env . addProject ( fixture , "<STR_LIT>" ) ; setupProject ( fixture , projectPath ) ; long stime = System . currentTimeMillis ( ) ; incrementalBuild ( projectPath ) ; System . out . println ( "<STR_LIT>" + fixture + "<STR_LIT>" + ( System . currentTimeMillis ( ) - stime ) + "<STR_LIT>" ) ; expectedCompiledClassCount ( <NUM_LIT> ) ; expectingNoErrors ( ) ; IJavaProject p = env . getJavaProject ( projectPath ) ; for ( int i = <NUM_LIT:0> ; i < <NUM_LIT:10> ; i ++ ) { ReconcilerUtils . reconcileAllCompilationUnits ( p , true ) ; } long t = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < <NUM_LIT:20> ; i ++ ) { ReconcileResults rr = ReconcilerUtils . reconcileAllCompilationUnits ( p , true ) ; System . out . println ( rr . getTotalTimeSpentReconciling ( ) + "<STR_LIT>" ) ; t += rr . getTotalTimeSpentReconciling ( ) ; } System . out . println ( "<STR_LIT>" + ( t / <NUM_LIT:20> ) + "<STR_LIT>" ) ; } private void setupProject ( String fixture , IPath projectPath ) throws JavaModelException , Exception { env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . addGroovyJars ( projectPath ) ; addLibraryDependencies ( fixture , projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; defineProject ( fixture , projectPath , root ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; } private void addLibraryDependencies ( String fixtureName , IPath projectPath ) throws Exception { File f = getFile ( "<STR_LIT>" + fixtureName + "<STR_LIT>" ) ; assertTrue ( f . isDirectory ( ) ) ; File [ ] libs = f . listFiles ( ) ; for ( File lib : libs ) { String libpath = lib . getPath ( ) ; libpath = libpath . substring ( libpath . indexOf ( "<STR_LIT>" ) ) ; env . addJar ( projectPath , libpath ) ; } } private File getFile ( String path ) throws Exception { URL jar = Platform . getBundle ( "<STR_LIT>" ) . getEntry ( path ) ; File f = new File ( "<STR_LIT>" + jar . toURI ( ) . getPath ( ) ) ; return f ; } private int defineProject ( String testfixtureName , IPath projectPath , IPath root ) throws Exception { ZipFile zf = new ZipFile ( getFile ( "<STR_LIT>" + testfixtureName + "<STR_LIT>" ) ) ; int count = <NUM_LIT:0> ; Enumeration < ? extends ZipEntry > entries = zf . entries ( ) ; while ( entries . hasMoreElements ( ) ) { ZipEntry zipEntry = entries . nextElement ( ) ; String n = zipEntry . getName ( ) ; if ( ! ( n . endsWith ( "<STR_LIT>" ) || n . endsWith ( "<STR_LIT>" ) ) ) { continue ; } count ++ ; BufferedReader input = new BufferedReader ( new InputStreamReader ( zf . getInputStream ( zipEntry ) ) ) ; StringBuilder contents = new StringBuilder ( ) ; try { String line = null ; while ( ( line = input . readLine ( ) ) != null ) { contents . append ( line ) ; contents . append ( System . getProperty ( "<STR_LIT>" ) ) ; } } finally { input . close ( ) ; } int idx = n . lastIndexOf ( "<STR_LIT:/>" ) ; String pn = n . substring ( <NUM_LIT:0> , idx ) ; n = n . substring ( idx + <NUM_LIT:1> ) ; boolean isGroovy = n . endsWith ( "<STR_LIT>" ) ; n = n . substring ( <NUM_LIT:0> , n . indexOf ( "<STR_LIT:.>" ) ) ; if ( isGroovy ) { env . addGroovyClass ( root , pn , n , contents . toString ( ) ) ; } else { env . addClass ( root , pn , n , contents . toString ( ) ) ; } } zf . close ( ) ; return count ; } public List < String > loadFileAsList ( URL file ) throws Exception { List < String > lines = new ArrayList < String > ( ) ; BufferedReader input = new BufferedReader ( new InputStreamReader ( file . openStream ( ) ) ) ; try { String line = null ; while ( ( line = input . readLine ( ) ) != null ) { lines . add ( line ) ; } } finally { input . close ( ) ; } return lines ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . builder ; import java . io . File ; import java . util . Hashtable ; import java . util . StringTokenizer ; import junit . framework . Test ; import org . codehaus . groovy . ast . ClassHelper ; import org . codehaus . groovy . ast . ClassNode ; import org . codehaus . groovy . ast . FieldNode ; import org . codehaus . groovy . ast . PropertyNode ; import org . codehaus . groovy . ast . expr . ConstructorCallExpression ; import org . codehaus . groovy . ast . expr . Expression ; import org . codehaus . groovy . ast . stmt . ReturnStatement ; import org . codehaus . jdt . groovy . internal . compiler . ast . JDTResolver ; import org . codehaus . jdt . groovy . model . GroovyCompilationUnit ; import org . codehaus . jdt . groovy . model . ModuleNodeMapper . ModuleNodeInfo ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . IMarker ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . core . tests . builder . Problem ; import org . eclipse . jdt . core . tests . util . GroovyUtils ; import org . eclipse . jdt . core . tests . util . Util ; import org . eclipse . jdt . core . util . CompilerUtils ; import org . eclipse . jdt . groovy . search . VariableScope ; import org . eclipse . jdt . internal . core . builder . AbstractImageBuilder ; public class BasicGroovyBuildTests extends GroovierBuilderTests { public BasicGroovyBuildTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( BasicGroovyBuildTests . class ) ; } public void testMultiProjectDependenciesAndAstTransformClasspath ( ) throws JavaModelException { IPath projectAPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectAPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectAPath ) ; env . removePackageFragmentRoot ( projectAPath , "<STR_LIT>" ) ; IPath rootA = env . addPackageFragmentRoot ( projectAPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectAPath , "<STR_LIT>" ) ; env . addClass ( rootA , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath projectBPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectBPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectBPath ) ; env . removePackageFragmentRoot ( projectBPath , "<STR_LIT>" ) ; IPath rootB = env . addPackageFragmentRoot ( projectBPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectBPath , "<STR_LIT>" ) ; env . addClass ( rootB , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addRequiredProject ( projectBPath , projectAPath , new IPath [ ] { } , new IPath [ ] { } , true ) ; IPath projectCPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectCPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectCPath ) ; env . removePackageFragmentRoot ( projectCPath , "<STR_LIT>" ) ; IPath rootC = env . addPackageFragmentRoot ( projectCPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectCPath , "<STR_LIT>" ) ; env . addClass ( rootC , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addRequiredProject ( projectCPath , projectBPath , new IPath [ ] { } , new IPath [ ] { } , true ) ; IPath projectDPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectDPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectDPath ) ; env . removePackageFragmentRoot ( projectDPath , "<STR_LIT>" ) ; IPath rootD = env . addPackageFragmentRoot ( projectDPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectDPath , "<STR_LIT>" ) ; env . addClass ( rootD , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addRequiredProject ( projectDPath , projectCPath , new IPath [ ] { } , new IPath [ ] { } , true ) ; incrementalBuild ( projectDPath ) ; expectingCompiledClassesV ( "<STR_LIT>" ) ; expectingNoProblems ( ) ; executeClass ( projectDPath , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; String classpathForProjectD = CompilerUtils . calculateClasspath ( env . getJavaProject ( projectDPath ) ) ; StringTokenizer st = new StringTokenizer ( classpathForProjectD , File . pathSeparator ) ; boolean foundAndCheckedA = false ; boolean foundAndCheckedB = false ; boolean foundAndCheckedC = false ; while ( st . hasMoreElements ( ) ) { String pathElement = st . nextToken ( ) ; if ( pathElement . indexOf ( "<STR_LIT>" ) != - <NUM_LIT:1> ) { if ( pathElement . indexOf ( "<STR_LIT>" ) == <NUM_LIT:1> ) { fail ( "<STR_LIT>" + pathElement + "<STR_LIT:]>" ) ; } if ( ! pathElement . endsWith ( "<STR_LIT>" ) ) { fail ( "<STR_LIT>" + pathElement + "<STR_LIT:]>" ) ; } foundAndCheckedA = true ; } if ( pathElement . indexOf ( "<STR_LIT>" ) != - <NUM_LIT:1> ) { System . out . println ( "<STR_LIT>" + pathElement + "<STR_LIT:]>" ) ; if ( pathElement . indexOf ( "<STR_LIT>" ) == <NUM_LIT:1> ) { fail ( "<STR_LIT>" + pathElement + "<STR_LIT:]>" ) ; } if ( ! pathElement . endsWith ( "<STR_LIT>" ) ) { fail ( "<STR_LIT>" + pathElement + "<STR_LIT:]>" ) ; } foundAndCheckedB = true ; } if ( pathElement . indexOf ( "<STR_LIT>" ) != - <NUM_LIT:1> ) { System . out . println ( "<STR_LIT>" + pathElement + "<STR_LIT:]>" ) ; if ( pathElement . indexOf ( "<STR_LIT>" ) == <NUM_LIT:1> ) { fail ( "<STR_LIT>" + pathElement + "<STR_LIT:]>" ) ; } if ( ! pathElement . endsWith ( "<STR_LIT>" ) ) { fail ( "<STR_LIT>" + pathElement + "<STR_LIT:]>" ) ; } foundAndCheckedC = true ; } } if ( ! foundAndCheckedC ) { fail ( "<STR_LIT>" + classpathForProjectD ) ; } if ( ! foundAndCheckedB ) { fail ( "<STR_LIT>" + classpathForProjectD ) ; } if ( ! foundAndCheckedA ) { fail ( "<STR_LIT>" + classpathForProjectD ) ; } } public void testBuildJavaHelloWorld ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" ) ; expectingNoProblems ( ) ; executeClass ( projectPath , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; } public void testNPEAnno_1398 ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:A>" ) ; expectingNoProblems ( ) ; IPath pathToSecond = env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; if ( GroovyUtils . GROOVY_LEVEL < <NUM_LIT> ) { Problem [ ] probs = env . getProblemsFor ( pathToSecond ) ; boolean p1found = false ; boolean p2found = false ; for ( int i = <NUM_LIT:0> ; i < probs . length ; i ++ ) { if ( probs [ i ] . getMessage ( ) . equals ( "<STR_LIT>" ) ) { p1found = true ; } if ( probs [ i ] . getMessage ( ) . startsWith ( "<STR_LIT>" ) ) { p2found = true ; } } if ( ! p1found ) { printProblemsFor ( pathToSecond ) ; fail ( "<STR_LIT>" ) ; } if ( ! p2found ) { printProblemsFor ( pathToSecond ) ; fail ( "<STR_LIT>" ) ; } } else { expectingNoProblems ( ) ; expectingCompiledClassesV ( "<STR_LIT:A>" ) ; } } public void testInners_983 ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; expectingNoProblems ( ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; expectingCompiledClassesV ( "<STR_LIT>" ) ; } public void testCompileStatic ( ) throws Exception { if ( GroovyUtils . GROOVY_LEVEL < <NUM_LIT:20> ) { return ; } IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" ) ; expectingNoProblems ( ) ; } public void testCompileStatic2 ( ) throws Exception { if ( GroovyUtils . GROOVY_LEVEL < <NUM_LIT:20> ) { return ; } IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT:A>" ) ; expectingNoProblems ( ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT:B>" , "<STR_LIT>" ) ; expectingNoProblems ( ) ; } public void testCompileStatic3 ( ) throws Exception { if ( GroovyUtils . GROOVY_LEVEL < <NUM_LIT:20> ) { return ; } IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; expectingCompiledClassesV ( "<STR_LIT>" ) ; } public void test1167 ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; expectingNoProblems ( ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; expectingCompiledClassesV ( "<STR_LIT>" , "<STR_LIT>" ) ; } public void testTypeDuplication_GRE796_1 ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; IPath root2 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath pathToSecond = env . addGroovyClass ( root2 , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; Problem [ ] probs = env . getProblemsFor ( pathToSecond ) ; boolean p1found = false ; boolean p2found = false ; for ( int i = <NUM_LIT:0> ; i < probs . length ; i ++ ) { if ( probs [ i ] . getMessage ( ) . equals ( "<STR_LIT>" ) ) { p1found = true ; } if ( probs [ i ] . getMessage ( ) . startsWith ( "<STR_LIT>" ) ) { p2found = true ; } } if ( ! p1found ) { printProblemsFor ( pathToSecond ) ; fail ( "<STR_LIT>" ) ; } if ( ! p2found ) { printProblemsFor ( pathToSecond ) ; fail ( "<STR_LIT>" ) ; } } public void testTypeDuplication_GRE796_2 ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; IPath root2 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath pathToSecond = env . addGroovyClass ( root2 , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; Problem [ ] probs = env . getProblemsFor ( pathToSecond ) ; boolean p1found = false ; boolean p2found = false ; for ( int i = <NUM_LIT:0> ; i < probs . length ; i ++ ) { if ( probs [ i ] . getMessage ( ) . equals ( "<STR_LIT>" ) ) { p1found = true ; } if ( probs [ i ] . getMessage ( ) . startsWith ( "<STR_LIT>" ) ) { p2found = true ; } } if ( ! p1found ) { printProblemsFor ( pathToSecond ) ; fail ( "<STR_LIT>" ) ; } if ( ! p2found ) { printProblemsFor ( pathToSecond ) ; fail ( "<STR_LIT>" ) ; } } public void testClashingPackageAndType_1214 ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; env . addJar ( projectPath , "<STR_LIT>" ) ; env . addJar ( projectPath , "<STR_LIT>" ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath cuPath = env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingSpecificProblemFor ( cuPath , new Problem ( "<STR_LIT>" , "<STR_LIT>" , cuPath , <NUM_LIT:31> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_WARNING ) ) ; expectingCompiledClassesV ( "<STR_LIT>" , "<STR_LIT>" ) ; executeClass ( projectPath , "<STR_LIT>" , "<STR_LIT:abc>" , null ) ; } public void testSlowAnotherAttempt_GRE870 ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" ) ; } public void testSlow_GRE870 ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:n>" + "<STR_LIT>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" ) ; } public void testReallySlow_GRE870 ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" ) ; } public void testClosureBasics ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; expectingNoProblems ( ) ; executeClass ( projectPath , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; } public void testPackageNames_GRE342_1 ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath path = env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingOnlySpecificProblemFor ( path , new Problem ( "<STR_LIT>" , "<STR_LIT>" , path , <NUM_LIT:8> , <NUM_LIT:9> , <NUM_LIT> , IMarker . SEVERITY_ERROR ) ) ; } public void testPackageNames_GRE342_2 ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath path = env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingOnlySpecificProblemFor ( path , new Problem ( "<STR_LIT>" , "<STR_LIT>" , path , <NUM_LIT:8> , <NUM_LIT:15> , <NUM_LIT> , IMarker . SEVERITY_ERROR ) ) ; } public void testPackageNames_GRE342_3 ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; executeClass ( projectPath , "<STR_LIT:X>" , "<STR_LIT:abc>" , "<STR_LIT>" ) ; } public void testClosureIncremental ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; expectingNoProblems ( ) ; executeClass ( projectPath , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" , "<STR_LIT>" ) ; expectingNoProblems ( ) ; executeClass ( projectPath , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" , "<STR_LIT>" ) ; expectingNoProblems ( ) ; executeClass ( projectPath , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; expectingNoProblems ( ) ; executeClass ( projectPath , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; } public void testSpock_GRE558 ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; env . addJar ( projectPath , "<STR_LIT>" ) ; env . addJar ( projectPath , "<STR_LIT>" ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; expectingCompiledClassesV ( "<STR_LIT>" ) ; executeClass ( projectPath , "<STR_LIT>" , "<STR_LIT:success>" , null ) ; } public void testSpock_GRE605_1 ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; env . addJar ( projectPath , "<STR_LIT>" ) ; env . addJar ( projectPath , "<STR_LIT>" ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; expectingCompiledClassesV ( "<STR_LIT>" , "<STR_LIT>" ) ; IPath workspacePath = env . getWorkspaceRootPath ( ) ; File f = new File ( workspacePath . append ( env . getOutputLocation ( projectPath ) ) . toOSString ( ) , "<STR_LIT>" ) ; long filesize = f . length ( ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; expectingCompiledClassesV ( "<STR_LIT>" , "<STR_LIT>" ) ; long filesizeNow = f . length ( ) ; assertEquals ( filesize , filesizeNow ) ; } public void testSpock_GRE605_2 ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; env . addJar ( projectPath , "<STR_LIT>" ) ; env . addJar ( projectPath , "<STR_LIT>" ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; expectingCompiledClassesV ( "<STR_LIT>" , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; expectingCompiledClassesV ( "<STR_LIT>" , "<STR_LIT>" ) ; } public void testBuildGroovyHelloWorld ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" ) ; expectingNoProblems ( ) ; executeClass ( projectPath , "<STR_LIT>" , "<STR_LIT>" , null ) ; } public void testBuildGroovyHelloWorld2 ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" ) ; expectingNoProblems ( ) ; executeClass ( projectPath , "<STR_LIT>" , "<STR_LIT>" , null ) ; } public void testGenericMethods ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; } public void testPropertyAccessorLocationChecks ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" ) ; expectingNoProblems ( ) ; executeClass ( projectPath , "<STR_LIT>" , "<STR_LIT>" , null ) ; } public void testBuildGroovy2 ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" ) ; expectingNoProblems ( ) ; } public void testLargeProjects_GRE1037 ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; int max = AbstractImageBuilder . MAX_AT_ONCE ; try { AbstractImageBuilder . MAX_AT_ONCE = <NUM_LIT:10> ; for ( int i = <NUM_LIT:1> ; i < <NUM_LIT:10> ; i ++ ) { env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" + i , "<STR_LIT>" + "<STR_LIT>" + i + "<STR_LIT>" + "<STR_LIT>" ) ; } env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; executeClass ( projectPath , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; } finally { AbstractImageBuilder . MAX_AT_ONCE = max ; } } public void testIncrementalCompilationTheBasics ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" , "<STR_LIT>" ) ; expectingNoProblems ( ) ; executeClass ( projectPath , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" ) ; expectingNoProblems ( ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" , "<STR_LIT>" ) ; expectingNoProblems ( ) ; } public void testIncrementalGenericsAndBinaryTypeBindings_GRE566 ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; expectingNoProblems ( ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; expectingCompiledClassesV ( "<STR_LIT>" ) ; } public void testIncrementalCompilationTheBasics2_changingJavaDependedUponByGroovy ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" , "<STR_LIT>" ) ; expectingNoProblems ( ) ; executeClass ( projectPath , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" ) ; expectingNoProblems ( ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" , "<STR_LIT>" ) ; expectingNoProblems ( ) ; executeClass ( projectPath , "<STR_LIT>" , "<STR_LIT:abc>" , "<STR_LIT>" ) ; } public void testInnerClasses_GRE339 ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; expectingNoProblems ( ) ; executeClass ( projectPath , "<STR_LIT>" , "<STR_LIT:value>" , "<STR_LIT>" ) ; env . addGroovyClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClassesV ( "<STR_LIT>" ) ; expectingNoProblems ( ) ; executeClass ( projectPath , "<STR_LIT>" , "<STR_LIT:value>" , null ) ; } public void testSimpleTaskMarkerInSingleLineComment ( ) throws Exception { Hashtable options = JavaCore . getOptions ( ) ; Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . COMPILER_TASK_TAGS , "<STR_LIT>" ) ; JavaCore . setOptions ( newOptions ) ; IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath pathToA = env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; Problem [ ] rootProblems = env . getProblemsFor ( pathToA ) ; for ( int i = <NUM_LIT:0> ; i < rootProblems . length ; i ++ ) { System . out . println ( i + "<STR_LIT:U+0020U+0020>" + rootProblems [ i ] + "<STR_LIT:[>" + rootProblems [ i ] . getMessage ( ) + "<STR_LIT:]>" + rootProblems [ i ] . getEnd ( ) ) ; } expectingOnlySpecificProblemFor ( pathToA , new Problem ( "<STR_LIT:A>" , toTask ( "<STR_LIT>" , "<STR_LIT>" ) , pathToA , <NUM_LIT:24> , <NUM_LIT> , - <NUM_LIT:1> , IMarker . SEVERITY_ERROR ) ) ; JavaCore . setOptions ( options ) ; } private String toTask ( String tasktag , String message ) { return tasktag + message ; } public void testSimpleTaskMarkerInSingleLineCommentEndOfClass ( ) throws Exception { Hashtable options = JavaCore . getOptions ( ) ; Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . COMPILER_TASK_TAGS , "<STR_LIT>" ) ; JavaCore . setOptions ( newOptions ) ; IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath pathToA = env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; Problem [ ] rootProblems = env . getProblemsFor ( pathToA ) ; expectingOnlySpecificProblemFor ( pathToA , new Problem ( "<STR_LIT:A>" , toTask ( "<STR_LIT>" , "<STR_LIT:two>" ) , pathToA , <NUM_LIT> , <NUM_LIT> , - <NUM_LIT:1> , IMarker . SEVERITY_ERROR ) ) ; JavaCore . setOptions ( options ) ; } public void testSimpleTaskMarkerInSingleLineCommentEndOfClassCaseInsensitive ( ) throws Exception { Hashtable options = JavaCore . getOptions ( ) ; Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . COMPILER_TASK_TAGS , "<STR_LIT>" ) ; newOptions . put ( JavaCore . COMPILER_TASK_CASE_SENSITIVE , JavaCore . DISABLED ) ; JavaCore . setOptions ( newOptions ) ; IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath pathToA = env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; Problem [ ] rootProblems = env . getProblemsFor ( pathToA ) ; for ( int i = <NUM_LIT:0> ; i < rootProblems . length ; i ++ ) { System . out . println ( i + "<STR_LIT:U+0020U+0020>" + rootProblems [ i ] + "<STR_LIT:[>" + rootProblems [ i ] . getMessage ( ) + "<STR_LIT:]>" + rootProblems [ i ] . getEnd ( ) ) ; } expectingOnlySpecificProblemFor ( pathToA , new Problem ( "<STR_LIT:A>" , toTask ( "<STR_LIT>" , "<STR_LIT>" ) , pathToA , <NUM_LIT:24> , <NUM_LIT> , - <NUM_LIT:1> , IMarker . SEVERITY_ERROR ) ) ; JavaCore . setOptions ( options ) ; } public void testTaskMarkerInMultiLineCommentButOnOneLine ( ) throws Exception { Hashtable options = JavaCore . getOptions ( ) ; Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . COMPILER_TASK_TAGS , "<STR_LIT>" ) ; JavaCore . setOptions ( newOptions ) ; IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath pathToA = env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; Problem [ ] rootProblems = env . getProblemsFor ( pathToA ) ; for ( int i = <NUM_LIT:0> ; i < rootProblems . length ; i ++ ) { System . out . println ( i + "<STR_LIT:U+0020U+0020>" + rootProblems [ i ] + "<STR_LIT:[>" + rootProblems [ i ] . getMessage ( ) + "<STR_LIT:]>" ) ; } expectingOnlySpecificProblemFor ( pathToA , new Problem ( "<STR_LIT:A>" , toTask ( "<STR_LIT>" , "<STR_LIT>" ) , pathToA , <NUM_LIT:16> , <NUM_LIT> , - <NUM_LIT:1> , IMarker . SEVERITY_ERROR ) ) ; JavaCore . setOptions ( options ) ; } public void testTaskMarkerInMultiLineButNoText ( ) throws Exception { Hashtable options = JavaCore . getOptions ( ) ; Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . COMPILER_TASK_TAGS , "<STR_LIT>" ) ; JavaCore . setOptions ( newOptions ) ; IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath pathToA = env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; Problem [ ] rootProblems = env . getProblemsFor ( pathToA ) ; for ( int i = <NUM_LIT:0> ; i < rootProblems . length ; i ++ ) { System . out . println ( i + "<STR_LIT:U+0020U+0020>" + rootProblems [ i ] + "<STR_LIT>" + rootProblems [ i ] . getMessage ( ) + "<STR_LIT:]>" ) ; } expectingOnlySpecificProblemFor ( pathToA , new Problem ( "<STR_LIT:A>" , toTask ( "<STR_LIT>" , "<STR_LIT>" ) , pathToA , <NUM_LIT:16> , <NUM_LIT:20> , - <NUM_LIT:1> , IMarker . SEVERITY_ERROR ) ) ; JavaCore . setOptions ( options ) ; } public void testTaskMarkerInMultiLineOutsideClass ( ) throws Exception { Hashtable options = JavaCore . getOptions ( ) ; Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . COMPILER_TASK_TAGS , "<STR_LIT>" ) ; JavaCore . setOptions ( newOptions ) ; IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath pathToA = env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; Problem [ ] rootProblems = env . getProblemsFor ( pathToA ) ; for ( int i = <NUM_LIT:0> ; i < rootProblems . length ; i ++ ) { System . out . println ( i + "<STR_LIT:U+0020U+0020>" + rootProblems [ i ] + "<STR_LIT>" + rootProblems [ i ] . getMessage ( ) + "<STR_LIT:]>" ) ; } expectingOnlySpecificProblemFor ( pathToA , new Problem ( "<STR_LIT:A>" , toTask ( "<STR_LIT>" , "<STR_LIT>" ) , pathToA , <NUM_LIT:20> , <NUM_LIT> , - <NUM_LIT:1> , IMarker . SEVERITY_ERROR ) ) ; JavaCore . setOptions ( options ) ; } public void testTaskMarkerInMultiLineInsideClass ( ) throws Exception { Hashtable options = JavaCore . getOptions ( ) ; Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . COMPILER_TASK_TAGS , "<STR_LIT>" ) ; JavaCore . setOptions ( newOptions ) ; IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath pathToA = env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; Problem [ ] rootProblems = env . getProblemsFor ( pathToA ) ; for ( int i = <NUM_LIT:0> ; i < rootProblems . length ; i ++ ) { System . out . println ( i + "<STR_LIT:U+0020U+0020>" + rootProblems [ i ] ) ; } expectingOnlySpecificProblemFor ( pathToA , new Problem ( "<STR_LIT:A>" , toTask ( "<STR_LIT>" , "<STR_LIT>" ) , pathToA , <NUM_LIT> , <NUM_LIT> , - <NUM_LIT:1> , IMarker . SEVERITY_ERROR ) ) ; JavaCore . setOptions ( options ) ; } public void testTaskMarkerMixedPriorities ( ) throws Exception { Hashtable options = JavaCore . getOptions ( ) ; Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . COMPILER_TASK_TAGS , "<STR_LIT>" ) ; newOptions . put ( JavaCore . COMPILER_TASK_PRIORITIES , "<STR_LIT>" ) ; JavaCore . setOptions ( newOptions ) ; IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath pathToA = env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; IMarker [ ] markers = env . getTaskMarkersFor ( pathToA ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:3> , markers . length ) ; try { IMarker marker = markers [ <NUM_LIT:0> ] ; Object priority = marker . getAttribute ( IMarker . PRIORITY ) ; String message = ( String ) marker . getAttribute ( IMarker . MESSAGE ) ; assertTrue ( "<STR_LIT>" , message . startsWith ( "<STR_LIT>" ) ) ; assertNotNull ( "<STR_LIT>" , priority ) ; assertEquals ( "<STR_LIT>" , new Integer ( IMarker . PRIORITY_NORMAL ) , priority ) ; marker = markers [ <NUM_LIT:1> ] ; priority = marker . getAttribute ( IMarker . PRIORITY ) ; message = ( String ) marker . getAttribute ( IMarker . MESSAGE ) ; assertTrue ( "<STR_LIT>" , message . startsWith ( "<STR_LIT>" ) ) ; assertNotNull ( "<STR_LIT>" , priority ) ; assertEquals ( "<STR_LIT>" , new Integer ( IMarker . PRIORITY_HIGH ) , priority ) ; marker = markers [ <NUM_LIT:2> ] ; priority = marker . getAttribute ( IMarker . PRIORITY ) ; message = ( String ) marker . getAttribute ( IMarker . MESSAGE ) ; assertTrue ( "<STR_LIT>" , message . startsWith ( "<STR_LIT>" ) ) ; assertNotNull ( "<STR_LIT>" , priority ) ; assertEquals ( "<STR_LIT>" , new Integer ( IMarker . PRIORITY_LOW ) , priority ) ; } catch ( CoreException e ) { assertTrue ( false ) ; } JavaCore . setOptions ( options ) ; } public void testTaskMarkerMultipleOnOneLineInSLComment ( ) throws Exception { Hashtable options = JavaCore . getOptions ( ) ; Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . COMPILER_TASK_TAGS , "<STR_LIT>" ) ; newOptions . put ( JavaCore . COMPILER_TASK_PRIORITIES , "<STR_LIT>" ) ; JavaCore . setOptions ( newOptions ) ; IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath pathToA = env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; IMarker [ ] markers = env . getTaskMarkersFor ( pathToA ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:3> , markers . length ) ; try { IMarker marker = markers [ <NUM_LIT:2> ] ; Object priority = marker . getAttribute ( IMarker . PRIORITY ) ; String message = ( String ) marker . getAttribute ( IMarker . MESSAGE ) ; assertEquals ( "<STR_LIT>" , toTask ( "<STR_LIT>" , "<STR_LIT>" ) , message ) ; assertNotNull ( "<STR_LIT>" , priority ) ; assertEquals ( "<STR_LIT>" , new Integer ( IMarker . PRIORITY_NORMAL ) , priority ) ; marker = markers [ <NUM_LIT:1> ] ; priority = marker . getAttribute ( IMarker . PRIORITY ) ; message = ( String ) marker . getAttribute ( IMarker . MESSAGE ) ; assertEquals ( "<STR_LIT>" , toTask ( "<STR_LIT>" , "<STR_LIT>" ) , message ) ; assertNotNull ( "<STR_LIT>" , priority ) ; assertEquals ( "<STR_LIT>" , new Integer ( IMarker . PRIORITY_HIGH ) , priority ) ; marker = markers [ <NUM_LIT:0> ] ; priority = marker . getAttribute ( IMarker . PRIORITY ) ; message = ( String ) marker . getAttribute ( IMarker . MESSAGE ) ; assertEquals ( "<STR_LIT>" , toTask ( "<STR_LIT>" , "<STR_LIT>" ) , message ) ; assertNotNull ( "<STR_LIT>" , priority ) ; assertEquals ( "<STR_LIT>" , new Integer ( IMarker . PRIORITY_NORMAL ) , priority ) ; } catch ( CoreException e ) { assertTrue ( false ) ; } JavaCore . setOptions ( options ) ; } public void testTaskMarkerMultipleOnOneLineInMLComment ( ) throws Exception { Hashtable options = JavaCore . getOptions ( ) ; Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . COMPILER_TASK_TAGS , "<STR_LIT>" ) ; newOptions . put ( JavaCore . COMPILER_TASK_PRIORITIES , "<STR_LIT>" ) ; JavaCore . setOptions ( newOptions ) ; IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath pathToA = env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; IMarker [ ] markers = env . getTaskMarkersFor ( pathToA ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:3> , markers . length ) ; try { IMarker marker = markers [ <NUM_LIT:2> ] ; Object priority = marker . getAttribute ( IMarker . PRIORITY ) ; String message = ( String ) marker . getAttribute ( IMarker . MESSAGE ) ; assertEquals ( "<STR_LIT>" , toTask ( "<STR_LIT>" , "<STR_LIT>" ) , message ) ; assertNotNull ( "<STR_LIT>" , priority ) ; assertEquals ( "<STR_LIT>" , new Integer ( IMarker . PRIORITY_NORMAL ) , priority ) ; marker = markers [ <NUM_LIT:1> ] ; priority = marker . getAttribute ( IMarker . PRIORITY ) ; message = ( String ) marker . getAttribute ( IMarker . MESSAGE ) ; assertEquals ( "<STR_LIT>" , toTask ( "<STR_LIT>" , "<STR_LIT>" ) , message ) ; assertNotNull ( "<STR_LIT>" , priority ) ; assertEquals ( "<STR_LIT>" , new Integer ( IMarker . PRIORITY_HIGH ) , priority ) ; marker = markers [ <NUM_LIT:0> ] ; priority = marker . getAttribute ( IMarker . PRIORITY ) ; message = ( String ) marker . getAttribute ( IMarker . MESSAGE ) ; assertEquals ( "<STR_LIT>" , toTask ( "<STR_LIT>" , "<STR_LIT>" ) , message ) ; assertNotNull ( "<STR_LIT>" , priority ) ; assertEquals ( "<STR_LIT>" , new Integer ( IMarker . PRIORITY_NORMAL ) , priority ) ; } catch ( CoreException e ) { assertTrue ( false ) ; } JavaCore . setOptions ( options ) ; } @ SuppressWarnings ( "<STR_LIT:rawtypes>" ) public void testTaskMarkerSharedDescription ( ) throws Exception { Hashtable options = JavaCore . getOptions ( ) ; Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . COMPILER_TASK_TAGS , "<STR_LIT>" ) ; newOptions . put ( JavaCore . COMPILER_TASK_PRIORITIES , "<STR_LIT>" ) ; JavaCore . setOptions ( newOptions ) ; IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath pathToA = env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; IMarker [ ] markers = env . getTaskMarkersFor ( pathToA ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:2> , markers . length ) ; try { IMarker marker = markers [ <NUM_LIT:1> ] ; Object priority = marker . getAttribute ( IMarker . PRIORITY ) ; String message = ( String ) marker . getAttribute ( IMarker . MESSAGE ) ; assertEquals ( "<STR_LIT>" , toTask ( "<STR_LIT>" , "<STR_LIT>" ) , message ) ; assertNotNull ( "<STR_LIT>" , priority ) ; assertEquals ( "<STR_LIT>" , new Integer ( IMarker . PRIORITY_NORMAL ) , priority ) ; marker = markers [ <NUM_LIT:0> ] ; priority = marker . getAttribute ( IMarker . PRIORITY ) ; message = ( String ) marker . getAttribute ( IMarker . MESSAGE ) ; assertEquals ( "<STR_LIT>" , toTask ( "<STR_LIT>" , "<STR_LIT>" ) , message ) ; assertNotNull ( "<STR_LIT>" , priority ) ; assertEquals ( "<STR_LIT>" , new Integer ( IMarker . PRIORITY_NORMAL ) , priority ) ; } catch ( CoreException e ) { assertTrue ( false ) ; } JavaCore . setOptions ( options ) ; } public void testCopyGroovyResourceNonGroovyProject_GRECLIPSE653 ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removeGroovyNature ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; IPath output = env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath pathToA = env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( projectPath ) ; IPath pathToABin = output . append ( pathToA . removeFirstSegments ( pathToA . segmentCount ( ) - <NUM_LIT:2> ) ) ; assertTrue ( "<STR_LIT>" + pathToABin . toPortableString ( ) , env . getWorkspace ( ) . getRoot ( ) . getFile ( pathToABin ) . exists ( ) ) ; IPath pathToB = env . addGroovyClass ( root , "<STR_LIT:p>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; IPath pathToBBin = output . append ( pathToB . removeFirstSegments ( pathToB . segmentCount ( ) - <NUM_LIT:2> ) ) ; assertTrue ( "<STR_LIT>" + pathToBBin . toPortableString ( ) , env . getWorkspace ( ) . getRoot ( ) . getFile ( pathToBBin ) . exists ( ) ) ; IFile bFile = env . getWorkspace ( ) . getRoot ( ) . getFile ( pathToB ) ; bFile . delete ( true , null ) ; incrementalBuild ( projectPath ) ; assertFalse ( "<STR_LIT>" + pathToBBin . toPortableString ( ) , env . getWorkspace ( ) . getRoot ( ) . getFile ( pathToBBin ) . exists ( ) ) ; } public void testCopyResourceNonGroovyProject_GRECLIPSE653 ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removeGroovyNature ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; IPath output = env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath pathToA = env . addFile ( root , "<STR_LIT>" , "<STR_LIT:A>" ) ; fullBuild ( projectPath ) ; IPath pathToABin = output . append ( pathToA . removeFirstSegments ( pathToA . segmentCount ( ) - <NUM_LIT:1> ) ) ; assertTrue ( "<STR_LIT>" + pathToABin . toPortableString ( ) , env . getWorkspace ( ) . getRoot ( ) . getFile ( pathToABin ) . exists ( ) ) ; IPath pathToB = env . addFile ( root , "<STR_LIT>" , "<STR_LIT:B>" ) ; incrementalBuild ( projectPath ) ; IPath pathToBBin = output . append ( pathToB . removeFirstSegments ( pathToB . segmentCount ( ) - <NUM_LIT:1> ) ) ; assertTrue ( "<STR_LIT>" + pathToBBin . toPortableString ( ) , env . getWorkspace ( ) . getRoot ( ) . getFile ( pathToBBin ) . exists ( ) ) ; IFile bFile = env . getWorkspace ( ) . getRoot ( ) . getFile ( pathToB ) ; bFile . delete ( true , null ) ; incrementalBuild ( projectPath ) ; assertFalse ( "<STR_LIT>" + pathToBBin . toPortableString ( ) , env . getWorkspace ( ) . getRoot ( ) . getFile ( pathToBBin ) . exists ( ) ) ; } public void testCopyResourceGroovyProject_GRECLIPSE653 ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; env . addGroovyNature ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; IPath output = env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath pathToA = env . addFile ( root , "<STR_LIT>" , "<STR_LIT:A>" ) ; fullBuild ( projectPath ) ; IPath pathToABin = output . append ( pathToA . removeFirstSegments ( pathToA . segmentCount ( ) - <NUM_LIT:1> ) ) ; assertTrue ( "<STR_LIT>" + pathToABin . toPortableString ( ) , env . getWorkspace ( ) . getRoot ( ) . getFile ( pathToABin ) . exists ( ) ) ; IPath pathToB = env . addFile ( root , "<STR_LIT>" , "<STR_LIT:B>" ) ; incrementalBuild ( projectPath ) ; IPath pathToBBin = output . append ( pathToB . removeFirstSegments ( pathToB . segmentCount ( ) - <NUM_LIT:1> ) ) ; assertTrue ( "<STR_LIT>" + pathToBBin . toPortableString ( ) , env . getWorkspace ( ) . getRoot ( ) . getFile ( pathToBBin ) . exists ( ) ) ; IFile bFile = env . getWorkspace ( ) . getRoot ( ) . getFile ( pathToB ) ; bFile . delete ( true , null ) ; incrementalBuild ( projectPath ) ; assertFalse ( "<STR_LIT>" + pathToBBin . toPortableString ( ) , env . getWorkspace ( ) . getRoot ( ) . getFile ( pathToBBin ) . exists ( ) ) ; } public void testNoDoubleResolve ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; env . addGroovyNature ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( projectPath . append ( "<STR_LIT:src>" ) , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" ) ; GroovyCompilationUnit unit = ( GroovyCompilationUnit ) env . getJavaProject ( "<STR_LIT>" ) . findType ( "<STR_LIT>" ) . getCompilationUnit ( ) ; unit . becomeWorkingCopy ( null ) ; ModuleNodeInfo moduleInfo = unit . getModuleInfo ( true ) ; JDTResolver resolver = moduleInfo . resolver ; assertNotNull ( resolver ) ; resolver . currentClass = moduleInfo . module . getScriptClassDummy ( ) ; ClassNode url = resolver . resolve ( "<STR_LIT>" ) ; assertNotNull ( "<STR_LIT>" , url ) ; assertEquals ( "<STR_LIT>" , "<STR_LIT>" , url . getName ( ) ) ; } public void testFieldInitializerFromOtherFile ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; env . addGroovyNature ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addGroovyClass ( projectPath . append ( "<STR_LIT:src>" ) , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" ) ; env . addGroovyClass ( projectPath . append ( "<STR_LIT:src>" ) , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" ) ; GroovyCompilationUnit unit = ( GroovyCompilationUnit ) env . getJavaProject ( "<STR_LIT>" ) . findType ( "<STR_LIT>" ) . getCompilationUnit ( ) ; ClassNode type = ( ( ConstructorCallExpression ) ( ( ReturnStatement ) unit . getModuleNode ( ) . getStatementBlock ( ) . getStatements ( ) . get ( <NUM_LIT:0> ) ) . getExpression ( ) ) . getType ( ) ; Expression initialExpression = type . getField ( "<STR_LIT:x>" ) . getInitialExpression ( ) ; assertNotNull ( initialExpression ) ; assertEquals ( "<STR_LIT>" , VariableScope . INTEGER_CLASS_NODE , ClassHelper . getWrapper ( initialExpression . getType ( ) ) ) ; assertEquals ( "<STR_LIT>" , "<STR_LIT>" , initialExpression . getText ( ) ) ; int declCount = <NUM_LIT:0> ; for ( FieldNode field : type . getFields ( ) ) { if ( field . getName ( ) . equals ( "<STR_LIT:x>" ) ) declCount ++ ; } assertEquals ( "<STR_LIT>" , <NUM_LIT:1> , declCount ) ; declCount = <NUM_LIT:0> ; for ( PropertyNode prop : type . getProperties ( ) ) { if ( prop . getName ( ) . equals ( "<STR_LIT:x>" ) ) declCount ++ ; } assertEquals ( "<STR_LIT>" , <NUM_LIT:1> , declCount ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . builder ; import org . eclipse . jdt . core . tests . builder . BuilderTests ; public class GroovierBuilderTests extends BuilderTests { public GroovierBuilderTests ( String name ) { super ( name ) ; } protected void expectingCompiledClassesV ( String ... compiledClasses ) { expectingCompiledClasses ( compiledClasses ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . builder ; import java . io . File ; import java . io . FileOutputStream ; import java . io . IOException ; import java . net . URL ; import org . eclipse . core . resources . IProject ; import org . eclipse . core . resources . IWorkspace ; import org . eclipse . core . resources . IWorkspaceRoot ; import org . eclipse . core . resources . IWorkspaceRunnable ; import org . eclipse . core . resources . ResourcesPlugin ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . FileLocator ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . Platform ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . JavaCore ; public class ProjectUtils { private ProjectUtils ( ) { } public static String getSourceWorkspacePath ( ) { return getPluginDirectoryPath ( ) + java . io . File . separator + "<STR_LIT>" ; } protected static String getTestBundleName ( ) { return "<STR_LIT>" ; } protected static String getPluginDirectoryPath ( ) { try { URL platformURL = Platform . getBundle ( getTestBundleName ( ) ) . getEntry ( "<STR_LIT:/>" ) ; return new File ( FileLocator . toFileURL ( platformURL ) . getFile ( ) ) . getAbsolutePath ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return null ; } public static IWorkspace getWorkspace ( ) { return ResourcesPlugin . getWorkspace ( ) ; } public static IWorkspaceRoot getWorkspaceRoot ( ) { return getWorkspace ( ) . getRoot ( ) ; } protected static IJavaProject setUpJavaProject ( final String projectName ) throws CoreException , IOException { return setUpJavaProject ( projectName , "<STR_LIT>" ) ; } protected static IJavaProject setUpJavaProject ( final String projectName , String compliance ) throws CoreException , IOException { String sourceWorkspacePath = getSourceWorkspacePath ( ) ; String targetWorkspacePath = getWorkspaceRoot ( ) . getLocation ( ) . toFile ( ) . getCanonicalPath ( ) ; if ( ! copyDirectory ( new File ( sourceWorkspacePath , projectName ) , new File ( targetWorkspacePath , projectName ) ) ) { return null ; } final IProject project = getWorkspaceRoot ( ) . getProject ( projectName ) ; if ( ! project . exists ( ) ) { IWorkspaceRunnable populate = new IWorkspaceRunnable ( ) { public void run ( IProgressMonitor monitor ) throws CoreException { project . create ( null ) ; } } ; getWorkspace ( ) . run ( populate , null ) ; } project . open ( null ) ; IJavaProject javaProject = JavaCore . create ( project ) ; return javaProject ; } public static IProject createPredefinedProject ( final String projectName ) throws CoreException , RuntimeException { IJavaProject jp ; try { jp = setUpJavaProject ( projectName ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } if ( jp == null ) { return null ; } try { jp . setOption ( "<STR_LIT>" , "<STR_LIT>" ) ; } catch ( NullPointerException npe ) { } return jp . getProject ( ) ; } protected static boolean copyDirectory ( File source , File target ) throws IOException { if ( ! source . exists ( ) ) { return false ; } if ( ! target . exists ( ) ) { target . mkdirs ( ) ; } File [ ] files = source . listFiles ( ) ; if ( files == null ) return true ; for ( int i = <NUM_LIT:0> ; i < files . length ; i ++ ) { File sourceChild = files [ i ] ; String name = sourceChild . getName ( ) ; if ( name . equals ( "<STR_LIT>" ) ) continue ; File targetChild = new File ( target , name ) ; if ( sourceChild . isDirectory ( ) ) { copyDirectory ( sourceChild , targetChild ) ; } else { copy ( sourceChild , targetChild ) ; } } return true ; } public static void copy ( File src , File dest ) throws IOException { byte [ ] srcBytes = read ( src ) ; if ( convertToIndependantLineDelimiter ( src ) ) { String contents = new String ( srcBytes ) ; contents = convertToIndependantLineDelimiter ( contents ) ; srcBytes = contents . getBytes ( ) ; } FileOutputStream out = new FileOutputStream ( dest ) ; out . write ( srcBytes ) ; out . close ( ) ; } public static byte [ ] read ( java . io . File file ) throws java . io . IOException { int fileLength ; byte [ ] fileBytes = new byte [ fileLength = ( int ) file . length ( ) ] ; java . io . FileInputStream stream = new java . io . FileInputStream ( file ) ; int bytesRead = <NUM_LIT:0> ; int lastReadSize = <NUM_LIT:0> ; while ( ( lastReadSize != - <NUM_LIT:1> ) && ( bytesRead != fileLength ) ) { lastReadSize = stream . read ( fileBytes , bytesRead , fileLength - bytesRead ) ; bytesRead += lastReadSize ; } stream . close ( ) ; return fileBytes ; } public static boolean convertToIndependantLineDelimiter ( File file ) { return SOURCE_FILTER . accept ( file . getName ( ) ) ; } public static final FilenameFilter SOURCE_FILTER = new FilenameFilter ( ) { public boolean accept ( String name ) { return ( name . endsWith ( "<STR_LIT>" ) || name . endsWith ( "<STR_LIT>" ) ) ; } } ; public static interface FilenameFilter { public boolean accept ( String name ) ; } public static String convertToIndependantLineDelimiter ( String source ) { if ( source . indexOf ( '<STR_LIT:\n>' ) == - <NUM_LIT:1> && source . indexOf ( '<STR_LIT>' ) == - <NUM_LIT:1> ) return source ; StringBuffer buffer = new StringBuffer ( ) ; for ( int i = <NUM_LIT:0> , length = source . length ( ) ; i < length ; i ++ ) { char car = source . charAt ( i ) ; if ( car == '<STR_LIT>' ) { buffer . append ( '<STR_LIT:\n>' ) ; if ( i < length - <NUM_LIT:1> && source . charAt ( i + <NUM_LIT:1> ) == '<STR_LIT:\n>' ) { i ++ ; } } else { buffer . append ( car ) ; } } return buffer . toString ( ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . search ; import junit . framework . Test ; import org . eclipse . jdt . core . JavaModelException ; public class LocalVariableReferenceSearchTests extends AbstractGroovySearchTest { private static final String XXX = "<STR_LIT>" ; public LocalVariableReferenceSearchTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( LocalVariableReferenceSearchTests . class ) ; } public void testvarReference1 ( ) throws Exception { String contents = "<STR_LIT>" ; int nameStart = contents . indexOf ( XXX ) ; doTestForReferencesInScript ( contents , createRegions ( nameStart ) ) ; } public void testvarReference2 ( ) throws Exception { String contents = "<STR_LIT>" ; int nameStart = contents . indexOf ( XXX ) ; int nameStart2 = contents . indexOf ( XXX , nameStart + <NUM_LIT:1> ) ; doTestForReferencesInScript ( contents , createRegions ( nameStart , nameStart2 ) ) ; } public void testvarReference3 ( ) throws Exception { String contents = "<STR_LIT>" ; int nameStart = contents . indexOf ( XXX , contents . indexOf ( '<CHAR_LIT:(>' ) ) ; int nameStart2 = contents . indexOf ( XXX , nameStart + <NUM_LIT:1> ) ; int nameStart3 = contents . indexOf ( XXX , nameStart2 + <NUM_LIT:1> ) ; doTestForReferences ( contents , <NUM_LIT:4> , createRegions ( nameStart , nameStart2 , nameStart3 ) ) ; } public void testvarReference4 ( ) throws Exception { String contents = "<STR_LIT>" ; int nameStart = contents . indexOf ( XXX , contents . indexOf ( '<CHAR_LIT:(>' ) ) ; int nameStart2 = contents . indexOf ( XXX , nameStart + <NUM_LIT:1> ) ; int nameStart3 = contents . indexOf ( XXX , nameStart2 + <NUM_LIT:1> ) ; doTestForReferences ( contents , <NUM_LIT:4> , createRegions ( nameStart , nameStart2 , nameStart3 ) ) ; } public void testvarReference5 ( ) throws Exception { String contents = "<STR_LIT>" ; int nameStart = contents . indexOf ( XXX , contents . indexOf ( '<CHAR_LIT:(>' ) ) ; int nameStart2 = contents . indexOf ( XXX , nameStart + <NUM_LIT:1> ) ; int nameStart3 = contents . indexOf ( XXX , nameStart2 + <NUM_LIT:1> ) ; doTestForReferences ( contents , <NUM_LIT:4> , createRegions ( nameStart , nameStart2 , nameStart3 ) ) ; } public void testvarReference6 ( ) throws Exception { String contents = "<STR_LIT>" ; int nameStart = contents . indexOf ( XXX , contents . indexOf ( '<CHAR_LIT>' ) ) ; int nameStart2 = contents . indexOf ( XXX , nameStart + <NUM_LIT:1> ) ; int nameStart3 = contents . indexOf ( XXX , nameStart2 + <NUM_LIT:1> ) ; doTestForReferencesInScript ( contents , createRegions ( nameStart , nameStart2 , nameStart3 ) ) ; } public void testvarReference7 ( ) throws Exception { String contents = "<STR_LIT>" ; int nameStart = contents . indexOf ( XXX , contents . indexOf ( '<CHAR_LIT>' ) ) ; int nameStart2 = contents . indexOf ( XXX , nameStart + <NUM_LIT:1> ) ; int nameStart3 = contents . indexOf ( XXX , nameStart2 + <NUM_LIT:1> ) ; doTestForReferencesInScript ( contents , createRegions ( nameStart , nameStart2 , nameStart3 ) ) ; } public void testvarReference8 ( ) throws Exception { String contents = "<STR_LIT>" ; int nameStart = contents . indexOf ( XXX , contents . indexOf ( '<CHAR_LIT:(>' ) ) ; int nameStart2 = contents . indexOf ( XXX , nameStart + <NUM_LIT:1> ) ; doTestForReferencesInScript ( contents , createRegions ( nameStart , nameStart2 ) ) ; } public void testvarReference9 ( ) throws Exception { String contents = "<STR_LIT>" ; int nameStart = contents . indexOf ( XXX , contents . indexOf ( '<CHAR_LIT:}>' ) ) ; int nameStart2 = contents . indexOf ( XXX , nameStart + <NUM_LIT:1> ) ; doTestForReferences ( contents , <NUM_LIT:5> , createRegions ( nameStart , nameStart2 ) ) ; } public void testvarReference10 ( ) throws Exception { String contents = "<STR_LIT>" ; int nameStart = contents . indexOf ( XXX , contents . indexOf ( '<CHAR_LIT:(>' ) ) ; int nameStart2 = contents . indexOf ( XXX , nameStart + <NUM_LIT:1> ) ; doTestForReferences ( contents , <NUM_LIT:1> , createRegions ( nameStart , nameStart2 ) ) ; } public void testvarReferenceInGString1 ( ) throws Exception { String contents = "<STR_LIT>" ; int nameStart = contents . indexOf ( XXX ) ; int nameStart2 = contents . indexOf ( XXX , nameStart + <NUM_LIT:1> ) ; doTestForReferences ( contents , <NUM_LIT:3> , createRegions ( nameStart , nameStart2 ) ) ; } public void testvarReferenceInGString2 ( ) throws Exception { String contents = "<STR_LIT>" ; int nameStart = contents . indexOf ( XXX ) ; int nameStart2 = contents . indexOf ( XXX , nameStart + <NUM_LIT:1> ) ; doTestForReferences ( contents , <NUM_LIT:3> , createRegions ( nameStart , nameStart2 ) ) ; } public void testvarReferenceInGString3 ( ) throws Exception { String contents = "<STR_LIT>" ; int nameStart = contents . indexOf ( XXX ) ; int nameStart2 = contents . indexOf ( XXX , nameStart + <NUM_LIT:1> ) ; doTestForReferences ( contents , <NUM_LIT:3> , createRegions ( nameStart , nameStart2 ) ) ; } public void testvarReferenceInGString4 ( ) throws Exception { String contents = "<STR_LIT>" ; int nameStart = contents . indexOf ( XXX ) ; int nameStart2 = contents . indexOf ( XXX , nameStart + <NUM_LIT:1> ) ; doTestForReferences ( contents , <NUM_LIT:3> , createRegions ( nameStart , nameStart2 ) ) ; } public void testvarReferenceInGString5 ( ) throws Exception { String contents = "<STR_LIT>" ; int nameStart = contents . indexOf ( XXX ) ; int nameStart2 = contents . indexOf ( XXX , nameStart + <NUM_LIT:1> ) ; doTestForReferences ( contents , <NUM_LIT:3> , createRegions ( nameStart , nameStart2 ) ) ; } private MatchRegion [ ] createRegions ( int ... nameStarts ) { MatchRegion [ ] regions = new MatchRegion [ nameStarts . length ] ; for ( int i = <NUM_LIT:0> ; i < nameStarts . length ; i ++ ) { regions [ i ] = new MatchRegion ( nameStarts [ i ] , XXX . length ( ) ) ; } return regions ; } private void doTestForReferencesInScript ( String contents , MatchRegion [ ] matchLocations ) throws JavaModelException { doTestForVarReferences ( contents , <NUM_LIT:3> , XXX , matchLocations [ <NUM_LIT:0> ] . offset , matchLocations ) ; } private void doTestForReferences ( String contents , int locationInParent , MatchRegion [ ] matchLocations ) throws JavaModelException { doTestForVarReferences ( contents , locationInParent , XXX , matchLocations [ <NUM_LIT:0> ] . offset , matchLocations ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . search ; import java . util . ArrayList ; import java . util . HashSet ; import java . util . List ; import junit . framework . Test ; import org . codehaus . jdt . groovy . model . GroovyCompilationUnit ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . NullProgressMonitor ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . search . IJavaSearchConstants ; import org . eclipse . jdt . core . search . IJavaSearchScope ; import org . eclipse . jdt . core . search . SearchEngine ; import org . eclipse . jdt . core . search . SearchMatch ; import org . eclipse . jdt . core . search . SearchParticipant ; import org . eclipse . jdt . core . search . SearchPattern ; import org . eclipse . jdt . core . search . SearchRequestor ; public class TypeReferenceSearchTests extends AbstractGroovySearchTest { public TypeReferenceSearchTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( TypeReferenceSearchTests . class ) ; } public void testSearchForTypesScript1 ( ) throws Exception { doTestForTwoInScript ( "<STR_LIT>" ) ; } public void testSearchForTypesScript2 ( ) throws Exception { doTestForTwoInScript ( "<STR_LIT>" ) ; } public void testSearchForTypesScript3 ( ) throws Exception { doTestForTwoInScript ( "<STR_LIT>" ) ; } public void testSearchForTypesScript4 ( ) throws Exception { doTestForTwoInScript ( "<STR_LIT>" ) ; } public void testSearchForTypesScript5 ( ) throws Exception { doTestForTwoInScript ( "<STR_LIT>" ) ; } public void testSearchForTypesScript6 ( ) throws Exception { doTestForTwoInScript ( "<STR_LIT>" ) ; } public void testSearchForTypesClosure1 ( ) throws Exception { doTestForTwoInScript ( "<STR_LIT>" ) ; } public void testSearchForTypesClosure2 ( ) throws Exception { doTestForTwoInScript ( "<STR_LIT>" ) ; } public void testSearchForTypesClosure3 ( ) throws Exception { doTestForTwoInScript ( "<STR_LIT>" ) ; } public void testSearchForTypesClass1 ( ) throws Exception { doTestForTwoInClass ( "<STR_LIT>" ) ; } public void testSearchForTypesClass2 ( ) throws Exception { doTestForTwoInClass ( "<STR_LIT>" ) ; } public void testSearchForTypesClass3 ( ) throws Exception { doTestForTwoInClass ( "<STR_LIT>" ) ; } public void testSearchForTypesClass4 ( ) throws Exception { doTestForTwoInClass ( "<STR_LIT>" ) ; } public void testSearchForTypesClass5 ( ) throws Exception { doTestForTwoInClassUseWithDefaultMethod ( "<STR_LIT>" ) ; } public void testSearchForTypesClass6 ( ) throws Exception { doTestForTwoInClassWithImplements ( "<STR_LIT>" ) ; } public void testSearchForTypesClass7 ( ) throws Exception { createUnit ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; doTestForTwoInClass ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; } public void testSearchForTypesArray1 ( ) throws Exception { doTestForTwoInScript ( "<STR_LIT>" ) ; } public void testFindClassDeclaration ( ) throws Exception { String firstContents = "<STR_LIT>" ; String secondContents = "<STR_LIT>" ; List < SearchMatch > matches = getAllMatches ( firstContents , secondContents ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:2> , matches . size ( ) ) ; SearchMatch match = matches . get ( <NUM_LIT:0> ) ; int start = match . getOffset ( ) ; int end = start + match . getLength ( ) ; assertEquals ( "<STR_LIT>" , "<STR_LIT>" , firstContents . substring ( start , end ) ) ; match = matches . get ( <NUM_LIT:1> ) ; start = match . getOffset ( ) ; end = start + match . getLength ( ) ; assertEquals ( "<STR_LIT>" , "<STR_LIT>" , secondContents . substring ( start , end ) ) ; } public void testFindClassDeclarationWithPattern ( ) throws Exception { int matchRule = SearchPattern . R_EXACT_MATCH | SearchPattern . R_CASE_SENSITIVE ; SearchPattern testPattern = SearchPattern . createPattern ( "<STR_LIT>" , IJavaSearchConstants . TYPE , IJavaSearchConstants . DECLARATIONS , matchRule ) ; GroovyCompilationUnit songTests = createUnit ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; GroovyCompilationUnit weirdTests = createUnit ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; GroovyCompilationUnit artistTests = createUnit ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; IJavaProject javaProject = JavaCore . create ( project ) ; IType songTestsType = javaProject . findType ( "<STR_LIT>" ) ; assertNotNull ( songTestsType ) ; IType artistTestsType = javaProject . findType ( "<STR_LIT>" ) ; assertNotNull ( artistTestsType ) ; SearchParticipant [ ] searchParticipants = new SearchParticipant [ ] { SearchEngine . getDefaultSearchParticipant ( ) } ; final ArrayList < Object > result = new ArrayList < Object > ( ) ; IJavaSearchScope scope = SearchEngine . createJavaSearchScope ( new IJavaElement [ ] { songTests , weirdTests , artistTests } , IJavaSearchScope . SOURCES ) ; SearchRequestor requestor = new SearchRequestor ( ) { @ Override public void acceptSearchMatch ( SearchMatch match ) throws CoreException { Object element = match . getElement ( ) ; result . add ( element ) ; } } ; new SearchEngine ( ) . search ( testPattern , searchParticipants , scope , requestor , new NullProgressMonitor ( ) ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:2> , result . size ( ) ) ; assertElements ( new HashSet < Object > ( result ) , songTestsType , artistTestsType ) ; } public void testShouldntFindClassDeclarationInScript ( ) throws Exception { String firstContents = "<STR_LIT>" ; String secondContents = "<STR_LIT>" ; List < SearchMatch > matches = getAllMatches ( firstContents , secondContents ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:0> , matches . size ( ) ) ; } public void testInnerTypes1 ( ) throws Exception { String firstContents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; String secondContents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String name = "<STR_LIT>" ; int len = name . length ( ) ; List < SearchMatch > matches = getAllMatches ( firstContents , secondContents , true ) ; assertEquals ( "<STR_LIT>" + matches , <NUM_LIT:5> , matches . size ( ) ) ; int start = secondContents . indexOf ( "<STR_LIT>" ) ; SearchMatch match = matches . get ( <NUM_LIT:0> ) ; assertEquals ( "<STR_LIT>" + match , start , match . getOffset ( ) ) ; assertEquals ( "<STR_LIT>" + match , len , match . getLength ( ) ) ; start = secondContents . indexOf ( "<STR_LIT>" , start + <NUM_LIT:1> ) ; match = matches . get ( <NUM_LIT:1> ) ; assertEquals ( "<STR_LIT>" + match , start , match . getOffset ( ) ) ; assertEquals ( "<STR_LIT>" + match , len , match . getLength ( ) ) ; start = secondContents . indexOf ( "<STR_LIT>" , start + <NUM_LIT:1> ) ; match = matches . get ( <NUM_LIT:2> ) ; assertEquals ( "<STR_LIT>" + match , start , match . getOffset ( ) ) ; assertEquals ( "<STR_LIT>" + match , len , match . getLength ( ) ) ; start = secondContents . indexOf ( "<STR_LIT>" , start + <NUM_LIT:1> ) ; match = matches . get ( <NUM_LIT:3> ) ; assertEquals ( "<STR_LIT>" + match , start , match . getOffset ( ) ) ; assertEquals ( "<STR_LIT>" + match , len , match . getLength ( ) ) ; start = secondContents . indexOf ( "<STR_LIT>" , start + <NUM_LIT:1> ) ; match = matches . get ( <NUM_LIT:4> ) ; assertEquals ( "<STR_LIT>" + match , start , match . getOffset ( ) ) ; assertEquals ( "<STR_LIT>" + match , len , match . getLength ( ) ) ; } public void testInnerTypes2 ( ) throws Exception { String firstContents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; String secondContents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String name = "<STR_LIT>" ; int len = name . length ( ) ; List < SearchMatch > matches = getAllMatches ( firstContents , secondContents , "<STR_LIT:p>" , "<STR_LIT:q>" , true ) ; assertEquals ( "<STR_LIT>" + matches , <NUM_LIT:5> , matches . size ( ) ) ; int start = secondContents . indexOf ( "<STR_LIT>" ) ; SearchMatch match = matches . get ( <NUM_LIT:0> ) ; assertEquals ( "<STR_LIT>" + match , start , match . getOffset ( ) ) ; assertEquals ( "<STR_LIT>" + match , len , match . getLength ( ) ) ; start = secondContents . indexOf ( "<STR_LIT>" , start + <NUM_LIT:1> ) ; match = matches . get ( <NUM_LIT:1> ) ; assertEquals ( "<STR_LIT>" + match , start , match . getOffset ( ) ) ; assertEquals ( "<STR_LIT>" + match , len , match . getLength ( ) ) ; start = secondContents . indexOf ( "<STR_LIT>" , start + <NUM_LIT:1> ) ; match = matches . get ( <NUM_LIT:2> ) ; assertEquals ( "<STR_LIT>" + match , start , match . getOffset ( ) ) ; assertEquals ( "<STR_LIT>" + match , len , match . getLength ( ) ) ; start = secondContents . indexOf ( "<STR_LIT>" , start + <NUM_LIT:1> ) ; match = matches . get ( <NUM_LIT:3> ) ; assertEquals ( "<STR_LIT>" + match , start , match . getOffset ( ) ) ; assertEquals ( "<STR_LIT>" + match , len , match . getLength ( ) ) ; start = secondContents . indexOf ( "<STR_LIT>" , start + <NUM_LIT:1> ) ; match = matches . get ( <NUM_LIT:4> ) ; assertEquals ( "<STR_LIT>" + match , start , match . getOffset ( ) ) ; assertEquals ( "<STR_LIT>" + match , len , match . getLength ( ) ) ; } public void testInnerTypes3 ( ) throws Exception { String firstContents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; String secondContents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String name = "<STR_LIT>" ; int len = name . length ( ) ; List < SearchMatch > matches = getAllMatches ( firstContents , secondContents , "<STR_LIT:p>" , "<STR_LIT:q>" , true ) ; assertEquals ( "<STR_LIT>" + matches , <NUM_LIT:4> , matches . size ( ) ) ; int start = secondContents . indexOf ( "<STR_LIT>" ) ; SearchMatch match = matches . get ( <NUM_LIT:0> ) ; assertEquals ( "<STR_LIT>" + match , start , match . getOffset ( ) ) ; assertEquals ( "<STR_LIT>" + match , len , match . getLength ( ) ) ; start = secondContents . indexOf ( "<STR_LIT>" , start + <NUM_LIT:1> ) ; match = matches . get ( <NUM_LIT:1> ) ; assertEquals ( "<STR_LIT>" + match , start , match . getOffset ( ) ) ; assertEquals ( "<STR_LIT>" + match , len , match . getLength ( ) ) ; start = secondContents . indexOf ( "<STR_LIT>" , start + <NUM_LIT:1> ) ; match = matches . get ( <NUM_LIT:2> ) ; assertEquals ( "<STR_LIT>" + match , start , match . getOffset ( ) ) ; assertEquals ( "<STR_LIT>" + match , len , match . getLength ( ) ) ; start = secondContents . indexOf ( "<STR_LIT>" , start + <NUM_LIT:1> ) ; match = matches . get ( <NUM_LIT:3> ) ; assertEquals ( "<STR_LIT>" + match , start , match . getOffset ( ) ) ; assertEquals ( "<STR_LIT>" + match , len , match . getLength ( ) ) ; } private void doTestForTwoInScript ( String secondContents ) throws JavaModelException { doTestForTwoTypeReferences ( FIRST_CONTENTS_CLASS , secondContents , true , <NUM_LIT:3> ) ; } private void doTestForTwoInClass ( String secondContents ) throws JavaModelException { doTestForTwoTypeReferences ( FIRST_CONTENTS_CLASS , secondContents , false , <NUM_LIT:0> ) ; } private void doTestForTwoInClassUseWithDefaultMethod ( String secondContents ) throws JavaModelException { doTestForTwoTypeReferences ( FIRST_CONTENTS_CLASS , secondContents , false , <NUM_LIT:1> ) ; } private void doTestForTwoInClassWithImplements ( String secondContents ) throws JavaModelException { doTestForTwoTypeReferences ( FIRST_CONTENTS_INTERFACE , secondContents , false , <NUM_LIT:0> ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . search ; import junit . framework . Test ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . search . IJavaSearchConstants ; public class FieldReferenceSearchTests extends AbstractGroovySearchTest { public FieldReferenceSearchTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( FieldReferenceSearchTests . class ) ; } public void testFieldReferencesInScript1 ( ) throws Exception { doTestForTwoFieldReferencesInScript ( "<STR_LIT>" ) ; } public void testFieldReferencesInScript2 ( ) throws Exception { doTestForTwoFieldReferencesInScript ( "<STR_LIT>" ) ; } public void testFieldReferencesInScript3 ( ) throws Exception { doTestForTwoFieldReferencesInScript ( "<STR_LIT>" ) ; } public void testFieldReferencesInScript4 ( ) throws Exception { doTestForTwoFieldReferencesInScriptWithQuotes ( "<STR_LIT>" ) ; } public void testFieldReferencesInScript5 ( ) throws Exception { doTestForTwoFieldReferencesInScript ( "<STR_LIT>" ) ; } public void testFieldReferencesInScript6 ( ) throws Exception { doTestForTwoFieldReferencesInScript ( "<STR_LIT>" ) ; } public void testFieldReferencesInScript7 ( ) throws Exception { createUnit ( "<STR_LIT>" , "<STR_LIT>" ) ; doTestForTwoFieldReferencesInScript ( "<STR_LIT>" ) ; } public void testFieldReferencesInScript8 ( ) throws Exception { doTestForTwoFieldReferencesInScript ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; } public void testFieldReferencesInClass1 ( ) throws Exception { doTestForTwoFieldReferencesInClass ( "<STR_LIT>" ) ; } public void testFieldReferencesInClass2 ( ) throws Exception { doTestForTwoFieldReferencesInClass ( "<STR_LIT>" ) ; } public void testFieldReferencesInClass3 ( ) throws Exception { doTestForTwoFieldReferencesInClass ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; } public void testFieldReferencesInClass4 ( ) throws Exception { createUnit ( "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; doTestForTwoFieldReferencesInClass ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; } public void testFieldReferenceInGString1 ( ) throws Exception { doTestForTwoFieldReferencesInGString ( "<STR_LIT>" ) ; } public void testFieldReferenceInGString2 ( ) throws Exception { doTestForTwoFieldReferencesInGString ( "<STR_LIT>" ) ; } public void testFieldReferenceInGString3 ( ) throws Exception { doTestForTwoFieldReferencesInGString ( "<STR_LIT>" ) ; } public void testFieldReferenceInGString4 ( ) throws Exception { doTestForTwoFieldReferencesInGString ( "<STR_LIT>" ) ; } protected void doTestForTwoFieldReferencesInGString ( String secondContents ) throws JavaModelException { super . doTestForTwoFieldReferencesInGString ( FIRST_CONTENTS_CLASS_FOR_FIELDS , secondContents , "<STR_LIT>" ) ; } public void testFieldWritesInScript1 ( ) throws Exception { doTestForTwoFieldWritesInScript ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; } public void testFieldReadsInScript1 ( ) throws Exception { doTestForTwoFieldReadsInScript ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; } private void doTestForTwoFieldWritesInScript ( String secondContents ) throws JavaModelException { doTestForTwoFieldReferences ( FIRST_CONTENTS_CLASS_FOR_FIELDS , secondContents , true , <NUM_LIT:3> , "<STR_LIT>" , IJavaSearchConstants . WRITE_ACCESSES ) ; } private void doTestForTwoFieldReadsInScript ( String secondContents ) throws JavaModelException { doTestForTwoFieldReferences ( FIRST_CONTENTS_CLASS_FOR_FIELDS , secondContents , true , <NUM_LIT:3> , "<STR_LIT>" , IJavaSearchConstants . READ_ACCESSES ) ; } private void doTestForTwoFieldReferencesInScript ( String secondContents ) throws JavaModelException { doTestForTwoFieldReferences ( FIRST_CONTENTS_CLASS_FOR_FIELDS , secondContents , true , <NUM_LIT:3> , "<STR_LIT>" ) ; } private void doTestForTwoFieldReferencesInScriptWithQuotes ( String secondContents ) throws JavaModelException { doTestForTwoFieldReferences ( FIRST_CONTENTS_CLASS_FOR_FIELDS , secondContents , true , <NUM_LIT:3> , "<STR_LIT>" ) ; } private void doTestForTwoFieldReferencesInClass ( String secondContents ) throws JavaModelException { doTestForTwoFieldReferences ( FIRST_CONTENTS_CLASS_FOR_FIELDS , secondContents , false , <NUM_LIT:0> , "<STR_LIT>" ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . search ; import junit . framework . Test ; public class SyntheticAccessorInferencingTests extends AbstractInferencingTest { public static Test suite ( ) { return buildTestSuite ( SyntheticAccessorInferencingTests . class ) ; } public SyntheticAccessorInferencingTests ( String name ) { super ( name ) ; } public void testSyntheticAccessors1 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; shouldBeUnknown ( contents , "<STR_LIT>" ) ; shouldBeUnknown ( contents , "<STR_LIT>" ) ; shouldBeUnknown ( contents , "<STR_LIT>" ) ; shouldBeUnknown ( contents , "<STR_LIT>" ) ; shouldBeUnknown ( contents , "<STR_LIT>" ) ; shouldBeUnknown ( contents , "<STR_LIT>" ) ; shouldBeUnknown ( contents , "<STR_LIT>" ) ; shouldBeUnknown ( contents , "<STR_LIT>" ) ; shouldBeUnknown ( contents , "<STR_LIT>" ) ; shouldBeUnknown ( contents , "<STR_LIT>" ) ; shouldBeUnknown ( contents , "<STR_LIT>" ) ; shouldBeUnknown ( contents , "<STR_LIT>" ) ; shouldBeUnknown ( contents , "<STR_LIT>" ) ; shouldBeUnknown ( contents , "<STR_LIT>" ) ; shouldBeUnknown ( contents , "<STR_LIT>" ) ; shouldBeUnknown ( contents , "<STR_LIT>" ) ; shouldBeUnknown ( contents , "<STR_LIT>" ) ; shouldBeKnown ( contents , "<STR_LIT>" , "<STR_LIT>" ) ; shouldBeKnown ( contents , "<STR_LIT>" , "<STR_LIT>" ) ; shouldBeKnown ( contents , "<STR_LIT>" , "<STR_LIT>" ) ; shouldBeKnown ( contents , "<STR_LIT>" , "<STR_LIT>" ) ; shouldBeKnown ( contents , "<STR_LIT>" , "<STR_LIT>" ) ; shouldBeKnown ( contents , "<STR_LIT>" , "<STR_LIT>" ) ; shouldBeKnown ( contents , "<STR_LIT>" , "<STR_LIT>" ) ; } private void shouldBeUnknown ( String contents , String var ) { int start = contents . indexOf ( var ) ; int end = start + var . length ( ) ; assertUnknownConfidence ( contents , start , end , "<STR_LIT>" , false ) ; } private void shouldBeKnown ( String contents , String var , String type ) { int start = contents . lastIndexOf ( var ) ; int end = start + var . length ( ) ; assertDeclaringType ( contents , start , end , type , false ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . search ; import junit . framework . Test ; import org . eclipse . jdt . core . JavaModelException ; public class MethodReferenceSearchTests extends AbstractGroovySearchTest { public MethodReferenceSearchTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( MethodReferenceSearchTests . class ) ; } public void testMethodReferencesInScript1 ( ) throws Exception { doTestForTwoMethodReferencesInScript ( "<STR_LIT>" ) ; } public void testMethodReferencesInScript1GRE_1180 ( ) throws Exception { doTestForTwoMethodReferencesInScript ( "<STR_LIT>" ) ; } public void testMethodReferencesInScript2 ( ) throws Exception { doTestForTwoMethodReferencesInScript ( "<STR_LIT>" ) ; } public void testMethodReferencesInScript3 ( ) throws Exception { doTestForTwoMethodReferencesInScript ( "<STR_LIT>" ) ; } public void testMethodReferencesInScript4 ( ) throws Exception { doTestForTwoMethodReferencesInScriptWithQuotes ( "<STR_LIT>" ) ; } public void testMethodReferencesInScript5 ( ) throws Exception { doTestForTwoMethodReferencesInScript ( "<STR_LIT>" ) ; } public void testMethodReferencesInScript6 ( ) throws Exception { doTestForTwoMethodReferencesInScript ( "<STR_LIT>" ) ; } public void testMethodReferencesInScript7 ( ) throws Exception { createUnit ( "<STR_LIT>" , "<STR_LIT>" ) ; doTestForTwoMethodReferencesInScript ( "<STR_LIT>" ) ; } public void testMethodReferencesInScript8 ( ) throws Exception { doTestForTwoMethodReferencesInScript ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; } public void testMethodReferencesInClass1 ( ) throws Exception { doTestForTwoMethodReferencesInClass ( "<STR_LIT>" ) ; } public void testMethodReferencesInClass2 ( ) throws Exception { doTestForTwoMethodReferencesInClass ( "<STR_LIT>" ) ; } public void testMethodReferencesInClass3 ( ) throws Exception { doTestForTwoMethodReferencesInClass ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; } public void testMethodReferencesInClass4 ( ) throws Exception { createUnit ( "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; doTestForTwoMethodReferencesInClass ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; } public void testOverloadedMethodReferences1 ( ) throws Exception { doTestForTwoMethodReferences ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" , false , <NUM_LIT:0> , "<STR_LIT>" ) ; } public void testOverloadedMethodReferences2 ( ) throws Exception { doTestForTwoMethodReferences ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" , false , <NUM_LIT:0> , "<STR_LIT>" ) ; } public void testOverloadedMethodReferences3 ( ) throws Exception { createUnit ( "<STR_LIT>" , "<STR_LIT>" ) ; doTestForTwoMethodReferences ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" , false , <NUM_LIT:0> , "<STR_LIT>" ) ; } public void testOverloadedMethodReferences4 ( ) throws Exception { createUnit ( "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; doTestForTwoMethodReferences ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" , false , <NUM_LIT:0> , "<STR_LIT>" ) ; } public void testMethodWithDefaultParameters1 ( ) throws Exception { doTestForTwoMethodReferences ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" , false , <NUM_LIT:0> , "<STR_LIT>" ) ; } public void testMethodWithDefaultParameters2 ( ) throws Exception { doTestForTwoMethodReferences ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" , false , <NUM_LIT:0> , "<STR_LIT>" ) ; } private void doTestForTwoMethodReferencesInScript ( String secondContents ) throws JavaModelException { doTestForTwoMethodReferences ( FIRST_CONTENTS_CLASS_FOR_METHODS , secondContents , true , <NUM_LIT:3> , "<STR_LIT>" ) ; } private void doTestForTwoMethodReferencesInScriptWithQuotes ( String secondContents ) throws JavaModelException { doTestForTwoMethodReferences ( FIRST_CONTENTS_CLASS_FOR_METHODS , secondContents , true , <NUM_LIT:3> , "<STR_LIT>" ) ; } private void doTestForTwoMethodReferencesInClass ( String secondContents ) throws JavaModelException { doTestForTwoMethodReferences ( FIRST_CONTENTS_CLASS_FOR_METHODS , secondContents , false , <NUM_LIT:0> , "<STR_LIT>" ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . search ; import junit . framework . Test ; public class GenericInferencingTests extends AbstractInferencingTest { public static Test suite ( ) { return buildTestSuite ( GenericInferencingTests . class ) ; } public GenericInferencingTests ( String name ) { super ( name ) ; } public void testEnum1 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . indexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testList1 ( ) throws Exception { assertType ( "<STR_LIT>" , "<STR_LIT>" ) ; } public void testList2 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testList3 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testList4 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testList5 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:get>" ; int start = contents . indexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testList6 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . indexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testList7 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . indexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testList8 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:x>" ; int start = contents . indexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testSet1 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:x>" ; int start = contents . indexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testMap1 ( ) throws Exception { String contents = "<STR_LIT>" ; assertType ( contents , "<STR_LIT>" ) ; } public void testMap2 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:x>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testMap3 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testMap3a ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testMap4 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:key>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testMap5 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:value>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testMap6 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:value>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testMap7 ( ) throws Exception { String contents = "<STR_LIT>" ; assertType ( contents , "<STR_LIT>" ) ; } public void testMap8 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testMap9 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:f>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testMap10 ( ) throws Exception { String contents = "<STR_LIT>" ; assertType ( contents , "<STR_LIT>" ) ; } public void testMapOfList ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:value>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testMapOfList2 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testMapOfList4 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:x>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testArray1 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:x>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testArray2 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void _testArray3 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } private static final String XX = "<STR_LIT>" ; public void testArray4 ( ) throws Exception { createUnit ( "<STR_LIT>" , XX ) ; String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testArray5 ( ) throws Exception { createUnit ( "<STR_LIT>" , XX ) ; String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testArray6 ( ) throws Exception { createUnit ( "<STR_LIT>" , XX ) ; String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testArray7 ( ) throws Exception { createUnit ( "<STR_LIT>" , XX ) ; String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testArray8 ( ) throws Exception { createUnit ( "<STR_LIT>" , XX ) ; String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testArray9 ( ) throws Exception { createUnit ( "<STR_LIT>" , XX ) ; String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testArray10 ( ) throws Exception { createUnit ( "<STR_LIT>" , XX ) ; String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testArray11 ( ) throws Exception { createUnit ( "<STR_LIT>" , XX ) ; String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testArray12 ( ) throws Exception { createUnit ( "<STR_LIT>" , XX ) ; String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testArray13 ( ) throws Exception { createUnit ( "<STR_LIT>" , XX ) ; String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testMapOfList3 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:key>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void _testMapOfList4 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testMapOfList5 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testForLoop1 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:a>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testForLoop2 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:a>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testForLoop3 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:a>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testForLoop4 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:a>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testForLoop5 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:key>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testForLoop6 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:value>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testForLoop7 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:a>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testForLoop8 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:a>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testForLoop9 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:a>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testForLoop10 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testForLoop11 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String toFind = "<STR_LIT:foo>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGMClosure1 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGMClosure2 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGMClosure3 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGMClosure4 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:key>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGMClosure5 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:value>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGMClosure7 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGMClosure8 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGMClosure9 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGMClosure10 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:i>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGMClosure11 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGMClosure12 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:key>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGMClosure13 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:i>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGMClosure14 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:key>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGMClosure15 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGMClosure16 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:key>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGMClosure17 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGMClosure18 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:a>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGMClosure19 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:b>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGMClosure20 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:b>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGMClosure21 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:a>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGMClosure22 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:value>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGMClosure23 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT:key>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testNestedGenerics1 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String toFind = "<STR_LIT:get>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testNestedGenerics2 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testNestedGenerics3 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testNestedGenerics4 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testNestedGenerics5 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testNestedGenerics6 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testNestedGenerics7 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String toFind = "<STR_LIT:get>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testNestedGenerics8 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testEachOnNonIterables1 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testEachOnNonIterables2 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testEachOnNonIterables3 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInferringList1 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInferringList2 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInferringList3 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInferringRange1 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInferringRange2 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInferringMap1 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInferringMap2 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInferringMap3 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInferringMap4 ( ) throws Exception { String contents = "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInferringMap5 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInferringMap6 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String toFind = "<STR_LIT>" ; int start = contents . lastIndexOf ( toFind ) ; int end = start + toFind . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testConstructor1 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; assertDeclaration ( contents , start , end , "<STR_LIT>" , "<STR_LIT>" , DeclarationKind . FIELD ) ; start = contents . lastIndexOf ( "<STR_LIT>" ) ; end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; assertDeclaration ( contents , start , end , "<STR_LIT>" , "<STR_LIT>" , DeclarationKind . FIELD ) ; } public void testConstructor2 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; assertDeclaration ( contents , start , end , "<STR_LIT>" , "<STR_LIT>" , DeclarationKind . FIELD ) ; start = contents . lastIndexOf ( "<STR_LIT>" ) ; end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; assertDeclaration ( contents , start , end , "<STR_LIT>" , "<STR_LIT>" , DeclarationKind . FIELD ) ; } public void testConstructor3 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; assertDeclaration ( contents , start , end , "<STR_LIT>" , "<STR_LIT>" , DeclarationKind . FIELD ) ; } public void testConstructor4 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; assertDeclaringType ( contents , start , end , "<STR_LIT:null>" ) ; start = contents . lastIndexOf ( "<STR_LIT>" ) ; end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; assertDeclaringType ( contents , start , end , "<STR_LIT:null>" ) ; } public void testConstructor5 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; assertDeclaringType ( contents , start , end , "<STR_LIT:null>" ) ; start = contents . lastIndexOf ( "<STR_LIT>" ) ; end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; assertDeclaringType ( contents , start , end , "<STR_LIT:null>" ) ; } public void testConstructor6 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; assertDeclaringType ( contents , start , end , "<STR_LIT:null>" ) ; start = contents . lastIndexOf ( "<STR_LIT>" ) ; end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; assertDeclaringType ( contents , start , end , "<STR_LIT:null>" ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . search ; import org . eclipse . jdt . core . tests . util . GroovyUtils ; import junit . framework . Test ; public class DGMInferencingTests extends AbstractInferencingTest { public static Test suite ( ) { return buildTestSuite ( DGMInferencingTests . class ) ; } public DGMInferencingTests ( String name ) { super ( name ) ; } public void testDGM1 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM2 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM3 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM4 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM5 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT:key>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM6 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT:value>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM7 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT:key>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM8 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT:value>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM9 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void _testDGM10 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM11 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT:index>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM12 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT:key>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM13 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT:value>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM14 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM15 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM16 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT:key>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM17 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT:value>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM18 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT:key>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM19 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT:value>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM20 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT:key>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM21 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT:value>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM22 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM23 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT:key>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM24 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT:value>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM25 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT:key>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM26 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT:value>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM27 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT:key>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM28 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT:value>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM29 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM30 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM31 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM32 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM34 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM35 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM36 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM37 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM38 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM39 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM40 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM41 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM42 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM33 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM43 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGMDeclaring1 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; if ( GroovyUtils . GROOVY_LEVEL >= <NUM_LIT:20> ) { assertDeclaringType ( contents , start , end , "<STR_LIT>" ) ; } else { assertDeclaringType ( contents , start , end , "<STR_LIT>" ) ; } } public void testDGMDeclaring2 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; if ( GroovyUtils . GROOVY_LEVEL >= <NUM_LIT:20> ) { assertDeclaringType ( contents , start , end , "<STR_LIT>" ) ; } else { assertDeclaringType ( contents , start , end , "<STR_LIT>" ) ; } } public void testDGMDeclaring3 ( ) throws Exception { String contents = "<STR_LIT>" ; String str = "<STR_LIT>" ; int start = contents . lastIndexOf ( str ) ; int end = start + str . length ( ) ; if ( GroovyUtils . GROOVY_LEVEL >= <NUM_LIT:20> ) { assertDeclaringType ( contents , start , end , "<STR_LIT>" ) ; } else { assertDeclaringType ( contents , start , end , "<STR_LIT>" ) ; } } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . search ; import java . util . Iterator ; import java . util . List ; import java . util . regex . Matcher ; import java . util . regex . Pattern ; import junit . framework . Test ; import org . codehaus . jdt . groovy . model . GroovyCompilationUnit ; import org . eclipse . jdt . core . IMethod ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . search . IJavaSearchConstants ; import org . eclipse . jdt . core . search . SearchMatch ; import org . eclipse . jdt . core . search . SearchPattern ; import org . eclipse . jdt . groovy . search . ITypeRequestor ; import org . eclipse . jdt . groovy . search . TypeInferencingVisitorWithRequestor ; import org . eclipse . jdt . groovy . search . TypeRequestorFactory ; public class CategorySearchTests extends AbstractGroovySearchTest { public CategorySearchTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( CategorySearchTests . class ) ; } @ Override protected void setUp ( ) throws Exception { super . setUp ( ) ; } private static String CATEGORY_DEFN = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; private static String SIMPLE_CATEGORY = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; private static String CATEGORY_WITH_SUBTYPE = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; private static String CATEGORY_ASSIGNED = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; private static String CATEGORY_MULTIPLE_OUTER = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; private static String CATEGORY_MULTIPLE_INNER = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; private static String NO_CATEGORY = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; public void testCategorySearch1 ( ) throws Exception { doCategorySearchTest ( SIMPLE_CATEGORY , <NUM_LIT:4> ) ; } public void testCategorySearch2 ( ) throws Exception { doCategorySearchTest ( CATEGORY_WITH_SUBTYPE , <NUM_LIT:4> ) ; } public void testCategorySearch3 ( ) throws Exception { doCategorySearchTest ( CATEGORY_ASSIGNED , <NUM_LIT:4> ) ; } public void testCategorySearch4 ( ) throws Exception { doCategorySearchTest ( CATEGORY_MULTIPLE_INNER , <NUM_LIT:4> ) ; } public void testCategorySearch5 ( ) throws Exception { doCategorySearchTest ( CATEGORY_MULTIPLE_OUTER , <NUM_LIT:4> ) ; } public void testCategorySearch6 ( ) throws Exception { doCategorySearchTest ( NO_CATEGORY , <NUM_LIT:0> ) ; } void doCategorySearchTest ( String contents , int numMatches ) throws JavaModelException { checkMatches ( findMatches ( contents ) , numMatches , contents ) ; } List < SearchMatch > findMatches ( String contents ) throws JavaModelException { GroovyCompilationUnit catUnit = createUnit ( "<STR_LIT>" , CATEGORY_DEFN ) ; GroovyCompilationUnit unit = createUnit ( "<STR_LIT>" , contents ) ; env . waitForAutoBuild ( ) ; expectingNoProblems ( ) ; MockPossibleMatch match = new MockPossibleMatch ( unit ) ; IMethod searchFor = ( IMethod ) catUnit . getElementAt ( CATEGORY_DEFN . indexOf ( "<STR_LIT>" ) ) ; assertEquals ( "<STR_LIT>" + searchFor , "<STR_LIT>" , searchFor . getElementName ( ) ) ; SearchPattern pattern = SearchPattern . createPattern ( searchFor , IJavaSearchConstants . REFERENCES ) ; ITypeRequestor typeRequestor = new TypeRequestorFactory ( ) . createRequestor ( match , pattern , searchRequestor ) ; TypeInferencingVisitorWithRequestor visitor = factory . createVisitor ( match ) ; visitor . visitCompilationUnit ( typeRequestor ) ; System . out . println ( "<STR_LIT>" + searchRequestor . printMatches ( ) ) ; return searchRequestor . getMatches ( ) ; } void checkMatches ( List < SearchMatch > matches , int numExpected , String contents ) { assertEquals ( "<STR_LIT>" + searchRequestor . printMatches ( ) , numExpected , matches . size ( ) ) ; if ( numExpected == <NUM_LIT:0> ) { return ; } Pattern p = Pattern . compile ( "<STR_LIT>" ) ; Matcher m = p . matcher ( contents ) ; Iterator < SearchMatch > matchIter = matches . iterator ( ) ; while ( m . find ( ) ) { SearchMatch match = matchIter . next ( ) ; assertEquals ( "<STR_LIT>" + MockPossibleMatch . printMatch ( match ) , m . start ( ) , match . getOffset ( ) ) ; assertEquals ( "<STR_LIT>" + MockPossibleMatch . printMatch ( match ) , "<STR_LIT>" . length ( ) , match . getLength ( ) ) ; } } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . search ; import static org . eclipse . jdt . core . search . IJavaSearchConstants . CLASS ; import static org . eclipse . jdt . core . search . IJavaSearchConstants . WAIT_UNTIL_READY_TO_SEARCH ; import static org . eclipse . jdt . core . search . SearchEngine . createJavaSearchScope ; import static org . eclipse . jdt . core . search . SearchPattern . R_CASE_SENSITIVE ; import static org . eclipse . jdt . core . search . SearchPattern . R_EXACT_MATCH ; import java . util . List ; import org . codehaus . jdt . groovy . model . GroovyCompilationUnit ; import org . eclipse . core . resources . IFolder ; import org . eclipse . core . resources . IProject ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . Path ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IField ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . ILocalVariable ; import org . eclipse . jdt . core . IMethod ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . search . IJavaSearchConstants ; import org . eclipse . jdt . core . search . SearchEngine ; import org . eclipse . jdt . core . search . SearchMatch ; import org . eclipse . jdt . core . search . SearchPattern ; import org . eclipse . jdt . core . search . TypeNameRequestor ; import org . eclipse . jdt . core . tests . builder . BuilderTests ; import org . eclipse . jdt . core . tests . util . Util ; import org . eclipse . jdt . groovy . core . util . ReflectionUtils ; import org . eclipse . jdt . groovy . search . ITypeRequestor ; import org . eclipse . jdt . groovy . search . TypeInferencingVisitorFactory ; import org . eclipse . jdt . groovy . search . TypeInferencingVisitorWithRequestor ; import org . eclipse . jdt . groovy . search . TypeRequestorFactory ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . core . DefaultWorkingCopyOwner ; import org . eclipse . jdt . internal . core . JavaModelManager ; public abstract class AbstractGroovySearchTest extends BuilderTests { protected class MatchRegion { final int offset ; final int length ; public MatchRegion ( int offset , int length ) { this . offset = offset ; this . length = length ; } @ Override public String toString ( ) { return "<STR_LIT>" + offset + "<STR_LIT>" + length + "<STR_LIT>" ; } } MockSearchRequestor searchRequestor ; protected IProject project ; protected static final TypeInferencingVisitorFactory factory = new TypeInferencingVisitorFactory ( ) ; protected String defaultFileExtension = "<STR_LIT>" ; public AbstractGroovySearchTest ( String name ) { super ( name ) ; } @ Override protected void setUp ( ) throws Exception { super . setUp ( ) ; System . out . println ( "<STR_LIT>" ) ; System . out . println ( "<STR_LIT>" + this . getClass ( ) . getName ( ) + "<STR_LIT:.>" + this . getName ( ) ) ; searchRequestor = new MockSearchRequestor ( ) ; project = createSimpleGroovyProject ( ) ; } @ Override protected void tearDown ( ) throws Exception { super . tearDown ( ) ; ICompilationUnit [ ] units = JavaModelManager . getJavaModelManager ( ) . getWorkingCopies ( DefaultWorkingCopyOwner . PRIMARY , true ) ; if ( units != null ) { for ( int i = <NUM_LIT:0> ; i < units . length ; i ++ ) { units [ i ] . discardWorkingCopy ( ) ; } } defaultFileExtension = "<STR_LIT>" ; } protected IProject createSimpleGroovyProject ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addGroovyNature ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addGroovyJars ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IProject proj = env . getProject ( "<STR_LIT>" ) ; IJavaProject javaProject = JavaCore . create ( proj ) ; javaProject . setOption ( CompilerOptions . OPTION_Compliance , "<STR_LIT>" ) ; javaProject . setOption ( CompilerOptions . OPTION_Source , "<STR_LIT>" ) ; javaProject . setOption ( CompilerOptions . OPTION_TargetPlatform , "<STR_LIT>" ) ; fullBuild ( projectPath ) ; return proj ; } protected GroovyCompilationUnit createUnit ( String name , String contents ) { IPath path = env . addGroovyClassExtension ( project . getFolder ( "<STR_LIT:src>" ) . getFullPath ( ) , name , contents , defaultFileExtension ) ; fullBuild ( project . getFullPath ( ) ) ; return ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( env . getWorkspace ( ) . getRoot ( ) . getFile ( path ) ) ; } protected ICompilationUnit createJavaUnit ( String name , String contents ) { IPath path = env . addClass ( project . getFolder ( "<STR_LIT:src>" ) . getFullPath ( ) , name , contents ) ; return JavaCore . createCompilationUnitFrom ( env . getWorkspace ( ) . getRoot ( ) . getFile ( path ) ) ; } protected ICompilationUnit createJavaUnit ( String pack , String name , String contents ) { IPath path = env . addClass ( project . getFolder ( "<STR_LIT:src>" ) . getFullPath ( ) , pack , name , contents ) ; return JavaCore . createCompilationUnitFrom ( env . getWorkspace ( ) . getRoot ( ) . getFile ( path ) ) ; } protected GroovyCompilationUnit createUnit ( String pkg , String name , String contents ) throws CoreException { IFolder folder = project . getFolder ( "<STR_LIT:src>" ) . getFolder ( new Path ( pkg ) ) ; if ( ! folder . exists ( ) ) { folder . create ( true , true , null ) ; } IPath path = env . addGroovyClassExtension ( folder . getFullPath ( ) , name , contents , defaultFileExtension ) ; return ( GroovyCompilationUnit ) JavaCore . createCompilationUnitFrom ( env . getWorkspace ( ) . getRoot ( ) . getFile ( path ) ) ; } protected void assertLocation ( SearchMatch match , int start , int length ) { assertEquals ( "<STR_LIT>" + MockPossibleMatch . printMatch ( match ) , start , match . getOffset ( ) ) ; assertEquals ( "<STR_LIT>" + MockPossibleMatch . printMatch ( match ) , length , match . getLength ( ) ) ; } protected final static String FIRST_CONTENTS_CLASS = "<STR_LIT>" ; protected final static String FIRST_CONTENTS_INTERFACE = "<STR_LIT>" ; protected final static String FIRST_CONTENTS_CLASS_FOR_FIELDS = "<STR_LIT>" ; protected final static String FIRST_CONTENTS_CLASS_FOR_METHODS = "<STR_LIT>" ; protected final static String FIRST_CONTENTS_CLASS_FOR_METHODS2 = "<STR_LIT>" ; protected void doTestForTwoTypeReferences ( String firstContents , String secondContents , boolean contentsIsScript , int offsetInParent ) throws JavaModelException { String firstClassName = "<STR_LIT>" ; String secondClassName = "<STR_LIT>" ; GroovyCompilationUnit first = createUnit ( firstClassName , firstContents ) ; IType firstType = findType ( firstClassName , first ) ; SearchPattern pattern = SearchPattern . createPattern ( firstType , IJavaSearchConstants . REFERENCES ) ; GroovyCompilationUnit second = createUnit ( secondClassName , secondContents ) ; IJavaElement firstMatchEnclosingElement ; IJavaElement secondMatchEnclosingElement ; if ( contentsIsScript ) { firstMatchEnclosingElement = findType ( secondClassName , second ) . getChildren ( ) [ offsetInParent ] ; } else { firstMatchEnclosingElement = findType ( secondClassName , second ) ; } secondMatchEnclosingElement = findType ( secondClassName , second ) . getChildren ( ) [ offsetInParent ] ; checkMatches ( secondContents , firstClassName , pattern , second , firstMatchEnclosingElement , secondMatchEnclosingElement ) ; } protected void doTestForTwoFieldReferences ( String firstContents , String secondContents , boolean contentsIsScript , int offsetInParent , String matchName ) throws JavaModelException { doTestForTwoFieldReferences ( firstContents , secondContents , contentsIsScript , offsetInParent , matchName , IJavaSearchConstants . REFERENCES ) ; } protected void doTestForTwoFieldReferences ( String firstContents , String secondContents , boolean contentsIsScript , int offsetInParent , String matchName , int searchFlags ) throws JavaModelException { String firstClassName = "<STR_LIT>" ; String secondClassName = "<STR_LIT>" ; String matchedFieldName = "<STR_LIT>" ; GroovyCompilationUnit first = createUnit ( firstClassName , firstContents ) ; IField firstField = findType ( firstClassName , first ) . getField ( matchedFieldName ) ; SearchPattern pattern = SearchPattern . createPattern ( firstField , searchFlags ) ; GroovyCompilationUnit second = createUnit ( secondClassName , secondContents ) ; IJavaElement firstMatchEnclosingElement ; IJavaElement secondMatchEnclosingElement ; if ( contentsIsScript ) { firstMatchEnclosingElement = findType ( secondClassName , second ) . getChildren ( ) [ offsetInParent ] ; secondMatchEnclosingElement = findType ( secondClassName , second ) . getChildren ( ) [ offsetInParent ] ; } else { firstMatchEnclosingElement = findType ( secondClassName , second ) . getChildren ( ) [ offsetInParent ] ; secondMatchEnclosingElement = findType ( secondClassName , second ) . getChildren ( ) [ offsetInParent + <NUM_LIT:2> ] ; } checkMatches ( secondContents , matchName , pattern , second , firstMatchEnclosingElement , secondMatchEnclosingElement ) ; } protected void doTestForTwoFieldReferencesInGString ( String firstContents , String secondContents , String matchName ) throws JavaModelException { String firstClassName = "<STR_LIT>" ; String secondClassName = "<STR_LIT>" ; String matchedFieldName = "<STR_LIT>" ; GroovyCompilationUnit first = createUnit ( firstClassName , firstContents ) ; IField firstField = findType ( firstClassName , first ) . getField ( matchedFieldName ) ; SearchPattern pattern = SearchPattern . createPattern ( firstField , IJavaSearchConstants . REFERENCES ) ; GroovyCompilationUnit second = createUnit ( secondClassName , secondContents ) ; IJavaElement firstMatchEnclosingElement = findType ( secondClassName , second ) . getChildren ( ) [ <NUM_LIT:0> ] ; IJavaElement secondMatchEnclosingElement = findType ( secondClassName , second ) . getChildren ( ) [ <NUM_LIT:0> ] ; checkMatches ( secondContents , matchName , pattern , second , firstMatchEnclosingElement , secondMatchEnclosingElement ) ; } protected void doTestForTwoMethodReferences ( String firstContents , String secondContents , boolean contentsIsScript , int offsetInParent , String matchName ) throws JavaModelException { String firstClassName = "<STR_LIT>" ; String secondClassName = "<STR_LIT>" ; GroovyCompilationUnit first = createUnit ( firstClassName , firstContents ) ; IMethod firstMethod = ( IMethod ) findType ( firstClassName , first ) . getChildren ( ) [ <NUM_LIT:0> ] ; SearchPattern pattern = SearchPattern . createPattern ( firstMethod , IJavaSearchConstants . REFERENCES ) ; GroovyCompilationUnit second = createUnit ( secondClassName , secondContents ) ; env . fullBuild ( ) ; IJavaElement firstMatchEnclosingElement ; IJavaElement secondMatchEnclosingElement ; if ( contentsIsScript ) { firstMatchEnclosingElement = findType ( secondClassName , second ) . getChildren ( ) [ offsetInParent ] ; secondMatchEnclosingElement = findType ( secondClassName , second ) . getChildren ( ) [ offsetInParent ] ; } else { firstMatchEnclosingElement = findType ( secondClassName , second ) . getChildren ( ) [ offsetInParent ] ; secondMatchEnclosingElement = findType ( secondClassName , second ) . getChildren ( ) [ offsetInParent + <NUM_LIT:2> ] ; } checkMatches ( secondContents , matchName , pattern , second , firstMatchEnclosingElement , secondMatchEnclosingElement ) ; } protected List < SearchMatch > getAllMatches ( String firstContents , String secondContents ) throws CoreException { return getAllMatches ( firstContents , secondContents , false ) ; } protected List < SearchMatch > getAllMatches ( String firstContents , String secondContents , boolean waitForIndexer ) throws CoreException { return getAllMatches ( firstContents , secondContents , "<STR_LIT>" , "<STR_LIT>" , waitForIndexer ) ; } protected List < SearchMatch > getAllMatches ( String firstContents , String secondContents , String firstPackage , String secondPackage , boolean waitForIndexer ) throws CoreException { String firstClassName = "<STR_LIT>" ; String secondClassName = "<STR_LIT>" ; GroovyCompilationUnit first = createUnit ( firstPackage , firstClassName , firstContents ) ; IType firstType = findType ( firstClassName , first ) ; SearchPattern pattern = SearchPattern . createPattern ( firstType , IJavaSearchConstants . REFERENCES ) ; GroovyCompilationUnit second = createUnit ( secondPackage , secondClassName , secondContents ) ; if ( waitForIndexer ) { waitForIndexer ( ) ; } MockPossibleMatch match1 = new MockPossibleMatch ( first ) ; ITypeRequestor typeRequestor1 = new TypeRequestorFactory ( ) . createRequestor ( match1 , pattern , searchRequestor ) ; TypeInferencingVisitorWithRequestor visitor1 = factory . createVisitor ( match1 ) ; visitor1 . visitCompilationUnit ( typeRequestor1 ) ; MockPossibleMatch match2 = new MockPossibleMatch ( second ) ; ITypeRequestor typeRequestor2 = new TypeRequestorFactory ( ) . createRequestor ( match2 , pattern , searchRequestor ) ; TypeInferencingVisitorWithRequestor visitor2 = factory . createVisitor ( match2 ) ; visitor2 . visitCompilationUnit ( typeRequestor2 ) ; return searchRequestor . getMatches ( ) ; } @ SuppressWarnings ( "<STR_LIT:deprecation>" ) private void waitForIndexer ( ) throws JavaModelException { final TypeNameRequestor requestor = new TypeNameRequestor ( ) { } ; new SearchEngine ( ) . searchAllTypeNames ( null , null , R_EXACT_MATCH | R_CASE_SENSITIVE , CLASS , createJavaSearchScope ( new IJavaElement [ <NUM_LIT:0> ] ) , requestor , WAIT_UNTIL_READY_TO_SEARCH , null ) ; } private IType findType ( String firstClassName , GroovyCompilationUnit first ) { IType type = first . getType ( firstClassName ) ; if ( ! type . exists ( ) ) { try { IType [ ] allTypes = first . getAllTypes ( ) ; for ( IType type2 : allTypes ) { if ( type2 . getElementName ( ) . equals ( firstClassName ) ) { return type2 ; } } } catch ( JavaModelException e ) { e . printStackTrace ( ) ; } return null ; } return type ; } protected void doTestForVarReferences ( String contents , int offsetInParent , String matchName , int declStart , MatchRegion [ ] matchLocations ) throws JavaModelException { String className = "<STR_LIT>" ; String matchedVarName = "<STR_LIT>" ; GroovyCompilationUnit unit = createUnit ( className , contents ) ; ILocalVariable var = ReflectionUtils . createLocalVariable ( findType ( className , unit ) . getChildren ( ) [ offsetInParent ] , matchedVarName , declStart , Signature . SIG_INT ) ; SearchPattern pattern = SearchPattern . createPattern ( var , IJavaSearchConstants . REFERENCES ) ; checkLocalVarMatches ( contents , matchName , pattern , unit , matchLocations ) ; } private void checkLocalVarMatches ( String contents , String matchName , SearchPattern pattern , GroovyCompilationUnit unit , MatchRegion [ ] matchLocations ) { MockPossibleMatch match = new MockPossibleMatch ( unit ) ; ITypeRequestor typeRequestor = new TypeRequestorFactory ( ) . createRequestor ( match , pattern , searchRequestor ) ; TypeInferencingVisitorWithRequestor visitor = factory . createVisitor ( match ) ; visitor . visitCompilationUnit ( typeRequestor ) ; assertEquals ( "<STR_LIT>" + matchLocations . length + "<STR_LIT>" + searchRequestor . printMatches ( ) , matchLocations . length , searchRequestor . matches . size ( ) ) ; for ( int i = <NUM_LIT:0> ; i < matchLocations . length ; i ++ ) { assertLocation ( searchRequestor . getMatch ( i ) , matchLocations [ i ] . offset , matchLocations [ i ] . length ) ; } } private void checkMatches ( String secondContents , String matchText , SearchPattern pattern , GroovyCompilationUnit second , IJavaElement firstMatchEnclosingElement , IJavaElement secondMatchEnclosingElement ) { MockPossibleMatch match = new MockPossibleMatch ( second ) ; ITypeRequestor typeRequestor = new TypeRequestorFactory ( ) . createRequestor ( match , pattern , searchRequestor ) ; TypeInferencingVisitorWithRequestor visitor = factory . createVisitor ( match ) ; visitor . visitCompilationUnit ( typeRequestor ) ; assertEquals ( "<STR_LIT>" + searchRequestor . printMatches ( ) , <NUM_LIT:2> , searchRequestor . matches . size ( ) ) ; assertEquals ( "<STR_LIT>" + searchRequestor . printMatches ( ) , firstMatchEnclosingElement , searchRequestor . getElementNumber ( <NUM_LIT:0> ) ) ; assertLocation ( searchRequestor . getMatch ( <NUM_LIT:0> ) , secondContents . indexOf ( matchText ) , matchText . length ( ) ) ; assertEquals ( "<STR_LIT>" + searchRequestor . printMatches ( ) , secondMatchEnclosingElement , searchRequestor . getElementNumber ( <NUM_LIT:1> ) ) ; assertLocation ( searchRequestor . getMatch ( <NUM_LIT:1> ) , secondContents . lastIndexOf ( matchText ) , matchText . length ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . search ; import org . codehaus . jdt . groovy . model . GroovyCompilationUnit ; import org . eclipse . jdt . core . search . SearchMatch ; import org . eclipse . jdt . internal . core . search . JavaSearchDocument ; import org . eclipse . jdt . internal . core . search . JavaSearchParticipant ; import org . eclipse . jdt . internal . core . search . matching . PossibleMatch ; public class MockPossibleMatch extends PossibleMatch { public MockPossibleMatch ( GroovyCompilationUnit unit ) { super ( null , unit . getResource ( ) , unit , new JavaSearchDocument ( unit . getResource ( ) . getFullPath ( ) . toPortableString ( ) , new JavaSearchParticipant ( ) ) , false ) ; } static String printMatch ( SearchMatch match ) { return "<STR_LIT>" + match . getOffset ( ) + "<STR_LIT:U+002CU+0020>" + match . getLength ( ) + "<STR_LIT>" + accuracy ( match ) + "<STR_LIT>" + match . getElement ( ) + "<STR_LIT:n>" ; } static String accuracy ( SearchMatch match ) { return match . getAccuracy ( ) == SearchMatch . A_ACCURATE ? "<STR_LIT>" : "<STR_LIT>" ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . search ; import junit . framework . Test ; public class StaticInferencingTests extends AbstractInferencingTest { public static Test suite ( ) { return buildTestSuite ( StaticInferencingTests . class ) ; } public StaticInferencingTests ( String name ) { super ( name ) ; } public void testClassReference1 ( ) throws Exception { String contents = "<STR_LIT:String>" ; assertType ( contents , "<STR_LIT>" ) ; } public void testClassReference2 ( ) throws Exception { String contents = "<STR_LIT>" ; assertType ( contents , "<STR_LIT>" ) ; } public void testClassReference3 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . indexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testClassReference4 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . indexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testClassReference5 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . indexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testClassReference6 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . indexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testClassReference7 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . indexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testClassReference8 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . indexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testNonStaticReference1 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . indexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertUnknownConfidence ( contents , start , end , "<STR_LIT>" , false ) ; } public void testNonStaticReference2 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . indexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertUnknownConfidence ( contents , start , end , "<STR_LIT>" , false ) ; } public void testNonStaticReference3 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertUnknownConfidence ( contents , start , end , "<STR_LIT>" , false ) ; } public void testNonStaticReference4 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertUnknownConfidence ( contents , start , end , "<STR_LIT>" , false ) ; } public void testNonStaticReference5 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertUnknownConfidence ( contents , start , end , "<STR_LIT>" , false ) ; } public void testNonStaticReference6 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertUnknownConfidence ( contents , start , end , "<STR_LIT>" , false ) ; } public void testNonStaticReference7 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertUnknownConfidence ( contents , start , end , "<STR_LIT>" , false ) ; } public void testNonStaticReference8 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertUnknownConfidence ( contents , start , end , "<STR_LIT>" , false ) ; } public void testStaticReference1 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" , false ) ; } public void testStaticImport1 ( ) throws Exception { createUnit ( "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" ) ; String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" , false ) ; } public void testStaticImport2 ( ) throws Exception { createUnit ( "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" ) ; String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" , false ) ; } public void testStaticImport3 ( ) throws Exception { createUnit ( "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" ) ; String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" , false ) ; } public void testStaticImport4 ( ) throws Exception { createUnit ( "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" ) ; String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertUnknownConfidence ( contents , start , end , "<STR_LIT>" , false ) ; } public void testStaticImport5 ( ) throws Exception { createUnit ( "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" ) ; String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertUnknownConfidence ( contents , start , end , "<STR_LIT>" , false ) ; } public void testStaticImport6 ( ) throws Exception { createUnit ( "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" ) ; String contents = "<STR_LIT>" ; int start = contents . indexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" , false ) ; start = contents . lastIndexOf ( "<STR_LIT>" ) ; end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" , false ) ; } public void testStaticImport7 ( ) throws Exception { createUnit ( "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" ) ; String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" , false ) ; } public void testStaticImport8 ( ) throws Exception { createUnit ( "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" ) ; String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" , false ) ; } public void testStaticImport9 ( ) throws Exception { createUnit ( "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" ) ; String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" , false ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . search ; import java . util . List ; import junit . framework . Test ; import org . codehaus . groovy . ast . ASTNode ; import org . codehaus . jdt . groovy . model . GroovyCompilationUnit ; import org . eclipse . jdt . core . tests . util . GroovyUtils ; import org . eclipse . jdt . groovy . search . TypeInferencingVisitorWithRequestor ; public class InferencingTests extends AbstractInferencingTest { private static final String GET_AT = "<STR_LIT>" ; public static Test suite ( ) { return buildTestSuite ( InferencingTests . class ) ; } public InferencingTests ( String name ) { super ( name ) ; } public void testLocalVar1 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertUnknownConfidence ( contents , start , end , "<STR_LIT>" , false ) ; } public void testLocalVar2 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertUnknownConfidence ( contents , start , end , "<STR_LIT>" , false ) ; } public void testLocalVar2a ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertUnknownConfidence ( contents , start , end , "<STR_LIT>" , false ) ; } public void testLocalVar3 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testLocalVar4 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testLocalMethod1 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testLocalMethod2 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testLocalMethod3 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testLocalMethod4 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testLocalMethod5 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testLocalMethod6 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertUnknownConfidence ( contents , start , end , "<STR_LIT>" , false ) ; } public void testLocalMethod7 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertUnknownConfidence ( contents , start , end , "<STR_LIT>" , false ) ; } public void testInferNumber1 ( ) throws Exception { assertType ( "<STR_LIT:10>" , "<STR_LIT>" ) ; } public void testInferNumber1a ( ) throws Exception { assertType ( "<STR_LIT>" , <NUM_LIT:0> , <NUM_LIT:2> , "<STR_LIT>" ) ; } public void testInferNumber2 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInferNumber3 ( ) throws Exception { assertType ( "<STR_LIT>" , "<STR_LIT>" ) ; } public void testInferNumber4 ( ) throws Exception { assertType ( "<STR_LIT>" , "<STR_LIT>" ) ; } public void testInferNumber5 ( ) throws Exception { assertType ( "<STR_LIT>" , "<STR_LIT>" ) ; } public void testInferNumber6 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . indexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInferString1 ( ) throws Exception { assertType ( "<STR_LIT>" , "<STR_LIT>" ) ; } public void testInferString2 ( ) throws Exception { assertType ( "<STR_LIT>" , "<STR_LIT>" ) ; } public void testInferString3 ( ) throws Exception { String contents = "<STR_LIT>" ; assertType ( contents , contents . indexOf ( '<STR_LIT>' ) , contents . lastIndexOf ( '<STR_LIT>' ) + <NUM_LIT:1> , "<STR_LIT>" ) ; } public void testInferString4 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testMatcher1 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testMatcher2 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . indexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testPattern ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInferList1 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInferList2 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInferClosure1 ( ) throws Exception { assertType ( "<STR_LIT>" , "<STR_LIT>" ) ; } public void testSpread1 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:value>" ) ; assertType ( contents , start , start + "<STR_LIT:value>" . length ( ) , "<STR_LIT>" ) ; } public void testSpread2 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; assertType ( contents , start , start + "<STR_LIT>" . length ( ) , "<STR_LIT>" ) ; } public void testSpread3 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:value>" ) ; assertType ( contents , start , start + "<STR_LIT:value>" . length ( ) , "<STR_LIT>" ) ; } public void testSpread4 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; assertType ( contents , start , start + "<STR_LIT>" . length ( ) , "<STR_LIT>" ) ; } public void testSpread5 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; assertType ( contents , start , start + "<STR_LIT>" . length ( ) , "<STR_LIT>" ) ; } public void testSpread6 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:key>" ) ; assertType ( contents , start , start + "<STR_LIT:key>" . length ( ) , "<STR_LIT>" ) ; } public void testSpread7 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:value>" ) ; assertType ( contents , start , start + "<STR_LIT:value>" . length ( ) , "<STR_LIT>" ) ; } public void testSpread8 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; assertType ( contents , start , start + "<STR_LIT>" . length ( ) , "<STR_LIT>" ) ; } public void testSpread9 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; assertType ( contents , start , start + "<STR_LIT>" . length ( ) , "<STR_LIT>" ) ; } public void testSpread10 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:value>" ) ; assertType ( contents , start , start + "<STR_LIT:value>" . length ( ) , "<STR_LIT>" ) ; } public void testInferMap1 ( ) throws Exception { assertType ( "<STR_LIT>" , "<STR_LIT>" ) ; } public void testInferBoolean1 ( ) throws Exception { assertType ( "<STR_LIT>" , "<STR_LIT>" ) ; } public void testInferBoolean2 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . indexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInferBoolean3 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . indexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInferBoolean4 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . indexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInferBoolean5 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . indexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInferBoolean6 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . indexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInferBoolean7 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . indexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testStaticMethodCall ( ) throws Exception { String contents = "<STR_LIT>" ; String expr = "<STR_LIT:x>" ; assertType ( contents , contents . indexOf ( expr ) , contents . indexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testStaticMethodCall2 ( ) throws Exception { String contents = "<STR_LIT>" ; String expr = "<STR_LIT:x>" ; assertType ( contents , contents . indexOf ( expr ) , contents . indexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testStaticMethodCall3 ( ) throws Exception { String contents = "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . indexOf ( expr ) , contents . indexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testStaticMethodCall4 ( ) throws Exception { String contents = "<STR_LIT>" ; String expr = "<STR_LIT:x>" ; assertType ( contents , contents . indexOf ( expr ) , contents . indexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testStaticMethodCall5 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; String expr = "<STR_LIT>" ; assertDeclaringType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testStaticMethodCall6 ( ) throws Exception { createUnit ( "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; String expr = "<STR_LIT>" ; assertDeclaringType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testSuperFieldReference ( ) throws Exception { String contents = "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . indexOf ( expr ) , contents . indexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testInferFieldWithInitializer1 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( '<CHAR_LIT>' ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInferFieldWithInitializer2 ( ) throws Exception { createUnit ( "<STR_LIT:A>" , "<STR_LIT>" ) ; String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( '<CHAR_LIT>' ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testTernaryExpression ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testElvisOperator ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testRangeExpression1 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testRangeExpression2 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + "<STR_LIT:x>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testRangeExpression3 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testRangeExpression4 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testRangeExpression5 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testRangeExpression6 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInnerClass1 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + <NUM_LIT:1> ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInnerClass2 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + <NUM_LIT:1> ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInnerClass3 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . indexOf ( "<STR_LIT:x>" ) ; int end = start + <NUM_LIT:1> ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInnerClass4 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . indexOf ( "<STR_LIT:x>" ) ; int end = start + <NUM_LIT:1> ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInnerClass5 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInnerClass6 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testConstantFromSuper ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testAssignementInInnerBlock ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testAssignementInInnerBlock2 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testOverrideCategory1 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( GET_AT ) ; int end = start + GET_AT . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; assertDeclaringType ( contents , start , end , "<STR_LIT>" ) ; } public void testOverrideCategory2 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( GET_AT ) ; int end = start + GET_AT . length ( ) ; assertType ( contents , start , end , "<STR_LIT:A>" ) ; assertDeclaringType ( contents , start , end , "<STR_LIT:A>" ) ; } public void testOverrideCategory3 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( GET_AT ) ; int end = start + GET_AT . length ( ) ; assertType ( contents , start , end , "<STR_LIT:A>" ) ; assertDeclaringType ( contents , start , end , "<STR_LIT:A>" ) ; } public void testGRECLIPSE731a ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testGRECLIPSE731b ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testGRECLIPSE731c ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testGRECLIPSE731d ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testGRECLIPSE731e ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testGRECLIPSE731f ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } private final static String catchString = "<STR_LIT>" ; private final static String catchString2 = "<STR_LIT>" ; private final static String npe = "<STR_LIT>" ; public void testCatchBlock1 ( ) throws Exception { int start = catchString . lastIndexOf ( npe ) ; int end = start + npe . length ( ) ; assertType ( catchString , start , end , "<STR_LIT>" ) ; } public void testCatchBlock2 ( ) throws Exception { int start = catchString . lastIndexOf ( "<STR_LIT:e>" ) ; int end = start + <NUM_LIT:1> ; assertType ( catchString , start , end , "<STR_LIT>" ) ; } public void testCatchBlock3 ( ) throws Exception { int start = catchString . indexOf ( npe + "<STR_LIT>" ) ; int end = start + ( npe + "<STR_LIT>" ) . length ( ) ; assertType ( catchString , start , end , "<STR_LIT>" ) ; } public void testCatchBlock4 ( ) throws Exception { int start = catchString2 . indexOf ( "<STR_LIT:e>" ) ; int end = start + <NUM_LIT:1> ; assertType ( catchString2 , start , end , "<STR_LIT>" ) ; } public void testCatchBlock5 ( ) throws Exception { int start = catchString2 . lastIndexOf ( "<STR_LIT:e>" ) ; int end = start + <NUM_LIT:1> ; assertType ( catchString2 , start , end , "<STR_LIT>" ) ; } public void testAssignment1 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + <NUM_LIT:1> ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testAssignment2 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + <NUM_LIT:1> ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testAssignment3 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + <NUM_LIT:1> ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testAssignment4 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + <NUM_LIT:1> ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testAssignment5 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int end = start + <NUM_LIT:1> ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInClosure1 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInClosure2 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInClosure2a ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInClosure2b ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInClosure2c ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; if ( GroovyUtils . GROOVY_LEVEL > <NUM_LIT> ) { assertType ( contents , start , end , "<STR_LIT>" ) ; } else { assertType ( contents , start , end , "<STR_LIT>" ) ; } } public void testInClosure3 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInClosure4 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInClosure5 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInClosure6 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertUnknownConfidence ( contents , start , end , "<STR_LIT>" , false ) ; } public void testInClosure7 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" , false ) ; } public void testClosure4 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testClosure5 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; start = contents . lastIndexOf ( "<STR_LIT>" ) ; end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; start = contents . lastIndexOf ( "<STR_LIT>" ) ; end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; start = contents . lastIndexOf ( "<STR_LIT>" ) ; end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testClosure6 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; start = contents . lastIndexOf ( "<STR_LIT>" ) ; end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; start = contents . lastIndexOf ( "<STR_LIT>" ) ; end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; start = contents . lastIndexOf ( "<STR_LIT>" ) ; end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testClosure7 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; start = contents . lastIndexOf ( "<STR_LIT>" ) ; end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; start = contents . lastIndexOf ( "<STR_LIT>" ) ; end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; start = contents . lastIndexOf ( "<STR_LIT>" ) ; end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInClosureDeclaringType1 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; assertDeclaringType ( contents , start , end , "<STR_LIT>" ) ; } public void testInClosureDeclaringType2 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertDeclaringType ( contents , start , end , "<STR_LIT>" , false , true ) ; } public void testInClosureDeclaringType3 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertDeclaringType ( contents , start , end , "<STR_LIT>" , false , true ) ; } public void testInClosureDeclaringType4 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertDeclaringType ( contents , start , end , "<STR_LIT>" , false ) ; } public void testInClosureDeclaringType5 ( ) throws Exception { if ( GroovyUtils . GROOVY_LEVEL > <NUM_LIT> ) { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertDeclaringType ( contents , start , end , "<STR_LIT>" , false ) ; } } public void testInClassDeclaringType1 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertDeclaringType ( contents , start , end , "<STR_LIT>" , false , true ) ; } public void testInClassDeclaringType2 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertDeclaringType ( contents , start , end , "<STR_LIT>" , false , true ) ; } public void testDoubleClosure1 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:U+0020U+0020}>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDoubleClosure2 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:U+0020U+0020}>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDoubleClosure2a ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:U+0020U+0020}>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDoubleClosure3 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:U+0020U+0020}>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDoubleClosure4 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:U+0020U+0020}>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDoubleClosure5 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:U+0020U+0020}>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDoubleClosure6 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:U+0020U+0020}>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertUnknownConfidence ( contents , start , end , "<STR_LIT>" , false ) ; } public void testDoubleClosure7 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:U+0020U+0020}>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testInScriptDeclaringType ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertDeclaringType ( contents , start , end , "<STR_LIT>" , false , true ) ; } public void testStaticImports1 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testStaticImports2 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testStaticImports3 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testStaticImports4 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM1 ( ) throws Exception { String contents = "<STR_LIT>" ; String lookFor = "<STR_LIT>" ; int start = contents . indexOf ( lookFor ) ; int end = start + lookFor . length ( ) ; assertDeclaringType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM2 ( ) throws Exception { String contents = "<STR_LIT>" ; String lookFor = "<STR_LIT>" ; int start = contents . indexOf ( lookFor ) ; int end = start + lookFor . length ( ) ; assertDeclaringType ( contents , start , end , "<STR_LIT>" ) ; } public void testDGM3 ( ) throws Exception { String contents = "<STR_LIT>" ; String lookFor = "<STR_LIT>" ; int start = contents . indexOf ( lookFor ) ; int end = start + lookFor . length ( ) ; assertDeclaringType ( contents , start , end , "<STR_LIT>" ) ; } private static final String CONTENTS_GETAT1 = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; private static final String CONTENTS_GETAT2 = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; public void testGetAt1 ( ) throws Exception { int start = CONTENTS_GETAT1 . indexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertDeclaringType ( CONTENTS_GETAT1 , start , end , "<STR_LIT>" ) ; } public void testGetAt2 ( ) throws Exception { int start = CONTENTS_GETAT1 . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertDeclaringType ( CONTENTS_GETAT1 , start , end , "<STR_LIT>" ) ; } public void testGetAt3 ( ) throws Exception { int start = CONTENTS_GETAT2 . indexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertDeclaringType ( CONTENTS_GETAT2 , start , end , "<STR_LIT>" , false , true ) ; } public void testGetAt4 ( ) throws Exception { int start = CONTENTS_GETAT2 . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertDeclaringType ( CONTENTS_GETAT2 , start , end , "<STR_LIT>" , false , true ) ; } public void testCategoryMethodAsField ( ) throws Exception { String contents = "<STR_LIT>" ; int textStart = contents . indexOf ( "<STR_LIT:text>" ) ; int textEnd = textStart + "<STR_LIT:text>" . length ( ) ; if ( GroovyUtils . GROOVY_LEVEL >= <NUM_LIT:20> ) { assertDeclaringType ( contents , textStart , textEnd , "<STR_LIT>" ) ; } else { assertDeclaringType ( contents , textStart , textEnd , "<STR_LIT>" ) ; } } public void testClassReference1 ( ) throws Exception { String contents = "<STR_LIT:String>" ; assertDeclaringType ( contents , <NUM_LIT:0> , contents . length ( ) , "<STR_LIT>" ) ; } public void testClassReference2 ( ) throws Exception { String contents = "<STR_LIT>" ; int textStart = contents . indexOf ( "<STR_LIT>" ) ; int textEnd = textStart + "<STR_LIT>" . length ( ) ; assertDeclaringType ( contents , textStart , textEnd , "<STR_LIT>" , false , true ) ; } public void testClassReference3 ( ) throws Exception { String contents = "<STR_LIT>" ; int textStart = contents . indexOf ( "<STR_LIT>" ) ; int textEnd = textStart + "<STR_LIT>" . length ( ) ; assertType ( contents , textStart , textEnd , "<STR_LIT>" ) ; } public void testClassReference4 ( ) throws Exception { String contents = "<STR_LIT>" ; int textStart = contents . indexOf ( "<STR_LIT>" ) ; int textEnd = textStart + "<STR_LIT>" . length ( ) ; assertType ( contents , textStart , textEnd , "<STR_LIT>" ) ; } public void testClassReference5 ( ) throws Exception { String contents = "<STR_LIT>" ; int textStart = contents . indexOf ( "<STR_LIT>" ) ; int textEnd = textStart + "<STR_LIT>" . length ( ) ; assertType ( contents , textStart , textEnd , "<STR_LIT>" ) ; } public void testClassReference6 ( ) throws Exception { String contents = "<STR_LIT>" ; int textStart = contents . indexOf ( "<STR_LIT>" ) ; int textEnd = textStart + "<STR_LIT>" . length ( ) ; assertDeclaringType ( contents , textStart , textEnd , "<STR_LIT>" , false , false ) ; } public void testMultiDecl1 ( ) throws Exception { String contents = "<STR_LIT>" ; int xStart = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int yStart = contents . lastIndexOf ( "<STR_LIT:y>" ) ; assertType ( contents , xStart , xStart + <NUM_LIT:1> , "<STR_LIT>" ) ; assertType ( contents , yStart , yStart + <NUM_LIT:1> , "<STR_LIT>" ) ; } public void testMultiDecl2 ( ) throws Exception { String contents = "<STR_LIT>" ; int xStart = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int yStart = contents . lastIndexOf ( "<STR_LIT:y>" ) ; assertType ( contents , xStart , xStart + <NUM_LIT:1> , "<STR_LIT>" ) ; assertType ( contents , yStart , yStart + <NUM_LIT:1> , "<STR_LIT>" ) ; } public void testMultiDecl3 ( ) throws Exception { String contents = "<STR_LIT>" ; int xStart = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int yStart = contents . lastIndexOf ( "<STR_LIT:y>" ) ; assertType ( contents , xStart , xStart + <NUM_LIT:1> , "<STR_LIT>" ) ; assertType ( contents , yStart , yStart + <NUM_LIT:1> , "<STR_LIT>" ) ; } public void testMultiDecl4 ( ) throws Exception { String contents = "<STR_LIT>" ; int xStart = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int yStart = contents . lastIndexOf ( "<STR_LIT:y>" ) ; assertType ( contents , xStart , xStart + <NUM_LIT:1> , "<STR_LIT>" ) ; assertType ( contents , yStart , yStart + <NUM_LIT:1> , "<STR_LIT>" ) ; } public void testMultiDecl6 ( ) throws Exception { String contents = "<STR_LIT>" ; int xStart = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int yStart = contents . lastIndexOf ( "<STR_LIT:y>" ) ; assertType ( contents , xStart , xStart + <NUM_LIT:1> , "<STR_LIT>" ) ; assertType ( contents , yStart , yStart + <NUM_LIT:1> , "<STR_LIT>" ) ; } public void testMultiDecl7 ( ) throws Exception { String contents = "<STR_LIT>" ; int xStart = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int yStart = contents . lastIndexOf ( "<STR_LIT:y>" ) ; assertType ( contents , xStart , xStart + <NUM_LIT:1> , "<STR_LIT>" ) ; assertType ( contents , yStart , yStart + <NUM_LIT:1> , "<STR_LIT>" ) ; } public void testMultiDecl8 ( ) throws Exception { String contents = "<STR_LIT>" ; int xStart = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int yStart = contents . lastIndexOf ( "<STR_LIT:y>" ) ; assertType ( contents , xStart , xStart + <NUM_LIT:1> , "<STR_LIT>" ) ; assertType ( contents , yStart , yStart + <NUM_LIT:1> , "<STR_LIT>" ) ; } public void testMultiDecl9 ( ) throws Exception { String contents = "<STR_LIT>" ; int xStart = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int yStart = contents . lastIndexOf ( "<STR_LIT:y>" ) ; assertType ( contents , xStart , xStart + <NUM_LIT:1> , "<STR_LIT>" ) ; assertType ( contents , yStart , yStart + <NUM_LIT:1> , "<STR_LIT>" ) ; } public void testMultiDecl10 ( ) throws Exception { String contents = "<STR_LIT>" ; int xStart = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int yStart = contents . lastIndexOf ( "<STR_LIT:y>" ) ; assertType ( contents , xStart , xStart + <NUM_LIT:1> , "<STR_LIT>" ) ; assertType ( contents , yStart , yStart + <NUM_LIT:1> , "<STR_LIT>" ) ; } public void testMultiDecl11 ( ) throws Exception { String contents = "<STR_LIT>" ; int xStart = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int yStart = contents . lastIndexOf ( "<STR_LIT:y>" ) ; assertType ( contents , xStart , xStart + <NUM_LIT:1> , "<STR_LIT>" ) ; assertType ( contents , yStart , yStart + <NUM_LIT:1> , "<STR_LIT>" ) ; } public void testMultiDecl12 ( ) throws Exception { String contents = "<STR_LIT>" ; int xStart = contents . lastIndexOf ( "<STR_LIT:x>" ) ; int yStart = contents . lastIndexOf ( "<STR_LIT:y>" ) ; assertType ( contents , xStart , xStart + <NUM_LIT:1> , "<STR_LIT>" ) ; assertType ( contents , yStart , yStart + <NUM_LIT:1> , "<STR_LIT>" ) ; } public void testAsExpression1 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; assertType ( contents , start , start + "<STR_LIT>" . length ( ) , "<STR_LIT>" ) ; } public void testAsExpression2 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:x>" ) ; assertType ( contents , start , start + "<STR_LIT:x>" . length ( ) , "<STR_LIT>" ) ; } public void testImplicitVar1 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; assertUnknownConfidence ( contents , start , start + "<STR_LIT>" . length ( ) , "<STR_LIT>" , false ) ; } public void testImplicitVar2 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; assertUnknownConfidence ( contents , start , start + "<STR_LIT>" . length ( ) , "<STR_LIT>" , false ) ; } public void testImplicitVar3 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; assertUnknownConfidence ( contents , start , start + "<STR_LIT>" . length ( ) , "<STR_LIT>" , false ) ; } public void testImplicitVar4 ( ) throws Exception { String contents = "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; assertDeclaringType ( contents , start , start + "<STR_LIT>" . length ( ) , "<STR_LIT>" , false ) ; } public void testImplicitVar5 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; assertDeclaringType ( contents , start , start + "<STR_LIT>" . length ( ) , "<STR_LIT>" , false ) ; } public void testImplicitVar6 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; assertDeclaringType ( contents , start , start + "<STR_LIT>" . length ( ) , "<STR_LIT>" , false ) ; } public void testImplicitVar7 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; assertUnknownConfidence ( contents , start , start + "<STR_LIT>" . length ( ) , "<STR_LIT>" , false ) ; } public void testNested1 ( ) throws Exception { String contents = "<STR_LIT>" ; assertType ( contents , "<STR_LIT>" ) ; } public void testNested2 ( ) throws Exception { String contents = "<STR_LIT>" ; assertType ( contents , "<STR_LIT>" ) ; } public void testNested3 ( ) throws Exception { String contents = "<STR_LIT>" ; assertType ( contents , "<STR_LIT>" ) ; } public void testNested4 ( ) throws Exception { createUnit ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; String contents = "<STR_LIT>" ; assertType ( contents , "<STR_LIT>" ) ; } public void testPostfix ( ) throws Exception { if ( GroovyUtils . GROOVY_LEVEL > <NUM_LIT> ) { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( '<CHAR_LIT>' ) ; assertType ( contents , start , start + <NUM_LIT:1> , "<STR_LIT>" ) ; } } public void testNothingIsUnknown ( ) throws Exception { assertNoUnknowns ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; } public void testNothingIsUnknownWithCategories ( ) throws Exception { assertNoUnknowns ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; } public void testNoGString1 ( ) throws Exception { assertNoUnknowns ( "<STR_LIT>" ) ; } public void testClosureReferencesSuperClass ( ) throws Exception { assertNoUnknowns ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; } public void testDeclarationAtBeginningOfMethod ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } protected void assertNoUnknowns ( String contents ) { GroovyCompilationUnit unit = createUnit ( "<STR_LIT>" , contents ) ; TypeInferencingVisitorWithRequestor visitor = factory . createVisitor ( unit ) ; visitor . DEBUG = true ; UnknownTypeRequestor requestor = new UnknownTypeRequestor ( ) ; visitor . visitCompilationUnit ( requestor ) ; List < ASTNode > unknownNodes = requestor . getUnknownNodes ( ) ; assertTrue ( "<STR_LIT>" + unknownNodes , unknownNodes . isEmpty ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . search ; import junit . framework . Test ; public class JDTPropertyNodeInferencingTests extends AbstractInferencingTest { public static Test suite ( ) { return buildTestSuite ( JDTPropertyNodeInferencingTests . class ) ; } public JDTPropertyNodeInferencingTests ( String name ) { super ( name ) ; } @ Override protected void setUp ( ) throws Exception { super . setUp ( ) ; createJavaUnit ( "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; } public void testNodeFromJava1 ( ) throws Exception { String contents = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( '<CHAR_LIT>' ) , contents . lastIndexOf ( '<CHAR_LIT>' ) + <NUM_LIT:1> , "<STR_LIT>" ) ; } public void testPropertyNodeFromJava1 ( ) throws Exception { String contents = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( "<STR_LIT:foo>" ) , contents . length ( ) , "<STR_LIT>" ) ; } public void testPropertyNodeFromJava2 ( ) throws Exception { String contents = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( '<CHAR_LIT>' ) , contents . lastIndexOf ( '<CHAR_LIT>' ) + <NUM_LIT:1> , "<STR_LIT>" ) ; } public void testPropertyNodeFromJava3 ( ) throws Exception { String contents = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( '<CHAR_LIT>' ) , contents . lastIndexOf ( '<CHAR_LIT>' ) + <NUM_LIT:1> , "<STR_LIT>" ) ; } public void testPropertyNodeFromJava4 ( ) throws Exception { String contents = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( "<STR_LIT:foo>" ) , contents . lastIndexOf ( "<STR_LIT:foo>" ) + "<STR_LIT:foo>" . length ( ) , "<STR_LIT>" ) ; } public void testPropertyNodeReferenceInBinary1 ( ) throws Exception { String contents = "<STR_LIT>" ; env . addJar ( project . getFullPath ( ) , "<STR_LIT>" ) ; assertType ( contents , contents . lastIndexOf ( "<STR_LIT>" ) , contents . lastIndexOf ( "<STR_LIT>" ) + "<STR_LIT>" . length ( ) , "<STR_LIT>" ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . search ; import junit . framework . Test ; import junit . framework . TestSuite ; public class AllSearchTests { public static Test suite ( ) throws Exception { TestSuite suite = new TestSuite ( "<STR_LIT>" ) ; suite . addTestSuite ( TypeReferenceSearchTests . class ) ; suite . addTestSuite ( FieldReferenceSearchTests . class ) ; suite . addTestSuite ( MethodReferenceSearchTests . class ) ; suite . addTestSuite ( CategorySearchTests . class ) ; suite . addTestSuite ( InferencingTests . class ) ; suite . addTestSuite ( StaticInferencingTests . class ) ; suite . addTestSuite ( GenericInferencingTests . class ) ; suite . addTestSuite ( DGMInferencingTests . class ) ; suite . addTestSuite ( LocalVariableReferenceSearchTests . class ) ; suite . addTestSuite ( JDTPropertyNodeInferencingTests . class ) ; suite . addTestSuite ( DeclarationInferencingTests . class ) ; suite . addTestSuite ( OperatorOverloadingInferencingTests . class ) ; suite . addTestSuite ( SyntheticAccessorInferencingTests . class ) ; suite . addTestSuite ( Groovy20InferencingTests . class ) ; suite . addTestSuite ( GenericsMappingTest . class ) ; return suite ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . search ; public class DeclarationInferencingTests extends AbstractInferencingTest { public DeclarationInferencingTests ( String name ) { super ( name ) ; } public void testGettersAndField1 ( ) throws Exception { createUnit ( "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; String contents = "<STR_LIT>" ; int start = contents . indexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertDeclaration ( contents , start , end , "<STR_LIT>" , "<STR_LIT>" , DeclarationKind . PROPERTY ) ; } public void testGettersAndField2 ( ) throws Exception { createUnit ( "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; String contents = "<STR_LIT>" ; int start = contents . indexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertDeclaration ( contents , start , end , "<STR_LIT>" , "<STR_LIT>" , DeclarationKind . METHOD ) ; } public void testGettersAndField3 ( ) throws Exception { createUnit ( "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; String contents = "<STR_LIT>" ; int start = contents . indexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertDeclaration ( contents , start , end , "<STR_LIT>" , "<STR_LIT>" , DeclarationKind . METHOD ) ; } public void testGettersAndField4 ( ) throws Exception { createUnit ( "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; String contents = "<STR_LIT>" ; int start = contents . indexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertDeclaration ( contents , start , end , "<STR_LIT>" , "<STR_LIT>" , DeclarationKind . PROPERTY ) ; } public void testGettersAndField5 ( ) throws Exception { createUnit ( "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertDeclaration ( contents , start , end , "<STR_LIT>" , "<STR_LIT>" , DeclarationKind . PROPERTY ) ; } public void testGettersAndField6 ( ) throws Exception { createUnit ( "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertDeclaration ( contents , start , end , "<STR_LIT>" , "<STR_LIT>" , DeclarationKind . PROPERTY ) ; } public void testMethodAndFieldWithSameName1 ( ) throws Exception { createUnit ( "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; String contents = "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:field>" ) ; int end = start + "<STR_LIT:field>" . length ( ) ; assertDeclaration ( contents , start , end , "<STR_LIT:A>" , "<STR_LIT:field>" , DeclarationKind . METHOD ) ; } public void testMethodAndFieldWithSameName2 ( ) throws Exception { createUnit ( "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; String contents = "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:field>" ) ; int end = start + "<STR_LIT:field>" . length ( ) ; assertDeclaration ( contents , start , end , "<STR_LIT:A>" , "<STR_LIT:field>" , DeclarationKind . PROPERTY ) ; } public void testMethodAndFieldWithSameName3 ( ) throws Exception { createUnit ( "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; String contents = "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:field>" ) ; int end = start + "<STR_LIT:field>" . length ( ) ; assertDeclaration ( contents , start , end , "<STR_LIT:A>" , "<STR_LIT:field>" , DeclarationKind . PROPERTY ) ; } public void testMethodAndFieldWithSameName4 ( ) throws Exception { createUnit ( "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; String contents = "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:field>" ) ; int end = start + "<STR_LIT:field>" . length ( ) ; assertUnknownConfidence ( contents , start , end , "<STR_LIT:A>" , false ) ; } public void testMethodAndFieldWithSameName5 ( ) throws Exception { createUnit ( "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; String contents = "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertDeclaration ( contents , start , end , "<STR_LIT:A>" , "<STR_LIT>" , DeclarationKind . METHOD ) ; } public void testMethodAndFieldWithSameName6 ( ) throws Exception { createUnit ( "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; String contents = "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertDeclaration ( contents , start , end , "<STR_LIT:A>" , "<STR_LIT>" , DeclarationKind . METHOD ) ; } public void testMethodAndFieldWithSameName7 ( ) throws Exception { createUnit ( "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; String contents = "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:field>" ) ; int end = start + "<STR_LIT:field>" . length ( ) ; assertDeclaration ( contents , start , end , "<STR_LIT:A>" , "<STR_LIT:field>" , DeclarationKind . PROPERTY ) ; } public void testMethodAndFieldWithSameName8 ( ) throws Exception { createUnit ( "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; String contents = "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:field>" ) ; int end = start + "<STR_LIT:field>" . length ( ) ; assertDeclaration ( contents , start , end , "<STR_LIT:A>" , "<STR_LIT:field>" , DeclarationKind . METHOD ) ; } public void testMethodAndFieldWithSameName9 ( ) throws Exception { createUnit ( "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; String contents = "<STR_LIT>" + "<STR_LIT>" ; int start = contents . lastIndexOf ( "<STR_LIT:field>" ) ; int end = start + "<STR_LIT:field>" . length ( ) ; assertDeclaration ( contents , start , end , "<STR_LIT:A>" , "<STR_LIT:field>" , DeclarationKind . PROPERTY ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . search ; import junit . framework . Test ; public class OperatorOverloadingInferencingTests extends AbstractInferencingTest { public static Test suite ( ) { return buildTestSuite ( OperatorOverloadingInferencingTests . class ) ; } public OperatorOverloadingInferencingTests ( String name ) { super ( name ) ; } public void testPlus1 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testPlus2 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testMinus ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testPlus3 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testMinus2 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testMultiply ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testDivide ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testMod ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testAnd ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testOr ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testXor ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testRightShift ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testLeftShift ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testGetAt1 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testGetAt2 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testGetAt3 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testGetAt4 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testGetAt5 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testGetAt6 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testGetAt7 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testGetAt8 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testGetAt9 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testAttributeExpr1 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testAttributeExpr2 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testLongExpr1 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testLongExpr2 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testLongExpr3 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testNumberPlusString1 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testNumberPlusString2 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testCompleteExpr1 ( ) throws Exception { assertType ( "<STR_LIT>" , "<STR_LIT>" ) ; } public void testCompleteExpr2 ( ) throws Exception { assertType ( "<STR_LIT>" , "<STR_LIT>" ) ; } public void testCompleteExpr3 ( ) throws Exception { assertType ( "<STR_LIT>" , "<STR_LIT>" ) ; } public void testCompleteExpr4 ( ) throws Exception { assertType ( "<STR_LIT>" , "<STR_LIT>" ) ; } public void testCompleteExpr5 ( ) throws Exception { assertType ( "<STR_LIT>" , "<STR_LIT>" ) ; } public void testCompleteExpr6 ( ) throws Exception { assertType ( "<STR_LIT>" , "<STR_LIT>" ) ; } public void testCompleteExpr7 ( ) throws Exception { assertType ( "<STR_LIT>" , "<STR_LIT>" ) ; } public void testCompleteExpr8 ( ) throws Exception { assertType ( "<STR_LIT>" , "<STR_LIT>" ) ; } public void testPrefix1 ( ) throws Exception { String contents = "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testPrefix2 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testPrefix3 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testPrefix4 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testPrefix5 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testPrefix6 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testPostfix1 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } public void testPostfix2 ( ) throws Exception { String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; String expr = "<STR_LIT>" ; assertType ( contents , contents . lastIndexOf ( expr ) , contents . lastIndexOf ( expr ) + expr . length ( ) , "<STR_LIT>" ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . search ; import java . util . List ; import junit . framework . Test ; import org . codehaus . groovy . ast . ASTNode ; import org . codehaus . jdt . groovy . model . GroovyCompilationUnit ; import org . eclipse . jdt . core . tests . util . GroovyUtils ; import org . eclipse . jdt . groovy . search . TypeInferencingVisitorWithRequestor ; public class Groovy20InferencingTests extends AbstractInferencingTest { public static Test suite ( ) { return buildTestSuite ( Groovy20InferencingTests . class ) ; } public Groovy20InferencingTests ( String name ) { super ( name ) ; } public void testCompileStatic1 ( ) throws Exception { if ( GroovyUtils . GROOVY_LEVEL < <NUM_LIT:20> ) { return ; } String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testCompileStatic2 ( ) throws Exception { if ( GroovyUtils . GROOVY_LEVEL < <NUM_LIT:20> ) { return ; } String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testCompileStatic3 ( ) throws Exception { if ( GroovyUtils . GROOVY_LEVEL < <NUM_LIT:20> ) { return ; } String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testCompileStatic4 ( ) throws Exception { if ( GroovyUtils . GROOVY_LEVEL < <NUM_LIT:20> ) { return ; } String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testCompileStatic5 ( ) throws Exception { if ( GroovyUtils . GROOVY_LEVEL < <NUM_LIT:20> ) { return ; } String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testTypeChecked1 ( ) throws Exception { if ( GroovyUtils . GROOVY_LEVEL < <NUM_LIT:20> ) { return ; } String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testTypeChecked2 ( ) throws Exception { if ( GroovyUtils . GROOVY_LEVEL < <NUM_LIT:20> ) { return ; } String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testTypeChecked3 ( ) throws Exception { if ( GroovyUtils . GROOVY_LEVEL < <NUM_LIT:20> ) { return ; } String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testTypeChecked4 ( ) throws Exception { if ( GroovyUtils . GROOVY_LEVEL < <NUM_LIT:20> ) { return ; } String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } public void testTypeChecked5 ( ) throws Exception { if ( GroovyUtils . GROOVY_LEVEL < <NUM_LIT:20> ) { return ; } String contents = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ; int start = contents . lastIndexOf ( "<STR_LIT>" ) ; int end = start + "<STR_LIT>" . length ( ) ; assertType ( contents , start , end , "<STR_LIT>" ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . search ; import org . codehaus . groovy . ast . ClassNode ; import org . codehaus . jdt . groovy . model . GroovyCompilationUnit ; public class GenericsMappingTest extends AbstractGroovySearchTest { public GenericsMappingTest ( String name ) { super ( name ) ; } public void testGenericsMapper ( ) throws Exception { GroovyCompilationUnit unit = createUnit ( "<STR_LIT>" , "<STR_LIT>" ) ; ClassNode classNode = unit . getModuleNode ( ) . getClasses ( ) . get ( <NUM_LIT:2> ) ; System . out . println ( unit . getModuleNode ( ) . getClasses ( ) . get ( <NUM_LIT:2> ) . getUnresolvedSuperClass ( ) . isRedirectNode ( ) ) ; assertEquals ( "<STR_LIT>" , "<STR_LIT:C>" , classNode . getName ( ) ) ; assertFalse ( "<STR_LIT>" , classNode . getSuperClass ( ) . isRedirectNode ( ) ) ; assertTrue ( "<STR_LIT>" , classNode . getUnresolvedSuperClass ( ) . isRedirectNode ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . search ; import java . util . ArrayList ; import java . util . List ; import org . codehaus . groovy . ast . ASTNode ; import org . codehaus . groovy . ast . AnnotatedNode ; import org . codehaus . groovy . ast . ClassNode ; import org . codehaus . groovy . ast . FieldNode ; import org . codehaus . groovy . ast . GenericsType ; import org . codehaus . groovy . ast . MethodNode ; import org . codehaus . groovy . ast . PropertyNode ; import org . codehaus . groovy . ast . stmt . Statement ; import org . codehaus . jdt . groovy . model . GroovyCompilationUnit ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . groovy . search . ITypeRequestor ; import org . eclipse . jdt . groovy . search . TypeInferencingVisitorWithRequestor ; import org . eclipse . jdt . groovy . search . TypeLookupResult ; import org . eclipse . jdt . groovy . search . TypeLookupResult . TypeConfidence ; import org . eclipse . jdt . groovy . search . VariableScope ; import org . objectweb . asm . Opcodes ; public abstract class AbstractInferencingTest extends AbstractGroovySearchTest { public AbstractInferencingTest ( String name ) { super ( name ) ; } protected void assertType ( String contents , String expectedType ) { assertType ( contents , <NUM_LIT:0> , contents . length ( ) , expectedType , false ) ; } protected void assertType ( String contents , int exprStart , int exprEnd , String expectedType ) { assertType ( contents , exprStart , exprEnd , expectedType , false ) ; } public static void assertType ( GroovyCompilationUnit contents , int start , int end , String expectedType ) { assertType ( contents , start , end , expectedType , false ) ; } protected void assertType ( String contents , String expectedType , boolean forceWorkingCopy ) { assertType ( contents , <NUM_LIT:0> , contents . length ( ) , expectedType , forceWorkingCopy ) ; } protected void assertType ( String contents , int exprStart , int exprEnd , String expectedType , boolean forceWorkingCopy ) { assertType ( contents , exprStart , exprEnd , expectedType , null , forceWorkingCopy ) ; } public static void assertType ( GroovyCompilationUnit contents , int exprStart , int exprEnd , String expectedType , boolean forceWorkingCopy ) { assertType ( contents , exprStart , exprEnd , expectedType , null , forceWorkingCopy ) ; } public static void assertType ( GroovyCompilationUnit unit , int exprStart , int exprEnd , String expectedType , String extraDocSnippet , boolean forceWorkingCopy ) { SearchRequestor requestor = doVisit ( exprStart , exprEnd , unit , forceWorkingCopy ) ; assertNotNull ( "<STR_LIT>" , requestor . node ) ; if ( ! expectedType . equals ( printTypeName ( requestor . result . type ) ) ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "<STR_LIT>" ) ; sb . append ( "<STR_LIT>" + expectedType + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + printTypeName ( requestor . result . type ) + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + printTypeName ( requestor . result . declaringType ) + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + requestor . node + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + requestor . result . confidence + "<STR_LIT:n>" ) ; fail ( sb . toString ( ) ) ; } if ( extraDocSnippet != null && ! requestor . result . extraDoc . contains ( extraDocSnippet ) ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "<STR_LIT>" ) ; sb . append ( "<STR_LIT>" + extraDocSnippet + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + requestor . result . extraDoc + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + requestor . node + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + requestor . result . confidence + "<STR_LIT:n>" ) ; fail ( sb . toString ( ) ) ; } assertNull ( "<STR_LIT>" , VariableScope . OBJECT_CLASS_NODE . getGenericsTypes ( ) ) ; } public static String checkType ( GroovyCompilationUnit unit , int exprStart , int exprEnd , String expectedType , String expectedDeclaringType , boolean assumeNoUnknowns , boolean forceWorkingCopy ) { SearchRequestor requestor = doVisit ( exprStart , exprEnd , unit , forceWorkingCopy ) ; if ( requestor . node == null ) { return "<STR_LIT>" + exprStart + "<STR_LIT>" + exprEnd + "<STR_LIT>" + "<STR_LIT>" + String . valueOf ( CharOperation . subarray ( unit . getContents ( ) , exprStart , exprEnd ) ) + "<STR_LIT:n>" ; } if ( expectedType != null && ! expectedType . equals ( printTypeName ( requestor . result . type ) ) ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "<STR_LIT>" ) ; sb . append ( "<STR_LIT>" + expectedType + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + printTypeName ( requestor . result . type ) + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + printTypeName ( requestor . result . declaringType ) + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + requestor . node + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + requestor . result . confidence + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + requestor . node . getLineNumber ( ) + "<STR_LIT:U+002CU+0020>" + requestor . node . getColumnNumber ( ) ) ; return sb . toString ( ) ; } if ( expectedDeclaringType != null && ! expectedDeclaringType . equals ( printTypeName ( requestor . result . declaringType ) ) ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "<STR_LIT>" ) ; sb . append ( "<STR_LIT>" + expectedDeclaringType + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + printTypeName ( requestor . result . declaringType ) + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + printTypeName ( requestor . result . type ) + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + requestor . node + "<STR_LIT:U+0020:U+0020>" + requestor . node . getText ( ) + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + requestor . result . confidence + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + requestor . node . getLineNumber ( ) + "<STR_LIT:U+002CU+0020>" + requestor . node . getColumnNumber ( ) + "<STR_LIT:n>" ) ; return sb . toString ( ) ; } if ( assumeNoUnknowns && ! requestor . unknowns . isEmpty ( ) ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "<STR_LIT>" ) ; for ( ASTNode unknown : requestor . unknowns ) { sb . append ( "<STR_LIT:(>" + unknown . getLineNumber ( ) + "<STR_LIT::>" + unknown . getColumnNumber ( ) + "<STR_LIT>" ) ; sb . append ( unknown + "<STR_LIT:n>" ) ; } return sb . toString ( ) ; } if ( VariableScope . OBJECT_CLASS_NODE . getGenericsTypes ( ) != null ) { return "<STR_LIT>" ; } return null ; } protected void assertType ( String contents , int exprStart , int exprEnd , String expectedType , String extraDocSnippet , boolean forceWorkingCopy ) { GroovyCompilationUnit unit = createUnit ( "<STR_LIT>" , contents ) ; assertType ( unit , exprStart , exprEnd , expectedType , extraDocSnippet , forceWorkingCopy ) ; } protected void assertDeprecated ( String contents , int exprStart , int exprEnd ) { GroovyCompilationUnit unit = createUnit ( "<STR_LIT>" , contents ) ; SearchRequestor requestor = doVisit ( exprStart , exprEnd , unit , false ) ; assertNotNull ( "<STR_LIT>" , requestor . node ) ; assertTrue ( "<STR_LIT>" + requestor . result . declaration , hasDeprecatedFlag ( ( AnnotatedNode ) requestor . result . declaration ) ) ; } private boolean hasDeprecatedFlag ( AnnotatedNode declaration ) { int flags ; if ( declaration instanceof PropertyNode ) { declaration = ( ( PropertyNode ) declaration ) . getField ( ) ; } if ( declaration instanceof ClassNode ) { flags = ( ( ClassNode ) declaration ) . getModifiers ( ) ; } else if ( declaration instanceof MethodNode ) { flags = ( ( MethodNode ) declaration ) . getModifiers ( ) ; } else if ( declaration instanceof FieldNode ) { flags = ( ( FieldNode ) declaration ) . getModifiers ( ) ; } else { flags = <NUM_LIT:0> ; } return ( flags & Opcodes . ACC_DEPRECATED ) != <NUM_LIT:0> ; } public static SearchRequestor doVisit ( int exprStart , int exprEnd , GroovyCompilationUnit unit , boolean forceWorkingCopy ) { try { if ( forceWorkingCopy ) { unit . becomeWorkingCopy ( null ) ; } try { TypeInferencingVisitorWithRequestor visitor = factory . createVisitor ( unit ) ; visitor . DEBUG = true ; SearchRequestor requestor = new SearchRequestor ( exprStart , exprEnd ) ; visitor . visitCompilationUnit ( requestor ) ; return requestor ; } finally { if ( forceWorkingCopy ) { unit . discardWorkingCopy ( ) ; } } } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } protected void assertDeclaringType ( String contents , int exprStart , int exprEnd , String expectedDeclaringType ) { assertDeclaringType ( contents , exprStart , exprEnd , expectedDeclaringType , false ) ; } protected enum DeclarationKind { FIELD , METHOD , PROPERTY , CLASS } protected void assertDeclaration ( String contents , int exprStart , int exprEnd , String expectedDeclaringType , String declarationName , DeclarationKind kind ) { assertDeclaringType ( contents , exprStart , exprEnd , expectedDeclaringType , false , false ) ; GroovyCompilationUnit unit = createUnit ( "<STR_LIT>" , contents ) ; SearchRequestor requestor = doVisit ( exprStart , exprEnd , unit , false ) ; switch ( kind ) { case FIELD : assertTrue ( "<STR_LIT>" + requestor . result . declaration , requestor . result . declaration instanceof FieldNode ) ; assertEquals ( "<STR_LIT>" , declarationName , ( ( FieldNode ) requestor . result . declaration ) . getName ( ) ) ; break ; case METHOD : assertTrue ( "<STR_LIT>" + requestor . result . declaration , requestor . result . declaration instanceof MethodNode ) ; assertEquals ( "<STR_LIT>" , declarationName , ( ( MethodNode ) requestor . result . declaration ) . getName ( ) ) ; break ; case PROPERTY : assertTrue ( "<STR_LIT>" + requestor . result . declaration , requestor . result . declaration instanceof PropertyNode ) ; assertEquals ( "<STR_LIT>" , declarationName , ( ( PropertyNode ) requestor . result . declaration ) . getName ( ) ) ; break ; case CLASS : assertTrue ( "<STR_LIT>" + requestor . result . declaration , requestor . result . declaration instanceof ClassNode ) ; assertEquals ( "<STR_LIT>" , declarationName , ( ( ClassNode ) requestor . result . declaration ) . getName ( ) ) ; } } protected void assertDeclaringType ( String contents , int exprStart , int exprEnd , String expectedDeclaringType , boolean forceWorkingCopy ) { assertDeclaringType ( contents , exprStart , exprEnd , expectedDeclaringType , forceWorkingCopy , false ) ; } protected void assertDeclaringType ( String contents , int exprStart , int exprEnd , String expectedDeclaringType , boolean forceWorkingCopy , boolean expectingUnknown ) { GroovyCompilationUnit unit = createUnit ( "<STR_LIT>" , contents ) ; SearchRequestor requestor = doVisit ( exprStart , exprEnd , unit , forceWorkingCopy ) ; assertNotNull ( "<STR_LIT>" , requestor . node ) ; if ( ! expectedDeclaringType . equals ( requestor . getDeclaringTypeName ( ) ) ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "<STR_LIT>" ) ; sb . append ( "<STR_LIT>" + expectedDeclaringType + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + printTypeName ( requestor . result . type ) + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + printTypeName ( requestor . result . declaringType ) + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + requestor . node + "<STR_LIT:n>" ) ; fail ( sb . toString ( ) ) ; } if ( expectingUnknown ) { if ( requestor . result . confidence != TypeConfidence . UNKNOWN ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "<STR_LIT>" + requestor . result . confidence + "<STR_LIT>" ) ; sb . append ( "<STR_LIT>" + expectedDeclaringType + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + printTypeName ( requestor . result . type ) + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + printTypeName ( requestor . result . declaringType ) + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + requestor . node + "<STR_LIT:n>" ) ; fail ( sb . toString ( ) ) ; } } else { if ( requestor . result . confidence == TypeConfidence . UNKNOWN ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "<STR_LIT>" ) ; sb . append ( "<STR_LIT>" + expectedDeclaringType + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + printTypeName ( requestor . result . type ) + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + printTypeName ( requestor . result . declaringType ) + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + requestor . node + "<STR_LIT:n>" ) ; fail ( sb . toString ( ) ) ; } } } protected void assertUnknownConfidence ( String contents , int exprStart , int exprEnd , String expectedDeclaringType , boolean forceWorkingCopy ) { GroovyCompilationUnit unit = createUnit ( "<STR_LIT>" , contents ) ; SearchRequestor requestor = doVisit ( exprStart , exprEnd , unit , forceWorkingCopy ) ; assertNotNull ( "<STR_LIT>" , requestor . node ) ; if ( requestor . result . confidence != TypeConfidence . UNKNOWN ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "<STR_LIT>" + requestor . result . confidence + "<STR_LIT>" ) ; sb . append ( "<STR_LIT>" + expectedDeclaringType + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + printTypeName ( requestor . result . type ) + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + printTypeName ( requestor . result . declaringType ) + "<STR_LIT:n>" ) ; sb . append ( "<STR_LIT>" + requestor . node + "<STR_LIT:n>" ) ; fail ( sb . toString ( ) ) ; } } public static String printTypeName ( ClassNode type ) { return type != null ? type . getName ( ) + printGenerics ( type ) : "<STR_LIT:null>" ; } public static String printGenerics ( ClassNode type ) { if ( type . getGenericsTypes ( ) == null || type . getGenericsTypes ( ) . length == <NUM_LIT:0> ) { return "<STR_LIT>" ; } StringBuilder sb = new StringBuilder ( ) ; sb . append ( '<CHAR_LIT>' ) ; for ( int i = <NUM_LIT:0> ; i < type . getGenericsTypes ( ) . length ; i ++ ) { GenericsType gt = type . getGenericsTypes ( ) [ i ] ; sb . append ( printTypeName ( gt . getType ( ) ) ) ; if ( i < type . getGenericsTypes ( ) . length - <NUM_LIT:1> ) { sb . append ( '<CHAR_LIT:U+002C>' ) ; } } sb . append ( '<CHAR_LIT:>>' ) ; return sb . toString ( ) ; } public class UnknownTypeRequestor implements ITypeRequestor { private List < ASTNode > unknownNodes = new ArrayList < ASTNode > ( ) ; public List < ASTNode > getUnknownNodes ( ) { return unknownNodes ; } public VisitStatus acceptASTNode ( ASTNode node , TypeLookupResult result , IJavaElement enclosingElement ) { if ( result . confidence == TypeConfidence . UNKNOWN && node . getEnd ( ) > <NUM_LIT:0> ) { unknownNodes . add ( node ) ; } return VisitStatus . CONTINUE ; } } public static class SearchRequestor implements ITypeRequestor { private final int start ; private final int end ; public TypeLookupResult result ; public ASTNode node ; public final List < ASTNode > unknowns = new ArrayList < ASTNode > ( ) ; public SearchRequestor ( int start , int end ) { super ( ) ; this . start = start ; this . end = end ; } public VisitStatus acceptASTNode ( ASTNode visitorNode , TypeLookupResult visitorResult , IJavaElement enclosingElement ) { if ( this . result == null && visitorNode . getStart ( ) == start && visitorNode . getEnd ( ) == end && ! ( visitorNode instanceof MethodNode ) && ! ( visitorNode instanceof Statement ) && ! ( visitorNode instanceof ClassNode && ( ( ClassNode ) visitorNode ) . isScript ( ) ) ) { this . result = visitorResult ; this . node = visitorNode ; } if ( visitorResult . confidence == TypeConfidence . UNKNOWN && visitorNode . getEnd ( ) > <NUM_LIT:0> ) { unknowns . add ( visitorNode ) ; } return VisitStatus . CONTINUE ; } public String getDeclaringTypeName ( ) { return printTypeName ( result . declaringType ) ; } public String getTypeName ( ) { return result . type . getName ( ) ; } } } </s>
<s> package org . eclipse . jdt . core . groovy . tests . search ; import java . util . ArrayList ; import java . util . List ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . search . SearchMatch ; import org . eclipse . jdt . core . search . SearchRequestor ; public class MockSearchRequestor extends SearchRequestor { List < SearchMatch > matches = new ArrayList < SearchMatch > ( ) ; @ Override public void acceptSearchMatch ( SearchMatch match ) throws CoreException { boolean added = false ; for ( int i = <NUM_LIT:0> ; i < matches . size ( ) ; i ++ ) { if ( matches . get ( i ) . getOffset ( ) > match . getOffset ( ) ) { matches . add ( i , match ) ; added = true ; break ; } } if ( ! added ) { matches . add ( match ) ; } } String printMatches ( ) { StringBuffer sb = new StringBuffer ( ) ; for ( SearchMatch match : matches ) { sb . append ( MockPossibleMatch . printMatch ( match ) ) ; } return sb . toString ( ) ; } IJavaElement getElementNumber ( int num ) { return ( IJavaElement ) getMatch ( num ) . getElement ( ) ; } SearchMatch getMatch ( int num ) { return matches . get ( num ) ; } List < SearchMatch > getMatches ( ) { return matches ; } } </s>
<s> package org . eclipse . jdt . core . tests . builder ; import java . io . * ; import java . util . * ; import junit . framework . * ; import org . eclipse . core . runtime . * ; import org . eclipse . core . resources . * ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . core . compiler . * ; import org . eclipse . jdt . core . dom . * ; import org . eclipse . jdt . core . tests . util . Util ; public class ParticipantBuildTests extends BuilderTests { public ParticipantBuildTests ( String name ) { super ( name ) ; } public void tearDown ( ) throws Exception { TestBuilderParticipant . PARTICIPANT = null ; super . tearDown ( ) ; } public static Test suite ( ) { return buildTestSuite ( ParticipantBuildTests . class ) ; } static class BuildTestParticipant extends CompilationParticipant { BuildTestParticipant ( ) { TestBuilderParticipant . PARTICIPANT = this ; } } static class ParticipantProblem extends CategorizedProblem { int counter = <NUM_LIT:0> ; String message ; int id ; char [ ] filename ; ParticipantProblem ( String message , String filename ) { this . message = message ; id = counter ++ ; this . filename = filename . toCharArray ( ) ; } public String [ ] getArguments ( ) { return new String [ <NUM_LIT:0> ] ; } public int getID ( ) { return id ; } public String getMessage ( ) { return message ; } public char [ ] getOriginatingFileName ( ) { return filename ; } public int getSourceStart ( ) { return <NUM_LIT:0> ; } public int getSourceEnd ( ) { return <NUM_LIT:0> ; } public int getSourceLineNumber ( ) { return <NUM_LIT:1> ; } public boolean isError ( ) { return true ; } public boolean isWarning ( ) { return false ; } public void setSourceEnd ( int sourceEnd ) { } public void setSourceLineNumber ( int lineNumber ) { } public void setSourceStart ( int sourceStart ) { } public int getCategoryID ( ) { return <NUM_LIT:0> ; } public String getMarkerType ( ) { return "<STR_LIT>" ; } } CompilationUnit buildCompilationUnit ( BuildContext file ) { IJavaProject javaProject = JavaCore . create ( file . getFile ( ) . getProject ( ) ) ; ASTParser p = ASTParser . newParser ( AST . JLS3 ) ; p . setProject ( javaProject ) ; p . setSource ( file . getContents ( ) ) ; p . setResolveBindings ( true ) ; p . setKind ( ASTParser . K_COMPILATION_UNIT ) ; p . setUnitName ( file . getFile ( ) . getName ( ) ) ; return ( CompilationUnit ) p . createAST ( null ) ; } public void testBuildStarting ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath test = env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Test>" , "<STR_LIT>" ) ; new BuildTestParticipant ( ) { int buildPass = <NUM_LIT:0> ; public void buildStarting ( BuildContext [ ] files , boolean isBatchBuild ) { BuildContext result = files [ <NUM_LIT:0> ] ; IFile genedType = result . getFile ( ) . getParent ( ) . getFile ( new Path ( "<STR_LIT>" ) ) ; if ( this . buildPass == <NUM_LIT:0> || this . buildPass == <NUM_LIT:3> ) { try { genedType . create ( new ByteArrayInputStream ( "<STR_LIT>" . getBytes ( ) ) , true , null ) ; } catch ( CoreException e ) { e . printStackTrace ( ) ; } result . recordAddedGeneratedFiles ( new IFile [ ] { genedType } ) ; } else if ( this . buildPass == <NUM_LIT:1> ) { try { genedType . delete ( true , null ) ; } catch ( CoreException e ) { e . printStackTrace ( ) ; } result . recordDeletedGeneratedFiles ( new IFile [ ] { genedType } ) ; } this . buildPass ++ ; } } ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Test>" , "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingOnlySpecificProblemFor ( test , new Problem ( "<STR_LIT>" , "<STR_LIT>" , test , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Test>" , "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; } public void testDefaultValue ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:test>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:test>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; new BuildTestParticipant ( ) { public boolean isAnnotationProcessor ( ) { return true ; } public void processAnnotations ( BuildContext [ ] files ) { for ( int i = <NUM_LIT:0> , total = files . length ; i < total ; i ++ ) { IFile file = files [ i ] . getFile ( ) ; if ( ! "<STR_LIT>" . equals ( file . getName ( ) ) ) continue ; List problems = new ArrayList ( ) ; CompilationUnit unit = buildCompilationUnit ( files [ i ] ) ; List types = unit . types ( ) ; for ( int t = <NUM_LIT:0> , l = types . size ( ) ; t < l ; t ++ ) { AbstractTypeDeclaration typeDecl = ( AbstractTypeDeclaration ) types . get ( t ) ; ITypeBinding typeBinding = typeDecl . resolveBinding ( ) ; if ( typeBinding == null ) continue ; IVariableBinding [ ] fieldBindings = typeBinding . getDeclaredFields ( ) ; for ( int f = <NUM_LIT:0> , fLength = fieldBindings . length ; f < fLength ; f ++ ) { IVariableBinding field = fieldBindings [ f ] ; if ( "<STR_LIT>" . equals ( field . getName ( ) ) ) { ITypeBinding fieldType = field . getType ( ) ; ITypeBinding [ ] declaredTypes = fieldType . getDeclaredTypes ( ) ; for ( int d = <NUM_LIT:0> , dLength = declaredTypes . length ; d < dLength ; d ++ ) { if ( ! "<STR_LIT>" . equals ( declaredTypes [ d ] . getName ( ) ) ) continue ; IMethodBinding [ ] annotationMethods = declaredTypes [ d ] . getDeclaredMethods ( ) ; for ( int m = <NUM_LIT:0> , mLength = annotationMethods . length ; m < mLength ; m ++ ) { if ( ! "<STR_LIT:value>" . equals ( annotationMethods [ m ] . getName ( ) ) ) continue ; Object defaultValue = annotationMethods [ m ] . getDefaultValue ( ) ; assertTrue ( "<STR_LIT>" , defaultValue instanceof IVariableBinding ) ; IVariableBinding variableBinding = ( IVariableBinding ) defaultValue ; String defaultString = variableBinding . getName ( ) ; String expected = "<STR_LIT>" ; if ( ! expected . equals ( defaultString ) ) { IProblem problem = new ParticipantProblem ( "<STR_LIT>" + expected + "<STR_LIT>" + defaultString , file . getName ( ) ) ; problems . add ( problem ) ; } } } IVariableBinding [ ] nestedFields = fieldType . getDeclaredFields ( ) ; for ( int nf = <NUM_LIT:0> , nfLength = nestedFields . length ; nf < nfLength ; nf ++ ) { if ( ! nestedFields [ nf ] . getName ( ) . equals ( "<STR_LIT>" ) ) continue ; Object constant = nestedFields [ nf ] . getConstantValue ( ) ; String constantStr = constant == null ? "<STR_LIT>" : constant . toString ( ) ; String expected = "<STR_LIT:4>" ; if ( ! constantStr . equals ( expected ) ) problems . add ( new ParticipantProblem ( "<STR_LIT>" + expected + "<STR_LIT>" + constantStr , file . getName ( ) ) ) ; } } else { problems . add ( new ParticipantProblem ( "<STR_LIT>" + field , file . getName ( ) ) ) ; } } } if ( ! problems . isEmpty ( ) ) { CategorizedProblem [ ] problemArray = new CategorizedProblem [ problems . size ( ) ] ; problemArray = ( CategorizedProblem [ ] ) problems . toArray ( problemArray ) ; files [ i ] . recordNewProblems ( problemArray ) ; } } } } ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; } public void testParticipantProblems ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" ) ; new BuildTestParticipant ( ) { public void buildStarting ( BuildContext [ ] files , boolean isBatch ) { for ( int i = <NUM_LIT:0> , total = files . length ; i < total ; i ++ ) { BuildContext context = files [ i ] ; if ( CharOperation . indexOf ( "<STR_LIT>" . toCharArray ( ) , context . getContents ( ) , true ) != - <NUM_LIT:1> ) { context . recordNewProblems ( new CategorizedProblem [ ] { new ParticipantProblem ( "<STR_LIT>" , context . getFile ( ) . getFullPath ( ) . toString ( ) ) } ) ; } } } } ; fullBuild ( projectPath ) ; expectingParticipantProblems ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingParticipantProblems ( projectPath , "<STR_LIT>" ) ; } public void testProcessAnnotationDeclarations ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Test>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; new BuildTestParticipant ( ) { int count = <NUM_LIT:2> ; public boolean isAnnotationProcessor ( ) { return true ; } public void processAnnotations ( BuildContext [ ] files ) { if ( this . count == <NUM_LIT:2> ) { this . count -- ; BuildContext result = files [ <NUM_LIT:0> ] ; IFile genedType = result . getFile ( ) . getParent ( ) . getFile ( new Path ( "<STR_LIT>" ) ) ; try { genedType . create ( new ByteArrayInputStream ( "<STR_LIT>" . getBytes ( ) ) , true , null ) ; } catch ( CoreException e ) { e . printStackTrace ( ) ; } result . recordAddedGeneratedFiles ( new IFile [ ] { genedType } ) ; } else if ( this . count == <NUM_LIT:1> ) { this . count -- ; BuildContext result = files [ <NUM_LIT:0> ] ; IFile genedType = result . getFile ( ) . getParent ( ) . getFile ( new Path ( "<STR_LIT>" ) ) ; try { genedType . create ( new ByteArrayInputStream ( "<STR_LIT>" . getBytes ( ) ) , true , null ) ; } catch ( CoreException e ) { e . printStackTrace ( ) ; } result . recordAddedGeneratedFiles ( new IFile [ ] { genedType } ) ; } } } ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; } public void testProcessAnnotationQualifiedReferences ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Test>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; new BuildTestParticipant ( ) { public boolean isAnnotationProcessor ( ) { return true ; } public void processAnnotations ( BuildContext [ ] files ) { BuildContext result = files [ <NUM_LIT:0> ] ; IFile genedType = result . getFile ( ) . getProject ( ) . getFile ( new Path ( "<STR_LIT>" ) ) ; if ( genedType . exists ( ) ) return ; try { IFolder folder = ( IFolder ) genedType . getParent ( ) ; if ( ! folder . exists ( ) ) folder . create ( true , true , null ) ; genedType . create ( new ByteArrayInputStream ( "<STR_LIT>" . getBytes ( ) ) , true , null ) ; } catch ( CoreException e ) { e . printStackTrace ( ) ; } result . recordAddedGeneratedFiles ( new IFile [ ] { genedType } ) ; } } ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; } public void testProcessAnnotationReferences ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Test>" , "<STR_LIT>" + "<STR_LIT>" ) ; new BuildTestParticipant ( ) { public boolean isAnnotationProcessor ( ) { return true ; } public void processAnnotations ( BuildContext [ ] files ) { BuildContext result = files [ <NUM_LIT:0> ] ; IFile genedType = result . getFile ( ) . getParent ( ) . getFile ( new Path ( "<STR_LIT>" ) ) ; if ( genedType . exists ( ) ) return ; try { genedType . create ( new ByteArrayInputStream ( "<STR_LIT>" . getBytes ( ) ) , true , null ) ; } catch ( CoreException e ) { e . printStackTrace ( ) ; } result . recordAddedGeneratedFiles ( new IFile [ ] { genedType } ) ; } } ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; } public void testResolvedMethod ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; new BuildTestParticipant ( ) { public boolean isAnnotationProcessor ( ) { return true ; } public void processAnnotations ( BuildContext [ ] files ) { for ( int i = <NUM_LIT:0> , total = files . length ; i < total ; i ++ ) { IFile file = files [ i ] . getFile ( ) ; if ( ! "<STR_LIT>" . equals ( file . getName ( ) ) ) continue ; List problems = new ArrayList ( ) ; CompilationUnit unit = buildCompilationUnit ( files [ i ] ) ; List types = unit . types ( ) ; for ( int t = <NUM_LIT:0> , l = types . size ( ) ; t < l ; t ++ ) { AbstractTypeDeclaration typeDecl = ( AbstractTypeDeclaration ) types . get ( t ) ; ITypeBinding typeBinding = typeDecl . resolveBinding ( ) ; if ( typeBinding == null ) continue ; typeBinding = typeBinding . getAnnotations ( ) [ <NUM_LIT:0> ] . getAnnotationType ( ) ; IAnnotationBinding targetValue = typeBinding . getAnnotations ( ) [ <NUM_LIT:0> ] ; IMethodBinding method = targetValue . getDeclaredMemberValuePairs ( ) [ <NUM_LIT:0> ] . getMethodBinding ( ) ; if ( ! "<STR_LIT:value>" . equals ( method . getName ( ) ) ) problems . add ( new ParticipantProblem ( "<STR_LIT>" + method . getName ( ) + "<STR_LIT>" , file . getName ( ) ) ) ; } if ( ! problems . isEmpty ( ) ) { CategorizedProblem [ ] problemArray = new CategorizedProblem [ problems . size ( ) ] ; problemArray = ( CategorizedProblem [ ] ) problems . toArray ( problemArray ) ; files [ i ] . recordNewProblems ( problemArray ) ; } } } } ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; } public void test1001 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" ) ; new BuildTestParticipant ( ) { public void buildStarting ( BuildContext [ ] files , boolean isBatch ) { for ( int i = <NUM_LIT:0> , total = files . length ; i < total ; i ++ ) { BuildContext context = files [ i ] ; if ( CharOperation . indexOf ( "<STR_LIT>" . toCharArray ( ) , context . getContents ( ) , true ) != - <NUM_LIT:1> ) { context . recordNewProblems ( new CategorizedProblem [ ] { new ParticipantProblem ( "<STR_LIT>" , context . getFile ( ) . getFullPath ( ) . toString ( ) ) } ) ; } } } } ; fullBuild ( projectPath ) ; Problem [ ] problems = env . getProblemsFor ( projectPath , "<STR_LIT>" ) ; assertNotNull ( "<STR_LIT>" , problems ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:1> , problems . length ) ; assertEquals ( "<STR_LIT>" , "<STR_LIT>" , problems [ <NUM_LIT:0> ] . getSourceId ( ) ) ; } public void test1002 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" ) ; final String specificGeneratedBy = "<STR_LIT>" ; new BuildTestParticipant ( ) { public void buildStarting ( BuildContext [ ] files , boolean isBatch ) { for ( int i = <NUM_LIT:0> , total = files . length ; i < total ; i ++ ) { BuildContext context = files [ i ] ; if ( CharOperation . indexOf ( "<STR_LIT>" . toCharArray ( ) , context . getContents ( ) , true ) != - <NUM_LIT:1> ) { context . recordNewProblems ( new CategorizedProblem [ ] { new ParticipantProblem ( "<STR_LIT>" , context . getFile ( ) . getFullPath ( ) . toString ( ) ) { public String [ ] getExtraMarkerAttributeNames ( ) { return new String [ ] { IMarker . SOURCE_ID } ; } public Object [ ] getExtraMarkerAttributeValues ( ) { return new String [ ] { specificGeneratedBy } ; } } } ) ; } } } } ; fullBuild ( projectPath ) ; Problem [ ] problems = env . getProblemsFor ( projectPath , "<STR_LIT>" ) ; assertNotNull ( "<STR_LIT>" , problems ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:1> , problems . length ) ; assertEquals ( "<STR_LIT>" , specificGeneratedBy , problems [ <NUM_LIT:0> ] . getSourceId ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . tests . builder ; import java . io . File ; import junit . framework . * ; import org . eclipse . core . resources . IFolder ; import org . eclipse . core . resources . IProject ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . tests . util . Util ; public class PackageTests extends BuilderTests { public PackageTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( PackageTests . class ) ; } public void testPackageProblem ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath src = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; IPath src2 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( src , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( src2 , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( src2 , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( src2 , "<STR_LIT>" , "<STR_LIT:Z>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; env . removeClass ( env . getPackagePath ( src , "<STR_LIT>" ) , "<STR_LIT:X>" ) ; env . removePackage ( src2 , "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; } public void test001 ( ) throws CoreException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; try { env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath src = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; IPath bin = env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( src , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; File tmpDir = env . getTmpDirectory ( ) ; File externalPackageDir = new File ( tmpDir . getAbsolutePath ( ) + File . separator + "<STR_LIT:q>" ) ; externalPackageDir . mkdir ( ) ; IFolder folder = env . getWorkspace ( ) . getRoot ( ) . getFolder ( src . append ( "<STR_LIT>" ) ) ; folder . createLink ( externalPackageDir . toURI ( ) , <NUM_LIT:0> , null ) ; env . addClass ( src , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( src , "<STR_LIT>" , "<STR_LIT:Z>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; assertTrue ( new File ( externalPackageDir . getAbsolutePath ( ) + File . separator + "<STR_LIT:r>" + File . separator + "<STR_LIT>" ) . exists ( ) ) ; fullBuild ( ) ; expectingPresenceOf ( bin . append ( "<STR_LIT>" ) ) ; expectingNoProblems ( ) ; env . removeClass ( env . getPackagePath ( src , "<STR_LIT>" ) , "<STR_LIT:Z>" ) ; env . removePackage ( src , "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; } finally { env . deleteTmpDirectory ( ) ; env . removeProject ( projectPath ) ; } } public void test002 ( ) throws CoreException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; IPath externalProjectPath = env . addProject ( "<STR_LIT>" ) ; try { env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath src = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; IPath bin = env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( src , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IProject externalProject = env . getProject ( externalProjectPath ) ; IFolder externalFolder = externalProject . getFolder ( "<STR_LIT:q>" ) ; externalFolder . create ( false , true , null ) ; IFolder folder = env . getWorkspace ( ) . getRoot ( ) . getFolder ( src . append ( "<STR_LIT>" ) ) ; folder . createLink ( externalFolder . getLocationURI ( ) , <NUM_LIT:0> , null ) ; env . addClass ( src , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( src , "<STR_LIT>" , "<STR_LIT:Z>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; assertTrue ( new File ( externalFolder . getLocation ( ) + File . separator + "<STR_LIT:r>" + File . separator + "<STR_LIT>" ) . exists ( ) ) ; env . incrementalBuild ( projectPath ) ; expectingPresenceOf ( bin . append ( "<STR_LIT>" ) ) ; expectingNoProblems ( ) ; env . removeClass ( env . getPackagePath ( src , "<STR_LIT>" ) , "<STR_LIT:Z>" ) ; env . removePackage ( src , "<STR_LIT>" ) ; env . incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; } finally { env . deleteTmpDirectory ( ) ; env . removeProject ( projectPath ) ; env . removeProject ( externalProjectPath ) ; } } } </s>
<s> package org . eclipse . jdt . core . tests . builder ; import java . io . PrintWriter ; import java . io . StringWriter ; import java . util . Arrays ; import junit . framework . Test ; import org . eclipse . core . resources . IMarker ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . core . tests . util . Util ; public class PackageInfoTest extends BuilderTests { public PackageInfoTest ( String name ) { super ( name ) ; } static { } public static Test suite ( ) { return buildTestSuite ( PackageInfoTest . class ) ; } public void test001 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; IPath packageInfoPath = env . addFile ( root , "<STR_LIT>" , "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingOnlyProblemsFor ( packageInfoPath ) ; final Problem [ ] problems = env . getProblems ( ) ; Arrays . sort ( problems ) ; assertNotNull ( problems ) ; final StringWriter stringWriter = new StringWriter ( ) ; final PrintWriter writer = new PrintWriter ( stringWriter ) ; final int problemsLength = problems . length ; if ( problemsLength == <NUM_LIT:1> ) { writer . print ( problems [ <NUM_LIT:0> ] . getMessage ( ) ) ; } else { for ( int i = <NUM_LIT:0> ; i < problemsLength - <NUM_LIT:1> ; i ++ ) { writer . println ( problems [ i ] . getMessage ( ) ) ; } writer . print ( problems [ problemsLength - <NUM_LIT:1> ] . getMessage ( ) ) ; } writer . close ( ) ; final String expectedOutput = "<STR_LIT>" + "<STR_LIT>" ; assertSourceEquals ( "<STR_LIT>" , expectedOutput , stringWriter . toString ( ) ) ; } public void test002 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; env . addFile ( root , "<STR_LIT>" , "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; executeClass ( projectPath , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; } public void test003 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addPackage ( root , "<STR_LIT>" ) ; IPath packageInfoPath = env . addFile ( root , "<STR_LIT>" , "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingOnlySpecificProblemFor ( packageInfoPath , new Problem ( "<STR_LIT>" , "<STR_LIT>" , packageInfoPath , <NUM_LIT:0> , <NUM_LIT:0> , CategorizedProblem . CAT_INTERNAL , IMarker . SEVERITY_ERROR ) ) ; } public void test004 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath otherRoot = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:test>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addPackage ( root , "<STR_LIT>" ) ; env . addPackage ( otherRoot , "<STR_LIT>" ) ; env . addFile ( root , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath otherPackageInfoPath = env . addFile ( otherRoot , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingOnlySpecificProblemFor ( otherPackageInfoPath , new Problem ( "<STR_LIT>" , "<STR_LIT>" , otherPackageInfoPath , <NUM_LIT:0> , <NUM_LIT:0> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; } protected void assertSourceEquals ( String message , String expected , String actual ) { if ( actual == null ) { assertEquals ( message , expected , null ) ; return ; } actual = org . eclipse . jdt . core . tests . util . Util . convertToIndependantLineDelimiter ( actual ) ; if ( ! actual . equals ( expected ) ) { System . out . print ( org . eclipse . jdt . core . tests . util . Util . displayString ( actual . toString ( ) , <NUM_LIT:0> ) ) ; } assertEquals ( message , expected , actual ) ; } public static Class testClass ( ) { return PackageInfoTest . class ; } } </s>
<s> package org . eclipse . jdt . core . tests . builder ; import junit . framework . * ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . Path ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . tests . util . Util ; public class MultiSourceFolderAndOutputFolderTests extends BuilderTests { public MultiSourceFolderAndOutputFolderTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( MultiSourceFolderAndOutputFolderTests . class ) ; } public void test0001 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath src1 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , null , "<STR_LIT>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addClass ( src1 , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( projectPath . append ( "<STR_LIT>" ) ) ; expectingNoPresenceOf ( projectPath . append ( "<STR_LIT>" ) ) ; } public void test0002 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath src1 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , null , "<STR_LIT>" ) ; IPath src2 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addClass ( src1 , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( src2 , "<STR_LIT:p>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( projectPath . append ( "<STR_LIT>" ) ) ; expectingPresenceOf ( projectPath . append ( "<STR_LIT>" ) ) ; expectingNoPresenceOf ( projectPath . append ( "<STR_LIT>" ) ) ; expectingNoPresenceOf ( projectPath . append ( "<STR_LIT>" ) ) ; } public void test0003 ( ) { try { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" , null , null ) ; env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , null , null ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( ) ; expectingNoProblems ( ) ; assertTrue ( "<STR_LIT>" , false ) ; } catch ( JavaModelException e ) { assertEquals ( "<STR_LIT>" + "<STR_LIT>" , e . getMessage ( ) ) ; } } public void test0004 ( ) { try { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , null , null ) ; env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" , new IPath [ ] { new Path ( "<STR_LIT>" ) } , null ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( ) ; expectingNoProblems ( ) ; assertTrue ( "<STR_LIT>" , false ) ; } catch ( JavaModelException e ) { assertEquals ( "<STR_LIT>" , e . getMessage ( ) ) ; } } public void test0005 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , null , null ) ; env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" , new IPath [ ] { new Path ( "<STR_LIT>" ) } , null ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( ) ; expectingNoProblems ( ) ; } public void test0006 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath srcF1 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , null , null ) ; IPath src = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" , new IPath [ ] { new Path ( "<STR_LIT>" ) } , null ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addClass ( src , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( srcF1 , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; } public void test0007 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath srcF1 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , null , null ) ; IPath src = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" , new IPath [ ] { new Path ( "<STR_LIT>" ) } , null ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; IPath xPath = env . addClass ( src , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( srcF1 , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingOnlyProblemsFor ( xPath ) ; } public void test0008 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath srcF1 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , null , null ) ; IPath src = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" , new IPath [ ] { new Path ( "<STR_LIT>" ) } , null ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; IPath xPath = env . addClass ( src , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( srcF1 , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( ) ; expectingOnlyProblemsFor ( xPath ) ; env . addClass ( srcF1 , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; } public void test0009 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , null , "<STR_LIT>" ) ; env . addFolder ( projectPath , "<STR_LIT>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( projectPath , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( projectPath . append ( "<STR_LIT>" ) . append ( "<STR_LIT>" ) ) ; expectingNoPresenceOf ( projectPath . append ( "<STR_LIT>" ) . append ( "<STR_LIT>" ) ) ; expectingNoPresenceOf ( projectPath . append ( "<STR_LIT>" ) . append ( "<STR_LIT>" ) ) ; expectingNoPresenceOf ( projectPath . append ( "<STR_LIT>" ) . append ( "<STR_LIT>" ) ) ; } public void test0010 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , new IPath [ ] { new Path ( "<STR_LIT>" ) } , "<STR_LIT>" ) ; IPath src = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" , null , null ) ; env . addFolder ( projectPath , "<STR_LIT>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( projectPath , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" ) ; env . addClass ( src , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( projectPath . append ( "<STR_LIT>" ) . append ( "<STR_LIT>" ) ) ; expectingNoPresenceOf ( projectPath . append ( "<STR_LIT>" ) . append ( "<STR_LIT>" ) ) ; expectingPresenceOf ( projectPath . append ( "<STR_LIT>" ) . append ( "<STR_LIT>" ) ) ; expectingNoPresenceOf ( projectPath . append ( "<STR_LIT>" ) . append ( "<STR_LIT>" ) ) ; expectingNoPresenceOf ( projectPath . append ( "<STR_LIT>" ) . append ( "<STR_LIT>" ) ) ; expectingNoPresenceOf ( projectPath . append ( "<STR_LIT>" ) . append ( "<STR_LIT>" ) ) ; } public void test0011 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , new IPath [ ] { new Path ( "<STR_LIT>" ) } , null ) ; IPath src = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" , null , "<STR_LIT>" ) ; env . addFolder ( projectPath , "<STR_LIT>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( projectPath , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" ) ; env . addClass ( src , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( projectPath . append ( "<STR_LIT>" ) . append ( "<STR_LIT>" ) ) ; expectingNoPresenceOf ( projectPath . append ( "<STR_LIT>" ) . append ( "<STR_LIT>" ) ) ; expectingPresenceOf ( projectPath . append ( "<STR_LIT>" ) . append ( "<STR_LIT>" ) ) ; expectingNoPresenceOf ( projectPath . append ( "<STR_LIT>" ) . append ( "<STR_LIT>" ) ) ; expectingNoPresenceOf ( projectPath . append ( "<STR_LIT>" ) . append ( "<STR_LIT>" ) ) ; expectingNoPresenceOf ( projectPath . append ( "<STR_LIT>" ) . append ( "<STR_LIT>" ) ) ; } public void test0012 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath src = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , new IPath [ ] { new Path ( "<STR_LIT>" ) , new Path ( "<STR_LIT>" ) } , null , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addClass ( src , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; env . addClass ( src , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; } } </s>
<s> package org . eclipse . jdt . core . tests . builder ; import junit . framework . * ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . tests . util . Util ; public class EfficiencyTests extends BuilderTests { public EfficiencyTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( EfficiencyTests . class ) ; } public void testEfficiency ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( projectPath ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClasses ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" } ) ; expectingCompilingOrder ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" } ) ; } public void testMethodAddition ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Z>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( projectPath ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClasses ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" } ) ; expectingCompilingOrder ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" } ) ; } public void testLocalTypeAddition ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Z>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( projectPath ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClasses ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" } ) ; expectingCompilingOrder ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" } ) ; } public void testLocalTypeAddition2 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Z>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( projectPath ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClasses ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" } ) ; expectingCompilingOrder ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" } ) ; } public void testLocalTypeRemoval ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Z>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( projectPath ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClasses ( new String [ ] { "<STR_LIT>" } ) ; expectingCompilingOrder ( new String [ ] { "<STR_LIT>" } ) ; } public void testLocalTypeRemoval2 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Z>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( projectPath ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClasses ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" } ) ; expectingCompilingOrder ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" } ) ; } public void testMissingType001 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( projectPath ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Z>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingCompiledClasses ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" } ) ; expectingCompilingOrder ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" } ) ; } } </s>
<s> package org . eclipse . jdt . core . tests . builder ; import java . util . Hashtable ; import junit . framework . * ; import org . eclipse . core . resources . IMarker ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . preferences . IEclipsePreferences ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . core . tests . util . Util ; import org . eclipse . jdt . internal . core . JavaModelManager ; public class BasicBuildTests extends BuilderTests { public BasicBuildTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( BasicBuildTests . class ) ; } public void testBuild ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; } public void testToDoMarker ( ) throws JavaModelException { Hashtable options = JavaCore . getOptions ( ) ; Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . COMPILER_TASK_TAGS , "<STR_LIT>" ) ; JavaCore . setOptions ( newOptions ) ; IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath pathToA = env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; expectingOnlySpecificProblemFor ( pathToA , new Problem ( "<STR_LIT:A>" , "<STR_LIT>" , pathToA , <NUM_LIT> , <NUM_LIT> , - <NUM_LIT:1> , IMarker . SEVERITY_ERROR ) ) ; JavaCore . setOptions ( options ) ; } public void testToDoMarker2 ( ) throws JavaModelException { Hashtable options = JavaCore . getOptions ( ) ; Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . COMPILER_TASK_TAGS , "<STR_LIT>" ) ; newOptions . put ( JavaCore . COMPILER_TASK_PRIORITIES , "<STR_LIT>" ) ; JavaCore . setOptions ( newOptions ) ; IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath pathToA = env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; IMarker [ ] markers = env . getTaskMarkersFor ( pathToA ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:3> , markers . length ) ; try { IMarker marker = markers [ <NUM_LIT:0> ] ; Object priority = marker . getAttribute ( IMarker . PRIORITY ) ; String message = ( String ) marker . getAttribute ( IMarker . MESSAGE ) ; assertTrue ( "<STR_LIT>" , message . startsWith ( "<STR_LIT>" ) ) ; assertNotNull ( "<STR_LIT>" , priority ) ; assertEquals ( "<STR_LIT>" , new Integer ( IMarker . PRIORITY_NORMAL ) , priority ) ; marker = markers [ <NUM_LIT:1> ] ; priority = marker . getAttribute ( IMarker . PRIORITY ) ; message = ( String ) marker . getAttribute ( IMarker . MESSAGE ) ; assertTrue ( "<STR_LIT>" , message . startsWith ( "<STR_LIT>" ) ) ; assertNotNull ( "<STR_LIT>" , priority ) ; assertEquals ( "<STR_LIT>" , new Integer ( IMarker . PRIORITY_HIGH ) , priority ) ; marker = markers [ <NUM_LIT:2> ] ; priority = marker . getAttribute ( IMarker . PRIORITY ) ; message = ( String ) marker . getAttribute ( IMarker . MESSAGE ) ; assertTrue ( "<STR_LIT>" , message . startsWith ( "<STR_LIT>" ) ) ; assertNotNull ( "<STR_LIT>" , priority ) ; assertEquals ( "<STR_LIT>" , new Integer ( IMarker . PRIORITY_LOW ) , priority ) ; } catch ( CoreException e ) { assertTrue ( false ) ; } JavaCore . setOptions ( options ) ; } public void testTags ( ) throws JavaModelException { Hashtable options = JavaCore . getOptions ( ) ; Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . COMPILER_TASK_TAGS , "<STR_LIT>" ) ; newOptions . put ( JavaCore . COMPILER_TASK_PRIORITIES , "<STR_LIT>" ) ; JavaCore . setOptions ( newOptions ) ; IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath pathToA = env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; IMarker [ ] markers = env . getTaskMarkersFor ( pathToA ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:3> , markers . length ) ; try { IMarker marker = markers [ <NUM_LIT:2> ] ; Object priority = marker . getAttribute ( IMarker . PRIORITY ) ; String message = ( String ) marker . getAttribute ( IMarker . MESSAGE ) ; assertEquals ( "<STR_LIT>" , "<STR_LIT>" , message ) ; assertNotNull ( "<STR_LIT>" , priority ) ; assertEquals ( "<STR_LIT>" , new Integer ( IMarker . PRIORITY_NORMAL ) , priority ) ; marker = markers [ <NUM_LIT:1> ] ; priority = marker . getAttribute ( IMarker . PRIORITY ) ; message = ( String ) marker . getAttribute ( IMarker . MESSAGE ) ; assertEquals ( "<STR_LIT>" , "<STR_LIT>" , message ) ; assertNotNull ( "<STR_LIT>" , priority ) ; assertEquals ( "<STR_LIT>" , new Integer ( IMarker . PRIORITY_HIGH ) , priority ) ; marker = markers [ <NUM_LIT:0> ] ; priority = marker . getAttribute ( IMarker . PRIORITY ) ; message = ( String ) marker . getAttribute ( IMarker . MESSAGE ) ; assertEquals ( "<STR_LIT>" , "<STR_LIT>" , message ) ; assertNotNull ( "<STR_LIT>" , priority ) ; assertEquals ( "<STR_LIT>" , new Integer ( IMarker . PRIORITY_NORMAL ) , priority ) ; } catch ( CoreException e ) { assertTrue ( false ) ; } JavaCore . setOptions ( options ) ; } public void testTags2 ( ) throws JavaModelException { Hashtable options = JavaCore . getOptions ( ) ; Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . COMPILER_TASK_TAGS , "<STR_LIT>" ) ; newOptions . put ( JavaCore . COMPILER_TASK_PRIORITIES , "<STR_LIT>" ) ; JavaCore . setOptions ( newOptions ) ; IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath pathToA = env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; IMarker [ ] markers = env . getTaskMarkersFor ( pathToA ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:2> , markers . length ) ; try { IMarker marker = markers [ <NUM_LIT:1> ] ; Object priority = marker . getAttribute ( IMarker . PRIORITY ) ; String message = ( String ) marker . getAttribute ( IMarker . MESSAGE ) ; assertEquals ( "<STR_LIT>" , "<STR_LIT>" , message ) ; assertNotNull ( "<STR_LIT>" , priority ) ; assertEquals ( "<STR_LIT>" , new Integer ( IMarker . PRIORITY_NORMAL ) , priority ) ; marker = markers [ <NUM_LIT:0> ] ; priority = marker . getAttribute ( IMarker . PRIORITY ) ; message = ( String ) marker . getAttribute ( IMarker . MESSAGE ) ; assertEquals ( "<STR_LIT>" , "<STR_LIT>" , message ) ; assertNotNull ( "<STR_LIT>" , priority ) ; assertEquals ( "<STR_LIT>" , new Integer ( IMarker . PRIORITY_NORMAL ) , priority ) ; } catch ( CoreException e ) { assertTrue ( false ) ; } JavaCore . setOptions ( options ) ; } public void testTags3 ( ) throws CoreException { Hashtable options = JavaCore . getOptions ( ) ; try { Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . COMPILER_TASK_TAGS , "<STR_LIT>" ) ; newOptions . put ( JavaCore . COMPILER_TASK_PRIORITIES , "<STR_LIT>" ) ; JavaCore . setOptions ( newOptions ) ; IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath pathToA = env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; IMarker [ ] markers = env . getTaskMarkersFor ( pathToA ) ; assertEquals ( "<STR_LIT>" , Boolean . FALSE , markers [ <NUM_LIT:0> ] . getAttribute ( IMarker . USER_EDITABLE ) ) ; } finally { JavaCore . setOptions ( options ) ; } } public void testUnusedImport ( ) throws JavaModelException { Hashtable options = JavaCore . getOptions ( ) ; Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . COMPILER_PB_UNUSED_IMPORT , JavaCore . WARNING ) ; JavaCore . setOptions ( newOptions ) ; IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:Test>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; JavaCore . setOptions ( options ) ; } public void test98667 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; } public void testBug164707 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; IJavaProject javaProject = env . getJavaProject ( projectPath ) ; javaProject . setOption ( JavaCore . COMPILER_SOURCE , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; } public void _testUpdateProjectPreferences ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; IPath cuPath = env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:Test>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; expectingSpecificProblemFor ( projectPath , new Problem ( "<STR_LIT>" , "<STR_LIT>" , cuPath , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_UNNECESSARY_CODE , IMarker . SEVERITY_WARNING ) ) ; IJavaProject project = env . getJavaProject ( projectPath ) ; project . setOption ( JavaCore . COMPILER_PB_UNUSED_IMPORT , JavaCore . IGNORE ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; } public void _testUpdateWkspPreferences ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; IPath cuPath = env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:Test>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( ) ; expectingSpecificProblemFor ( projectPath , new Problem ( "<STR_LIT>" , "<STR_LIT>" , cuPath , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_UNNECESSARY_CODE , IMarker . SEVERITY_WARNING ) ) ; JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; IEclipsePreferences preferences = manager . getInstancePreferences ( ) ; String unusedImport = preferences . get ( JavaCore . COMPILER_PB_UNUSED_IMPORT , null ) ; try { preferences . put ( JavaCore . COMPILER_PB_UNUSED_IMPORT , JavaCore . IGNORE ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; } finally { if ( unusedImport == null ) { preferences . remove ( JavaCore . COMPILER_PB_UNUSED_IMPORT ) ; } else { preferences . put ( JavaCore . COMPILER_PB_UNUSED_IMPORT , unusedImport ) ; } } } public void testTags4 ( ) throws JavaModelException { Hashtable options = JavaCore . getOptions ( ) ; Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . COMPILER_TASK_TAGS , "<STR_LIT>" ) ; newOptions . put ( JavaCore . COMPILER_TASK_PRIORITIES , "<STR_LIT>" ) ; JavaCore . setOptions ( newOptions ) ; IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath pathToA = env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; IMarker [ ] markers = env . getTaskMarkersFor ( pathToA ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:2> , markers . length ) ; try { IMarker marker = markers [ <NUM_LIT:1> ] ; Object priority = marker . getAttribute ( IMarker . PRIORITY ) ; String message = ( String ) marker . getAttribute ( IMarker . MESSAGE ) ; assertEquals ( "<STR_LIT>" , "<STR_LIT>" , message ) ; assertNotNull ( "<STR_LIT>" , priority ) ; assertEquals ( "<STR_LIT>" , new Integer ( IMarker . PRIORITY_LOW ) , priority ) ; marker = markers [ <NUM_LIT:0> ] ; priority = marker . getAttribute ( IMarker . PRIORITY ) ; message = ( String ) marker . getAttribute ( IMarker . MESSAGE ) ; assertEquals ( "<STR_LIT>" , "<STR_LIT>" , message ) ; assertNotNull ( "<STR_LIT>" , priority ) ; assertEquals ( "<STR_LIT>" , new Integer ( IMarker . PRIORITY_HIGH ) , priority ) ; } catch ( CoreException e ) { assertTrue ( false ) ; } JavaCore . setOptions ( options ) ; } } </s>
<s> package org . eclipse . jdt . core . tests . builder ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . compiler . * ; public class TestBuilderParticipant extends CompilationParticipant { public static CompilationParticipant PARTICIPANT ; public int aboutToBuild ( IJavaProject project ) { return PARTICIPANT . aboutToBuild ( project ) ; } public void buildFinished ( IJavaProject project ) { PARTICIPANT . buildFinished ( project ) ; } public void buildStarting ( BuildContext [ ] files , boolean isBatchBuild ) { PARTICIPANT . buildStarting ( files , isBatchBuild ) ; } public void cleanStarting ( IJavaProject project ) { PARTICIPANT . cleanStarting ( project ) ; } public boolean isActive ( IJavaProject project ) { return PARTICIPANT != null ; } public boolean isAnnotationProcessor ( ) { return PARTICIPANT != null && PARTICIPANT . isAnnotationProcessor ( ) ; } public void processAnnotations ( BuildContext [ ] files ) { PARTICIPANT . processAnnotations ( files ) ; } } </s>
<s> package org . eclipse . jdt . core . tests . builder ; import java . io . File ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . StringWriter ; import java . util . Arrays ; import java . util . Comparator ; import junit . framework . * ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . IMarker ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . IRegion ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . ToolFactory ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . tests . util . Util ; import org . eclipse . jdt . core . util . IClassFileReader ; import org . eclipse . jdt . core . util . IMethodInfo ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileReader ; import org . eclipse . jdt . internal . core . builder . JavaBuilder ; public class ErrorsTests extends BuilderTests { private static final Comparator COMPARATOR = new Comparator ( ) { public int compare ( Object o1 , Object o2 ) { IResource resource1 = ( IResource ) o1 ; IResource resource2 = ( IResource ) o2 ; String path1 = resource1 . getFullPath ( ) . toString ( ) ; String path2 = resource2 . getFullPath ( ) . toString ( ) ; int length1 = path1 . length ( ) ; int length2 = path2 . length ( ) ; if ( length1 != length2 ) { return length1 - length2 ; } return path1 . toString ( ) . compareTo ( path2 . toString ( ) ) ; } } ; public ErrorsTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( ErrorsTests . class ) ; } public void testErrors ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath collaboratorPath = env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingOnlyProblemsFor ( collaboratorPath ) ; expectingOnlySpecificProblemFor ( collaboratorPath , new Problem ( "<STR_LIT>" , "<STR_LIT>" , collaboratorPath , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_MEMBER , IMarker . SEVERITY_ERROR ) ) ; } public void testRenameToNonJava ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath cuPath = env . addClass ( root , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( projectPath ) ; expectingOnlyProblemsFor ( cuPath ) ; expectingOnlySpecificProblemFor ( cuPath , new Problem ( "<STR_LIT:X>" , "<STR_LIT>" , cuPath , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; env . renameCU ( root . append ( "<STR_LIT>" ) , "<STR_LIT>" , "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; } public void test0100 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; IPath classTest1 = env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; Problem [ ] prob1 = env . getProblemsFor ( classTest1 ) ; expectingSpecificProblemFor ( classTest1 , new Problem ( "<STR_LIT>" , "<STR_LIT>" , classTest1 , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; assertEquals ( JavaBuilder . SOURCE_ID , prob1 [ <NUM_LIT:0> ] . getSourceId ( ) ) ; } public void test0101 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; IPath classTest1 = env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; Problem [ ] prob1 = env . getProblemsFor ( classTest1 ) ; expectingSpecificProblemFor ( classTest1 , new Problem ( "<STR_LIT>" , "<STR_LIT>" , classTest1 , <NUM_LIT:31> , <NUM_LIT> , CategorizedProblem . CAT_SYNTAX , IMarker . SEVERITY_ERROR ) ) ; assertEquals ( JavaBuilder . SOURCE_ID , prob1 [ <NUM_LIT:0> ] . getSourceId ( ) ) ; } public void test0102 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; IPath classTest1 = env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; Problem [ ] prob1 = env . getProblemsFor ( classTest1 ) ; expectingSpecificProblemFor ( classTest1 , new Problem ( "<STR_LIT>" , "<STR_LIT>" , classTest1 , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_MEMBER , IMarker . SEVERITY_ERROR ) ) ; assertEquals ( JavaBuilder . SOURCE_ID , prob1 [ <NUM_LIT:0> ] . getSourceId ( ) ) ; } public void test0103 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; IPath classTest1 = env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; Problem [ ] prob1 = env . getProblemsFor ( classTest1 ) ; expectingSpecificProblemFor ( classTest1 , new Problem ( "<STR_LIT>" , "<STR_LIT>" , classTest1 , <NUM_LIT> , <NUM_LIT> , - <NUM_LIT:1> , IMarker . SEVERITY_ERROR ) ) ; assertEquals ( JavaBuilder . SOURCE_ID , prob1 [ <NUM_LIT:0> ] . getSourceId ( ) ) ; } public void test0104 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; IPath classTest1 = env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; Problem [ ] prob1 = env . getProblemsFor ( classTest1 ) ; expectingSpecificProblemFor ( classTest1 , new Problem ( "<STR_LIT>" , "<STR_LIT>" , classTest1 , <NUM_LIT:0> , <NUM_LIT:0> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) ) ; assertEquals ( JavaBuilder . SOURCE_ID , prob1 [ <NUM_LIT:0> ] . getSourceId ( ) ) ; } public void test0105 ( ) throws JavaModelException , CoreException , IOException { if ( "<STR_LIT>" . equals ( System . getProperty ( "<STR_LIT>" ) ) ) { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; IPath root = env . getPackageFragmentRootPath ( projectPath , "<STR_LIT>" ) ; IPath outputFolderPath = env . getOutputLocation ( projectPath ) ; File outputFolder = env . getWorkspaceRootPath ( ) . append ( outputFolderPath ) . toFile ( ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; try { fullBuild ( projectPath ) ; expectingNoProblems ( ) ; outputFolder . setReadOnly ( ) ; System . err . println ( "<STR_LIT>" ) ; System . err . println ( "<STR_LIT>" ) ; cleanBuild ( ) ; System . err . println ( "<STR_LIT>" ) ; expectingOnlySpecificProblemFor ( env . getWorkspaceRootPath ( ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" + env . getWorkspaceRootPath ( ) + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" , projectPath , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) ) ; } finally { Process process = null ; try { process = Runtime . getRuntime ( ) . exec ( "<STR_LIT>" + outputFolder . getAbsolutePath ( ) ) ; process . waitFor ( ) ; } catch ( InterruptedException e ) { } finally { if ( process != null ) { process . destroy ( ) ; } } } try { cleanBuild ( ) ; expectingNoProblems ( ) ; } catch ( Throwable t ) { Process process = null ; try { process = Runtime . getRuntime ( ) . exec ( "<STR_LIT>" + outputFolder . getAbsolutePath ( ) ) ; process . waitFor ( ) ; } catch ( InterruptedException ie ) { } finally { if ( process != null ) { process . destroy ( ) ; } } fail ( t . getMessage ( ) ) ; } } } public void test0106 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" , null , null ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath classTest1 = env . addClass ( root , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:I>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingSpecificProblemFor ( classTest1 , new Problem ( "<STR_LIT>" , "<STR_LIT>" , classTest1 , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_MEMBER , IMarker . SEVERITY_ERROR ) ) ; IJavaProject project = env . getJavaProject ( projectPath ) ; IRegion region = JavaCore . newRegion ( ) ; region . add ( project ) ; IResource [ ] resources = JavaCore . getGeneratedResources ( region , false ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:2> , resources . length ) ; Arrays . sort ( resources , COMPARATOR ) ; String actualOutput = getResourceOuput ( resources ) ; String expectedOutput = "<STR_LIT>" + "<STR_LIT>" ; assertEquals ( "<STR_LIT>" , Util . convertToIndependantLineDelimiter ( expectedOutput ) , actualOutput ) ; assertEquals ( "<STR_LIT>" , IResource . FILE , resources [ <NUM_LIT:1> ] . getType ( ) ) ; IFile classFile = ( IFile ) resources [ <NUM_LIT:1> ] ; IClassFileReader classFileReader = null ; InputStream stream = null ; try { stream = classFile . getContents ( ) ; classFileReader = ToolFactory . createDefaultClassFileReader ( stream , IClassFileReader . ALL ) ; } catch ( CoreException e ) { e . printStackTrace ( ) ; } finally { if ( stream != null ) { try { stream . close ( ) ; } catch ( IOException e ) { } } } assertNotNull ( "<STR_LIT>" , classFileReader ) ; IMethodInfo [ ] methodInfos = classFileReader . getMethodInfos ( ) ; IMethodInfo found = null ; loop : for ( int i = <NUM_LIT:0> , max = methodInfos . length ; i < max ; i ++ ) { IMethodInfo methodInfo = methodInfos [ i ] ; if ( CharOperation . equals ( methodInfo . getName ( ) , "<STR_LIT:foo>" . toCharArray ( ) ) ) { found = methodInfo ; break loop ; } } assertNotNull ( "<STR_LIT>" , found ) ; assertTrue ( "<STR_LIT>" , found . isSynthetic ( ) ) ; env . removeProject ( projectPath ) ; } public void test0107 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" , null , null ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath classTest1 = env . addClass ( root , "<STR_LIT>" , "<STR_LIT:C>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; incrementalBuild ( projectPath ) ; expectingOnlySpecificProblemsFor ( classTest1 , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , classTest1 , <NUM_LIT> , <NUM_LIT:30> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" , classTest1 , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" , classTest1 , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) } ) ; IJavaProject project = env . getJavaProject ( projectPath ) ; IRegion region = JavaCore . newRegion ( ) ; region . add ( project ) ; IResource [ ] resources = JavaCore . getGeneratedResources ( region , false ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:1> , resources . length ) ; Arrays . sort ( resources , COMPARATOR ) ; String actualOutput = getResourceOuput ( resources ) ; String expectedOutput = "<STR_LIT>" ; assertEquals ( "<STR_LIT>" , Util . convertToIndependantLineDelimiter ( expectedOutput ) , actualOutput ) ; assertEquals ( "<STR_LIT>" , IResource . FILE , resources [ <NUM_LIT:0> ] . getType ( ) ) ; IFile classFile = ( IFile ) resources [ <NUM_LIT:0> ] ; InputStream stream = null ; try { stream = classFile . getContents ( ) ; ClassFileReader . read ( stream , "<STR_LIT>" ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; assertTrue ( "<STR_LIT>" , false ) ; } finally { if ( stream != null ) { try { stream . close ( ) ; } catch ( IOException e ) { } } } } private String getResourceOuput ( IResource [ ] resources ) { StringWriter stringWriter = new StringWriter ( ) ; PrintWriter writer = new PrintWriter ( stringWriter ) ; for ( int i = <NUM_LIT:0> , max = resources . length ; i < max ; i ++ ) { writer . println ( resources [ i ] . getFullPath ( ) . toString ( ) ) ; } writer . flush ( ) ; writer . close ( ) ; return Util . convertToIndependantLineDelimiter ( String . valueOf ( stringWriter ) ) ; } } </s>
<s> package org . eclipse . jdt . core . tests . builder ; import java . util . Hashtable ; import junit . framework . Test ; import org . eclipse . core . resources . IMarker ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . Path ; import org . eclipse . jdt . core . IAccessRule ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . core . tests . util . Util ; public class MultiProjectTests extends BuilderTests { public MultiProjectTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( MultiProjectTests . class ) ; } public void testCompileOnlyDependent ( ) throws JavaModelException { IPath project1Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project1Path , Util . getJavaClassLibs ( ) ) ; IPath root1 = env . getPackageFragmentRootPath ( project1Path , "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" ) ; IPath project2Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project2Path , Util . getJavaClassLibs ( ) ) ; env . addRequiredProject ( project2Path , project1Path ) ; IPath root2 = env . getPackageFragmentRootPath ( project2Path , "<STR_LIT>" ) ; env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" ) ; IPath project3Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project3Path , Util . getJavaClassLibs ( ) ) ; IPath root3 = env . getPackageFragmentRootPath ( project3Path , "<STR_LIT>" ) ; env . addClass ( root3 , "<STR_LIT>" , "<STR_LIT:C>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingCompiledClasses ( new String [ ] { "<STR_LIT:A>" , "<STR_LIT:B>" } ) ; } public void testCompileOnlyStructuralDependent ( ) throws JavaModelException { IPath project1Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project1Path , Util . getJavaClassLibs ( ) ) ; IPath root1 = env . getPackageFragmentRootPath ( project1Path , "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; IPath project2Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project2Path , Util . getJavaClassLibs ( ) ) ; env . addRequiredProject ( project2Path , project1Path ) ; IPath root2 = env . getPackageFragmentRootPath ( project2Path , "<STR_LIT>" ) ; env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" ) ; IPath project3Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project3Path , Util . getJavaClassLibs ( ) ) ; IPath root3 = env . getPackageFragmentRootPath ( project3Path , "<STR_LIT>" ) ; env . addClass ( root3 , "<STR_LIT>" , "<STR_LIT:C>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingCompiledClasses ( new String [ ] { "<STR_LIT:A>" , "<STR_LIT>" } ) ; } public void testRemoveField ( ) throws JavaModelException { Hashtable options = JavaCore . getOptions ( ) ; options . put ( JavaCore . COMPILER_PB_UNUSED_LOCAL , JavaCore . IGNORE ) ; JavaCore . setOptions ( options ) ; IPath project1Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project1Path , Util . getJavaClassLibs ( ) ) ; IPath root1 = env . getPackageFragmentRootPath ( project1Path , "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath project2Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project2Path , Util . getJavaClassLibs ( ) ) ; env . addRequiredProject ( project2Path , project1Path ) ; IPath root2 = env . getPackageFragmentRootPath ( project2Path , "<STR_LIT>" ) ; IPath b = env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingSpecificProblemFor ( b , new Problem ( "<STR_LIT>" , "<STR_LIT>" , b , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_MEMBER , IMarker . SEVERITY_ERROR ) ) ; } public void testCompileOrder ( ) throws JavaModelException { Hashtable options = JavaCore . getOptions ( ) ; Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . CORE_CIRCULAR_CLASSPATH , JavaCore . WARNING ) ; JavaCore . setOptions ( newOptions ) ; IPath p1 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( p1 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p1 , "<STR_LIT>" ) ; IPath root1 = env . addPackageFragmentRoot ( p1 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p1 , "<STR_LIT>" ) ; IPath c1 = env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath p2 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( p2 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p2 , "<STR_LIT>" ) ; IPath root2 = env . addPackageFragmentRoot ( p2 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p2 , "<STR_LIT>" ) ; IPath c2 = env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath p3 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( p3 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p3 , "<STR_LIT>" ) ; IPath root3 = env . addPackageFragmentRoot ( p3 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p3 , "<STR_LIT>" ) ; IPath c3 = env . addClass ( root3 , "<STR_LIT>" , "<STR_LIT:Z>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . setBuildOrder ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" } ) ; fullBuild ( ) ; expectingCompilingOrder ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" } ) ; IPath workspaceRootPath = env . getWorkspaceRootPath ( ) ; expectingOnlySpecificProblemsFor ( workspaceRootPath , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , c3 , <NUM_LIT:31> , <NUM_LIT:32> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" , c2 , <NUM_LIT:31> , <NUM_LIT:32> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" , c1 , <NUM_LIT:31> , <NUM_LIT:32> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) } ) ; JavaCore . setOptions ( options ) ; } public void testCycle1 ( ) throws JavaModelException { Hashtable options = JavaCore . getOptions ( ) ; Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . CORE_CIRCULAR_CLASSPATH , JavaCore . WARNING ) ; JavaCore . setOptions ( newOptions ) ; IPath p1 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( p1 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p1 , "<STR_LIT>" ) ; IPath root1 = env . addPackageFragmentRoot ( p1 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p1 , "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath p2 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( p2 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p2 , "<STR_LIT>" ) ; IPath root2 = env . addPackageFragmentRoot ( p2 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p2 , "<STR_LIT>" ) ; env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath p3 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( p3 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p3 , "<STR_LIT>" ) ; IPath root3 = env . addPackageFragmentRoot ( p3 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p3 , "<STR_LIT>" ) ; env . addClass ( root3 , "<STR_LIT>" , "<STR_LIT:Z>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addRequiredProject ( p1 , p2 ) ; env . addRequiredProject ( p1 , p3 ) ; env . addRequiredProject ( p2 , p1 ) ; env . addRequiredProject ( p2 , p3 ) ; env . addRequiredProject ( p3 , p1 ) ; try { env . setBuildOrder ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" } ) ; fullBuild ( ) ; expectingCompilingOrder ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" } ) ; expectingOnlySpecificProblemFor ( p1 , new Problem ( "<STR_LIT>" , "<STR_LIT>" , p1 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) ) ; expectingOnlySpecificProblemFor ( p2 , new Problem ( "<STR_LIT>" , "<STR_LIT>" , p2 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) ) ; expectingOnlySpecificProblemFor ( p3 , new Problem ( "<STR_LIT>" , "<STR_LIT>" , p3 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) ) ; JavaCore . setOptions ( options ) ; } finally { env . setBuildOrder ( null ) ; } } public void testCycle2 ( ) throws JavaModelException { Hashtable options = JavaCore . getOptions ( ) ; Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . CORE_CIRCULAR_CLASSPATH , JavaCore . WARNING ) ; JavaCore . setOptions ( newOptions ) ; IPath p1 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( p1 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p1 , "<STR_LIT>" ) ; IPath root1 = env . addPackageFragmentRoot ( p1 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p1 , "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath p2 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( p2 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p2 , "<STR_LIT>" ) ; IPath root2 = env . addPackageFragmentRoot ( p2 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p2 , "<STR_LIT>" ) ; IPath c2 = env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath p3 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( p3 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p3 , "<STR_LIT>" ) ; IPath root3 = env . addPackageFragmentRoot ( p3 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p3 , "<STR_LIT>" ) ; env . addClass ( root3 , "<STR_LIT>" , "<STR_LIT:Z>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addRequiredProject ( p1 , p2 ) ; env . addRequiredProject ( p1 , p3 ) ; env . addRequiredProject ( p2 , p1 ) ; env . addRequiredProject ( p2 , p3 ) ; env . addRequiredProject ( p3 , p1 ) ; try { env . setBuildOrder ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" } ) ; fullBuild ( ) ; expectingCompilingOrder ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" } ) ; expectingOnlySpecificProblemFor ( p1 , new Problem ( "<STR_LIT>" , "<STR_LIT>" , p1 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) ) ; expectingOnlySpecificProblemsFor ( p2 , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , c2 , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_MEMBER , IMarker . SEVERITY_ERROR ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" , p2 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) } ) ; expectingOnlySpecificProblemFor ( p3 , new Problem ( "<STR_LIT>" , "<STR_LIT>" , p3 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) ) ; JavaCore . setOptions ( options ) ; } finally { env . setBuildOrder ( null ) ; } } public void testCycle3 ( ) throws JavaModelException { Hashtable options = JavaCore . getOptions ( ) ; Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . CORE_CIRCULAR_CLASSPATH , JavaCore . WARNING ) ; JavaCore . setOptions ( newOptions ) ; IPath p1 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( p1 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p1 , "<STR_LIT>" ) ; IPath root1 = env . addPackageFragmentRoot ( p1 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p1 , "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath p2 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( p2 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p2 , "<STR_LIT>" ) ; IPath root2 = env . addPackageFragmentRoot ( p2 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p2 , "<STR_LIT>" ) ; IPath c2 = env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath p3 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( p3 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p3 , "<STR_LIT>" ) ; IPath root3 = env . addPackageFragmentRoot ( p3 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p3 , "<STR_LIT>" ) ; env . addClass ( root3 , "<STR_LIT>" , "<STR_LIT:Z>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addRequiredProject ( p1 , p2 ) ; env . addRequiredProject ( p1 , p3 ) ; env . addRequiredProject ( p2 , p1 ) ; env . addRequiredProject ( p2 , p3 ) ; env . addRequiredProject ( p3 , p1 ) ; try { env . setBuildOrder ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" } ) ; fullBuild ( ) ; expectingCompilingOrder ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" } ) ; expectingOnlySpecificProblemFor ( p1 , new Problem ( "<STR_LIT>" , "<STR_LIT>" , p1 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) ) ; expectingOnlySpecificProblemFor ( p2 , new Problem ( "<STR_LIT>" , "<STR_LIT>" , p2 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) ) ; expectingOnlySpecificProblemFor ( p3 , new Problem ( "<STR_LIT>" , "<STR_LIT>" , p3 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingCompilingOrder ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" } ) ; expectingOnlySpecificProblemFor ( p1 , new Problem ( "<STR_LIT>" , "<STR_LIT>" , p1 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) ) ; expectingOnlySpecificProblemsFor ( p2 , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , c2 , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_MEMBER , IMarker . SEVERITY_ERROR ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" , p2 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) } ) ; expectingOnlySpecificProblemFor ( p3 , new Problem ( "<STR_LIT>" , "<STR_LIT>" , p3 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) ) ; JavaCore . setOptions ( options ) ; } finally { env . setBuildOrder ( null ) ; } } public void testCycle4 ( ) throws JavaModelException { Hashtable options = JavaCore . getOptions ( ) ; Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . CORE_CIRCULAR_CLASSPATH , JavaCore . WARNING ) ; JavaCore . setOptions ( newOptions ) ; IPath p1 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( p1 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p1 , "<STR_LIT>" ) ; IPath root1 = env . addPackageFragmentRoot ( p1 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p1 , "<STR_LIT>" ) ; IPath p2 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( p2 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p2 , "<STR_LIT>" ) ; IPath root2 = env . addPackageFragmentRoot ( p2 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p2 , "<STR_LIT>" ) ; IPath c2 = env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath p3 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( p3 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p3 , "<STR_LIT>" ) ; IPath root3 = env . addPackageFragmentRoot ( p3 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p3 , "<STR_LIT>" ) ; IPath c3 = env . addClass ( root3 , "<STR_LIT>" , "<STR_LIT:Z>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addRequiredProject ( p1 , p2 ) ; env . addRequiredProject ( p1 , p3 ) ; env . addRequiredProject ( p2 , p1 ) ; env . addRequiredProject ( p2 , p3 ) ; env . addRequiredProject ( p3 , p1 ) ; try { env . setBuildOrder ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" } ) ; fullBuild ( ) ; expectingCompilingOrder ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" } ) ; expectingOnlySpecificProblemFor ( p1 , new Problem ( "<STR_LIT>" , "<STR_LIT>" , p1 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) ) ; expectingOnlySpecificProblemsFor ( p2 , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , c2 , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" , c2 , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_MEMBER , IMarker . SEVERITY_ERROR ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" , c2 , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_IMPORT , IMarker . SEVERITY_ERROR ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" , c2 , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" , p2 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) } ) ; expectingOnlySpecificProblemsFor ( p3 , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , c3 , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" , c3 , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_IMPORT , IMarker . SEVERITY_ERROR ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" , p3 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) } ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingCompilingOrder ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" } ) ; expectingOnlySpecificProblemFor ( p1 , new Problem ( "<STR_LIT>" , "<STR_LIT>" , p1 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) ) ; expectingOnlySpecificProblemFor ( p2 , new Problem ( "<STR_LIT>" , "<STR_LIT>" , p2 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) ) ; expectingOnlySpecificProblemFor ( p3 , new Problem ( "<STR_LIT>" , "<STR_LIT>" , p3 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) ) ; JavaCore . setOptions ( options ) ; } finally { env . setBuildOrder ( null ) ; } } public void testCycle5 ( ) throws JavaModelException { Hashtable options = JavaCore . getOptions ( ) ; Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . CORE_CIRCULAR_CLASSPATH , JavaCore . WARNING ) ; JavaCore . setOptions ( newOptions ) ; IPath p1 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( p1 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p1 , "<STR_LIT>" ) ; IPath root1 = env . addPackageFragmentRoot ( p1 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p1 , "<STR_LIT>" ) ; IPath c1 = env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath p2 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( p2 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p2 , "<STR_LIT>" ) ; IPath root2 = env . addPackageFragmentRoot ( p2 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p2 , "<STR_LIT>" ) ; IPath c2 = env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addRequiredProject ( p1 , p2 ) ; env . addRequiredProject ( p2 , p1 ) ; try { env . setBuildOrder ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" } ) ; fullBuild ( ) ; expectingCompilingOrder ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" } ) ; expectingOnlySpecificProblemsFor ( p1 , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , c1 , <NUM_LIT:32> , <NUM_LIT> , CategorizedProblem . CAT_IMPORT , IMarker . SEVERITY_ERROR ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" , p1 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) } ) ; expectingOnlySpecificProblemsFor ( p2 , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , c2 , <NUM_LIT:32> , <NUM_LIT> , CategorizedProblem . CAT_IMPORT , IMarker . SEVERITY_ERROR ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" , p2 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) } ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingCompilingOrder ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" } ) ; expectingOnlySpecificProblemsFor ( p1 , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , c1 , <NUM_LIT:32> , <NUM_LIT> , CategorizedProblem . CAT_UNNECESSARY_CODE , IMarker . SEVERITY_WARNING ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" , p1 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) } ) ; expectingOnlySpecificProblemsFor ( p2 , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , c2 , <NUM_LIT:32> , <NUM_LIT> , CategorizedProblem . CAT_UNNECESSARY_CODE , IMarker . SEVERITY_WARNING ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" , p2 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) } ) ; JavaCore . setOptions ( options ) ; } finally { env . setBuildOrder ( null ) ; } } public void testCycle6 ( ) throws JavaModelException { Hashtable options = JavaCore . getOptions ( ) ; Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . CORE_CIRCULAR_CLASSPATH , JavaCore . WARNING ) ; JavaCore . setOptions ( newOptions ) ; IPath p1 = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( p1 , "<STR_LIT>" ) ; IPath root1 = env . addPackageFragmentRoot ( p1 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p1 , "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath p2 = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( p2 , "<STR_LIT>" ) ; IPath root2 = env . addPackageFragmentRoot ( p2 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p2 , "<STR_LIT>" ) ; env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath p3 = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( p3 , "<STR_LIT>" ) ; IPath root3 = env . addPackageFragmentRoot ( p3 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p3 , "<STR_LIT>" ) ; env . addClass ( root3 , "<STR_LIT>" , "<STR_LIT:String>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath [ ] accessiblePaths = new IPath [ ] { new Path ( "<STR_LIT>" ) } ; IPath [ ] forbiddenPaths = new IPath [ ] { new Path ( "<STR_LIT>" ) } ; env . addRequiredProject ( p1 , p2 , accessiblePaths , forbiddenPaths , false ) ; env . addRequiredProject ( p1 , p3 , accessiblePaths , forbiddenPaths , false ) ; env . addRequiredProject ( p2 , p1 , accessiblePaths , forbiddenPaths , false ) ; env . addRequiredProject ( p2 , p3 , accessiblePaths , forbiddenPaths , false ) ; env . addRequiredProject ( p3 , p1 , accessiblePaths , forbiddenPaths , false ) ; env . addRequiredProject ( p3 , p2 , accessiblePaths , forbiddenPaths , false ) ; try { fullBuild ( ) ; expectingOnlySpecificProblemsFor ( p1 , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , p1 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) } ) ; expectingOnlySpecificProblemsFor ( p2 , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , p2 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) } ) ; expectingOnlySpecificProblemsFor ( p3 , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , p3 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) } ) ; } finally { JavaCore . setOptions ( options ) ; } } public void testCycle7 ( ) throws JavaModelException { Hashtable options = JavaCore . getOptions ( ) ; Hashtable newOptions = JavaCore . getOptions ( ) ; newOptions . put ( JavaCore . CORE_CIRCULAR_CLASSPATH , JavaCore . WARNING ) ; JavaCore . setOptions ( newOptions ) ; IPath p1 = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( p1 , "<STR_LIT>" ) ; IPath root1 = env . addPackageFragmentRoot ( p1 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p1 , "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath p2 = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( p2 , "<STR_LIT>" ) ; IPath root2 = env . addPackageFragmentRoot ( p2 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p2 , "<STR_LIT>" ) ; env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath p3 = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( p3 , "<STR_LIT>" ) ; IPath root3 = env . addPackageFragmentRoot ( p3 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p3 , "<STR_LIT>" ) ; env . addClass ( root3 , "<STR_LIT>" , "<STR_LIT:String>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath [ ] accessiblePaths = new IPath [ ] { new Path ( "<STR_LIT>" ) } ; IPath [ ] forbiddenPaths = new IPath [ ] { new Path ( "<STR_LIT>" ) } ; env . addRequiredProject ( p1 , p2 , accessiblePaths , forbiddenPaths , false ) ; env . addRequiredProject ( p1 , p3 , accessiblePaths , forbiddenPaths , false ) ; env . addRequiredProject ( p2 , p1 , accessiblePaths , forbiddenPaths , false ) ; env . addRequiredProject ( p2 , p3 , accessiblePaths , forbiddenPaths , false ) ; env . addRequiredProject ( p3 , p1 , accessiblePaths , forbiddenPaths , false ) ; env . addRequiredProject ( p3 , p2 , accessiblePaths , forbiddenPaths , false ) ; try { fullBuild ( ) ; expectingOnlySpecificProblemsFor ( p1 , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , p1 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) } ) ; expectingOnlySpecificProblemsFor ( p2 , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , p2 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) } ) ; expectingOnlySpecificProblemsFor ( p3 , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , p3 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) } ) ; } finally { JavaCore . setOptions ( options ) ; } } public void testExcludePartOfAnotherProject1 ( ) throws JavaModelException { IPath project1Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project1Path , Util . getJavaClassLibs ( ) ) ; IPath root1 = env . getPackageFragmentRootPath ( project1Path , "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath project2Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project2Path , Util . getJavaClassLibs ( ) ) ; env . addRequiredProject ( project2Path , project1Path , new IPath [ ] { } , new IPath [ ] { new Path ( "<STR_LIT>" ) } , false ) ; IPath root2 = env . getPackageFragmentRootPath ( project2Path , "<STR_LIT>" ) ; env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:C>" , "<STR_LIT>" + "<STR_LIT>" ) ; IPath d = env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:D>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingSpecificProblemFor ( project2Path , new Problem ( "<STR_LIT>" , "<STR_LIT>" , d , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; } public void testExcludePartOfAnotherProject2 ( ) throws JavaModelException { IPath project1Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project1Path , Util . getJavaClassLibs ( ) ) ; IPath root1 = env . getPackageFragmentRootPath ( project1Path , "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath project2Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project2Path , Util . getJavaClassLibs ( ) ) ; env . addRequiredProject ( project2Path , project1Path , new IPath [ ] { } , new IPath [ ] { new Path ( "<STR_LIT>" ) } , false ) ; IPath root2 = env . getPackageFragmentRootPath ( project2Path , "<STR_LIT>" ) ; env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:C>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; IPath d = env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:D>" , "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingSpecificProblemFor ( project2Path , new Problem ( "<STR_LIT>" , "<STR_LIT>" , d , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; } public void testExcludePartOfAnotherProject3 ( ) throws JavaModelException { IPath project1Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project1Path , Util . getJavaClassLibs ( ) ) ; IPath root1 = env . getPackageFragmentRootPath ( project1Path , "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath project2Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project2Path , Util . getJavaClassLibs ( ) ) ; env . addRequiredProject ( project2Path , project1Path , new IPath [ ] { } , new IPath [ ] { new Path ( "<STR_LIT>" ) } , false ) ; IPath root2 = env . getPackageFragmentRootPath ( project2Path , "<STR_LIT>" ) ; env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:C>" , "<STR_LIT>" + "<STR_LIT>" ) ; IPath d = env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:D>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingSpecificProblemFor ( project2Path , new Problem ( "<STR_LIT>" , "<STR_LIT>" , d , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; env . removeRequiredProject ( project2Path , project1Path ) ; env . addRequiredProject ( project2Path , project1Path , new IPath [ ] { } , new IPath [ ] { } , false ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; } public void testIncludePartOfAnotherProject1 ( ) throws JavaModelException { IPath project1Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project1Path , Util . getJavaClassLibs ( ) ) ; IPath root1 = env . getPackageFragmentRootPath ( project1Path , "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath project2Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project2Path , Util . getJavaClassLibs ( ) ) ; env . addRequiredProject ( project2Path , project1Path , new IPath [ ] { new Path ( "<STR_LIT>" ) } , new IPath [ ] { new Path ( "<STR_LIT>" ) } , false ) ; IPath root2 = env . getPackageFragmentRootPath ( project2Path , "<STR_LIT>" ) ; env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:C>" , "<STR_LIT>" + "<STR_LIT>" ) ; IPath d = env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:D>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingSpecificProblemFor ( project2Path , new Problem ( "<STR_LIT>" , "<STR_LIT>" , d , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; } public void testIncludePartOfAnotherProject2 ( ) throws JavaModelException { IPath project1Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project1Path , Util . getJavaClassLibs ( ) ) ; IPath root1 = env . getPackageFragmentRootPath ( project1Path , "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath project2Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project2Path , Util . getJavaClassLibs ( ) ) ; env . addRequiredProject ( project2Path , project1Path , new IPath [ ] { new Path ( "<STR_LIT>" ) } , new IPath [ ] { new Path ( "<STR_LIT>" ) } , false ) ; IPath root2 = env . getPackageFragmentRootPath ( project2Path , "<STR_LIT>" ) ; env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:C>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; IPath d = env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:D>" , "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingSpecificProblemFor ( project2Path , new Problem ( "<STR_LIT>" , "<STR_LIT>" , d , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; } public void testIncludePartOfAnotherProject3 ( ) throws JavaModelException { IPath project1Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project1Path , Util . getJavaClassLibs ( ) ) ; IPath root1 = env . getPackageFragmentRootPath ( project1Path , "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath project2Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project2Path , Util . getJavaClassLibs ( ) ) ; env . addRequiredProject ( project2Path , project1Path , new IPath [ ] { new Path ( "<STR_LIT>" ) } , new IPath [ ] { new Path ( "<STR_LIT>" ) } , false ) ; IPath root2 = env . getPackageFragmentRootPath ( project2Path , "<STR_LIT>" ) ; env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:C>" , "<STR_LIT>" + "<STR_LIT>" ) ; IPath d = env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:D>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingSpecificProblemFor ( project2Path , new Problem ( "<STR_LIT>" , "<STR_LIT>" , d , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; env . removeRequiredProject ( project2Path , project1Path ) ; env . addRequiredProject ( project2Path , project1Path , new IPath [ ] { } , new IPath [ ] { } , false ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; } public void testIgnoreIfBetterNonAccessibleRule1 ( ) throws JavaModelException { IPath project1Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project1Path , Util . getJavaClassLibs ( ) ) ; IPath root1 = env . getPackageFragmentRootPath ( project1Path , "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath project2Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project2Path , Util . getJavaClassLibs ( ) ) ; IPath root2 = env . getPackageFragmentRootPath ( project2Path , "<STR_LIT>" ) ; env . addClass ( root2 , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath project3Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project3Path , Util . getJavaClassLibs ( ) ) ; env . addRequiredProject ( project3Path , project1Path , new Path ( "<STR_LIT>" ) , IAccessRule . K_NON_ACCESSIBLE | IAccessRule . IGNORE_IF_BETTER ) ; env . addRequiredProject ( project3Path , project2Path , new Path ( "<STR_LIT>" ) , IAccessRule . K_ACCESSIBLE ) ; IPath root3 = env . getPackageFragmentRootPath ( project3Path , "<STR_LIT>" ) ; env . addClass ( root3 , "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; } public void testIgnoreIfBetterNonAccessibleRule2 ( ) throws JavaModelException { IPath project1Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project1Path , Util . getJavaClassLibs ( ) ) ; IPath root1 = env . getPackageFragmentRootPath ( project1Path , "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath project2Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project2Path , Util . getJavaClassLibs ( ) ) ; IPath root2 = env . getPackageFragmentRootPath ( project2Path , "<STR_LIT>" ) ; env . addClass ( root2 , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath project3Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project3Path , Util . getJavaClassLibs ( ) ) ; env . addRequiredProject ( project3Path , project1Path , new Path ( "<STR_LIT>" ) , IAccessRule . K_NON_ACCESSIBLE | IAccessRule . IGNORE_IF_BETTER ) ; env . addRequiredProject ( project3Path , project2Path , new Path ( "<STR_LIT>" ) , IAccessRule . K_DISCOURAGED ) ; IPath root3 = env . getPackageFragmentRootPath ( project3Path , "<STR_LIT>" ) ; IPath b = env . addClass ( root3 , "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingSpecificProblemFor ( project3Path , new Problem ( "<STR_LIT>" , "<STR_LIT>" , b , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_RESTRICTION , IMarker . SEVERITY_WARNING ) ) ; } public void testMissingRequiredBinaries ( ) throws JavaModelException { IPath p1 = env . addProject ( "<STR_LIT>" ) ; IPath p2 = env . addProject ( "<STR_LIT>" ) ; IPath p3 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( p1 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p1 , "<STR_LIT>" ) ; IPath root1 = env . addPackageFragmentRoot ( p1 , "<STR_LIT:src>" ) ; env . addRequiredProject ( p1 , p2 ) ; env . setOutputFolder ( p1 , "<STR_LIT>" ) ; env . addExternalJars ( p2 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p2 , "<STR_LIT>" ) ; IPath root2 = env . addPackageFragmentRoot ( p2 , "<STR_LIT:src>" ) ; env . addRequiredProject ( p2 , p3 ) ; env . setOutputFolder ( p2 , "<STR_LIT>" ) ; env . addExternalJars ( p3 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p3 , "<STR_LIT>" ) ; IPath root3 = env . addPackageFragmentRoot ( p3 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p3 , "<STR_LIT>" ) ; IPath x = env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root3 , "<STR_LIT>" , "<STR_LIT:Z>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; try { fullBuild ( ) ; expectingOnlySpecificProblemsFor ( p1 , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , x , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" , p1 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) } ) ; } finally { env . setBuildOrder ( null ) ; } } public void test100_class_folder_exported ( ) throws JavaModelException { IPath P1 = env . addProject ( "<STR_LIT>" ) ; env . setOutputFolder ( P1 , "<STR_LIT>" ) ; env . addExternalJars ( P1 , Util . getJavaClassLibs ( ) ) ; env . addClass ( env . addPackage ( env . getPackageFragmentRootPath ( P1 , "<STR_LIT>" ) , "<STR_LIT:p>" ) , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; env . removePackageFragmentRoot ( P1 , "<STR_LIT>" ) ; env . addClassFolder ( P1 , P1 . append ( "<STR_LIT>" ) , true ) ; IPath P2 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( P2 , Util . getJavaClassLibs ( ) ) ; env . addRequiredProject ( P2 , P1 ) ; env . addClass ( env . getPackageFragmentRootPath ( P2 , "<STR_LIT>" ) , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; } public void test101_class_folder_non_exported ( ) throws JavaModelException { IPath P1 = env . addProject ( "<STR_LIT>" ) ; env . setOutputFolder ( P1 , "<STR_LIT>" ) ; env . addExternalJars ( P1 , Util . getJavaClassLibs ( ) ) ; env . addClass ( env . addPackage ( env . getPackageFragmentRootPath ( P1 , "<STR_LIT>" ) , "<STR_LIT:p>" ) , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; env . removePackageFragmentRoot ( P1 , "<STR_LIT>" ) ; env . addClassFolder ( P1 , P1 . append ( "<STR_LIT>" ) , false ) ; IPath P2 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( P2 , Util . getJavaClassLibs ( ) ) ; env . addRequiredProject ( P2 , P1 ) ; IPath c = env . addClass ( env . getPackageFragmentRootPath ( P2 , "<STR_LIT>" ) , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( ) ; expectingSpecificProblemsFor ( P2 , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , c , <NUM_LIT:7> , <NUM_LIT:8> , CategorizedProblem . CAT_IMPORT , IMarker . SEVERITY_ERROR ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" , c , <NUM_LIT:31> , <NUM_LIT:32> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) } ) ; } public void test102_missing_required_binaries ( ) throws JavaModelException { IPath p1 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( p1 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p1 , "<STR_LIT>" ) ; IPath root1 = env . addPackageFragmentRoot ( p1 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p1 , "<STR_LIT>" ) ; IPath p2 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( p2 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p2 , "<STR_LIT>" ) ; IPath root2 = env . addPackageFragmentRoot ( p2 , "<STR_LIT:src>" ) ; env . addRequiredProject ( p2 , p1 ) ; env . setOutputFolder ( p2 , "<STR_LIT>" ) ; IPath p3 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( p3 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p3 , "<STR_LIT>" ) ; IPath root3 = env . addPackageFragmentRoot ( p3 , "<STR_LIT:src>" ) ; env . addRequiredProject ( p3 , p2 ) ; env . setOutputFolder ( p3 , "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:I>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" ) ; IPath y = env . addClass ( root3 , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; try { fullBuild ( ) ; expectingOnlySpecificProblemsFor ( p3 , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , p3 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" , y , <NUM_LIT> , <NUM_LIT:24> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) , } ) ; } finally { env . setBuildOrder ( null ) ; } } public void test103_missing_required_binaries ( ) throws JavaModelException { IPath p1 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( p1 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p1 , "<STR_LIT>" ) ; IPath root1 = env . addPackageFragmentRoot ( p1 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p1 , "<STR_LIT>" ) ; IPath p2 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( p2 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p2 , "<STR_LIT>" ) ; IPath root2 = env . addPackageFragmentRoot ( p2 , "<STR_LIT:src>" ) ; env . addRequiredProject ( p2 , p1 ) ; env . setOutputFolder ( p2 , "<STR_LIT>" ) ; IPath p3 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( p3 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p3 , "<STR_LIT>" ) ; IPath root3 = env . addPackageFragmentRoot ( p3 , "<STR_LIT:src>" ) ; env . addRequiredProject ( p3 , p2 ) ; env . setOutputFolder ( p3 , "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:I>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" ) ; IPath y = env . addClass ( root3 , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; try { fullBuild ( ) ; expectingOnlySpecificProblemsFor ( p3 , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , p3 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" , y , <NUM_LIT:0> , <NUM_LIT:0> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) , } ) ; } finally { env . setBuildOrder ( null ) ; } } } </s>
<s> package org . eclipse . jdt . core . tests . builder ; import junit . framework . * ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . tests . util . Util ; public class CopyResourceTests extends BuilderTests { public CopyResourceTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( CopyResourceTests . class ) ; } public void testFilteredResources ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath src = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , new IPath [ ] { new org . eclipse . core . runtime . Path ( "<STR_LIT>" ) } , new IPath [ ] { new org . eclipse . core . runtime . Path ( "<STR_LIT>" ) } , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addClass ( src , "<STR_LIT:foo>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( src , "<STR_LIT:bar>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addFolder ( src , "<STR_LIT>" ) ; IPath ignored = env . addFolder ( src , "<STR_LIT>" ) ; env . addFile ( ignored , "<STR_LIT>" , "<STR_LIT>" ) ; env . addFile ( src . append ( "<STR_LIT:bar>" ) , "<STR_LIT>" , "<STR_LIT>" ) ; org . eclipse . jdt . core . IJavaProject p = env . getJavaProject ( "<STR_LIT>" ) ; java . util . Map options = p . getOptions ( true ) ; options . put ( org . eclipse . jdt . core . JavaCore . CORE_JAVA_BUILD_RESOURCE_COPY_FILTER , "<STR_LIT>" ) ; options . put ( org . eclipse . jdt . core . JavaCore . CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER , "<STR_LIT>" ) ; p . setOptions ( options ) ; int max = org . eclipse . jdt . internal . core . builder . AbstractImageBuilder . MAX_AT_ONCE ; try { org . eclipse . jdt . internal . core . builder . AbstractImageBuilder . MAX_AT_ONCE = <NUM_LIT:1> ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingNoPresenceOf ( projectPath . append ( "<STR_LIT>" ) ) ; expectingNoPresenceOf ( projectPath . append ( "<STR_LIT>" ) ) ; expectingNoPresenceOf ( projectPath . append ( "<STR_LIT>" ) ) ; env . removeFolder ( projectPath . append ( "<STR_LIT>" ) ) ; env . addClass ( src , "<STR_LIT:x>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addFile ( src . append ( "<STR_LIT:bar>" ) , "<STR_LIT>" , "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; expectingNoPresenceOf ( projectPath . append ( "<STR_LIT>" ) ) ; expectingNoPresenceOf ( projectPath . append ( "<STR_LIT>" ) ) ; expectingNoPresenceOf ( projectPath . append ( "<STR_LIT>" ) ) ; } finally { org . eclipse . jdt . internal . core . builder . AbstractImageBuilder . MAX_AT_ONCE = max ; } } public void testSimpleProject ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; IPath src = env . getPackageFragmentRootPath ( projectPath , "<STR_LIT>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addFile ( src , "<STR_LIT>" , "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( projectPath . append ( "<STR_LIT>" ) ) ; env . removeFile ( src . append ( "<STR_LIT>" ) ) ; IPath p = env . addFolder ( src , "<STR_LIT:p>" ) ; env . addFile ( p , "<STR_LIT>" , "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; expectingNoPresenceOf ( projectPath . append ( "<STR_LIT>" ) ) ; expectingPresenceOf ( p . append ( "<STR_LIT>" ) ) ; } public void testProjectWithBin ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; IPath src = env . getPackageFragmentRootPath ( projectPath , "<STR_LIT>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addFile ( src , "<STR_LIT>" , "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( new IPath [ ] { projectPath . append ( "<STR_LIT>" ) , projectPath . append ( "<STR_LIT>" ) } ) ; env . removeFile ( src . append ( "<STR_LIT>" ) ) ; IPath p = env . addFolder ( src , "<STR_LIT:p>" ) ; env . addFile ( p , "<STR_LIT>" , "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; expectingNoPresenceOf ( new IPath [ ] { projectPath . append ( "<STR_LIT>" ) , projectPath . append ( "<STR_LIT>" ) } ) ; expectingPresenceOf ( new IPath [ ] { projectPath . append ( "<STR_LIT>" ) , projectPath . append ( "<STR_LIT>" ) } ) ; } public void testProjectWithSrcBin ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath src = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addFile ( src , "<STR_LIT>" , "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( new IPath [ ] { projectPath . append ( "<STR_LIT>" ) , projectPath . append ( "<STR_LIT>" ) } ) ; env . removeFile ( src . append ( "<STR_LIT>" ) ) ; env . addFile ( src , "<STR_LIT>" , "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; expectingNoPresenceOf ( new IPath [ ] { projectPath . append ( "<STR_LIT>" ) , projectPath . append ( "<STR_LIT>" ) } ) ; expectingPresenceOf ( new IPath [ ] { projectPath . append ( "<STR_LIT>" ) , projectPath . append ( "<STR_LIT>" ) } ) ; } public void testProjectWith2SrcBin ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath src1 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath src2 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addFile ( src1 , "<STR_LIT>" , "<STR_LIT>" ) ; env . addFile ( src2 , "<STR_LIT>" , "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( new IPath [ ] { projectPath . append ( "<STR_LIT>" ) , projectPath . append ( "<STR_LIT>" ) , projectPath . append ( "<STR_LIT>" ) , projectPath . append ( "<STR_LIT>" ) } ) ; env . removeFile ( src2 . append ( "<STR_LIT>" ) ) ; IPath p = env . addFolder ( src2 , "<STR_LIT:p>" ) ; env . addFile ( p , "<STR_LIT>" , "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; expectingNoPresenceOf ( new IPath [ ] { projectPath . append ( "<STR_LIT>" ) , projectPath . append ( "<STR_LIT>" ) } ) ; expectingPresenceOf ( new IPath [ ] { projectPath . append ( "<STR_LIT>" ) , projectPath . append ( "<STR_LIT>" ) } ) ; } public void testProjectWith2SrcAsBin ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath src1 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , null , "<STR_LIT>" ) ; IPath src2 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , null , "<STR_LIT>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addFile ( src1 , "<STR_LIT>" , "<STR_LIT>" ) ; env . addFile ( src2 , "<STR_LIT>" , "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( new IPath [ ] { projectPath . append ( "<STR_LIT>" ) , projectPath . append ( "<STR_LIT>" ) , } ) ; expectingNoPresenceOf ( new IPath [ ] { projectPath . append ( "<STR_LIT>" ) , projectPath . append ( "<STR_LIT>" ) } ) ; } public void testProjectWith2Src2Bin ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath src1 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , null , "<STR_LIT>" ) ; IPath src2 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , null , "<STR_LIT>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addFile ( src1 , "<STR_LIT>" , "<STR_LIT>" ) ; env . addFile ( src2 , "<STR_LIT>" , "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( new IPath [ ] { projectPath . append ( "<STR_LIT>" ) , projectPath . append ( "<STR_LIT>" ) , } ) ; expectingNoPresenceOf ( new IPath [ ] { projectPath . append ( "<STR_LIT>" ) , projectPath . append ( "<STR_LIT>" ) , } ) ; } public void test2ProjectWith1Bin ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; IPath bin = env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; IPath projectPath2 = env . addProject ( "<STR_LIT>" ) ; IPath binLocation = env . getProject ( projectPath ) . getFolder ( "<STR_LIT>" ) . getLocation ( ) ; env . setExternalOutputFolder ( projectPath2 , "<STR_LIT>" , binLocation ) ; env . addExternalJars ( projectPath2 , Util . getJavaClassLibs ( ) ) ; env . addFile ( projectPath2 , "<STR_LIT>" , "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( bin . append ( "<STR_LIT>" ) ) ; } public void testBug154693 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath src = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; org . eclipse . jdt . core . IJavaProject p = env . getJavaProject ( "<STR_LIT>" ) ; java . util . Map options = p . getOptions ( true ) ; options . put ( org . eclipse . jdt . core . JavaCore . CORE_JAVA_BUILD_RESOURCE_COPY_FILTER , "<STR_LIT>" ) ; p . setOptions ( options ) ; IPath folder = env . addFolder ( src , "<STR_LIT:p>" ) ; env . addFolder ( folder , "<STR_LIT>" ) ; env . addFile ( folder , "<STR_LIT>" , "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingNoPresenceOf ( new IPath [ ] { projectPath . append ( "<STR_LIT>" ) } ) ; } public void testBug194420 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath src = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; IPath bin = env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; IPath folder = env . addFolder ( src , "<STR_LIT:p>" ) ; String testContents = "<STR_LIT>" ; IPath zPath = env . addFile ( folder , "<STR_LIT>" , testContents ) ; IPath zBinPath = bin . append ( "<STR_LIT>" ) ; org . eclipse . core . resources . IFile zFile = env . getWorkspace ( ) . getRoot ( ) . getFile ( zPath ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( zBinPath ) ; try { byte [ ] contents = new byte [ testContents . length ( ) ] ; java . io . InputStream stream = zFile . getContents ( ) ; stream . read ( contents ) ; stream . close ( ) ; assumeEquals ( "<STR_LIT>" , testContents , new String ( contents ) ) ; } catch ( Exception e ) { fail ( "<STR_LIT>" ) ; } java . io . File file = new java . io . File ( zFile . getLocation ( ) . toOSString ( ) ) ; file . delete ( ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingNoPresenceOf ( zBinPath ) ; testContents = "<STR_LIT>" ; env . addFile ( folder , "<STR_LIT>" , testContents ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( zBinPath ) ; try { byte [ ] contents = new byte [ testContents . length ( ) ] ; java . io . InputStream stream = zFile . getContents ( ) ; stream . read ( contents ) ; stream . close ( ) ; assumeEquals ( "<STR_LIT>" , testContents , new String ( contents ) ) ; } catch ( Exception e ) { fail ( "<STR_LIT>" ) ; } env . addFile ( folder , "<STR_LIT>" , "<STR_LIT>" ) ; file . delete ( ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; expectingNoPresenceOf ( zBinPath ) ; } } </s>
<s> package org . eclipse . jdt . core . tests . builder ; import junit . framework . Test ; import org . eclipse . core . resources . IFolder ; import org . eclipse . core . resources . IMarker ; import org . eclipse . core . resources . IProject ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . Path ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . core . tests . util . Util ; public class IncrementalTests extends BuilderTests { public IncrementalTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( IncrementalTests . class ) ; } public void testAddDuplicateSecondaryType ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:C>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; IPath pathToD = env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:D>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingProblemsFor ( pathToD , "<STR_LIT>" ) ; expectingSpecificProblemsFor ( pathToD , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , pathToD , <NUM_LIT> , <NUM_LIT> , - <NUM_LIT:1> , IMarker . SEVERITY_ERROR ) } ) ; } public void testDefaultPackage ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( projectPath , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" ) ; env . addClass ( projectPath , "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT>" ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; env . addClass ( projectPath , "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; } public void testDefaultPackage2 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( projectPath , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" ) ; env . addClass ( projectPath , "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT>" ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; env . addClass ( projectPath , "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; } public void testNewJCL ( ) { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; IPath root = env . getPackageFragmentRootPath ( projectPath , "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; } public void testRenameMainType ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath pathToA = env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" ) ; IPath pathToB = env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" ) ; IPath pathToC = env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:C>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; pathToA = env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" ) ; pathToC = env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:C>" , "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingProblemsFor ( new IPath [ ] { pathToA , pathToB , pathToC } , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; expectingSpecificProblemFor ( pathToA , new Problem ( "<STR_LIT>" , "<STR_LIT>" , pathToA , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; expectingSpecificProblemFor ( pathToB , new Problem ( "<STR_LIT:B>" , "<STR_LIT>" , pathToB , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; expectingSpecificProblemFor ( pathToC , new Problem ( "<STR_LIT:C>" , "<STR_LIT>" , pathToC , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; pathToA = env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; } public void testRemoveSecondaryType ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath pathToAB = env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; incrementalBuild ( projectPath ) ; expectingProblemsFor ( pathToAB , "<STR_LIT>" ) ; expectingSpecificProblemFor ( pathToAB , new Problem ( "<STR_LIT>" , "<STR_LIT>" , pathToAB , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; } public void testRemoveSecondaryType2 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; IPath pathToBB = env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; pathToBB = env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; incrementalBuild ( projectPath ) ; expectingProblemsFor ( pathToBB , "<STR_LIT>" ) ; expectingSpecificProblemFor ( pathToBB , new Problem ( "<STR_LIT>" , "<STR_LIT>" , pathToBB , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; } public void testMoveSecondaryType ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; } public void testMoveMemberType ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( projectPath ) ; expectingOnlySpecificProblemsFor ( root , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , new Path ( "<STR_LIT>" ) , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_UNNECESSARY_CODE , IMarker . SEVERITY_WARNING ) , } ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingOnlySpecificProblemsFor ( root , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , new Path ( "<STR_LIT>" ) , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_UNNECESSARY_CODE , IMarker . SEVERITY_WARNING ) , } ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingOnlySpecificProblemsFor ( root , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , new Path ( "<STR_LIT>" ) , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_UNNECESSARY_CODE , IMarker . SEVERITY_WARNING ) , } ) ; } public void testMovePackage ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath [ ] exclusionPatterns = new Path [ ] { new Path ( "<STR_LIT>" ) } ; IPath src1 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , exclusionPatterns , null ) ; IPath src2 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( src1 , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; env . removePackage ( src1 , "<STR_LIT:p>" ) ; env . addClass ( src2 , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; } public void testMovePackage2 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath src = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; IPath other = env . addFolder ( projectPath , "<STR_LIT>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath classA = env . addClass ( src , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" ) ; IPath classB = env . addClass ( src , "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( projectPath ) ; expectingSpecificProblemFor ( classA , new Problem ( "<STR_LIT>" , "<STR_LIT>" , new Path ( "<STR_LIT>" ) , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; expectingSpecificProblemFor ( classB , new Problem ( "<STR_LIT>" , "<STR_LIT>" , new Path ( "<STR_LIT>" ) , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; try { IProject p = env . getProject ( projectPath ) ; IFolder pFolder = p . getWorkspace ( ) . getRoot ( ) . getFolder ( classA . removeLastSegments ( <NUM_LIT:1> ) ) ; pFolder . move ( other . append ( "<STR_LIT:p>" ) , true , false , null ) ; } catch ( CoreException e ) { env . handle ( e ) ; } incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; } public void testMemberTypeFromClassFile ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:E>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:Z>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:E>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:Z>" , "<STR_LIT>" + "<STR_LIT>" ) ; int previous = org . eclipse . jdt . internal . core . builder . AbstractImageBuilder . MAX_AT_ONCE ; org . eclipse . jdt . internal . core . builder . AbstractImageBuilder . MAX_AT_ONCE = <NUM_LIT:1> ; incrementalBuild ( projectPath ) ; org . eclipse . jdt . internal . core . builder . AbstractImageBuilder . MAX_AT_ONCE = previous ; expectingNoProblems ( ) ; } public void testObjectWithSuperInterfaces ( ) throws JavaModelException { try { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( projectPath ) ; expectingOnlySpecificProblemsFor ( root , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , new Path ( "<STR_LIT>" ) , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_INTERNAL , IMarker . SEVERITY_ERROR ) , } ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingOnlySpecificProblemsFor ( root , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , new Path ( "<STR_LIT>" ) , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_INTERNAL , IMarker . SEVERITY_ERROR ) , } ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingOnlySpecificProblemsFor ( root , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , new Path ( "<STR_LIT>" ) , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_INTERNAL , IMarker . SEVERITY_ERROR ) , } ) ; } catch ( StackOverflowError e ) { assertTrue ( "<STR_LIT>" , false ) ; e . printStackTrace ( ) ; } } public void _testWrongCompilationUnitLocation ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; IPath bin = env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath x = env . addClass ( root , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( bin . append ( "<STR_LIT>" ) ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingProblemsFor ( x , "<STR_LIT>" ) ; expectingNoPresenceOf ( bin . append ( "<STR_LIT>" ) ) ; } public void testMemberTypeCollisionWithBinary ( ) throws JavaModelException { int max = org . eclipse . jdt . internal . core . builder . AbstractImageBuilder . MAX_AT_ONCE ; try { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:I>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; org . eclipse . jdt . internal . core . builder . AbstractImageBuilder . MAX_AT_ONCE = <NUM_LIT:1> ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:I>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; } finally { org . eclipse . jdt . internal . core . builder . AbstractImageBuilder . MAX_AT_ONCE = max ; } } public void testMemberTypeCollisionWithBinary2 ( ) throws JavaModelException { int max = org . eclipse . jdt . internal . core . builder . AbstractImageBuilder . MAX_AT_ONCE ; try { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath src1 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath bin1 = env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( src1 , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; IPath src2 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , null , "<STR_LIT>" ) ; env . addClass ( src2 , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; env . addClass ( src2 , "<STR_LIT>" , "<STR_LIT:Test>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; env . addClassFolder ( projectPath , bin1 , false ) ; org . eclipse . jdt . internal . core . builder . AbstractImageBuilder . MAX_AT_ONCE = <NUM_LIT:1> ; env . addClass ( src2 , "<STR_LIT>" , "<STR_LIT:Test>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; } finally { org . eclipse . jdt . internal . core . builder . AbstractImageBuilder . MAX_AT_ONCE = max ; } } public void test129316 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath yPath = env . addClass ( projectPath , "<STR_LIT:p>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( projectPath , "<STR_LIT:p>" , "<STR_LIT:Z>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( projectPath , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; env . addClass ( projectPath , "<STR_LIT:p>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingSpecificProblemFor ( yPath , new Problem ( "<STR_LIT:Y>" , "<STR_LIT>" , yPath , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; IPath xPath = env . addClass ( projectPath , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; incrementalBuild ( projectPath ) ; expectingSpecificProblemFor ( yPath , new Problem ( "<STR_LIT:Y>" , "<STR_LIT>" , yPath , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; expectingNoProblemsFor ( xPath ) ; } public void testSecondaryType ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; int max = org . eclipse . jdt . internal . core . builder . AbstractImageBuilder . MAX_AT_ONCE ; try { org . eclipse . jdt . internal . core . builder . AbstractImageBuilder . MAX_AT_ONCE = <NUM_LIT:1> ; fullBuild ( projectPath ) ; } finally { org . eclipse . jdt . internal . core . builder . AbstractImageBuilder . MAX_AT_ONCE = max ; } expectingNoProblems ( ) ; } public void testMissingType001 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath xPath = env . addClass ( root , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath yPath = env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( projectPath ) ; expectingSpecificProblemFor ( xPath , new Problem ( "<STR_LIT:X>" , "<STR_LIT>" , xPath , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_CODE_STYLE , IMarker . SEVERITY_WARNING ) ) ; expectingSpecificProblemFor ( yPath , new Problem ( "<STR_LIT:Y>" , "<STR_LIT>" , yPath , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Z>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingSpecificProblemFor ( xPath , new Problem ( "<STR_LIT:X>" , "<STR_LIT>" , xPath , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_CODE_STYLE , IMarker . SEVERITY_WARNING ) ) ; } public void testMissingType002 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath yPath = env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( projectPath ) ; expectingSpecificProblemFor ( yPath , new Problem ( "<STR_LIT:Y>" , "<STR_LIT>" , yPath , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; IPath xPath = env . addClass ( root , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingSpecificProblemFor ( xPath , new Problem ( "<STR_LIT:X>" , "<STR_LIT>" , xPath , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_CODE_STYLE , IMarker . SEVERITY_WARNING ) ) ; expectingSpecificProblemFor ( yPath , new Problem ( "<STR_LIT:Y>" , "<STR_LIT>" , yPath , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Z>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingSpecificProblemFor ( xPath , new Problem ( "<STR_LIT:X>" , "<STR_LIT>" , xPath , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_CODE_STYLE , IMarker . SEVERITY_WARNING ) ) ; } public void testMissingType003 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath yPath = env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( projectPath ) ; expectingSpecificProblemFor ( yPath , new Problem ( "<STR_LIT:Y>" , "<STR_LIT>" , yPath , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; IPath xPath = env . addClass ( root , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingSpecificProblemFor ( xPath , new Problem ( "<STR_LIT:X>" , "<STR_LIT>" , xPath , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_CODE_STYLE , IMarker . SEVERITY_WARNING ) ) ; expectingSpecificProblemFor ( yPath , new Problem ( "<STR_LIT:Y>" , "<STR_LIT>" , yPath , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Z>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingSpecificProblemFor ( xPath , new Problem ( "<STR_LIT:X>" , "<STR_LIT>" , xPath , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_CODE_STYLE , IMarker . SEVERITY_WARNING ) ) ; } } </s>
<s> package org . eclipse . jdt . core . tests . builder ; import java . io . PrintWriter ; import java . io . StringWriter ; import java . util . Arrays ; import java . util . Comparator ; import junit . framework . Test ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . Path ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . IPackageFragment ; import org . eclipse . jdt . core . IPackageFragmentRoot ; import org . eclipse . jdt . core . IRegion ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . tests . util . Util ; public class GetResourcesTests extends BuilderTests { private static final Comparator COMPARATOR = new Comparator ( ) { public int compare ( Object o1 , Object o2 ) { IResource resource1 = ( IResource ) o1 ; IResource resource2 = ( IResource ) o2 ; String path1 = resource1 . getFullPath ( ) . toString ( ) ; String path2 = resource2 . getFullPath ( ) . toString ( ) ; int length1 = path1 . length ( ) ; int length2 = path2 . length ( ) ; if ( length1 != length2 ) { return length1 - length2 ; } return path1 . toString ( ) . compareTo ( path2 . toString ( ) ) ; } } ; public GetResourcesTests ( String name ) { super ( name ) ; } static { } public static Test suite ( ) { return buildTestSuite ( GetResourcesTests . class ) ; } public void test001 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; IJavaProject project = env . getJavaProject ( projectPath ) ; IPackageFragmentRoot root2 = project . getPackageFragmentRoot ( project . getProject ( ) . getWorkspace ( ) . getRoot ( ) . findMember ( root . makeAbsolute ( ) ) ) ; IPackageFragment packageFragment = root2 . getPackageFragment ( "<STR_LIT>" ) ; ICompilationUnit compilationUnit = packageFragment . getCompilationUnit ( "<STR_LIT>" ) ; IRegion region = JavaCore . newRegion ( ) ; region . add ( compilationUnit ) ; IResource [ ] resources = JavaCore . getGeneratedResources ( region , false ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:1> , resources . length ) ; String actualOutput = getResourceOuput ( resources ) ; String expectedOutput = "<STR_LIT>" ; assertEquals ( "<STR_LIT>" , Util . convertToIndependantLineDelimiter ( expectedOutput ) , actualOutput ) ; env . removeProject ( projectPath ) ; } public void test002 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; IJavaProject project = env . getJavaProject ( projectPath ) ; IPackageFragmentRoot root2 = project . getPackageFragmentRoot ( project . getProject ( ) . getWorkspace ( ) . getRoot ( ) . findMember ( root . makeAbsolute ( ) ) ) ; IPackageFragment packageFragment = root2 . getPackageFragment ( "<STR_LIT>" ) ; ICompilationUnit compilationUnit = packageFragment . getCompilationUnit ( "<STR_LIT>" ) ; IRegion region = JavaCore . newRegion ( ) ; region . add ( compilationUnit ) ; IResource [ ] resources = JavaCore . getGeneratedResources ( region , false ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:2> , resources . length ) ; Arrays . sort ( resources , COMPARATOR ) ; String actualOutput = getResourceOuput ( resources ) ; String expectedOutput = "<STR_LIT>" + "<STR_LIT>" ; assertEquals ( "<STR_LIT>" , Util . convertToIndependantLineDelimiter ( expectedOutput ) , actualOutput ) ; env . removeProject ( projectPath ) ; } public void test003 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; IJavaProject project = env . getJavaProject ( projectPath ) ; IPackageFragmentRoot root2 = project . getPackageFragmentRoot ( project . getProject ( ) . getWorkspace ( ) . getRoot ( ) . findMember ( root . makeAbsolute ( ) ) ) ; IPackageFragment packageFragment = root2 . getPackageFragment ( "<STR_LIT>" ) ; ICompilationUnit compilationUnit = packageFragment . getCompilationUnit ( "<STR_LIT>" ) ; IRegion region = JavaCore . newRegion ( ) ; region . add ( compilationUnit ) ; IResource [ ] resources = JavaCore . getGeneratedResources ( region , false ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:1> , resources . length ) ; String actualOutput = getResourceOuput ( resources ) ; String expectedOutput = "<STR_LIT>" ; assertEquals ( "<STR_LIT>" , Util . convertToIndependantLineDelimiter ( expectedOutput ) , actualOutput ) ; env . removeProject ( projectPath ) ; } public void test004 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; IJavaProject project = env . getJavaProject ( projectPath ) ; IPackageFragmentRoot root2 = project . getPackageFragmentRoot ( project . getProject ( ) . getWorkspace ( ) . getRoot ( ) . findMember ( root . makeAbsolute ( ) ) ) ; IPackageFragment packageFragment = root2 . getPackageFragment ( "<STR_LIT>" ) ; ICompilationUnit compilationUnit = packageFragment . getCompilationUnit ( "<STR_LIT>" ) ; IRegion region = JavaCore . newRegion ( ) ; region . add ( compilationUnit ) ; IResource [ ] resources = JavaCore . getGeneratedResources ( region , false ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:3> , resources . length ) ; Arrays . sort ( resources , COMPARATOR ) ; String actualOutput = getResourceOuput ( resources ) ; String expectedOutput = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; assertEquals ( "<STR_LIT>" , Util . convertToIndependantLineDelimiter ( expectedOutput ) , actualOutput ) ; env . removeProject ( projectPath ) ; } public void test005 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:a>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; incrementalBuild ( projectPath ) ; IJavaProject project = env . getJavaProject ( projectPath ) ; IPackageFragmentRoot root2 = project . getPackageFragmentRoot ( project . getProject ( ) . getWorkspace ( ) . getRoot ( ) . findMember ( root . makeAbsolute ( ) ) ) ; IPackageFragment packageFragment = root2 . getPackageFragment ( "<STR_LIT:a>" ) ; ICompilationUnit compilationUnit = packageFragment . getCompilationUnit ( "<STR_LIT>" ) ; IRegion region = JavaCore . newRegion ( ) ; region . add ( compilationUnit ) ; IResource [ ] resources = JavaCore . getGeneratedResources ( region , false ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT> , resources . length ) ; Arrays . sort ( resources , COMPARATOR ) ; String actualOutput = getResourceOuput ( resources ) ; String expectedOutput = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; assertEquals ( "<STR_LIT>" , Util . convertToIndependantLineDelimiter ( expectedOutput ) , actualOutput ) ; env . removeProject ( projectPath ) ; } public void test006 ( ) throws JavaModelException { IPath projectPath = null ; try { projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; } catch ( RuntimeException e ) { return ; } env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:a>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; incrementalBuild ( projectPath ) ; IJavaProject project = env . getJavaProject ( projectPath ) ; IPackageFragmentRoot root2 = project . getPackageFragmentRoot ( project . getProject ( ) . getWorkspace ( ) . getRoot ( ) . findMember ( root . makeAbsolute ( ) ) ) ; IPackageFragment packageFragment = root2 . getPackageFragment ( "<STR_LIT:a>" ) ; ICompilationUnit compilationUnit = packageFragment . getCompilationUnit ( "<STR_LIT>" ) ; IRegion region = JavaCore . newRegion ( ) ; region . add ( compilationUnit ) ; IResource [ ] resources = JavaCore . getGeneratedResources ( region , false ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT> , resources . length ) ; Arrays . sort ( resources , COMPARATOR ) ; String actualOutput = getResourceOuput ( resources ) ; String expectedOutput = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; assertEquals ( "<STR_LIT>" , Util . convertToIndependantLineDelimiter ( expectedOutput ) , actualOutput ) ; env . removeProject ( projectPath ) ; } private String getResourceOuput ( IResource [ ] resources ) { StringWriter stringWriter = new StringWriter ( ) ; PrintWriter writer = new PrintWriter ( stringWriter ) ; for ( int i = <NUM_LIT:0> , max = resources . length ; i < max ; i ++ ) { writer . println ( resources [ i ] . getFullPath ( ) . toString ( ) ) ; } writer . flush ( ) ; writer . close ( ) ; return Util . convertToIndependantLineDelimiter ( String . valueOf ( stringWriter ) ) ; } public void test007 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; IJavaProject project = env . getJavaProject ( projectPath ) ; IPackageFragmentRoot root2 = project . getPackageFragmentRoot ( project . getProject ( ) . getWorkspace ( ) . getRoot ( ) . findMember ( root . makeAbsolute ( ) ) ) ; IPackageFragment packageFragment = root2 . getPackageFragment ( "<STR_LIT>" ) ; ICompilationUnit compilationUnit = packageFragment . getCompilationUnit ( "<STR_LIT>" ) ; IRegion region = JavaCore . newRegion ( ) ; region . add ( compilationUnit ) ; IResource [ ] resources = JavaCore . getGeneratedResources ( region , false ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:2> , resources . length ) ; env . removeProject ( projectPath ) ; } public void test008 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; IJavaProject project = env . getJavaProject ( projectPath ) ; IPackageFragmentRoot root2 = project . getPackageFragmentRoot ( project . getProject ( ) . getWorkspace ( ) . getRoot ( ) . findMember ( root . makeAbsolute ( ) ) ) ; IPackageFragment packageFragment = root2 . getPackageFragment ( "<STR_LIT>" ) ; IRegion region = JavaCore . newRegion ( ) ; region . add ( packageFragment ) ; IResource [ ] resources = JavaCore . getGeneratedResources ( region , false ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:2> , resources . length ) ; Arrays . sort ( resources , COMPARATOR ) ; String actualOutput = getResourceOuput ( resources ) ; String expectedOutput = "<STR_LIT>" + "<STR_LIT>" ; assertEquals ( "<STR_LIT>" , Util . convertToIndependantLineDelimiter ( expectedOutput ) , actualOutput ) ; env . removeProject ( projectPath ) ; } public void test009 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( projectPath , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; IJavaProject project = env . getJavaProject ( projectPath ) ; IPackageFragmentRoot root2 = project . getPackageFragmentRoot ( project . getUnderlyingResource ( ) ) ; IPackageFragment packageFragment = root2 . getPackageFragment ( "<STR_LIT>" ) ; ICompilationUnit compilationUnit = packageFragment . getCompilationUnit ( "<STR_LIT>" ) ; IRegion region = JavaCore . newRegion ( ) ; region . add ( compilationUnit ) ; IResource [ ] resources = JavaCore . getGeneratedResources ( region , false ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:1> , resources . length ) ; String actualOutput = getResourceOuput ( resources ) ; String expectedOutput = "<STR_LIT>" ; assertEquals ( "<STR_LIT>" , Util . convertToIndependantLineDelimiter ( expectedOutput ) , actualOutput ) ; env . removeProject ( projectPath ) ; } public void test010 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addFile ( root , "<STR_LIT>" , "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; IJavaProject project = env . getJavaProject ( projectPath ) ; IPackageFragmentRoot root2 = project . getPackageFragmentRoot ( project . getProject ( ) . getWorkspace ( ) . getRoot ( ) . findMember ( root . makeAbsolute ( ) ) ) ; IPackageFragment packageFragment = root2 . getPackageFragment ( "<STR_LIT>" ) ; IRegion region = JavaCore . newRegion ( ) ; region . add ( packageFragment ) ; IResource [ ] resources = JavaCore . getGeneratedResources ( region , false ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:2> , resources . length ) ; Arrays . sort ( resources , COMPARATOR ) ; String actualOutput = getResourceOuput ( resources ) ; String expectedOutput = "<STR_LIT>" + "<STR_LIT>" ; assertEquals ( "<STR_LIT>" , Util . convertToIndependantLineDelimiter ( expectedOutput ) , actualOutput ) ; resources = JavaCore . getGeneratedResources ( region , true ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:3> , resources . length ) ; Arrays . sort ( resources , COMPARATOR ) ; actualOutput = getResourceOuput ( resources ) ; expectedOutput = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; assertEquals ( "<STR_LIT>" , Util . convertToIndependantLineDelimiter ( expectedOutput ) , actualOutput ) ; env . removeProject ( projectPath ) ; } public void test011 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; IJavaProject project = env . getJavaProject ( projectPath ) ; IPackageFragmentRoot root2 = project . getPackageFragmentRoot ( project . getProject ( ) . getWorkspace ( ) . getRoot ( ) . findMember ( root . makeAbsolute ( ) ) ) ; IPackageFragment packageFragment = root2 . getPackageFragment ( "<STR_LIT>" ) ; IRegion region = JavaCore . newRegion ( ) ; region . add ( packageFragment ) ; IResource [ ] resources = JavaCore . getGeneratedResources ( region , true ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:2> , resources . length ) ; Arrays . sort ( resources , COMPARATOR ) ; String actualOutput = getResourceOuput ( resources ) ; String expectedOutput = "<STR_LIT>" + "<STR_LIT>" ; assertEquals ( "<STR_LIT>" , Util . convertToIndependantLineDelimiter ( expectedOutput ) , actualOutput ) ; env . addFile ( root , "<STR_LIT>" , "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; resources = JavaCore . getGeneratedResources ( region , true ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:3> , resources . length ) ; Arrays . sort ( resources , COMPARATOR ) ; actualOutput = getResourceOuput ( resources ) ; expectedOutput = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; assertEquals ( "<STR_LIT>" , Util . convertToIndependantLineDelimiter ( expectedOutput ) , actualOutput ) ; env . removeProject ( projectPath ) ; } public void test012 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; IJavaProject project = env . getJavaProject ( projectPath ) ; IPackageFragmentRoot root2 = project . getPackageFragmentRoot ( project . getProject ( ) . getWorkspace ( ) . getRoot ( ) . findMember ( root . makeAbsolute ( ) ) ) ; IPackageFragment packageFragment = root2 . getPackageFragment ( "<STR_LIT>" ) ; IRegion region = JavaCore . newRegion ( ) ; region . add ( packageFragment ) ; IResource [ ] resources = JavaCore . getGeneratedResources ( region , true ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:2> , resources . length ) ; Arrays . sort ( resources , COMPARATOR ) ; String actualOutput = getResourceOuput ( resources ) ; String expectedOutput = "<STR_LIT>" + "<STR_LIT>" ; assertEquals ( "<STR_LIT>" , Util . convertToIndependantLineDelimiter ( expectedOutput ) , actualOutput ) ; env . addFile ( root , "<STR_LIT>" , "<STR_LIT>" ) ; resources = JavaCore . getGeneratedResources ( region , true ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:2> , resources . length ) ; Arrays . sort ( resources , COMPARATOR ) ; actualOutput = getResourceOuput ( resources ) ; expectedOutput = "<STR_LIT>" + "<STR_LIT>" ; assertEquals ( "<STR_LIT>" , Util . convertToIndependantLineDelimiter ( expectedOutput ) , actualOutput ) ; env . removeProject ( projectPath ) ; } public void test013 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" , new Path [ ] { new Path ( "<STR_LIT>" ) } , null ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; IJavaProject project = env . getJavaProject ( projectPath ) ; IPackageFragmentRoot root2 = project . getPackageFragmentRoot ( project . getProject ( ) . getWorkspace ( ) . getRoot ( ) . findMember ( root . makeAbsolute ( ) ) ) ; IPackageFragment packageFragment = root2 . getPackageFragment ( "<STR_LIT>" ) ; IRegion region = JavaCore . newRegion ( ) ; region . add ( packageFragment ) ; IResource [ ] resources = JavaCore . getGeneratedResources ( region , true ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:2> , resources . length ) ; Arrays . sort ( resources , COMPARATOR ) ; String actualOutput = getResourceOuput ( resources ) ; String expectedOutput = "<STR_LIT>" + "<STR_LIT>" ; assertEquals ( "<STR_LIT>" , Util . convertToIndependantLineDelimiter ( expectedOutput ) , actualOutput ) ; env . addFile ( root , "<STR_LIT>" , "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; resources = JavaCore . getGeneratedResources ( region , true ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:2> , resources . length ) ; Arrays . sort ( resources , COMPARATOR ) ; actualOutput = getResourceOuput ( resources ) ; expectedOutput = "<STR_LIT>" + "<STR_LIT>" ; assertEquals ( "<STR_LIT>" , Util . convertToIndependantLineDelimiter ( expectedOutput ) , actualOutput ) ; env . removeProject ( projectPath ) ; } public void test014 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" , new Path [ ] { new Path ( "<STR_LIT>" ) } , null ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; IJavaProject project = env . getJavaProject ( projectPath ) ; IPackageFragmentRoot root2 = project . getPackageFragmentRoot ( project . getProject ( ) . getWorkspace ( ) . getRoot ( ) . findMember ( root . makeAbsolute ( ) ) ) ; IPackageFragment packageFragment = root2 . getPackageFragment ( "<STR_LIT>" ) ; IRegion region = JavaCore . newRegion ( ) ; region . add ( packageFragment ) ; IResource [ ] resources = JavaCore . getGeneratedResources ( region , true ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:2> , resources . length ) ; Arrays . sort ( resources , COMPARATOR ) ; String actualOutput = getResourceOuput ( resources ) ; String expectedOutput = "<STR_LIT>" + "<STR_LIT>" ; assertEquals ( "<STR_LIT>" , Util . convertToIndependantLineDelimiter ( expectedOutput ) , actualOutput ) ; env . addFile ( root , "<STR_LIT>" , "<STR_LIT>" ) ; env . addFile ( root , "<STR_LIT>" , "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; resources = JavaCore . getGeneratedResources ( region , true ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:3> , resources . length ) ; Arrays . sort ( resources , COMPARATOR ) ; actualOutput = getResourceOuput ( resources ) ; expectedOutput = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; assertEquals ( "<STR_LIT>" , Util . convertToIndependantLineDelimiter ( expectedOutput ) , actualOutput ) ; env . removeProject ( projectPath ) ; } public void test015 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" , new Path [ ] { new Path ( "<STR_LIT>" ) } , null ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; IJavaProject project = env . getJavaProject ( projectPath ) ; IRegion region = JavaCore . newRegion ( ) ; region . add ( project ) ; IResource [ ] resources = JavaCore . getGeneratedResources ( region , true ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:2> , resources . length ) ; Arrays . sort ( resources , COMPARATOR ) ; String actualOutput = getResourceOuput ( resources ) ; String expectedOutput = "<STR_LIT>" + "<STR_LIT>" ; assertEquals ( "<STR_LIT>" , Util . convertToIndependantLineDelimiter ( expectedOutput ) , actualOutput ) ; env . addFile ( root , "<STR_LIT>" , "<STR_LIT>" ) ; env . addFile ( root , "<STR_LIT>" , "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; resources = JavaCore . getGeneratedResources ( region , true ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:3> , resources . length ) ; Arrays . sort ( resources , COMPARATOR ) ; actualOutput = getResourceOuput ( resources ) ; expectedOutput = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; assertEquals ( "<STR_LIT>" , Util . convertToIndependantLineDelimiter ( expectedOutput ) , actualOutput ) ; env . removeProject ( projectPath ) ; } public void test016 ( ) throws JavaModelException { try { JavaCore . getGeneratedResources ( null , true ) ; assertTrue ( "<STR_LIT>" , false ) ; } catch ( IllegalArgumentException e ) { } } } </s>
<s> package org . eclipse . jdt . core . tests . builder ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . StringWriter ; import java . util . Arrays ; import java . util . Comparator ; import junit . framework . * ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . IMarker ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . IRegion ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . ToolFactory ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . tests . util . Util ; import org . eclipse . jdt . core . util . IClassFileReader ; import org . eclipse . jdt . core . util . IMethodInfo ; public class AbstractMethodTests extends BuilderTests { private static final Comparator COMPARATOR = new Comparator ( ) { public int compare ( Object o1 , Object o2 ) { IResource resource1 = ( IResource ) o1 ; IResource resource2 = ( IResource ) o2 ; String path1 = resource1 . getFullPath ( ) . toString ( ) ; String path2 = resource2 . getFullPath ( ) . toString ( ) ; int length1 = path1 . length ( ) ; int length2 = path2 . length ( ) ; if ( length1 != length2 ) { return length1 - length2 ; } return path1 . toString ( ) . compareTo ( path2 . toString ( ) ) ; } } ; public AbstractMethodTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( AbstractMethodTests . class ) ; } public void test001 ( ) throws JavaModelException { IPath project1Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project1Path , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( project1Path , "<STR_LIT>" ) ; env . setOutputFolder ( project1Path , "<STR_LIT>" ) ; IPath root1 = env . addPackageFragmentRoot ( project1Path , "<STR_LIT:src>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath classX = env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath project2Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project2Path , Util . getJavaClassLibs ( ) ) ; env . addRequiredProject ( project2Path , project1Path ) ; env . removePackageFragmentRoot ( project2Path , "<STR_LIT>" ) ; IPath root2 = env . addPackageFragmentRoot ( project2Path , "<STR_LIT:src>" ) ; env . setOutputFolder ( project2Path , "<STR_LIT>" ) ; IPath classY = env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingOnlySpecificProblemFor ( classX , new Problem ( "<STR_LIT>" , "<STR_LIT>" , classX , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; expectingOnlySpecificProblemFor ( classY , new Problem ( "<STR_LIT:Y>" , "<STR_LIT>" , classY , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_MEMBER , IMarker . SEVERITY_ERROR ) ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; } public void test002 ( ) throws JavaModelException { IPath project1Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project1Path , Util . getJavaClassLibs ( ) ) ; env . getJavaProject ( project1Path ) . setOption ( JavaCore . COMPILER_CODEGEN_TARGET_PLATFORM , JavaCore . VERSION_1_1 ) ; env . removePackageFragmentRoot ( project1Path , "<STR_LIT>" ) ; env . setOutputFolder ( project1Path , "<STR_LIT>" ) ; IPath root1 = env . addPackageFragmentRoot ( project1Path , "<STR_LIT:src>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath classX = env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; IPath project2Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project2Path , Util . getJavaClassLibs ( ) ) ; env . addRequiredProject ( project2Path , project1Path ) ; env . removePackageFragmentRoot ( project2Path , "<STR_LIT>" ) ; IPath root2 = env . addPackageFragmentRoot ( project2Path , "<STR_LIT:src>" ) ; env . setOutputFolder ( project2Path , "<STR_LIT>" ) ; IPath classY = env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingOnlySpecificProblemFor ( classX , new Problem ( "<STR_LIT>" , "<STR_LIT>" , classX , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; expectingOnlySpecificProblemFor ( classY , new Problem ( "<STR_LIT:Y>" , "<STR_LIT>" , classY , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_MEMBER , IMarker . SEVERITY_ERROR ) ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; } public void test003 ( ) throws JavaModelException { IPath project1Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project1Path , Util . getJavaClassLibs ( ) ) ; env . getJavaProject ( project1Path ) . setOption ( JavaCore . COMPILER_CODEGEN_TARGET_PLATFORM , JavaCore . VERSION_1_1 ) ; env . removePackageFragmentRoot ( project1Path , "<STR_LIT>" ) ; env . setOutputFolder ( project1Path , "<STR_LIT>" ) ; IPath root1 = env . addPackageFragmentRoot ( project1Path , "<STR_LIT:src>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; IJavaProject project = env . getJavaProject ( project1Path ) ; IRegion region = JavaCore . newRegion ( ) ; region . add ( project ) ; IResource [ ] resources = JavaCore . getGeneratedResources ( region , false ) ; assertEquals ( "<STR_LIT>" , <NUM_LIT:2> , resources . length ) ; Arrays . sort ( resources , COMPARATOR ) ; String actualOutput = getResourceOuput ( resources ) ; String expectedOutput = "<STR_LIT>" + "<STR_LIT>" ; assertEquals ( "<STR_LIT>" , Util . convertToIndependantLineDelimiter ( expectedOutput ) , actualOutput ) ; assertEquals ( "<STR_LIT>" , IResource . FILE , resources [ <NUM_LIT:0> ] . getType ( ) ) ; IFile classFile = ( IFile ) resources [ <NUM_LIT:0> ] ; IClassFileReader classFileReader = null ; InputStream stream = null ; try { stream = classFile . getContents ( ) ; classFileReader = ToolFactory . createDefaultClassFileReader ( stream , IClassFileReader . ALL ) ; } catch ( CoreException e ) { e . printStackTrace ( ) ; } finally { if ( stream != null ) { try { stream . close ( ) ; } catch ( IOException e ) { } } } assertNotNull ( "<STR_LIT>" , classFileReader ) ; IMethodInfo [ ] methodInfos = classFileReader . getMethodInfos ( ) ; IMethodInfo found = null ; loop : for ( int i = <NUM_LIT:0> , max = methodInfos . length ; i < max ; i ++ ) { IMethodInfo methodInfo = methodInfos [ i ] ; if ( CharOperation . equals ( methodInfo . getName ( ) , "<STR_LIT:foo>" . toCharArray ( ) ) ) { found = methodInfo ; break loop ; } } assertNotNull ( "<STR_LIT>" , found ) ; assertTrue ( "<STR_LIT>" , found . isSynthetic ( ) ) ; } private String getResourceOuput ( IResource [ ] resources ) { StringWriter stringWriter = new StringWriter ( ) ; PrintWriter writer = new PrintWriter ( stringWriter ) ; for ( int i = <NUM_LIT:0> , max = resources . length ; i < max ; i ++ ) { writer . println ( resources [ i ] . getFullPath ( ) . toString ( ) ) ; } writer . flush ( ) ; writer . close ( ) ; return Util . convertToIndependantLineDelimiter ( String . valueOf ( stringWriter ) ) ; } } </s>
<s> package org . eclipse . jdt . core . tests . builder ; import java . io . ByteArrayInputStream ; import java . io . File ; import java . io . UnsupportedEncodingException ; import java . net . URL ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Comparator ; import java . util . Enumeration ; import java . util . HashMap ; import java . util . Hashtable ; import java . util . Map ; import org . codehaus . groovy . activator . GroovyActivator ; import org . codehaus . jdt . groovy . model . GroovyNature ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . IFolder ; import org . eclipse . core . resources . IMarker ; import org . eclipse . core . resources . IProject ; import org . eclipse . core . resources . IProjectDescription ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . resources . IWorkspace ; import org . eclipse . core . resources . IWorkspaceDescription ; import org . eclipse . core . resources . IWorkspaceRunnable ; import org . eclipse . core . resources . IncrementalProjectBuilder ; import org . eclipse . core . resources . ResourcesPlugin ; import org . eclipse . core . runtime . Assert ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . FileLocator ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . IStatus ; import org . eclipse . core . runtime . MultiStatus ; import org . eclipse . core . runtime . OperationCanceledException ; import org . eclipse . core . runtime . Path ; import org . eclipse . core . runtime . Platform ; import org . eclipse . core . runtime . jobs . Job ; import org . eclipse . jdt . core . IAccessRule ; import org . eclipse . jdt . core . IClasspathAttribute ; import org . eclipse . jdt . core . IClasspathEntry ; import org . eclipse . jdt . core . IJavaModelMarker ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . tests . util . AbstractCompilerTest ; import org . eclipse . jdt . core . tests . util . Util ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . core . ClasspathEntry ; import org . eclipse . jdt . internal . core . JavaProject ; public class TestingEnvironment { private boolean fIsOpen = false ; private IWorkspace fWorkspace = null ; private Hashtable fProjects = null ; private void addBuilderSpecs ( String projectName ) { try { IProject project = getProject ( projectName ) ; IProjectDescription description = project . getDescription ( ) ; description . setNatureIds ( new String [ ] { JavaCore . NATURE_ID , GroovyNature . GROOVY_NATURE } ) ; project . setDescription ( description , null ) ; } catch ( CoreException e ) { handleCoreException ( e ) ; } } public void removeGroovyNature ( String projectName ) { try { IProject project = getProject ( projectName ) ; IProjectDescription description = project . getDescription ( ) ; description . setNatureIds ( new String [ ] { JavaCore . NATURE_ID } ) ; project . setDescription ( description , null ) ; } catch ( CoreException e ) { handleCoreException ( e ) ; } } public void addGroovyNature ( String projectName ) { try { IProject project = getProject ( projectName ) ; IProjectDescription description = project . getDescription ( ) ; description . setNatureIds ( new String [ ] { JavaCore . NATURE_ID , GroovyNature . GROOVY_NATURE } ) ; project . setDescription ( description , null ) ; } catch ( CoreException e ) { handleCoreException ( e ) ; } } public void addNature ( String projectName , String natureId ) { try { IProject project = getProject ( projectName ) ; IProjectDescription description = project . getDescription ( ) ; String [ ] existingNatures = description . getNatureIds ( ) ; String [ ] newNatures = new String [ existingNatures . length + <NUM_LIT:1> ] ; System . arraycopy ( existingNatures , <NUM_LIT:0> , newNatures , <NUM_LIT:0> , existingNatures . length ) ; newNatures [ existingNatures . length ] = natureId ; description . setNatureIds ( newNatures ) ; project . setDescription ( description , null ) ; } catch ( CoreException e ) { handleCoreException ( e ) ; } } public IPath addBinaryClass ( IPath packagePath , String className , byte [ ] contents ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; IPath classPath = packagePath . append ( className + "<STR_LIT:.class>" ) ; createFile ( classPath , contents ) ; return classPath ; } public IPath addBinaryClass ( IPath packageFragmentRootPath , String packageName , String className , byte [ ] contents ) { if ( packageName != null && packageName . length ( ) > <NUM_LIT:0> ) { IPath packagePath = addPackage ( packageFragmentRootPath , packageName ) ; return addBinaryClass ( packagePath , className , contents ) ; } return addBinaryClass ( packageFragmentRootPath , className , contents ) ; } public IPath addClass ( IPath packagePath , String className , String contents ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; IPath classPath = packagePath . append ( className + "<STR_LIT>" ) ; try { createFile ( classPath , contents . getBytes ( "<STR_LIT>" ) ) ; } catch ( UnsupportedEncodingException e ) { e . printStackTrace ( ) ; checkAssertion ( "<STR_LIT>" , false ) ; } return classPath ; } public IPath addGroovyClass ( IPath packagePath , String className , String contents ) { return addGroovyClassExtension ( packagePath , className , contents , null ) ; } public IPath addGroovyClassWithSuffix ( IPath packagePath , String className , String suffix , String contents ) { return addGroovyClassExtension ( packagePath , className , suffix , contents , suffix ) ; } public IPath addGroovyClassExtension ( IPath packagePath , String className , String contents , String fileExtension ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; if ( fileExtension == null ) { fileExtension = "<STR_LIT>" ; } IPath classPath = packagePath . append ( className + "<STR_LIT:.>" + fileExtension ) ; try { createFile ( classPath , contents . getBytes ( "<STR_LIT>" ) ) ; } catch ( UnsupportedEncodingException e ) { e . printStackTrace ( ) ; checkAssertion ( "<STR_LIT>" , false ) ; } return classPath ; } public IPath addClass ( IPath packageFragmentRootPath , String packageName , String className , String contents ) { if ( packageName != null && packageName . length ( ) > <NUM_LIT:0> ) { IPath packagePath = addPackage ( packageFragmentRootPath , packageName ) ; return addClass ( packagePath , className , contents ) ; } return addClass ( packageFragmentRootPath , className , contents ) ; } public IPath addGroovyClass ( IPath packageFragmentRootPath , String packageName , String className , String contents ) { return addGroovyClassExtension ( packageFragmentRootPath , packageName , className , contents , null ) ; } public IPath addGroovyClassWithSuffix ( IPath packageFragmentRootPath , String packageName , String className , String suffix , String contents ) { return addGroovyClassExtension ( packageFragmentRootPath , packageName , className , contents , suffix ) ; } public IPath addGroovyClassExtension ( IPath packageFragmentRootPath , String packageName , String className , String contents , String fileExtension ) { if ( packageName != null && packageName . length ( ) > <NUM_LIT:0> ) { IPath packagePath = addPackage ( packageFragmentRootPath , packageName ) ; return addGroovyClassExtension ( packagePath , className , contents , fileExtension ) ; } return addGroovyClassExtension ( packageFragmentRootPath , className , contents , fileExtension ) ; } public void addClassFolder ( IPath projectPath , IPath classFolderPath , boolean isExported ) throws JavaModelException { addEntry ( projectPath , JavaCore . newLibraryEntry ( classFolderPath , null , null , isExported ) ) ; } public IPath addPackage ( IPath packageFragmentRootPath , String packageName ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; IPath path = packageFragmentRootPath . append ( packageName . replace ( '<CHAR_LIT:.>' , IPath . SEPARATOR ) ) ; createFolder ( path ) ; return path ; } public IPath addPackageFragmentRoot ( IPath projectPath , String sourceFolderName ) throws JavaModelException { return addPackageFragmentRoot ( projectPath , sourceFolderName , null , null ) ; } public IPath addPackageFragmentRoot ( IPath projectPath , String sourceFolderName , IPath [ ] exclusionPatterns , String specificOutputLocation ) throws JavaModelException { return addPackageFragmentRoot ( projectPath , sourceFolderName , null , exclusionPatterns , specificOutputLocation ) ; } public IPath addPackageFragmentRoot ( IPath projectPath , String sourceFolderName , IPath [ ] inclusionPatterns , IPath [ ] exclusionPatterns , String specificOutputLocation ) throws JavaModelException { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; IPath path = getPackageFragmentRootPath ( projectPath , sourceFolderName ) ; createFolder ( path ) ; IPath outputPath = null ; if ( specificOutputLocation != null ) { outputPath = getPackageFragmentRootPath ( projectPath , specificOutputLocation ) ; createFolder ( outputPath ) ; } IClasspathEntry entry = JavaCore . newSourceEntry ( path , inclusionPatterns == null ? new Path [ <NUM_LIT:0> ] : inclusionPatterns , exclusionPatterns == null ? new Path [ <NUM_LIT:0> ] : exclusionPatterns , outputPath ) ; addEntry ( projectPath , entry ) ; return path ; } public void addProject ( IProject project ) { fProjects . put ( project . getName ( ) , project ) ; } public IPath addProject ( String projectName ) { return addProject ( projectName , "<STR_LIT>" ) ; } public IPath addProject ( String projectName , String compliance ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; IProject project = createProject ( projectName ) ; int requiredComplianceFlag = <NUM_LIT:0> ; String compilerVersion = null ; if ( "<STR_LIT>" . equals ( compliance ) ) { requiredComplianceFlag = AbstractCompilerTest . F_1_5 ; compilerVersion = CompilerOptions . VERSION_1_5 ; } else if ( "<STR_LIT>" . equals ( compliance ) ) { requiredComplianceFlag = AbstractCompilerTest . F_1_6 ; compilerVersion = CompilerOptions . VERSION_1_6 ; } else if ( "<STR_LIT>" . equals ( compliance ) ) { requiredComplianceFlag = AbstractCompilerTest . F_1_7 ; compilerVersion = CompilerOptions . VERSION_1_7 ; } else if ( ! "<STR_LIT>" . equals ( compliance ) && ! "<STR_LIT>" . equals ( compliance ) ) { throw new UnsupportedOperationException ( "<STR_LIT>" + compliance ) ; } if ( requiredComplianceFlag != <NUM_LIT:0> ) { if ( ( AbstractCompilerTest . getPossibleComplianceLevels ( ) & requiredComplianceFlag ) == <NUM_LIT:0> ) throw new RuntimeException ( "<STR_LIT>" + compliance + "<STR_LIT>" ) ; IJavaProject javaProject = JavaCore . create ( project ) ; Map options = new HashMap ( ) ; options . put ( CompilerOptions . OPTION_Compliance , compilerVersion ) ; options . put ( CompilerOptions . OPTION_Source , compilerVersion ) ; options . put ( CompilerOptions . OPTION_TargetPlatform , compilerVersion ) ; javaProject . setOptions ( options ) ; } return project . getFullPath ( ) ; } public void addRequiredProject ( IPath projectPath , IPath requiredProjectPath ) throws JavaModelException { addRequiredProject ( projectPath , requiredProjectPath , new IPath [ ] { } , new IPath [ ] { } , false ) ; } public void addRequiredProject ( IPath projectPath , IPath requiredProjectPath , IPath [ ] accessibleFiles , IPath [ ] nonAccessibleFiles , boolean isExported ) throws JavaModelException { checkAssertion ( "<STR_LIT>" , ! projectPath . isPrefixOf ( requiredProjectPath ) ) ; IAccessRule [ ] accessRules = ClasspathEntry . getAccessRules ( accessibleFiles , nonAccessibleFiles ) ; addEntry ( projectPath , JavaCore . newProjectEntry ( requiredProjectPath , accessRules , true , new IClasspathAttribute [ <NUM_LIT:0> ] , isExported ) ) ; } public void addRequiredProject ( IPath projectPath , IPath requiredProjectPath , IPath rule , int ruleKind ) throws JavaModelException { checkAssertion ( "<STR_LIT>" , ! projectPath . isPrefixOf ( requiredProjectPath ) ) ; IAccessRule accessRule = JavaCore . newAccessRule ( rule , ruleKind ) ; addEntry ( projectPath , JavaCore . newProjectEntry ( requiredProjectPath , new IAccessRule [ ] { accessRule } , true , new IClasspathAttribute [ <NUM_LIT:0> ] , false ) ) ; } public void addRequiredProject ( IPath projectPath , IPath requiredProjectPath , boolean isOptional ) throws JavaModelException { checkAssertion ( "<STR_LIT>" , ! projectPath . isPrefixOf ( requiredProjectPath ) ) ; IClasspathAttribute [ ] attributes = isOptional ? new IClasspathAttribute [ ] { JavaCore . newClasspathAttribute ( IClasspathAttribute . OPTIONAL , "<STR_LIT:true>" ) } : new IClasspathAttribute [ <NUM_LIT:0> ] ; addEntry ( projectPath , JavaCore . newProjectEntry ( requiredProjectPath , null , true , attributes , false ) ) ; } public void addExternalFolders ( IPath projectPath , String [ ] folders ) throws JavaModelException { addExternalFolders ( projectPath , folders , false ) ; } public void addExternalFolders ( IPath projectPath , String [ ] folders , boolean isExported ) throws JavaModelException { for ( int i = <NUM_LIT:0> , max = folders . length ; i < max ; i ++ ) { String folder = folders [ i ] ; checkAssertion ( "<STR_LIT>" , ! folder . endsWith ( "<STR_LIT>" ) && ! folder . endsWith ( "<STR_LIT>" ) ) ; addEntry ( projectPath , JavaCore . newLibraryEntry ( new Path ( folder ) , null , null , isExported ) ) ; } } public void addExternalJars ( IPath projectPath , String [ ] jars ) throws JavaModelException { addExternalJars ( projectPath , jars , false ) ; } public void addExternalJar ( IPath projectPath , String jar ) throws JavaModelException { addExternalJar ( projectPath , jar , false ) ; } public void addExternalJars ( IPath projectPath , String [ ] jars , boolean isExported ) throws JavaModelException { for ( int i = <NUM_LIT:0> , max = jars . length ; i < max ; i ++ ) { String jar = jars [ i ] ; addEntry ( projectPath , JavaCore . newLibraryEntry ( new Path ( jar ) , null , null , isExported ) ) ; } } public void addExternalJar ( IPath projectPath , String jar , boolean isExported ) throws JavaModelException { addEntry ( projectPath , JavaCore . newLibraryEntry ( new Path ( jar ) , null , null , isExported ) ) ; } public void addLibrary ( IPath projectPath , IPath libraryPath , IPath sourceAttachmentPath , IPath sourceAttachmentRootPath ) throws JavaModelException { addEntry ( projectPath , JavaCore . newLibraryEntry ( libraryPath , sourceAttachmentPath , sourceAttachmentRootPath ) ) ; } public void addEntry ( IPath projectPath , IClasspathEntry entryPath ) throws JavaModelException { IClasspathEntry [ ] classpath = getClasspath ( projectPath ) ; for ( IClasspathEntry entry : classpath ) { if ( entry . equals ( entryPath ) ) { return ; } } IClasspathEntry [ ] newClaspath = new IClasspathEntry [ classpath . length + <NUM_LIT:1> ] ; System . arraycopy ( classpath , <NUM_LIT:0> , newClaspath , <NUM_LIT:0> , classpath . length ) ; newClaspath [ classpath . length ] = entryPath ; setClasspath ( projectPath , newClaspath ) ; } public IPath addFile ( IPath root , String fileName , String contents ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; IPath filePath = root . append ( fileName ) ; try { createFile ( filePath , contents . getBytes ( "<STR_LIT>" ) ) ; } catch ( UnsupportedEncodingException e ) { e . printStackTrace ( ) ; checkAssertion ( "<STR_LIT>" , false ) ; } return filePath ; } public IPath addFolder ( IPath root , String folderName ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; IPath folderPath = root . append ( folderName ) ; createFolder ( folderPath ) ; return folderPath ; } public IPath addInternalJar ( IPath projectPath , String zipName , byte [ ] contents ) throws JavaModelException { return addInternalJar ( projectPath , zipName , contents , false ) ; } public IPath addInternalJar ( IPath projectPath , String zipName , byte [ ] contents , boolean isExported ) throws JavaModelException { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; IPath path = projectPath . append ( zipName ) ; removeInternalJar ( projectPath , zipName ) ; createFile ( path , contents ) ; addEntry ( projectPath , JavaCore . newLibraryEntry ( path , null , null , isExported ) ) ; return path ; } private void checkAssertion ( String message , boolean b ) { Assert . isTrue ( b , message ) ; } public void cleanBuild ( ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; try { getWorkspace ( ) . build ( IncrementalProjectBuilder . CLEAN_BUILD , null ) ; } catch ( CoreException e ) { handle ( e ) ; } } public void close ( ) { try { if ( fProjects != null ) { Enumeration projectNames = fProjects . keys ( ) ; while ( projectNames . hasMoreElements ( ) ) { String projectName = ( String ) projectNames . nextElement ( ) ; getJavaProject ( projectName ) . getJavaModel ( ) . close ( ) ; } } closeWorkspace ( ) ; } catch ( JavaModelException e ) { e . printStackTrace ( ) ; } catch ( RuntimeException e ) { e . printStackTrace ( ) ; } } public void closeProject ( IPath projectPath ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; try { getJavaProject ( projectPath ) . getProject ( ) . close ( null ) ; } catch ( CoreException e ) { e . printStackTrace ( ) ; } } private void closeWorkspace ( ) { fIsOpen = false ; } private IFile createFile ( IPath path , byte [ ] contents ) { try { IFile file = fWorkspace . getRoot ( ) . getFile ( path ) ; ByteArrayInputStream is = new ByteArrayInputStream ( contents ) ; if ( file . exists ( ) ) { file . setContents ( is , true , false , null ) ; } else { file . create ( is , true , null ) ; } return file ; } catch ( CoreException e ) { handle ( e ) ; } return null ; } private IFolder createFolder ( IPath path ) { checkAssertion ( "<STR_LIT:root>" , ! path . isRoot ( ) ) ; if ( path . segmentCount ( ) <= <NUM_LIT:1> ) { return null ; } IFolder folder = fWorkspace . getRoot ( ) . getFolder ( path ) ; if ( ! folder . exists ( ) ) { createFolder ( path . removeLastSegments ( <NUM_LIT:1> ) ) ; try { folder . create ( true , true , null ) ; } catch ( CoreException e ) { handle ( e ) ; } } return folder ; } private IProject createProject ( String projectName ) { final IProject project = fWorkspace . getRoot ( ) . getProject ( projectName ) ; try { IWorkspaceRunnable create = new IWorkspaceRunnable ( ) { public void run ( IProgressMonitor monitor ) throws CoreException { project . create ( null , null ) ; project . open ( null ) ; } } ; fWorkspace . run ( create , null ) ; fProjects . put ( projectName , project ) ; addBuilderSpecs ( projectName ) ; } catch ( CoreException e ) { handle ( e ) ; } return project ; } public void fullBuild ( ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; try { getWorkspace ( ) . build ( IncrementalProjectBuilder . FULL_BUILD , null ) ; } catch ( CoreException e ) { handle ( e ) ; } } public void fullBuild ( IPath projectPath ) { fullBuild ( projectPath . lastSegment ( ) ) ; } public void fullBuild ( String projectName ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; try { getProject ( projectName ) . build ( IncrementalProjectBuilder . FULL_BUILD , null ) ; } catch ( CoreException e ) { handle ( e ) ; } } public IClasspathEntry [ ] getClasspath ( IPath projectPath ) { try { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; JavaProject javaProject = ( JavaProject ) JavaCore . create ( getProject ( projectPath ) ) ; return javaProject . getExpandedClasspath ( ) ; } catch ( JavaModelException e ) { e . printStackTrace ( ) ; checkAssertion ( "<STR_LIT>" , false ) ; return null ; } } public IJavaProject getJavaProject ( IPath projectPath ) { IJavaProject javaProject = JavaCore . create ( getProject ( projectPath ) ) ; Assert . isNotNull ( javaProject ) ; return javaProject ; } public IJavaProject getJavaProject ( String projectName ) { IJavaProject javaProject = JavaCore . create ( getProject ( projectName ) ) ; Assert . isNotNull ( javaProject ) ; return javaProject ; } public IPath getOutputLocation ( IPath projectPath ) { try { IJavaProject javaProject = JavaCore . create ( getProject ( projectPath ) ) ; return javaProject . getOutputLocation ( ) ; } catch ( CoreException e ) { } return null ; } public Problem [ ] getProblems ( ) { return getProblemsFor ( getWorkspaceRootPath ( ) ) ; } public Problem [ ] getProblemsFor ( IPath path ) { return getProblemsFor ( path , null ) ; } public Problem [ ] getProblemsFor ( IPath path , String additionalMarkerType ) { IResource resource ; if ( path . equals ( getWorkspaceRootPath ( ) ) ) { resource = getWorkspace ( ) . getRoot ( ) ; } else { IProject p = getProject ( path ) ; if ( p != null && path . equals ( p . getFullPath ( ) ) ) { resource = getProject ( path . lastSegment ( ) ) ; } else if ( path . getFileExtension ( ) == null ) { resource = getWorkspace ( ) . getRoot ( ) . getFolder ( path ) ; } else { resource = getWorkspace ( ) . getRoot ( ) . getFile ( path ) ; } } try { ArrayList problems = new ArrayList ( ) ; IMarker [ ] markers = resource . findMarkers ( IJavaModelMarker . JAVA_MODEL_PROBLEM_MARKER , true , IResource . DEPTH_INFINITE ) ; for ( int i = <NUM_LIT:0> ; i < markers . length ; i ++ ) problems . add ( new Problem ( markers [ i ] ) ) ; markers = resource . findMarkers ( IJavaModelMarker . BUILDPATH_PROBLEM_MARKER , true , IResource . DEPTH_INFINITE ) ; for ( int i = <NUM_LIT:0> ; i < markers . length ; i ++ ) problems . add ( new Problem ( markers [ i ] ) ) ; markers = resource . findMarkers ( IJavaModelMarker . TASK_MARKER , true , IResource . DEPTH_INFINITE ) ; for ( int i = <NUM_LIT:0> ; i < markers . length ; i ++ ) problems . add ( new Problem ( markers [ i ] ) ) ; if ( additionalMarkerType != null ) { markers = resource . findMarkers ( additionalMarkerType , true , IResource . DEPTH_INFINITE ) ; for ( int i = <NUM_LIT:0> ; i < markers . length ; i ++ ) problems . add ( new Problem ( markers [ i ] ) ) ; } Problem [ ] result = new Problem [ problems . size ( ) ] ; problems . toArray ( result ) ; return result ; } catch ( CoreException e ) { } return new Problem [ <NUM_LIT:0> ] ; } public IMarker [ ] getTaskMarkersFor ( IPath path ) { IResource resource = null ; if ( path . equals ( getWorkspaceRootPath ( ) ) ) { resource = getWorkspace ( ) . getRoot ( ) ; } else { IProject p = getProject ( path ) ; if ( p != null && path . equals ( p . getFullPath ( ) ) ) { resource = getProject ( path . lastSegment ( ) ) ; } else if ( path . getFileExtension ( ) == null ) { resource = getWorkspace ( ) . getRoot ( ) . getFolder ( path ) ; } else { resource = getWorkspace ( ) . getRoot ( ) . getFile ( path ) ; } } try { if ( resource != null ) { final IMarker [ ] markers = resource . findMarkers ( IJavaModelMarker . TASK_MARKER , true , IResource . DEPTH_INFINITE ) ; if ( markers . length > <NUM_LIT:1> ) { Arrays . sort ( markers , new Comparator ( ) { public int compare ( Object o1 , Object o2 ) { IMarker marker1 = ( IMarker ) o1 ; IMarker marker2 = ( IMarker ) o2 ; try { final int start1 = ( ( Integer ) marker1 . getAttribute ( IMarker . CHAR_START ) ) . intValue ( ) ; final int start2 = ( ( Integer ) marker2 . getAttribute ( IMarker . CHAR_START ) ) . intValue ( ) ; return start1 - start2 ; } catch ( CoreException e ) { return <NUM_LIT:0> ; } } } ) ; } return markers ; } } catch ( CoreException e ) { } return new IMarker [ <NUM_LIT:0> ] ; } public IPath getPackagePath ( IPath root , String packageName ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; if ( packageName . length ( ) == <NUM_LIT:0> ) { return root ; } return root . append ( packageName . replace ( '<CHAR_LIT:.>' , IPath . SEPARATOR ) ) ; } public IPath getPackageFragmentRootPath ( IPath projectPath , String name ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; if ( name . length ( ) == <NUM_LIT:0> ) { return projectPath ; } return projectPath . append ( name ) ; } public IProject getProject ( String projectName ) { return ( IProject ) fProjects . get ( projectName ) ; } public IProject getProject ( IPath projectPath ) { return ( IProject ) fProjects . get ( projectPath . lastSegment ( ) ) ; } private File tmpDirectory ; File getTmpDirectory ( ) { if ( this . tmpDirectory == null ) { this . tmpDirectory = new File ( System . getProperty ( "<STR_LIT>" ) + File . separator + "<STR_LIT>" ) ; if ( this . tmpDirectory . exists ( ) && ! this . tmpDirectory . isDirectory ( ) ) { Util . delete ( this . tmpDirectory ) ; } this . tmpDirectory . mkdir ( ) ; } return this . tmpDirectory ; } void deleteTmpDirectory ( ) { if ( this . tmpDirectory != null ) { Util . delete ( this . tmpDirectory ) ; this . tmpDirectory = null ; } } public IWorkspace getWorkspace ( ) { return fWorkspace ; } public IPath getWorkspaceRootPath ( ) { return getWorkspace ( ) . getRoot ( ) . getLocation ( ) ; } private IPath getJarRootPath ( IPath projectPath ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; return getProject ( projectPath ) . getFullPath ( ) ; } void handle ( Exception e ) { if ( e instanceof CoreException ) { handleCoreException ( ( CoreException ) e ) ; } else { e . printStackTrace ( ) ; Assert . isTrue ( false ) ; } } private void handleCoreException ( CoreException e ) { e . printStackTrace ( ) ; IStatus status = e . getStatus ( ) ; String message = e . getMessage ( ) ; if ( status . isMultiStatus ( ) ) { MultiStatus multiStatus = ( MultiStatus ) status ; IStatus [ ] children = multiStatus . getChildren ( ) ; StringBuffer buffer = new StringBuffer ( ) ; for ( int i = <NUM_LIT:0> , max = children . length ; i < max ; i ++ ) { IStatus child = children [ i ] ; if ( child != null ) { buffer . append ( child . getMessage ( ) ) ; buffer . append ( System . getProperty ( "<STR_LIT>" ) ) ; Throwable childException = child . getException ( ) ; if ( childException != null ) { childException . printStackTrace ( ) ; } } } message = buffer . toString ( ) ; } Assert . isTrue ( false , "<STR_LIT>" + message ) ; } public void incrementalBuild ( ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; try { getWorkspace ( ) . build ( IncrementalProjectBuilder . INCREMENTAL_BUILD , null ) ; } catch ( CoreException e ) { handle ( e ) ; } } public void incrementalBuild ( IPath projectPath ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; try { getProject ( projectPath ) . build ( IncrementalProjectBuilder . INCREMENTAL_BUILD , null ) ; } catch ( CoreException e ) { handle ( e ) ; } catch ( Throwable e ) { e . printStackTrace ( ) ; } } public boolean isAutoBuilding ( ) { IWorkspace w = getWorkspace ( ) ; IWorkspaceDescription d = w . getDescription ( ) ; return d . isAutoBuilding ( ) ; } public void openEmptyWorkspace ( ) { close ( ) ; openWorkspace ( ) ; fProjects = new Hashtable ( <NUM_LIT:10> ) ; setup ( ) ; } public void openProject ( IPath projectPath ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; try { getJavaProject ( projectPath ) . getProject ( ) . open ( null ) ; } catch ( CoreException e ) { e . printStackTrace ( ) ; } } private void openWorkspace ( ) { try { closeWorkspace ( ) ; fWorkspace = ResourcesPlugin . getWorkspace ( ) ; IWorkspaceDescription description = fWorkspace . getDescription ( ) ; description . setAutoBuilding ( false ) ; fWorkspace . setDescription ( description ) ; } catch ( Exception e ) { handle ( e ) ; } } public void renameCU ( IPath packagePath , String cuName , String newName ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; IFolder packageFolder = fWorkspace . getRoot ( ) . getFolder ( packagePath ) ; try { packageFolder . getFile ( cuName ) . move ( packageFolder . getFile ( newName ) . getFullPath ( ) , true , null ) ; } catch ( CoreException e ) { handle ( e ) ; } } public void removeBinaryClass ( IPath packagePath , String className ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; className += "<STR_LIT:.class>" ; IFolder packageFolder = fWorkspace . getRoot ( ) . getFolder ( packagePath ) ; try { packageFolder . getFile ( className ) . delete ( true , null ) ; } catch ( CoreException e ) { handle ( e ) ; } } public void removeClass ( IPath packagePath , String className ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; className += "<STR_LIT>" ; IFolder packageFolder = fWorkspace . getRoot ( ) . getFolder ( packagePath ) ; try { packageFolder . getFile ( className ) . delete ( true , null ) ; } catch ( CoreException e ) { handle ( e ) ; } } public void removePackage ( IPath packageFragmentRootPath , String packageName ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; IPath path = packageFragmentRootPath . append ( packageName . replace ( '<CHAR_LIT:.>' , IPath . SEPARATOR ) ) ; IFolder folder = fWorkspace . getRoot ( ) . getFolder ( path ) ; try { folder . delete ( false , null ) ; } catch ( CoreException e ) { handle ( e ) ; } } public void removePackageFragmentRoot ( IPath projectPath , String packageFragmentRootName ) throws JavaModelException { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; if ( packageFragmentRootName . length ( ) > <NUM_LIT:0> ) { IFolder folder = getProject ( projectPath ) . getFolder ( packageFragmentRootName ) ; if ( folder . exists ( ) ) { try { folder . delete ( false , null ) ; } catch ( CoreException e ) { handle ( e ) ; } } } IPath rootPath = getPackageFragmentRootPath ( projectPath , packageFragmentRootName ) ; removeEntry ( projectPath , rootPath ) ; } public void removeProject ( IPath projectPath ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; try { getJavaProject ( projectPath ) . close ( ) ; } catch ( JavaModelException e ) { e . printStackTrace ( ) ; } IProject project = getProject ( projectPath ) ; try { project . delete ( true , null ) ; } catch ( CoreException e ) { handle ( e ) ; } } public void removeRequiredProject ( IPath projectPath , IPath requiredProject ) throws JavaModelException { removeEntry ( projectPath , requiredProject ) ; } public void resetWorkspace ( ) { if ( fProjects != null ) { Enumeration projectNames = fProjects . keys ( ) ; while ( projectNames . hasMoreElements ( ) ) { String projectName = ( String ) projectNames . nextElement ( ) ; removeProject ( getProject ( projectName ) . getFullPath ( ) ) ; } } } public void removeInternalJar ( IPath projectPath , String zipName ) throws JavaModelException { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; checkAssertion ( "<STR_LIT>" , zipName . endsWith ( "<STR_LIT>" ) || zipName . endsWith ( "<STR_LIT>" ) ) ; IPath zipPath = getJarRootPath ( projectPath ) . append ( zipName ) ; try { getJavaProject ( projectPath ) . getPackageFragmentRoot ( getWorkspace ( ) . getRoot ( ) . getFile ( zipPath ) ) . close ( ) ; } catch ( JavaModelException e ) { e . printStackTrace ( ) ; } removePackageFragmentRoot ( projectPath , zipName ) ; IFile file = getProject ( projectPath ) . getFile ( zipName ) ; try { file . delete ( false , null ) ; } catch ( CoreException e ) { handle ( e ) ; } } public void removeExternalJar ( IPath projectPath , IPath jarPath ) throws JavaModelException { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; removeEntry ( projectPath , jarPath ) ; } private void removeEntry ( IPath projectPath , IPath entryPath ) throws JavaModelException { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; IClasspathEntry [ ] oldEntries = getClasspath ( projectPath ) ; for ( int i = <NUM_LIT:0> ; i < oldEntries . length ; ++ i ) { if ( oldEntries [ i ] . getPath ( ) . equals ( entryPath ) ) { IClasspathEntry [ ] newEntries = new IClasspathEntry [ oldEntries . length - <NUM_LIT:1> ] ; System . arraycopy ( oldEntries , <NUM_LIT:0> , newEntries , <NUM_LIT:0> , i ) ; System . arraycopy ( oldEntries , i + <NUM_LIT:1> , newEntries , i , oldEntries . length - i - <NUM_LIT:1> ) ; setClasspath ( projectPath , newEntries ) ; } } } public void removeFile ( IPath filePath ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; try { fWorkspace . getRoot ( ) . getFile ( filePath ) . delete ( true , null ) ; } catch ( CoreException e ) { handle ( e ) ; } } public void removeFolder ( IPath folderPath ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; IFolder folder = fWorkspace . getRoot ( ) . getFolder ( folderPath ) ; try { folder . delete ( true , null ) ; } catch ( CoreException e ) { handle ( e ) ; } } public void setAutoBuilding ( boolean value ) { try { IWorkspace w = getWorkspace ( ) ; IWorkspaceDescription d = w . getDescription ( ) ; d . setAutoBuilding ( value ) ; w . setDescription ( d ) ; } catch ( CoreException e ) { e . printStackTrace ( ) ; checkAssertion ( "<STR_LIT>" , false ) ; } } public void setBuildOrder ( String [ ] projects ) { try { IWorkspace w = getWorkspace ( ) ; IWorkspaceDescription d = w . getDescription ( ) ; d . setBuildOrder ( projects ) ; w . setDescription ( d ) ; } catch ( CoreException e ) { e . printStackTrace ( ) ; checkAssertion ( "<STR_LIT>" , false ) ; } } public void setClasspath ( IPath projectPath , IClasspathEntry [ ] entries ) throws JavaModelException { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; IJavaProject javaProject = JavaCore . create ( getProject ( projectPath ) ) ; javaProject . setRawClasspath ( entries , null ) ; } public IPath setExternalOutputFolder ( IPath projectPath , String name , IPath externalOutputLocation ) { IPath result = null ; try { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; IProject p = getProject ( projectPath ) ; IFolder f = p . getFolder ( name ) ; f . createLink ( externalOutputLocation , IResource . ALLOW_MISSING_LOCAL , null ) ; result = f . getFullPath ( ) ; IJavaProject javaProject = JavaCore . create ( p ) ; javaProject . setOutputLocation ( result , null ) ; } catch ( CoreException e ) { e . printStackTrace ( ) ; checkAssertion ( "<STR_LIT>" , false ) ; } return result ; } public IPath setOutputFolder ( IPath projectPath , String outputFolder ) { IPath outputPath = null ; try { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; IJavaProject javaProject = JavaCore . create ( getProject ( projectPath ) ) ; outputPath = projectPath . append ( outputFolder ) ; javaProject . setOutputLocation ( outputPath , null ) ; } catch ( JavaModelException e ) { e . printStackTrace ( ) ; checkAssertion ( "<STR_LIT>" , false ) ; } return outputPath ; } private void setup ( ) { fIsOpen = true ; } public void waitForAutoBuild ( ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; boolean wasInterrupted = false ; do { try { Job . getJobManager ( ) . join ( ResourcesPlugin . FAMILY_AUTO_BUILD , null ) ; wasInterrupted = false ; } catch ( OperationCanceledException e ) { handle ( e ) ; } catch ( InterruptedException e ) { wasInterrupted = true ; } } while ( wasInterrupted ) ; } public void waitForManualRefresh ( ) { checkAssertion ( "<STR_LIT>" , fIsOpen ) ; boolean wasInterrupted = false ; do { try { Job . getJobManager ( ) . join ( ResourcesPlugin . FAMILY_MANUAL_REFRESH , null ) ; wasInterrupted = false ; } catch ( OperationCanceledException e ) { handle ( e ) ; } catch ( InterruptedException e ) { wasInterrupted = true ; } } while ( wasInterrupted ) ; } public void addJar ( IPath projectPath , String path ) throws Exception { URL jar = Platform . getBundle ( "<STR_LIT>" ) . getEntry ( path ) ; addExternalJar ( projectPath , FileLocator . resolve ( jar ) . getFile ( ) ) ; } public void addGroovyJars ( IPath projectPath ) throws Exception { addExternalJar ( projectPath , GroovyActivator . GROOVY_JAR_URL . getFile ( ) ) ; addExternalJar ( projectPath , GroovyActivator . ASM_JAR_URL . getFile ( ) ) ; } public void addGroovyPlusPlusJar ( IPath projectPath ) throws Exception { addExternalJar ( projectPath , GroovyActivator . GROOVY_GPP_URL . getFile ( ) ) ; } public void addJUnitJar ( IPath projectPath ) throws Exception { addExternalJar ( projectPath , FileLocator . resolve ( Platform . getBundle ( "<STR_LIT>" ) . getEntry ( "<STR_LIT>" ) ) . getFile ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . tests . builder ; import junit . framework . * ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . tests . util . Util ; import org . eclipse . jdt . internal . core . JavaModelManager ; import org . eclipse . jdt . internal . core . JavaProject ; public class OutputFolderTests extends BuilderTests { public OutputFolderTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( OutputFolderTests . class ) ; } public void testChangeOutputFolder ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; IPath bin1 = env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:Test>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( bin1 . append ( "<STR_LIT>" ) ) ; IPath bin2 = env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( bin2 . append ( "<STR_LIT>" ) ) ; } public void testDeleteOutputFolder ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; IPath root = env . getPackageFragmentRootPath ( projectPath , "<STR_LIT>" ) ; IPath bin = env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Test>" , "<STR_LIT>" ) ; env . addFile ( root , "<STR_LIT>" , "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( new IPath [ ] { bin . append ( "<STR_LIT>" ) , bin . append ( "<STR_LIT>" ) } ) ; env . removeFolder ( bin ) ; fullBuild ( ) ; expectingPresenceOf ( new IPath [ ] { bin . append ( "<STR_LIT>" ) , bin . append ( "<STR_LIT>" ) } ) ; } public void testInvalidOutput ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addClass ( projectPath , "<STR_LIT:src>" , "<STR_LIT:A>" , "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; env . addFile ( projectPath , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + Util . getJavaClassLibs ( ) + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; JavaProject project = ( JavaProject ) manager . getJavaModel ( ) . getJavaProject ( "<STR_LIT>" ) ; manager . removePerProjectInfo ( project , true ) ; IPath cuPath = env . addClass ( projectPath , "<STR_LIT:src>" , "<STR_LIT:A>" , "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingPresenceOf ( new IPath [ ] { cuPath } ) ; } public void testSimpleProject ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; IPath bin = env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addClass ( projectPath , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" ) ; env . addClass ( projectPath , "<STR_LIT:p>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( new IPath [ ] { bin . append ( "<STR_LIT>" ) , bin . append ( "<STR_LIT>" ) } ) ; } public void testProjectWithBin ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; IPath src = env . getPackageFragmentRootPath ( projectPath , "<STR_LIT>" ) ; IPath bin = env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addClass ( src , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" ) ; env . addClass ( src , "<STR_LIT:p>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( new IPath [ ] { bin . append ( "<STR_LIT>" ) , bin . append ( "<STR_LIT>" ) } ) ; } public void testProjectWithSrcBin ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath src = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; IPath bin = env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addClass ( src , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" ) ; env . addClass ( src , "<STR_LIT:p>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( new IPath [ ] { bin . append ( "<STR_LIT>" ) , bin . append ( "<STR_LIT>" ) } ) ; } public void testProjectWith2SrcBin ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath src1 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath src2 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath bin = env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addClass ( src1 , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" ) ; env . addClass ( src2 , "<STR_LIT:p>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( new IPath [ ] { bin . append ( "<STR_LIT>" ) , bin . append ( "<STR_LIT>" ) } ) ; } public void testProjectWith2SrcAsBin ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath src1 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , null , "<STR_LIT>" ) ; IPath src2 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , null , "<STR_LIT>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addClass ( src1 , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" ) ; env . addClass ( src2 , "<STR_LIT:p>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( new IPath [ ] { src1 . append ( "<STR_LIT>" ) , src2 . append ( "<STR_LIT>" ) } ) ; } public void testProjectWith2Src2Bin ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath src1 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , null , "<STR_LIT>" ) ; IPath src2 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , null , "<STR_LIT>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addClass ( src1 , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" ) ; env . addClass ( src2 , "<STR_LIT:p>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( new IPath [ ] { projectPath . append ( "<STR_LIT>" ) , projectPath . append ( "<STR_LIT>" ) } ) ; } public void testProjectWith3Src2Bin ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath src1 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , null , "<STR_LIT>" ) ; IPath src2 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , null , "<STR_LIT>" ) ; IPath src3 = env . addPackageFragmentRoot ( projectPath , "<STR_LIT>" , null , "<STR_LIT>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addClass ( src1 , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" ) ; env . addClass ( src2 , "<STR_LIT:p>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( src3 , "<STR_LIT>" , "<STR_LIT:C>" , "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( new IPath [ ] { projectPath . append ( "<STR_LIT>" ) , projectPath . append ( "<STR_LIT>" ) , projectPath . append ( "<STR_LIT>" ) } ) ; } public void test2ProjectWith1Bin ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; IPath bin = env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; IPath projectPath2 = env . addProject ( "<STR_LIT>" ) ; IPath binLocation = env . getProject ( projectPath ) . getFolder ( "<STR_LIT>" ) . getLocation ( ) ; env . setExternalOutputFolder ( projectPath2 , "<STR_LIT>" , binLocation ) ; env . addExternalJars ( projectPath2 , Util . getJavaClassLibs ( ) ) ; env . addRequiredProject ( projectPath2 , projectPath ) ; env . addClass ( projectPath2 , "<STR_LIT:p>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( bin . append ( "<STR_LIT>" ) ) ; } } </s>
<s> package org . eclipse . jdt . core . tests . builder ; import java . util . Arrays ; import java . util . Enumeration ; import java . util . HashSet ; import java . util . Hashtable ; import java . util . List ; import java . util . Set ; import java . util . Vector ; import org . eclipse . core . resources . IMarker ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . IClasspathEntry ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . tests . junit . extension . TestCase ; import org . eclipse . jdt . core . tests . util . TestVerifier ; import org . eclipse . jdt . core . tests . util . Util ; import org . eclipse . jdt . internal . compiler . Compiler ; import org . eclipse . jdt . internal . core . DefaultWorkingCopyOwner ; public class BuilderTests extends TestCase { protected static boolean DEBUG = false ; protected static TestingEnvironment env = null ; protected EfficiencyCompilerRequestor debugRequestor = null ; public BuilderTests ( String name ) { super ( name ) ; } protected void cleanBuild ( ) { debugRequestor . clearResult ( ) ; debugRequestor . activate ( ) ; env . cleanBuild ( ) ; debugRequestor . deactivate ( ) ; } protected void executeClass ( IPath projectPath , String className , String expectingOutput , String expectedError ) { TestVerifier verifier = new TestVerifier ( false ) ; Vector classpath = new Vector ( <NUM_LIT:5> ) ; IPath workspacePath = env . getWorkspaceRootPath ( ) ; classpath . addElement ( workspacePath . append ( env . getOutputLocation ( projectPath ) ) . toOSString ( ) ) ; IClasspathEntry [ ] cp = env . getClasspath ( projectPath ) ; for ( int i = <NUM_LIT:0> ; i < cp . length ; i ++ ) { IPath c = cp [ i ] . getPath ( ) ; String ext = c . getFileExtension ( ) ; if ( ext != null && ( ext . equals ( "<STR_LIT>" ) || ext . equals ( "<STR_LIT>" ) ) ) { if ( projectPath . isPrefixOf ( c ) ) { classpath . addElement ( workspacePath . append ( c ) . toOSString ( ) ) ; } else { classpath . addElement ( c . toOSString ( ) ) ; } } } verifier . execute ( className , ( String [ ] ) classpath . toArray ( new String [ <NUM_LIT:0> ] ) ) ; if ( DEBUG ) { System . out . println ( "<STR_LIT>" ) ; System . out . println ( Util . displayString ( verifier . getExecutionError ( ) ) ) ; System . out . println ( "<STR_LIT>" ) ; System . out . println ( Util . displayString ( verifier . getExecutionOutput ( ) ) ) ; } String actualError = verifier . getExecutionError ( ) ; char [ ] error = actualError . toCharArray ( ) ; actualError = new String ( CharOperation . replace ( error , System . getProperty ( "<STR_LIT>" ) . toCharArray ( ) , new char [ ] { '<STR_LIT:\n>' } ) ) ; if ( expectedError == null && actualError . length ( ) != <NUM_LIT:0> ) { fail ( "<STR_LIT>" + actualError ) ; } if ( expectedError != null && actualError . indexOf ( expectedError ) == - <NUM_LIT:1> ) { System . out . println ( "<STR_LIT>" ) ; System . out . println ( Util . displayString ( actualError ) ) ; } if ( expectedError != null ) { assertTrue ( "<STR_LIT>" + actualError + "<STR_LIT>" + expectedError , actualError . indexOf ( expectedError ) != - <NUM_LIT:1> ) ; } String actualOutput = verifier . getExecutionOutput ( ) ; if ( actualOutput . indexOf ( expectingOutput ) == - <NUM_LIT:1> ) { System . out . println ( "<STR_LIT>" ) ; System . out . println ( Util . displayString ( actualOutput ) ) ; } int idx = - <NUM_LIT:1> ; while ( ( idx = actualOutput . indexOf ( '<STR_LIT>' ) ) != - <NUM_LIT:1> ) { actualOutput = actualOutput . substring ( <NUM_LIT:0> , idx ) + actualOutput . substring ( idx + <NUM_LIT:1> ) ; } assertTrue ( "<STR_LIT>" + expectingOutput + "<STR_LIT>" + actualOutput , actualOutput . indexOf ( expectingOutput ) != - <NUM_LIT:1> ) ; } protected void expectingParticipantProblems ( IPath path , String expected ) { Problem [ ] problems = env . getProblemsFor ( path , "<STR_LIT>" ) ; StringBuffer buf = new StringBuffer ( ) ; for ( int i = <NUM_LIT:0> , length = problems . length ; i < length ; i ++ ) { Problem problem = problems [ i ] ; buf . append ( problem . getMessage ( ) ) ; if ( i < length - <NUM_LIT:1> ) buf . append ( '<STR_LIT:\n>' ) ; } assertEquals ( "<STR_LIT>" , expected , buf . toString ( ) ) ; } protected void expectingPresenceOf ( IPath path ) { expectingPresenceOf ( new IPath [ ] { path } ) ; } protected void expectingPresenceOf ( IPath [ ] paths ) { IPath wRoot = env . getWorkspaceRootPath ( ) ; for ( int i = <NUM_LIT:0> ; i < paths . length ; i ++ ) assertTrue ( paths [ i ] + "<STR_LIT>" , wRoot . append ( paths [ i ] ) . toFile ( ) . exists ( ) ) ; } protected void expectingNoPresenceOf ( IPath path ) { expectingNoPresenceOf ( new IPath [ ] { path } ) ; } protected void expectingNoPresenceOf ( IPath [ ] paths ) { IPath wRoot = env . getWorkspaceRootPath ( ) ; for ( int i = <NUM_LIT:0> ; i < paths . length ; i ++ ) assertTrue ( paths [ i ] + "<STR_LIT>" , ! wRoot . append ( paths [ i ] ) . toFile ( ) . exists ( ) ) ; } protected void expectingCompiledClasses ( String [ ] expected ) { String [ ] actual = debugRequestor . getCompiledClasses ( ) ; org . eclipse . jdt . internal . core . util . Util . sort ( actual ) ; org . eclipse . jdt . internal . core . util . Util . sort ( expected ) ; expectingCompiling ( actual , expected , "<STR_LIT>" + expected . length + "<STR_LIT>" + actual . length ) ; } protected void expectedCompiledClassCount ( int expected ) { int actual = debugRequestor . getCompiledClasses ( ) . length ; assertEquals ( expected , actual ) ; } protected void expectingUniqueCompiledClasses ( String [ ] expected ) { String [ ] actual = debugRequestor . getCompiledClasses ( ) ; org . eclipse . jdt . internal . core . util . Util . sort ( actual ) ; int dups = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < actual . length - <NUM_LIT:1> ; ++ i ) { if ( actual [ i + <NUM_LIT:1> ] . equals ( actual [ i ] ) ) { ++ dups ; actual [ i ] = null ; } } String [ ] uniqueActual = new String [ actual . length - dups ] ; for ( int i = <NUM_LIT:0> , j = <NUM_LIT:0> ; i < actual . length ; ++ i ) { if ( actual [ i ] != null ) { uniqueActual [ j ++ ] = actual [ i ] ; } } org . eclipse . jdt . internal . core . util . Util . sort ( expected ) ; expectingCompiling ( uniqueActual , expected , "<STR_LIT>" ) ; } protected void expectingCompilingOrder ( String [ ] expected ) { expectingCompiling ( debugRequestor . getCompiledClasses ( ) , expected , "<STR_LIT>" ) ; } private void expectingCompiling ( String [ ] actual , String [ ] expected , String message ) { if ( DEBUG ) for ( int i = <NUM_LIT:0> ; i < actual . length ; i ++ ) System . out . println ( actual [ i ] ) ; StringBuffer actualBuffer = new StringBuffer ( "<STR_LIT:{>" ) ; for ( int i = <NUM_LIT:0> ; i < actual . length ; i ++ ) { if ( i > <NUM_LIT:0> ) actualBuffer . append ( "<STR_LIT:U+002C>" ) ; actualBuffer . append ( actual [ i ] ) ; } actualBuffer . append ( '<CHAR_LIT:}>' ) ; StringBuffer expectedBuffer = new StringBuffer ( "<STR_LIT:{>" ) ; for ( int i = <NUM_LIT:0> ; i < expected . length ; i ++ ) { if ( i > <NUM_LIT:0> ) expectedBuffer . append ( "<STR_LIT:U+002C>" ) ; expectedBuffer . append ( expected [ i ] ) ; } expectedBuffer . append ( '<CHAR_LIT:}>' ) ; assertEquals ( message , expectedBuffer . toString ( ) , actualBuffer . toString ( ) ) ; } protected void expectingNoProblems ( ) { expectingNoProblemsFor ( env . getWorkspaceRootPath ( ) ) ; } protected void expectingNoErrors ( ) { expectingNoErrorsFor ( env . getWorkspaceRootPath ( ) ) ; } protected void expectingNoProblemsFor ( IPath root ) { expectingNoProblemsFor ( new IPath [ ] { root } ) ; } protected void expectingNoErrorsFor ( IPath root ) { expectingNoErrorsFor ( new IPath [ ] { root } ) ; } protected void expectingNoProblemsFor ( IPath [ ] roots ) { StringBuffer buffer = new StringBuffer ( ) ; Problem [ ] allProblems = allSortedProblems ( roots ) ; if ( allProblems != null ) { for ( int i = <NUM_LIT:0> , length = allProblems . length ; i < length ; i ++ ) { buffer . append ( allProblems [ i ] + "<STR_LIT:n>" ) ; } } String actual = buffer . toString ( ) ; assumeEquals ( "<STR_LIT>" , "<STR_LIT>" , actual ) ; } protected void expectingNoErrorsFor ( IPath [ ] roots ) { StringBuffer buffer = new StringBuffer ( ) ; Problem [ ] allProblems = allSortedProblems ( roots ) ; int count = <NUM_LIT:0> ; if ( allProblems != null ) { for ( int i = <NUM_LIT:0> , length = allProblems . length ; i < length ; i ++ ) { if ( allProblems [ i ] . getSeverity ( ) == IMarker . SEVERITY_ERROR ) { if ( allProblems [ i ] . toString ( ) . indexOf ( "<STR_LIT>" ) == - <NUM_LIT:1> ) { buffer . append ( allProblems [ i ] + "<STR_LIT:n>" ) ; count ++ ; } } } } String actual = buffer . toString ( ) ; assumeEquals ( "<STR_LIT>" + count , "<STR_LIT>" , actual ) ; } protected void expectingOnlyProblemsFor ( IPath expected ) { expectingOnlyProblemsFor ( new IPath [ ] { expected } ) ; } protected void expectingOnlyProblemsFor ( IPath [ ] expected ) { if ( DEBUG ) printProblems ( ) ; Problem [ ] rootProblems = env . getProblems ( ) ; Hashtable actual = new Hashtable ( rootProblems . length * <NUM_LIT:2> + <NUM_LIT:1> ) ; for ( int i = <NUM_LIT:0> ; i < rootProblems . length ; i ++ ) { IPath culprit = rootProblems [ i ] . getResourcePath ( ) ; actual . put ( culprit , culprit ) ; } for ( int i = <NUM_LIT:0> ; i < expected . length ; i ++ ) if ( ! actual . containsKey ( expected [ i ] ) ) assertTrue ( "<STR_LIT>" + expected [ i ] . toString ( ) , false ) ; if ( actual . size ( ) > expected . length ) { for ( Enumeration e = actual . elements ( ) ; e . hasMoreElements ( ) ; ) { IPath path = ( IPath ) e . nextElement ( ) ; boolean found = false ; for ( int i = <NUM_LIT:0> ; i < expected . length ; ++ i ) { if ( path . equals ( expected [ i ] ) ) { found = true ; break ; } } if ( ! found ) assertTrue ( "<STR_LIT>" + path . toString ( ) , false ) ; } } } protected void expectingOnlySpecificProblemFor ( IPath root , Problem problem ) { expectingOnlySpecificProblemsFor ( root , new Problem [ ] { problem } ) ; } protected void expectingOnlySpecificProblemsFor ( IPath root , Problem [ ] expectedProblems ) { if ( DEBUG ) printProblemsFor ( root ) ; Problem [ ] rootProblems = env . getProblemsFor ( root ) ; for ( int i = <NUM_LIT:0> ; i < expectedProblems . length ; i ++ ) { Problem expectedProblem = expectedProblems [ i ] ; boolean found = false ; for ( int j = <NUM_LIT:0> ; j < rootProblems . length ; j ++ ) { if ( expectedProblem . equals ( rootProblems [ j ] ) ) { found = true ; rootProblems [ j ] = null ; break ; } } if ( ! found ) { printProblemsFor ( root ) ; } assertTrue ( "<STR_LIT>" + expectedProblem . toString ( ) , found ) ; } for ( int i = <NUM_LIT:0> ; i < rootProblems . length ; i ++ ) { if ( rootProblems [ i ] != null ) { printProblemsFor ( root ) ; assertTrue ( "<STR_LIT>" + rootProblems [ i ] . toString ( ) , false ) ; } } } protected void expectingProblemsFor ( IPath root , String expected ) { expectingProblemsFor ( new IPath [ ] { root } , expected ) ; } protected void expectingProblemsFor ( IPath [ ] roots , String expected ) { Problem [ ] problems = allSortedProblems ( roots ) ; assumeEquals ( "<STR_LIT>" , expected , arrayToString ( problems ) ) ; } protected void expectingProblemsFor ( IPath root , List expected ) { expectingProblemsFor ( new IPath [ ] { root } , expected ) ; } protected void expectingProblemsFor ( IPath [ ] roots , List expected ) { Problem [ ] allProblems = allSortedProblems ( roots ) ; assumeEquals ( "<STR_LIT>" , arrayToString ( expected . toArray ( ) ) , arrayToString ( allProblems ) ) ; } protected void expectingSpecificProblemFor ( IPath root , Problem problem ) { expectingSpecificProblemsFor ( root , new Problem [ ] { problem } ) ; } protected void expectingSpecificProblemsFor ( IPath root , Problem [ ] problems ) { if ( DEBUG ) printProblemsFor ( root ) ; Problem [ ] rootProblems = env . getProblemsFor ( root ) ; next : for ( int i = <NUM_LIT:0> ; i < problems . length ; i ++ ) { Problem problem = problems [ i ] ; for ( int j = <NUM_LIT:0> ; j < rootProblems . length ; j ++ ) { Problem rootProblem = rootProblems [ j ] ; if ( rootProblem != null ) { if ( problem . equals ( rootProblem ) ) { rootProblems [ j ] = null ; continue next ; } } } System . out . println ( "<STR_LIT>" ) ; System . out . println ( "<STR_LIT>" + getName ( ) + "<STR_LIT::>" ) ; System . out . println ( "<STR_LIT>" + problem ) ; System . out . println ( "<STR_LIT>" + arrayToString ( rootProblems ) ) ; assumeTrue ( "<STR_LIT>" + problem , false ) ; } } protected void fullBuild ( ) { debugRequestor . clearResult ( ) ; debugRequestor . activate ( ) ; env . fullBuild ( ) ; debugRequestor . deactivate ( ) ; } protected void fullBuild ( IPath projectPath ) { debugRequestor . clearResult ( ) ; debugRequestor . activate ( ) ; env . fullBuild ( projectPath ) ; debugRequestor . deactivate ( ) ; } protected void incrementalBuild ( IPath projectPath ) { debugRequestor . clearResult ( ) ; debugRequestor . activate ( ) ; env . incrementalBuild ( projectPath ) ; debugRequestor . deactivate ( ) ; } protected void incrementalBuild ( ) { debugRequestor . clearResult ( ) ; debugRequestor . activate ( ) ; env . incrementalBuild ( ) ; debugRequestor . deactivate ( ) ; } protected void printProblems ( ) { printProblemsFor ( env . getWorkspaceRootPath ( ) ) ; } protected void printProblemsFor ( IPath root ) { printProblemsFor ( new IPath [ ] { root } ) ; } protected void printProblemsFor ( IPath [ ] roots ) { for ( int i = <NUM_LIT:0> ; i < roots . length ; i ++ ) { IPath path = roots [ i ] ; Problem [ ] problems = env . getProblemsFor ( path ) ; System . out . println ( arrayToString ( problems ) ) ; System . out . println ( ) ; } } protected String arrayToString ( Object [ ] array ) { StringBuffer buffer = new StringBuffer ( ) ; int length = array == null ? <NUM_LIT:0> : array . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( array [ i ] != null ) { if ( i > <NUM_LIT:0> ) buffer . append ( '<STR_LIT:\n>' ) ; buffer . append ( array [ i ] . toString ( ) ) ; } } return buffer . toString ( ) ; } protected void setUp ( ) throws Exception { super . setUp ( ) ; System . out . println ( "<STR_LIT>" ) ; System . out . println ( "<STR_LIT>" + getName ( ) ) ; debugRequestor = new EfficiencyCompilerRequestor ( ) ; Compiler . DebugRequestor = debugRequestor ; if ( env == null ) { env = new TestingEnvironment ( ) ; env . openEmptyWorkspace ( ) ; } env . resetWorkspace ( ) ; } protected void tearDown ( ) throws Exception { env . resetWorkspace ( ) ; ICompilationUnit [ ] wcs = new ICompilationUnit [ <NUM_LIT:0> ] ; int i = <NUM_LIT:0> ; do { wcs = JavaCore . getWorkingCopies ( DefaultWorkingCopyOwner . PRIMARY ) ; for ( ICompilationUnit workingCopy : wcs ) { try { workingCopy . discardWorkingCopy ( ) ; workingCopy . close ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } i ++ ; if ( i > <NUM_LIT:20> ) { fail ( "<STR_LIT>" + wcs ) ; } } while ( wcs . length > <NUM_LIT:0> ) ; JavaCore . setOptions ( JavaCore . getDefaultOptions ( ) ) ; super . tearDown ( ) ; } Problem [ ] allSortedProblems ( IPath [ ] roots ) { Problem [ ] allProblems = null ; for ( int i = <NUM_LIT:0> , max = roots . length ; i < max ; i ++ ) { Problem [ ] problems = env . getProblemsFor ( roots [ i ] ) ; int length = problems . length ; if ( problems . length != <NUM_LIT:0> ) { if ( allProblems == null ) { allProblems = problems ; } else { int all = allProblems . length ; System . arraycopy ( allProblems , <NUM_LIT:0> , allProblems = new Problem [ all + length ] , <NUM_LIT:0> , all ) ; System . arraycopy ( problems , <NUM_LIT:0> , allProblems , all , length ) ; } } } if ( allProblems != null ) { Arrays . sort ( allProblems ) ; } return allProblems ; } public static void assertElements ( Set < Object > actualSet , Object ... expecteds ) { HashSet < Object > expectedSet = new HashSet < Object > ( Arrays . asList ( expecteds ) ) ; StringBuilder msg = new StringBuilder ( ) ; for ( Object expected : expectedSet ) { if ( ! actualSet . contains ( expected ) ) { msg . append ( "<STR_LIT>" + expected + "<STR_LIT:n>" ) ; } } for ( Object actual : actualSet ) { if ( ! expectedSet . contains ( actual ) ) { msg . append ( "<STR_LIT>" + actual + "<STR_LIT:n>" ) ; } } if ( ! "<STR_LIT>" . equals ( msg . toString ( ) ) ) { fail ( msg . toString ( ) ) ; } } } </s>
<s> package org . eclipse . jdt . core . tests . builder ; import org . eclipse . core . resources . IMarker ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . IJavaModelMarker ; public class Problem implements Comparable { private String location ; private String message ; private IPath resourcePath ; private int start = - <NUM_LIT:1> , end = - <NUM_LIT:1> , categoryId = - <NUM_LIT:1> ; private String sourceId ; private int severity = IMarker . SEVERITY_ERROR ; public Problem ( String location , String message , IPath resourcePath , int start , int end , int categoryId , int severity ) { this . location = location ; this . message = message ; this . resourcePath = resourcePath ; this . start = start ; this . end = end ; this . categoryId = categoryId ; this . severity = severity ; } public Problem ( IMarker marker ) { this . location = marker . getAttribute ( IMarker . LOCATION , "<STR_LIT>" ) ; this . message = marker . getAttribute ( IMarker . MESSAGE , "<STR_LIT>" ) ; this . resourcePath = marker . getResource ( ) . getFullPath ( ) ; this . start = marker . getAttribute ( IMarker . CHAR_START , - <NUM_LIT:1> ) ; this . end = marker . getAttribute ( IMarker . CHAR_END , - <NUM_LIT:1> ) ; this . categoryId = marker . getAttribute ( IJavaModelMarker . CATEGORY_ID , - <NUM_LIT:1> ) ; this . sourceId = marker . getAttribute ( IMarker . SOURCE_ID , "<STR_LIT>" ) ; this . severity = marker . getAttribute ( IMarker . SEVERITY , IMarker . SEVERITY_ERROR ) ; } public int getCategoryId ( ) { return categoryId ; } public String getSourceId ( ) { return this . sourceId ; } public String getLocation ( ) { return location ; } public String getMessage ( ) { return message ; } public IPath getResourcePath ( ) { return resourcePath ; } public int getSeverity ( ) { return this . severity ; } public int getStart ( ) { return this . start ; } public int getEnd ( ) { return this . end ; } public String toString ( ) { return "<STR_LIT>" + message + "<STR_LIT>" + resourcePath + "<STR_LIT:>>" + ( "<STR_LIT>" + this . start + "<STR_LIT:U+002C>" + this . end + "<STR_LIT:>>" ) + ( "<STR_LIT>" + this . categoryId + "<STR_LIT:>>" ) + ( "<STR_LIT>" + this . severity + "<STR_LIT:>>" ) + "<STR_LIT:]>" ; } public boolean equals ( Object o ) { if ( o instanceof Problem ) { return this . toString ( ) . equals ( o . toString ( ) ) ; } return false ; } public int compareTo ( Object o ) { if ( o instanceof Problem ) { Problem problem = ( Problem ) o ; return this . toString ( ) . compareTo ( problem . toString ( ) ) ; } return - <NUM_LIT:1> ; } } </s>
<s> package org . eclipse . jdt . core . tests . builder ; import junit . framework . Test ; import org . eclipse . core . resources . IMarker ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . core . tests . util . Util ; public class Java50Tests extends BuilderTests { public Java50Tests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( Java50Tests . class ) ; } public void testAnnotation ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath usePath = env . addClass ( projectPath , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; env . addClass ( projectPath , "<STR_LIT:q>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; env . addClass ( projectPath , "<STR_LIT:q>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; incrementalBuild ( projectPath ) ; expectingProblemsFor ( usePath , "<STR_LIT>" ) ; } public void testHierarchyCycle ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( projectPath , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( projectPath , "<STR_LIT>" , "<STR_LIT:C>" , "<STR_LIT>" ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; } public void testHierarchyCycleInstanceof ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( projectPath , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; env . addClass ( projectPath , "<STR_LIT>" , "<STR_LIT:C>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; } public void testMissingRequiredBinaries ( ) throws JavaModelException { IPath p1 = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; IPath p2 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( p1 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p1 , "<STR_LIT>" ) ; IPath root1 = env . addPackageFragmentRoot ( p1 , "<STR_LIT:src>" ) ; env . setOutputFolder ( p1 , "<STR_LIT>" ) ; env . addExternalJars ( p2 , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( p2 , "<STR_LIT>" ) ; IPath root2 = env . addPackageFragmentRoot ( p2 , "<STR_LIT:src>" ) ; IPath p2bin = env . setOutputFolder ( p2 , "<STR_LIT>" ) ; env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; env . addClassFolder ( p1 , p2bin , false ) ; env . removeFile ( p2bin . append ( "<STR_LIT>" ) ) ; env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( p1 ) ; expectingNoProblems ( ) ; IPath xx = env . addClass ( root1 , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( p1 ) ; expectingOnlySpecificProblemsFor ( p1 , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , p1 , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" , xx , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) } ) ; } public void testParameterizedMemberType ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath xPath = env . addClass ( projectPath , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" ) ; IPath aPath = env . addClass ( projectPath , "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT>" ) ; IPath bPath = env . addClass ( projectPath , "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; env . addClass ( projectPath , "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; incrementalBuild ( projectPath ) ; expectingSpecificProblemFor ( xPath , new Problem ( "<STR_LIT:X>" , "<STR_LIT>" , xPath , <NUM_LIT:6> , <NUM_LIT:7> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; expectingSpecificProblemFor ( aPath , new Problem ( "<STR_LIT:A>" , "<STR_LIT>" , aPath , <NUM_LIT:6> , <NUM_LIT:7> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; expectingSpecificProblemFor ( bPath , new Problem ( "<STR_LIT:B>" , "<STR_LIT>" , bPath , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; env . addClass ( projectPath , "<STR_LIT>" , "<STR_LIT:X>" , "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingSpecificProblemFor ( xPath , new Problem ( "<STR_LIT:X>" , "<STR_LIT>" , xPath , <NUM_LIT:6> , <NUM_LIT:7> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; expectingSpecificProblemFor ( aPath , new Problem ( "<STR_LIT:A>" , "<STR_LIT>" , aPath , <NUM_LIT:6> , <NUM_LIT:7> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; expectingSpecificProblemFor ( bPath , new Problem ( "<STR_LIT:B>" , "<STR_LIT>" , bPath , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; env . addClass ( projectPath , "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; incrementalBuild ( projectPath ) ; expectingSpecificProblemFor ( xPath , new Problem ( "<STR_LIT:X>" , "<STR_LIT>" , xPath , <NUM_LIT:6> , <NUM_LIT:7> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; expectingSpecificProblemFor ( aPath , new Problem ( "<STR_LIT:A>" , "<STR_LIT>" , aPath , <NUM_LIT:6> , <NUM_LIT:7> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; expectingSpecificProblemFor ( bPath , new Problem ( "<STR_LIT:B>" , "<STR_LIT>" , bPath , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; env . addClass ( projectPath , "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; } public void testParameterizedType1 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath usePath = env . addClass ( projectPath , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; env . addClass ( projectPath , "<STR_LIT:q>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; env . addClass ( projectPath , "<STR_LIT:q>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; incrementalBuild ( projectPath ) ; expectingProblemsFor ( usePath , "<STR_LIT>" ) ; } public void testParameterizedType2 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath usePath = env . addClass ( projectPath , "<STR_LIT:p>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; env . addClass ( projectPath , "<STR_LIT:q>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; env . addClass ( projectPath , "<STR_LIT:q>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; incrementalBuild ( projectPath ) ; expectingProblemsFor ( usePath , "<STR_LIT>" ) ; } } </s>
<s> package org . eclipse . jdt . core . tests . builder ; import junit . framework . * ; import org . eclipse . core . resources . IMarker ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . resources . ResourcesPlugin ; import org . eclipse . core . runtime . * ; import org . eclipse . core . runtime . preferences . IEclipsePreferences ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . core . tests . util . AbstractCompilerTest ; import org . eclipse . jdt . core . tests . util . Util ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . core . * ; import java . io . File ; import java . io . IOException ; import java . util . * ; public class BuildpathTests extends BuilderTests { public BuildpathTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( BuildpathTests . class ) ; } private String getJdkLevelProblem ( String expectedRuntime , String path , int severity ) { Object target = JavaModel . getTarget ( new Path ( path ) . makeAbsolute ( ) , true ) ; long libraryJDK = org . eclipse . jdt . internal . core . util . Util . getJdkLevel ( target ) ; String jclRuntime = CompilerOptions . versionFromJdkLevel ( libraryJDK ) ; StringBuffer jdkLevelProblem = new StringBuffer ( "<STR_LIT>" ) ; jdkLevelProblem . append ( expectedRuntime ) ; jdkLevelProblem . append ( "<STR_LIT>" ) ; jdkLevelProblem . append ( path ) ; jdkLevelProblem . append ( "<STR_LIT>" ) ; jdkLevelProblem . append ( jclRuntime ) ; jdkLevelProblem . append ( "<STR_LIT>" ) ; jdkLevelProblem . append ( severity ) ; jdkLevelProblem . append ( "<STR_LIT>" ) ; return jdkLevelProblem . toString ( ) ; } public void testClasspathFileChange ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath classTest1 = env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; IPath src2Path = env . addFolder ( projectPath , "<STR_LIT>" ) ; IPath src2p1Path = env . addFolder ( src2Path , "<STR_LIT>" ) ; env . addFile ( src2p1Path , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingSpecificProblemFor ( classTest1 , new Problem ( "<STR_LIT:src>" , "<STR_LIT>" , classTest1 , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; StringBuffer buffer = new StringBuffer ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) ; String [ ] classlibs = Util . getJavaClassLibs ( ) ; for ( int i = <NUM_LIT:0> ; i < classlibs . length ; i ++ ) { buffer . append ( "<STR_LIT>" ) . append ( classlibs [ i ] ) . append ( "<STR_LIT>" ) ; } buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) ; boolean wasAutoBuilding = env . isAutoBuilding ( ) ; try { env . setAutoBuilding ( true ) ; env . addFile ( projectPath , "<STR_LIT>" , buffer . toString ( ) ) ; env . waitForAutoBuild ( ) ; expectingNoProblems ( ) ; } finally { env . setAutoBuilding ( wasAutoBuilding ) ; } } public void testClosedProject ( ) throws JavaModelException { IPath project1Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project1Path , Util . getJavaClassLibs ( ) ) ; IPath jarPath = env . addInternalJar ( project1Path , "<STR_LIT>" , new byte [ ] { <NUM_LIT:0> } ) ; IPath project2Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project2Path , Util . getJavaClassLibs ( ) ) ; env . addRequiredProject ( project2Path , project1Path ) ; IPath project3Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project3Path , Util . getJavaClassLibs ( ) ) ; env . addExternalJar ( project3Path , jarPath . toString ( ) ) ; fullBuild ( ) ; expectingNoProblems ( ) ; env . closeProject ( project1Path ) ; incrementalBuild ( ) ; expectingOnlyProblemsFor ( new IPath [ ] { project2Path , project3Path } ) ; expectingOnlySpecificProblemsFor ( project2Path , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , project2Path , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" , project2Path , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) } ) ; expectingOnlySpecificProblemsFor ( project3Path , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , project3Path , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" , project3Path , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) } ) ; env . openProject ( project1Path ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; Hashtable options = JavaCore . getOptions ( ) ; options . put ( JavaCore . CORE_JAVA_BUILD_INVALID_CLASSPATH , JavaCore . IGNORE ) ; JavaCore . setOptions ( options ) ; env . closeProject ( project1Path ) ; incrementalBuild ( ) ; expectingOnlyProblemsFor ( new IPath [ ] { project2Path , project3Path } ) ; expectingOnlySpecificProblemFor ( project2Path , new Problem ( "<STR_LIT>" , "<STR_LIT>" , project2Path , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) ) ; expectingOnlySpecificProblemFor ( project3Path , new Problem ( "<STR_LIT>" , "<STR_LIT>" , project3Path , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) ) ; env . openProject ( project1Path ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; options . put ( JavaCore . CORE_JAVA_BUILD_INVALID_CLASSPATH , JavaCore . ABORT ) ; JavaCore . setOptions ( options ) ; } public void testCorruptBuilder ( ) throws JavaModelException { IPath project1Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project1Path , Util . getJavaClassLibs ( ) ) ; env . addClass ( project1Path , "<STR_LIT:p>" , "<STR_LIT:Test>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; IPath outputFolderPackage = env . getOutputLocation ( project1Path ) . append ( "<STR_LIT:p>" ) ; env . removeBinaryClass ( outputFolderPackage , "<STR_LIT:Test>" ) ; IPath subTest = env . addClass ( project1Path , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingOnlySpecificProblemFor ( subTest , new Problem ( "<STR_LIT>" , "<STR_LIT>" , subTest , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; env . addClass ( project1Path , "<STR_LIT:p>" , "<STR_LIT:Test>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; Hashtable options = JavaCore . getOptions ( ) ; options . put ( JavaCore . CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER , JavaCore . ENABLED ) ; JavaCore . setOptions ( options ) ; env . removeBinaryClass ( outputFolderPackage , "<STR_LIT:Test>" ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; options . put ( JavaCore . CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER , JavaCore . IGNORE ) ; JavaCore . setOptions ( options ) ; } public void testCorruptBuilder2 ( ) throws JavaModelException { IPath project1Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project1Path , Util . getJavaClassLibs ( ) ) ; env . removePackageFragmentRoot ( project1Path , "<STR_LIT>" ) ; IPath src = env . addPackageFragmentRoot ( project1Path , "<STR_LIT:src>" ) ; IPath bin = env . setOutputFolder ( project1Path , "<STR_LIT>" ) ; env . addClass ( src , "<STR_LIT:p>" , "<STR_LIT:Test>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; IPath outputFolderPackage = bin . append ( "<STR_LIT:p>" ) ; env . removeBinaryClass ( outputFolderPackage , "<STR_LIT:Test>" ) ; IPath subTest = env . addClass ( src , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingOnlySpecificProblemFor ( subTest , new Problem ( "<STR_LIT>" , "<STR_LIT>" , subTest , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; env . addClass ( src , "<STR_LIT:p>" , "<STR_LIT:Test>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; Hashtable options = JavaCore . getOptions ( ) ; options . put ( JavaCore . CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER , JavaCore . ENABLED ) ; JavaCore . setOptions ( options ) ; env . removeBinaryClass ( outputFolderPackage , "<STR_LIT:Test>" ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; options . put ( JavaCore . CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER , JavaCore . IGNORE ) ; JavaCore . setOptions ( options ) ; } public void testChangeExternalFolder ( ) throws CoreException { String externalLib = Util . getOutputDirectory ( ) + File . separator + "<STR_LIT>" ; try { new File ( externalLib ) . mkdirs ( ) ; Util . compile ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" } , new HashMap ( ) , externalLib ) ; IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addExternalFolders ( projectPath , new String [ ] { externalLib } ) ; IPath root = env . getPackageFragmentRootPath ( projectPath , "<STR_LIT>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath classY = env . addClass ( root , "<STR_LIT:q>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; String externalClassFile = externalLib + File . separator + "<STR_LIT:p>" + File . separator + "<STR_LIT>" ; long lastModified = new java . io . File ( externalClassFile ) . lastModified ( ) ; try { Thread . sleep ( <NUM_LIT:1000> ) ; } catch ( InterruptedException e ) { } Util . compile ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" } , new HashMap ( ) , externalLib ) ; new java . io . File ( externalClassFile ) . setLastModified ( lastModified + <NUM_LIT:1000> ) ; env . getProject ( projectPath ) . refreshLocal ( IResource . DEPTH_INFINITE , null ) ; env . waitForManualRefresh ( ) ; incrementalBuild ( projectPath ) ; expectingProblemsFor ( classY , "<STR_LIT>" ) ; } finally { new File ( externalLib ) . delete ( ) ; } } public void testChangeZIPArchive1 ( ) throws Exception { String externalLib = Util . getOutputDirectory ( ) + File . separator + "<STR_LIT>" ; try { org . eclipse . jdt . core . tests . util . Util . createJar ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" } , externalLib , "<STR_LIT>" ) ; IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addExternalJars ( projectPath , new String [ ] { externalLib } ) ; IPath root = env . getPackageFragmentRootPath ( projectPath , "<STR_LIT>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath classY = env . addClass ( root , "<STR_LIT:q>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; long lastModified = new java . io . File ( externalLib ) . lastModified ( ) ; try { Thread . sleep ( <NUM_LIT:1000> ) ; } catch ( InterruptedException e ) { } org . eclipse . jdt . core . tests . util . Util . createJar ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" } , externalLib , "<STR_LIT>" ) ; new java . io . File ( externalLib ) . setLastModified ( lastModified + <NUM_LIT:1000> ) ; IJavaProject p = env . getJavaProject ( projectPath ) ; p . getJavaModel ( ) . refreshExternalArchives ( new IJavaElement [ ] { p } , null ) ; incrementalBuild ( projectPath ) ; expectingProblemsFor ( classY , "<STR_LIT>" ) ; } finally { new File ( externalLib ) . delete ( ) ; } } public void testChangeZIPArchive2 ( ) throws Exception { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; String internalLib = env . getProject ( "<STR_LIT>" ) . getLocation ( ) . toOSString ( ) + File . separator + "<STR_LIT>" ; org . eclipse . jdt . core . tests . util . Util . createJar ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" } , internalLib , "<STR_LIT>" ) ; env . getProject ( projectPath ) . refreshLocal ( IResource . DEPTH_INFINITE , null ) ; env . addEntry ( projectPath , JavaCore . newLibraryEntry ( new Path ( "<STR_LIT>" ) , null , null ) ) ; IPath root = env . getPackageFragmentRootPath ( projectPath , "<STR_LIT>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath classY = env . addClass ( root , "<STR_LIT:q>" , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( projectPath ) ; expectingNoProblems ( ) ; long lastModified = new java . io . File ( internalLib ) . lastModified ( ) ; try { Thread . sleep ( <NUM_LIT:1000> ) ; } catch ( InterruptedException e ) { } org . eclipse . jdt . core . tests . util . Util . createJar ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" } , internalLib , "<STR_LIT>" ) ; new java . io . File ( internalLib ) . setLastModified ( lastModified + <NUM_LIT:1000> ) ; env . getProject ( projectPath ) . refreshLocal ( IResource . DEPTH_INFINITE , null ) ; incrementalBuild ( projectPath ) ; expectingProblemsFor ( classY , "<STR_LIT>" ) ; } public void testExternalJarChange ( ) throws JavaModelException , IOException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; IPath root = env . getPackageFragmentRootPath ( projectPath , "<STR_LIT>" ) ; IPath classTest = env . addClass ( root , "<STR_LIT:p>" , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; String externalJar = Util . getOutputDirectory ( ) + File . separator + "<STR_LIT>" ; Util . createJar ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" } , new HashMap ( ) , externalJar ) ; long lastModified = new java . io . File ( externalJar ) . lastModified ( ) ; env . addExternalJar ( projectPath , externalJar ) ; fullBuild ( ) ; expectingProblemsFor ( classTest , "<STR_LIT>" ) ; try { Thread . sleep ( <NUM_LIT:1000> ) ; } catch ( InterruptedException e ) { } Util . createJar ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" } , new HashMap ( ) , externalJar ) ; new java . io . File ( externalJar ) . setLastModified ( lastModified + <NUM_LIT:1000> ) ; IJavaProject project = JavaCore . create ( ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getProject ( "<STR_LIT>" ) ) ; project . getJavaModel ( ) . refreshExternalArchives ( new IJavaElement [ ] { project } , null ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; } public void testMissingBuilder ( ) throws JavaModelException { IPath project1Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project1Path , Util . getJavaClassLibs ( ) ) ; IPath project2Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project2Path , Util . getJavaClassLibs ( ) ) ; env . addRequiredProject ( project2Path , project1Path ) ; env . addClass ( project1Path , "<STR_LIT>" , "<STR_LIT:Test>" , "<STR_LIT>" ) ; IPath sub = env . addClass ( project2Path , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; env . removeRequiredProject ( project2Path , project1Path ) ; incrementalBuild ( ) ; expectingOnlySpecificProblemFor ( sub , new Problem ( "<STR_LIT>" , "<STR_LIT>" , sub , <NUM_LIT> , <NUM_LIT> , CategorizedProblem . CAT_TYPE , IMarker . SEVERITY_ERROR ) ) ; env . addRequiredProject ( project2Path , project1Path ) ; try { JavaProject p = ( JavaProject ) env . getJavaProject ( project1Path ) ; p . deconfigure ( ) ; JavaModelManager . getJavaModelManager ( ) . setLastBuiltState ( p . getProject ( ) , null ) ; } catch ( CoreException e ) { e . printStackTrace ( ) ; } env . addClass ( project2Path , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; } public void testMissingFieldType ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; IPath root = env . getPackageFragmentRootPath ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Test>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; IPath projectPath2 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath2 , Util . getJavaClassLibs ( ) ) ; env . addRequiredProject ( projectPath2 , projectPath ) ; IPath root2 = env . getPackageFragmentRootPath ( projectPath2 , "<STR_LIT>" ) ; env . addClass ( root2 , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; IPath projectPath3 = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath3 , Util . getJavaClassLibs ( ) ) ; env . addRequiredProject ( projectPath3 , projectPath2 ) ; IPath root3 = env . getPackageFragmentRootPath ( projectPath3 , "<STR_LIT>" ) ; env . addClass ( root3 , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; } public void testMissingLibrary1 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; IPath bin = env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath classTest1 = env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingOnlyProblemsFor ( new IPath [ ] { projectPath , classTest1 } ) ; expectingOnlySpecificProblemsFor ( projectPath , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , projectPath , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" , classTest1 , <NUM_LIT:0> , <NUM_LIT:0> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) } ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( new IPath [ ] { bin . append ( "<STR_LIT>" ) . append ( "<STR_LIT>" ) , } ) ; env . removeProject ( projectPath ) ; } public void testMissingLibrary2 ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; IPath bin = env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath classTest1 = env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; IPath classTest2 = env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; IPath classTest3 = env . addClass ( root , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; fullBuild ( ) ; expectingSpecificProblemFor ( projectPath , new Problem ( "<STR_LIT>" , "<STR_LIT>" , projectPath , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) ) ; Problem [ ] prob1 = env . getProblemsFor ( classTest1 ) ; Problem [ ] prob2 = env . getProblemsFor ( classTest2 ) ; Problem [ ] prob3 = env . getProblemsFor ( classTest3 ) ; assertEquals ( "<STR_LIT>" , prob1 . length + prob2 . length + prob3 . length , <NUM_LIT:1> ) ; if ( prob1 . length == <NUM_LIT:1> ) { expectingSpecificProblemFor ( classTest1 , new Problem ( "<STR_LIT>" , "<STR_LIT>" , classTest1 , - <NUM_LIT:1> , - <NUM_LIT:1> , - <NUM_LIT:1> , IMarker . SEVERITY_ERROR ) ) ; } else if ( prob2 . length == <NUM_LIT:1> ) { expectingSpecificProblemFor ( classTest2 , new Problem ( "<STR_LIT>" , "<STR_LIT>" , classTest2 , - <NUM_LIT:1> , - <NUM_LIT:1> , - <NUM_LIT:1> , IMarker . SEVERITY_ERROR ) ) ; } else { expectingSpecificProblemFor ( classTest3 , new Problem ( "<STR_LIT>" , "<STR_LIT>" , classTest3 , <NUM_LIT:0> , <NUM_LIT:0> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) ) ; } env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( new IPath [ ] { bin . append ( "<STR_LIT>" ) . append ( "<STR_LIT>" ) , bin . append ( "<STR_LIT>" ) . append ( "<STR_LIT>" ) , bin . append ( "<STR_LIT>" ) . append ( "<STR_LIT>" ) } ) ; env . removeProject ( projectPath ) ; } public void testMissingLibrary3 ( ) throws JavaModelException { this . abortOnFailure = false ; IPath projectPath = env . addProject ( "<STR_LIT>" ) ; IJavaProject project = env . getJavaProject ( projectPath ) ; fullBuild ( ) ; expectingNoProblems ( ) ; project . setOption ( JavaCore . CORE_INCOMPLETE_CLASSPATH , CompilerOptions . WARNING ) ; env . addLibrary ( projectPath , projectPath . append ( "<STR_LIT>" ) , null , null ) ; fullBuild ( ) ; expectingSpecificProblemFor ( projectPath , new Problem ( "<STR_LIT>" , "<STR_LIT>" , projectPath , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) ) ; project . setOption ( JavaCore . CORE_INCOMPLETE_CLASSPATH , CompilerOptions . ERROR ) ; IClasspathEntry [ ] classpath = project . getRawClasspath ( ) ; IPath outputLocation ; project . setRawClasspath ( null , outputLocation = project . getOutputLocation ( ) , false , null ) ; project . setRawClasspath ( classpath , outputLocation , false , null ) ; fullBuild ( ) ; expectingSpecificProblemFor ( projectPath , new Problem ( "<STR_LIT>" , "<STR_LIT>" , projectPath , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) ) ; expectingSpecificProblemFor ( projectPath , new Problem ( "<STR_LIT>" , "<STR_LIT>" , projectPath , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) ) ; env . removeProject ( projectPath ) ; } public void testMissingLibrary4 ( ) throws JavaModelException { this . abortOnFailure = false ; IPath projectPath = env . addProject ( "<STR_LIT>" ) ; IJavaProject project = env . getJavaProject ( projectPath ) ; fullBuild ( ) ; expectingNoProblems ( ) ; env . addLibrary ( projectPath , projectPath . append ( "<STR_LIT>" ) , null , null ) ; fullBuild ( ) ; expectingSpecificProblemFor ( projectPath , new Problem ( "<STR_LIT>" , "<STR_LIT>" , projectPath , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) ) ; expectingSpecificProblemFor ( projectPath , new Problem ( "<STR_LIT>" , "<STR_LIT>" , projectPath , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) ) ; project . setOption ( JavaCore . CORE_INCOMPLETE_CLASSPATH , CompilerOptions . WARNING ) ; incrementalBuild ( ) ; expectingSpecificProblemFor ( projectPath , new Problem ( "<STR_LIT>" , "<STR_LIT>" , projectPath , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_WARNING ) ) ; env . removeProject ( projectPath ) ; } public void testIncompatibleJdkLEvelOnProject ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; IJavaProject project = env . getJavaProject ( projectPath ) ; String [ ] classlibs = Util . getJavaClassLibs ( ) ; env . addExternalJars ( projectPath , classlibs ) ; Arrays . sort ( classlibs ) ; fullBuild ( ) ; expectingNoProblems ( ) ; String projectRuntime = project . getOption ( JavaCore . COMPILER_CODEGEN_TARGET_PLATFORM , true ) ; project . setOption ( JavaCore . CORE_INCOMPATIBLE_JDK_LEVEL , CompilerOptions . WARNING ) ; incrementalBuild ( ) ; long projectRuntimeJDKLevel = CompilerOptions . versionToJdkLevel ( projectRuntime ) ; int max = classlibs . length ; List expectedProblems = new ArrayList ( ) ; for ( int i = <NUM_LIT:0> ; i < max ; i ++ ) { String path = project . getPackageFragmentRoot ( classlibs [ i ] ) . getPath ( ) . makeRelative ( ) . toString ( ) ; Object target = JavaModel . getTarget ( new Path ( path ) . makeAbsolute ( ) , true ) ; long libraryJDK = org . eclipse . jdt . internal . core . util . Util . getJdkLevel ( target ) ; if ( libraryJDK > projectRuntimeJDKLevel ) { expectedProblems . add ( getJdkLevelProblem ( projectRuntime , path , IMarker . SEVERITY_WARNING ) ) ; } } expectingProblemsFor ( projectPath , expectedProblems ) ; project . setOption ( JavaCore . CORE_INCOMPATIBLE_JDK_LEVEL , CompilerOptions . ERROR ) ; incrementalBuild ( ) ; expectedProblems = new ArrayList ( ) ; for ( int i = <NUM_LIT:0> ; i < max ; i ++ ) { String path = project . getPackageFragmentRoot ( classlibs [ i ] ) . getPath ( ) . makeRelative ( ) . toString ( ) ; Object target = JavaModel . getTarget ( new Path ( path ) . makeAbsolute ( ) , true ) ; long libraryJDK = org . eclipse . jdt . internal . core . util . Util . getJdkLevel ( target ) ; if ( libraryJDK > projectRuntimeJDKLevel ) { expectedProblems . add ( getJdkLevelProblem ( projectRuntime , path , IMarker . SEVERITY_ERROR ) ) ; } } expectedProblems . add ( "<STR_LIT>" ) ; expectingProblemsFor ( projectPath , expectedProblems ) ; env . removeProject ( projectPath ) ; } public void testIncompatibleJdkLEvelOnWksp ( ) throws JavaModelException { JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; IEclipsePreferences preferences = manager . getInstancePreferences ( ) ; String incompatibleJdkLevel = preferences . get ( JavaCore . CORE_INCOMPATIBLE_JDK_LEVEL , null ) ; try { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; IJavaProject project = env . getJavaProject ( projectPath ) ; String [ ] classlibs = Util . getJavaClassLibs ( ) ; env . addExternalJars ( projectPath , classlibs ) ; fullBuild ( ) ; expectingNoProblems ( ) ; String wkspRuntime = JavaCore . getOption ( JavaCore . COMPILER_CODEGEN_TARGET_PLATFORM ) ; long wkspRuntimeJDKLevel = CompilerOptions . versionToJdkLevel ( wkspRuntime ) ; Arrays . sort ( classlibs ) ; preferences . put ( JavaCore . CORE_INCOMPATIBLE_JDK_LEVEL , JavaCore . WARNING ) ; incrementalBuild ( ) ; List expectedProblems = new ArrayList ( ) ; int max = classlibs . length ; for ( int i = <NUM_LIT:0> ; i < max ; i ++ ) { String path = project . getPackageFragmentRoot ( classlibs [ i ] ) . getPath ( ) . makeRelative ( ) . toString ( ) ; Object target = JavaModel . getTarget ( new Path ( path ) . makeAbsolute ( ) , true ) ; long libraryJDK = org . eclipse . jdt . internal . core . util . Util . getJdkLevel ( target ) ; if ( libraryJDK > wkspRuntimeJDKLevel ) { expectedProblems . add ( getJdkLevelProblem ( wkspRuntime , path , IMarker . SEVERITY_WARNING ) ) ; } } expectingProblemsFor ( projectPath , expectedProblems ) ; preferences . put ( JavaCore . CORE_INCOMPATIBLE_JDK_LEVEL , JavaCore . ERROR ) ; incrementalBuild ( ) ; expectedProblems = new ArrayList ( ) ; for ( int i = <NUM_LIT:0> ; i < max ; i ++ ) { String path = project . getPackageFragmentRoot ( classlibs [ i ] ) . getPath ( ) . makeRelative ( ) . toString ( ) ; Object target = JavaModel . getTarget ( new Path ( path ) . makeAbsolute ( ) , true ) ; long libraryJDK = org . eclipse . jdt . internal . core . util . Util . getJdkLevel ( target ) ; if ( libraryJDK > wkspRuntimeJDKLevel ) { expectedProblems . add ( getJdkLevelProblem ( wkspRuntime , path , IMarker . SEVERITY_ERROR ) ) ; } } expectedProblems . add ( "<STR_LIT>" ) ; expectingProblemsFor ( projectPath , expectedProblems ) ; env . removeProject ( projectPath ) ; } finally { if ( incompatibleJdkLevel == null ) { preferences . remove ( JavaCore . CORE_INCOMPATIBLE_JDK_LEVEL ) ; } else { preferences . put ( JavaCore . CORE_INCOMPATIBLE_JDK_LEVEL , incompatibleJdkLevel ) ; } } } public void testMissingProject ( ) throws JavaModelException { IPath project1Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project1Path , Util . getJavaClassLibs ( ) ) ; IPath project2Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project2Path , Util . getJavaClassLibs ( ) ) ; env . addRequiredProject ( project2Path , project1Path ) ; fullBuild ( ) ; expectingNoProblems ( ) ; env . removeProject ( project1Path ) ; incrementalBuild ( ) ; expectingOnlyProblemsFor ( project2Path ) ; expectingOnlySpecificProblemsFor ( project2Path , new Problem [ ] { new Problem ( "<STR_LIT>" , "<STR_LIT>" , project2Path , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) , new Problem ( "<STR_LIT>" , "<STR_LIT>" , project2Path , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) } ) ; project1Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project1Path , Util . getJavaClassLibs ( ) ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; Hashtable options = JavaCore . getOptions ( ) ; options . put ( JavaCore . CORE_JAVA_BUILD_INVALID_CLASSPATH , JavaCore . IGNORE ) ; JavaCore . setOptions ( options ) ; env . removeProject ( project1Path ) ; incrementalBuild ( ) ; expectingOnlyProblemsFor ( project2Path ) ; expectingOnlySpecificProblemFor ( project2Path , new Problem ( "<STR_LIT>" , "<STR_LIT>" , project2Path , - <NUM_LIT:1> , - <NUM_LIT:1> , CategorizedProblem . CAT_BUILDPATH , IMarker . SEVERITY_ERROR ) ) ; project1Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project1Path , Util . getJavaClassLibs ( ) ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; options . put ( JavaCore . CORE_JAVA_BUILD_INVALID_CLASSPATH , JavaCore . ABORT ) ; JavaCore . setOptions ( options ) ; } public void testMissingOptionalProject ( ) throws JavaModelException { IPath project1Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project1Path , Util . getJavaClassLibs ( ) ) ; IPath project2Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project2Path , Util . getJavaClassLibs ( ) ) ; env . addRequiredProject ( project2Path , project1Path , true ) ; fullBuild ( ) ; expectingNoProblems ( ) ; env . removeProject ( project1Path ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; project1Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project1Path , Util . getJavaClassLibs ( ) ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; Hashtable options = JavaCore . getOptions ( ) ; options . put ( JavaCore . CORE_JAVA_BUILD_INVALID_CLASSPATH , JavaCore . IGNORE ) ; JavaCore . setOptions ( options ) ; env . removeProject ( project1Path ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; project1Path = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( project1Path , Util . getJavaClassLibs ( ) ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; options . put ( JavaCore . CORE_JAVA_BUILD_INVALID_CLASSPATH , JavaCore . ABORT ) ; JavaCore . setOptions ( options ) ; } public void test0100 ( ) throws JavaModelException { if ( ! AbstractCompilerTest . isJRELevel ( AbstractCompilerTest . F_1_5 ) ) { return ; } IPath projectPath = env . addProject ( "<STR_LIT>" , "<STR_LIT>" ) ; IPath defaultPackagePath = env . addPackage ( projectPath , "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; env . addClass ( defaultPackagePath , "<STR_LIT:X>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; env . addClass ( defaultPackagePath , "<STR_LIT:Y>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT:}>" ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; } public void testMissingOutputFolder ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; IPath bin = env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; fullBuild ( ) ; expectingNoProblems ( ) ; env . removeFolder ( bin ) ; incrementalBuild ( ) ; expectingNoProblems ( ) ; expectingPresenceOf ( bin ) ; if ( ! env . getProject ( projectPath ) . getFolder ( "<STR_LIT>" ) . isDerived ( ) ) fail ( "<STR_LIT>" ) ; } } </s>
<s> package org . eclipse . jdt . core . tests . builder ; import junit . framework . * ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . tests . util . Util ; public class ExecutionTests extends BuilderTests { public ExecutionTests ( String name ) { super ( name ) ; } public static Test suite ( ) { return buildTestSuite ( ExecutionTests . class ) ; } public void testSuccess ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingNoProblems ( ) ; executeClass ( projectPath , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; } public void testFailure ( ) throws JavaModelException { IPath projectPath = env . addProject ( "<STR_LIT>" ) ; env . addExternalJars ( projectPath , Util . getJavaClassLibs ( ) ) ; fullBuild ( projectPath ) ; env . removePackageFragmentRoot ( projectPath , "<STR_LIT>" ) ; IPath root = env . addPackageFragmentRoot ( projectPath , "<STR_LIT:src>" ) ; env . setOutputFolder ( projectPath , "<STR_LIT>" ) ; IPath helloPath = env . addClass ( root , "<STR_LIT>" , "<STR_LIT:Hello>" , "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) ; incrementalBuild ( projectPath ) ; expectingOnlyProblemsFor ( helloPath ) ; executeClass ( projectPath , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) ; } } </s>