diff --git a/org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/hierarchy/XtextCallHierarchyBuilderTest.java b/org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/hierarchy/XtextCallHierarchyBuilderTest.java new file mode 100644 index 0000000000..035270e54a --- /dev/null +++ b/org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/hierarchy/XtextCallHierarchyBuilderTest.java @@ -0,0 +1,262 @@ +/** + * Copyright (c) 2016, 2021 TypeFox GmbH (http://www.typefox.io) and others. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.eclipse.xtext.xtext.ui.editor.hierarchy; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.xtext.ide.editor.hierarchy.ICallHierarchyBuilder; +import org.eclipse.xtext.ide.editor.hierarchy.IHierarchyBuilder; +import org.eclipse.xtext.ide.editor.hierarchy.IHierarchyNode; +import org.eclipse.xtext.junit4.ide.AbstractHierarchyBuilderTest; +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.XtextRunner; +import org.eclipse.xtext.ui.editor.hierarchy.XtextCallHierarchyBuilder; +import org.eclipse.xtext.ui.editor.hierarchy.XtextCallHierarchyNode; +import org.eclipse.xtext.util.Strings; +import org.eclipse.xtext.xbase.lib.Pair; +import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; +import org.eclipse.xtext.xtext.ui.XtextInjectorProvider; +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.google.common.collect.Iterables; +import com.google.inject.Inject; +import com.google.inject.Provider; + +/** + * @author kosyakov - Initial contribution and API + */ +@RunWith(XtextRunner.class) +@InjectWith(XtextInjectorProvider.class) +public class XtextCallHierarchyBuilderTest extends AbstractHierarchyBuilderTest { + @Inject + private Provider callHierarchyBuilderProvider; + + @Override + protected void testBuildHierarchy(Procedure1 configurator) { + super.testBuildHierarchy((AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration it) -> { + it.setHierarchyBuilderProvider((ResourceSet resourceSet) -> { + XtextCallHierarchyBuilder callHierarchyBuilder = configureBuilderWith(callHierarchyBuilderProvider.get(), resourceSet); + callHierarchyBuilder.setHierarchyType(ICallHierarchyBuilder.CallHierarchyType.CALLER); + return callHierarchyBuilder; + }); + configurator.apply(it); + }); + } + + protected void testBuildCalleeHierarchy( + Procedure1 configurator) { + testBuildHierarchy((AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration it) -> { + it.setHierarchyBuilderProvider((ResourceSet resourceSet) -> { + XtextCallHierarchyBuilder callHierarchyBuilder = configureBuilderWith(callHierarchyBuilderProvider.get(), resourceSet); + callHierarchyBuilder.setHierarchyType(ICallHierarchyBuilder.CallHierarchyType.CALLEE); + return callHierarchyBuilder; + }); + configurator.apply(it); + }); + } + + @Test + public void testBuildHierarchy_01() { + testBuildHierarchy((AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration it) -> { + String model = "grammar org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals\n" + + "\n" + + "generate callHierarchyBuilderTestLanguage 'http://www.eclipse.org/2010/tmf/xtext/CallHierarchyBuilderTestLanguage'\n" + + "\n" + "Model:\n" + " element+=Element*\n" + ";\n" + "\n" + "Element:\n" + " name=ID\n" + ";\n"; + it.getModels().add(Pair.of("callHierarchyBuilderTestLanguage.xtext", model)); + it.setIndex(Iterables.getFirst(it.getModels(), null).getValue().indexOf("Element*")); + String expectedHierarchy = "Element {\n" + + " grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage\n" + " Model {\n" + + " grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage\n" + + " 'element+=Element*' [250, 17]\n" + " }\n" + "}\n"; + it.setExpectedHierarchy(expectedHierarchy); + }); + } + + @Test + public void testBuildCalleeHierarchy_01() { + testBuildCalleeHierarchy((AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration it) -> { + String model = "grammar org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals\n" + + "\n" + + "generate callHierarchyBuilderTestLanguage 'http://www.eclipse.org/2010/tmf/xtext/CallHierarchyBuilderTestLanguage'\n" + + "\n" + "Model:\n" + " element+=Element*\n" + ";\n" + "\n" + "Element:\n" + " name=ID\n" + ";\n"; + it.getModels().add(Pair.of("callHierarchyBuilderTestLanguage.xtext", model)); + it.setIndex(Iterables.getFirst(it.getModels(), null).getValue().indexOf("Model")); + String expectedHierarchy = "Model {\n" + + " grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage\n" + " Element {\n" + + " grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage\n" + + " 'element+=Element*' [250, 17]\n" + " ID {\n" + " grammar: org.eclipse.xtext.common.Terminals\n" + + " 'name=ID' [281, 7]\n" + " }\n" + " }\n" + "}\n"; + it.setExpectedHierarchy(expectedHierarchy); + }); + } + + @Test + public void testBuildHierarchy_02() { + testBuildHierarchy((AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration it) -> { + String model = "grammar org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals\n" + + "\n" + + "generate callHierarchyBuilderTestLanguage 'http://www.eclipse.org/2010/tmf/xtext/CallHierarchyBuilderTestLanguage'\n" + + "\n" + "Model:\n" + " element+=AbstractElement*\n" + ";\n" + "\n" + "AbstractElement:\n" + " Element |\n" + + " '(' Model ')'\n" + ";\n" + "\n" + "Element:\n" + " name=ID\n" + ";\n"; + it.getModels().add(Pair.of("callHierarchyBuilderTestLanguage.xtext", model)); + it.setIndex(Iterables.getFirst(it.getModels(), null).getValue().indexOf("AbstractElement*")); + String expectedHierarchy = "AbstractElement {\n" + + " grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage\n" + " Model {\n" + + " grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage\n" + + " 'element+=AbstractElement*' [250, 25]\n" + " AbstractElement {\n" + + " grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage\n" + + " 'Model' [312, 5]\n" + " }\n" + " }\n" + "}\n"; + it.setExpectedHierarchy(expectedHierarchy); + }); + } + + @Test + public void testBuildHierarchy_03() { + testBuildHierarchy((AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration it) -> { + String model = "grammar org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals\n" + + "\n" + + "generate callHierarchyBuilderTestLanguage 'http://www.eclipse.org/2010/tmf/xtext/CallHierarchyBuilderTestLanguage'\n" + + "\n" + "Model:\n" + " element+=Element element+=Element element+=Element\n" + ";\n" + "\n" + "Element:\n" + + " name=ID\n" + ";\n"; + it.getModels().add(Pair.of("callHierarchyBuilderTestLanguage.xtext", model)); + it.setIndex(Iterables.getFirst(it.getModels(), null).getValue().lastIndexOf("Element")); + String expectedHierarchy = "Element {\n" + + " grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage\n" + " Model {\n" + + " grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage\n" + + " 'element+=Element' [250, 16]\n" + " 'element+=Element' [267, 16]\n" + " 'element+=Element' [284, 16]\n" + + " }\n" + "}\n"; + it.setExpectedHierarchy(expectedHierarchy); + }); + } + + @Test + public void testBuildHierarchy_04() { + testBuildHierarchy((AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration it) -> { + String model1 = "grammar org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals hidden(ID)\n" + + "\n" + + "generate baseCallHierarchyBuilderTestLanguage 'http://www.eclipse.org/2010/tmf/xtext/BaseCallHierarchyBuilderTestLanguage'\n" + + "\n" + "Model: name=ID;\n"; + it.getModels().add(Pair.of("baseCallHierarchyBuilderTestLanguage.xtext", model1)); + String model2 = "grammar org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage with org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage\n" + + "\n" + + "generate callHierarchyBuilderTestLanguage 'http://www.eclipse.org/2010/tmf/xtext/CallHierarchyBuilderTestLanguage'\n" + + "\n" + "@Override\n" + "Model: name=ID;\n"; + it.getModels().add(Pair.of("callHierarchyBuilderTestLanguage.xtext", model2)); + it.setResourceURI(Iterables.getFirst(it.getModels(), null).getKey()); + it.setIndex(Iterables.getFirst(it.getModels(), null).getValue().indexOf("ID")); + String expectedHierarchy = "ID {\n" + " grammar: org.eclipse.xtext.common.Terminals\n" + + " org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage {\n" + + " grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage\n" + + " 'ID' [136, 2]\n" + " }\n" + " Model {\n" + + " grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage\n" + + " 'name=ID' [272, 7]\n" + " }\n" + " Model {\n" + + " grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage\n" + + " 'name=ID' [305, 7]\n" + " }\n" + "}\n"; + it.setExpectedHierarchy(expectedHierarchy); + }); + } + + @Test + public void testBuildHierarchy_05() { + testBuildHierarchy((AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration it) -> { + String model = "grammar org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals\n" + + "\n" + + "generate baseCallHierarchyBuilderTestLanguage 'http://www.eclipse.org/2010/tmf/xtext/BaseCallHierarchyBuilderTestLanguage'\n" + + "\n" + "Model: name=ID;\n"; + it.getModels().add(Pair.of("baseCallHierarchyBuilderTestLanguage.xtext", model)); + it.setIndex(Iterables.getFirst(it.getModels(), null).getValue().indexOf("BaseCallHierarchyBuilderTestLanguage")); + it.setExpectedHierarchy(""); + }); + } + + @Test + public void testBuildHierarchy_06() { + testBuildHierarchy((AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration it) -> { + String model1 = "grammar org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals\n" + + "\n" + + "generate baseCallHierarchyBuilderTestLanguage 'http://www.eclipse.org/2010/tmf/xtext/BaseCallHierarchyBuilderTestLanguage'\n" + + "\n" + "Model: \n" + " elements+=Element*\n" + ";\n" + "\n" + "Element:\n" + " name=ID\n" + ";\n"; + it.getModels().add(Pair.of("baseCallHierarchyBuilderTestLanguage.xtext", model1)); + String model2 = "grammar org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage with org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage\n" + + "\n" + + "generate callHierarchyBuilderTestLanguage 'http://www.eclipse.org/2010/tmf/xtext/CallHierarchyBuilderTestLanguage'\n" + + "\n" + "Model2:\n" + " elements+=Element*\n" + ";\n" + "\n" + "@Override\n" + "Element:\n" + " name=ID\n" + ";\n"; + it.getModels().add(Pair.of("callHierarchyBuilderTestLanguage.xtext", model2)); + it.setResourceURI(Iterables.getFirst(it.getModels(), null).getKey()); + it.setIndex(Iterables.getFirst(it.getModels(), null).getValue().indexOf("Element")); + String expectedHierarchy = "Element {\n" + + " grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage\n" + " Model {\n" + + " grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage\n" + + " 'elements+=Element*' [263, 18]\n" + " }\n" + " Model2 {\n" + + " grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage\n" + + " 'elements+=Element*' [297, 18]\n" + " }\n" + "}\n"; + it.setExpectedHierarchy(expectedHierarchy); + }); + } + + @Test + public void testBuildHierarchy_07() { + testBuildHierarchy((AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration it) -> { + String model1 = "grammar org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals\n" + + "\n" + + "generate baseCallHierarchyBuilderTestLanguage 'http://www.eclipse.org/2010/tmf/xtext/BaseCallHierarchyBuilderTestLanguage'\n" + + "\n" + "Model: \n" + " elements+=Element*\n" + ";\n" + "\n" + "Element:\n" + " name=ID\n" + ";\n"; + it.getModels().add(Pair.of("baseCallHierarchyBuilderTestLanguage.xtext", model1)); + String model2 = "grammar org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage with org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage\n" + + "\n" + + "generate callHierarchyBuilderTestLanguage 'http://www.eclipse.org/2010/tmf/xtext/CallHierarchyBuilderTestLanguage'\n" + + "\n" + "Model2:\n" + " elements+=Element*\n" + ";\n" + "\n" + "@Override\n" + "Element:\n" + " name=ID\n" + ";\n"; + it.getModels().add(Pair.of("callHierarchyBuilderTestLanguage.xtext", model2)); + it.setResourceURI(Iterables.getLast(it.getModels()).getKey()); + it.setIndex(Iterables.getLast(it.getModels()).getValue().indexOf("Element")); + String expectedHierarchy = "Element {\n" + + " grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage\n" + " Model {\n" + + " grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage\n" + + " 'elements+=Element*' [263, 18]\n" + " }\n" + " Model2 {\n" + + " grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage\n" + + " 'elements+=Element*' [297, 18]\n" + " }\n" + "}\n"; + it.setExpectedHierarchy(expectedHierarchy); + }); + } + + @Test + public void testBuildHierarchy_08() { + testBuildHierarchy((AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration it) -> { + String model = "grammar org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals\n" + + "\n" + + "generate callHierarchyBuilderTestLanguage 'http://www.eclipse.org/2010/tmf/xtext/CallHierarchyBuilderTestLanguage'\n" + + "\n" + "Model:\n" + " elements+=[Element]\n" + " elements+=[Element|ID]\n" + ";\n" + "\n" + "Element:\n" + + " name=ID\n" + ";\n"; + it.getModels().add(Pair.of("callHierarchyBuilderTestLanguage.xtext", model)); + it.setIndex(Iterables.getFirst(it.getModels(), null).getValue().lastIndexOf("ID")); + String expectedHierarchy = "ID {\n" + " grammar: org.eclipse.xtext.common.Terminals\n" + " Model {\n" + + " grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage\n" + + " 'elements+=[Element]' [250, 19]\n" + " 'elements+=[Element|ID]' [271, 22]\n" + " }\n" + " Element {\n" + + " grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage\n" + + " 'name=ID' [307, 7]\n" + " }\n" + "}\n"; + it.setExpectedHierarchy(expectedHierarchy); + }); + } + + @Override + protected String internalToExpectation(IHierarchyNode node, IHierarchyBuilder builder) { + String superExpectation = super.internalToExpectation(node, builder); + if (node instanceof XtextCallHierarchyNode) { + return Strings + .toUnixLineSeparator("grammar: " + ((XtextCallHierarchyNode) node).getGrammarDescription() + "\n" + superExpectation); + } + return Strings.toUnixLineSeparator(superExpectation); + } + + @Override + protected String toExpectation(URI rootURI, IHierarchyBuilder builder) { + return Strings.toUnixLineSeparator(super.toExpectation(rootURI, builder)); + } +} diff --git a/org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/hierarchy/XtextCallHierarchyBuilderTest.xtend b/org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/hierarchy/XtextCallHierarchyBuilderTest.xtend deleted file mode 100644 index e4bb5d9ee8..0000000000 --- a/org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/hierarchy/XtextCallHierarchyBuilderTest.xtend +++ /dev/null @@ -1,395 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016, 2017 TypeFox GmbH (http://www.typefox.io) and others. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - *******************************************************************************/ -package org.eclipse.xtext.xtext.ui.editor.hierarchy - -import static org.eclipse.xtext.ui.testing.util.LineDelimiters.toUnix; - -import com.google.inject.Inject -import com.google.inject.Provider -import org.eclipse.xtext.ide.editor.hierarchy.DefaultCallHierarchyBuilder.CallHierarchyType -import org.eclipse.xtext.testing.InjectWith -import org.eclipse.xtext.testing.XtextRunner -import org.eclipse.xtext.junit4.ide.AbstractHierarchyBuilderTest -import org.eclipse.xtext.xtext.ui.XtextInjectorProvider -import org.eclipse.xtext.ui.editor.hierarchy.XtextCallHierarchyBuilder -import org.eclipse.xtext.ui.editor.hierarchy.XtextCallHierarchyNode -import org.junit.Test -import org.junit.runner.RunWith -import org.eclipse.xtext.ide.editor.hierarchy.IHierarchyBuilder -import org.eclipse.xtext.ide.editor.hierarchy.IHierarchyNode - -/** - * @author kosyakov - Initial contribution and API - */ -@RunWith(XtextRunner) -@InjectWith(XtextInjectorProvider) -class XtextCallHierarchyBuilderTest extends AbstractHierarchyBuilderTest { - - @Inject - Provider callHierarchyBuilderProvider - - override protected testBuildHierarchy((HierarchyBuilderTestConfiguration)=>void configurator) { - super.testBuildHierarchy [ - hierarchyBuilderProvider = [ resourceSet | - val callHierarchyBuilder = callHierarchyBuilderProvider.get.configureBuilderWith(resourceSet) - callHierarchyBuilder.hierarchyType = CallHierarchyType.CALLER - return callHierarchyBuilder - ] - configurator.apply(it) - ] - } - - protected def void testBuildCalleeHierarchy((HierarchyBuilderTestConfiguration)=>void configurator) { - super.testBuildHierarchy [ - hierarchyBuilderProvider = [ resourceSet | - val callHierarchyBuilder = callHierarchyBuilderProvider.get.configureBuilderWith(resourceSet) - callHierarchyBuilder.hierarchyType = CallHierarchyType.CALLEE - return callHierarchyBuilder - ] - configurator.apply(it) - ] - } - - @Test - def void testBuildHierarchy_01() { - testBuildHierarchy[ - models += ('callHierarchyBuilderTestLanguage.xtext' -> toUnix(''' - grammar org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals - - generate callHierarchyBuilderTestLanguage "http://www.eclipse.org/2010/tmf/xtext/CallHierarchyBuilderTestLanguage" - - Model: - element+=Element* - ; - - Element: - name=ID - ; - ''')) - - index = models.head.value.indexOf('Element*') - expectedHierarchy = ''' - Element { - grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage - Model { - grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage - 'element+=Element*' [250, 17] - } - } - ''' - ] - } - - @Test - def void testBuildCalleeHierarchy_01() { - testBuildCalleeHierarchy[ - models += ('callHierarchyBuilderTestLanguage.xtext' -> toUnix(''' - grammar org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals - - generate callHierarchyBuilderTestLanguage "http://www.eclipse.org/2010/tmf/xtext/CallHierarchyBuilderTestLanguage" - - Model: - element+=Element* - ; - - Element: - name=ID - ; - ''')) - - index = models.head.value.indexOf('Model') - expectedHierarchy = ''' - Model { - grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage - Element { - grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage - 'element+=Element*' [250, 17] - ID { - grammar: org.eclipse.xtext.common.Terminals - 'name=ID' [281, 7] - } - } - } - ''' - ] - } - - @Test - def void testBuildHierarchy_02() { - testBuildHierarchy[ - models += ('callHierarchyBuilderTestLanguage.xtext' -> toUnix(''' - grammar org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals - - generate callHierarchyBuilderTestLanguage "http://www.eclipse.org/2010/tmf/xtext/CallHierarchyBuilderTestLanguage" - - Model: - element+=AbstractElement* - ; - - AbstractElement: - Element | - '(' Model ')' - ; - - Element: - name=ID - ; - ''')) - - index = models.head.value.indexOf('AbstractElement*') - expectedHierarchy = ''' - AbstractElement { - grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage - Model { - grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage - 'element+=AbstractElement*' [250, 25] - AbstractElement { - grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage - 'Model' [312, 5] - } - } - } - ''' - ] - } - - @Test - def void testBuildHierarchy_03() { - testBuildHierarchy[ - models += ('callHierarchyBuilderTestLanguage.xtext' -> toUnix(''' - grammar org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals - - generate callHierarchyBuilderTestLanguage "http://www.eclipse.org/2010/tmf/xtext/CallHierarchyBuilderTestLanguage" - - Model: - element+=Element element+=Element element+=Element - ; - - Element: - name=ID - ; - ''')) - - index = models.head.value.lastIndexOf('Element') - expectedHierarchy = ''' - Element { - grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage - Model { - grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage - 'element+=Element' [250, 16] - 'element+=Element' [267, 16] - 'element+=Element' [284, 16] - } - } - ''' - ] - } - - @Test - def void testBuildHierarchy_04() { - testBuildHierarchy[ - models += ('baseCallHierarchyBuilderTestLanguage.xtext' -> toUnix(''' - grammar org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals hidden(ID) - - generate baseCallHierarchyBuilderTestLanguage "http://www.eclipse.org/2010/tmf/xtext/BaseCallHierarchyBuilderTestLanguage" - - Model: name=ID; - ''')) - models += ('callHierarchyBuilderTestLanguage.xtext' -> toUnix(''' - grammar org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage with org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage - - generate callHierarchyBuilderTestLanguage "http://www.eclipse.org/2010/tmf/xtext/CallHierarchyBuilderTestLanguage" - - @Override - Model: name=ID; - ''')) - - resourceURI = models.head.key - index = models.head.value.indexOf('ID') - expectedHierarchy = ''' - ID { - grammar: org.eclipse.xtext.common.Terminals - org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage { - grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage - 'ID' [136, 2] - } - Model { - grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage - 'name=ID' [272, 7] - } - Model { - grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage - 'name=ID' [305, 7] - } - } - ''' - ] - } - - @Test - def void testBuildHierarchy_05() { - testBuildHierarchy[ - models += ('baseCallHierarchyBuilderTestLanguage.xtext' -> toUnix(''' - grammar org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals - - generate baseCallHierarchyBuilderTestLanguage "http://www.eclipse.org/2010/tmf/xtext/BaseCallHierarchyBuilderTestLanguage" - - Model: name=ID; - ''')) - - index = models.head.value.indexOf('BaseCallHierarchyBuilderTestLanguage') - expectedHierarchy = '' - ] - } - - @Test - def void testBuildHierarchy_06() { - testBuildHierarchy[ - models += ('baseCallHierarchyBuilderTestLanguage.xtext' -> toUnix(''' - grammar org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals - - generate baseCallHierarchyBuilderTestLanguage "http://www.eclipse.org/2010/tmf/xtext/BaseCallHierarchyBuilderTestLanguage" - - Model: - elements+=Element* - ; - - Element: - name=ID - ; - ''')) - models += ('callHierarchyBuilderTestLanguage.xtext' -> toUnix(''' - grammar org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage with org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage - - generate callHierarchyBuilderTestLanguage "http://www.eclipse.org/2010/tmf/xtext/CallHierarchyBuilderTestLanguage" - - Model2: - elements+=Element* - ; - - @Override - Element: - name=ID - ; - ''')) - - resourceURI = models.head.key - index = models.head.value.indexOf('Element') - expectedHierarchy = ''' - Element { - grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage - Model { - grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage - 'elements+=Element*' [263, 18] - } - Model2 { - grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage - 'elements+=Element*' [297, 18] - } - } - ''' - ] - } - - @Test - def void testBuildHierarchy_07() { - testBuildHierarchy[ - models += ('baseCallHierarchyBuilderTestLanguage.xtext' -> toUnix(''' - grammar org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals - - generate baseCallHierarchyBuilderTestLanguage "http://www.eclipse.org/2010/tmf/xtext/BaseCallHierarchyBuilderTestLanguage" - - Model: - elements+=Element* - ; - - Element: - name=ID - ; - ''')) - models += ('callHierarchyBuilderTestLanguage.xtext' -> toUnix(''' - grammar org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage with org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage - - generate callHierarchyBuilderTestLanguage "http://www.eclipse.org/2010/tmf/xtext/CallHierarchyBuilderTestLanguage" - - Model2: - elements+=Element* - ; - - @Override - Element: - name=ID - ; - ''')) - - resourceURI = models.last.key - index = models.last.value.indexOf('Element') - expectedHierarchy = ''' - Element { - grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage - Model { - grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage - 'elements+=Element*' [263, 18] - } - Model2 { - grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage - 'elements+=Element*' [297, 18] - } - } - ''' - ] - } - - @Test - def void testBuildHierarchy_08() { - testBuildHierarchy[ - models += ('callHierarchyBuilderTestLanguage.xtext' -> toUnix(''' - grammar org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals - - generate callHierarchyBuilderTestLanguage "http://www.eclipse.org/2010/tmf/xtext/CallHierarchyBuilderTestLanguage" - - Model: - elements+=[Element] - elements+=[Element|ID] - ; - - Element: - name=ID - ; - ''')) - - index = models.head.value.lastIndexOf('ID') - expectedHierarchy = ''' - ID { - grammar: org.eclipse.xtext.common.Terminals - Model { - grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage - 'elements+=[Element]' [250, 19] - 'elements+=[Element|ID]' [271, 22] - } - Element { - grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage - 'name=ID' [307, 7] - } - } - ''' - ] - } - - override protected internalToExpectation(IHierarchyNode node, IHierarchyBuilder builder) { - val superExpectation = super.internalToExpectation(node, builder) - if (node instanceof XtextCallHierarchyNode) - return ''' - grammar: �node.grammarDescription� - �superExpectation� - ''' - return superExpectation - } - -} diff --git a/org.eclipse.xtext.xtext.ui.tests/xtend-gen/org/eclipse/xtext/xtext/ui/editor/hierarchy/XtextCallHierarchyBuilderTest.java b/org.eclipse.xtext.xtext.ui.tests/xtend-gen/org/eclipse/xtext/xtext/ui/editor/hierarchy/XtextCallHierarchyBuilderTest.java deleted file mode 100644 index bf67d4f711..0000000000 --- a/org.eclipse.xtext.xtext.ui.tests/xtend-gen/org/eclipse/xtext/xtext/ui/editor/hierarchy/XtextCallHierarchyBuilderTest.java +++ /dev/null @@ -1,716 +0,0 @@ -/** - * Copyright (c) 2016, 2017 TypeFox GmbH (http://www.typefox.io) and others. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.xtext.xtext.ui.editor.hierarchy; - -import com.google.inject.Inject; -import com.google.inject.Provider; -import java.util.Collection; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.ide.editor.hierarchy.ICallHierarchyBuilder; -import org.eclipse.xtext.ide.editor.hierarchy.IHierarchyBuilder; -import org.eclipse.xtext.ide.editor.hierarchy.IHierarchyNode; -import org.eclipse.xtext.junit4.ide.AbstractHierarchyBuilderTest; -import org.eclipse.xtext.resource.IEObjectDescription; -import org.eclipse.xtext.testing.InjectWith; -import org.eclipse.xtext.testing.XtextRunner; -import org.eclipse.xtext.ui.editor.hierarchy.XtextCallHierarchyBuilder; -import org.eclipse.xtext.ui.editor.hierarchy.XtextCallHierarchyNode; -import org.eclipse.xtext.ui.testing.util.LineDelimiters; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.Pair; -import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; -import org.eclipse.xtext.xtext.ui.XtextInjectorProvider; -import org.junit.Test; -import org.junit.runner.RunWith; - -/** - * @author kosyakov - Initial contribution and API - */ -@RunWith(XtextRunner.class) -@InjectWith(XtextInjectorProvider.class) -@SuppressWarnings("all") -public class XtextCallHierarchyBuilderTest extends AbstractHierarchyBuilderTest { - @Inject - private Provider callHierarchyBuilderProvider; - - @Override - protected void testBuildHierarchy(final Procedure1 configurator) { - final Procedure1 _function = (AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration it) -> { - final Function1 _function_1 = (ResourceSet resourceSet) -> { - final XtextCallHierarchyBuilder callHierarchyBuilder = this.configureBuilderWith(this.callHierarchyBuilderProvider.get(), resourceSet); - callHierarchyBuilder.setHierarchyType(ICallHierarchyBuilder.CallHierarchyType.CALLER); - return callHierarchyBuilder; - }; - it.setHierarchyBuilderProvider(_function_1); - configurator.apply(it); - }; - super.testBuildHierarchy(_function); - } - - protected void testBuildCalleeHierarchy(final Procedure1 configurator) { - final Procedure1 _function = (AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration it) -> { - final Function1 _function_1 = (ResourceSet resourceSet) -> { - final XtextCallHierarchyBuilder callHierarchyBuilder = this.configureBuilderWith(this.callHierarchyBuilderProvider.get(), resourceSet); - callHierarchyBuilder.setHierarchyType(ICallHierarchyBuilder.CallHierarchyType.CALLEE); - return callHierarchyBuilder; - }; - it.setHierarchyBuilderProvider(_function_1); - configurator.apply(it); - }; - super.testBuildHierarchy(_function); - } - - @Test - public void testBuildHierarchy_01() { - final Procedure1 _function = (AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration it) -> { - Collection> _models = it.getModels(); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("grammar org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals"); - _builder.newLine(); - _builder.newLine(); - _builder.append("generate callHierarchyBuilderTestLanguage \"http://www.eclipse.org/2010/tmf/xtext/CallHierarchyBuilderTestLanguage\""); - _builder.newLine(); - _builder.newLine(); - _builder.append("Model:"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("element+=Element*"); - _builder.newLine(); - _builder.append(";"); - _builder.newLine(); - _builder.newLine(); - _builder.append("Element:"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("name=ID"); - _builder.newLine(); - _builder.append(";"); - _builder.newLine(); - String _unix = LineDelimiters.toUnix(_builder.toString()); - Pair _mappedTo = Pair.of("callHierarchyBuilderTestLanguage.xtext", _unix); - _models.add(_mappedTo); - it.setIndex(IterableExtensions.>head(it.getModels()).getValue().indexOf("Element*")); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("Element {"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("Model {"); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage"); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("\'element+=Element*\' [250, 17]"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("}"); - _builder_1.newLine(); - _builder_1.append("}"); - _builder_1.newLine(); - it.setExpectedHierarchy(_builder_1.toString()); - }; - this.testBuildHierarchy(_function); - } - - @Test - public void testBuildCalleeHierarchy_01() { - final Procedure1 _function = (AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration it) -> { - Collection> _models = it.getModels(); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("grammar org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals"); - _builder.newLine(); - _builder.newLine(); - _builder.append("generate callHierarchyBuilderTestLanguage \"http://www.eclipse.org/2010/tmf/xtext/CallHierarchyBuilderTestLanguage\""); - _builder.newLine(); - _builder.newLine(); - _builder.append("Model:"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("element+=Element*"); - _builder.newLine(); - _builder.append(";"); - _builder.newLine(); - _builder.newLine(); - _builder.append("Element:"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("name=ID"); - _builder.newLine(); - _builder.append(";"); - _builder.newLine(); - String _unix = LineDelimiters.toUnix(_builder.toString()); - Pair _mappedTo = Pair.of("callHierarchyBuilderTestLanguage.xtext", _unix); - _models.add(_mappedTo); - it.setIndex(IterableExtensions.>head(it.getModels()).getValue().indexOf("Model")); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("Model {"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("Element {"); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage"); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("\'element+=Element*\' [250, 17]"); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("ID {"); - _builder_1.newLine(); - _builder_1.append("\t\t\t"); - _builder_1.append("grammar: org.eclipse.xtext.common.Terminals"); - _builder_1.newLine(); - _builder_1.append("\t\t\t"); - _builder_1.append("\'name=ID\' [281, 7]"); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("}"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("}"); - _builder_1.newLine(); - _builder_1.append("}"); - _builder_1.newLine(); - it.setExpectedHierarchy(_builder_1.toString()); - }; - this.testBuildCalleeHierarchy(_function); - } - - @Test - public void testBuildHierarchy_02() { - final Procedure1 _function = (AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration it) -> { - Collection> _models = it.getModels(); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("grammar org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals"); - _builder.newLine(); - _builder.newLine(); - _builder.append("generate callHierarchyBuilderTestLanguage \"http://www.eclipse.org/2010/tmf/xtext/CallHierarchyBuilderTestLanguage\""); - _builder.newLine(); - _builder.newLine(); - _builder.append("Model:"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("element+=AbstractElement*"); - _builder.newLine(); - _builder.append(";"); - _builder.newLine(); - _builder.newLine(); - _builder.append("AbstractElement:"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("Element |"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\'(\' Model \')\'"); - _builder.newLine(); - _builder.append(";"); - _builder.newLine(); - _builder.newLine(); - _builder.append("Element:"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("name=ID"); - _builder.newLine(); - _builder.append(";"); - _builder.newLine(); - String _unix = LineDelimiters.toUnix(_builder.toString()); - Pair _mappedTo = Pair.of("callHierarchyBuilderTestLanguage.xtext", _unix); - _models.add(_mappedTo); - it.setIndex(IterableExtensions.>head(it.getModels()).getValue().indexOf("AbstractElement*")); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("AbstractElement {"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("Model {"); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage"); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("\'element+=AbstractElement*\' [250, 25]"); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("AbstractElement {"); - _builder_1.newLine(); - _builder_1.append("\t\t\t"); - _builder_1.append("grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage"); - _builder_1.newLine(); - _builder_1.append("\t\t\t"); - _builder_1.append("\'Model\' [312, 5]"); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("}"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("}"); - _builder_1.newLine(); - _builder_1.append("}"); - _builder_1.newLine(); - it.setExpectedHierarchy(_builder_1.toString()); - }; - this.testBuildHierarchy(_function); - } - - @Test - public void testBuildHierarchy_03() { - final Procedure1 _function = (AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration it) -> { - Collection> _models = it.getModels(); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("grammar org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals"); - _builder.newLine(); - _builder.newLine(); - _builder.append("generate callHierarchyBuilderTestLanguage \"http://www.eclipse.org/2010/tmf/xtext/CallHierarchyBuilderTestLanguage\""); - _builder.newLine(); - _builder.newLine(); - _builder.append("Model:"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("element+=Element element+=Element element+=Element"); - _builder.newLine(); - _builder.append(";"); - _builder.newLine(); - _builder.newLine(); - _builder.append("Element:"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("name=ID"); - _builder.newLine(); - _builder.append(";"); - _builder.newLine(); - String _unix = LineDelimiters.toUnix(_builder.toString()); - Pair _mappedTo = Pair.of("callHierarchyBuilderTestLanguage.xtext", _unix); - _models.add(_mappedTo); - it.setIndex(IterableExtensions.>head(it.getModels()).getValue().lastIndexOf("Element")); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("Element {"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("Model {"); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage"); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("\'element+=Element\' [250, 16]"); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("\'element+=Element\' [267, 16]"); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("\'element+=Element\' [284, 16]"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("}"); - _builder_1.newLine(); - _builder_1.append("}"); - _builder_1.newLine(); - it.setExpectedHierarchy(_builder_1.toString()); - }; - this.testBuildHierarchy(_function); - } - - @Test - public void testBuildHierarchy_04() { - final Procedure1 _function = (AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration it) -> { - Collection> _models = it.getModels(); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("grammar org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals hidden(ID)"); - _builder.newLine(); - _builder.newLine(); - _builder.append("generate baseCallHierarchyBuilderTestLanguage \"http://www.eclipse.org/2010/tmf/xtext/BaseCallHierarchyBuilderTestLanguage\""); - _builder.newLine(); - _builder.newLine(); - _builder.append("Model: name=ID;"); - _builder.newLine(); - String _unix = LineDelimiters.toUnix(_builder.toString()); - Pair _mappedTo = Pair.of("baseCallHierarchyBuilderTestLanguage.xtext", _unix); - _models.add(_mappedTo); - Collection> _models_1 = it.getModels(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("grammar org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage with org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage"); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("generate callHierarchyBuilderTestLanguage \"http://www.eclipse.org/2010/tmf/xtext/CallHierarchyBuilderTestLanguage\""); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("@Override"); - _builder_1.newLine(); - _builder_1.append("Model: name=ID;"); - _builder_1.newLine(); - String _unix_1 = LineDelimiters.toUnix(_builder_1.toString()); - Pair _mappedTo_1 = Pair.of("callHierarchyBuilderTestLanguage.xtext", _unix_1); - _models_1.add(_mappedTo_1); - it.setResourceURI(IterableExtensions.>head(it.getModels()).getKey()); - it.setIndex(IterableExtensions.>head(it.getModels()).getValue().indexOf("ID")); - StringConcatenation _builder_2 = new StringConcatenation(); - _builder_2.append("ID {"); - _builder_2.newLine(); - _builder_2.append("\t"); - _builder_2.append("grammar: org.eclipse.xtext.common.Terminals"); - _builder_2.newLine(); - _builder_2.append("\t"); - _builder_2.append("org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage {"); - _builder_2.newLine(); - _builder_2.append("\t\t"); - _builder_2.append("grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage"); - _builder_2.newLine(); - _builder_2.append("\t\t"); - _builder_2.append("\'ID\' [136, 2]"); - _builder_2.newLine(); - _builder_2.append("\t"); - _builder_2.append("}"); - _builder_2.newLine(); - _builder_2.append("\t"); - _builder_2.append("Model {"); - _builder_2.newLine(); - _builder_2.append("\t\t"); - _builder_2.append("grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage"); - _builder_2.newLine(); - _builder_2.append("\t\t"); - _builder_2.append("\'name=ID\' [272, 7]"); - _builder_2.newLine(); - _builder_2.append("\t"); - _builder_2.append("}"); - _builder_2.newLine(); - _builder_2.append("\t"); - _builder_2.append("Model {"); - _builder_2.newLine(); - _builder_2.append("\t\t"); - _builder_2.append("grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage"); - _builder_2.newLine(); - _builder_2.append("\t\t"); - _builder_2.append("\'name=ID\' [305, 7]"); - _builder_2.newLine(); - _builder_2.append("\t"); - _builder_2.append("}"); - _builder_2.newLine(); - _builder_2.append("}"); - _builder_2.newLine(); - it.setExpectedHierarchy(_builder_2.toString()); - }; - this.testBuildHierarchy(_function); - } - - @Test - public void testBuildHierarchy_05() { - final Procedure1 _function = (AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration it) -> { - Collection> _models = it.getModels(); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("grammar org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals"); - _builder.newLine(); - _builder.newLine(); - _builder.append("generate baseCallHierarchyBuilderTestLanguage \"http://www.eclipse.org/2010/tmf/xtext/BaseCallHierarchyBuilderTestLanguage\""); - _builder.newLine(); - _builder.newLine(); - _builder.append("Model: name=ID;"); - _builder.newLine(); - String _unix = LineDelimiters.toUnix(_builder.toString()); - Pair _mappedTo = Pair.of("baseCallHierarchyBuilderTestLanguage.xtext", _unix); - _models.add(_mappedTo); - it.setIndex(IterableExtensions.>head(it.getModels()).getValue().indexOf("BaseCallHierarchyBuilderTestLanguage")); - it.setExpectedHierarchy(""); - }; - this.testBuildHierarchy(_function); - } - - @Test - public void testBuildHierarchy_06() { - final Procedure1 _function = (AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration it) -> { - Collection> _models = it.getModels(); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("grammar org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals"); - _builder.newLine(); - _builder.newLine(); - _builder.append("generate baseCallHierarchyBuilderTestLanguage \"http://www.eclipse.org/2010/tmf/xtext/BaseCallHierarchyBuilderTestLanguage\""); - _builder.newLine(); - _builder.newLine(); - _builder.append("Model: "); - _builder.newLine(); - _builder.append("\t"); - _builder.append("elements+=Element*"); - _builder.newLine(); - _builder.append(";"); - _builder.newLine(); - _builder.newLine(); - _builder.append("Element:"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("name=ID"); - _builder.newLine(); - _builder.append(";"); - _builder.newLine(); - String _unix = LineDelimiters.toUnix(_builder.toString()); - Pair _mappedTo = Pair.of("baseCallHierarchyBuilderTestLanguage.xtext", _unix); - _models.add(_mappedTo); - Collection> _models_1 = it.getModels(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("grammar org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage with org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage"); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("generate callHierarchyBuilderTestLanguage \"http://www.eclipse.org/2010/tmf/xtext/CallHierarchyBuilderTestLanguage\""); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("Model2:"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("elements+=Element*"); - _builder_1.newLine(); - _builder_1.append(";"); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("@Override"); - _builder_1.newLine(); - _builder_1.append("Element:"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("name=ID"); - _builder_1.newLine(); - _builder_1.append(";"); - _builder_1.newLine(); - String _unix_1 = LineDelimiters.toUnix(_builder_1.toString()); - Pair _mappedTo_1 = Pair.of("callHierarchyBuilderTestLanguage.xtext", _unix_1); - _models_1.add(_mappedTo_1); - it.setResourceURI(IterableExtensions.>head(it.getModels()).getKey()); - it.setIndex(IterableExtensions.>head(it.getModels()).getValue().indexOf("Element")); - StringConcatenation _builder_2 = new StringConcatenation(); - _builder_2.append("Element {"); - _builder_2.newLine(); - _builder_2.append("\t"); - _builder_2.append("grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage"); - _builder_2.newLine(); - _builder_2.append("\t"); - _builder_2.append("Model {"); - _builder_2.newLine(); - _builder_2.append("\t\t"); - _builder_2.append("grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage"); - _builder_2.newLine(); - _builder_2.append("\t\t"); - _builder_2.append("\'elements+=Element*\' [263, 18]"); - _builder_2.newLine(); - _builder_2.append("\t"); - _builder_2.append("}"); - _builder_2.newLine(); - _builder_2.append("\t"); - _builder_2.append("Model2 {"); - _builder_2.newLine(); - _builder_2.append("\t\t"); - _builder_2.append("grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage"); - _builder_2.newLine(); - _builder_2.append("\t\t"); - _builder_2.append("\'elements+=Element*\' [297, 18]"); - _builder_2.newLine(); - _builder_2.append("\t"); - _builder_2.append("}"); - _builder_2.newLine(); - _builder_2.append("}"); - _builder_2.newLine(); - it.setExpectedHierarchy(_builder_2.toString()); - }; - this.testBuildHierarchy(_function); - } - - @Test - public void testBuildHierarchy_07() { - final Procedure1 _function = (AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration it) -> { - Collection> _models = it.getModels(); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("grammar org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals"); - _builder.newLine(); - _builder.newLine(); - _builder.append("generate baseCallHierarchyBuilderTestLanguage \"http://www.eclipse.org/2010/tmf/xtext/BaseCallHierarchyBuilderTestLanguage\""); - _builder.newLine(); - _builder.newLine(); - _builder.append("Model: "); - _builder.newLine(); - _builder.append("\t"); - _builder.append("elements+=Element*"); - _builder.newLine(); - _builder.append(";"); - _builder.newLine(); - _builder.newLine(); - _builder.append("Element:"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("name=ID"); - _builder.newLine(); - _builder.append(";"); - _builder.newLine(); - String _unix = LineDelimiters.toUnix(_builder.toString()); - Pair _mappedTo = Pair.of("baseCallHierarchyBuilderTestLanguage.xtext", _unix); - _models.add(_mappedTo); - Collection> _models_1 = it.getModels(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("grammar org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage with org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage"); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("generate callHierarchyBuilderTestLanguage \"http://www.eclipse.org/2010/tmf/xtext/CallHierarchyBuilderTestLanguage\""); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("Model2:"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("elements+=Element*"); - _builder_1.newLine(); - _builder_1.append(";"); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("@Override"); - _builder_1.newLine(); - _builder_1.append("Element:"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("name=ID"); - _builder_1.newLine(); - _builder_1.append(";"); - _builder_1.newLine(); - String _unix_1 = LineDelimiters.toUnix(_builder_1.toString()); - Pair _mappedTo_1 = Pair.of("callHierarchyBuilderTestLanguage.xtext", _unix_1); - _models_1.add(_mappedTo_1); - it.setResourceURI(IterableExtensions.>last(it.getModels()).getKey()); - it.setIndex(IterableExtensions.>last(it.getModels()).getValue().indexOf("Element")); - StringConcatenation _builder_2 = new StringConcatenation(); - _builder_2.append("Element {"); - _builder_2.newLine(); - _builder_2.append("\t"); - _builder_2.append("grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage"); - _builder_2.newLine(); - _builder_2.append("\t"); - _builder_2.append("Model {"); - _builder_2.newLine(); - _builder_2.append("\t\t"); - _builder_2.append("grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.BaseCallHierarchyBuilderTestLanguage"); - _builder_2.newLine(); - _builder_2.append("\t\t"); - _builder_2.append("\'elements+=Element*\' [263, 18]"); - _builder_2.newLine(); - _builder_2.append("\t"); - _builder_2.append("}"); - _builder_2.newLine(); - _builder_2.append("\t"); - _builder_2.append("Model2 {"); - _builder_2.newLine(); - _builder_2.append("\t\t"); - _builder_2.append("grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage"); - _builder_2.newLine(); - _builder_2.append("\t\t"); - _builder_2.append("\'elements+=Element*\' [297, 18]"); - _builder_2.newLine(); - _builder_2.append("\t"); - _builder_2.append("}"); - _builder_2.newLine(); - _builder_2.append("}"); - _builder_2.newLine(); - it.setExpectedHierarchy(_builder_2.toString()); - }; - this.testBuildHierarchy(_function); - } - - @Test - public void testBuildHierarchy_08() { - final Procedure1 _function = (AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration it) -> { - Collection> _models = it.getModels(); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("grammar org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage with org.eclipse.xtext.common.Terminals"); - _builder.newLine(); - _builder.newLine(); - _builder.append("generate callHierarchyBuilderTestLanguage \"http://www.eclipse.org/2010/tmf/xtext/CallHierarchyBuilderTestLanguage\""); - _builder.newLine(); - _builder.newLine(); - _builder.append("Model:"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("elements+=[Element]"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("elements+=[Element|ID]"); - _builder.newLine(); - _builder.append(";"); - _builder.newLine(); - _builder.newLine(); - _builder.append("Element:"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("name=ID"); - _builder.newLine(); - _builder.append(";"); - _builder.newLine(); - String _unix = LineDelimiters.toUnix(_builder.toString()); - Pair _mappedTo = Pair.of("callHierarchyBuilderTestLanguage.xtext", _unix); - _models.add(_mappedTo); - it.setIndex(IterableExtensions.>head(it.getModels()).getValue().lastIndexOf("ID")); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("ID {"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("grammar: org.eclipse.xtext.common.Terminals"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("Model {"); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage"); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("\'elements+=[Element]\' [250, 19]"); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("\'elements+=[Element|ID]\' [271, 22]"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("}"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("Element {"); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("grammar: org.eclipse.xtext.ui.tests.editor.hierarchy.CallHierarchyBuilderTestLanguage"); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("\'name=ID\' [307, 7]"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("}"); - _builder_1.newLine(); - _builder_1.append("}"); - _builder_1.newLine(); - it.setExpectedHierarchy(_builder_1.toString()); - }; - this.testBuildHierarchy(_function); - } - - @Override - protected String internalToExpectation(final IHierarchyNode node, final IHierarchyBuilder builder) { - final String superExpectation = super.internalToExpectation(node, builder); - if ((node instanceof XtextCallHierarchyNode)) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("grammar: "); - IEObjectDescription _grammarDescription = ((XtextCallHierarchyNode)node).getGrammarDescription(); - _builder.append(_grammarDescription); - _builder.newLineIfNotEmpty(); - _builder.append(superExpectation); - _builder.newLineIfNotEmpty(); - return _builder.toString(); - } - return superExpectation; - } -}