Skip to content
Snippets Groups Projects
Commit ddb016d5 authored by Florian Angerer's avatar Florian Angerer
Browse files

Added deparse fallback if file system fails.

parent 5631b210
No related branches found
No related tags found
No related merge requests found
......@@ -379,26 +379,35 @@ public class RDeparse {
public void fixupSources() {
if (FastROptions.EmitTmpSource.getBooleanValue()) {
try {
RootNode rootNode = getRootNode();
String name = rootNode != null ? rootNode.getName() : null;
Path path = emitToFile(name);
Source source = RSource.fromFile(path.toFile());
for (SourceSectionElement s : sources) {
if (s.element.getLazySourceSection() == null || s.element.getLazySourceSection() == RSyntaxNode.LAZY_DEPARSE) {
s.element.setSourceSection(source.createSection(s.start, s.length));
}
}
} catch (IOException e) {
RInternalError.reportError(e);
} catch (NoSuchAlgorithmException e) {
throw RInternalError.shouldNotReachHere("SHA-256 is an unknown algorithm");
}
fixupSourcesTempFile();
} else {
Source source = RSource.fromTextInternal(sb.toString(), RSource.Internal.DEPARSE);
fixupSourcesTextInternal();
}
}
private void fixupSourcesTextInternal() {
Source source = RSource.fromTextInternal(sb.toString(), RSource.Internal.DEPARSE);
for (SourceSectionElement s : sources) {
s.element.setSourceSection(source.createSection(s.start, s.length));
}
}
private void fixupSourcesTempFile() {
try {
RootNode rootNode = getRootNode();
String name = rootNode != null ? rootNode.getName() : null;
Path path = emitToFile(name);
Source source = RSource.fromFile(path.toFile());
for (SourceSectionElement s : sources) {
s.element.setSourceSection(source.createSection(s.start, s.length));
if (s.element.getLazySourceSection() == null || s.element.getLazySourceSection() == RSyntaxNode.LAZY_DEPARSE) {
s.element.setSourceSection(source.createSection(s.start, s.length));
}
}
} catch (IOException e) {
RInternalError.reportError(e);
fixupSourcesTextInternal();
} catch (NoSuchAlgorithmException e) {
throw RInternalError.shouldNotReachHere("SHA-256 is an unknown algorithm");
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment