use of javax.tools.FileObject in project ceylon-compiler by ceylon.
the class ClassDocImpl method containingPackage.
/**
* Return the package that this class is contained in.
*/
@Override
public PackageDoc containingPackage() {
PackageDocImpl p = env.getPackageDoc(tsym.packge());
if (p.setDocPath == false) {
FileObject docPath;
try {
Location location = env.fileManager.hasLocation(StandardLocation.SOURCE_PATH) ? StandardLocation.SOURCE_PATH : StandardLocation.CLASS_PATH;
docPath = env.fileManager.getFileForInput(location, p.qualifiedName(), "package.html");
} catch (IOException e) {
docPath = null;
}
if (docPath == null) {
// fall back on older semantics of looking in same directory as
// source file for this class
SourcePosition po = position();
if (env.fileManager instanceof StandardJavaFileManager && po instanceof SourcePositionImpl) {
URI uri = ((SourcePositionImpl) po).filename.toUri();
if ("file".equals(uri.getScheme())) {
File f = new File(uri);
File dir = f.getParentFile();
if (dir != null) {
File pf = new File(dir, "package.html");
if (pf.exists()) {
StandardJavaFileManager sfm = (StandardJavaFileManager) env.fileManager;
docPath = sfm.getJavaFileObjects(pf).iterator().next();
}
}
}
}
}
p.setDocPath(docPath);
}
return p;
}
use of javax.tools.FileObject in project ceylon-compiler by ceylon.
the class LanguageCompiler method addResources.
private void addResources() throws Abort {
HashSet<String> written = new HashSet<String>();
try {
for (JavaFileObject fo : resourceFileObjects) {
CeyloncFileManager dfm = (CeyloncFileManager) fileManager;
String jarFileName = JarUtils.toPlatformIndependentPath(dfm.getLocation(CeylonLocation.RESOURCE_PATH), fo.getName());
if (!written.contains(jarFileName)) {
dfm.setModule(modelLoader.findModuleForFile(new File(jarFileName)));
FileObject outFile = dfm.getFileForOutput(StandardLocation.CLASS_OUTPUT, "", jarFileName, null);
OutputStream out = outFile.openOutputStream();
try {
InputStream in = new FileInputStream(new File(fo.getName()));
try {
JarUtils.copy(in, out);
} finally {
in.close();
}
} finally {
out.close();
}
written.add(jarFileName);
}
}
} catch (IOException ex) {
throw new Abort(ex);
}
}
use of javax.tools.FileObject in project pentaho-kettle by pentaho.
the class PDI_6976_Test method testVerifyNoPreviousStep.
@Test
public void testVerifyNoPreviousStep() {
LoadFileInputMeta spy = spy(new LoadFileInputMeta());
FileInputList fileInputList = mock(FileInputList.class);
List<FileObject> files = when(mock(List.class).size()).thenReturn(1).getMock();
doReturn(files).when(fileInputList).getFiles();
doReturn(fileInputList).when(spy).getFiles(any(VariableSpace.class));
@SuppressWarnings("unchecked") List<CheckResultInterface> validationResults = mock(List.class);
// Check we do not get validation errors
doAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
if (((CheckResultInterface) invocation.getArguments()[0]).getType() != CheckResultInterface.TYPE_RESULT_OK) {
TestCase.fail("We've got validation error");
}
return null;
}
}).when(validationResults).add(any(CheckResultInterface.class));
spy.check(validationResults, mock(TransMeta.class), mock(StepMeta.class), mock(RowMetaInterface.class), new String[] {}, new String[] { "File content", "File size" }, mock(RowMetaInterface.class), mock(VariableSpace.class), mock(Repository.class), mock(IMetaStore.class));
}
use of javax.tools.FileObject in project lombok by rzwitserloot.
the class SpiProcessorPersistence method write.
void write(String serviceName, String value) throws IOException {
FileObject output = filer.createResource(StandardLocation.CLASS_OUTPUT, "", path + serviceName);
Writer writer = output.openWriter();
writer.write("# Generated by " + name + "\n");
writer.write("# " + new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.US).format(new Date()) + "\n");
writer.write(value);
writer.close();
}
use of javax.tools.FileObject in project lombok by rzwitserloot.
the class SpiProcessorCollector method readInitialData.
private CharSequence readInitialData(String serviceName) {
String pathName = SpiProcessor.getRootPathOfServiceFiles() + serviceName;
FileObject resource;
try {
resource = filer.getResource(StandardLocation.CLASS_OUTPUT, "", pathName);
} catch (Exception e) {
logger.printMessage(Kind.ERROR, SpiProcessor.toErrorMsg(e, pathName));
return null;
}
return SpiProcessorPersistence.readFilerResource(resource, logger, pathName);
}
Aggregations