mirror of
https://github.com/processing/processing4.git
synced 2026-02-16 03:45:40 +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
@@ -0,0 +1,52 @@
|
||||
package processing.mode.java.pdex.util;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import processing.app.Problem;
|
||||
import processing.app.ui.Editor;
|
||||
import processing.mode.java.preproc.issue.PdePreprocessIssue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class ProblemFactoryTest {
|
||||
|
||||
private PdePreprocessIssue pdePreprocessIssue;
|
||||
private List<Integer> tabStarts;
|
||||
private Editor editor;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
pdePreprocessIssue = new PdePreprocessIssue(8, 2, "test");
|
||||
|
||||
tabStarts = new ArrayList<>();
|
||||
tabStarts.add(5);
|
||||
|
||||
editor = Mockito.mock(Editor.class);
|
||||
Mockito.when(editor.getLineStartOffset(3)).thenReturn(10);
|
||||
Mockito.when(editor.getLineStopOffset(3)).thenReturn(12);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildWithEditor() {
|
||||
Problem problem = ProblemFactory.build(pdePreprocessIssue, tabStarts, 15, editor);
|
||||
|
||||
Assert.assertEquals(3, problem.getLineNumber());
|
||||
Assert.assertEquals("test", problem.getMessage());
|
||||
Assert.assertEquals(10, problem.getStartOffset());
|
||||
Assert.assertEquals(11, problem.getStopOffset());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildWithoutEditor() {
|
||||
Problem problem = ProblemFactory.build(pdePreprocessIssue, tabStarts);
|
||||
|
||||
Assert.assertEquals(3, problem.getLineNumber());
|
||||
Assert.assertEquals("test", problem.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package processing.mode.java.pdex.util;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class TabLineFactoryTest {
|
||||
|
||||
private List<Integer> starts;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
starts = new ArrayList<>();
|
||||
starts.add(0);
|
||||
starts.add(5);
|
||||
starts.add(10);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTabStart() {
|
||||
Assert.assertEquals(0, TabLineFactory.getTab(starts, 0).getTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTabMiddleFrontEdge() {
|
||||
Assert.assertEquals(1, TabLineFactory.getTab(starts, 5).getTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTabMiddle() {
|
||||
TabLine tabLine = TabLineFactory.getTab(starts, 7);
|
||||
Assert.assertEquals(1, tabLine.getTab());
|
||||
Assert.assertEquals(2, tabLine.getLineInTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTabMiddleBackEdge() {
|
||||
Assert.assertEquals(2, TabLineFactory.getTab(starts, 10).getTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTabEnd() {
|
||||
Assert.assertEquals(2, TabLineFactory.getTab(starts, 15).getTab());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user