Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Content assist test with import
Content assist test with import [message #1810664] Thu, 15 August 2019 13:25 Go to next message
Edmundo López Bóbeda is currently offline Edmundo López BóbedaFriend
Messages: 26
Registered: October 2012
Junior Member
Hello,

I'm trying to create a content assist test but the test does not take into account the imported files. I found that xtext is loading both resources but not doing the linking, and thus my autocomplete (which depends on the linking) fails. How can I force the linking of the resources in the test. Below is the failing test. Any ideas of what can be wrong?

@RunWith(XtextRunner)
@InjectWith(MappingUiInjectorProvider)
class PathContentAssistTest extends AbstractContentAssistTest {

    @Inject
    ResourceSetManager resourceSetManager
    
    protected var ResourceSet testModel

	val mapModel = ''' my model (..) '''



	@Test
	def void testComplete() {
		
		val model = '''
		SimpleMapping 1.0.0
		
		import "MAP.model"
		
		VirtualMappingWithAggregationTest for input @MAP.OtherOutputEntity
		
		output @MAP.VirtualModelOutputEntity
		
		
		 with @MAP.OtherOutputEntity as myInput {
		 	outputBoolean = myInput.otherBoolean.outputBoolean
		}'''
			  	
		newBuilder()
			.append(model)
			.assertTextAtCursorPosition(model.indexOf("otherBoolean"), "\"Column\"", "\"otherBoolean\"", "\"otherDate\"")
	}
	
	def addResource(XtextResourceSet set, String modelName, String modelContent) {
		val inputStream = new StringInputStream(modelContent)
		val resource = set.createResource(URI::createURI(modelName))
		resource.load(inputStream, null)
	}
	
	
	
	override protected initializeTypeProvider(XtextResourceSet set) {
		addResource(set, "test.model", mapModel)
		super.initializeTypeProvider(set)
	}
	
}
Re: Content assist test with import [message #1810669 is a reply to message #1810664] Thu, 15 August 2019 16:37 Go to previous messageGo to next message
Tamas Miklossy is currently offline Tamas MiklossyFriend
Messages: 53
Registered: February 2016
Member
An example for that can be found under https://github.com/itemis/itemis-blog/blob/combining-emf-models-with-xtext-dsls/org.eclipse.xtext.example.fowlerdsl.ui.tests/src/org/eclipse/xtext/example/fowlerdsl/ui/tests/StatemachineContentAssist2Test.xtend
Re: Content assist test with import [message #1810676 is a reply to message #1810669] Thu, 15 August 2019 19:11 Go to previous message
Edmundo López Bóbeda is currently offline Edmundo López BóbedaFriend
Messages: 26
Registered: October 2012
Junior Member
Hello,

Thanks for the example, I managed to adapt it to my needs.

Best regards,

Edmundo López Bóbeda
Previous Topic:Mwe2Launcher - Cannot create a resource with ANT
Next Topic:Code generation
Goto Forum:
  


Current Time: Thu Sep 19 02:41:28 GMT 2019

Powered by FUDForum. Page generated in 0.01764 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top