From 1f24c2ad719d2d3b2dfe05a8da01d54fc585a299 Mon Sep 17 00:00:00 2001 From: Christian Dietrich Date: Mon, 22 Mar 2021 13:47:22 +0100 Subject: [PATCH] [eclipse/xtext#1952] migrated xtend test code to java Signed-off-by: Christian Dietrich --- org.eclipse.xtext.ui.tests/.classpath | 1 - org.eclipse.xtext.ui.tests/build.properties | 3 +- .../tests/xmleditor/AbstractXmlLexerTest.java | 525 ++++++++++ .../xmleditor/AbstractXmlLexerTest.xtend | 517 ---------- .../xmleditor/XmlContentAssistLexerTests.java | 46 + .../XmlContentAssistLexerTests.xtend | 45 - .../tests/xmleditor/AbstractXmlLexerTest.java | 930 ------------------ .../xmleditor/XmlContentAssistLexerTests.java | 54 - org.eclipse.xtext.xtext.ui.tests/.classpath | 1 - .../build.properties | 3 +- .../quickfix/XtextGrammarQuickfixTest.java | 242 +++++ .../quickfix/XtextGrammarQuickfixTest.xtend | 235 ----- .../quickfix/XtextGrammarQuickfixTest.java | 341 ------- 13 files changed, 815 insertions(+), 2128 deletions(-) create mode 100644 org.eclipse.xtext.ui.tests/tests/org/eclipse/xtext/ui/tests/xmleditor/AbstractXmlLexerTest.java delete mode 100644 org.eclipse.xtext.ui.tests/tests/org/eclipse/xtext/ui/tests/xmleditor/AbstractXmlLexerTest.xtend create mode 100644 org.eclipse.xtext.ui.tests/tests/org/eclipse/xtext/ui/tests/xmleditor/XmlContentAssistLexerTests.java delete mode 100644 org.eclipse.xtext.ui.tests/tests/org/eclipse/xtext/ui/tests/xmleditor/XmlContentAssistLexerTests.xtend delete mode 100644 org.eclipse.xtext.ui.tests/xtend-gen/org/eclipse/xtext/ui/tests/xmleditor/AbstractXmlLexerTest.java delete mode 100644 org.eclipse.xtext.ui.tests/xtend-gen/org/eclipse/xtext/ui/tests/xmleditor/XmlContentAssistLexerTests.java create mode 100644 org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/quickfix/XtextGrammarQuickfixTest.java delete mode 100644 org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/quickfix/XtextGrammarQuickfixTest.xtend delete mode 100644 org.eclipse.xtext.xtext.ui.tests/xtend-gen/org/eclipse/xtext/xtext/ui/editor/quickfix/XtextGrammarQuickfixTest.java diff --git a/org.eclipse.xtext.ui.tests/.classpath b/org.eclipse.xtext.ui.tests/.classpath index de3d6bf350..24e74839a3 100644 --- a/org.eclipse.xtext.ui.tests/.classpath +++ b/org.eclipse.xtext.ui.tests/.classpath @@ -4,7 +4,6 @@ - diff --git a/org.eclipse.xtext.ui.tests/build.properties b/org.eclipse.xtext.ui.tests/build.properties index 7b4b0634db..78969bd33b 100644 --- a/org.eclipse.xtext.ui.tests/build.properties +++ b/org.eclipse.xtext.ui.tests/build.properties @@ -2,8 +2,7 @@ source.. = tests/,\ src-gen/,\ emf-gen/,\ src/,\ - src-longrunning/,\ - xtend-gen/ + src-longrunning/ output.. = bin/ bin.includes = model/generated/,\ META-INF/,\ diff --git a/org.eclipse.xtext.ui.tests/tests/org/eclipse/xtext/ui/tests/xmleditor/AbstractXmlLexerTest.java b/org.eclipse.xtext.ui.tests/tests/org/eclipse/xtext/ui/tests/xmleditor/AbstractXmlLexerTest.java new file mode 100644 index 0000000000..a2a8d8a955 --- /dev/null +++ b/org.eclipse.xtext.ui.tests/tests/org/eclipse/xtext/ui/tests/xmleditor/AbstractXmlLexerTest.java @@ -0,0 +1,525 @@ +/** + * Copyright (c) 2019, 2021 itemis AG (http://www.itemis.eu) and others. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.eclipse.xtext.ui.tests.xmleditor; + +import org.eclipse.xtext.util.Strings; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.Timeout; + +public abstract class AbstractXmlLexerTest extends AbstractLexerTest { + @Rule + public final Timeout timeout = Timeout.seconds(2); + + @Override + protected void assertLexing(CharSequence modelAsText, CharSequence expected) throws Exception { + super.assertLexing(Strings.toPlatformLineSeparator(modelAsText), Strings.toPlatformLineSeparator(expected)); + } + + @Test + public void test001() throws Exception { + assertLexing("", ""); + } + + @Test + public void test002() throws Exception { + String model = "\n"; + String expectation = + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'a'\n" + + "RULE_TAG_EMPTY_CLOSE '/>'\n"; + assertLexing(model, expectation); + } + + @Test + public void test003() throws Exception { + String model = "\n"; + String expectation = + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'a'\n" + + "RULE_WS ' '\n" + + "RULE_ID 'b'\n" + + "RULE_ATTR_EQ '='\n" + + "RULE_STRING '\"\"'\n" + + "RULE_TAG_EMPTY_CLOSE '/>'\n"; + assertLexing(model, expectation); + } + + @Test + public void test004() throws Exception { + String model = "\n"; + String expectation = + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'a'\n" + + "RULE_WS ' '\n" + + "RULE_ID 'b'\n" + + "RULE_ATTR_EQ '='\n" + + "RULE_STRING '\"c\"'\n" + + "RULE_TAG_EMPTY_CLOSE '/>'\n"; + assertLexing(model, expectation); + } + + @Test + public void test005() throws Exception { + String model = "\n"; + String expectation = + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'a'\n" + + "RULE_WS ' '\n" + + "RULE_ID 'b'\n" + + "RULE_ATTR_EQ '='\n" + + "RULE_STRING ''c''\n" + + "RULE_TAG_EMPTY_CLOSE '/>'\n"; + assertLexing(model, expectation); + } + + @Test + public void test006() throws Exception { + String model = "\n"; + String expectation = + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'a'\n" + + "RULE_WS ' '\n" + + "RULE_ID 'b'\n" + + "RULE_ATTR_EQ '='\n" + + "RULE_STRING '\"c\"'\n" + + "RULE_WS ' '\n" + + "RULE_ID 'd'\n" + + "RULE_ATTR_EQ '='\n" + + "RULE_STRING ''e''\n" + + "RULE_TAG_EMPTY_CLOSE '/>'\n"; + assertLexing(model, expectation); + } + + @Test + public void test007() throws Exception { + String model = "\n"; + String expectation = + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'a'\n" + + "RULE_WS ' '\n" + + "RULE_ID 'b'\n" + + "RULE_ATTR_EQ '='\n" + + "RULE_STRING ''c''\n" + + "RULE_WS ' '\n" + + "RULE_ID 'd'\n" + + "RULE_ATTR_EQ '='\n" + + "RULE_STRING '\"e\"'\n" + + "RULE_TAG_EMPTY_CLOSE '/>'\n"; + assertLexing(model, expectation); + } + + @Test + public void test008() throws Exception { + String model = "\n"; + String expectation = + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'a'\n" + + "RULE_TAG_CLOSE '>'\n" + + "RULE_TAG_END_OPEN ''\n"; + assertLexing(model, expectation); + } + + @Test + public void test009() throws Exception { + String model = "\n"; + String expectation = + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'a'\n" + + "RULE_WS ' '\n" + + "RULE_ID 'b'\n" + + "RULE_ATTR_EQ '='\n" + + "RULE_STRING '\"c\"'\n" + + "RULE_TAG_CLOSE '>'\n" + + "RULE_TAG_END_OPEN ''\n"; + assertLexing(model, expectation); + } + + @Test + public void test010() throws Exception { + String model = "\n"; + String expectation = + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'a'\n" + + "RULE_WS ' '\n" + + "RULE_ID 'b'\n" + + "RULE_ATTR_EQ '='\n" + + "RULE_STRING ''c''\n" + + "RULE_TAG_CLOSE '>'\n" + + "RULE_TAG_END_OPEN ''\n"; + assertLexing(model, expectation); + } + + @Test + public void test011() throws Exception { + String model = "\n"; + String expectation = + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'a'\n" + + "RULE_WS ' '\n" + + "RULE_ID 'b'\n" + + "RULE_ATTR_EQ '='\n" + + "RULE_STRING ''c''\n" + + "RULE_WS ' '\n" + + "RULE_ID 'd'\n" + + "RULE_ATTR_EQ '='\n" + + "RULE_STRING '\"e\"'\n" + + "RULE_TAG_CLOSE '>'\n" + + "RULE_TAG_END_OPEN ''\n"; + assertLexing(model, expectation); + } + + @Test + public void test012() throws Exception { + String model = "\n"; + String expectation = + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'a'\n" + + "RULE_WS ' '\n" + + "RULE_ID 'b'\n" + + "RULE_ATTR_EQ '='\n" + + "RULE_STRING '\"c\"'\n" + + "RULE_WS ' '\n" + + "RULE_ID 'd'\n" + + "RULE_ATTR_EQ '='\n" + + "RULE_STRING ''e''\n" + + "RULE_TAG_CLOSE '>'\n" + + "RULE_TAG_END_OPEN ''\n"; + assertLexing(model,expectation); + } + + @Test + public void test013() throws Exception { + String model = "text\n"; + String expectation = + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'a'\n" + + "RULE_TAG_CLOSE '>'\n" + + "RULE_PCDATA 'text'\n" + + "RULE_TAG_END_OPEN ''\n"; + assertLexing(model, expectation); + } + + @Test + public void test014() throws Exception { + String model = "text\n"; + String expectation = + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'a'\n" + + "RULE_WS ' '\n" + + "RULE_ID 'b'\n" + + "RULE_ATTR_EQ '='\n" + + "RULE_STRING '\"c\"'\n" + + "RULE_TAG_CLOSE '>'\n" + + "RULE_PCDATA 'text'\n" + + "RULE_TAG_END_OPEN ''\n"; + assertLexing(model, expectation); + } + + @Test + public void test015() throws Exception { + String model = + "\n" + + " text\n" + + "\n"; + String expectation = + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'a'\n" + + "RULE_TAG_CLOSE '>'\n" + + "RULE_PCDATA '\n" + + " '\n" + + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'b'\n" + + "RULE_TAG_CLOSE '>'\n" + + "RULE_PCDATA 'text'\n" + + "RULE_TAG_END_OPEN ''\n" + + "RULE_PCDATA '\n" + + "'\n" + + "RULE_TAG_END_OPEN ''\n"; + assertLexing(model, expectation); + } + + @Test + public void test016() throws Exception { + String model = + "\n" + + " \n" + + "\n"; + String expectation = + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'a'\n" + + "RULE_TAG_CLOSE '>'\n" + + "RULE_PCDATA '\n" + + " '\n" + + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'b'\n" + + "RULE_TAG_EMPTY_CLOSE '/>'\n" + + "RULE_PCDATA '\n" + + "'\n" + + "RULE_TAG_END_OPEN ''\n"; + assertLexing(model, expectation); + } + + @Test + public void test017() throws Exception { + String model = + "\n" + + " \n" + + "\n"; + String expectation = + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'a'\n" + + "RULE_WS ' '\n" + + "RULE_ID 'b'\n" + + "RULE_ATTR_EQ '='\n" + + "RULE_STRING '\"c\"'\n" + + "RULE_TAG_CLOSE '>'\n" + + "RULE_PCDATA '\n" + + " '\n" + + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'd'\n" + + "RULE_WS ' '\n" + + "RULE_ID 'e'\n" + + "RULE_ATTR_EQ '='\n" + + "RULE_STRING '\"f\"'\n" + + "RULE_TAG_EMPTY_CLOSE '/>'\n" + + "RULE_PCDATA '\n" + + "'\n" + + "RULE_TAG_END_OPEN ''\n"; + assertLexing(model, expectation); + } + + @Test + public void test018() throws Exception { + String model = + "\n" + + " c\n" + + " e\n" + + " \n" + + "\n"; + String expectation = + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'a'\n" + + "RULE_TAG_CLOSE '>'\n" + + "RULE_PCDATA '\n" + + " '\n" + + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'b'\n" + + "RULE_TAG_CLOSE '>'\n" + + "RULE_PCDATA 'c'\n" + + "RULE_TAG_END_OPEN ''\n" + + "RULE_PCDATA '\n" + + " '\n" + + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'd'\n" + + "RULE_TAG_CLOSE '>'\n" + + "RULE_PCDATA 'e'\n" + + "RULE_TAG_END_OPEN ''\n" + + "RULE_PCDATA '\n" + + " '\n" + + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'f'\n" + + "RULE_TAG_EMPTY_CLOSE '/>'\n" + + "RULE_PCDATA '\n" + + "'\n" + + "RULE_TAG_END_OPEN ''\n"; + assertLexing(model, expectation); + } + + @Test + public void test019() throws Exception { + String model = + "\n" + + " \n" + + " \n" + + " e\n" + + " \n" + + "\n"; + String expectation = + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'a'\n" + + "RULE_TAG_CLOSE '>'\n" + + "RULE_PCDATA '\n" + + " '\n" + + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'b'\n" + + "RULE_TAG_CLOSE '>'\n" + + "RULE_PCDATA '\n" + + " '\n" + + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'c'\n" + + "RULE_TAG_EMPTY_CLOSE '/>'\n" + + "RULE_PCDATA '\n" + + " '\n" + + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'd'\n" + + "RULE_TAG_CLOSE '>'\n" + + "RULE_PCDATA 'e'\n" + + "RULE_TAG_END_OPEN ''\n" + + "RULE_PCDATA '\n" + + " '\n" + + "RULE_TAG_END_OPEN ''\n" + + "RULE_PCDATA '\n" + + "'\n" + + "RULE_TAG_END_OPEN ''\n"; + assertLexing(model, expectation); + } + + @Test + public void test020() throws Exception { + String model = + "\n" + + " \n" + + " d\n" + + " \n" + + " \n" + + "\n"; + String expectation = + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'a'\n" + + "RULE_TAG_CLOSE '>'\n" + + "RULE_PCDATA '\n" + + " '\n" + + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'b'\n" + + "RULE_TAG_CLOSE '>'\n" + + "RULE_PCDATA '\n" + + " '\n" + + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'c'\n" + + "RULE_TAG_CLOSE '>'\n" + + "RULE_PCDATA 'd'\n" + + "RULE_TAG_END_OPEN ''\n" + + "RULE_PCDATA '\n" + + " '\n" + + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'd'\n" + + "RULE_TAG_EMPTY_CLOSE '/>'\n" + + "RULE_PCDATA '\n" + + " '\n" + + "RULE_TAG_END_OPEN ''\n" + + "RULE_PCDATA '\n" + + "'\n" + + "RULE_TAG_END_OPEN ''\n"; + assertLexing(model, expectation); + } + + @Test + public void test021() throws Exception { + String model = + "\n" + + " \n" + + " d\n" + + " \n" + + " h\n" + + " \n" + + "\n"; + String expectation = + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'a'\n" + + "RULE_TAG_CLOSE '>'\n" + + "RULE_PCDATA '\n" + + " '\n" + + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'b'\n" + + "RULE_TAG_CLOSE '>'\n" + + "RULE_PCDATA '\n" + + " '\n" + + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'c'\n" + + "RULE_TAG_CLOSE '>'\n" + + "RULE_PCDATA 'd'\n" + + "RULE_TAG_END_OPEN ''\n" + + "RULE_PCDATA '\n" + + " '\n" + + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'd'\n" + + "RULE_WS ' '\n" + + "RULE_ID 'e'\n" + + "RULE_ATTR_EQ '='\n" + + "RULE_STRING ''f''\n" + + "RULE_TAG_EMPTY_CLOSE '/>'\n" + + "RULE_PCDATA '\n" + + " '\n" + + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'g'\n" + + "RULE_TAG_CLOSE '>'\n" + + "RULE_PCDATA 'h'\n" + + "RULE_TAG_END_OPEN ''\n" + + "RULE_PCDATA '\n" + + " '\n" + + "RULE_TAG_END_OPEN ''\n" + + "RULE_PCDATA '\n" + + "'\n" + + "RULE_TAG_END_OPEN ''\n"; + assertLexing(model, expectation); + } + + @Test + public void test022() throws Exception { + String model = "\n"; + String expectation = + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'a'\n" + + "RULE_WS ' '\n" + + "RULE_ID 'b'\n" + + "RULE_ATTR_EQ '='\n" + + "0 '\"'\n" + + "RULE_TAG_EMPTY_CLOSE '/>'\n"; + assertLexing(model, expectation); + } +} diff --git a/org.eclipse.xtext.ui.tests/tests/org/eclipse/xtext/ui/tests/xmleditor/AbstractXmlLexerTest.xtend b/org.eclipse.xtext.ui.tests/tests/org/eclipse/xtext/ui/tests/xmleditor/AbstractXmlLexerTest.xtend deleted file mode 100644 index a06da19beb..0000000000 --- a/org.eclipse.xtext.ui.tests/tests/org/eclipse/xtext/ui/tests/xmleditor/AbstractXmlLexerTest.xtend +++ /dev/null @@ -1,517 +0,0 @@ -package org.eclipse.xtext.ui.tests.xmleditor - -import org.junit.Rule -import org.junit.Test -import org.junit.rules.Timeout - -abstract class AbstractXmlLexerTest extends AbstractLexerTest { - - @Rule public val timeout = Timeout.seconds(2) - - @Test def test001() throws Exception { - ''''''.assertLexing('''''') - } - - @Test def test002() throws Exception { - ''' - - ''' - .assertLexing(''' - RULE_TAG_START_OPEN '<' - RULE_ID 'a' - RULE_TAG_EMPTY_CLOSE '/>' - ''') - } - - @Test def test003() throws Exception { - ''' - - ''' - .assertLexing(''' - RULE_TAG_START_OPEN '<' - RULE_ID 'a' - RULE_WS ' ' - RULE_ID 'b' - RULE_ATTR_EQ '=' - RULE_STRING '""' - RULE_TAG_EMPTY_CLOSE '/>' - ''') - } - - @Test def test004() throws Exception { - ''' - - ''' - .assertLexing(''' - RULE_TAG_START_OPEN '<' - RULE_ID 'a' - RULE_WS ' ' - RULE_ID 'b' - RULE_ATTR_EQ '=' - RULE_STRING '"c"' - RULE_TAG_EMPTY_CLOSE '/>' - ''') - } - - @Test def test005() throws Exception { - ''' - - ''' - .assertLexing(''' - RULE_TAG_START_OPEN '<' - RULE_ID 'a' - RULE_WS ' ' - RULE_ID 'b' - RULE_ATTR_EQ '=' - RULE_STRING ''c'' - RULE_TAG_EMPTY_CLOSE '/>' - ''') - } - - @Test def test006() throws Exception { - ''' - - ''' - .assertLexing(''' - RULE_TAG_START_OPEN '<' - RULE_ID 'a' - RULE_WS ' ' - RULE_ID 'b' - RULE_ATTR_EQ '=' - RULE_STRING '"c"' - RULE_WS ' ' - RULE_ID 'd' - RULE_ATTR_EQ '=' - RULE_STRING ''e'' - RULE_TAG_EMPTY_CLOSE '/>' - ''') - } - - @Test def test007() throws Exception { - ''' - - ''' - .assertLexing(''' - RULE_TAG_START_OPEN '<' - RULE_ID 'a' - RULE_WS ' ' - RULE_ID 'b' - RULE_ATTR_EQ '=' - RULE_STRING ''c'' - RULE_WS ' ' - RULE_ID 'd' - RULE_ATTR_EQ '=' - RULE_STRING '"e"' - RULE_TAG_EMPTY_CLOSE '/>' - ''') - } - - @Test def test008() throws Exception { - ''' - - ''' - .assertLexing(''' - RULE_TAG_START_OPEN '<' - RULE_ID 'a' - RULE_TAG_CLOSE '>' - RULE_TAG_END_OPEN '' - ''') - } - - @Test def test009() throws Exception { - ''' - - ''' - .assertLexing(''' - RULE_TAG_START_OPEN '<' - RULE_ID 'a' - RULE_WS ' ' - RULE_ID 'b' - RULE_ATTR_EQ '=' - RULE_STRING '"c"' - RULE_TAG_CLOSE '>' - RULE_TAG_END_OPEN '' - ''') - } - - @Test def test010() throws Exception { - ''' - - ''' - .assertLexing(''' - RULE_TAG_START_OPEN '<' - RULE_ID 'a' - RULE_WS ' ' - RULE_ID 'b' - RULE_ATTR_EQ '=' - RULE_STRING ''c'' - RULE_TAG_CLOSE '>' - RULE_TAG_END_OPEN '' - ''') - } - - @Test def test011() throws Exception { - ''' - - ''' - .assertLexing(''' - RULE_TAG_START_OPEN '<' - RULE_ID 'a' - RULE_WS ' ' - RULE_ID 'b' - RULE_ATTR_EQ '=' - RULE_STRING ''c'' - RULE_WS ' ' - RULE_ID 'd' - RULE_ATTR_EQ '=' - RULE_STRING '"e"' - RULE_TAG_CLOSE '>' - RULE_TAG_END_OPEN '' - ''') - } - - @Test def test012() throws Exception { - ''' - - ''' - .assertLexing(''' - RULE_TAG_START_OPEN '<' - RULE_ID 'a' - RULE_WS ' ' - RULE_ID 'b' - RULE_ATTR_EQ '=' - RULE_STRING '"c"' - RULE_WS ' ' - RULE_ID 'd' - RULE_ATTR_EQ '=' - RULE_STRING ''e'' - RULE_TAG_CLOSE '>' - RULE_TAG_END_OPEN '' - ''') - } - - @Test def test013() throws Exception { - ''' - text - ''' - .assertLexing(''' - RULE_TAG_START_OPEN '<' - RULE_ID 'a' - RULE_TAG_CLOSE '>' - RULE_PCDATA 'text' - RULE_TAG_END_OPEN '' - ''') - } - - @Test def test014() throws Exception { - ''' - text - ''' - .assertLexing(''' - RULE_TAG_START_OPEN '<' - RULE_ID 'a' - RULE_WS ' ' - RULE_ID 'b' - RULE_ATTR_EQ '=' - RULE_STRING '"c"' - RULE_TAG_CLOSE '>' - RULE_PCDATA 'text' - RULE_TAG_END_OPEN '' - ''') - } - - @Test def test015() throws Exception { - ''' - - text - - '''.assertLexing(''' - RULE_TAG_START_OPEN '<' - RULE_ID 'a' - RULE_TAG_CLOSE '>' - RULE_PCDATA ' - ' - RULE_TAG_START_OPEN '<' - RULE_ID 'b' - RULE_TAG_CLOSE '>' - RULE_PCDATA 'text' - RULE_TAG_END_OPEN '' - RULE_PCDATA ' - ' - RULE_TAG_END_OPEN '' - ''') - } - - @Test def test016() throws Exception { - ''' - - - - '''.assertLexing(''' - RULE_TAG_START_OPEN '<' - RULE_ID 'a' - RULE_TAG_CLOSE '>' - RULE_PCDATA ' - ' - RULE_TAG_START_OPEN '<' - RULE_ID 'b' - RULE_TAG_EMPTY_CLOSE '/>' - RULE_PCDATA ' - ' - RULE_TAG_END_OPEN '' - ''') - } - - @Test def test017() throws Exception { - ''' - - - - '''.assertLexing(''' - RULE_TAG_START_OPEN '<' - RULE_ID 'a' - RULE_WS ' ' - RULE_ID 'b' - RULE_ATTR_EQ '=' - RULE_STRING '"c"' - RULE_TAG_CLOSE '>' - RULE_PCDATA ' - ' - RULE_TAG_START_OPEN '<' - RULE_ID 'd' - RULE_WS ' ' - RULE_ID 'e' - RULE_ATTR_EQ '=' - RULE_STRING '"f"' - RULE_TAG_EMPTY_CLOSE '/>' - RULE_PCDATA ' - ' - RULE_TAG_END_OPEN '' - ''') - } - - @Test def test018() throws Exception { - ''' - - c - e - - - '''.assertLexing(''' - RULE_TAG_START_OPEN '<' - RULE_ID 'a' - RULE_TAG_CLOSE '>' - RULE_PCDATA ' - ' - RULE_TAG_START_OPEN '<' - RULE_ID 'b' - RULE_TAG_CLOSE '>' - RULE_PCDATA 'c' - RULE_TAG_END_OPEN '' - RULE_PCDATA ' - ' - RULE_TAG_START_OPEN '<' - RULE_ID 'd' - RULE_TAG_CLOSE '>' - RULE_PCDATA 'e' - RULE_TAG_END_OPEN '' - RULE_PCDATA ' - ' - RULE_TAG_START_OPEN '<' - RULE_ID 'f' - RULE_TAG_EMPTY_CLOSE '/>' - RULE_PCDATA ' - ' - RULE_TAG_END_OPEN '' - ''') - } - - @Test def test019() throws Exception { - ''' - - - - e - - - '''.assertLexing(''' - RULE_TAG_START_OPEN '<' - RULE_ID 'a' - RULE_TAG_CLOSE '>' - RULE_PCDATA ' - ' - RULE_TAG_START_OPEN '<' - RULE_ID 'b' - RULE_TAG_CLOSE '>' - RULE_PCDATA ' - ' - RULE_TAG_START_OPEN '<' - RULE_ID 'c' - RULE_TAG_EMPTY_CLOSE '/>' - RULE_PCDATA ' - ' - RULE_TAG_START_OPEN '<' - RULE_ID 'd' - RULE_TAG_CLOSE '>' - RULE_PCDATA 'e' - RULE_TAG_END_OPEN '' - RULE_PCDATA ' - ' - RULE_TAG_END_OPEN '' - RULE_PCDATA ' - ' - RULE_TAG_END_OPEN '' - ''') - } - - @Test def test020() throws Exception { - ''' - - - d - - - - '''.assertLexing(''' - RULE_TAG_START_OPEN '<' - RULE_ID 'a' - RULE_TAG_CLOSE '>' - RULE_PCDATA ' - ' - RULE_TAG_START_OPEN '<' - RULE_ID 'b' - RULE_TAG_CLOSE '>' - RULE_PCDATA ' - ' - RULE_TAG_START_OPEN '<' - RULE_ID 'c' - RULE_TAG_CLOSE '>' - RULE_PCDATA 'd' - RULE_TAG_END_OPEN '' - RULE_PCDATA ' - ' - RULE_TAG_START_OPEN '<' - RULE_ID 'd' - RULE_TAG_EMPTY_CLOSE '/>' - RULE_PCDATA ' - ' - RULE_TAG_END_OPEN '' - RULE_PCDATA ' - ' - RULE_TAG_END_OPEN '' - ''') - } - - @Test def test021() throws Exception { - ''' - - - d - - h - - - '''.assertLexing(''' - RULE_TAG_START_OPEN '<' - RULE_ID 'a' - RULE_TAG_CLOSE '>' - RULE_PCDATA ' - ' - RULE_TAG_START_OPEN '<' - RULE_ID 'b' - RULE_TAG_CLOSE '>' - RULE_PCDATA ' - ' - RULE_TAG_START_OPEN '<' - RULE_ID 'c' - RULE_TAG_CLOSE '>' - RULE_PCDATA 'd' - RULE_TAG_END_OPEN '' - RULE_PCDATA ' - ' - RULE_TAG_START_OPEN '<' - RULE_ID 'd' - RULE_WS ' ' - RULE_ID 'e' - RULE_ATTR_EQ '=' - RULE_STRING ''f'' - RULE_TAG_EMPTY_CLOSE '/>' - RULE_PCDATA ' - ' - RULE_TAG_START_OPEN '<' - RULE_ID 'g' - RULE_TAG_CLOSE '>' - RULE_PCDATA 'h' - RULE_TAG_END_OPEN '' - RULE_PCDATA ' - ' - RULE_TAG_END_OPEN '' - RULE_PCDATA ' - ' - RULE_TAG_END_OPEN '' - ''') - } - - @Test def test022() throws Exception { - ''' - ' - ''') - } -} diff --git a/org.eclipse.xtext.ui.tests/tests/org/eclipse/xtext/ui/tests/xmleditor/XmlContentAssistLexerTests.java b/org.eclipse.xtext.ui.tests/tests/org/eclipse/xtext/ui/tests/xmleditor/XmlContentAssistLexerTests.java new file mode 100644 index 0000000000..0e8ba782c4 --- /dev/null +++ b/org.eclipse.xtext.ui.tests/tests/org/eclipse/xtext/ui/tests/xmleditor/XmlContentAssistLexerTests.java @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2019, 2021 itemis AG (http://www.itemis.eu) and others. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.eclipse.xtext.ui.tests.xmleditor; + +import javax.inject.Inject; +import javax.inject.Named; +import org.eclipse.xtext.ide.editor.contentassist.antlr.internal.Lexer; +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.XtextRunner; +import org.eclipse.xtext.ui.LexerUIBindings; +import org.eclipse.xtext.ui.tests.xmleditor.ui.tests.XmlUiInjectorProvider; +import org.junit.runner.RunWith; + +@RunWith(XtextRunner.class) +@InjectWith(XmlUiInjectorProvider.class) +public class XmlContentAssistLexerTests extends AbstractXmlLexerTest { + @Inject + @Named(LexerUIBindings.CONTENT_ASSIST) + private Lexer lexer; + + @Override + public org.antlr.runtime.Lexer lexer() { + return lexer; + } + + @Override + public void test022() throws Exception { + String modelAsText = "\n"; + String expectation = + "RULE_TAG_START_OPEN '<'\n" + + "RULE_ID 'a'\n" + + "RULE_WS ' '\n" + + "RULE_ID 'b'\n" + + "RULE_ATTR_EQ '='\n" + + // The content assist lexer produces different tokens than the parser/highlighting lexer + // 0 '\"'\n" + + "RULE_TAG_EMPTY_CLOSE '/>'\n"; + assertLexing(modelAsText, expectation); + } +} diff --git a/org.eclipse.xtext.ui.tests/tests/org/eclipse/xtext/ui/tests/xmleditor/XmlContentAssistLexerTests.xtend b/org.eclipse.xtext.ui.tests/tests/org/eclipse/xtext/ui/tests/xmleditor/XmlContentAssistLexerTests.xtend deleted file mode 100644 index a8ce64bbb5..0000000000 --- a/org.eclipse.xtext.ui.tests/tests/org/eclipse/xtext/ui/tests/xmleditor/XmlContentAssistLexerTests.xtend +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (c) 2019, 2020 itemis AG (http://www.itemis.eu) and others. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.xtext.ui.tests.xmleditor - -import javax.inject.Inject -import javax.inject.Named -import org.eclipse.xtext.ide.editor.contentassist.antlr.internal.Lexer -import org.eclipse.xtext.testing.InjectWith -import org.eclipse.xtext.testing.XtextRunner -import org.eclipse.xtext.ui.LexerUIBindings -import org.junit.runner.RunWith -import org.eclipse.xtext.ui.tests.xmleditor.ui.tests.XmlUiInjectorProvider - -@RunWith(XtextRunner) -@InjectWith(XmlUiInjectorProvider) -class XmlContentAssistLexerTests extends AbstractXmlLexerTest { - - @Inject @Named(LexerUIBindings.CONTENT_ASSIST) Lexer lexer - - override lexer() { - lexer - } - - override test022() throws Exception { - ''' - ' - ''') - } -} diff --git a/org.eclipse.xtext.ui.tests/xtend-gen/org/eclipse/xtext/ui/tests/xmleditor/AbstractXmlLexerTest.java b/org.eclipse.xtext.ui.tests/xtend-gen/org/eclipse/xtext/ui/tests/xmleditor/AbstractXmlLexerTest.java deleted file mode 100644 index bd7a7725d0..0000000000 --- a/org.eclipse.xtext.ui.tests/xtend-gen/org/eclipse/xtext/ui/tests/xmleditor/AbstractXmlLexerTest.java +++ /dev/null @@ -1,930 +0,0 @@ -package org.eclipse.xtext.ui.tests.xmleditor; - -import org.eclipse.xtend2.lib.StringConcatenation; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.Timeout; - -@SuppressWarnings("all") -public abstract class AbstractXmlLexerTest extends AbstractLexerTest { - @Rule - public final Timeout timeout = Timeout.seconds(2); - - @Test - public void test001() throws Exception { - StringConcatenation _builder = new StringConcatenation(); - StringConcatenation _builder_1 = new StringConcatenation(); - this.assertLexing(_builder, _builder_1); - } - - @Test - public void test002() throws Exception { - StringConcatenation _builder = new StringConcatenation(); - _builder.append(""); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'a\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_EMPTY_CLOSE \'/>\'"); - _builder_1.newLine(); - this.assertLexing(_builder, _builder_1); - } - - @Test - public void test003() throws Exception { - StringConcatenation _builder = new StringConcatenation(); - _builder.append(""); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'a\'"); - _builder_1.newLine(); - _builder_1.append("RULE_WS \' \'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'b\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ATTR_EQ \'=\'"); - _builder_1.newLine(); - _builder_1.append("RULE_STRING \'\"\"\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_EMPTY_CLOSE \'/>\'"); - _builder_1.newLine(); - this.assertLexing(_builder, _builder_1); - } - - @Test - public void test004() throws Exception { - StringConcatenation _builder = new StringConcatenation(); - _builder.append(""); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'a\'"); - _builder_1.newLine(); - _builder_1.append("RULE_WS \' \'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'b\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ATTR_EQ \'=\'"); - _builder_1.newLine(); - _builder_1.append("RULE_STRING \'\"c\"\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_EMPTY_CLOSE \'/>\'"); - _builder_1.newLine(); - this.assertLexing(_builder, _builder_1); - } - - @Test - public void test005() throws Exception { - StringConcatenation _builder = new StringConcatenation(); - _builder.append(""); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'a\'"); - _builder_1.newLine(); - _builder_1.append("RULE_WS \' \'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'b\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ATTR_EQ \'=\'"); - _builder_1.newLine(); - _builder_1.append("RULE_STRING \'\'c\'\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_EMPTY_CLOSE \'/>\'"); - _builder_1.newLine(); - this.assertLexing(_builder, _builder_1); - } - - @Test - public void test006() throws Exception { - StringConcatenation _builder = new StringConcatenation(); - _builder.append(""); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'a\'"); - _builder_1.newLine(); - _builder_1.append("RULE_WS \' \'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'b\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ATTR_EQ \'=\'"); - _builder_1.newLine(); - _builder_1.append("RULE_STRING \'\"c\"\'"); - _builder_1.newLine(); - _builder_1.append("RULE_WS \' \'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'d\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ATTR_EQ \'=\'"); - _builder_1.newLine(); - _builder_1.append("RULE_STRING \'\'e\'\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_EMPTY_CLOSE \'/>\'"); - _builder_1.newLine(); - this.assertLexing(_builder, _builder_1); - } - - @Test - public void test007() throws Exception { - StringConcatenation _builder = new StringConcatenation(); - _builder.append(""); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'a\'"); - _builder_1.newLine(); - _builder_1.append("RULE_WS \' \'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'b\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ATTR_EQ \'=\'"); - _builder_1.newLine(); - _builder_1.append("RULE_STRING \'\'c\'\'"); - _builder_1.newLine(); - _builder_1.append("RULE_WS \' \'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'d\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ATTR_EQ \'=\'"); - _builder_1.newLine(); - _builder_1.append("RULE_STRING \'\"e\"\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_EMPTY_CLOSE \'/>\'"); - _builder_1.newLine(); - this.assertLexing(_builder, _builder_1); - } - - @Test - public void test008() throws Exception { - StringConcatenation _builder = new StringConcatenation(); - _builder.append(""); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'a\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_CLOSE \'>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_END_OPEN \'\'"); - _builder_1.newLine(); - this.assertLexing(_builder, _builder_1); - } - - @Test - public void test009() throws Exception { - StringConcatenation _builder = new StringConcatenation(); - _builder.append(""); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'a\'"); - _builder_1.newLine(); - _builder_1.append("RULE_WS \' \'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'b\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ATTR_EQ \'=\'"); - _builder_1.newLine(); - _builder_1.append("RULE_STRING \'\"c\"\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_CLOSE \'>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_END_OPEN \'\'"); - _builder_1.newLine(); - this.assertLexing(_builder, _builder_1); - } - - @Test - public void test010() throws Exception { - StringConcatenation _builder = new StringConcatenation(); - _builder.append(""); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'a\'"); - _builder_1.newLine(); - _builder_1.append("RULE_WS \' \'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'b\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ATTR_EQ \'=\'"); - _builder_1.newLine(); - _builder_1.append("RULE_STRING \'\'c\'\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_CLOSE \'>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_END_OPEN \'\'"); - _builder_1.newLine(); - this.assertLexing(_builder, _builder_1); - } - - @Test - public void test011() throws Exception { - StringConcatenation _builder = new StringConcatenation(); - _builder.append(""); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'a\'"); - _builder_1.newLine(); - _builder_1.append("RULE_WS \' \'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'b\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ATTR_EQ \'=\'"); - _builder_1.newLine(); - _builder_1.append("RULE_STRING \'\'c\'\'"); - _builder_1.newLine(); - _builder_1.append("RULE_WS \' \'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'d\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ATTR_EQ \'=\'"); - _builder_1.newLine(); - _builder_1.append("RULE_STRING \'\"e\"\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_CLOSE \'>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_END_OPEN \'\'"); - _builder_1.newLine(); - this.assertLexing(_builder, _builder_1); - } - - @Test - public void test012() throws Exception { - StringConcatenation _builder = new StringConcatenation(); - _builder.append(""); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'a\'"); - _builder_1.newLine(); - _builder_1.append("RULE_WS \' \'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'b\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ATTR_EQ \'=\'"); - _builder_1.newLine(); - _builder_1.append("RULE_STRING \'\"c\"\'"); - _builder_1.newLine(); - _builder_1.append("RULE_WS \' \'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'d\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ATTR_EQ \'=\'"); - _builder_1.newLine(); - _builder_1.append("RULE_STRING \'\'e\'\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_CLOSE \'>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_END_OPEN \'\'"); - _builder_1.newLine(); - this.assertLexing(_builder, _builder_1); - } - - @Test - public void test013() throws Exception { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("text"); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'a\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_CLOSE \'>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'text\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_END_OPEN \'\'"); - _builder_1.newLine(); - this.assertLexing(_builder, _builder_1); - } - - @Test - public void test014() throws Exception { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("text"); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'a\'"); - _builder_1.newLine(); - _builder_1.append("RULE_WS \' \'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'b\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ATTR_EQ \'=\'"); - _builder_1.newLine(); - _builder_1.append("RULE_STRING \'\"c\"\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_CLOSE \'>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'text\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_END_OPEN \'\'"); - _builder_1.newLine(); - this.assertLexing(_builder, _builder_1); - } - - @Test - public void test015() throws Exception { - StringConcatenation _builder = new StringConcatenation(); - _builder.append(""); - _builder.newLine(); - _builder.append("\t"); - _builder.append("text"); - _builder.newLine(); - _builder.append(""); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'a\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_CLOSE \'>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'b\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_CLOSE \'>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'text\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_END_OPEN \'\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_END_OPEN \'\'"); - _builder_1.newLine(); - this.assertLexing(_builder, _builder_1); - } - - @Test - public void test016() throws Exception { - StringConcatenation _builder = new StringConcatenation(); - _builder.append(""); - _builder.newLine(); - _builder.append("\t"); - _builder.append(""); - _builder.newLine(); - _builder.append(""); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'a\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_CLOSE \'>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'b\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_EMPTY_CLOSE \'/>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_END_OPEN \'\'"); - _builder_1.newLine(); - this.assertLexing(_builder, _builder_1); - } - - @Test - public void test017() throws Exception { - StringConcatenation _builder = new StringConcatenation(); - _builder.append(""); - _builder.newLine(); - _builder.append("\t"); - _builder.append(""); - _builder.newLine(); - _builder.append(""); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'a\'"); - _builder_1.newLine(); - _builder_1.append("RULE_WS \' \'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'b\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ATTR_EQ \'=\'"); - _builder_1.newLine(); - _builder_1.append("RULE_STRING \'\"c\"\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_CLOSE \'>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'d\'"); - _builder_1.newLine(); - _builder_1.append("RULE_WS \' \'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'e\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ATTR_EQ \'=\'"); - _builder_1.newLine(); - _builder_1.append("RULE_STRING \'\"f\"\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_EMPTY_CLOSE \'/>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_END_OPEN \'\'"); - _builder_1.newLine(); - this.assertLexing(_builder, _builder_1); - } - - @Test - public void test018() throws Exception { - StringConcatenation _builder = new StringConcatenation(); - _builder.append(""); - _builder.newLine(); - _builder.append("\t"); - _builder.append("c"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("e"); - _builder.newLine(); - _builder.append("\t"); - _builder.append(""); - _builder.newLine(); - _builder.append(""); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'a\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_CLOSE \'>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'b\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_CLOSE \'>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'c\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_END_OPEN \'\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'d\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_CLOSE \'>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'e\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_END_OPEN \'\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'f\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_EMPTY_CLOSE \'/>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_END_OPEN \'\'"); - _builder_1.newLine(); - this.assertLexing(_builder, _builder_1); - } - - @Test - public void test019() throws Exception { - StringConcatenation _builder = new StringConcatenation(); - _builder.append(""); - _builder.newLine(); - _builder.append("\t"); - _builder.append(""); - _builder.newLine(); - _builder.append("\t"); - _builder.append(""); - _builder.newLine(); - _builder.append("\t"); - _builder.append("e"); - _builder.newLine(); - _builder.append("\t"); - _builder.append(""); - _builder.newLine(); - _builder.append(""); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'a\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_CLOSE \'>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'b\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_CLOSE \'>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'c\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_EMPTY_CLOSE \'/>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'d\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_CLOSE \'>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'e\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_END_OPEN \'\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_END_OPEN \'\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_END_OPEN \'\'"); - _builder_1.newLine(); - this.assertLexing(_builder, _builder_1); - } - - @Test - public void test020() throws Exception { - StringConcatenation _builder = new StringConcatenation(); - _builder.append(""); - _builder.newLine(); - _builder.append("\t"); - _builder.append(""); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("d"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append(""); - _builder.newLine(); - _builder.append("\t"); - _builder.append(""); - _builder.newLine(); - _builder.append(""); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'a\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_CLOSE \'>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'b\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_CLOSE \'>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'c\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_CLOSE \'>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'d\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_END_OPEN \'\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'d\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_EMPTY_CLOSE \'/>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_END_OPEN \'\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_END_OPEN \'\'"); - _builder_1.newLine(); - this.assertLexing(_builder, _builder_1); - } - - @Test - public void test021() throws Exception { - StringConcatenation _builder = new StringConcatenation(); - _builder.append(""); - _builder.newLine(); - _builder.append("\t"); - _builder.append(""); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("d"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append(""); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("h"); - _builder.newLine(); - _builder.append("\t"); - _builder.append(""); - _builder.newLine(); - _builder.append(""); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'a\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_CLOSE \'>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'b\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_CLOSE \'>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'c\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_CLOSE \'>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'d\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_END_OPEN \'\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'d\'"); - _builder_1.newLine(); - _builder_1.append("RULE_WS \' \'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'e\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ATTR_EQ \'=\'"); - _builder_1.newLine(); - _builder_1.append("RULE_STRING \'\'f\'\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_EMPTY_CLOSE \'/>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'g\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_CLOSE \'>\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'h\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_END_OPEN \'\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_END_OPEN \'\'"); - _builder_1.newLine(); - _builder_1.append("RULE_PCDATA \'"); - _builder_1.newLine(); - _builder_1.append("\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_END_OPEN \'\'"); - _builder_1.newLine(); - this.assertLexing(_builder, _builder_1); - } - - @Test - public void test022() throws Exception { - StringConcatenation _builder = new StringConcatenation(); - _builder.append(""); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'a\'"); - _builder_1.newLine(); - _builder_1.append("RULE_WS \' \'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'b\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ATTR_EQ \'=\'"); - _builder_1.newLine(); - _builder_1.append("0 \'\"\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_EMPTY_CLOSE \'/>\'"); - _builder_1.newLine(); - this.assertLexing(_builder, _builder_1); - } -} diff --git a/org.eclipse.xtext.ui.tests/xtend-gen/org/eclipse/xtext/ui/tests/xmleditor/XmlContentAssistLexerTests.java b/org.eclipse.xtext.ui.tests/xtend-gen/org/eclipse/xtext/ui/tests/xmleditor/XmlContentAssistLexerTests.java deleted file mode 100644 index 8c26482a09..0000000000 --- a/org.eclipse.xtext.ui.tests/xtend-gen/org/eclipse/xtext/ui/tests/xmleditor/XmlContentAssistLexerTests.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) 2019, 2020 itemis AG (http://www.itemis.eu) and others. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.xtext.ui.tests.xmleditor; - -import javax.inject.Inject; -import javax.inject.Named; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.ide.editor.contentassist.antlr.internal.Lexer; -import org.eclipse.xtext.testing.InjectWith; -import org.eclipse.xtext.testing.XtextRunner; -import org.eclipse.xtext.ui.LexerUIBindings; -import org.eclipse.xtext.ui.tests.xmleditor.ui.tests.XmlUiInjectorProvider; -import org.junit.runner.RunWith; - -@RunWith(XtextRunner.class) -@InjectWith(XmlUiInjectorProvider.class) -@SuppressWarnings("all") -public class XmlContentAssistLexerTests extends AbstractXmlLexerTest { - @Inject - @Named(LexerUIBindings.CONTENT_ASSIST) - private Lexer lexer; - - @Override - public org.antlr.runtime.Lexer lexer() { - return this.lexer; - } - - @Override - public void test022() throws Exception { - StringConcatenation _builder = new StringConcatenation(); - _builder.append(""); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("RULE_TAG_START_OPEN \'<\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'a\'"); - _builder_1.newLine(); - _builder_1.append("RULE_WS \' \'"); - _builder_1.newLine(); - _builder_1.append("RULE_ID \'b\'"); - _builder_1.newLine(); - _builder_1.append("RULE_ATTR_EQ \'=\'"); - _builder_1.newLine(); - _builder_1.append("RULE_TAG_EMPTY_CLOSE \'/>\'"); - _builder_1.newLine(); - this.assertLexing(_builder, _builder_1); - } -} diff --git a/org.eclipse.xtext.xtext.ui.tests/.classpath b/org.eclipse.xtext.xtext.ui.tests/.classpath index b54fbad350..2075df999a 100644 --- a/org.eclipse.xtext.xtext.ui.tests/.classpath +++ b/org.eclipse.xtext.xtext.ui.tests/.classpath @@ -3,7 +3,6 @@ - diff --git a/org.eclipse.xtext.xtext.ui.tests/build.properties b/org.eclipse.xtext.xtext.ui.tests/build.properties index 54fe9e9066..6db48f04de 100644 --- a/org.eclipse.xtext.xtext.ui.tests/build.properties +++ b/org.eclipse.xtext.xtext.ui.tests/build.properties @@ -6,8 +6,7 @@ bin.includes = .,\ source.. = emf-gen/,\ src/,\ src-gen/,\ - src-longrunning/,\ - xtend-gen/ + src-longrunning/ output.. = bin/ src.excludes = generator/ src.includes = about.html diff --git a/org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/quickfix/XtextGrammarQuickfixTest.java b/org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/quickfix/XtextGrammarQuickfixTest.java new file mode 100644 index 0000000000..e01423b7d1 --- /dev/null +++ b/org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/quickfix/XtextGrammarQuickfixTest.java @@ -0,0 +1,242 @@ +/** + * Copyright (c) 2019, 2021 RCP Vision s.r.l. (http://www.rcp-vision.com) and others. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.eclipse.xtext.xtext.ui.editor.quickfix; + +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.XtextRunner; +import org.eclipse.xtext.ui.editor.quickfix.IssueResolution; +import org.eclipse.xtext.ui.testing.AbstractQuickfixTest; +import org.eclipse.xtext.util.Strings; +import org.eclipse.xtext.xtext.XtextConfigurableIssueCodes; +import org.eclipse.xtext.xtext.ui.XtextUiInjectorProvider; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * @author loradd - Initial contribution and API + */ +@RunWith(XtextRunner.class) +@InjectWith(XtextUiInjectorProvider.class) +public class XtextGrammarQuickfixTest extends AbstractQuickfixTest { + + @Override + protected void assertIssueResolutionResult(String expectedResult, IssueResolution actualIssueResolution, String originalText) { + super.assertIssueResolutionResult(Strings.toPlatformLineSeparator(expectedResult), actualIssueResolution, Strings.toPlatformLineSeparator(originalText)); + } + + @Override + public void testQuickfixesOn(CharSequence content, String issueCode, Quickfix... quickfixes) { + super.testQuickfixesOn(Strings.toPlatformLineSeparator(content), issueCode, quickfixes); + } + + @Test + public void test_convert_terminal_fragment_to_terminal_rule() { + String result1 = + "grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals\n" + + "\n" + + "generate myDsl 'http://www.xtext.org/example/mydsl/MyDsl'\n" + + "\n" + + "Model hidden(ABC):\n" + + " a = ID;\n" + + "\n" + + "terminal ABC:\n" + + " 'a';\n"; + Quickfix quickfix1 = new Quickfix("Convert terminal fragment to terminal rule", "Convert terminal fragment to terminal rule", result1); + String result2 = + "grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals\n" + + "\n" + + "generate myDsl 'http://www.xtext.org/example/mydsl/MyDsl'\n" + + "\n" + + "Model hidden():\n" + + " a = ID;\n" + + "\n" + + "terminal fragment ABC:\n" + + " 'a';\n"; + Quickfix quickfix2 = new Quickfix("Remove hidden token definition", "Remove hidden token definition", result2); + String model = + "grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals\n" + + "\n" + + "generate myDsl 'http://www.xtext.org/example/mydsl/MyDsl'\n" + + "\n" + + "Model hidden(ABC):\n" + + " a = ID;\n" + + "\n" + + "terminal fragment ABC:\n" + + " 'a';\n"; + testQuickfixesOn(model, "org.eclipse.xtext.grammar.InvalidHiddenTokenFragment", quickfix1, quickfix2); + } + + @Test + public void test_convert_terminal_fragment_to_terminal_rule_01() { + String result = + "grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals\n" + + "\n" + + "generate myDsl 'http://www.xtext.org/example/mydsl/MyDsl'\n" + + "\n" + + "Model:\n" + + " a = ABC;\n" + + "\n" + + "terminal ABC:\n" + + " 'a';\n"; + Quickfix quickfix = new Quickfix("Convert terminal fragment to terminal rule", "Convert terminal fragment to terminal rule", result); + String model = + "grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals\n" + + "\n" + + "generate myDsl 'http://www.xtext.org/example/mydsl/MyDsl'\n" + + "\n" + + "Model:\n" + + " a = ABC;\n" + + "\n" + + "terminal fragment ABC:\n" + + " 'a';\n"; + testQuickfixesOn(model, "org.eclipse.xtext.grammar.InvalidTerminalFragmentRuleReference", quickfix); + } + + @Test + public void test_fix_invalid_hidden_token() { + String result = + "grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals\n" + + "\n" + + "generate myDsl 'http://www.xtext.org/example/mydsl/MyDsl'\n" + + "\n" + + "Model hidden():\n" + + " a = ID;\n" + + "\n" + + "AnotherModel:\n" + + " b = ID;\n"; + Quickfix quickfix = new Quickfix("Remove hidden token definition", "Remove hidden token definition", result); + String model = + "grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals\n" + + "\n" + + "generate myDsl 'http://www.xtext.org/example/mydsl/MyDsl'\n" + + "\n" + + "Model hidden(AnotherModel):\n" + + " a = ID;\n" + + "\n" + + "AnotherModel:\n" + + " b = ID;\n"; + testQuickfixesOn(model, "org.eclipse.xtext.grammar.InvalidHiddenToken", quickfix); + } + + @Test + public void test_fix_missing_rule() { + String result1 = + "grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals\n" + + "\n" + + "generate myDsl 'http://www.xtext.org/example/mydsl/MyDsl'\n" + + "\n" + + "Model:\n" + + " greetings+=Greeting*;\n" + + "\n" + + "Greeting:\n" + + " \n" + + ";\n"; + Quickfix quickfix1 = new Quickfix("Create rule 'Greeting'", "Create rule 'Greeting'", result1); + String result2 = + "grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals\n" + + "\n" + + "generate myDsl 'http://www.xtext.org/example/mydsl/MyDsl'\n" + + "\n" + + "Model:\n" + + " greetings+=Greeting*;\n" + + "\n" + + "enum Greeting:\n" + + " \n" + + ";\n"; + Quickfix quickfix2 = new Quickfix("Create enum rule 'Greeting'", "Create enum rule 'Greeting'", result2); + String result3 = + "grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals\n" + + "\n" + + "generate myDsl 'http://www.xtext.org/example/mydsl/MyDsl'\n" + + "\n" + + "Model:\n" + + " greetings+=Greeting*;\n" + + "\n" + + "terminal Greeting:\n" + + " \n" + + ";\n"; + Quickfix quickfix3 = new Quickfix("Create terminal 'Greeting'", "Create terminal 'Greeting'", result3); + String model = + "grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals\n" + + "\n" + + "generate myDsl 'http://www.xtext.org/example/mydsl/MyDsl'\n" + + "\n" + + "Model:\n" + + " greetings+=Greeting*;\n"; + testQuickfixesOn(model, "org.eclipse.xtext.grammar.UnresolvedRule", quickfix1, quickfix2, quickfix3); + } + + @Test + public void test_fix_empty_keyword() { + String result1 = + "grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals\n" + + "generate myDsl 'http://www.xtext.org/mydsl/MyDsl'\n" + + "\n" + + "Model: a=ID;\n"; + String result2 = + "grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals\n" + + "generate myDsl 'http://www.xtext.org/mydsl/MyDsl'\n" + + "\n" + + "Model: \"model\" a=ID;\n"; + String model = + "grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals\n" + + "generate myDsl 'http://www.xtext.org/mydsl/MyDsl'\n" + + "\n" + + "Model: \"\" a=ID;\n"; + testQuickfixesOn( + model, + XtextConfigurableIssueCodes.EMPTY_KEYWORD, removeEmptyKeywordQuickfix(result1), + replaceEmptyKeywordWithRuleNameQuickfix(result2)); + } + + @Test + public void fix_keyword_with_spaces() { + String model = + "grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals\n" + + "generate myDsl 'http://www.xtext.org/mydsl/MyDsl'\n" + + "\n" + + "Model: ' a b c d ' a=ID;\n"; + String result = + "grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals\n" + + "generate myDsl 'http://www.xtext.org/mydsl/MyDsl'\n" + + "\n" + + "Model: 'a' 'b' 'c' 'd' a=ID;\n"; + applyKeywordWithSpacesQuickfix(model, result); + } + + @Test + public void fix_empty_keyword_with_spaces() { + String model = + "grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals\n" + + "generate myDsl 'http://www.xtext.org/mydsl/MyDsl'\n" + + "\n" + + "Model: ' ' a=ID;\n"; + String result = + "grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals\n" + + "generate myDsl 'http://www.xtext.org/mydsl/MyDsl'\n" + + "\n" + + "Model: 'model' a=ID;\n"; + applyKeywordWithSpacesQuickfix(model, result); + } + + private Quickfix removeEmptyKeywordQuickfix(final String result) { + return new Quickfix("Remove empty keyword", "Remove empty keyword", result); + } + + private Quickfix replaceEmptyKeywordWithRuleNameQuickfix(final String result) { + return new Quickfix("Replace empty keyword with rule name", "Replace empty keyword with rule name", result); + } + + private void applyKeywordWithSpacesQuickfix(final CharSequence input, final String result) { + String issueCode = XtextConfigurableIssueCodes.SPACES_IN_KEYWORD; + String label = "Fix keyword with spaces"; + String description = "Fix keyword with spaces"; + testQuickfixesOn(input, issueCode, new Quickfix(label, description, result)); + } +} diff --git a/org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/quickfix/XtextGrammarQuickfixTest.xtend b/org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/quickfix/XtextGrammarQuickfixTest.xtend deleted file mode 100644 index 8ef9450c43..0000000000 --- a/org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/quickfix/XtextGrammarQuickfixTest.xtend +++ /dev/null @@ -1,235 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2019, 2020 RCP Vision s.r.l. (http://www.rcp-vision.com) and others. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - *******************************************************************************/ -package org.eclipse.xtext.xtext.ui.editor.quickfix - -import org.eclipse.xtext.testing.InjectWith -import org.eclipse.xtext.testing.XtextRunner -import org.eclipse.xtext.ui.testing.AbstractQuickfixTest -import org.eclipse.xtext.xtext.ui.XtextUiInjectorProvider -import org.junit.Test -import org.junit.runner.RunWith - -import static org.eclipse.xtext.xtext.XtextConfigurableIssueCodes.EMPTY_KEYWORD -import static org.eclipse.xtext.xtext.XtextConfigurableIssueCodes.SPACES_IN_KEYWORD - -/** - * @author loradd - Initial contribution and API - */ -@RunWith(XtextRunner) -@InjectWith(XtextUiInjectorProvider) -class XtextGrammarQuickfixTest extends AbstractQuickfixTest { - - @Test def test_convert_terminal_fragment_to_terminal_rule() { - ''' - grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals - - generate myDsl "http://www.xtext.org/example/mydsl/MyDsl" - - Model hidden(ABC): - a = ID; - - terminal fragment ABC: - 'a'; - '''.testQuickfixesOn( - "org.eclipse.xtext.grammar.InvalidHiddenTokenFragment", - new Quickfix("Convert terminal fragment to terminal rule", "Convert terminal fragment to terminal rule", ''' - grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals - - generate myDsl "http://www.xtext.org/example/mydsl/MyDsl" - - Model hidden(ABC): - a = ID; - - terminal ABC: - 'a'; - '''), - new Quickfix("Remove hidden token definition", "Remove hidden token definition", ''' - grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals - - generate myDsl "http://www.xtext.org/example/mydsl/MyDsl" - - Model hidden(): - a = ID; - - terminal fragment ABC: - 'a'; - ''') - ); - } - - @Test def test_convert_terminal_fragment_to_terminal_rule_01() { - ''' - grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals - - generate myDsl "http://www.xtext.org/example/mydsl/MyDsl" - - Model: - a = ABC; - - terminal fragment ABC: - 'a'; - '''.testQuickfixesOn( - "org.eclipse.xtext.grammar.InvalidTerminalFragmentRuleReference", - new Quickfix("Convert terminal fragment to terminal rule", "Convert terminal fragment to terminal rule", ''' - grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals - - generate myDsl "http://www.xtext.org/example/mydsl/MyDsl" - - Model: - a = ABC; - - terminal ABC: - 'a'; - ''') - ); - } - - @Test def test_fix_invalid_hidden_token() { - ''' - grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals - - generate myDsl "http://www.xtext.org/example/mydsl/MyDsl" - - Model hidden(AnotherModel): - a = ID; - - AnotherModel: - b = ID; - '''.testQuickfixesOn( - "org.eclipse.xtext.grammar.InvalidHiddenToken", - new Quickfix("Remove hidden token definition", "Remove hidden token definition", ''' - grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals - - generate myDsl "http://www.xtext.org/example/mydsl/MyDsl" - - Model hidden(): - a = ID; - - AnotherModel: - b = ID; - ''') - ); - } - - @Test def test_fix_missing_rule() { - ''' - grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals - - generate myDsl "http://www.xtext.org/example/mydsl/MyDsl" - - Model: - greetings+=Greeting*; - '''.testQuickfixesOn( - "org.eclipse.xtext.grammar.UnresolvedRule", - new Quickfix("Create rule 'Greeting'", "Create rule 'Greeting'", ''' - grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals - - generate myDsl "http://www.xtext.org/example/mydsl/MyDsl" - - Model: - greetings+=Greeting*; - - Greeting: - - ; - '''), - new Quickfix("Create enum rule 'Greeting'", "Create enum rule 'Greeting'", ''' - grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals - - generate myDsl "http://www.xtext.org/example/mydsl/MyDsl" - - Model: - greetings+=Greeting*; - - enum Greeting: - - ; - '''), - new Quickfix("Create terminal 'Greeting'", "Create terminal 'Greeting'", ''' - grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals - - generate myDsl "http://www.xtext.org/example/mydsl/MyDsl" - - Model: - greetings+=Greeting*; - - terminal Greeting: - - ; - ''') - ); - } - - @Test def test_fix_empty_keyword() { - ''' - grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals - generate myDsl "http://www.xtext.org/mydsl/MyDsl" - - Model: "" a=ID; - ''' - .testQuickfixesOn(EMPTY_KEYWORD, - removeEmptyKeywordQuickfix(''' - grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals - generate myDsl "http://www.xtext.org/mydsl/MyDsl" - - Model: a=ID; - '''), - replaceEmptyKeywordWithRuleNameQuickfix(''' - grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals - generate myDsl "http://www.xtext.org/mydsl/MyDsl" - - Model: "model" a=ID; - ''') - ); - } - - @Test def fix_keyword_with_spaces() { - ''' - grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals - generate myDsl "http://www.xtext.org/mydsl/MyDsl" - - Model: ' a b c d ' a=ID; - '''.applyKeywordWithSpacesQuickfix(''' - grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals - generate myDsl "http://www.xtext.org/mydsl/MyDsl" - - Model: 'a' 'b' 'c' 'd' a=ID; - ''') - } - - @Test def fix_empty_keyword_with_spaces() { - ''' - grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals - generate myDsl "http://www.xtext.org/mydsl/MyDsl" - - Model: ' ' a=ID; - '''.applyKeywordWithSpacesQuickfix(''' - grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals - generate myDsl "http://www.xtext.org/mydsl/MyDsl" - - Model: 'model' a=ID; - ''') - } - - private def removeEmptyKeywordQuickfix(String result) { - new Quickfix("Remove empty keyword", "Remove empty keyword", result) - } - - private def replaceEmptyKeywordWithRuleNameQuickfix(String result) { - new Quickfix("Replace empty keyword with rule name", "Replace empty keyword with rule name", result) - } - - private def applyKeywordWithSpacesQuickfix(CharSequence input, String result) { - val issueCode = SPACES_IN_KEYWORD - val label = "Fix keyword with spaces" - val description = "Fix keyword with spaces" - - input.testQuickfixesOn(issueCode, new Quickfix(label, description, result)) - } -} \ No newline at end of file diff --git a/org.eclipse.xtext.xtext.ui.tests/xtend-gen/org/eclipse/xtext/xtext/ui/editor/quickfix/XtextGrammarQuickfixTest.java b/org.eclipse.xtext.xtext.ui.tests/xtend-gen/org/eclipse/xtext/xtext/ui/editor/quickfix/XtextGrammarQuickfixTest.java deleted file mode 100644 index cd5796c854..0000000000 --- a/org.eclipse.xtext.xtext.ui.tests/xtend-gen/org/eclipse/xtext/xtext/ui/editor/quickfix/XtextGrammarQuickfixTest.java +++ /dev/null @@ -1,341 +0,0 @@ -/** - * Copyright (c) 2019, 2020 RCP Vision s.r.l. (http://www.rcp-vision.com) and others. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.xtext.xtext.ui.editor.quickfix; - -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.testing.InjectWith; -import org.eclipse.xtext.testing.XtextRunner; -import org.eclipse.xtext.ui.testing.AbstractQuickfixTest; -import org.eclipse.xtext.xtext.XtextConfigurableIssueCodes; -import org.eclipse.xtext.xtext.ui.XtextUiInjectorProvider; -import org.junit.Test; -import org.junit.runner.RunWith; - -/** - * @author loradd - Initial contribution and API - */ -@RunWith(XtextRunner.class) -@InjectWith(XtextUiInjectorProvider.class) -@SuppressWarnings("all") -public class XtextGrammarQuickfixTest extends AbstractQuickfixTest { - @Test - public void test_convert_terminal_fragment_to_terminal_rule() { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals"); - _builder.newLine(); - _builder.newLine(); - _builder.append("generate myDsl \"http://www.xtext.org/example/mydsl/MyDsl\""); - _builder.newLine(); - _builder.newLine(); - _builder.append("Model hidden(ABC):"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("a = ID;"); - _builder.newLine(); - _builder.newLine(); - _builder.append("terminal fragment ABC:"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\'a\';"); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals"); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("generate myDsl \"http://www.xtext.org/example/mydsl/MyDsl\""); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("Model hidden(ABC):"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("a = ID;"); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("terminal ABC:"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("\'a\';"); - _builder_1.newLine(); - AbstractQuickfixTest.Quickfix _quickfix = new AbstractQuickfixTest.Quickfix("Convert terminal fragment to terminal rule", "Convert terminal fragment to terminal rule", _builder_1.toString()); - StringConcatenation _builder_2 = new StringConcatenation(); - _builder_2.append("grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals"); - _builder_2.newLine(); - _builder_2.newLine(); - _builder_2.append("generate myDsl \"http://www.xtext.org/example/mydsl/MyDsl\""); - _builder_2.newLine(); - _builder_2.newLine(); - _builder_2.append("Model hidden():"); - _builder_2.newLine(); - _builder_2.append("\t"); - _builder_2.append("a = ID;"); - _builder_2.newLine(); - _builder_2.newLine(); - _builder_2.append("terminal fragment ABC:"); - _builder_2.newLine(); - _builder_2.append("\t"); - _builder_2.append("\'a\';"); - _builder_2.newLine(); - AbstractQuickfixTest.Quickfix _quickfix_1 = new AbstractQuickfixTest.Quickfix("Remove hidden token definition", "Remove hidden token definition", _builder_2.toString()); - this.testQuickfixesOn(_builder, - "org.eclipse.xtext.grammar.InvalidHiddenTokenFragment", _quickfix, _quickfix_1); - } - - @Test - public void test_convert_terminal_fragment_to_terminal_rule_01() { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals"); - _builder.newLine(); - _builder.newLine(); - _builder.append("generate myDsl \"http://www.xtext.org/example/mydsl/MyDsl\""); - _builder.newLine(); - _builder.newLine(); - _builder.append("Model:"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("a = ABC;"); - _builder.newLine(); - _builder.newLine(); - _builder.append("terminal fragment ABC:"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\'a\';"); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals"); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("generate myDsl \"http://www.xtext.org/example/mydsl/MyDsl\""); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("Model:"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("a = ABC;"); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("terminal ABC:"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("\'a\';"); - _builder_1.newLine(); - AbstractQuickfixTest.Quickfix _quickfix = new AbstractQuickfixTest.Quickfix("Convert terminal fragment to terminal rule", "Convert terminal fragment to terminal rule", _builder_1.toString()); - this.testQuickfixesOn(_builder, - "org.eclipse.xtext.grammar.InvalidTerminalFragmentRuleReference", _quickfix); - } - - @Test - public void test_fix_invalid_hidden_token() { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals"); - _builder.newLine(); - _builder.newLine(); - _builder.append("generate myDsl \"http://www.xtext.org/example/mydsl/MyDsl\""); - _builder.newLine(); - _builder.newLine(); - _builder.append("Model hidden(AnotherModel):"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("a = ID;"); - _builder.newLine(); - _builder.newLine(); - _builder.append("AnotherModel:"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("b = ID;"); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals"); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("generate myDsl \"http://www.xtext.org/example/mydsl/MyDsl\""); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("Model hidden():"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("a = ID;"); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("AnotherModel:"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("b = ID;"); - _builder_1.newLine(); - AbstractQuickfixTest.Quickfix _quickfix = new AbstractQuickfixTest.Quickfix("Remove hidden token definition", "Remove hidden token definition", _builder_1.toString()); - this.testQuickfixesOn(_builder, - "org.eclipse.xtext.grammar.InvalidHiddenToken", _quickfix); - } - - @Test - public void test_fix_missing_rule() { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals"); - _builder.newLine(); - _builder.newLine(); - _builder.append("generate myDsl \"http://www.xtext.org/example/mydsl/MyDsl\""); - _builder.newLine(); - _builder.newLine(); - _builder.append("Model:"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("greetings+=Greeting*;"); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals"); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("generate myDsl \"http://www.xtext.org/example/mydsl/MyDsl\""); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("Model:"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("greetings+=Greeting*;"); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("Greeting:"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.newLine(); - _builder_1.append(";"); - _builder_1.newLine(); - AbstractQuickfixTest.Quickfix _quickfix = new AbstractQuickfixTest.Quickfix("Create rule \'Greeting\'", "Create rule \'Greeting\'", _builder_1.toString()); - StringConcatenation _builder_2 = new StringConcatenation(); - _builder_2.append("grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals"); - _builder_2.newLine(); - _builder_2.newLine(); - _builder_2.append("generate myDsl \"http://www.xtext.org/example/mydsl/MyDsl\""); - _builder_2.newLine(); - _builder_2.newLine(); - _builder_2.append("Model:"); - _builder_2.newLine(); - _builder_2.append("\t"); - _builder_2.append("greetings+=Greeting*;"); - _builder_2.newLine(); - _builder_2.newLine(); - _builder_2.append("enum Greeting:"); - _builder_2.newLine(); - _builder_2.append("\t"); - _builder_2.newLine(); - _builder_2.append(";"); - _builder_2.newLine(); - AbstractQuickfixTest.Quickfix _quickfix_1 = new AbstractQuickfixTest.Quickfix("Create enum rule \'Greeting\'", "Create enum rule \'Greeting\'", _builder_2.toString()); - StringConcatenation _builder_3 = new StringConcatenation(); - _builder_3.append("grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals"); - _builder_3.newLine(); - _builder_3.newLine(); - _builder_3.append("generate myDsl \"http://www.xtext.org/example/mydsl/MyDsl\""); - _builder_3.newLine(); - _builder_3.newLine(); - _builder_3.append("Model:"); - _builder_3.newLine(); - _builder_3.append("\t"); - _builder_3.append("greetings+=Greeting*;"); - _builder_3.newLine(); - _builder_3.newLine(); - _builder_3.append("terminal Greeting:"); - _builder_3.newLine(); - _builder_3.append("\t"); - _builder_3.newLine(); - _builder_3.append(";"); - _builder_3.newLine(); - AbstractQuickfixTest.Quickfix _quickfix_2 = new AbstractQuickfixTest.Quickfix("Create terminal \'Greeting\'", "Create terminal \'Greeting\'", _builder_3.toString()); - this.testQuickfixesOn(_builder, - "org.eclipse.xtext.grammar.UnresolvedRule", _quickfix, _quickfix_1, _quickfix_2); - } - - @Test - public void test_fix_empty_keyword() { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals"); - _builder.newLine(); - _builder.append("generate myDsl \"http://www.xtext.org/mydsl/MyDsl\""); - _builder.newLine(); - _builder.newLine(); - _builder.append("Model: \"\" a=ID;"); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals"); - _builder_1.newLine(); - _builder_1.append("generate myDsl \"http://www.xtext.org/mydsl/MyDsl\""); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("Model: a=ID;"); - _builder_1.newLine(); - StringConcatenation _builder_2 = new StringConcatenation(); - _builder_2.append("grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals"); - _builder_2.newLine(); - _builder_2.append("generate myDsl \"http://www.xtext.org/mydsl/MyDsl\""); - _builder_2.newLine(); - _builder_2.newLine(); - _builder_2.append("Model: \"model\" a=ID;"); - _builder_2.newLine(); - this.testQuickfixesOn(_builder, XtextConfigurableIssueCodes.EMPTY_KEYWORD, - this.removeEmptyKeywordQuickfix(_builder_1.toString()), - this.replaceEmptyKeywordWithRuleNameQuickfix(_builder_2.toString())); - } - - @Test - public void fix_keyword_with_spaces() { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals"); - _builder.newLine(); - _builder.append("generate myDsl \"http://www.xtext.org/mydsl/MyDsl\""); - _builder.newLine(); - _builder.newLine(); - _builder.append("Model: \' a b c d \' a=ID;"); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals"); - _builder_1.newLine(); - _builder_1.append("generate myDsl \"http://www.xtext.org/mydsl/MyDsl\""); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("Model: \'a\' \'b\' \'c\' \'d\' a=ID;"); - _builder_1.newLine(); - this.applyKeywordWithSpacesQuickfix(_builder, _builder_1.toString()); - } - - @Test - public void fix_empty_keyword_with_spaces() { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals"); - _builder.newLine(); - _builder.append("generate myDsl \"http://www.xtext.org/mydsl/MyDsl\""); - _builder.newLine(); - _builder.newLine(); - _builder.append("Model: \' \' a=ID;"); - _builder.newLine(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals"); - _builder_1.newLine(); - _builder_1.append("generate myDsl \"http://www.xtext.org/mydsl/MyDsl\""); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("Model: \'model\' a=ID;"); - _builder_1.newLine(); - this.applyKeywordWithSpacesQuickfix(_builder, _builder_1.toString()); - } - - private AbstractQuickfixTest.Quickfix removeEmptyKeywordQuickfix(final String result) { - return new AbstractQuickfixTest.Quickfix("Remove empty keyword", "Remove empty keyword", result); - } - - private AbstractQuickfixTest.Quickfix replaceEmptyKeywordWithRuleNameQuickfix(final String result) { - return new AbstractQuickfixTest.Quickfix("Replace empty keyword with rule name", "Replace empty keyword with rule name", result); - } - - private void applyKeywordWithSpacesQuickfix(final CharSequence input, final String result) { - final String issueCode = XtextConfigurableIssueCodes.SPACES_IN_KEYWORD; - final String label = "Fix keyword with spaces"; - final String description = "Fix keyword with spaces"; - AbstractQuickfixTest.Quickfix _quickfix = new AbstractQuickfixTest.Quickfix(label, description, result); - this.testQuickfixesOn(input, issueCode, _quickfix); - } -}