Home » Archived » B3 » Using B3 language with Java classes
|
Re: Using B3 language with Java classes [message #532594 is a reply to message #532578] |
Mon, 10 May 2010 14:29   |
Henrik Lindberg 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 #532610 is a reply to message #532607] |
Mon, 10 May 2010 14:57   |
Henrik Lindberg 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 #606405 is a reply to message #606404] |
Mon, 10 May 2010 14:57  |
Henrik Lindberg 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
>
>
>
|
|
| | | | | |
Goto Forum:
Current Time: Thu Jun 01 03:31:31 GMT 2023
Powered by FUDForum. Page generated in 0.03149 seconds
|