diff --git a/pdex/Todo, GSoC 2013.txt b/pdex/Todo, GSoC 2013.txt index 54ca3a00b..10415a8ec 100644 --- a/pdex/Todo, GSoC 2013.txt +++ b/pdex/Todo, GSoC 2013.txt @@ -15,6 +15,7 @@ The big stuff: - Making very good progress here. The elegance of recurion - Hats off! - Many of the cases seem to have been covered, and I'm achieving more and more code unification as I'm working through the problem step by step - Looks almost complete now, nearly all cases covered(July 13th) +* After popup appears, the popup location is fixed for the current line. So if editor window is moved while staying in the same line, popup appears at the prev location. Need to ensure editor is still at last know location * Scope handling? Static/non static scope? * Disable completions on comment line * Trie implementation would be lower priority, "premature optimisation is pure evil". Get all features of CC working good enough and then plan this. diff --git a/pdex/src/processing/mode/experimental/ASTGenerator.java b/pdex/src/processing/mode/experimental/ASTGenerator.java index 9ba2d3e53..d20b6fc1a 100644 --- a/pdex/src/processing/mode/experimental/ASTGenerator.java +++ b/pdex/src/processing/mode/experimental/ASTGenerator.java @@ -153,7 +153,7 @@ public class ASTGenerator { this.editor = ecs.getEditor(); setupGUI(); //addCompletionPopupListner(); - addListeners(); + addListeners(); loadJavaDoc(); } protected void setupGUI(){ @@ -220,18 +220,20 @@ public class ASTGenerator { // sp3.setViewportView(tableAuto); // frameAutoComp.add(sp3); -// jdocWindow = new JFrame(); -// jdocWindow.setTitle("P5 InstaHelp"); +// frmJavaDoc = new JFrame(); +// frmJavaDoc.setTitle("P5 InstaHelp"); // //jdocWindow.setUndecorated(true); -// jdocWindow.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); +// frmJavaDoc.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); // javadocPane = new JEditorPane(); // javadocPane.setContentType("text/html"); +// javadocPane.setText(" "); // javadocPane.setEditable(false); // scrollPane = new JScrollPane(); // scrollPane.setViewportView(javadocPane); -// jdocWindow.add(scrollPane); -// jdocMap = new TreeMap(); -//// loadJars(); +// frmJavaDoc.add(scrollPane); + //frmJavaDoc.setUndecorated(true); + + } protected DefaultMutableTreeNode buildAST(String source, CompilationUnit cu) { @@ -282,17 +284,16 @@ public class ASTGenerator { // frameAutoComp.setVisible(true); // // } -// if (!jdocWindow.isVisible()) { +// if (!frmJavaDoc.isVisible()) { // long t = System.currentTimeMillis(); -// loadJars(); // loadJavaDoc(); // log("Time taken: " // + (System.currentTimeMillis() - t)); -// jdocWindow.setBounds(new Rectangle(errorCheckerService.getEditor() +// frmJavaDoc.setBounds(new Rectangle(errorCheckerService.getEditor() // .getX() + errorCheckerService.getEditor().getWidth(), // errorCheckerService.getEditor() // .getY(), 450, 600)); -// jdocWindow.setVisible(true); +// frmJavaDoc.setVisible(true); // } } } @@ -311,7 +312,7 @@ public class ASTGenerator { */ protected ClassPath classPath; - protected JFrame jdocWindow; + //protected JFrame frmJavaDoc; /** * Loads up .jar files and classes defined in it for completion lookup @@ -398,7 +399,7 @@ public class ASTGenerator { protected TreeMap jdocMap; protected void loadJavaDoc() { - + jdocMap = new TreeMap(); // presently loading only p5 reference for PApplet Thread t = new Thread(new Runnable() { @@ -763,7 +764,7 @@ public class ASTGenerator { newWord = newWord.toLowerCase(); for (CompletionCandidate comp : candidates) { if(comp.toString().toLowerCase().startsWith(newWord)){ - log("Adding " + comp); + // log("Adding " + comp); newCandidate.add(comp); } } @@ -1309,37 +1310,44 @@ public class ASTGenerator { public void updateJavaDoc(final CompletionCandidate candidate) { //TODO: Work on this later. - return; - /*String methodmatch = candidate.toString(); + return; + /* String methodmatch = candidate.toString(); if (methodmatch.indexOf('(') != -1) { methodmatch = methodmatch.substring(0, methodmatch.indexOf('(')); } //log("jdoc match " + methodmatch); + String temp = " "; for (final String key : jdocMap.keySet()) { if (key.startsWith(methodmatch) && key.length() > 3) { log("Matched jdoc " + key); - - //visitRecur((ASTNode) compilationUnit.types().get(0), codeTree); - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - - log("Class: " + candidate.getDefiningClass()); - if (candidate.getDefiningClass().equals("processing.core.PApplet")) { - javadocPane.setText(jdocMap.get(key)); - //jdocWindow.setVisible(true); - //editor.textArea().requestFocus() - } else - javadocPane.setText(""); - javadocPane.setCaretPosition(0); + if (candidate.getWrappedObject() != null) { + String definingClass = ""; + if (candidate.getWrappedObject() instanceof Field) + definingClass = ((Field) candidate.getWrappedObject()) + .getDeclaringClass().getName(); + else if (candidate.getWrappedObject() instanceof Method) + definingClass = ((Method) candidate.getWrappedObject()) + .getDeclaringClass().getName(); + if (definingClass.equals("processing.core.PApplet")) { + temp = (jdocMap.get(key)); + break; } - }); - break; + } } - }*/ - //jdocWindow.setVisible(false); - + } + + final String jdocString = temp; + SwingUtilities.invokeLater(new Runnable() { + public void run() { + javadocPane.setText(jdocString); + scrollPane.getVerticalScrollBar().setValue(0); + //frmJavaDoc.setVisible(!jdocString.equals(" ")); + editor.toFront(); + editor.ta.requestFocus(); + } + }); +*/ } @SuppressWarnings("unchecked") @@ -3271,7 +3279,7 @@ public class ASTGenerator { } public void jdocWindowVisible(boolean visible) { - jdocWindow.setVisible(visible); + // frmJavaDoc.setVisible(visible); } public static String readFile(String path) { diff --git a/pdex/src/processing/mode/experimental/CompletionCandidate.java b/pdex/src/processing/mode/experimental/CompletionCandidate.java index bc2973785..ef29d5963 100644 --- a/pdex/src/processing/mode/experimental/CompletionCandidate.java +++ b/pdex/src/processing/mode/experimental/CompletionCandidate.java @@ -18,6 +18,8 @@ public class CompletionCandidate implements Comparable{ private String label; // the toString value private String completionString; + + private Object wrappedObject; private int type; @@ -48,8 +50,13 @@ public class CompletionCandidate implements Comparable{ this.label = label.toString(); this.completionString = cstr.toString(); type = PREDEF_METHOD; + wrappedObject = method; } + public Object getWrappedObject() { + return wrappedObject; + } + public CompletionCandidate(SingleVariableDeclaration svd) { completionString = svd.getName().toString(); elementName = svd.getName().toString(); @@ -110,6 +117,7 @@ public class CompletionCandidate implements Comparable{ label = f.getName() + " : " + f.getType().getSimpleName() + " - " + f.getDeclaringClass().getSimpleName(); completionString = elementName; + wrappedObject = f; } public CompletionCandidate(String name, String labelStr, String completionStr, int type) {