Embed Text File Ressources in my Language.

Hello MPS Team!

I rely on external plain text files for the textGen aspect of my language.
I would like to embed those ressources in the language tree or in a solution tree. Is it possible to do so in MPS?

I already did an attempt. I'v created a Concept with a string property and a corresponding swing JTextArea cell for the Editor Aspect. But my TextArea miss the Delete/Backward key events and some others. I guess those events are captured by the cell. Can I prevent this?

So is there any better solution to integrate those text files in my language/solutions?

Thanks a lot and best regards,

1 comment
Comment actions Permalink
If you don't need an editor for the text files, you can always read it from a path.
/* Behavior method */
public string getFileContents() { 
  try { 
    return FileUtils.readFileToString(new File(this.path)); 
  } catch (IOException exception) { 
    <no statements> 
  return ""; 

And in textgen:
foreach line in node.getFileContents().split("\n") { 
  append ${line} \n ; 

If you need an editor just could make a new Concept with
line : Line[0..n]
and use the generator.
You can make an indention to fill this concept with content (for example with a path property).
You could also split text that was pasted into the first line on \n and add for each splitted line a new concept of type Line.

Please sign in to leave a comment.