SayMing / jsyntaxpane

Automatically exported from code.google.com/p/jsyntaxpane
0 stars 0 forks source link

Does Reflection Dialog support user created classes? #69

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have been playing around with the reflection dialog, but I cannot get it
to display any information for my own classes in my application.  I thought
if I typed in the name of the class it would find it and display its
information, but it doesn't.  I even tried pre-pending the class name with
the package but that didn't help.  Should this approach work?  If so maybe
I could get a hint as to what I could be doing wrong?  Thanks!

Original issue reported on code.google.com by chad.dor...@gmail.com on 9 Mar 2009 at 7:53

GoogleCodeExporter commented 9 years ago
The full name of the class should work.  Make sure the case is correct.
I have tried it with jsyntaxpane classes and it works.  Just make sure the 
compiled
classes are available to the editor and in the classpath.

Original comment by ayman.al...@gmail.com on 9 Mar 2009 at 2:20

GoogleCodeExporter commented 9 years ago
I've tried several classes with full name and got no results.  My app is built 
on top
of the Netbeans Platform so maybe it needs a little something special to be
compatible.  I will try making a simple app without building on top of the 
Netbeans
Platform and make sure I can get that to work.  As a side note I did try the 
full
class name to some of the built-in Java classes such as javax.swing.JList and it
worked great.

Original comment by chad.dor...@gmail.com on 9 Mar 2009 at 3:56

GoogleCodeExporter commented 9 years ago
My problem was due to Netbeans Platform module dependencies.  When using the
platform, module A can only reference classes within module B when module A has
declared a dependency on module B.  So, declaring that my jsyntaxpane module 
depends
on another module gave me access to that other module's classes.

The only problem here is that Netbeans modules cannot declare dual dependencies,
(Module B cannot declare a dependency on module A if A has a dependency on B
already).  This means that the jsyntaxpane module can not ever use reflection on
classes in a module that makes use of the jsyntaxpane module.

Original comment by chad.dor...@gmail.com on 9 Mar 2009 at 5:20

GoogleCodeExporter commented 9 years ago
In your case, is Module B's classloader (or it's classpath) available to Module 
A's
jsyntaxpane?  If it is, then maybe we could pass that, to Reflection Utils to 
allow
to see Module B's classes.

If not, then I have no other ideas.

Original comment by ayman.al...@gmail.com on 10 Mar 2009 at 5:10

GoogleCodeExporter commented 9 years ago
I believe I could get a reference to the ClassLoader and pass it to the 
jsyntaxpane's
reflection utils if that was possible.  

Original comment by chad.dor...@gmail.com on 10 Mar 2009 at 8:13

GoogleCodeExporter commented 9 years ago
Doesn't seem like that will help though.  I use the Class.forName to get a 
reference
to the Class.  From there, I just use reflection to get members and methods.  
Not
sure how having a ClassLoader will provide any help.
Any ideas?

Original comment by ayman.al...@gmail.com on 16 Mar 2009 at 10:48

GoogleCodeExporter commented 9 years ago
Hi, I wanted the same functionality, and I got this to work by adding my 
package in 
ReflectUtils (  DEFAULT_PACKAGES.add("myPackage");  ) and copying the package 
with 
my generated .class directly to jsyntaxpane\target\classes. I also added my 
class 
name to the combo in ReflectCompletionDialog. It may not be an elegant 
solution, but 
it works perfectly!

My only trouble now is that the reflection dialog will appear empty if I type 
cap+F1 
right after typing my variable name: for example, if I write this in the java 
editor:
myClass var = new myClass();
var.
and I want to view myClass methods now to choose from, I can't: I need to place 
the 
caret after a blank to view my methods.

Also, it would be beautiful to have javadoc for the displayed methods. Any 
thoughts 
on that?

Original comment by carolgpa...@yahoo.es on 26 Mar 2009 at 9:35

GoogleCodeExporter commented 9 years ago
The Reflect edit should also work without adding your package to 
DEFAULT_PACKAGES,
but then you need to specify the full class name (myPackage.MyClass).  You also 
do
not need to put your classes under jsyntaxpane folder.  As long as they are on 
the
classpath, they should be found.  Otherwise there is a bug.

The reflection dialog is actually pretty dumb.  It does not what class it needs 
to
display (you need to select / or type the class in the combo below).  

The reason is that it is actually very complicated to know or guess the type of 
a
variable at the cursor without parsing (not lexing) whole file into some kind of
syntax tree.  

And then comes the issue of having un-compiled classes which you want to perform
auto-completion on.  That's going into the IDE territory for me :-).  Not 
something i
have the time for right now.  But i did have initial looks at some other 
libraries,
including JavaParser, which seems like a good fit.  Either way, having proper
completions will at least double the size, and complexity of the project.

As for JavaDoc, I did make some initial work, but got dragged into other stuff, 
and
properly locating the JavaDoc window was not that easy.  Also, without proper
completions as above, JavaDoc did not seem useful, to me at least.  

Please Create an Enhancement request for JavaDoc, and if there is enough 
requests,
I'll work on next. 

Original comment by ayman.al...@gmail.com on 27 Mar 2009 at 3:53

GoogleCodeExporter commented 9 years ago
I just tried specifying the full class name and it works perfectly, but since I 
only 
need support for 3 classes, it's much more convenient for me to add them 
directly to 
DEFAULT_PACKAGES. Since my project is so simple, the reflection dialog works 
great 
for me, even if I have to select the class myself: there's no real need for 
completion.
Also, I've never worked with Maven before, and I get quite confused when trying 
to 
set the project's properties: is there any way I can edit the classpath? Where 
do I 
need to put my classes?

Original comment by carolgpa...@yahoo.es on 30 Mar 2009 at 11:59

GoogleCodeExporter commented 9 years ago
Ok, I must have had some wrong settings, because suddenly my project started 
working 
without having to copy my classes to the jsyntaxpane folder! Problem solved, 
thanks 
for your support! :)

Original comment by carolgpa...@yahoo.es on 30 Mar 2009 at 12:18

GoogleCodeExporter commented 9 years ago

Original comment by ayman.al...@gmail.com on 30 Mar 2009 at 1:40