Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » B3 » Using B3 language with Java classes
Using B3 language with Java classes [message #532578] Mon, 10 May 2010 13:46 Go to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
Hi,

I just manage to launch an eclipse workbench with the B3 language.
I try to create a simple example.
My workspace look like it :
A java package called "test1",
In this package, to Class called "A.java" and "B,java",
A folder called ''B3Files';
In this folder, a b3 file called test1.B3.

in test.b3 I try to import the package test1, but I don't manage to do it.
I also implement the method : function square(Number x) : x * x ;
As written in the B3Book manual page 24.
but B3 don't recognize the class "Number"
I think it miss an import

thanks,

Jérémie



Re: Using B3 language with Java classes [message #532594 is a reply to message #532578] Mon, 10 May 2010 14:29 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Hi,
An example with a square function for Number would look like this:

square.b3--------------
import java.util.List;
import java.lang.Number;

function main(List argv) : square(3) ;

function square(Number n) : n * n;
----------

Will check that the documentation shows this correctly.
(A note, type inference is not that smart yet, and as a result, a bit
more typing than what the finished b3 will have is required).

Regarding access to classes.
----
The b3 environment sees classes from all bundles that are visible from
the OSGi managed classpath. To make b3 see more things, a bundle needs
to declare itself to be a buddy of b3.

So, if you want to call java code from B3, create a bundle, and add the
following to the MANIFEST.MF of the bundle where you have the classes
you want to expose to b3.

Eclipse-RegisterBuddy: org.eclipse.b3.backend

This is done in the org.eclipse.b3.beelang.tests project/bundle.

- henrik


On 5/10/10 3:46 PM, jeremie wrote:
> Hi,
>
> I just manage to launch an eclipse workbench with the B3 language.
> I try to create a simple example.
> My workspace look like it :
> A java package called "test1",
> In this package, to Class called "A.java" and "B,java",
> A folder called ''B3Files';
> In this folder, a b3 file called test1.B3.
>
> in test.b3 I try to import the package test1, but I don't manage to do it.
> I also implement the method : function square(Number x) : x * x ;
> As written in the B3Book manual page 24.
> but B3 don't recognize the class "Number"
> I think it miss an import
>
> thanks,
> Jérémie
>
>
>
>
Re: Using B3 language with Java classes [message #532595 is a reply to message #532578] Mon, 10 May 2010 14:32 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
I manage to use the Class number :

import java.lang.Number;

But I still can't import My owned classes : test1.A and test1.B
Re: Using B3 language with Java classes [message #532602 is a reply to message #532595] Mon, 10 May 2010 14:39 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Did you see my other post regarding using "buddy classloading" ?
- henrik

On 5/10/10 4:32 PM, jeremie wrote:
> I manage to use the Class number :
>
> import java.lang.Number;
>
> But I still can't import My owned classes : test1.A and test1.B
Re: Using B3 language with Java classes [message #532607 is a reply to message #532595] Mon, 10 May 2010 14:48 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
oki, I will look at it.

Is it normal that there is no content assist and validation for method call?
for example,

I write this method (find in the manual too),

function camelCase(String s) : {
s.split( ~/_/ ).inject( "", _, | r, s | r + s[0].toUpper() + s.subString(1));

}

when I write "s." no content assist is proposed. If I male a mistake (s.sppplit() for example), b3 don't underline sppplit in red.

Jérémie


Re: Using B3 language with Java classes [message #532610 is a reply to message #532607] Mon, 10 May 2010 14:57 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
That is correct - there is only the automatically generated content
assist, only limited validation, and no quickfixes implemented at this
point.

I have focused on the models, and the evaluation, and have waited with
many things until the 1.0 release of Xtext. As that is now imminent and
the APIs have stabilized I think this is quite high on the wish list.

What I am working on right now is to finalize the grammar and model for
repositories and resolution. Next thing is to separate the execution
from the grammar by using google guice (i.e. bind an implementation to
the specification).

As I do this, I will explore more of the Xtext API - I have just added a
quick fix for a small thing in the repository grammar.

Hope the missing features does not discourage you too much :)

Regards
- henrik



On 5/10/10 4:48 PM, jeremie wrote:
> oki, I will look at it.
>
> Is it normal that there is no content assist and validation for method
> call?
> for example,
>
> I write this method (find in the manual too),
> function camelCase(String s) : {
> s.split( ~/_/ ).inject( "", _, | r, s | r + s[0].toUpper() +
> s.subString(1));
>
> }
>
> when I write "s." no content assist is proposed. If I male a mistake
> (s.sppplit() for example), b3 don't underline sppplit in red.
>
> Jérémie
>
>
>
Re: Using B3 language with Java classes [message #532616 is a reply to message #532610] Mon, 10 May 2010 15:22 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
Don't worry, it won't discourage me Wink,
Re: Using B3 language with Java classes [message #532627 is a reply to message #532616] Mon, 10 May 2010 15:40 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
sorry, I don't find your other post : "buddy classloading" ?

Jérémie
Re: Using B3 language with Java classes [message #532629 is a reply to message #532616] Mon, 10 May 2010 15:35 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Good,
If you want to chat, you find me on #eclipse-b3 on irc.freenode.net

(If you need an IRC client for mac, I can recommend
http://colloquy.info/downloads.html)

Regards
- henrik

On 5/10/10 5:22 PM, jeremie wrote:
> Don't worry, it won't discourage me ;),
>
Re: Using B3 language with Java classes [message #532634 is a reply to message #532629] Mon, 10 May 2010 15:53 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
oki, I am on the channel, my pseudo is iguidoux
Re: Using B3 language with Java classes [message #532641 is a reply to message #532627] Mon, 10 May 2010 16:04 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
This was in an earlier post:

Regarding access to classes.
----
The b3 environment sees classes from all bundles that are visible from
the OSGi managed classpath. To make b3 see more things, a bundle needs
to declare itself to be a buddy of b3.

So, if you want to call java code from B3, create a bundle, and add the
following to the MANIFEST.MF of the bundle where you have the classes
you want to expose to b3.

Eclipse-RegisterBuddy: org.eclipse.b3.backend

This is done in the org.eclipse.b3.beelang.tests project/bundle.

On 5/10/10 5:40 PM, jeremie wrote:
> sorry, I don't find your other post : "buddy classloading" ?
>
> Jérémie
Re: Using B3 language with Java classes [message #606400 is a reply to message #532595] Mon, 10 May 2010 14:39 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Did you see my other post regarding using "buddy classloading" ?
- henrik

On 5/10/10 4:32 PM, jeremie wrote:
> I manage to use the Class number :
>
> import java.lang.Number;
>
> But I still can't import My owned classes : test1.A and test1.B
Re: Using B3 language with Java classes [message #606404 is a reply to message #532595] Mon, 10 May 2010 14:48 Go to previous message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
oki, I will look at it.

Is it normal that there is no content assist and validation for method call?
for example,

I write this method (find in the manual too),

function camelCase(String s) : {
s.split( ~/_/ ).inject( "", _, | r, s | r + s[0].toUpper() + s.subString(1));

}

when I write "s." no content assist is proposed. If I male a mistake (s.sppplit() for example), b3 don't underline sppplit in red.

Jérémie
Re: Using B3 language with Java classes [message #606405 is a reply to message #606404] Mon, 10 May 2010 14:57 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
That is correct - there is only the automatically generated content
assist, only limited validation, and no quickfixes implemented at this
point.

I have focused on the models, and the evaluation, and have waited with
many things until the 1.0 release of Xtext. As that is now imminent and
the APIs have stabilized I think this is quite high on the wish list.

What I am working on right now is to finalize the grammar and model for
repositories and resolution. Next thing is to separate the execution
from the grammar by using google guice (i.e. bind an implementation to
the specification).

As I do this, I will explore more of the Xtext API - I have just added a
quick fix for a small thing in the repository grammar.

Hope the missing features does not discourage you too much :)

Regards
- henrik



On 5/10/10 4:48 PM, jeremie wrote:
> oki, I will look at it.
>
> Is it normal that there is no content assist and validation for method
> call?
> for example,
>
> I write this method (find in the manual too),
> function camelCase(String s) : {
> s.split( ~/_/ ).inject( "", _, | r, s | r + s[0].toUpper() +
> s.subString(1));
>
> }
>
> when I write "s." no content assist is proposed. If I male a mistake
> (s.sppplit() for example), b3 don't underline sppplit in red.
>
> Jérémie
>
>
>
Re: Using B3 language with Java classes [message #606409 is a reply to message #532610] Mon, 10 May 2010 15:22 Go to previous message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
Don't worry, it won't discourage me ;),
Re: Using B3 language with Java classes [message #606413 is a reply to message #532616] Mon, 10 May 2010 15:35 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Good,
If you want to chat, you find me on #eclipse-b3 on irc.freenode.net

(If you need an IRC client for mac, I can recommend
http://colloquy.info/downloads.html)

Regards
- henrik

On 5/10/10 5:22 PM, jeremie wrote:
> Don't worry, it won't discourage me ;),
>
Re: Using B3 language with Java classes [message #606415 is a reply to message #532616] Mon, 10 May 2010 15:40 Go to previous message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
sorry, I don't find your other post : "buddy classloading" ?

Jérémie
Re: Using B3 language with Java classes [message #606960 is a reply to message #532629] Mon, 10 May 2010 15:53 Go to previous message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
oki, I am on the channel, my pseudo is iguidoux
Re: Using B3 language with Java classes [message #606962 is a reply to message #606415] Mon, 10 May 2010 16:04 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
This was in an earlier post:

Regarding access to classes.
----
The b3 environment sees classes from all bundles that are visible from
the OSGi managed classpath. To make b3 see more things, a bundle needs
to declare itself to be a buddy of b3.

So, if you want to call java code from B3, create a bundle, and add the
following to the MANIFEST.MF of the bundle where you have the classes
you want to expose to b3.

Eclipse-RegisterBuddy: org.eclipse.b3.backend

This is done in the org.eclipse.b3.beelang.tests project/bundle.

On 5/10/10 5:40 PM, jeremie wrote:
> sorry, I don't find your other post : "buddy classloading" ?
>
> Jérémie
Previous Topic:first launch of an eclipse workbench with B3 language
Next Topic:Question about B3 meta-model and B3 language
Goto Forum:
  


Current Time: Tue Mar 19 02:54:14 GMT 2024

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

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

Back to the top