2

With Rascal I am trying to create a M3 model of another eclipse project. The java project I try to load is called eLib, it is opened in eclipse, I also can run the project. The project is located in my workspace. However, if I use the following commands in my rascal console (in the eclipse plugin):

import lang::java::m3::Core;
import lang::java::jdt::m3::Core;
myModel = createM3FromEclipseProject(|project://eLib|);

I get the following error:

|rascal://lang::java::m3::AST|(6315,172,<156,0>,<158,87>):  Java("IllegalArgumentException","Path must include project and resource name: /eLib")
at org.eclipse.core.runtime.Assert.isLegal(|file:///Assert.java|(0,0,<63,0>,<63,0>))
at org.eclipse.core.internal.resources.Workspace.newResource(|file:///Workspace.java|(0,0,<2164,0>,<2164,0>))
at org.eclipse.core.internal.resources.Container.getFolder(|file:///Container.java|(0,0,<215,0>,<215,0>))
at org.rascalmpl.eclipse.uri.ProjectURIResolver.resolve(|file:///ProjectURIResolver.java|(0,0,<107,0>,<107,0>))
at org.rascalmpl.eclipse.uri.ProjectURIResolver.getResourceURI(|file:///ProjectURIResolver.java|(0,0,<224,0>,<224,0>))
at org.rascalmpl.uri.URIResolverRegistry.getResourceURI(|file:///URIResolverRegistry.java|(0,0,<95,0>,<95,0>))
at org.rascalmpl.library.lang.java.m3.internal.EclipseJavaCompiler.setEnvironmentOptions(|file:///EclipseJavaCompiler.java|(0,0,<67,0>,<67,0>))
at sun.reflect.NativeMethodAccessorImpl.invoke0(|file:///NativeMethodAccessorImpl.java|(0,0,<0,0>,<0,0>))
at setEnvironmentOptions(|rascal://lang::java::jdt::m3::Core|(762,7,<28,76>,<28,83>))
at $shell$(|stdin:///|(10,45,<1,10>,<1,55>))

I hope one of you can help me.

  • Weird, because this works for so many other people. Could you try `myModel = createM3FromEclipseProject(|project://eLib/|);` with the extra slash? What kind of system is this? Windows, mac, linux? Which version of Eclipse? – Jurgen Vinju Feb 20 '14 at 11:03
  • I included the extra slash now, still the same error. I work on a windows 8 64 bit machine. Java jdk 7 update 51 64 bit. Eclipse Kepler Service Release 1 64 bit (2.0.1.20130919-0803). In addition, I added "import lang::java::io;", but this wasn't the solution either. – Jesper Huijgens Feb 20 '14 at 11:09
  • I found a workaround to the problem. I can use the function createM3FromDirectory, this function does work on my setup. However, it is a workaround and not a solution to the initial problem. – Jesper Huijgens Feb 20 '14 at 15:51
  • Now I continued working on the project and started to finally use the OFG module. To use the function createOFG, I have to give an Eclipse project location as an argument, which brings me back to the initial problem. Any other suggestions? – Jesper Huijgens Feb 20 '14 at 21:46
  • could it be a case-sensitivity issue? is the directory called `elib` instead of `eLib` ? For OFG you need to be able to extract from an eclipse project, just to get the accurate bindings. – Davy Landman Feb 21 '14 at 08:09
  • another thing to try: a different project (simple hello world should work). also, try your workspace on a computer of another student? another: try unstable version? try 32bit version of eclipse? if all else fails, ask someone to run the `createM3FromEclipseProject` & `createAstsFromEclipseProject` and save the results to files using [`ValueIO`](http://tutor.rascal-mpl.org/Rascal/Libraries/Prelude/ValueIO/ValueIO.html) which you can then use in your eclipse. the `OFG` library also has an overload to accept a `set[Declaration]`, which you could use in case all else fails. – Davy Landman Feb 21 '14 at 08:21
  • 2
    It was not an issue of case-sensitivity, but I now started a very new eclipse project, instead of importing the project from existing files, I copy pasted the files from the eLib project to the new project (via the eclipse project explorer). I don't know why, but it finally works :). Thx guys! – Jesper Huijgens Feb 21 '14 at 08:24
  • Wow. I suppose we will never know what was going on there. Thanks for reporting your success and have fun! – Jurgen Vinju Feb 21 '14 at 09:20
  • ah, if I had to guess, it wasn't an actual java project, but just a eclipse project. – Davy Landman Feb 21 '14 at 09:30
  • Just for you information / reference, the project actually was an actual java project (according to Eclipse). It was probably just some corruption in my Eclipse / project settings. But as I said, it now works like a charm. – Jesper Huijgens Feb 21 '14 at 10:56

1 Answers1

1

Make sure the project you are trying to analyse is an actual Java project (not a generic eclipse project), and that it compiles (no red crosses in the project).

Davy Landman
  • 15,109
  • 6
  • 49
  • 73