How to support a such a different overloading which is different from Java [message #1220306] |
Tue, 10 December 2013 20:28  |
Eclipse User |
|
|
|
Dear all,
As we known, in Java world, overloading only exists in ONE scope (with in one class). Please see the following Java snippet (the method with name "meth").
public class OuterCLass {
class InnerClass{
public void meth(int a){} // 1: in "InnerClass" scope
public void meth(){ } // 2: in InnerClass scope
public void call(){
meth(4); //<--- 3: method call, Java editor finds correct reference
}
}
}
The scoping of Xtext works in the same way. In Xtext world cross-references are established via names. When doing cross-referencing, it looks from the current scope where the the code locates. If the expected name could be found, then it would stop. If not, it would look from the next outer scope until the name is found. Or the expected name still can NOT be found from the outer-most scope, the an error would appear. This imply that the name in the outer scope is shadowed by the same name in the inner scope.
However, In our DSL, we need to support the overloading in all scopes (including local scope and global scope). The following code should be supported:
public class OuterCLass {
public void meth(int a){} // 1: in "OuterCLass" scope
class InnerClass{
public void meth(){ } // 2: in InnerClass scope
public void call(){
meth(4); //<--- 3: method call, Java editor shows an error: The method meth() in the type OuterCLass.InnerClass is not applicable for the arguments (int)
}
}
}
That is, if Xtext find the expected name ("meth"), it should NOT stop; it should continue to find other expect names ( all "meth"s) until the outer-most scope.
Could anyone give me some advice about this? Thanks in advance!
Best Regards,
Matthew
[Updated on: Tue, 10 December 2013 20:31] by Moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05084 seconds