|
|
Re: Restricting Java-like statements in method bodies [message #1691535 is a reply to message #1691512] |
Tue, 07 April 2015 23:37 |
Som 2015 Messages: 16 Registered: March 2015 |
Junior Member |
|
|
Hello,
Can you please elaborate more on this? I am not an expert on this.
This is how my code should look like (access to both class-level methods and variables must be reported as error, however, the access to local variables defined in the method is fine)
myClass{
int my_var;
my_normal_method(){...}
my_especial_method (){
int i;
//it is OK to invoke on external methods defined in other classes
Helper.method();
//it is OK to access local variables
i = 10;
// this must be reported as an error; there should be no access to local variables
my_var = 10;
// this must be reported as an error, there should be no access to local methods
my_normal_method();
}
}
Thanks
[Updated on: Wed, 08 April 2015 00:53] Report message to a moderator
|
|
|
|
|
Re: Restricting Java-like statements in method bodies [message #1691623 is a reply to message #1691619] |
Wed, 08 April 2015 14:10 |
|
Hi,
have a look at XFeatureCall.
P.S:
if class level stuff shall not be visible then my first approach will work! it does not work if some stuff shall be visible and some not
if you have following dsl
class X {
var y : String
def z() {
}
special a() {
println("hello")
}
}
Then infer following java code and it will work automatically
public class X {
String y;
public void z() {
}
public static void a() {
X_A_Delegate.a(); // body = '''/* code here */'''
}
}
public class X_A_Delegate {
public static void a() {
System.out.println("Hello"); //body = XExpression
}
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Powered by
FUDForum. Page generated in 0.03668 seconds