1 19 package org.netbeans.test.refactoring.experimental; 20 21 import java.io.File ; 22 import org.netbeans.modules.javacore.internalapi.JavaMetamodel; 23 import org.netbeans.jmi.javamodel.JavaClass; 24 import org.netbeans.jmi.javamodel.UnresolvedClass; 25 import org.openide.filesystems.FileStateInvalidException; 26 27 public class Utility { 28 29 public static File getFile(File dataDir, String fileName) throws FileStateInvalidException { 30 String result = dataDir.getAbsolutePath() + "/projects/default/src/" + fileName; 31 System.out.println("looking for file: " + result); 32 return new File (result); 33 } 34 35 public static JavaClass findClass(String s) { 36 JavaClass result; 37 int i = 20; 38 do { 39 result = (JavaClass) JavaMetamodel.getManager().getDefaultExtent().getType().resolve(s); 40 if (result instanceof UnresolvedClass) { 41 try { 42 Thread.sleep(1000); 43 } catch (InterruptedException e) { 44 e.printStackTrace(); 45 return null; 46 } 47 } 48 i--; 49 } while ((result instanceof UnresolvedClass) && i > 0); 50 if (result instanceof UnresolvedClass) { 51 throw new IllegalStateException ("Class " + s + " not found."); 52 } 53 return result; 54 } 55 } 56 | Popular Tags |