[Sirius] Access to local resources of modeling project [message #1854672] |
Fri, 02 September 2022 05:24 |
Akira Tanaka Messages: 98 Registered: March 2010 |
Member |
|
|
Dear Eclipse/Sirius experts,
This is a question for Desktop version of Sirius.
I am working on a Sirius-Xtext project where:
- First, defined an Xtext grammar and generated Xtext aretefacts
- Created another Eclipse instance that contains above Xtext plugin
- Defined viewpoint specification project. In that, I defined an odesign file under description folder, and wrote some functionality to generated Services.java
To test above, I created a test project, which is a normal Modeling project except for one thing, which is a resource folder that contains more than one Xtext (textual) dsl models.
What I like to achieve is, by writing a Java service that reads those Xtext textual models (as text files), do some text processing, and reflect the result to a property view definition part of the odesign file.
However, I do not know how to get access to text files under resources folder from within Java services. I tried typical File IO mechanism in Java but did not work.
File newFile = new File("resources/test.txt");
newFile.createNewFile();
if (!newFile.exists()) {
System.out.println("file does not exist");
}
FileReader fr = new FileReader(newFile);
int data;
while ((data = fr.read()) != -1) {
System.out.println((char) data);
}
fr.close();
System.out.println(newFile);
The real objective is to implement "scoping" for references in property view. With default implementation, the number of reference candidates (in several cases) is too large (>100) and without name ordering (i.e. it's difficult to use from users' point of view).
The question is about the right way (in services) to access local resources of the modeling project.
Your advice is very much appreciated.
|
|
|
Re: [Sirius] Access to local resources of modeling project [message #1854707 is a reply to message #1854672] |
Fri, 02 September 2022 22:22 |
|
Hi,
I am not sure why your code snippet, but I am pretty sure that in Sirius when we need to read a file we use FileInputStream rather than FileReader. If the file is an XML file, we use SaxParserFactory.
I know less about XText, but I think an alternative is that you should be able to load these models in your Sirius session and acces these resource directly from it as semantic resources and navigate to find what information you want.
Best regards,
Steve
Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
Powered by
FUDForum. Page generated in 0.02935 seconds