diff --git a/pdex/src/processing/mode/experimental/ASTGenerator.java b/pdex/src/processing/mode/experimental/ASTGenerator.java index 1db31a42c..5b887b35b 100644 --- a/pdex/src/processing/mode/experimental/ASTGenerator.java +++ b/pdex/src/processing/mode/experimental/ASTGenerator.java @@ -254,7 +254,7 @@ public class ASTGenerator { StringBuffer tehPath = new StringBuffer( System .getProperty("java.class.path")); - tehPath.append(+File.pathSeparatorChar + System.getProperty("java.home") + tehPath.append(File.pathSeparatorChar + System.getProperty("java.home") + "/lib/rt.jar" + File.pathSeparatorChar); if (errorCheckerService.classpathJars != null) { for (URL jarPath : errorCheckerService.classpathJars) { @@ -271,18 +271,18 @@ public class ASTGenerator { } classPath = factory.createFromPath(tehPath.toString()); - for (String packageName : classPath.listPackages("")) { - System.out.println(packageName); - } - RegExpResourceFilter regExpResourceFilter = new RegExpResourceFilter( - ".*", - "ArrayList.class"); - String[] resources = classPath.findResources("", regExpResourceFilter); - for (String className : resources) { - System.out.println("-> " + className); - } +// for (String packageName : classPath.listPackages("")) { +// System.out.println(packageName); +// } +// RegExpResourceFilter regExpResourceFilter = new RegExpResourceFilter( +// ".*", +// "ArrayList.class"); +// String[] resources = classPath.findResources("", regExpResourceFilter); +// for (String className : resources) { +// System.out.println("-> " + className); +// } + System.out.println("jars loaded."); } catch (Exception e) { - // TODO Auto-generated catch block e.printStackTrace(); } @@ -297,7 +297,7 @@ public class ASTGenerator { @Override public void run() { - JavadocHelper.loadJavaDoc(jdocMap); + JavadocHelper.loadJavaDoc(jdocMap,editor.mode().getReferenceFolder()); } }); t.start(); @@ -667,6 +667,7 @@ public class ASTGenerator { } } else if (word.length() - word2.length() == 1) { + System.out.println(word +" w2 " + word2); // int dC = 0; // for (int i = 0; i < word.length(); i++) { // if(word.charAt(i) == '.') @@ -677,6 +678,13 @@ public class ASTGenerator { candidates = getMembersForType(word2, "", true, true); // } } + else{ + System.out.println("Some members of " + word2); + int x = word2.indexOf('.'); + if(x != -1){ + candidates = getMembersForType(word2.substring(0, x), word2.substring(x+1), false, true); + } + } } diff --git a/pdex/src/processing/mode/experimental/CompletionCandidate.java b/pdex/src/processing/mode/experimental/CompletionCandidate.java index ebf8bddf3..5f3f0d740 100644 --- a/pdex/src/processing/mode/experimental/CompletionCandidate.java +++ b/pdex/src/processing/mode/experimental/CompletionCandidate.java @@ -10,75 +10,93 @@ import org.eclipse.jdt.core.dom.MethodDeclaration; public class CompletionCandidate { private String definingClass; + private String elementName; // + private String label; // the toString value + private String completionString; + private int type; - public static final int METHOD = 0, FIELD = 1, LOCAL_VAR = 3; - - public CompletionCandidate(String name, String className, String label, int TYPE){ + + public static final int METHOD = 0, FIELD = 1, LOCAL_VAR = 3; + + public CompletionCandidate(String name, String className, String label, + int TYPE) { definingClass = className; elementName = name; - if(label.length() > 0) + if (label.length() > 0) this.label = label; else this.label = name; this.type = TYPE; - if(type == METHOD){ + if (type == METHOD) { this.label += "()"; } - + completionString = this.label; } - - public CompletionCandidate(Method method){ + + public CompletionCandidate(Method method) { definingClass = method.getDeclaringClass().getName(); elementName = method.getName(); type = METHOD; StringBuffer label = new StringBuffer(method.getName() + "("); + StringBuffer cstr = new StringBuffer(method.getName() + "("); for (int i = 0; i < method.getParameterTypes().length; i++) { label.append(method.getParameterTypes()[i].getSimpleName()); - if (i < method.getParameterTypes().length - 1) + if (i < method.getParameterTypes().length - 1) { label.append(","); + cstr.append(","); + } } label.append(")"); + cstr.append(")"); this.label = label.toString(); + this.completionString = cstr.toString(); } - - public CompletionCandidate(MethodDeclaration method){ + + public CompletionCandidate(MethodDeclaration method) { definingClass = ""; elementName = method.getName().toString(); type = METHOD; List params = (List) method .getStructuralProperty(MethodDeclaration.PARAMETERS_PROPERTY); StringBuffer label = new StringBuffer(elementName + "("); + StringBuffer cstr = new StringBuffer(method.getName() + "("); for (int i = 0; i < params.size(); i++) { label.append(params.get(i).toString()); - if (i < params.size() - 1) + if (i < params.size() - 1){ label.append(","); + cstr.append(","); + } } label.append(")"); + cstr.append(")"); this.label = label.toString(); + this.completionString = cstr.toString(); } - - - public CompletionCandidate(Field f){ + + public CompletionCandidate(Field f) { definingClass = f.getDeclaringClass().getName(); elementName = f.getName(); type = FIELD; label = f.getName(); + completionString = elementName; } - - public CompletionCandidate(String name, String className){ + + public CompletionCandidate(String name, String className) { definingClass = className; elementName = name; label = name; + completionString = name; } - - public CompletionCandidate(String name){ + + public CompletionCandidate(String name) { definingClass = ""; elementName = name; label = name; + completionString = name; } public String getDefiningClass() { @@ -88,16 +106,16 @@ public class CompletionCandidate { public String getElementName() { return elementName; } - - public String getCompletionString(){ + + public String getCompletionString() { return completionString; } - - public String toString(){ + + public String toString() { return label; } - - public int getType(){ + + public int getType() { return type; } diff --git a/pdex/src/processing/mode/experimental/CompletionPanel.java b/pdex/src/processing/mode/experimental/CompletionPanel.java index 6d5eeb130..3e0f7678d 100644 --- a/pdex/src/processing/mode/experimental/CompletionPanel.java +++ b/pdex/src/processing/mode/experimental/CompletionPanel.java @@ -81,7 +81,7 @@ public class CompletionPanel { if (list.getSelectedValue() != null) { try { final String selectedSuggestion = ((CompletionCandidate) list - .getSelectedValue()).toString().substring(subWord.length()); + .getSelectedValue()).getCompletionString().substring(subWord.length()); textarea.getDocument().insertString(insertionPosition, selectedSuggestion, null); textarea.setCaretPosition(insertionPosition diff --git a/pdex/src/processing/mode/experimental/ErrorCheckerService.java b/pdex/src/processing/mode/experimental/ErrorCheckerService.java index fbdfbb953..cd1c181d4 100644 --- a/pdex/src/processing/mode/experimental/ErrorCheckerService.java +++ b/pdex/src/processing/mode/experimental/ErrorCheckerService.java @@ -182,6 +182,7 @@ public class ErrorCheckerService implements Runnable{ PdePreprocessor pdePrepoc = new PdePreprocessor(null); defaultImportsOffset = pdePrepoc.getCoreImports().length + pdePrepoc.getDefaultImports().length + 1; + astGenerator = new ASTGenerator(this); } /** @@ -256,7 +257,7 @@ public class ErrorCheckerService implements Runnable{ } } - ASTGenerator astGenerator = new ASTGenerator(this); + protected ASTGenerator astGenerator; AtomicInteger textModified = new AtomicInteger(); private boolean checkCode() { System.out.println("checkCode() " + textModified.get() ); diff --git a/pdex/src/processing/mode/experimental/JavadocHelper.java b/pdex/src/processing/mode/experimental/JavadocHelper.java index 7f59da5ab..7cc582072 100644 --- a/pdex/src/processing/mode/experimental/JavadocHelper.java +++ b/pdex/src/processing/mode/experimental/JavadocHelper.java @@ -12,13 +12,17 @@ import org.jsoup.select.Elements; public class JavadocHelper { - public static void loadJavaDoc(TreeMap jdocMap){ + public static void loadJavaDoc(TreeMap jdocMap, File p5Ref){ Document doc; //Pattern pat = Pattern.compile("\\w+"); try { - File p5Ref = new File( - "/home/quarkninja/Workspaces/processing-workspace/processing/build/linux/work/modes/java/reference"); + if (p5Ref == null) { + System.out.println("P5 Ref location null"); + p5Ref = new File( + "/home/quarkninja/Workspaces/processing-workspace/processing/build/linux/work/modes/java/reference"); + } + FileFilter fileFilter = new FileFilter() { public boolean accept(File file) { if(!file.getName().endsWith("_.html")) @@ -52,7 +56,7 @@ public class JavadocHelper { } jdocMap.put(methodName, msg); } - + System.out.println("JDoc loaded "+jdocMap.size()); /* File javaDocFile = new File( "/home/quarkninja/Workspaces/processing-workspace/processing/build/javadoc/core/processing/core/PApplet.html"); //SimpleOpenNI.SimpleOpenNI @@ -105,7 +109,7 @@ public class JavadocHelper { //System.out.println("Name " + parts.get(i)); jdocMap.put(parts.get(i), msg); } - System.out.println("JDoc loaded"); + // for (String key : jdocMap.keySet()) { // System.out.println("Method: " + key); // System.out.println("Method: " + jdocMap.get(key));