Xtend2 - try/catch resulting in invalid xblockexpression [message #670863] |
Sun, 15 May 2011 20:43  |
Eclipse User |
|
|
|
Hi,
I found the following issue in the latest Xtend2 (2.0.0.v201105141032). If I have an xtend function with multiple statements in a try block, it will generate an invalid _xblockexpression:
Xtend class:
package xtend.tutorial
import java.io.*
class Test {
def containsExpression(File f) {
try {
val reader = new BufferedReader(new FileReader(f))
var line = reader.readLine()
while (line != null) {
if (line.contains("function"))
return true;
line = reader.readLine()
}
reader.close()
} catch (IOException ex) {
ex.printStackTrace
}
return false
}
}
Generated Test.java file:
package xtend.tutorial;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
@SuppressWarnings("all")
public class Test {
public boolean containsExpression(final File f) {
{
try {
void _xblockexpression = null;
{
FileReader _fileReader = new FileReader(f);
BufferedReader _bufferedReader = new BufferedReader(_fileReader);
final BufferedReader reader = _bufferedReader;
String _readLine = reader.readLine();
String line = _readLine;
boolean _operator_notEquals = ObjectExtensions.operator_notEquals(line, null);
Boolean _xwhileexpression = _operator_notEquals;
while (_xwhileexpression) {
{
boolean _contains = line.contains("function");
if (_contains) {
return true;
}
String _readLine_1 = reader.readLine();
line = _readLine_1;
}
boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(line, null);
_xwhileexpression = _operator_notEquals_1;
}
reader.close();
_xblockexpression = (null);
}
} catch (IOException ex) {
ex.printStackTrace();
}
return false;
}
}
}
Note that the _xblockexpression is generated with a type of void.
Regards,
Edwin
|
|
|
Re: Xtend2 - try/catch resulting in invalid xblockexpression [message #670912 is a reply to message #670863] |
Mon, 16 May 2011 03:31  |
Eclipse User |
|
|
|
Hi Edwin,
you may want to follow this ticket:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=345371
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 16.05.11 02:43, schrieb Edwin Park:
> Hi,
>
> I found the following issue in the latest Xtend2
> (2.0.0.v201105141032). If I have an xtend function with
> multiple statements in a try block, it will generate an
> invalid _xblockexpression:
>
> Xtend class:
>
> package xtend.tutorial
>
> import java.io.*
>
> class Test {
>
> def containsExpression(File f) {
> try {
> val reader = new BufferedReader(new FileReader(f))
>
> var line = reader.readLine()
> while (line != null) {
> if (line.contains("function"))
> return true;
> line = reader.readLine()
> }
>
> reader.close()
> } catch (IOException ex) {
> ex.printStackTrace
> }
>
> return false
> }
>
> }
>
>
> Generated Test.java file:
>
> package xtend.tutorial;
>
> import java.io.BufferedReader;
> import java.io.File;
> import java.io.FileReader;
> import java.io.IOException;
> import org.eclipse.xtext.xbase.lib.ObjectExtensions;
>
> @SuppressWarnings("all")
> public class Test {
>
> public boolean containsExpression(final File f) {
> {
> try {
> void _xblockexpression = null;
> {
> FileReader _fileReader = new FileReader(f);
> BufferedReader _bufferedReader = new
> BufferedReader(_fileReader);
> final BufferedReader reader = _bufferedReader;
> String _readLine = reader.readLine();
> String line = _readLine;
> boolean _operator_notEquals =
> ObjectExtensions.operator_notEquals(line, null);
> Boolean _xwhileexpression = _operator_notEquals;
> while (_xwhileexpression) {
> {
> boolean _contains =
> line.contains("function");
> if (_contains) {
> return true;
> }
> String _readLine_1 = reader.readLine();
> line = _readLine_1;
> }
> boolean _operator_notEquals_1 =
> ObjectExtensions.operator_notEquals(line, null);
> _xwhileexpression = _operator_notEquals_1;
> }
> reader.close();
> _xblockexpression = (null);
> }
> } catch (IOException ex) { ex.printStackTrace();
> }
> return false;
> }
> }
> }
>
>
> Note that the _xblockexpression is generated with a type of
> void.
>
> Regards,
> Edwin
>
|
|
|
Powered by
FUDForum. Page generated in 0.11967 seconds