package cssanalisys; import com.sun.javafx.css.StyleableProperty; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.List; public class CSS_propertiesFinder { static String cssrefContent; public static void main(String[] args) { File folder1 = new File("C://work//repos//all_rt"); File cssref = new File("C://work//builds//2.1.0b20x86//javafx-sdk2.1.0//docs//api//javafx//scene//doc-files//cssref.html"); try { BufferedReader cssrefIn = new BufferedReader(new FileReader(cssref)); String str; StringBuilder cssSB = new StringBuilder(); while ((str = cssrefIn.readLine()) != null) { cssSB.append(str); } cssrefContent = cssSB.toString(); } catch (IOException e) { System.out.println("EXCEPTION : "); e.printStackTrace(); } recursiveSearch(folder1); } private static void workWithTargetFile(File file) throws MalformedURLException, IllegalAccessException, InstantiationException, IllegalArgumentException, InvocationTargetException { if (file.getAbsolutePath().contains("\\src\\")) { URL[] addr = new URL[1]; addr[0] = file.toURL(); ClassLoader loader = new URLClassLoader(addr); String className = file.getAbsolutePath().substring(file.getAbsolutePath().indexOf("src") + 4, file.getAbsolutePath().length() - 5).replace('\\', '.'); try { Class someClass = loader.loadClass(className); //System.out.println("Class analyzed : " + className); Method[] methodsArray = someClass.getDeclaredMethods(); for (Method m : methodsArray) { //System.out.println("Method : " + m); if (m.getReturnType().equals(List.class) && m.getName().equalsIgnoreCase("impl_CSS_STYLEABLES") && Modifier.isStatic(m.getModifiers())) { //System.out.println("Found one needed method : " + m); for (StyleableProperty styleable : (List) m.invoke(null)) { String propertyName = styleable.getProperty(); if (!cssrefContent.contains(propertyName)) { System.out.println("Property description was not found in CSSref : " + propertyName + " used in class " + className); } } } } } catch (ClassNotFoundException ex) { //System.out.println("Class not found : " + className); } } } private static void parseTargetDirectory(File directory) { if (directory.isDirectory()) { for (File subFile : directory.listFiles()) { if (subFile.isFile() && subFile.getName().endsWith(".java")) { try { workWithTargetFile(subFile); } catch (Exception e) { System.out.println("Exception : " + e); } } else { parseTargetDirectory(subFile); } } } } private static void recursiveSearch(File directory) { if (directory.isDirectory()) { //System.out.println(directory.getPath()); if (directory.getPath().endsWith("javafx\\scene")) { parseTargetDirectory(directory); } for (File subFile : directory.listFiles()) { recursiveSearch(subFile); } } } }