[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] [how to create an .aj file]

Alex Vasc <altvex@xxxxxxxxx> wrote on 10/06/2005 17:48:21:
> Hello everybody,
>   Do you know how can I create an empty .aj file? In JDT, I used a
> code like this:
> --------------------
> public ICompilationUnit generateEmptyClass(String newClassName,
>    IPackageFragment iPackageFragment) throws JavaModelException,
>    BadLocationException {
>    ICompilationUnit iCU = iPackageFragment.createCompilationUnit(
>       newClassName + ".java", "", true, null);
>    return iCU;
> }  
> ----------------------
>   Afterwards, I would like to open the new file in the Editor by the
> source code. Any thoughts?

Hi Alex,

Try looking at the code for the New Aspect wizard in AJDT, as it creates a .aj file and then opens it in the editor. The code is in NewAspectCreationWizard.java - look at the finish() method. It just does a workspace operation to create the file. You can then get an ICompilationUnit from the file with AJCompilationUnitManager.getAJCompilationUnit(file);

Note that the AJDT source code is now under "AJDT_src" in CVS as per my earlier note to ajdt-dev.