mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-15 08:18:55 +00:00
cleaner exception handling in tests
Signed-off-by: Christian Dietrich <christian.dietrich@itemis.de>
This commit is contained in:
parent
db91447032
commit
eb35e376f7
18 changed files with 658 additions and 735 deletions
|
@ -30,7 +30,7 @@ class ContentAssistContextFactoryTest {
|
|||
@Inject ContentAssistContextFactory factory
|
||||
@Inject TestLanguageGrammarAccess grammar
|
||||
|
||||
@Test def void testSimple1() {
|
||||
@Test def void testSimple1() throws Exception {
|
||||
document = '''
|
||||
type Foo <|>{
|
||||
int bar
|
||||
|
@ -44,7 +44,7 @@ class ContentAssistContextFactoryTest {
|
|||
'''.toString.assertEquals(factory.firstSetGrammarElementsToString)
|
||||
}
|
||||
|
||||
@Test def void testSimple2() {
|
||||
@Test def void testSimple2() throws Exception {
|
||||
document = '''
|
||||
type Foo {
|
||||
<|>int bar
|
||||
|
@ -72,7 +72,7 @@ class ContentAssistContextFactoryTest {
|
|||
'''.toString.assertEquals(factory.firstSetGrammarElementsToString)
|
||||
}
|
||||
|
||||
@Test def void testBeginning() {
|
||||
@Test def void testBeginning() throws Exception {
|
||||
document = '''
|
||||
<|>type Foo {
|
||||
int bar
|
||||
|
@ -91,7 +91,7 @@ class ContentAssistContextFactoryTest {
|
|||
'''.toString.assertEquals(factory.firstSetGrammarElementsToString)
|
||||
}
|
||||
|
||||
@Test def void testCustomEntryPoint() {
|
||||
@Test def void testCustomEntryPoint() throws Exception {
|
||||
entryPoint = grammar.propertyRule
|
||||
document = '''
|
||||
int <|>bar
|
||||
|
@ -106,7 +106,7 @@ class ContentAssistContextFactoryTest {
|
|||
'''.toString.assertEquals(factory.firstSetGrammarElementsToString)
|
||||
}
|
||||
|
||||
@Test def void testCustomEntryPointBeginning() {
|
||||
@Test def void testCustomEntryPointBeginning() throws Exception {
|
||||
entryPoint = grammar.propertyRule
|
||||
document = '''
|
||||
<|>int bar
|
||||
|
|
|
@ -36,7 +36,7 @@ class ContentAssistContextTestHelper {
|
|||
@Accessors ParserRule entryPoint
|
||||
@Accessors String cursor = "<|>"
|
||||
|
||||
def private XtextResource parse(String doc) {
|
||||
def private XtextResource parse(String doc) throws Exception {
|
||||
val uri = URI.createURI("dummy." + fileExtension.primaryFileExtension)
|
||||
val res = resFactory.createResource(uri) as XtextResource
|
||||
new XtextResourceSet().resources += res
|
||||
|
@ -48,7 +48,7 @@ class ContentAssistContextTestHelper {
|
|||
return res
|
||||
}
|
||||
|
||||
def String firstSetGrammarElementsToString(ContentAssistContextFactory factory) {
|
||||
def String firstSetGrammarElementsToString(ContentAssistContextFactory factory) throws Exception {
|
||||
val offset = document.indexOf(cursor)
|
||||
Preconditions.checkArgument(offset >= 0, "you forgot to provide a cursor")
|
||||
val doc = document.replace(cursor, "")
|
||||
|
|
|
@ -35,7 +35,7 @@ class PartialContentAssistTestLanguageContextFactoryTest {
|
|||
assertTrue(factory instanceof PartialContentAssistContextFactory)
|
||||
}
|
||||
|
||||
@Test def void testSimple1() {
|
||||
@Test def void testSimple1() throws Exception {
|
||||
document = '''
|
||||
type Foo <|>{
|
||||
int bar
|
||||
|
@ -49,7 +49,7 @@ class PartialContentAssistTestLanguageContextFactoryTest {
|
|||
'''.toString.assertEquals(factory.firstSetGrammarElementsToString)
|
||||
}
|
||||
|
||||
@Test def void testSimple2() {
|
||||
@Test def void testSimple2() throws Exception {
|
||||
document = '''
|
||||
type Foo {
|
||||
<|>int bar
|
||||
|
@ -67,7 +67,7 @@ class PartialContentAssistTestLanguageContextFactoryTest {
|
|||
'''.toString.assertEquals(factory.firstSetGrammarElementsToString)
|
||||
}
|
||||
|
||||
@Test def void testBeginning() {
|
||||
@Test def void testBeginning() throws Exception {
|
||||
document = '''
|
||||
<|>type Foo {
|
||||
int bar
|
||||
|
@ -81,7 +81,7 @@ class PartialContentAssistTestLanguageContextFactoryTest {
|
|||
'''.toString.assertEquals(factory.firstSetGrammarElementsToString)
|
||||
}
|
||||
|
||||
@Test def void testCustomEntryPoint() {
|
||||
@Test def void testCustomEntryPoint() throws Exception {
|
||||
entryPoint = grammar.propertyRule
|
||||
document = '''
|
||||
int <|>bar
|
||||
|
@ -94,7 +94,7 @@ class PartialContentAssistTestLanguageContextFactoryTest {
|
|||
'''.toString.assertEquals(factory.firstSetGrammarElementsToString)
|
||||
}
|
||||
|
||||
@Test def void testCustomEntryPointBeginning() {
|
||||
@Test def void testCustomEntryPointBeginning() throws Exception {
|
||||
entryPoint = grammar.propertyRule
|
||||
document = '''
|
||||
<|>int bar
|
||||
|
|
|
@ -32,15 +32,15 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
|
||||
@Inject ParseHelper<Tree> parseHelper;
|
||||
|
||||
@Test def void testInputToParse_01() {
|
||||
@Test def void testInputToParse_01() throws Exception {
|
||||
assertEquals("abc", testee.getInputToParse("abcdefg", 3, 7 /* do not care about this */))
|
||||
}
|
||||
|
||||
@Test def void testInputToParse_02() {
|
||||
@Test def void testInputToParse_02() throws Exception {
|
||||
assertEquals("abc", testee.getInputToParse("abc defg", 3, 7 /* do not care about this */))
|
||||
}
|
||||
|
||||
@Test def void testWholeNodeModel() {
|
||||
@Test def void testWholeNodeModel() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -78,7 +78,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_0_0() {
|
||||
@Test def void testLastCompleteNode_0_0() throws Exception {
|
||||
'''
|
||||
<|>parent1
|
||||
child1
|
||||
|
@ -91,7 +91,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_0_2() {
|
||||
@Test def void testLastCompleteNode_0_2() throws Exception {
|
||||
'''
|
||||
pa<|>rent1
|
||||
child1
|
||||
|
@ -100,7 +100,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_1_0() {
|
||||
@Test def void testLastCompleteNode_1_0() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
<|> child1
|
||||
|
@ -109,7 +109,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_1_1() {
|
||||
@Test def void testLastCompleteNode_1_1() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
<|>child1
|
||||
|
@ -118,7 +118,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_1_2() {
|
||||
@Test def void testLastCompleteNode_1_2() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
c<|>hild1
|
||||
|
@ -129,7 +129,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_2_0() {
|
||||
@Test def void testLastCompleteNode_2_0() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -141,7 +141,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_2_1() {
|
||||
@Test def void testLastCompleteNode_2_1() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -153,7 +153,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_2_2() {
|
||||
@Test def void testLastCompleteNode_2_2() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -165,7 +165,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_3_1() {
|
||||
@Test def void testLastCompleteNode_3_1() throws Exception {
|
||||
'''
|
||||
c
|
||||
d
|
||||
|
@ -180,7 +180,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_3_2() {
|
||||
@Test def void testLastCompleteNode_3_2() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -195,7 +195,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_4_2() {
|
||||
@Test def void testLastCompleteNode_4_2() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -212,7 +212,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_4_1() {
|
||||
@Test def void testLastCompleteNode_4_1() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -229,7 +229,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_4_0() {
|
||||
@Test def void testLastCompleteNode_4_0() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -244,7 +244,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_4_2b() {
|
||||
@Test def void testLastCompleteNode_4_2b() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -260,7 +260,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_4_1b() {
|
||||
@Test def void testLastCompleteNode_4_1b() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -276,7 +276,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_4_0b() {
|
||||
@Test def void testLastCompleteNode_4_0b() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -292,7 +292,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_4_2c() {
|
||||
@Test def void testLastCompleteNode_4_2c() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -309,7 +309,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_4_1c() {
|
||||
@Test def void testLastCompleteNode_4_1c() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -326,7 +326,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_4_0c() {
|
||||
@Test def void testLastCompleteNode_4_0c() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -342,7 +342,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_4_2d() {
|
||||
@Test def void testLastCompleteNode_4_2d() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -360,7 +360,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_4_1d() {
|
||||
@Test def void testLastCompleteNode_4_1d() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -378,7 +378,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_4_0d() {
|
||||
@Test def void testLastCompleteNode_4_0d() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -394,7 +394,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_6_0() {
|
||||
@Test def void testLastCompleteNode_6_0() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -414,7 +414,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_6_0b() {
|
||||
@Test def void testLastCompleteNode_6_0b() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -435,7 +435,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_6_1b() {
|
||||
@Test def void testLastCompleteNode_6_1b() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -458,7 +458,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_5_1() {
|
||||
@Test def void testLastCompleteNode_5_1() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -477,7 +477,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_6_3() {
|
||||
@Test def void testLastCompleteNode_6_3() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -498,7 +498,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_6_3b() {
|
||||
@Test def void testLastCompleteNode_6_3b() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -518,7 +518,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_6_3c() {
|
||||
@Test def void testLastCompleteNode_6_3c() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -538,7 +538,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_6_3d() {
|
||||
@Test def void testLastCompleteNode_6_3d() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -558,7 +558,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_7_0() {
|
||||
@Test def void testLastCompleteNode_7_0() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -580,7 +580,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_7_1() {
|
||||
@Test def void testLastCompleteNode_7_1() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -603,7 +603,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_8_1() {
|
||||
@Test def void testLastCompleteNode_8_1() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -630,7 +630,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_8_2() {
|
||||
@Test def void testLastCompleteNode_8_2() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -659,7 +659,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_8_2b() {
|
||||
@Test def void testLastCompleteNode_8_2b() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -687,7 +687,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_8_2c() {
|
||||
@Test def void testLastCompleteNode_8_2c() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -716,7 +716,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_8_3() {
|
||||
@Test def void testLastCompleteNode_8_3() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -745,7 +745,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_8_3b() {
|
||||
@Test def void testLastCompleteNode_8_3b() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -773,7 +773,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_8_3c() {
|
||||
@Test def void testLastCompleteNode_8_3c() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -802,7 +802,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_8_4() {
|
||||
@Test def void testLastCompleteNode_8_4() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -831,7 +831,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_8_4b() {
|
||||
@Test def void testLastCompleteNode_8_4b() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -859,7 +859,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
@Test def void testLastCompleteNode_8_4c() {
|
||||
@Test def void testLastCompleteNode_8_4c() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -888,7 +888,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
''')
|
||||
}
|
||||
|
||||
protected def void assertLastCompleteNode(CharSequence model, String expectation) {
|
||||
protected def void assertLastCompleteNode(CharSequence model, String expectation) throws Exception {
|
||||
val modelAsString = model.toString.replaceAll("\r\n","\n")
|
||||
modelAsString.assertLastCompleteNode(expectation);
|
||||
val withStringLiterals = modelAsString.replaceAll("(\\w+(<\\|>\\w+)?)", "\"$1\"")
|
||||
|
@ -896,7 +896,7 @@ abstract class AbstractCompletePrefixProviderTest {
|
|||
withStringLiterals.assertLastCompleteNode(expectationWithLiterals);
|
||||
}
|
||||
|
||||
private def void assertLastCompleteNode(String model, String expectation) {
|
||||
private def void assertLastCompleteNode(String model, String expectation) throws Exception {
|
||||
var offset = model.indexOf('<|>')
|
||||
if (offset === -1) {
|
||||
offset = model.length
|
||||
|
|
|
@ -31,11 +31,11 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
return testee
|
||||
}
|
||||
|
||||
@Test override void testInputToParse_02() {
|
||||
@Test override void testInputToParse_02() throws Exception {
|
||||
assertEquals("abc ", testee.getInputToParse("abc defg", 3, 5))
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_1_1() {
|
||||
@Test override void testLastCompleteNode_1_1() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
<|>child1
|
||||
|
@ -57,7 +57,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_2_2() {
|
||||
@Test override void testLastCompleteNode_2_2() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -81,7 +81,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_3_1() {
|
||||
@Test override void testLastCompleteNode_3_1() throws Exception {
|
||||
'''
|
||||
c
|
||||
d
|
||||
|
@ -95,7 +95,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_4_2() {
|
||||
@Test override void testLastCompleteNode_4_2() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -110,7 +110,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_4_1() {
|
||||
@Test override void testLastCompleteNode_4_1() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -126,7 +126,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_4_1b() {
|
||||
@Test override void testLastCompleteNode_4_1b() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -144,7 +144,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_4_0() {
|
||||
@Test override void testLastCompleteNode_4_0() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -161,7 +161,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_4_0c() {
|
||||
@Test override void testLastCompleteNode_4_0c() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -178,7 +178,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_4_0d() {
|
||||
@Test override void testLastCompleteNode_4_0d() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -196,7 +196,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_4_1d() {
|
||||
@Test override void testLastCompleteNode_4_1d() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -213,7 +213,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_4_2c() {
|
||||
@Test override void testLastCompleteNode_4_2c() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -229,7 +229,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_4_2d() {
|
||||
@Test override void testLastCompleteNode_4_2d() throws Exception {
|
||||
'''
|
||||
parent1
|
||||
child1
|
||||
|
@ -245,7 +245,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_6_0() {
|
||||
@Test override void testLastCompleteNode_6_0() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -268,7 +268,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_6_0b() {
|
||||
@Test override void testLastCompleteNode_6_0b() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -291,7 +291,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_5_1() {
|
||||
@Test override void testLastCompleteNode_5_1() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -313,7 +313,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_7_0() {
|
||||
@Test override void testLastCompleteNode_7_0() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -336,7 +336,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_7_1() {
|
||||
@Test override void testLastCompleteNode_7_1() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -358,7 +358,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_8_1() {
|
||||
@Test override void testLastCompleteNode_8_1() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -384,7 +384,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_8_2() {
|
||||
@Test override void testLastCompleteNode_8_2() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -411,7 +411,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_8_2b() {
|
||||
@Test override void testLastCompleteNode_8_2b() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -439,7 +439,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_8_2c() {
|
||||
@Test override void testLastCompleteNode_8_2c() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -467,7 +467,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_8_3() {
|
||||
@Test override void testLastCompleteNode_8_3() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -494,7 +494,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_8_3b() {
|
||||
@Test override void testLastCompleteNode_8_3b() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -522,7 +522,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_8_3c() {
|
||||
@Test override void testLastCompleteNode_8_3c() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -550,7 +550,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_8_4() {
|
||||
@Test override void testLastCompleteNode_8_4() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -577,7 +577,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_8_4b() {
|
||||
@Test override void testLastCompleteNode_8_4b() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
@ -605,7 +605,7 @@ class IndentationAwareCompletionPrefixProviderTest extends AbstractCompletePrefi
|
|||
''')
|
||||
}
|
||||
|
||||
@Test override void testLastCompleteNode_8_4c() {
|
||||
@Test override void testLastCompleteNode_8_4c() throws Exception {
|
||||
'''
|
||||
a
|
||||
b
|
||||
|
|
|
@ -32,7 +32,7 @@ class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
extension UriExtensions
|
||||
|
||||
@Test
|
||||
def void testRenameFqn_missing_file_null() {
|
||||
def void testRenameFqn_missing_file_null() throws Exception {
|
||||
val uri = new File('''missing.«fileExtension»''').toURI.normalize.toUriString
|
||||
initializeWithPrepareSupport()
|
||||
|
||||
|
@ -41,7 +41,7 @@ class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
def void testPrepareRenameFqn_missing_file_null() {
|
||||
def void testPrepareRenameFqn_missing_file_null() throws Exception {
|
||||
val uri = new File('''missing.«fileExtension»''').toURI.normalize.toUriString
|
||||
initializeWithPrepareSupport()
|
||||
|
||||
|
@ -50,7 +50,7 @@ class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
def void testPrepareRenameFqn_missing_file_exception() {
|
||||
def void testPrepareRenameFqn_missing_file_exception() throws Exception {
|
||||
val uri = new File('''missing.«fileExtension»''').toURI.normalize.toUriString
|
||||
initialize()
|
||||
|
||||
|
@ -65,7 +65,7 @@ class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
def void testRenameFqn_invalid_error() {
|
||||
def void testRenameFqn_invalid_error() throws Exception {
|
||||
val uri = 'my-type-invalid.testlang'.writeFile('''
|
||||
package foo.bar {
|
||||
type A {
|
||||
|
@ -89,7 +89,7 @@ class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
def void testRenameFqn_invalid_null() {
|
||||
def void testRenameFqn_invalid_null() throws Exception {
|
||||
val uri = 'my-type-invalid.testlang'.writeFile('''
|
||||
package foo.bar {
|
||||
type A {
|
||||
|
@ -105,7 +105,7 @@ class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
def void testRenameFqn_before_ok() {
|
||||
def void testRenameFqn_before_ok() throws Exception {
|
||||
val uri = 'my-type-valid.testlang'.writeFile('''
|
||||
package foo.bar {
|
||||
type A {
|
||||
|
@ -127,7 +127,7 @@ class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
def void testPrepareRenameFqn_before_nok() {
|
||||
def void testPrepareRenameFqn_before_nok() throws Exception {
|
||||
val model = '''
|
||||
package foo.bar {
|
||||
type A {
|
||||
|
@ -145,7 +145,7 @@ class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
def void testPrepareRenameFqn_start_ok() {
|
||||
def void testPrepareRenameFqn_start_ok() throws Exception {
|
||||
val model = '''
|
||||
package foo.bar {
|
||||
type A {
|
||||
|
@ -164,7 +164,7 @@ class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
def void testPrepareRenameFqn_in_ok() {
|
||||
def void testPrepareRenameFqn_in_ok() throws Exception {
|
||||
val model = '''
|
||||
package foo.bar {
|
||||
type A {
|
||||
|
@ -183,7 +183,7 @@ class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
def void testPrepareRenameFqn_end_ok() {
|
||||
def void testPrepareRenameFqn_end_ok() throws Exception {
|
||||
val model = '''
|
||||
package foo.bar {
|
||||
type A {
|
||||
|
@ -202,7 +202,7 @@ class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
def void testPrepareRenameFqn_end_null() {
|
||||
def void testPrepareRenameFqn_end_null() throws Exception {
|
||||
val model = '''
|
||||
package foo.bar {
|
||||
type A {
|
||||
|
|
|
@ -40,41 +40,41 @@ class RenameTest extends AbstractTestLangLanguageServerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
def void testRenameBeforeDeclaration() {
|
||||
def void testRenameBeforeDeclaration() throws Exception {
|
||||
doTest(firstFile, new Position(0, 5))
|
||||
}
|
||||
|
||||
@Test
|
||||
def void testRenameOnDeclaration() {
|
||||
def void testRenameOnDeclaration() throws Exception {
|
||||
doTest(firstFile, new Position(0, 6))
|
||||
}
|
||||
|
||||
@Test
|
||||
def void testRenameAfterDeclaration() {
|
||||
def void testRenameAfterDeclaration() throws Exception {
|
||||
doTest(firstFile, new Position(0, 8))
|
||||
}
|
||||
|
||||
@Test
|
||||
def void testRenameOnReference() {
|
||||
def void testRenameOnReference() throws Exception {
|
||||
doTest(firstFile, new Position(1, 5))
|
||||
}
|
||||
|
||||
@Test
|
||||
def void testRenameAfterReference() {
|
||||
def void testRenameAfterReference() throws Exception {
|
||||
doTest(firstFile, new Position(1, 8))
|
||||
}
|
||||
|
||||
@Test
|
||||
def void testRenameOnReferenceInOtherFile() {
|
||||
def void testRenameOnReferenceInOtherFile() throws Exception {
|
||||
doTest(secondFile, new Position(1, 5))
|
||||
}
|
||||
|
||||
@Test
|
||||
def void testRenameAfterReferenceInOtherFile() {
|
||||
def void testRenameAfterReferenceInOtherFile() throws Exception {
|
||||
doTest(secondFile, new Position(1,8))
|
||||
}
|
||||
|
||||
protected def doTest(String fileName, Position position) {
|
||||
protected def doTest(String fileName, Position position) throws Exception {
|
||||
val params = new RenameParams(new TextDocumentIdentifier(fileName), position, 'Tescht')
|
||||
val workspaceEdit = languageServer.rename(params).get
|
||||
assertEquals('''
|
||||
|
|
|
@ -31,7 +31,7 @@ class RenameTest2 extends AbstractLanguageServerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
def void testRenameSelfRef() {
|
||||
def void testRenameSelfRef() throws Exception {
|
||||
val model = '''
|
||||
package foo
|
||||
|
||||
|
@ -56,7 +56,7 @@ class RenameTest2 extends AbstractLanguageServerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
def void testRenameContainer() {
|
||||
def void testRenameContainer() throws Exception {
|
||||
val model = '''
|
||||
package foo
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class RenameTest3 extends AbstractLanguageServerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
def void testRenameAutoQuote() {
|
||||
def void testRenameAutoQuote() throws Exception {
|
||||
val model = '''
|
||||
type Foo {
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ class RenameTest3 extends AbstractLanguageServerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
def void testRenameQuoted() {
|
||||
def void testRenameQuoted() throws Exception {
|
||||
val model = '''
|
||||
type ^type {
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ class RenameTest3 extends AbstractLanguageServerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
def void testRenameAutoQuoteRef() {
|
||||
def void testRenameAutoQuoteRef() throws Exception {
|
||||
val model = '''
|
||||
type Foo {
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ class RenameTest3 extends AbstractLanguageServerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
def void testRenameQuotedRef() {
|
||||
def void testRenameQuotedRef() throws Exception {
|
||||
val model = '''
|
||||
type ^type {
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class ContentAssistContextFactoryTest {
|
|||
private TestLanguageGrammarAccess grammar;
|
||||
|
||||
@Test
|
||||
public void testSimple1() {
|
||||
public void testSimple1() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("type Foo <|>{");
|
||||
_builder.newLine();
|
||||
|
@ -64,7 +64,7 @@ public class ContentAssistContextFactoryTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSimple2() {
|
||||
public void testSimple2() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("type Foo {");
|
||||
_builder.newLine();
|
||||
|
@ -131,7 +131,7 @@ public class ContentAssistContextFactoryTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testBeginning() {
|
||||
public void testBeginning() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("<|>type Foo {");
|
||||
_builder.newLine();
|
||||
|
@ -171,7 +171,7 @@ public class ContentAssistContextFactoryTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCustomEntryPoint() {
|
||||
public void testCustomEntryPoint() throws Exception {
|
||||
this._contentAssistContextTestHelper.setEntryPoint(this.grammar.getPropertyRule());
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("int <|>bar");
|
||||
|
@ -198,7 +198,7 @@ public class ContentAssistContextFactoryTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCustomEntryPointBeginning() {
|
||||
public void testCustomEntryPointBeginning() throws Exception {
|
||||
this._contentAssistContextTestHelper.setEntryPoint(this.grammar.getPropertyRule());
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("<|>int bar");
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.eclipse.xtext.util.StringInputStream;
|
|||
import org.eclipse.xtext.util.TextRegion;
|
||||
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
|
||||
import org.eclipse.xtext.xbase.lib.Conversions;
|
||||
import org.eclipse.xtext.xbase.lib.Exceptions;
|
||||
import org.eclipse.xtext.xbase.lib.IterableExtensions;
|
||||
import org.eclipse.xtext.xbase.lib.Pair;
|
||||
import org.eclipse.xtext.xbase.lib.Pure;
|
||||
|
@ -59,28 +58,24 @@ public class ContentAssistContextTestHelper {
|
|||
@Accessors
|
||||
private String cursor = "<|>";
|
||||
|
||||
private XtextResource parse(final String doc) {
|
||||
try {
|
||||
String _primaryFileExtension = this.fileExtension.getPrimaryFileExtension();
|
||||
String _plus = ("dummy." + _primaryFileExtension);
|
||||
final URI uri = URI.createURI(_plus);
|
||||
Resource _createResource = this.resFactory.createResource(uri);
|
||||
final XtextResource res = ((XtextResource) _createResource);
|
||||
EList<Resource> _resources = new XtextResourceSet().getResources();
|
||||
_resources.add(res);
|
||||
if ((this.entryPoint != null)) {
|
||||
res.setEntryPoint(this.entryPoint);
|
||||
}
|
||||
StringInputStream _stringInputStream = new StringInputStream(doc);
|
||||
res.load(_stringInputStream, CollectionLiterals.<Object, Object>emptyMap());
|
||||
this.validator.assertNoErrors(res);
|
||||
return res;
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
private XtextResource parse(final String doc) throws Exception {
|
||||
String _primaryFileExtension = this.fileExtension.getPrimaryFileExtension();
|
||||
String _plus = ("dummy." + _primaryFileExtension);
|
||||
final URI uri = URI.createURI(_plus);
|
||||
Resource _createResource = this.resFactory.createResource(uri);
|
||||
final XtextResource res = ((XtextResource) _createResource);
|
||||
EList<Resource> _resources = new XtextResourceSet().getResources();
|
||||
_resources.add(res);
|
||||
if ((this.entryPoint != null)) {
|
||||
res.setEntryPoint(this.entryPoint);
|
||||
}
|
||||
StringInputStream _stringInputStream = new StringInputStream(doc);
|
||||
res.load(_stringInputStream, CollectionLiterals.<Object, Object>emptyMap());
|
||||
this.validator.assertNoErrors(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
public String firstSetGrammarElementsToString(final ContentAssistContextFactory factory) {
|
||||
public String firstSetGrammarElementsToString(final ContentAssistContextFactory factory) throws Exception {
|
||||
final int offset = this.document.indexOf(this.cursor);
|
||||
Preconditions.checkArgument((offset >= 0), "you forgot to provide a cursor");
|
||||
final String doc = this.document.replace(this.cursor, "");
|
||||
|
|
|
@ -45,7 +45,7 @@ public class PartialContentAssistTestLanguageContextFactoryTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSimple1() {
|
||||
public void testSimple1() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("type Foo <|>{");
|
||||
_builder.newLine();
|
||||
|
@ -70,7 +70,7 @@ public class PartialContentAssistTestLanguageContextFactoryTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSimple2() {
|
||||
public void testSimple2() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("type Foo {");
|
||||
_builder.newLine();
|
||||
|
@ -107,7 +107,7 @@ public class PartialContentAssistTestLanguageContextFactoryTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testBeginning() {
|
||||
public void testBeginning() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("<|>type Foo {");
|
||||
_builder.newLine();
|
||||
|
@ -132,7 +132,7 @@ public class PartialContentAssistTestLanguageContextFactoryTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCustomEntryPoint() {
|
||||
public void testCustomEntryPoint() throws Exception {
|
||||
this._contentAssistContextTestHelper.setEntryPoint(this.grammar.getPropertyRule());
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("int <|>bar");
|
||||
|
@ -153,7 +153,7 @@ public class PartialContentAssistTestLanguageContextFactoryTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCustomEntryPointBeginning() {
|
||||
public void testCustomEntryPointBeginning() throws Exception {
|
||||
this._contentAssistContextTestHelper.setEntryPoint(this.grammar.getPropertyRule());
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("<|>int bar");
|
||||
|
|
|
@ -23,7 +23,6 @@ import org.eclipse.xtext.nodemodel.ILeafNode;
|
|||
import org.eclipse.xtext.nodemodel.INode;
|
||||
import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
|
||||
import org.eclipse.xtext.testing.util.ParseHelper;
|
||||
import org.eclipse.xtext.xbase.lib.Exceptions;
|
||||
import org.eclipse.xtext.xbase.lib.Functions.Function1;
|
||||
import org.eclipse.xtext.xbase.lib.IterableExtensions;
|
||||
import org.junit.Assert;
|
||||
|
@ -40,17 +39,17 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
private ParseHelper<Tree> parseHelper;
|
||||
|
||||
@Test
|
||||
public void testInputToParse_01() {
|
||||
public void testInputToParse_01() throws Exception {
|
||||
Assert.assertEquals("abc", this.getTestee().getInputToParse("abcdefg", 3, 7));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInputToParse_02() {
|
||||
public void testInputToParse_02() throws Exception {
|
||||
Assert.assertEquals("abc", this.getTestee().getInputToParse("abc defg", 3, 7));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWholeNodeModel() {
|
||||
public void testWholeNodeModel() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -128,7 +127,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_0_0() {
|
||||
public void testLastCompleteNode_0_0() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("<|>parent1");
|
||||
_builder.newLine();
|
||||
|
@ -149,7 +148,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_0_2() {
|
||||
public void testLastCompleteNode_0_2() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("pa<|>rent1");
|
||||
_builder.newLine();
|
||||
|
@ -163,7 +162,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_1_0() {
|
||||
public void testLastCompleteNode_1_0() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -176,7 +175,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_1_1() {
|
||||
public void testLastCompleteNode_1_1() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -190,7 +189,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_1_2() {
|
||||
public void testLastCompleteNode_1_2() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -208,7 +207,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_2_0() {
|
||||
public void testLastCompleteNode_2_0() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -228,7 +227,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_2_1() {
|
||||
public void testLastCompleteNode_2_1() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -249,7 +248,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_2_2() {
|
||||
public void testLastCompleteNode_2_2() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -270,7 +269,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_3_1() {
|
||||
public void testLastCompleteNode_3_1() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("c");
|
||||
_builder.newLine();
|
||||
|
@ -298,7 +297,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_3_2() {
|
||||
public void testLastCompleteNode_3_2() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -326,7 +325,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_4_2() {
|
||||
public void testLastCompleteNode_4_2() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -358,7 +357,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_4_1() {
|
||||
public void testLastCompleteNode_4_1() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -390,7 +389,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_4_0() {
|
||||
public void testLastCompleteNode_4_0() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -417,7 +416,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_4_2b() {
|
||||
public void testLastCompleteNode_4_2b() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -448,7 +447,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_4_1b() {
|
||||
public void testLastCompleteNode_4_1b() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -479,7 +478,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_4_0b() {
|
||||
public void testLastCompleteNode_4_0b() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -509,7 +508,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_4_2c() {
|
||||
public void testLastCompleteNode_4_2c() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -542,7 +541,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_4_1c() {
|
||||
public void testLastCompleteNode_4_1c() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -575,7 +574,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_4_0c() {
|
||||
public void testLastCompleteNode_4_0c() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -605,7 +604,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_4_2d() {
|
||||
public void testLastCompleteNode_4_2d() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -639,7 +638,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_4_1d() {
|
||||
public void testLastCompleteNode_4_1d() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -673,7 +672,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_4_0d() {
|
||||
public void testLastCompleteNode_4_0d() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -702,7 +701,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_6_0() {
|
||||
public void testLastCompleteNode_6_0() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -740,7 +739,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_6_0b() {
|
||||
public void testLastCompleteNode_6_0b() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -781,7 +780,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_6_1b() {
|
||||
public void testLastCompleteNode_6_1b() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -827,7 +826,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_5_1() {
|
||||
public void testLastCompleteNode_5_1() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -865,7 +864,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_6_3() {
|
||||
public void testLastCompleteNode_6_3() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -905,7 +904,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_6_3b() {
|
||||
public void testLastCompleteNode_6_3b() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -944,7 +943,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_6_3c() {
|
||||
public void testLastCompleteNode_6_3c() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -983,7 +982,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_6_3d() {
|
||||
public void testLastCompleteNode_6_3d() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -1022,7 +1021,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_7_0() {
|
||||
public void testLastCompleteNode_7_0() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -1064,7 +1063,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_7_1() {
|
||||
public void testLastCompleteNode_7_1() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -1109,7 +1108,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_8_1() {
|
||||
public void testLastCompleteNode_8_1() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -1163,7 +1162,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_8_2() {
|
||||
public void testLastCompleteNode_8_2() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -1222,7 +1221,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_8_2b() {
|
||||
public void testLastCompleteNode_8_2b() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -1280,7 +1279,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_8_2c() {
|
||||
public void testLastCompleteNode_8_2c() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -1340,7 +1339,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_8_3() {
|
||||
public void testLastCompleteNode_8_3() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -1399,7 +1398,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_8_3b() {
|
||||
public void testLastCompleteNode_8_3b() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -1457,7 +1456,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_8_3c() {
|
||||
public void testLastCompleteNode_8_3c() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -1517,7 +1516,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_8_4() {
|
||||
public void testLastCompleteNode_8_4() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -1576,7 +1575,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_8_4b() {
|
||||
public void testLastCompleteNode_8_4b() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -1634,7 +1633,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLastCompleteNode_8_4c() {
|
||||
public void testLastCompleteNode_8_4c() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -1693,7 +1692,7 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
this.assertLastCompleteNode(_builder, _builder_1.toString());
|
||||
}
|
||||
|
||||
protected void assertLastCompleteNode(final CharSequence model, final String expectation) {
|
||||
protected void assertLastCompleteNode(final CharSequence model, final String expectation) throws Exception {
|
||||
final String modelAsString = model.toString().replaceAll("\r\n", "\n");
|
||||
this.assertLastCompleteNode(modelAsString, expectation);
|
||||
final String withStringLiterals = modelAsString.replaceAll("(\\w+(<\\|>\\w+)?)", "\"$1\"");
|
||||
|
@ -1701,23 +1700,19 @@ public abstract class AbstractCompletePrefixProviderTest {
|
|||
this.assertLastCompleteNode(withStringLiterals, expectationWithLiterals);
|
||||
}
|
||||
|
||||
private void assertLastCompleteNode(final String model, final String expectation) {
|
||||
try {
|
||||
int offset = model.indexOf("<|>");
|
||||
if ((offset == (-1))) {
|
||||
offset = model.length();
|
||||
}
|
||||
int completionOffset = model.indexOf("<|>", offset);
|
||||
if ((completionOffset == (-1))) {
|
||||
completionOffset = offset;
|
||||
}
|
||||
final Tree tree = this.parseHelper.parse(model.replace("<|>", ""));
|
||||
final ICompositeNode nodeModel = NodeModelUtils.findActualNodeFor(tree);
|
||||
final INode completeNode = this.getTestee().getLastCompleteNodeByOffset(nodeModel, offset, completionOffset);
|
||||
this.assertNodeModel(expectation, completeNode);
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
private void assertLastCompleteNode(final String model, final String expectation) throws Exception {
|
||||
int offset = model.indexOf("<|>");
|
||||
if ((offset == (-1))) {
|
||||
offset = model.length();
|
||||
}
|
||||
int completionOffset = model.indexOf("<|>", offset);
|
||||
if ((completionOffset == (-1))) {
|
||||
completionOffset = offset;
|
||||
}
|
||||
final Tree tree = this.parseHelper.parse(model.replace("<|>", ""));
|
||||
final ICompositeNode nodeModel = NodeModelUtils.findActualNodeFor(tree);
|
||||
final INode completeNode = this.getTestee().getLastCompleteNodeByOffset(nodeModel, offset, completionOffset);
|
||||
this.assertNodeModel(expectation, completeNode);
|
||||
}
|
||||
|
||||
private void assertNodeModel(final String expectation, final INode node) {
|
||||
|
|
|
@ -37,13 +37,13 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testInputToParse_02() {
|
||||
public void testInputToParse_02() throws Exception {
|
||||
Assert.assertEquals("abc ", this.testee.getInputToParse("abc defg", 3, 5));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_1_1() {
|
||||
public void testLastCompleteNode_1_1() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -90,7 +90,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_2_2() {
|
||||
public void testLastCompleteNode_2_2() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -141,7 +141,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_3_1() {
|
||||
public void testLastCompleteNode_3_1() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("c");
|
||||
_builder.newLine();
|
||||
|
@ -168,7 +168,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_4_2() {
|
||||
public void testLastCompleteNode_4_2() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -197,7 +197,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_4_1() {
|
||||
public void testLastCompleteNode_4_1() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -228,7 +228,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_4_1b() {
|
||||
public void testLastCompleteNode_4_1b() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -264,7 +264,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_4_0() {
|
||||
public void testLastCompleteNode_4_0() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -296,7 +296,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_4_0c() {
|
||||
public void testLastCompleteNode_4_0c() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -329,7 +329,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_4_0d() {
|
||||
public void testLastCompleteNode_4_0d() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -363,7 +363,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_4_1d() {
|
||||
public void testLastCompleteNode_4_1d() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -396,7 +396,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_4_2c() {
|
||||
public void testLastCompleteNode_4_2c() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -428,7 +428,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_4_2d() {
|
||||
public void testLastCompleteNode_4_2d() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("parent1");
|
||||
_builder.newLine();
|
||||
|
@ -459,7 +459,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_6_0() {
|
||||
public void testLastCompleteNode_6_0() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -504,7 +504,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_6_0b() {
|
||||
public void testLastCompleteNode_6_0b() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -550,7 +550,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_5_1() {
|
||||
public void testLastCompleteNode_5_1() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -595,7 +595,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_7_0() {
|
||||
public void testLastCompleteNode_7_0() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -640,7 +640,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_7_1() {
|
||||
public void testLastCompleteNode_7_1() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -684,7 +684,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_8_1() {
|
||||
public void testLastCompleteNode_8_1() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -737,7 +737,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_8_2() {
|
||||
public void testLastCompleteNode_8_2() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -793,7 +793,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_8_2b() {
|
||||
public void testLastCompleteNode_8_2b() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -852,7 +852,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_8_2c() {
|
||||
public void testLastCompleteNode_8_2c() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -911,7 +911,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_8_3() {
|
||||
public void testLastCompleteNode_8_3() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -967,7 +967,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_8_3b() {
|
||||
public void testLastCompleteNode_8_3b() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -1026,7 +1026,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_8_3c() {
|
||||
public void testLastCompleteNode_8_3c() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -1085,7 +1085,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_8_4() {
|
||||
public void testLastCompleteNode_8_4() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -1141,7 +1141,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_8_4b() {
|
||||
public void testLastCompleteNode_8_4b() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
@ -1200,7 +1200,7 @@ public class IndentationAwareCompletionPrefixProviderTest extends AbstractComple
|
|||
|
||||
@Test
|
||||
@Override
|
||||
public void testLastCompleteNode_8_4c() {
|
||||
public void testLastCompleteNode_8_4c() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("a");
|
||||
_builder.newLine();
|
||||
|
|
|
@ -43,41 +43,33 @@ public class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
private UriExtensions _uriExtensions;
|
||||
|
||||
@Test
|
||||
public void testRenameFqn_missing_file_null() {
|
||||
try {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("missing.");
|
||||
_builder.append(this.fileExtension);
|
||||
final String uri = this._uriExtensions.toUriString(new File(_builder.toString()).toURI().normalize());
|
||||
this.initializeWithPrepareSupport();
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
|
||||
Position _position = new Position(2, 5);
|
||||
final RenameParams params = new RenameParams(_textDocumentIdentifier, _position, "Does not matter");
|
||||
Assert.assertNull(this.languageServer.rename(params).get());
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
}
|
||||
public void testRenameFqn_missing_file_null() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("missing.");
|
||||
_builder.append(this.fileExtension);
|
||||
final String uri = this._uriExtensions.toUriString(new File(_builder.toString()).toURI().normalize());
|
||||
this.initializeWithPrepareSupport();
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
|
||||
Position _position = new Position(2, 5);
|
||||
final RenameParams params = new RenameParams(_textDocumentIdentifier, _position, "Does not matter");
|
||||
Assert.assertNull(this.languageServer.rename(params).get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrepareRenameFqn_missing_file_null() {
|
||||
try {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("missing.");
|
||||
_builder.append(this.fileExtension);
|
||||
final String uri = this._uriExtensions.toUriString(new File(_builder.toString()).toURI().normalize());
|
||||
this.initializeWithPrepareSupport();
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
|
||||
Position _position = new Position(2, 5);
|
||||
final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
|
||||
Assert.assertNull(this.languageServer.prepareRename(params).get());
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
}
|
||||
public void testPrepareRenameFqn_missing_file_null() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("missing.");
|
||||
_builder.append(this.fileExtension);
|
||||
final String uri = this._uriExtensions.toUriString(new File(_builder.toString()).toURI().normalize());
|
||||
this.initializeWithPrepareSupport();
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
|
||||
Position _position = new Position(2, 5);
|
||||
final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
|
||||
Assert.assertNull(this.languageServer.prepareRename(params).get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrepareRenameFqn_missing_file_exception() {
|
||||
public void testPrepareRenameFqn_missing_file_exception() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("missing.");
|
||||
_builder.append(this.fileExtension);
|
||||
|
@ -101,7 +93,7 @@ public class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRenameFqn_invalid_error() {
|
||||
public void testRenameFqn_invalid_error() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("package foo.bar {");
|
||||
_builder.newLine();
|
||||
|
@ -144,240 +136,212 @@ public class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRenameFqn_invalid_null() {
|
||||
try {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("package foo.bar {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type A {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("foo.bar.MyType bar");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type MyType { }");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String uri = this.writeFile("my-type-invalid.testlang", _builder);
|
||||
this.initializeWithPrepareSupport();
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
|
||||
Position _position = new Position(2, 5);
|
||||
final RenameParams params = new RenameParams(_textDocumentIdentifier, _position, "Does not matter");
|
||||
Assert.assertNull(this.languageServer.rename(params).get());
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
}
|
||||
public void testRenameFqn_invalid_null() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("package foo.bar {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type A {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("foo.bar.MyType bar");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type MyType { }");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String uri = this.writeFile("my-type-invalid.testlang", _builder);
|
||||
this.initializeWithPrepareSupport();
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
|
||||
Position _position = new Position(2, 5);
|
||||
final RenameParams params = new RenameParams(_textDocumentIdentifier, _position, "Does not matter");
|
||||
Assert.assertNull(this.languageServer.rename(params).get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRenameFqn_before_ok() {
|
||||
try {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("package foo.bar {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type A {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("foo.bar.MyType bar");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type MyType { }");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String uri = this.writeFile("my-type-valid.testlang", _builder);
|
||||
this.initializeWithPrepareSupport();
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
|
||||
Position _position = new Position(2, 13);
|
||||
final RenameParams params = new RenameParams(_textDocumentIdentifier, _position, "YourType");
|
||||
final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
|
||||
StringConcatenation _builder_1 = new StringConcatenation();
|
||||
_builder_1.append("changes :");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append("\t");
|
||||
_builder_1.append("my-type-valid.testlang : foo.bar.YourType [[2, 4] .. [2, 18]]");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append("\t");
|
||||
_builder_1.append("YourType [[4, 7] .. [4, 13]]");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append("documentChanges : ");
|
||||
_builder_1.newLine();
|
||||
this.assertEquals(_builder_1.toString(), this.toExpectation(workspaceEdit));
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
}
|
||||
public void testRenameFqn_before_ok() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("package foo.bar {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type A {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("foo.bar.MyType bar");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type MyType { }");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String uri = this.writeFile("my-type-valid.testlang", _builder);
|
||||
this.initializeWithPrepareSupport();
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
|
||||
Position _position = new Position(2, 13);
|
||||
final RenameParams params = new RenameParams(_textDocumentIdentifier, _position, "YourType");
|
||||
final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
|
||||
StringConcatenation _builder_1 = new StringConcatenation();
|
||||
_builder_1.append("changes :");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append("\t");
|
||||
_builder_1.append("my-type-valid.testlang : foo.bar.YourType [[2, 4] .. [2, 18]]");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append("\t");
|
||||
_builder_1.append("YourType [[4, 7] .. [4, 13]]");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append("documentChanges : ");
|
||||
_builder_1.newLine();
|
||||
this.assertEquals(_builder_1.toString(), this.toExpectation(workspaceEdit));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrepareRenameFqn_before_nok() {
|
||||
try {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("package foo.bar {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type A {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("foo.bar.MyType bar");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type MyType { }");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String model = _builder.toString();
|
||||
this.initializeWithPrepareSupport();
|
||||
final String uri = this.writeFile("my-type-valid.testlang", model);
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
|
||||
Position _position = new Position(2, 11);
|
||||
final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
|
||||
Assert.assertNull(this.languageServer.prepareRename(params).get());
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
}
|
||||
public void testPrepareRenameFqn_before_nok() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("package foo.bar {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type A {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("foo.bar.MyType bar");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type MyType { }");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String model = _builder.toString();
|
||||
this.initializeWithPrepareSupport();
|
||||
final String uri = this.writeFile("my-type-valid.testlang", model);
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
|
||||
Position _position = new Position(2, 11);
|
||||
final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
|
||||
Assert.assertNull(this.languageServer.prepareRename(params).get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrepareRenameFqn_start_ok() {
|
||||
try {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("package foo.bar {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type A {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("foo.bar.MyType bar");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type MyType { }");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String model = _builder.toString();
|
||||
this.initializeWithPrepareSupport();
|
||||
final String uri = this.writeFile("my-type-valid.testlang", model);
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
|
||||
Position _position = new Position(2, 12);
|
||||
final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
|
||||
final Range range = this.languageServer.prepareRename(params).get().getLeft();
|
||||
this.assertEquals("MyType", new Document(Integer.valueOf(0), model).getSubstring(range));
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
}
|
||||
public void testPrepareRenameFqn_start_ok() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("package foo.bar {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type A {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("foo.bar.MyType bar");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type MyType { }");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String model = _builder.toString();
|
||||
this.initializeWithPrepareSupport();
|
||||
final String uri = this.writeFile("my-type-valid.testlang", model);
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
|
||||
Position _position = new Position(2, 12);
|
||||
final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
|
||||
final Range range = this.languageServer.prepareRename(params).get().getLeft();
|
||||
this.assertEquals("MyType", new Document(Integer.valueOf(0), model).getSubstring(range));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrepareRenameFqn_in_ok() {
|
||||
try {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("package foo.bar {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type A {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("foo.bar.MyType bar");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type MyType { }");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String model = _builder.toString();
|
||||
this.initializeWithPrepareSupport();
|
||||
final String uri = this.writeFile("my-type-valid.testlang", model);
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
|
||||
Position _position = new Position(2, 14);
|
||||
final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
|
||||
final Range range = this.languageServer.prepareRename(params).get().getLeft();
|
||||
this.assertEquals("MyType", new Document(Integer.valueOf(0), model).getSubstring(range));
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
}
|
||||
public void testPrepareRenameFqn_in_ok() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("package foo.bar {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type A {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("foo.bar.MyType bar");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type MyType { }");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String model = _builder.toString();
|
||||
this.initializeWithPrepareSupport();
|
||||
final String uri = this.writeFile("my-type-valid.testlang", model);
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
|
||||
Position _position = new Position(2, 14);
|
||||
final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
|
||||
final Range range = this.languageServer.prepareRename(params).get().getLeft();
|
||||
this.assertEquals("MyType", new Document(Integer.valueOf(0), model).getSubstring(range));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrepareRenameFqn_end_ok() {
|
||||
try {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("package foo.bar {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type A {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("foo.bar.MyType bar");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type MyType { }");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String model = _builder.toString();
|
||||
this.initializeWithPrepareSupport();
|
||||
final String uri = this.writeFile("my-type-valid.testlang", model);
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
|
||||
Position _position = new Position(2, 18);
|
||||
final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
|
||||
final Range range = this.languageServer.prepareRename(params).get().getLeft();
|
||||
this.assertEquals("MyType", new Document(Integer.valueOf(0), model).getSubstring(range));
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
}
|
||||
public void testPrepareRenameFqn_end_ok() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("package foo.bar {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type A {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("foo.bar.MyType bar");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type MyType { }");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String model = _builder.toString();
|
||||
this.initializeWithPrepareSupport();
|
||||
final String uri = this.writeFile("my-type-valid.testlang", model);
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
|
||||
Position _position = new Position(2, 18);
|
||||
final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
|
||||
final Range range = this.languageServer.prepareRename(params).get().getLeft();
|
||||
this.assertEquals("MyType", new Document(Integer.valueOf(0), model).getSubstring(range));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrepareRenameFqn_end_null() {
|
||||
try {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("package foo.bar {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type A {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("foo.bar.MyType bar");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type MyType { }");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String model = _builder.toString();
|
||||
this.initialize();
|
||||
final String uri = this.writeFile("my-type-valid.testlang", model);
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
|
||||
Position _position = new Position(2, 18);
|
||||
final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
|
||||
Assert.assertNull(this.languageServer.prepareRename(params).get());
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
}
|
||||
public void testPrepareRenameFqn_end_null() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("package foo.bar {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type A {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("foo.bar.MyType bar");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("type MyType { }");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String model = _builder.toString();
|
||||
this.initialize();
|
||||
final String uri = this.writeFile("my-type-valid.testlang", model);
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
|
||||
Position _position = new Position(2, 18);
|
||||
final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
|
||||
Assert.assertNull(this.languageServer.prepareRename(params).get());
|
||||
}
|
||||
|
||||
private InitializeResult initializeWithPrepareSupport() {
|
||||
|
|
|
@ -14,7 +14,6 @@ import org.eclipse.lsp4j.TextDocumentIdentifier;
|
|||
import org.eclipse.lsp4j.WorkspaceEdit;
|
||||
import org.eclipse.xtend2.lib.StringConcatenation;
|
||||
import org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest;
|
||||
import org.eclipse.xtext.xbase.lib.Exceptions;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -53,69 +52,65 @@ public class RenameTest extends AbstractTestLangLanguageServerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRenameBeforeDeclaration() {
|
||||
public void testRenameBeforeDeclaration() throws Exception {
|
||||
Position _position = new Position(0, 5);
|
||||
this.doTest(this.firstFile, _position);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRenameOnDeclaration() {
|
||||
public void testRenameOnDeclaration() throws Exception {
|
||||
Position _position = new Position(0, 6);
|
||||
this.doTest(this.firstFile, _position);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRenameAfterDeclaration() {
|
||||
public void testRenameAfterDeclaration() throws Exception {
|
||||
Position _position = new Position(0, 8);
|
||||
this.doTest(this.firstFile, _position);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRenameOnReference() {
|
||||
public void testRenameOnReference() throws Exception {
|
||||
Position _position = new Position(1, 5);
|
||||
this.doTest(this.firstFile, _position);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRenameAfterReference() {
|
||||
public void testRenameAfterReference() throws Exception {
|
||||
Position _position = new Position(1, 8);
|
||||
this.doTest(this.firstFile, _position);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRenameOnReferenceInOtherFile() {
|
||||
public void testRenameOnReferenceInOtherFile() throws Exception {
|
||||
Position _position = new Position(1, 5);
|
||||
this.doTest(this.secondFile, _position);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRenameAfterReferenceInOtherFile() {
|
||||
public void testRenameAfterReferenceInOtherFile() throws Exception {
|
||||
Position _position = new Position(1, 8);
|
||||
this.doTest(this.secondFile, _position);
|
||||
}
|
||||
|
||||
protected void doTest(final String fileName, final Position position) {
|
||||
try {
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(fileName);
|
||||
final RenameParams params = new RenameParams(_textDocumentIdentifier, position, "Tescht");
|
||||
final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("changes :");
|
||||
_builder.newLine();
|
||||
_builder.append("\t");
|
||||
_builder.append("MyType1.testlang : Tescht [[0, 5] .. [0, 9]]");
|
||||
_builder.newLine();
|
||||
_builder.append("\t");
|
||||
_builder.append("Tescht [[1, 4] .. [1, 8]]");
|
||||
_builder.newLine();
|
||||
_builder.append("\t");
|
||||
_builder.append("MyType2.testlang : Tescht [[1, 4] .. [1, 8]]");
|
||||
_builder.newLine();
|
||||
_builder.append("documentChanges : ");
|
||||
_builder.newLine();
|
||||
this.assertEquals(_builder.toString(), this.toExpectation(workspaceEdit));
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
}
|
||||
protected void doTest(final String fileName, final Position position) throws Exception {
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(fileName);
|
||||
final RenameParams params = new RenameParams(_textDocumentIdentifier, position, "Tescht");
|
||||
final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("changes :");
|
||||
_builder.newLine();
|
||||
_builder.append("\t");
|
||||
_builder.append("MyType1.testlang : Tescht [[0, 5] .. [0, 9]]");
|
||||
_builder.newLine();
|
||||
_builder.append("\t");
|
||||
_builder.append("Tescht [[1, 4] .. [1, 8]]");
|
||||
_builder.newLine();
|
||||
_builder.append("\t");
|
||||
_builder.append("MyType2.testlang : Tescht [[1, 4] .. [1, 8]]");
|
||||
_builder.newLine();
|
||||
_builder.append("documentChanges : ");
|
||||
_builder.newLine();
|
||||
this.assertEquals(_builder.toString(), this.toExpectation(workspaceEdit));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.eclipse.lsp4j.WorkspaceEditCapabilities;
|
|||
import org.eclipse.xtend2.lib.StringConcatenation;
|
||||
import org.eclipse.xtext.ide.server.Document;
|
||||
import org.eclipse.xtext.testing.AbstractLanguageServerTest;
|
||||
import org.eclipse.xtext.xbase.lib.Exceptions;
|
||||
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
|
||||
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
|
||||
import org.junit.Test;
|
||||
|
@ -39,100 +38,92 @@ public class RenameTest2 extends AbstractLanguageServerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRenameSelfRef() {
|
||||
try {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("package foo");
|
||||
_builder.newLine();
|
||||
_builder.newLine();
|
||||
_builder.append("element Foo {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("ref Foo");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String model = _builder.toString();
|
||||
final String file = this.writeFile("foo/Foo.fileawaretestlanguage", model);
|
||||
this.initialize();
|
||||
final TextDocumentIdentifier identifier = new TextDocumentIdentifier(file);
|
||||
final Position position = new Position(2, 9);
|
||||
PrepareRenameParams _prepareRenameParams = new PrepareRenameParams(identifier, position);
|
||||
final Range range = this.languageServer.prepareRename(_prepareRenameParams).get().getLeft();
|
||||
this.assertEquals("Foo", new Document(Integer.valueOf(0), model).getSubstring(range));
|
||||
final RenameParams params = new RenameParams(identifier, position, "Bar");
|
||||
final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
|
||||
StringConcatenation _builder_1 = new StringConcatenation();
|
||||
_builder_1.append("changes :");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append("documentChanges : ");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("Foo.fileawaretestlanguage <1> : Bar [[2, 8] .. [2, 11]]");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("Bar [[3, 5] .. [3, 8]]");
|
||||
_builder_1.newLine();
|
||||
this.assertEquals(_builder_1.toString(), this.toExpectation(workspaceEdit));
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
}
|
||||
public void testRenameSelfRef() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("package foo");
|
||||
_builder.newLine();
|
||||
_builder.newLine();
|
||||
_builder.append("element Foo {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("ref Foo");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String model = _builder.toString();
|
||||
final String file = this.writeFile("foo/Foo.fileawaretestlanguage", model);
|
||||
this.initialize();
|
||||
final TextDocumentIdentifier identifier = new TextDocumentIdentifier(file);
|
||||
final Position position = new Position(2, 9);
|
||||
PrepareRenameParams _prepareRenameParams = new PrepareRenameParams(identifier, position);
|
||||
final Range range = this.languageServer.prepareRename(_prepareRenameParams).get().getLeft();
|
||||
this.assertEquals("Foo", new Document(Integer.valueOf(0), model).getSubstring(range));
|
||||
final RenameParams params = new RenameParams(identifier, position, "Bar");
|
||||
final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
|
||||
StringConcatenation _builder_1 = new StringConcatenation();
|
||||
_builder_1.append("changes :");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append("documentChanges : ");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("Foo.fileawaretestlanguage <1> : Bar [[2, 8] .. [2, 11]]");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("Bar [[3, 5] .. [3, 8]]");
|
||||
_builder_1.newLine();
|
||||
this.assertEquals(_builder_1.toString(), this.toExpectation(workspaceEdit));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRenameContainer() {
|
||||
try {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("package foo");
|
||||
_builder.newLine();
|
||||
_builder.newLine();
|
||||
_builder.append("element Foo {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("element Bar {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("ref foo.Foo.Bar");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("ref Foo.Bar");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("ref Bar");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String model = _builder.toString();
|
||||
final String file = this.writeFile("foo/Foo.fileawaretestlanguage", model);
|
||||
this.initialize();
|
||||
final TextDocumentIdentifier identifier = new TextDocumentIdentifier(file);
|
||||
final Position position = new Position(2, 9);
|
||||
PrepareRenameParams _prepareRenameParams = new PrepareRenameParams(identifier, position);
|
||||
final Range range = this.languageServer.prepareRename(_prepareRenameParams).get().getLeft();
|
||||
this.assertEquals("Foo", new Document(Integer.valueOf(0), model).getSubstring(range));
|
||||
final RenameParams params = new RenameParams(identifier, position, "Baz");
|
||||
final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
|
||||
StringConcatenation _builder_1 = new StringConcatenation();
|
||||
_builder_1.append("changes :");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append("documentChanges : ");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("Foo.fileawaretestlanguage <1> : Baz [[2, 8] .. [2, 11]]");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("Bar [[5, 5] .. [5, 16]]");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("Bar [[6, 5] .. [6, 12]]");
|
||||
_builder_1.newLine();
|
||||
this.assertEquals(_builder_1.toString(), this.toExpectation(workspaceEdit));
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
}
|
||||
public void testRenameContainer() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("package foo");
|
||||
_builder.newLine();
|
||||
_builder.newLine();
|
||||
_builder.append("element Foo {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("element Bar {");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("ref foo.Foo.Bar");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("ref Foo.Bar");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("ref Bar");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String model = _builder.toString();
|
||||
final String file = this.writeFile("foo/Foo.fileawaretestlanguage", model);
|
||||
this.initialize();
|
||||
final TextDocumentIdentifier identifier = new TextDocumentIdentifier(file);
|
||||
final Position position = new Position(2, 9);
|
||||
PrepareRenameParams _prepareRenameParams = new PrepareRenameParams(identifier, position);
|
||||
final Range range = this.languageServer.prepareRename(_prepareRenameParams).get().getLeft();
|
||||
this.assertEquals("Foo", new Document(Integer.valueOf(0), model).getSubstring(range));
|
||||
final RenameParams params = new RenameParams(identifier, position, "Baz");
|
||||
final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
|
||||
StringConcatenation _builder_1 = new StringConcatenation();
|
||||
_builder_1.append("changes :");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append("documentChanges : ");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("Foo.fileawaretestlanguage <1> : Baz [[2, 8] .. [2, 11]]");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("Bar [[5, 5] .. [5, 16]]");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("Bar [[6, 5] .. [6, 12]]");
|
||||
_builder_1.newLine();
|
||||
this.assertEquals(_builder_1.toString(), this.toExpectation(workspaceEdit));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.eclipse.lsp4j.WorkspaceEditCapabilities;
|
|||
import org.eclipse.xtend2.lib.StringConcatenation;
|
||||
import org.eclipse.xtext.ide.server.Document;
|
||||
import org.eclipse.xtext.testing.AbstractLanguageServerTest;
|
||||
import org.eclipse.xtext.xbase.lib.Exceptions;
|
||||
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
|
||||
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
|
||||
import org.junit.Test;
|
||||
|
@ -39,147 +38,131 @@ public class RenameTest3 extends AbstractLanguageServerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRenameAutoQuote() {
|
||||
try {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("type Foo {");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String model = _builder.toString();
|
||||
final String file = this.writeFile("foo/Foo.renametl", model);
|
||||
this.initialize();
|
||||
final TextDocumentIdentifier identifier = new TextDocumentIdentifier(file);
|
||||
final Position position = new Position(0, 6);
|
||||
PrepareRenameParams _prepareRenameParams = new PrepareRenameParams(identifier, position);
|
||||
final Range range = this.languageServer.prepareRename(_prepareRenameParams).get().getLeft();
|
||||
this.assertEquals("Foo", new Document(Integer.valueOf(0), model).getSubstring(range));
|
||||
final RenameParams params = new RenameParams(identifier, position, "type");
|
||||
final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
|
||||
StringConcatenation _builder_1 = new StringConcatenation();
|
||||
_builder_1.append("changes :");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append("documentChanges : ");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("Foo.renametl <1> : ^type [[0, 5] .. [0, 8]]");
|
||||
_builder_1.newLine();
|
||||
this.assertEquals(_builder_1.toString(), this.toExpectation(workspaceEdit));
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
}
|
||||
public void testRenameAutoQuote() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("type Foo {");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String model = _builder.toString();
|
||||
final String file = this.writeFile("foo/Foo.renametl", model);
|
||||
this.initialize();
|
||||
final TextDocumentIdentifier identifier = new TextDocumentIdentifier(file);
|
||||
final Position position = new Position(0, 6);
|
||||
PrepareRenameParams _prepareRenameParams = new PrepareRenameParams(identifier, position);
|
||||
final Range range = this.languageServer.prepareRename(_prepareRenameParams).get().getLeft();
|
||||
this.assertEquals("Foo", new Document(Integer.valueOf(0), model).getSubstring(range));
|
||||
final RenameParams params = new RenameParams(identifier, position, "type");
|
||||
final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
|
||||
StringConcatenation _builder_1 = new StringConcatenation();
|
||||
_builder_1.append("changes :");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append("documentChanges : ");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("Foo.renametl <1> : ^type [[0, 5] .. [0, 8]]");
|
||||
_builder_1.newLine();
|
||||
this.assertEquals(_builder_1.toString(), this.toExpectation(workspaceEdit));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRenameQuoted() {
|
||||
try {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("type ^type {");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String model = _builder.toString();
|
||||
final String file = this.writeFile("foo/Foo.renametl", model);
|
||||
this.initialize();
|
||||
final TextDocumentIdentifier identifier = new TextDocumentIdentifier(file);
|
||||
final Position position = new Position(0, 6);
|
||||
PrepareRenameParams _prepareRenameParams = new PrepareRenameParams(identifier, position);
|
||||
final Range range = this.languageServer.prepareRename(_prepareRenameParams).get().getLeft();
|
||||
this.assertEquals("^type", new Document(Integer.valueOf(0), model).getSubstring(range));
|
||||
final RenameParams params = new RenameParams(identifier, position, "Foo");
|
||||
final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
|
||||
StringConcatenation _builder_1 = new StringConcatenation();
|
||||
_builder_1.append("changes :");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append("documentChanges : ");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("Foo.renametl <1> : Foo [[0, 5] .. [0, 10]]");
|
||||
_builder_1.newLine();
|
||||
this.assertEquals(_builder_1.toString(), this.toExpectation(workspaceEdit));
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
}
|
||||
public void testRenameQuoted() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("type ^type {");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String model = _builder.toString();
|
||||
final String file = this.writeFile("foo/Foo.renametl", model);
|
||||
this.initialize();
|
||||
final TextDocumentIdentifier identifier = new TextDocumentIdentifier(file);
|
||||
final Position position = new Position(0, 6);
|
||||
PrepareRenameParams _prepareRenameParams = new PrepareRenameParams(identifier, position);
|
||||
final Range range = this.languageServer.prepareRename(_prepareRenameParams).get().getLeft();
|
||||
this.assertEquals("^type", new Document(Integer.valueOf(0), model).getSubstring(range));
|
||||
final RenameParams params = new RenameParams(identifier, position, "Foo");
|
||||
final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
|
||||
StringConcatenation _builder_1 = new StringConcatenation();
|
||||
_builder_1.append("changes :");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append("documentChanges : ");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("Foo.renametl <1> : Foo [[0, 5] .. [0, 10]]");
|
||||
_builder_1.newLine();
|
||||
this.assertEquals(_builder_1.toString(), this.toExpectation(workspaceEdit));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRenameAutoQuoteRef() {
|
||||
try {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("type Foo {");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.newLine();
|
||||
_builder.append("type Bar extends Foo {");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String model = _builder.toString();
|
||||
final String file = this.writeFile("foo/Foo.renametl", model);
|
||||
this.initialize();
|
||||
final TextDocumentIdentifier identifier = new TextDocumentIdentifier(file);
|
||||
final Position position = new Position(3, 18);
|
||||
PrepareRenameParams _prepareRenameParams = new PrepareRenameParams(identifier, position);
|
||||
final Range range = this.languageServer.prepareRename(_prepareRenameParams).get().getLeft();
|
||||
this.assertEquals("Foo", new Document(Integer.valueOf(0), model).getSubstring(range));
|
||||
final RenameParams params = new RenameParams(identifier, position, "type");
|
||||
final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
|
||||
StringConcatenation _builder_1 = new StringConcatenation();
|
||||
_builder_1.append("changes :");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append("documentChanges : ");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("Foo.renametl <1> : ^type [[0, 5] .. [0, 8]]");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("^type [[3, 17] .. [3, 20]]");
|
||||
_builder_1.newLine();
|
||||
this.assertEquals(_builder_1.toString(), this.toExpectation(workspaceEdit));
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
}
|
||||
public void testRenameAutoQuoteRef() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("type Foo {");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.newLine();
|
||||
_builder.append("type Bar extends Foo {");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String model = _builder.toString();
|
||||
final String file = this.writeFile("foo/Foo.renametl", model);
|
||||
this.initialize();
|
||||
final TextDocumentIdentifier identifier = new TextDocumentIdentifier(file);
|
||||
final Position position = new Position(3, 18);
|
||||
PrepareRenameParams _prepareRenameParams = new PrepareRenameParams(identifier, position);
|
||||
final Range range = this.languageServer.prepareRename(_prepareRenameParams).get().getLeft();
|
||||
this.assertEquals("Foo", new Document(Integer.valueOf(0), model).getSubstring(range));
|
||||
final RenameParams params = new RenameParams(identifier, position, "type");
|
||||
final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
|
||||
StringConcatenation _builder_1 = new StringConcatenation();
|
||||
_builder_1.append("changes :");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append("documentChanges : ");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("Foo.renametl <1> : ^type [[0, 5] .. [0, 8]]");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("^type [[3, 17] .. [3, 20]]");
|
||||
_builder_1.newLine();
|
||||
this.assertEquals(_builder_1.toString(), this.toExpectation(workspaceEdit));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRenameQuotedRef() {
|
||||
try {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("type ^type {");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.newLine();
|
||||
_builder.append("type Bar extends ^type {");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String model = _builder.toString();
|
||||
final String file = this.writeFile("foo/Foo.renametl", model);
|
||||
this.initialize();
|
||||
final TextDocumentIdentifier identifier = new TextDocumentIdentifier(file);
|
||||
final Position position = new Position(3, 19);
|
||||
PrepareRenameParams _prepareRenameParams = new PrepareRenameParams(identifier, position);
|
||||
final Range range = this.languageServer.prepareRename(_prepareRenameParams).get().getLeft();
|
||||
this.assertEquals("^type", new Document(Integer.valueOf(0), model).getSubstring(range));
|
||||
final RenameParams params = new RenameParams(identifier, position, "Foo");
|
||||
final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
|
||||
StringConcatenation _builder_1 = new StringConcatenation();
|
||||
_builder_1.append("changes :");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append("documentChanges : ");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("Foo.renametl <1> : Foo [[0, 5] .. [0, 10]]");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("Foo [[3, 17] .. [3, 22]]");
|
||||
_builder_1.newLine();
|
||||
this.assertEquals(_builder_1.toString(), this.toExpectation(workspaceEdit));
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
}
|
||||
public void testRenameQuotedRef() throws Exception {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("type ^type {");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.newLine();
|
||||
_builder.append("type Bar extends ^type {");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final String model = _builder.toString();
|
||||
final String file = this.writeFile("foo/Foo.renametl", model);
|
||||
this.initialize();
|
||||
final TextDocumentIdentifier identifier = new TextDocumentIdentifier(file);
|
||||
final Position position = new Position(3, 19);
|
||||
PrepareRenameParams _prepareRenameParams = new PrepareRenameParams(identifier, position);
|
||||
final Range range = this.languageServer.prepareRename(_prepareRenameParams).get().getLeft();
|
||||
this.assertEquals("^type", new Document(Integer.valueOf(0), model).getSubstring(range));
|
||||
final RenameParams params = new RenameParams(identifier, position, "Foo");
|
||||
final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
|
||||
StringConcatenation _builder_1 = new StringConcatenation();
|
||||
_builder_1.append("changes :");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append("documentChanges : ");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("Foo.renametl <1> : Foo [[0, 5] .. [0, 10]]");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("Foo [[3, 17] .. [3, 22]]");
|
||||
_builder_1.newLine();
|
||||
this.assertEquals(_builder_1.toString(), this.toExpectation(workspaceEdit));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue