From: Thiago A. <thi...@gm...> - 2006-04-24 17:31:37
|
FPers, You may have noticed I have been working on code assist support for EclipseFP. There has been sometime I don't touch anything (mostly because of a new project called Motiro, that will hopefully be used on developing EclipseFP in the future), but I would like to restart things in a near future. So, I would like to know from You any ideas for starting this thing. I know we'll probably evolve to a full-blown language model like JDT's, but what I am really looking right now is somewhere to start. Some approach that would let us experiment while being extensible. Any ideas are welcome, maybe we will need some good Eclipse knowledge here. There is already some simple code assist support built in the latest (integration) versions (screen shot at http://eclipsefp.sourceforge.net/images/first-content-assist.png), but it considers function declarations on the current file only. There is no support for importing modules, for example. I am sttruggling particularly with the ITextViewer and IDocument types. Eclipse's code assistants only receive a reference to a ITextViewer, from which you can get the file contents, but I still don't know how to link the current file with the other project files (at least not without messing with the filesystem). Does anyone know any higher-level solution? Can anyone point out how JDT's (or any other plugin's) code assistant works? I am trying to get some ideas here before I "use the source, Luke". Looking forward to hear from you, Thiago Arrais |
From: Leif F. <lfr...@in...> - 2006-04-25 08:57:15
|
Hi Thiago, > I am sttruggling particularly with the ITextViewer and IDocument > types. Eclipse's code assistants only receive a reference to a > ITextViewer, from which you can get the file contents, but I still > don't know how to link the current file with the other project files > (at least not without messing with the filesystem). Does anyone know > any higher-level solution? Can anyone point out how JDT's (or any > other plugin's) code assistant works? I am trying to get some ideas > here before I "use the source, Luke". > Here are some brainstorming items: ITextViewer and IDocument are part of the language-neutral framework. Accessing the Java Model in JDT works (roughly) as follows: There is a JavaCore class that provides static helping methods for getting an IJavaProject for a file or project. The IJavaProject is not really a resource, but a kind of (Java-related) metadata for a project. Model elements (i.e. ICompilationUnit, IClass etc.) can be created using the create() methods in JavaCore. They are just proxies, which means that operating with them is fast. There is very good background information about how the Java Model works in 'Contributing to Eclipse', by Erich Gamma and Kent Beck, in the third part of the book. So, what you would do to access other files in the workspace, would be roughly: - get the editor input, cast to IFIleEditorInput, get the IFile - get the IJavaElement for the IFile using JavaCore.create( IFile ) - that you can cast (probably, I'm just writing from faint memories at the moment :-) to ICompilationUnit - the ICompilationUnit you can use to query IField, IMethod etc. things from the model, or you can request a complete AST of the source file In practice, though, there will probably be an index over the complete model, so that querying a certain function declaration doesn't mean you have to touch all the files every time. The Java model contains of course not only the IFIelds, IMethods etc. from the sources in the workspace, but also everything from the class files in attached libs (jar files on the build path). Ciao, Leif > Looking forward to hear from you, > > Thiago Arrais > > > ------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=k&kid0709&bid&3057&dat1642 > _______________________________________________ > eclipsefp-develop mailing list > ecl...@li... > https://lists.sourceforge.net/lists/listinfo/eclipsefp-develop > |
From: Thiago A. <thi...@gm...> - 2006-04-25 12:43:52
|
Leif, Some questions below. On 4/25/06, Leif Frenzel <lfr...@in...> wrote: > There is very good background information about how the Java Model works > in 'Contributing to Eclipse', by Erich Gamma and Kent Beck, in the third > part of the book. I will definitely take a look at that. Actually, there has been some time it is on my to read list. Thought it was outdated, but have been pointed to it so much times that I think it is worth the read. > So, what you would do to access other files in the workspace, would be > roughly: > > - get the editor input, cast to IFIleEditorInput, get the IFile > - get the IJavaElement for the IFile using JavaCore.create( IFile ) > - that you can cast (probably, I'm just writing from faint memories at > the moment :-) to ICompilationUnit > - the ICompilationUnit you can use to query IField, IMethod etc. things > from the model, or you can request a complete AST of the source file Questions: We need to add something like that support on EclipseFP, right? I think there is already some work done on that direction, and I will certainly take a look at the code, but is there any framework support for this on Eclipse? What about context-sensitive information? I imagine JDT has an indexed internal model that it keeps in sync with the resources (I am guessing that based on the the extremely fast performance for things like Java Search). Does anyone know how to query that model? For instance, given a method name prefix (that will map almost directly to our function names) how do I know of all complete methods that are available (or can be easily made available, by adding an import statement or whatever) on the current context? Cheers, Thiago Arrais |
From: Leif F. <lfr...@in...> - 2006-04-25 12:56:15
|
Thiago Arrais wrote: > Leif, > > Some questions below. > > On 4/25/06, Leif Frenzel <lfr...@in...> wrote: > >> There is very good background information about how the Java Model works >> in 'Contributing to Eclipse', by Erich Gamma and Kent Beck, in the third >> part of the book. >> > > I will definitely take a look at that. Actually, there has been some > time it is on my to read list. Thought it was outdated, but have been > pointed to it so much times that I think it is worth the read. > That's true, many of the passages are no longer completely correct for Eclipse 3 and higher. The third part is more a general discussion of the Design patterns that were put to work in the different parts. That still applies and is definitely worth the read :-) > >> So, what you would do to access other files in the workspace, would be >> roughly: >> >> - get the editor input, cast to IFIleEditorInput, get the IFile >> - get the IJavaElement for the IFile using JavaCore.create( IFile ) >> - that you can cast (probably, I'm just writing from faint memories at >> the moment :-) to ICompilationUnit >> - the ICompilationUnit you can use to query IField, IMethod etc. things >> from the model, or you can request a complete AST of the source file >> > > Questions: > > We need to add something like that support on EclipseFP, right? I > think there is already some work done on that direction, and I will > certainly take a look at the code, but is there any framework support > for this on Eclipse? > Not really. This is something that was discussed a while ago, but it came to nothing. What is already in EclipseFP is mostly just the interfaces for the language model, but there is no such thing as a proxy mechanism there, which is probably tricky ... > What about context-sensitive information? I imagine JDT has an indexed > internal model that it keeps in sync with the resources (I am guessing > that based on the the extremely fast performance for things like Java > Search). Yes, afaik that's exactly how it works. > Does anyone know how to query that model? For instance, given > a method name prefix (that will map almost directly to our function > names) how do I know of all complete methods that are available (or > can be easily made available, by adding an import statement or > whatever) on the current context? > Hm, I have never looked that deeply into JDT in particular. I guess it would be a good approach to have a look at one of the simpler refactoring implementations, because what there is needed is exactly such queries. Btw: my article about the language toolkit is now available in English too, thanks to the Eclipse people :-) It can be found here: http://www.eclipse.org/articles/Article-LTK/ltk.html Ciao, Leif > Cheers, > > Thiago Arrais > > > ------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=k&kid0709&bid&3057&dat1642 > _______________________________________________ > eclipsefp-develop mailing list > ecl...@li... > https://lists.sourceforge.net/lists/listinfo/eclipsefp-develop > |