|
|
Re: Trying to use JavaIoFileSystemAccess directly [message #1220876 is a reply to message #1220485] |
Sun, 15 December 2013 04:21 |
Gary Worsham Messages: 176 Registered: September 2013 |
Senior Member |
|
|
Hi Christian,
I could use a few more details.
Here's my modified Java code.
package com.holycityaudio.spincad;
import java.io.File;
import java.io.FileFilter;
import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.eclipse.emf.common.util.URI;
import org.eclipse.xtext.generator.IFileSystemAccess;
import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
import org.eclipse.xtext.generator.OutputConfiguration;
import com.holycityaudio.spincad.generator.*;
public class GenTestCases {
static String CADBlockPath = "C:\\long_path_to_files\\";
public static void main(String[] args) {
JavaIoFileSystemAccess fsa = new JavaIoFileSystemAccess();
fsa.setOutputPath("outputPath");
File dir = new File(CADBlockPath);
FileFilter fileFilter = new WildcardFileFilter("*CADBlock.java");
File[] files = dir.listFiles(fileFilter);
SpinCADGenerator sG = new SpinCADGenerator();
if(files != null) {
for (int i = 0; i < files.length; i++) {
String fileName = files[i].getName().split("CADBlock")[0];
System.out.println(fileName);
CharSequence cS = sG.toTestCode(fileName);
String youAreI = dir.toURI().toString();
fsa.generateFile(youAreI, cS);
}
}
}
}
All of my matching source files are getting found properly. However I get the error:
Exception in thread "main" org.eclipse.xtext.util.RuntimeIOException: Could not create directory C:\long_path_to_files\outputPath\file:\C:\long_path_to_files
What am I doing wrong?
GW
[Updated on: Sun, 15 December 2013 04:23] Report message to a moderator
|
|
|
|
|
Re: Trying to use JavaIoFileSystemAccess directly [message #1220881 is a reply to message #1220880] |
Sun, 15 December 2013 09:03 |
|
public static void main(String[] args) {
JavaIoFileSystemAccess fsa = new JavaIoFileSystemAccess();
Guice.createInjector(new AbstractGenericModule() {
public Class<? extends IEncodingProvider> bindIEncodingProvider() {
return IEncodingProvider.Runtime.class;
}
}).injectMembers(fsa);
fsa.setOutputPath("dummy");
fsa.generateFile("xxxx.txt", "contents");
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: Trying to use JavaIoFileSystemAccess directly [message #1220887 is a reply to message #1220881] |
Sun, 15 December 2013 13:53 |
Gary Worsham Messages: 176 Registered: September 2013 |
Senior Member |
|
|
Thank you very much! I don't think I ever would have figured this out by myself. I had been tracing through this with the debugger for a few days, but when you're tracing through a ".class" file it's not possible to see the values of any local variables.
Here's what ultimately worked:
package com.holycityaudio.spincad;
import java.io.File;
import java.io.FileFilter;
import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.eclipse.emf.common.util.URI;
import org.eclipse.xtext.generator.IFileSystemAccess;
import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
import org.eclipse.xtext.generator.OutputConfiguration;
import org.eclipse.xtext.parser.IEncodingProvider;
import org.eclipse.xtext.service.AbstractGenericModule;
import com.google.inject.Guice;
import com.holycityaudio.spincad.generator.*;
public class GenTestCases {
static String CADBlockPath = "C:\\path_to_source_files\\";
static String TestBlockPath = "C:\\path_to_output_files\\";
public static void main(String[] args) {
JavaIoFileSystemAccess fsa = new JavaIoFileSystemAccess();
fsa.setOutputPath(TestBlockPath);
File dir = new File(CADBlockPath);
FileFilter fileFilter = new WildcardFileFilter("*CADBlock.java");
File[] files = dir.listFiles(fileFilter);
SpinCADGenerator sG = new SpinCADGenerator();
Guice.createInjector(new AbstractGenericModule() {
public Class<? extends IEncodingProvider> bindIEncodingProvider() {
return IEncodingProvider.Runtime.class;
}
}).injectMembers(fsa);
if(files != null) {
for (int i = 0; i < files.length; i++) {
String fileName = files[i].getName().split("CADBlock")[0];
System.out.println(fileName);
CharSequence cS = sG.toTestCode(fileName);
fsa.generateFile(fileName + "Test.java", cS);
}
}
}
}
[Updated on: Sun, 15 December 2013 13:54] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03752 seconds