Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,8 @@ private boolean validPluginFile(final IFile file) {
if (file == null || !file.exists()) {
return false;
}
try {
SAXParserFactory.newInstance().newSAXParser().parse(new BufferedInputStream(file.getContents(true)), new PluginHandler(false));
try (BufferedInputStream stream = new BufferedInputStream(file.getContents(true))) {
SAXParserFactory.newInstance().newSAXParser().parse(stream, new PluginHandler(false));
return true;
} catch (SAXException | IOException | ParserConfigurationException | CoreException e) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ private void deployCheckConfiguration() throws DeployException {
String uriString = pathMan.getURIValue(CheckCfgConstants.CHECK_CFG_VAR_NAME).toString();
URI uri = URI.createURI(uriString, true);
Resource resource = rs.createResource(uri);
try {
resource.load(new FileInputStream(new File(pathMan.getURIValue(CheckCfgConstants.CHECK_CFG_VAR_NAME))), rs.getLoadOptions());
try (FileInputStream input = new FileInputStream(new File(pathMan.getURIValue(CheckCfgConstants.CHECK_CFG_VAR_NAME)))) {
resource.load(input, rs.getLoadOptions());
rs.getURIResourceMap().put(uri, resource);
EcoreUtil.resolveAll(resource);
CheckConfiguration checkConfig = (CheckConfiguration) resource.getContents().get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,8 @@ private boolean hasLetters(final String keyword) {
* if an I/O error occurs
*/
public void printViolations(final String srcGenPath) {
try {
String fileName = getKeywordsDiagnosticReportFileName(srcGenPath);
PrintWriter writer = new PrintWriter(new File(fileName), StandardCharsets.UTF_8);
String fileName = getKeywordsDiagnosticReportFileName(srcGenPath);
try (PrintWriter writer = new PrintWriter(new File(fileName), StandardCharsets.UTF_8)) {
writer.println("Please check in this file, so a diff can be used to detect unexpected changes");
writer.println();
writer.println(" identifiers rejected - are not listed in MWE2 file as reserved words");
Expand Down Expand Up @@ -266,7 +265,6 @@ public void printViolations(final String srcGenPath) {
writer.println(ruleName);
}
writer.println("if any of them is used to parse identifiers, add them to identifierRules in MWE2 file");
writer.close();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
Expand Down Expand Up @@ -441,13 +439,13 @@ public List<Grammar> getAllGrammars() {
public void printReport(final String srcGenPath) {
try {
String fileName = getReportFileName(srcGenPath);
PrintWriter writer = new PrintWriter(new File(fileName), StandardCharsets.UTF_8);
writer.print(report.build());
writer.close();
try (PrintWriter writer = new PrintWriter(new File(fileName), StandardCharsets.UTF_8)) {
writer.print(report.build());
}
String docuFileName = getDocFileName(srcGenPath);
PrintWriter docuWriter = new PrintWriter(new File(docuFileName), StandardCharsets.UTF_8);
docuWriter.print(new CombinedGrammarReportBuilder(grammarExtensions).getDocumentation(grammar, parserRules, enumRules));
docuWriter.close();
try (PrintWriter docuWriter = new PrintWriter(new File(docuFileName), StandardCharsets.UTF_8)) {
docuWriter.print(new CombinedGrammarReportBuilder(grammarExtensions).getDocumentation(grammar, parserRules, enumRules));
}
LOGGER.info("report on keywords is written into {}", fileName);
} catch (IOException e) {
throw new UncheckedIOException(e);
Expand Down