Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Extends JDT to support @java
Extends JDT to support @java [message #256755] Fri, 03 October 2008 18:52 Go to next message
Eclipse UserFriend
Originally posted by: rief.the.dreamer.gmail.com

Hi developers,
I'm a diploma student and for my final project I want to develop an
eclipse plugin for the @java language

http://homes.dico.unimi.it/~cazzola/atjava.html

developed in my lab. that extends the annotation model of Java.

Since the language I have to support is strictly related to Java I'd
like to "import" the JDT plugin and extend it; in this way any bug fix
or extension you will do on the JDT will be immediately available also
in my plugin.

Is it this possible? If yes, how? At the moment I can copy the JDT
sources and extend them but such an approach sounds quite silly to me.

Moreover could you address me to a tutorial/documentation about
extending the JDT plugin since at the moment I'm still unacquainted with
this kind of development.

Thanks,

Mario Pastorelli
Re: Extends JDT to support @java [message #256773 is a reply to message #256755] Tue, 07 October 2008 05:36 Go to previous messageGo to next message
Eclipse UserFriend
> Since the language I have to support is strictly related to Java I'd
> like to "import" the JDT plugin and extend it; in this way any bug fix
> or extension you will do on the JDT will be immediately available also
> in my plugin.

You should have a look at the implementation for annotation processing
(JSR-269) which is hooking into JDT via the compiler participant API.

The annotation processing is contained in JDT/APT projects, and
compilation participant API is defined in JDT/Core:
org.eclipse.jdt.core.compiler.CompilationParticipant
Re: Extends JDT to support @java [message #257056 is a reply to message #256773] Fri, 24 October 2008 10:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rief.the.dreamer.gmail.com

Philippe Mulet wrote:
>> Since the language I have to support is strictly related to Java I'd
>> like to "import" the JDT plugin and extend it; in this way any bug fix
>> or extension you will do on the JDT will be immediately available also
>> in my plugin.
>
> You should have a look at the implementation for annotation processing
> (JSR-269) which is hooking into JDT via the compiler participant API.
>
> The annotation processing is contained in JDT/APT projects, and
> compilation participant API is defined in JDT/Core:
> org.eclipse.jdt.core.compiler.CompilationParticipant

Thanks a lot for your answer. I have explored your suggestion but
CompilationParticipant can't help me. From what I can see seems that
org.eclipse.jdt.apt.core.internal.AptCompilationParticipant. class
doesn't participate to the creation of the source file's AST but only
processes the annotations after that the AST has been created.

Unfortunately @java extends Java syntax (it adds a new way to annotate
statements and expressions, that is, @annotation(..) {
«statement|expression» }). So I need to change the java parser to accept
these syntactic extensions.


In the package org.eclipse.jdt.core.dom there is the ASTNode
class and instructions for adding new concrete AST node types.
I would like to know: if I add a new AST node following that
instructions, can I force Java plugin to accept @Java code or is there
something else necessary to change?

Thanks,
Mario Pastorelli
Re: Extends JDT to support @java [message #257275 is a reply to message #257056] Sat, 08 November 2008 11:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rief.the.dreamer.gmail.com

Hi programmers,
I founded the web site http://jmlspecs.wiki.sourceforge.net/ and in
particular the page
http://jmlspecs.wiki.sourceforge.net/JML4+HowTo+Build+the+Pa rser where
jml4's team explain how to build a new parser.

I edited the java.g grammar file inserting the block annotation in this way:

java.g:
============================================================ ===========
....

Annotation -> BlockAnnotation
/:$compiliance 1.5:/

....

BlockAnnotation ::= AnnotationName '(' MemberValuePairsopt ')' Statement
/.$putCase consumeBlockAnnotation() ; $break ./
/:$readableName BlockAnnotation:/
/:$compliance 1.5:/

....
============================================================ ===========


I compiled the new Parser and tried to use it in a test:

============================================================ ===========
public class test_01_BlockAnnotations extends AbstractComparableTest {

public test_01_BlockAnnotations(String testName) {
super(testName);
}

protected Map<String, String> getCompilerOptions() {
@SuppressWarnings("unchecked")
Map<String, String> options = super.getCompilerOptions();
options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5);

return options;
}

public void test_blockAnnotation() {
this.runConformTest(new String[] {
"b.java",
"class b { \n"+
" @interface a { }\n"+
" @a () { } \n"+
"}"
},
"");
}
}
============================================================ ===========


The test failed with this output:

Copy-paste compiler log:
"----------\n" +
"1. ERROR in b.java (at line 3)\n" +
" @a { } \n" +
" ^\n" +
"Syntax error, insert \"enum Identifier\" to complete EnumHeader\n" +
"----------\n"



Anyone know why?

Thanks,
Mario Pastorelli
Re: Extends JDT to support @java [message #257279 is a reply to message #257275] Sat, 08 November 2008 13:58 Go to previous messageGo to next message
Eclipse UserFriend
Rief a écrit :
> I compiled the new Parser and tried to use it in a test:
When I tried your new rule, the parser is no longer LALR(1). So this is
why it doesn't work on your example.
You have to modify the grammar to make it LALR(1).
--
Olivier
Re: Extends JDT to support @java [message #257432 is a reply to message #257279] Tue, 18 November 2008 20:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rief.the.dreamer.gmail.com

Olivier Thomann wrote:
> Rief a écrit :
>> I compiled the new Parser and tried to use it in a test:
> When I tried your new rule, the parser is no longer LALR(1). So this is
> why it doesn't work on your example.
> You have to modify the grammar to make it LALR(1).
> --
> Olivier

Thanks Oliviers.

Another question; I want to compile org.eclipse.jdt.core project without
eclipse, from command line, there is a script or something else to do that?

Thanks,
Mario
Re: Extends JDT to support @java [message #257443 is a reply to message #257432] Tue, 18 November 2008 21:58 Go to previous messageGo to next message
Eclipse UserFriend
Mario Pastorelli a écrit :
> Another question; I want to compile org.eclipse.jdt.core project without
> eclipse, from command line, there is a script or something else to do that?
You want to compile the whole jdt.core project or just the compiler part?
--
Olivier
Re: Extends JDT to support @java [message #257451 is a reply to message #257443] Wed, 19 November 2008 04:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rief.the.dreamer.gmail.com

Olivier Thomann wrote:
> Mario Pastorelli a écrit :
>> Another question; I want to compile org.eclipse.jdt.core project
>> without eclipse, from command line, there is a script or something
>> else to do that?
> You want to compile the whole jdt.core project or just the compiler part?
> --
> Olivier

I want to compile only the compiler part for now.

Mario
Re: Extends JDT to support @java [message #257462 is a reply to message #257451] Wed, 19 November 2008 08:57 Go to previous messageGo to next message
Eclipse UserFriend
Mario Pastorelli a écrit :
> I want to compile only the compiler part for now.
Then you should retrieve the ecj.jar file provided with each build. It
contains a build.xml file that could be used to rebuild the project
using ant.
Let me know if you have some issues with this.
--
Olivier
Re: Extends JDT to support @java [message #258482 is a reply to message #257462] Tue, 03 February 2009 17:18 Go to previous message
Eclipse UserFriend
Originally posted by: rief.the.dreamer.gmail.com

Hello everyone,
I added those rules to java.g:

Statement -> BlockAnnotation
BlockAnnotation -> '@' Name '(' MemberValuePairsopt ')' StatementNoShortIf

but when I try to compile it with jikespg I obtain that the grammar is
not LALR(1) and those errors:

*** The following Terminals are useless:
const goto
*** Shift/reduce conflict on "LPAREN" with rule 674

I can't see the conflict with the left parent, where it is?
Just out of curiosity, can i compile java.g with LPG instead of Jikespg?


Thanks,
Mario Pastorelli
Previous Topic:javac compiles, eclipse doesn't
Next Topic:How to get a list of resolved(!) methods in a .java/class file?
Goto Forum:
  


Current Time: Sat Apr 19 11:55:49 EDT 2025

Powered by FUDForum. Page generated in 0.03244 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top