-
Notifications
You must be signed in to change notification settings - Fork 0
/
EmfParsleyDslResourceDescriptionStrategy.xtend
41 lines (37 loc) · 1.51 KB
/
EmfParsleyDslResourceDescriptionStrategy.xtend
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*******************************************************************************
* Copyright (c) 2016 RCP Vision (http://www.rcp-vision.com) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Lorenzo Bettini - initial API and implementation
*******************************************************************************/
package org.eclipse.emf.parsley.dsl.scoping
import com.google.inject.Singleton
import org.eclipse.emf.ecore.EObject
import org.eclipse.emf.parsley.dsl.model.ViewSpecification
import org.eclipse.xtext.resource.EObjectDescription
import org.eclipse.xtext.resource.IEObjectDescription
import org.eclipse.xtext.util.IAcceptor
import org.eclipse.xtext.xbase.resource.XbaseResourceDescriptionStrategy
/**
* We need to index part specification ids to avoid duplicate ids across
* files in the same project.
*
* @author Lorenzo Bettini - initial API and implementation
*/
@Singleton
class EmfParsleyDslResourceDescriptionStrategy extends XbaseResourceDescriptionStrategy {
override createEObjectDescriptions(EObject elem, IAcceptor<IEObjectDescription> acceptor) {
if (elem instanceof ViewSpecification) {
val id = elem.id
if (id != null) {
acceptor.accept(EObjectDescription.create(id, elem))
return true
}
}
return super.createEObjectDescriptions(elem, acceptor)
}
}