mirror of
https://github.com/processing/processing4.git
synced 2026-02-01 21:01:07 +01:00
Move to ANTLR 4 with Java 11 lang features and localization. (#5)
* Move to ANTLR 4 with Java 11 lang features and localization. Introduces ANTLR4 and Java 8 language feature support within IDE while also adding additional hooks for localization of syntax error messages, addressing https://github.com/processing/processing/issues/3054 and https://github.com/processing/processing/issues/3055. The PR is broadly a continuation of https://github.com/processing/processing/issues/3055, bringing it up to speed with the latest Processing master plus the changes introduced at https://github.com/processing/processing/pull/5753. **Requires https://github.com/processing/processing/pull/5753 as pre-requisite.** This introduces a number of edits beyond https://github.com/processing/processing/issues/3055 beyond compatibility with current Processing master and https://github.com/processing/processing/pull/5753 including: - Update to the grammar itself - Change ANTLR listeners to emit `TextTransform.Edit` to unify JDT-based `PreprocessingService` and `JavaBuild`, removing code with duplicate purpose. - Introduction of syntax error rewriting with support for localization. - Addition of complete localized strings set for English and Spanish. - Addition of partial localized strings set for other languages. - Refactor of ANTLR-related code for testability and readability - Expansion of tests including full parse tests for new Java features (type inference, lambdas). * Ask travis for ant upgrade prior to run. * Ask Travis for java11 update. * Add openjdk ppa * Travis no confirmation on add ppa. * Force newer ant on travis. * Swtich ant download to www-us mirror. * Switch ant to 1.10.7 * Start x for unit tests in travis. * More complete start x in travis. * Revert x in travis. * Try x in services.
This commit is contained in:
committed by
GitHub
parent
00dd2803f0
commit
ee299ef935
64
java/test/processing/mode/java/AutoFormatTests.java
Normal file
64
java/test/processing/mode/java/AutoFormatTests.java
Normal file
@@ -0,0 +1,64 @@
|
||||
package processing.mode.java;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static processing.mode.java.ProcessingTestUtil.res;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class AutoFormatTests {
|
||||
|
||||
@BeforeClass
|
||||
public static void init() {
|
||||
ProcessingTestUtil.init();
|
||||
}
|
||||
|
||||
static void expectGood(final String id) {
|
||||
try {
|
||||
final String formattedProgram = ProcessingTestUtil.format(res(id + ".pde"));
|
||||
final File goldenFile = res(id + ".expected");
|
||||
checkGolden(formattedProgram, goldenFile);
|
||||
// check that the formatted text doesn't change
|
||||
checkGolden(ProcessingTestUtil.format(formattedProgram), goldenFile);
|
||||
} catch (Exception e) {
|
||||
if (!e.equals(e.getCause()) && e.getCause() != null)
|
||||
fail(e.getCause().toString());
|
||||
else
|
||||
e.printStackTrace(System.err);
|
||||
fail(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkGolden(final String expectedText,
|
||||
final File goldenFile) throws IOException {
|
||||
if (goldenFile.exists()) {
|
||||
final String expected = ProcessingTestUtil.read(goldenFile);
|
||||
assertEquals(expected, expectedText);
|
||||
} else {
|
||||
System.err.println("WARN: golden file " + goldenFile
|
||||
+ " does not exist. Generating.");
|
||||
final FileWriter sug = new FileWriter(goldenFile);
|
||||
sug.write(ProcessingTestUtil.normalize(expectedText));
|
||||
sug.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug109() {
|
||||
expectGood("bug109");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug405() {
|
||||
expectGood("bug405");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug420() {
|
||||
expectGood("bug420");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user